gte.txt (49365B)
1 ========================================================================== 2 GTE.txt - Documentation & Explanation. 3 ========================================================================== 4 5 Disclaimer. 6 -------------------------------------------------------------------------- 7 This document is a collection of all info on the GTE i could find and my 8 own notes. Most of this is the result of experiment, so not all info might 9 be correct. This document is most probably not complete, and not all 10 capabilities and quirks of the GTE are documented. No responsibility is 11 taken for anything that might occur using the information in this document. 12 13 -------------------------------------------------------------------------- 14 Introduction. 15 -------------------------------------------------------------------------- 16 The Geometry Transformation Engine (GTE) is the heart of all 3d 17 calculations on the psx. The GTE has specialised functions for perspective 18 transformations, light sourcing and the like, and is much faster than the 19 CPU on these operations. It is mounted as the second coprocessor and as 20 such has no physical address in the memory of the psx. All control is done 21 through special instructions. 22 23 -------------------------------------------------------------------------- 24 Basic mathematics 25 -------------------------------------------------------------------------- 26 The GTE is basicly an engine for vector mathematics, so some knowledge 27 of that area is vital for correct usage of the GTE. I will not delve to 28 deeply in that area, as that's beyond the scope of this text, but i'll 29 introduce some concepts. 30 31 The basic representation of a point(vertex) in 3d space is through a vector 32 of the sort [X,Y,Z]. In GTE operation there's basicly two kinds of these, 33 vectors of variable length and vectors of a unit length of 1.0, called 34 normal vectors. The first is used to decribe a locations and translations 35 in 3d space, the second to describe a direction. 36 37 Rotation of vertices is performed by multiplying the vector of the vertex 38 with a rotation matrix. The rotation matrix is a 3x3 matrix consisting of 39 3 normal vectors which are orthogonal to each other. (It's actually the 40 matrix which describes the coordinate system in which the vertex is located 41 in relation to the unit coordinate system. See a maths book for more 42 details.) This matrix is derived from rotation angles as follows: 43 44 (s? = sin(?), c? = cos(?)) 45 46 Rotation angle A Rotation angle B Rotation angle C 47 about X axis: about Y axis: about Z axis: 48 49 | 1 0 0| | cB 0 sB| | cC -sC 0| 50 | 0 cA -sA| | 0 1 0| | sC cC 0| 51 | 0 sA cA| |-sB 0 cB| | 0 0 1| 52 53 Rotation about multiple axis can be done by multiplying these matrices 54 with eachother. Note that the order in which this multiplication is done 55 *IS* important. The GTE has no sine or cosine functions, so the calculation 56 of these must be done by the CPU. 57 58 Translation is the simple addition of two vectors, relocating the vertex 59 within its current coordinate system. Needless to say the order in which 60 translation and rotation occur for a vector is important. 61 62 -------------------------------------------------------------------------- 63 Brief Function descriptions 64 -------------------------------------------------------------------------- 65 RTPS/RTPT Rotate, translate and perpective transformation. 66 67 These two functions perform the final 3d calculations on one or three 68 vertices at once. The points are first multiplied with a rotation matrix(R), 69 and after that translated(TR). Finally a perspective transformation is 70 applied, which results in 2d screen coordinates. It also returns an 71 interpolation value to be used with the various depth cueing instructions. 72 -------------------------------------------------------------------------- 73 MVMVA Matrix & Vector multiplication and addition. 74 75 Multiplies a vector with either the rotation matrix, the light matrix or 76 the color matrix and then adds the translation vector or background color 77 vector. 78 -------------------------------------------------------------------------- 79 DCPL Depth cue light color 80 81 First calculates a color from a light vector(normal vector of a plane 82 multiplied with the light matrix and zero limited) and a provided RGB value. 83 Then performs depth cueing by interpolating between the far color vector and 84 the newfound color. 85 -------------------------------------------------------------------------- 86 DPCS/DPCT Depth cue single/triple 87 88 Performs depth cueing by interpolating between a color and the far color 89 vector on one or three colors. 90 -------------------------------------------------------------------------- 91 INTPL Interpolation 92 93 Interpolates between a vector and the far color vector. 94 -------------------------------------------------------------------------- 95 SQR Square 96 97 Calculates the square of a vector. 98 -------------------------------------------------------------------------- 99 NCS/NCT Normal Color 100 101 Calculates a color from the normal of a point or plane and the light 102 sources and colors. The basic color of the plane or point the normal 103 refers to is assumed to be white. 104 -------------------------------------------------------------------------- 105 NCDS/NCDT Normal Color Depth Cue. 106 107 Same as NCS/NCT but also performs depth cueing (like DPCS/DPCT) 108 -------------------------------------------------------------------------- 109 NCCS/NCCT 110 111 Same NCS/NCT, but the base color of the plane or point is taken into 112 account. 113 -------------------------------------------------------------------------- 114 CDP 115 116 A color is calculated from a light vector (base color is assumed to be 117 white) and depth cueing is performed (like DPCS). 118 -------------------------------------------------------------------------- 119 CC 120 121 A color is calculated from a light vector and a base color. 122 -------------------------------------------------------------------------- 123 NCLIP 124 125 Calculates the outer product of three 2d points.(ie. 3 vertices which 126 define a plane after projection.) 127 128 The 3 vertices should be stored clockwise according to the visual point: 129 130 Z+ 131 / 132 /____ X+ 133 | 134 | 135 Y+ 136 137 If this is so, the result of this function will be negative if we are 138 facing the backside of the plane. 139 -------------------------------------------------------------------------- 140 AVSZ3/AVSZ4 141 142 Adds 3 or 4 z values together and multplies them by a fixed point value. 143 This value is normally chosen so that this function returns the average 144 of the z values (usually further divided by 2 or 4 for easy adding to the 145 OT) 146 -------------------------------------------------------------------------- 147 OP 148 149 Calculates the outer product of 2 vectors. 150 -------------------------------------------------------------------------- 151 GPF 152 153 Multiplies 2 vectors. Also returns the result as 24bit rgb value. 154 -------------------------------------------------------------------------- 155 GPL 156 157 Multiplies a vector with a scalar and adds the result to another vector. 158 Also returns the result as 24bit rgb value. 159 160 -------------------------------------------------------------------------- 161 GTE Operation. 162 -------------------------------------------------------------------------- 163 Instructions. 164 -------------------------------------------------------------------------- 165 The CPU has six special load and store instructions for the GTE registers, 166 and an instruction to issue commands to the coprocessor. 167 168 rt CPU register 0-31 169 gd GTE data register 0-31 170 gc GTE control register 0-31 171 imm 16 bit immediate value 172 base CPU register 0-31 173 imm(base) address pointed to by base + imm. 174 b25 25 bit wide data field. 175 176 LWC2 gd, imm(base) stores value at imm(base) in gte data register gd. 177 SWC2 gd, imm(base) stores gte data register at imm(base). 178 MTC2 rt, gd stores register rt in GTE data register gd. 179 MFC2 rt, gd stores GTE data register gd in register rt. 180 CTC2 rt, gc stores register rt in GTE control register gc. 181 CFC2 rt, gc stores GTE control register in register rt. 182 183 COP2 b25 Issues a GTE command. 184 185 Gte load and store instructions have a delay of 2 instructions, for any 186 gte commands or operations accessing that register. 187 188 -------------------------------------------------------------------------- 189 Registers. 190 -------------------------------------------------------------------------- 191 The GTE has 32 data registers, and 32 control registers,each 32 bits wide. 192 The following list describes their common use and format. Note in some 193 functions format is different from the one that's given here. The numbers 194 in the format fields are the signed, integer and fractional parts of the 195 field. So 1,3,12 means signed(1 bit), 3 bits integral part, 12 bits 196 fractional part. 197 198 Control registers: 199 No. Name |31-24 23-16|15-08 07-01| Description 200 0 R11R12 |R12 1, 3,12|R11 1, 3,12| Rotation matrix elements 11, 12 201 1 R13R21 |R21 1, 3,12|R13 1, 3,12| Rotation matrix elements 13, 21 202 2 R22R23 |R23 1, 3,12|R22 1, 3,12| Rotation matrix elements 22, 23 203 3 R31R32 |R32 1, 3,12|R31 1, 3,12| Rotation matrix elements 31, 32 204 4 R33 | 0|R33 1, 3,12| Rotation matrix element 33 205 5 TRX |TRX 1,31, 0 | Translation vector X 206 6 TRY |TRY 1,31, 0 | Translation vector Y 207 7 TRZ |TRZ 1,31, 0 | Translation vector Z 208 8 L11L12 |L12 1, 3,12|L11 1, 3,12| Light source matrix elements 11, 12 209 9 L13L21 |L21 1, 3,12|L13 1, 3,12| Light source matrix elements 13, 21 210 10 L22L23 |L23 1, 3,12|L22 1, 3,12| Light source matrix elements 22, 23 211 11 L31L32 |L32 1, 3,12|L31 1, 3,12| Light source matrix elements 31, 32 212 12 L33 | 0|L33 1, 3,12| Light source matrix element 33 213 13 RBK |RBK 1,19,12 | Background color red component. 214 14 GBK |GBK 1,19,12 | Background color green component. 215 15 BBK |RBK 1,19,12 | Background color blue component. 216 16 LR1LR2 |LR2 1, 3,12|LR1 1, 3,12| Light color matrix source 1&2 red comp. 217 17 LR3LG1 |LG1 1, 3,12|LR3 1, 3,12| Light color matrix source 3 red, 1 green 218 18 LG2LG3 |LG3 1, 3,12|LG2 1, 3,12| Light color matrix source 2&3 green comp. 219 19 LB1LB2 |LB2 1, 3,12|LB1 1, 3,12| Light color matrix source 1&2 blue comp. 220 20 LB3 | 0|LB3 1, 3,12| Light color matrix source 3 blue component. 221 21 RFC |RFC 1,27, 4 | Far color red component. 222 22 GFC |GFC 1,27, 4 | Far color green component. 223 23 BFC |BFC 1,27, 4 | Far color blue component. 224 24 OFX |OFX 1,15,16 | Screen offset X 225 25 OFY |OFY 1,15,16 | Screen offset Y 226 26 H | 0|H 0,16, 0| Projection plane distance. 227 27 DQA | 0|DQA 1, 7, 8| Depth queing parameter A.(coefficient.) 228 28 DQB | 0|DQB 1, 7,24| Depth queing parameter B.(offset.) 229 29 ZSF3 | 0|ZSF3 1,3,12| Z3 average scale factor (normally 1/3) 230 30 ZSF4 | 0|ZSF4 1,3,12| Z4 average scale factor (normally 1/4) 231 31 FLAG |See gte funcions | Returns any calculation errors. 232 233 Data registers: 234 No. Name rw|31-24 23-16|15-08 07-01| Description 235 0 VXY0 rw|VY0 |VX0 | Vector 0 X and Y. 1,3,12 or 1,15,0 236 1 VZ0 rw| 0|VZ0 | Vector 0 Z. 237 2 VXY1 rw|VY1 |VX1 | Vector 1 X and Y. 1,3,12 or 1,15,0 238 3 VZ1 rw| 0|VZ1 | Vector 1 Z. 239 4 VXY2 rw|VY2 |VX2 | Vector 2 X and Y. 1,3,12 or 1,15,0 240 5 VZ2 rw| 0|VZ2 | Vector 2 Z. 241 6 RGB rw|Code |B |G |R | Rgb value. Code is passed, but not used in calc. 242 7 OTZ r | |OTZ 0,15, 0| Z Average value. 243 8 IR0 rw|Sign |IR0 1, 3,12| Intermediate value 0. *1 244 9 IR1 rw|Sign |IR0 1, 3,12| Intermediate value 1. *1 245 10 IR2 rw|Sign |IR0 1, 3,12| Intermediate value 2. *1 246 11 IR3 rw|Sign |IR0 1, 3,12| Intermediate value 3. *1 247 12 SXY0 rw|SY0 1,15, 0|SX0 1,15, 0| Screen XY coordinate fifo. *2 248 13 SXY1 rw|SY1 1,15, 0|SX1 1,15, 0| 249 14 SXY2 rw|SY2 1,15, 0|SX2 1,15, 0| 250 15 SXYP rw|SYP 1,15, 0|SXP 1,15, 0| 251 16 SZ0 rw| 0|SZ0 0,16, 0| Screen Z fifo. *2 252 17 SZ1 rw| 0|SZ1 0,16, 0| 253 18 SZ2 rw| 0|SZ2 0,16, 0| 254 19 SZ3 rw| 0|SZ3 0,16, 0| 255 20 RGB0 rw|CD0 |B0 |G0 |R0 | Characteristic color fifo. *2 256 21 RGB1 rw|CD1 |B1 |G1 |R1 | 257 22 RGB2 rw|CD2 |B2 |G2 |R2 | CD2 is the bit pattern of currently executed function 258 23 (RES1) | | Prohibited 259 24 MAC0 rw|MAC0 1,31,0 | Sum of products value 0 260 25 MAC1 rw|MAC1 1,31,0 | Sum of products value 1 261 26 MAC2 rw|MAC2 1,31,0 | Sum of products value 2 262 27 MAC3 rw|MAC3 1,31,0 | Sum of products value 3 263 28 IRGB w| |IB |IG |IR | *3 264 29 ORGB r | |OB |OG |OR | *4 265 30 LZCS w|LZCS 1,31,0 | Leading zero count source data.*5 266 31 LZCR r |LZCR 0,6,0 | Leading zero count result.*5 267 268 *1) The specified format is the format which GTE functions output to these 269 registers. The input format is mostly (1,19,12) 270 271 *2) The SXYx, SZx and RGBx are first in first out registers (fifo). The last 272 calculation result is stored in the last register, and previous results 273 are stored in previous registers. So for example when a new SXY value 274 is obtained the following happens: 275 SXY0 = SXY1 276 SXY1 = SXY2 277 SXY2 = SXYP 278 SXYP = result. 279 280 *3) IRGB: 281 |31 15|14-10| 9- 5| 4- 0| 282 | 0|IR |IG |IB | 283 When writing a value to IRGB the following happens: 284 IR1 = IR format converted to (1,11,4) 285 IR2 = IG format converted to (1,11,4) 286 IR3 = IB format converted to (1,11,4) 287 288 *4) ORGB: 289 |31 15|14-10| 9- 5| 4- 0| 290 | 0|IR |IG |IB | 291 When writing a value to IRGB the following happens: 292 IR = (IR1>>7) &$1f 293 IG = (IR2>>7) &$1f 294 IB = (IR3>>7) &$1f 295 *5) Reading LZCR returns the leading 0 count of LZCS if LZCS is positive 296 and the leading 1 count of LZCS if LZCS is negative. 297 298 -------------------------------------------------------------------------- 299 Programming Considerations. 300 -------------------------------------------------------------------------- 301 Before use the GTE must be turned on. The GTE has bit 30 allocated to it in 302 the status register of the stystem control coprocessor (cop0). Before any 303 GTE instruction is used, this bit must be set. 304 305 GTE instructions and functions should not be used in 306 - Delay slots of jumps and branches 307 - Event handlers or interrupts. 308 309 If an instruction that reads a GTE register or a GTE command is executed 310 before the current GTE command is finished, the cpu will hold until the 311 instruction has finished. The number of cycles each GTE instruction takes 312 is in the command list. 313 314 -------------------------------------------------------------------------- 315 Function Operation. 316 -------------------------------------------------------------------------- 317 This part describes the actual calculations performed by the various GTE 318 functions. The first line contains the name of the function, the number 319 of cycles it takes and a brief description. The second line any fields that 320 may be set in the opcode and in the third line is the actual opcode. See 321 the end of the list for the fields and their descriptions. Then follows a 322 list of all registers which are needed in the calculation under the 'in', 323 and a list of registers which modified under the 'out' with a brief 324 description and the format of the data. Next follows the calculation which 325 is performed after initiating the function. The format field left is the 326 size in which the data is stored, the format field on the right contains 327 the format in which the calculation is performed. At certain points in the 328 calculation checks and limitations are done and their results stored in the 329 flag register, see the table below. They are identified with the code from 330 the second column of the table directly followed by square brackets 331 enclosing the part of the calculation on which the check is performed. The 332 additional Lm_ identifier means the value is limited to the bottom or 333 ceiling of the check if it exceeds the boundary. 334 335 bit description 336 31 Checksum. 337 30 A1 Result larger than 43 bits and positive 338 29 A2 Result larger than 43 bits and positive 339 28 A3 Result larger than 43 bits and positive 340 27 A1 Result larger than 43 bits and negative 341 26 A2 Result larger than 43 bits and negative 342 25 A3 Result larger than 43 bits and negative 343 24 B1 Value negative(lm=1) or larger than 15 bits(lm=0) 344 23 B2 Value negative(lm=1) or larger than 15 bits(lm=0) 345 22 B3 Value negative(lm=1) or larger than 15 bits(lm=0) 346 21 C1 Value negative or larger than 8 bits. 347 20 C2 Value negative or larger than 8 bits. 348 19 C3 Value negative or larger than 8 bits. 349 18 D Value negative or larger than 16 bits. 350 17 E Divide overflow. (quotient > 2.0) 351 16 F Result larger than 31 bits and positive. 352 15 F Result larger than 31 bits and negative. 353 14 G1 Value larger than 10 bits. 354 13 G2 Value larger than 10 bits. 355 12 H Value negative or larger than 12 bits. 356 357 358 -------------------------------------------------------------------------- 359 RTPS 15 Perspective transformation 360 Fields: none 361 Opcode: cop2 $0180001 362 363 In: V0 Vector to transform. [1,15,0] 364 R Rotation matrix [1,3,12] 365 TR Translation vector [1,31,0] 366 H View plane distance [0,16,0] 367 DQA Depth que interpolation values. [1,7,8] 368 DQB [1,7,8] 369 OFX Screen offset values. [1,15,16] 370 OFY [1,15,16] 371 Out: SXY fifo Screen XY coordinates.(short) [1,15,0] 372 SZ fifo Screen Z coordinate.(short) [0,16,0] 373 IR0 Interpolation value for depth queing. [1,3,12] 374 IR1 Screen X (short) [1,15,0] 375 IR2 Screen Y (short) [1,15,0] 376 IR3 Screen Z (short) [1,15,0] 377 MAC1 Screen X (long) [1,31,0] 378 MAC2 Screen Y (long) [1,31,0] 379 MAC3 Screen Z (long) [1,31,0] 380 381 Calculation: 382 [1,31,0] MAC1=A1[TRX + R11*VX0 + R12*VY0 + R13*VZ0] [1,31,12] 383 [1,31,0] MAC2=A2[TRY + R21*VX0 + R22*VY0 + R23*VZ0] [1,31,12] 384 [1,31,0] MAC3=A3[TRZ + R31*VX0 + R32*VY0 + R33*VZ0] [1,31,12] 385 [1,15,0] IR1= Lm_B1[MAC1] [1,31,0] 386 [1,15,0] IR2= Lm_B2[MAC2] [1,31,0] 387 [1,15,0] IR3= Lm_B3[MAC3] [1,31,0] 388 SZ0<-SZ1<-SZ2<-SZ3 389 [0,16,0] SZ3= Lm_D(MAC3) [1,31,0] 390 SX0<-SX1<-SX2, SY0<-SY1<-SY2 391 [1,15,0] SX2= Lm_G1[F[OFX + IR1*(H/SZ)]] [1,27,16] 392 [1,15,0] SY2= Lm_G2[F[OFY + IR2*(H/SZ)]] [1,27,16] 393 [1,31,0] MAC0= F[DQB + DQA * (H/SZ)] [1,19,24] 394 [1,15,0] IR0= Lm_H[MAC0] [1,31,0] 395 396 Notes: 397 Z values are limited downwards at 0.5 * H. For smaller z values you'll have 398 write your own routine. 399 -------------------------------------------------------------------------- 400 RTPT 23 Perspective Transformation on 3 points. 401 Fields none 402 opcode cop2 $0280030 403 404 in V0 Vector to transform. [1,15,0] 405 V1 [1,15,0] 406 V2 [1,15,0] 407 R Rotation matrix [1,3,12] 408 TR Translation vector [1,31,0] 409 H View plane distance [0,16,0] 410 DQA Depth que interpolation values. [1,7,8] 411 DQB [1,7,8] 412 OFX Screen offset values. [1,15,16] 413 OFY [1,15,16] 414 out SXY fifo Screen XY coordinates.(short) [1,15,0] 415 SZ fifo Screen Z coordinate.(short) [0,16,0] 416 IR0 Interpolation value for depth queing. [1,3,12] 417 IR1 Screen X (short) [1,15,0] 418 IR2 Screen Y (short) [1,15,0] 419 IR3 Screen Z (short) [1,15,0] 420 MAC1 Screen X (long) [1,31,0] 421 MAC2 Screen Y (long) [1,31,0] 422 MAC3 Screen Z (long) [1,31,0] 423 424 Calculation: Same as RTPS, but repeats for V1 and V2. 425 -------------------------------------------------------------------------- 426 MVMVA 8 Multiply vector by matrix and vector addition. 427 Fields: sf,mx,v,cv,lm 428 Opcode: cop2 $0400012 429 430 in: V0/V1/V2/IR Vector v0, v1, v2 or [IR1,IR2,IR3] 431 R/LLM/LCM Rotation, light or color matrix. [1,3,12] 432 TR/BK Translation or background color vector. 433 out: [IR1,IR2,IR3] Short vector 434 [MAC1,MAC2,MAC3] Long vector 435 436 Calculation: 437 MX = matrix specified by mx 438 V = vector specified by v 439 CV = vector specified by cv 440 441 442 MAC1=A1[CV1 + MX11*V1 + MX12*V2 + MX13*V3] 443 MAC2=A2[CV2 + MX21*V1 + MX22*V2 + MX23*V3] 444 MAC3=A3[CV3 + MX31*V1 + MX32*V2 + MX33*V3] 445 IR1=Lm_B1[MAC1] 446 IR2=Lm_B2[MAC2] 447 IR3=Lm_B3[MAC3] 448 449 Notes: 450 The cv field allows selection of the far color vector, but this vector 451 is not added correctly by the GTE. 452 -------------------------------------------------------------------------- 453 DCPL 8 Depth Cue Color light 454 Fields: none 455 Opcode: cop2 $0680029 456 In: RGB Primary color. R,G,B,CODE [0,8,0] 457 IR0 interpolation value. [1,3,12] 458 [IR1,IR2,IR3] Local color vector. [1,3,12] 459 CODE Code value from RGB. CODE [0,8,0] 460 FC Far color. [1,27,4] 461 Out: RGBn RGB fifo Rn,Gn,Bn,CDn [0,8,0] 462 [IR1,IR2,IR3] Color vector [1,11,4] 463 [MAC1,MAC2,MAC3] Color vector [1,27,4] 464 465 Calculation: 466 [1,27,4] MAC1=A1[R*IR1 + IR0*(Lm_B1[RFC - R * IR1])] [1,27,16] 467 [1,27,4] MAC2=A2[G*IR2 + IR0*(Lm_B1[GFC - G * IR2])] [1,27,16] 468 [1,27,4] MAC3=A3[B*IR3 + IR0*(Lm_B1[BFC - B * IR3])] [1,27,16] 469 [1,11,4] IR1=Lm_B1[MAC1] [1,27,4] 470 [1,11,4] IR2=Lm_B2[MAC2] [1,27,4] 471 [1,11,4] IR3=Lm_B3[MAC3] [1,27,4] 472 [0,8,0] Cd0<-Cd1<-Cd2<- CODE 473 [0,8,0] R0<-R1<-R2<- Lm_C1[MAC1] [1,27,4] 474 [0,8,0] G0<-G1<-G2<- Lm_C2[MAC2] [1,27,4] 475 [0,8,0] B0<-B1<-B2<- Lm_C3[MAC3] [1,27,4] 476 -------------------------------------------------------------------------- 477 DPCS 8 Depth Cueing. 478 Fields: none 479 Opcode: cop2 $0780010 480 481 In: IR0 Interpolation value [1,3,12] 482 RGB Color R,G,B,CODE [0,8,0] 483 FC Far color RFC,GFC,BFC [1,27,4] 484 Out: RGBn RGB fifo Rn,Gn,Bn,CDn [0,8,0] 485 [IR1,IR2,IR3] Color vector [1,11,4] 486 [MAC1,MAC2,MAC3] Color vector [1,27,4] 487 488 Calculations: 489 [1,27,4] MAC1=A1[(R + IR0*(Lm_B1[RFC - R])] [1,27,16][lm=0] 490 [1,27,4] MAC2=A2[(G + IR0*(Lm_B1[GFC - G])] [1,27,16][lm=0] 491 [1,27,4] MAC3=A3[(B + IR0*(Lm_B1[BFC - B])] [1,27,16][lm=0] 492 [1,11,4] IR1=Lm_B1[MAC1] [1,27,4][lm=0] 493 [1,11,4] IR2=Lm_B2[MAC2] [1,27,4][lm=0] 494 [1,11,4] IR3=Lm_B3[MAC3] [1,27,4][lm=0] 495 [0,8,0] Cd0<-Cd1<-Cd2<- CODE 496 [0,8,0] R0<-R1<-R2<- Lm_C1[MAC1] [1,27,4] 497 [0,8,0] G0<-G1<-G2<- Lm_C2[MAC2] [1,27,4] 498 [0,8,0] B0<-B1<-B2<- Lm_C3[MAC3] [1,27,4] 499 -------------------------------------------------------------------------- 500 INTPL 8 Interpolation of a vector and far color vector. 501 Fields: none 502 Opcode: cop2 $0980011 503 504 In: [IR1,IR2,IR3] Vector [1,3,12] 505 IR0 Interpolation value [1,3,12] 506 CODE Code value from RGB. CODE [0,8,0] 507 FC Far color RFC,GFC,BFC [1,27,4] 508 Out: RGBn RGB fifo Rn,Gn,Bn,CDn [0,8,0] 509 [IR1,IR2,IR3] Color vector [1,11,4] 510 [MAC1,MAC2,MAC3] Color vector [1,27,4] 511 512 Calculations: 513 [1,27,4] MAC1=A1[IR1 + IR0*(Lm_B1[RFC - IR1])] [1,27,16] 514 [1,27,4] MAC2=A2[IR2 + IR0*(Lm_B1[GFC - IR2])] [1,27,16] 515 [1,27,4] MAC3=A3[IR3 + IR0*(Lm_B1[BFC - IR3])] [1,27,16] 516 [1,11,4] IR1=Lm_B1[MAC1] [1,27,4] 517 [1,11,4] IR2=Lm_B2[MAC2] [1,27,4] 518 [1,11,4] IR3=Lm_B3[MAC3] [1,27,4] 519 [0,8,0] Cd0<-Cd1<-Cd2<- CODE 520 [0,8,0] R0<-R1<-R2<- Lm_C1[MAC1] [1,27,4] 521 [0,8,0] G0<-G1<-G2<- Lm_C2[MAC2] [1,27,4] 522 [0,8,0] B0<-B1<-B2<- Lm_C3[MAC3] [1,27,4] 523 -------------------------------------------------------------------------- 524 SQR 5 Square vector. 525 Fields: sf 526 Opcode: cop2 $0a00428 527 sf=0 sf=1 528 in: [IR1,IR2,IR3] vector [1,15,0][1,3,12] 529 out: [IR1,IR2,IR3] vector^2 [1,15,0][1,3,12] 530 [MAC1,MAC2,MAC3] vector^2 [1,31,0][1,19,12] 531 532 Calculation: (left format sf=0, right format sf=1) 533 534 [1,31,0][1,19,12] MAC1=A1[IR1*IR1] [1,43,0][1,31,12] 535 [1,31,0][1,19,12] MAC2=A2[IR2*IR2] [1,43,0][1,31,12] 536 [1,31,0][1,19,12] MAC3=A3[IR3*IR3] [1,43,0][1,31,12] 537 [1,15,0][1,3,12] IR1=Lm_B1[MAC1] [1,31,0][1,19,12][lm=1] 538 [1,15,0][1,3,12] IR2=Lm_B2[MAC2] [1,31,0][1,19,12][lm=1] 539 [1,15,0][1,3,12] IR3=Lm_B3[MAC3] [1,31,0][1,19,12][lm=1] 540 -------------------------------------------------------------------------- 541 NCS 14 Normal color 542 Fields: none 543 Opcode: cop2 $0C8041E 544 545 In: V0 Normal vector [1,3,12] 546 BK Background color RBK,GBK,BBK [1,19,12] 547 CODE Code value from RGB. CODE [0,8,0] 548 LCM Color matrix [1,3,12] 549 LLM Light matrix [1,3,12] 550 Out: RGBn RGB fifo. Rn,Gn,Bn,CDn [0,8,0] 551 [IR1,IR2,IR3] Color vector [1,11,4] 552 [MAC1,MAC2,MAC3] Color vector [1,27,4] 553 554 [1,19,12] MAC1=A1[L11*VX0 + L12*VY0 + L13*VZ0] [1,19,24] 555 [1,19,12] MAC2=A2[L21*VX0 + L22*VY0 + L23*VZ0] [1,19,24] 556 [1,19,12] MAC3=A3[L31*VX0 + L32*VY0 + L33*VZ0] [1,19,24] 557 [1,3,12] IR1= Lm_B1[MAC1] [1,19,12][lm=1] 558 [1,3,12] IR2= Lm_B2[MAC2] [1,19,12][lm=1] 559 [1,3,12] IR3= Lm_B3[MAC3] [1,19,12][lm=1] 560 [1,19,12] MAC1=A1[RBK + LR1*IR1 + LR2*IR2 + LR3*IR3] [1,19,24] 561 [1,19,12] MAC2=A2[GBK + LG1*IR1 + LG2*IR2 + LG3*IR3] [1,19,24] 562 [1,19,12] MAC3=A3[BBK + LB1*IR1 + LB2*IR2 + LB3*IR3] [1,19,24] 563 [1,3,12] IR1= Lm_B1[MAC1] [1,19,12][lm=1] 564 [1,3,12] IR2= Lm_B2[MAC2] [1,19,12][lm=1] 565 [1,3,12] IR3= Lm_B3[MAC3] [1,19,12][lm=1] 566 [0,8,0] Cd0<-Cd1<-Cd2<- CODE 567 [0,8,0] R0<-R1<-R2<- Lm_C1[MAC1] [1,27,4] 568 [0,8,0] G0<-G1<-G2<- Lm_C2[MAC2] [1,27,4] 569 [0,8,0] B0<-B1<-B2<- Lm_C3[MAC3] [1,27,4] 570 -------------------------------------------------------------------------- 571 NCT 30 Normal color 572 Fields: none 573 Opcode: cop2 $0D80420 574 575 In: V0,V1,V2 Normal vector [1,3,12] 576 BK Background color RBK,GBK,BBK [1,19,12] 577 CODE Code value from RGB. CODE [0,8,0] 578 LCM Color matrix [1,3,12] 579 LLM Light matrix [1,3,12] 580 Out: RGBn RGB fifo. Rn,Gn,Bn,CDn [0,8,0] 581 [IR1,IR2,IR3] Color vector [1,11,4] 582 [MAC1,MAC2,MAC3] Color vector [1,27,4] 583 584 Calculation: Same as NCS, but repeated for V1 and V2. 585 -------------------------------------------------------------------------- 586 NCDS 19 Normal color depth cue single vector 587 Fields: none 588 Opcode: cop2 $0e80413 589 In: V0 Normal vector [1,3,12] 590 BK Background color RBK,GBK,BBK [1,19,12] 591 RGB Primary color R,G,B,CODE [0,8,0] 592 LLM Light matrix [1,3,12] 593 LCM Color matrix [1,3,12] 594 IR0 Interpolation value [1,3,12] 595 Out: RGBn RGB fifo. Rn,Gn,Bn,CDn [0,8,0] 596 [IR1,IR2,IR3] Color vector [1,11,4] 597 [MAC1,MAC2,MAC3] Color vector [1,27,4] 598 599 Calculation: 600 [1,19,12] MAC1=A1[L11*VX0 + L12*VY0 + L13*VZ0] [1,19,24] 601 [1,19,12] MAC2=A1[L21*VX0 + L22*VY0 + L23*VZ0] [1,19,24] 602 [1,19,12] MAC3=A1[L31*VX0 + L32*VY0 + L33*VZ0] [1,19,24] 603 [1,3,12] IR1= Lm_B1[MAC1] [1,19,12][lm=1] 604 [1,3,12] IR2= Lm_B2[MAC2] [1,19,12][lm=1] 605 [1,3,12] IR3= Lm_B3[MAC3] [1,19,12][lm=1] 606 [1,19,12] MAC1=A1[RBK + LR1*IR1 + LR2*IR2 + LR3*IR3] [1,19,24] 607 [1,19,12] MAC2=A1[GBK + LG1*IR1 + LG2*IR2 + LG3*IR3] [1,19,24] 608 [1,19,12] MAC3=A1[BBK + LB1*IR1 + LB2*IR2 + LB3*IR3] [1,19,24] 609 [1,3,12] IR1= Lm_B1[MAC1] [1,19,12][lm=1] 610 [1,3,12] IR2= Lm_B2[MAC2] [1,19,12][lm=1] 611 [1,3,12] IR3= Lm_B3[MAC3] [1,19,12][lm=1] 612 [1,27,4] MAC1=A1[R*IR1 + IR0*(Lm_B1[RFC-R*IR1])] [1,27,16][lm=0] 613 [1,27,4] MAC2=A1[G*IR2 + IR0*(Lm_B2[GFC-G*IR2])] [1,27,16][lm=0] 614 [1,27,4] MAC3=A1[B*IR3 + IR0*(Lm_B3[BFC-B*IR3])] [1,27,16][lm=0] 615 [1,3,12] IR1= Lm_B1[MAC1] [1,27,4][lm=1] 616 [1,3,12] IR2= Lm_B2[MAC2] [1,27,4][lm=1] 617 [1,3,12] IR3= Lm_B3[MAC3] [1,27,4][lm=1] 618 [0,8,0] Cd0<-Cd1<-Cd2<- CODE 619 [0,8,0] R0<-R1<-R2<- Lm_C1[MAC1] [1,27,4] 620 [0,8,0] G0<-G1<-G2<- Lm_C2[MAC2] [1,27,4] 621 [0,8,0] B0<-B1<-B2<- Lm_C3[MAC3] [1,27,4] 622 -------------------------------------------------------------------------- 623 NCDT 44 Normal color depth cue triple vectors 624 Fields: none 625 Opcode: cop2 $0f80416 626 In: V0 Normal vector [1,3,12] 627 V1 Normal vector [1,3,12] 628 V2 Normal vector [1,3,12] 629 BK Background color RBK,GBK,BBK [1,19,12] 630 FC Far color RFC,GFC,BFC [1,27,4] 631 RGB Primary color R,G,B,CODE [0,8,0] 632 LLM Light matrix [1,3,12] 633 LCM Color matrix [1,3,12] 634 IR0 Interpolation value [1,3,12] 635 Out: RGBn RGB fifo. Rn,Gn,Bn,CDn [0,8,0] 636 [IR1,IR2,IR3] Color vector [1,11,4] 637 [MAC1,MAC2,MAC3] Color vector [1,27,4] 638 639 Calculation: 640 Same as NCDS but repeats for v1 and v2. 641 -------------------------------------------------------------------------- 642 DPCT 17 Depth Cueing. 643 Fields: none 644 Opcode: cop2 $0F8002A 645 646 In: IR0 Interpolation value [1,3,12] 647 RGB0,RGB1,RGB2 Colors in RGB fifo. Rn,Gn,Bn,CDn [0,8,0] 648 FC Far color RFC,GFC,BFC [1,27,4] 649 Out: RGBn RGB fifo Rn,Gn,Bn,CDn [0,8,0] 650 [IR1,IR2,IR3] Color vector [1,11,4] 651 [MAC1,MAC2,MAC3] Color vector [1,27,4] 652 653 Calculations: 654 [1,27,4] MAC1=A1[R0+ IR0*(Lm_B1[RFC - R0])] [1,27,16][lm=0] 655 [1,27,4] MAC2=A2[G0+ IR0*(Lm_B1[GFC - G0])] [1,27,16][lm=0] 656 [1,27,4] MAC3=A3[B0+ IR0*(Lm_B1[BFC - B0])] [1,27,16][lm=0] 657 [1,11,4] IR1=Lm_B1[MAC1] [1,27,4][lm=0] 658 [1,11,4] IR2=Lm_B2[MAC2] [1,27,4][lm=0] 659 [1,11,4] IR3=Lm_B3[MAC3] [1,27,4][lm=0] 660 [0,8,0] Cd0<-Cd1<-Cd2<- CODE 661 [0,8,0] R0<-R1<-R2<- Lm_C1[MAC1] [1,27,4] 662 [0,8,0] G0<-G1<-G2<- Lm_C2[MAC2] [1,27,4] 663 [0,8,0] B0<-B1<-B2<- Lm_C3[MAC3] [1,27,4] 664 665 Performs this calculation 3 times, so all three RGB values have been 666 replaced by the depth cued RGB values. 667 668 -------------------------------------------------------------------------- 669 NCCS 17 Normal Color Color single vector 670 Fields: none 671 Opcode: cop2 $108041B 672 673 In: V0 Normal vector [1,3,12] 674 BK Background color RBK,GBK,BBK [1,19,12] 675 RGB Primary color R,G,B,CODE [0,8,0] 676 LLM Light matrix [1,3,12] 677 LCM Color matrix [1,3,12] 678 Out: RGBn RGB fifo. Rn,Gn,Bn,CDn [0,8,0] 679 [IR1,IR2,IR3] Color vector [1,11,4] 680 [MAC1,MAC2,MAC3] Color vector [1,27,4] 681 682 Calculation: 683 684 [1,19,12] MAC1=A1[L11*VX0 + L12*VY0 + L13*VZ0] [1,19,24] 685 [1,19,12] MAC2=A2[L21*VX0 + L22*VY0 + L23*VZ0] [1,19,24] 686 [1,19,12] MAC3=A3[L31*VX0 + L32*VY0 + L33*VZ0] [1,19,24] 687 [1,3,12] IR1= Lm_B1[MAC1] [1,19,12][lm=1] 688 [1,3,12] IR2= Lm_B2[MAC2] [1,19,12][lm=1] 689 [1,3,12] IR3= Lm_B3[MAC3] [1,19,12][lm=1] 690 [1,19,12] MAC1=A1[RBK + LR1*IR1 + LR2*IR2 + LR3*IR3] [1,19,24] 691 [1,19,12] MAC2=A2[GBK + LG1*IR1 + LG2*IR2 + LG3*IR3] [1,19,24] 692 [1,19,12] MAC3=A3[BBK + LB1*IR1 + LB2*IR2 + LB3*IR3] [1,19,24] 693 [1,3,12] IR1= Lm_B1[MAC1] [1,19,12][lm=1] 694 [1,3,12] IR2= Lm_B2[MAC2] [1,19,12][lm=1] 695 [1,3,12] IR3= Lm_B3[MAC3] [1,19,12][lm=1] 696 [1,27,4] MAC1=A1[R*IR1] [1,27,16] 697 [1,27,4] MAC2=A2[G*IR2] [1,27,16] 698 [1,27,4] MAC3=A3[B*IR3] [1,27,16] 699 [1,3,12] IR1= Lm_B1[MAC1] [1,27,4][lm=1] 700 [1,3,12] IR2= Lm_B2[MAC2] [1,27,4][lm=1] 701 [1,3,12] IR3= Lm_B3[MAC3] [1,27,4][lm=1] 702 [0,8,0] Cd0<-Cd1<-Cd2<- CODE 703 [0,8,0] R0<-R1<-R2<- Lm_C1[MAC1] [1,27,4] 704 [0,8,0] G0<-G1<-G2<- Lm_C2[MAC2] [1,27,4] 705 [0,8,0] B0<-B1<-B2<- Lm_C3[MAC3] [1,27,4] 706 -------------------------------------------------------------------------- 707 NCCT 39 Normal Color Color triple vector 708 Fields: none 709 Opcode: cop2 $118043F 710 711 In: V0 Normal vector 1 [1,3,12] 712 V1 Normal vector 2 [1,3,12] 713 V2 Normal vector 3 [1,3,12] 714 BK Background color RBK,GBK,BBK [1,19,12] 715 RGB Primary color R,G,B,CODE [0,8,0] 716 LLM Light matrix [1,3,12] 717 LCM Color matrix [1,3,12] 718 Out: RGBn RGB fifo. Rn,Gn,Bn,CDn [0,8,0] 719 [IR1,IR2,IR3] Color vector [1,11,4] 720 [MAC1,MAC2,MAC3] Color vector [1,27,4] 721 722 Calculation: 723 Same as NCCS but repeats for v1 and v2. 724 -------------------------------------------------------------------------- 725 CDP 13 Color Depth Que 726 Fields: none 727 Opcode: cop2 $1280414 728 729 In: [IR1,IR2,IR3] Vector [1,3,12] 730 RGB Primary color R,G,B,CODE [0,8,0] 731 IR0 Interpolation value [1,3,12] 732 BK Background color RBK,GBK,BBK [1,19,12] 733 LCM Color matrix [1,3,12] 734 FC Far color RFC,GFC,BFC [1,27,4] 735 Out: RGBn RGB fifo Rn,Gn,Bn,CDn [0,8,0] 736 [IR1,IR2,IR3] Color vector [1,11,4] 737 [MAC1,MAC2,MAC3] Color vector [1,27,4] 738 739 Calculation: 740 [1,19,12] MAC1=A1[RBK + LR1*IR1 + LR2*IR2 + LR3*IR3] [1,19,24] 741 [1,19,12] MAC2=A2[GBK + LG1*IR1 + LG2*IR2 + LG3*IR3] [1,19,24] 742 [1,19,12] MAC3=A3[BBK + LB1*IR1 + LB2*IR2 + LB3*IR3] [1,19,24] 743 [1,3,12] IR1= Lm_B1[MAC1] [1,19,12][lm=1] 744 [1,3,12] IR2= Lm_B2[MAC2] [1,19,12][lm=1] 745 [1,3,12] IR3= Lm_B3[MAC3] [1,19,12][lm=1] 746 [1,27,4] MAC1=A1[R*IR1 + IR0*(Lm_B1[RFC-R*IR1])] [1,27,16][lm=0] 747 [1,27,4] MAC2=A2[G*IR2 + IR0*(Lm_B2[GFC-G*IR2])] [1,27,16][lm=0] 748 [1,27,4] MAC3=A3[B*IR3 + IR0*(Lm_B3[BFC-B*IR3])] [1,27,16][lm=0] 749 [1,3,12] IR1= Lm_B1[MAC1] [1,27,4][lm=1] 750 [1,3,12] IR2= Lm_B2[MAC2] [1,27,4][lm=1] 751 [1,3,12] IR3= Lm_B3[MAC3] [1,27,4][lm=1] 752 [0,8,0] Cd0<-Cd1<-Cd2<- CODE 753 [0,8,0] R0<-R1<-R2<- Lm_C1[MAC1] [1,27,4] 754 [0,8,0] G0<-G1<-G2<- Lm_C2[MAC2] [1,27,4] 755 [0,8,0] B0<-B1<-B2<- Lm_C3[MAC3] [1,27,4] 756 -------------------------------------------------------------------------- 757 CC 11 Color Color. 758 Fields: none 759 Opcode: cop2 $138041C 760 In: [IR1,IR2,IR3] Vector [1,3,12] 761 BK Background color RBK,GBK,BBK [1,19,12] 762 RGB Primary color R,G,B,CODE [0,8,0] 763 LCM Color matrix [1,3,12] 764 Out: RGBn RGB fifo. Rn,Gn,Bn,CDn [0,8,0] 765 [IR1,IR2,IR3] Color vector [1,11,4] 766 [MAC1,MAC2,MAC3] Color vector [1,27,4] 767 768 Calculations: 769 [1,19,12] MAC1=A1[RBK + LR1*IR1 + LR2*IR2 + LR3*IR3] [1,19,24] 770 [1,19,12] MAC2=A2[GBK + LG1*IR1 + LG2*IR2 + LG3*IR3] [1,19,24] 771 [1,19,12] MAC3=A3[BBK + LB1*IR1 + LB2*IR2 + LB3*IR3] [1,19,24] 772 [1,3,12] IR1= Lm_B1[MAC1] [1,19,12][lm=1] 773 [1,3,12] IR2= Lm_B2[MAC2] [1,19,12][lm=1] 774 [1,3,12] IR3= Lm_B3[MAC3] [1,19,12][lm=1] 775 [1,27,4] MAC1=A1[R*IR1] [1,27,16] 776 [1,27,4] MAC2=A2[G*IR2] [1,27,16] 777 [1,27,4] MAC3=A3[B*IR3] [1,27,16] 778 [1,3,12] IR1= Lm_B1[MAC1] [1,27,4][lm=1] 779 [1,3,12] IR2= Lm_B2[MAC2] [1,27,4][lm=1] 780 [1,3,12] IR3= Lm_B3[MAC3] [1,27,4][lm=1] 781 [0,8,0] Cd0<-Cd1<-Cd2<- CODE 782 [0,8,0] R0<-R1<-R2<- Lm_C1[MAC1] [1,27,4] 783 [0,8,0] G0<-G1<-G2<- Lm_C2[MAC2] [1,27,4] 784 [0,8,0] B0<-B1<-B2<- Lm_C3[MAC3] [1,27,4] 785 -------------------------------------------------------------------------- 786 NCLIP 8 Normal clipping 787 Fields: 788 Opcode: cop2 $1400006 789 790 in: SXY0,SXY1,SXY2 Screen coordinates [1,15,0] 791 out: MAC0 Outerproduct of SXY1 and SXY2 with [1,31,0] 792 SXY0 as origin. 793 794 Calculation: 795 [1,31,0] MAC0 = F[SX0*SY1+SX1*SY2+SX2*SY0-SX0*SY2-SX1*SY0-SX2*SY1] [1,43,0] 796 -------------------------------------------------------------------------- 797 AVSZ3 5 Average of three Z values 798 fields: 799 Opcode: cop2 $158002D 800 801 in: SZ1, SZ2, SZ3 Z-Values [0,16,0] 802 ZSF3 Divider [1,3,12] 803 out: OTZ Average. [0,16,0] 804 MAC0 Average. [1,31,0] 805 806 Calculation: 807 [1,31,0] MAC0=F[ZSF3*SZ1 + ZSF3*SZ2 + ZSF3*SZ3] [1,31,12] 808 [0,16,0] OTZ=Lm_D[MAC0] [1,31,0] 809 -------------------------------------------------------------------------- 810 AVSZ4 6 Average of four Z values 811 Fields: 812 Opcode: cop2 $168002E 813 814 in: SZ1,SZ2,SZ3,SZ4 Z-Values [0,16,0] 815 ZSF4 Divider [1,3,12] 816 out: OTZ Average. [0,16,0] 817 MAC0 Average. [1,31,0] 818 819 Calculation: 820 [1,31,0] MAC0=F[ZSF4*SZ0 + ZSF4*SZ1 + ZSF4*SZ2 + ZSF4*SZ3] [1,31,12] 821 [0,16,0] OTZ=Lm_D[MAC0] [1,31,0] 822 -------------------------------------------------------------------------- 823 OP 6 Outer product of 2 vectors 824 Fields: sf 825 Opcode: cop2 $170000C 826 827 in: [R11R12,R22R23,R33] vector 1 828 [IR1,IR2,IR3] vector 2 829 out: [IR1,IR2,IR3] outer product 830 [MAC1,MAC2,MAC3] outer product 831 832 Calculation: (D1=R11R12,D2=R22R23,D3=R33) 833 834 MAC1=A1[D2*IR3 - D3*IR2] 835 MAC2=A2[D3*IR1 - D1*IR3] 836 MAC3=A3[D1*IR2 - D2*IR1] 837 IR1=Lm_B1[MAC0] 838 IR2=Lm_B2[MAC1] 839 IR3=Lm_B3[MAC2] 840 841 -------------------------------------------------------------------------- 842 GPF 5 General purpose interpolation 843 Fields: sf 844 Opcode: cop2 $190003D 845 846 in: IR0 scaling factor 847 CODE code field of RGB 848 [IR1,IR2,IR3] vector 849 out: [IR1,IR2,IR3] vector 850 [MAC1,MAC2,MAC3] vector 851 RGB2 RGB fifo. 852 853 Calculation: 854 855 MAC1=A1[IR0 * IR1] 856 MAC2=A2[IR0 * IR2] 857 MAC3=A3[IR0 * IR3] 858 IR1=Lm_B1[MAC1] 859 IR2=Lm_B2[MAC2] 860 IR3=Lm_B3[MAC3] 861 [0,8,0] Cd0<-Cd1<-Cd2<- CODE 862 [0,8,0] R0<-R1<-R2<- Lm_C1[MAC1] 863 [0,8,0] G0<-G1<-G2<- Lm_C2[MAC2] 864 [0,8,0] B0<-B1<-B2<- Lm_C3[MAC3] 865 -------------------------------------------------------------------------- 866 GPL 5 General purpose interpolation 867 Fields: sf 868 Opcode: cop2 $1A0003E 869 870 in: IR0 scaling factor 871 CODE code field of RGB 872 [IR1,IR2,IR3] vector 873 [MAC1,MAC2,MAC3] vector 874 out: [IR1,IR2,IR3] vector 875 [MAC1,MAC2,MAC3] vector 876 RGB2 RGB fifo. 877 878 Calculation: 879 880 MAC1=A1[MAC1 + IR0 * IR1] 881 MAC2=A2[MAC2 + IR0 * IR2] 882 MAC3=A3[MAC3 + IR0 * IR3] 883 IR1=Lm_B1[MAC1] 884 IR2=Lm_B2[MAC2] 885 IR3=Lm_B3[MAC3] 886 [0,8,0] Cd0<-Cd1<-Cd2<- CODE 887 [0,8,0] R0<-R1<-R2<- Lm_C1[MAC1] 888 [0,8,0] G0<-G1<-G2<- Lm_C2[MAC2] 889 [0,8,0] B0<-B1<-B2<- Lm_C3[MAC3] 890 -------------------------------------------------------------------------- 891 Field decriptions. 892 893 bit |24 23 22 21 20|19|18 17|16 15|14 13|12 11|10| 894 desc| |sf|mx |v |cv | |lm| 895 896 bit |09 08 07 06 05 04 03 02 01 00| 897 desc| | 898 899 sf 0 Normal calculation. 900 1 Calculations on data shifted 12 bits to the left in the IR regs. 901 (Not entirely sure about what really happens.) 902 903 mx 0 Multiply with rotation matrix 904 1 Multiply with light matrix 905 2 Multiply with color matrix 906 3 - 907 908 v 0 V0 source vector (short) 909 1 V1 source vector (short) 910 2 V2 source vector (short) 911 3 IR source vector (long) 912 913 cv 0 Add translation vector (TR) 914 1 Add back color vector (BK) 915 2 Bugged. Should add far color vector. (FC) 916 3 Add no vector 917 918 lm 0 No negative limit. 919 1 Limit negative results to 0. 920 921 -------------------------------------------------------------------------- 922 A list of common MVMVA instructions: 923 924 rtv0 cop2 $0486012 v0 * rotmatrix 925 rtv1 cop2 $048E012 v1 * rotmatrix 926 rtv2 cop2 $0496012 v2 * rotmatrix 927 928 rtir12 cop2 $049E012 ir * rotmatrix 929 rtir0 cop2 $041E012 ir * rotmatrix. 930 931 rtv0tr cop2 $0480012 v0 * rotmatrix + tr vector 932 rtv1tr cop2 $0488012 v1 * rotmatrix + tr vector 933 rtv2tr cop2 $0490012 v2 * rotmatrix + tr vector 934 rtirtr cop2 $0498012 ir * rotmatrix + tr vector 935 936 rtv0bk cop2 $0482012 v0 * rotmatrix + bk vector 937 rtv1bk cop2 $048A012 v1 * rotmatrix + bk vector 938 rtv2bk cop2 $0492012 v2 * rotmatrix + bk vector 939 rtirbk cop2 $049A012 ir * rotmatrix + bk vector 940 941 ll cop2 $04A6412 v0 * light matrix. Lower limit result to 0. 942 943 llv0 cop2 $04A6012 v0 * light matrix 944 llv1 cop2 $04AE012 v1 * light matrix 945 llv2 cop2 $04B6012 v2 * light matrix 946 llir cop2 $04BE012 ir * light matrix 947 948 llv0tr cop2 $04A0012 v0 * light matrix + tr vector 949 llv1tr cop2 $04A8012 v1 * light matrix + tr vector 950 llv2tr cop2 $04B0012 v2 * light matrix + tr vector 951 llirtr cop2 $04B8012 ir * light matrix + tr vector 952 953 llv0bk cop2 $04A2012 v0 * light matrix + bk vector 954 llv1bk cop2 $04AA012 v1 * light matrix + bk vector 955 llv2bk cop2 $04B2012 v2 * light matrix + bk vector 956 llirbk cop2 $04BA012 ir * light matrix + bk vector 957 958 lc cop2 $04DA412 959 960 lcv0 cop2 $04C6012 v0 * color matrix 961 lcv1 cop2 $04CE012 v1 * color matrix 962 lcv2 cop2 $04D6012 v2 * color matrix 963 lcir cop2 $04DE012 ir * color matrix 964 965 lcv0tr cop2 $04C0012 v0 * color matrix + tr vector 966 lcv1tr cop2 $04C8012 v1 * color matrix + tr vector 967 lcv2tr cop2 $04D0012 v2 * color matrix + tr vector 968 lcirtr cop2 $04D8012 ir * color matrix + tr vector 969 970 lcv0bk cop2 $04C2012 v0 * color matrix + bk vector 971 lcv1bk cop2 $04CA012 v1 * color matrix + bk vector 972 lcv2bk cop2 $04D2012 v2 * color matrix + bk vector 973 lcirbk cop2 $04DA012 ir * color matrix + bk vector 974 975 Other instructions: 976 977 sqr12 cop2 $0A80428 square of ir (1,19,12) 978 sqr0 cop2 $0A00428 (1,31, 0) 979 980 op12 cop2 $178000C outer product (1,19,12) 981 op0 cop2 $170000C (1,31, 0) 982 983 gpf12 cop2 $198003D general purpose interpolation (1,19,12) 984 gpf0 cop2 $190003D (1,31, 0) 985 986 gpl12 cop2 $1A8003E general purpose interpolation (1,19,12) 987 gpl0 cop2 $1A0003E (1,31, 0) 988 989 -------------------------------------------------------------------------- 990 doomed@c64.org <- corrections/additions latest update -> psx.rules.org 991 -------------------------------------------------------------------------- 992 8/jun/1999 Initial version. 993 23/aug/1999 Almost completely rewritten. 994 2/feb/2000 Small fix. 995 -------------------------------------------------------------------------- 996 If you miss anything that was in the previous version please mail me. 997 -------------------------------------------------------------------------- 998 999