1 /* ResidualVM - A 3D game interpreter 2 * 3 * ResidualVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the AUTHORS 5 * file distributed with this source distribution. 6 * 7 * Additional copyright for this file: 8 * Copyright (C) 1999-2000 Revolution Software Ltd. 9 * This code is based on source code created by Revolution Software, 10 * used with permission. 11 * 12 * This program is free software; you can redistribute it and/or 13 * modify it under the terms of the GNU General Public License 14 * as published by the Free Software Foundation; either version 2 15 * of the License, or (at your option) any later version. 16 * 17 * This program is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU General Public License for more details. 21 * 22 * You should have received a copy of the GNU General Public License 23 * along with this program; if not, write to the Free Software 24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 25 * 26 */ 27 28 #ifndef ICB_PSX_PCHMD_H 29 #define ICB_PSX_PCHMD_H 30 31 #include "engines/icb/gfx/psx_pcdefines.h" 32 33 namespace ICB { 34 35 const int32 HMD_FUS3 = 0x00000048; // Flat, Un-textured, Self-Luminous Triangle 36 const int32 HMD_FTS3 = 0x00000049; // Flat, Textured, Self-Luminous Triangle 37 const int32 HMD_GUS3 = 0x0000004c; // Gouraud, Un-textured, Self-Luminous Triangle 38 const int32 HMD_GTS3 = 0x0000004d; // Gouraud, Textured, Self-Luminous Triangle 39 40 const int32 HMD_FUL3 = 0x00000008; // Flat, Un-textured, Lit Triangle 41 const int32 HMD_FTL3 = 0x00000009; // Flat, Textured, Lit Triangle 42 const int32 HMD_GUL3 = 0x0000000c; // Gouraud, Un-textured, Lit Triangle 43 const int32 HMD_GTL3 = 0x0000000d; // Gouraud, Textured, Lit Triangle 44 45 const int32 TRIANGLE = 0x00000666; // Just 3 vertices for shadow polygon 46 47 const int32 HMD_FUS3_SIZE = 3; 48 const int32 HMD_GUS3_SIZE = 5; 49 const int32 HMD_FTS3_SIZE = 5; 50 const int32 HMD_GTS3_SIZE = 7; 51 const int32 HMD_FUL3_SIZE = 3; 52 const int32 HMD_GUL3_SIZE = 4; 53 const int32 HMD_FTL3_SIZE = 5; 54 const int32 HMD_GTL3_SIZE = 6; 55 const int32 TRIANGLE_SIZE = 2; 56 57 int32 decodeHMDpolygon(uint32 primType, uint32 pcplatform, uint32 *&pp, uint32 &code0, uint32 &r0, uint32 &g0, uint32 &b0, uint32 &code1, uint32 &r1, uint32 &g1, uint32 &b1, uint32 &code2, uint32 &r2, 58 uint32 &g2, uint32 &b2, uint32 &u0, uint32 &v0, uint32 &u1, uint32 &v1, uint32 &u2, uint32 &v2, uint32 &cba, uint32 &cx, uint32 &cy, uint32 &tsb, uint32 &tp, uint32 &n0, uint32 &vert0, 59 uint32 &n1, uint32 &vert1, uint32 &n2, uint32 &vert2, uint32 dump); 60 61 // Handy structures for decoding polygon information 62 63 // Flat, Un-textured, Self-Luminous Triangle 64 // Each polygon is 3 32-bit WORDS 65 // Bit 31 ----> Bit 0 66 // 67 // 8-bits | 8-bits | 8-bits | 8-bits 68 // 0x20 | Blue | Green | Red 69 // 16-bits | 8-bits | 8-bits 70 // -------------------------- 71 // vp1 | vp0 72 // pad | vp2 73 typedef struct PolyFUS3 { 74 uint8 r0, g0, b0, code0; 75 uint16 vp0, vp1; 76 uint16 vp2, pad; 77 } PolyFUS3; 78 79 // Gouraud, Un-textured, Self-Luminous Triangle 80 // Each polygon is 5 32-bit WORDS 81 // Bit 31 ----> Bit 0 82 // 83 // 8-bits | 8-bits | 8-bits | 8-bits 84 // 0x30 | Blue0 | Green0 | Red0 85 // 0x30 | Blue1 | Green1 | Red1 86 // 0x30 | Blue2 | Green2 | Red2 87 // 16-bits | 8-bits | 8-bits 88 // -------------------------- 89 // vp1 | vp0 90 // pad | vp2 91 typedef struct PolyGUS3 { 92 uint8 r0, g0, b0, code0; 93 uint8 r1, g1, b1, code1; 94 uint8 r2, g2, b2, code2; 95 uint16 vp0, vp1; 96 uint16 vp2, pad; 97 } PolyGUS3; 98 99 // Flat, Textured, Self-Luminous Triangle 100 // Each polygon is 5 32-bit WORDS 101 // Structure is : 102 // Bit 31 ----> Bit 0 103 // 104 // 8-bits | 8-bits | 8-bits | 8-bits 105 // 0x24 | Blue | Green | Red 106 // 16-bits | 8-bits | 8-bits 107 // -------------------------- 108 // cba | v0 | u0 109 // tsb | v1 | u1 110 // vp0 | v2 | u2 111 // -------------------------- 112 // vp2 | vp1 113 typedef struct PolyFTS3 { 114 uint8 r0, g0, b0, code0; 115 uint8 u0, v0; 116 uint16 cba; 117 uint8 u1, v1; 118 uint16 tsb; 119 uint8 u2, v2; 120 uint16 vp0; 121 uint16 vp1, vp2; 122 } PolyFTS3; 123 124 // Gouraud, Textured, Self-Luminous Triangle 125 // Each polygon is 7 32-bit WORDS 126 // Structure is : 127 // Bit 31 ----> Bit 0 128 // 129 // 8-bits | 8-bits | 8-bits | 8-bits 130 // 0x34 | Blue0 | Green0 | Red0 131 // 0x34 | Blue1 | Green1 | Red1 132 // 0x34 | Blue2 | Green2 | Red2 133 // 16-bits | 8-bits | 8-bits 134 // -------------------------- 135 // cba | v0 | u0 136 // tsb | v1 | u1 137 // vp0 | v2 | u2 138 // -------------------------- 139 // vp2 | vp2 140 typedef struct PolyGTS3 { 141 uint8 r0, g0, b0, code0; 142 uint8 r1, g1, b1, code1; 143 uint8 r2, g2, b2, code2; 144 uint8 u0, v0; 145 uint16 cba; 146 uint8 u1, v1; 147 uint16 tsb; 148 uint8 u2, v2; 149 uint16 vp0; 150 uint16 vp1, vp2; 151 } PolyGTS3; 152 153 // Flat, Un-textured, Lit Triangle 154 // Each polygon is 3 32-bit WORDS 155 // Bit 31 ----> Bit 0 156 // 157 // 8-bits | 8-bits | 8-bits | 8-bits 158 // 0x20 | Blue | Green | Red 159 // 16-bits | 16-bits 160 // ------------------ 161 // vp0 | np0 162 // vp2 | vp1 163 typedef struct PolyFUL3 { 164 uint8 r0, g0, b0, code0; 165 uint16 np0, vp0; 166 uint16 vp1, vp2; 167 } PolyFUL3; 168 169 // Gouraud, Un-textured, Lit Triangle 170 // Each polygon is 4 32-bit WORDS 171 // Bit 31 ----> Bit 0 172 // 173 // 8-bits | 8-bits | 8-bits | 8-bits 174 // 0x20 | Blue | Green | Red 175 // 16-bits | 8-bits | 8-bits 176 // -------------------------- 177 // vp0 | np0 178 // vp1 | np1 179 // vp2 | np2 180 typedef struct PolyGUL3 { 181 uint8 r0, g0, b0, code0; 182 uint16 np0, vp0; 183 uint16 np1, vp1; 184 uint16 np2, vp2; 185 } PolyGUL3; 186 187 // Flat, Textured, Lit Triangle 188 // Each polygon is 5 32-bit WORDS 189 // Structure is : 190 // Bit 31 ----> Bit 0 191 // 192 // 16-bits | 8-bits | 8-bits 193 // -------------------------- 194 // cba | v0 | u0 195 // tsb | v1 | u1 196 // pad | v2 | u2 197 // -------------------------- 198 // vp0 | np0 199 // vp2 | vp1 200 typedef struct PolyFTL3 { 201 uint8 u0, v0; 202 uint16 cba; 203 uint8 u1, v1; 204 uint16 tsb; 205 uint8 u2, v2; 206 uint16 pad; 207 uint16 np0, vp0; 208 uint16 vp1, vp2; 209 } PolyFTL3; 210 211 // Gouraud, Textured, Lit Triangle 212 // Each polygon is 6 32-bit WORDS 213 // Structure is : 214 // Bit 31 ----> Bit 0 215 // 216 // 16-bits | 8-bits | 8-bits 217 // -------------------------- 218 // cba | v0 | u0 219 // tsb | v1 | u1 220 // pad | v2 | u2 221 // -------------------------- 222 // vp0 | np0 223 // vp1 | np1 224 // vp2 | np2 225 // 226 typedef struct PolyGTL3 { 227 uint8 u0, v0; 228 uint16 cba; 229 uint8 u1, v1; 230 uint16 tsb; 231 uint8 u2, v2; 232 uint16 pad; 233 uint16 np0, vp0; 234 uint16 np1, vp1; 235 uint16 np2, vp2; 236 } PolyGTL3; 237 238 #if (_PSX == 0) || (_PSX_ON_PC == 1) 239 240 void MatrixToAngles(MATRIX *A, SVECTOR *rotvec); 241 float AngleOfVector(float x, float y); 242 243 #endif // #if (_PSX==0) || (_PSX_ON_PC==1) 244 245 } // End of namespace ICB 246 247 #endif // #ifndef PSX_PCHMD_H 248