diff --git a/include/PR/gbi.h b/include/PR/gbi.h index 170916445..1d7611ae1 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -75,13 +75,13 @@ * * IMPLEMENTATION NOTE: * There is another group of RDP commands that includes the triangle commands - * generated by the RSP code. These are the raw commands the rasterizer - * hardware chews on, with slope info, etc. They will follow the RDP + * generated by the RSP code. These are the raw commands the rasterizer + * hardware chews on, with slope info, etc. They will follow the RDP * ordering... * * IMPLEMENTATION NOTE: - * The RDP hardware has some of these bit patterns wired up. If the hardware - * changes, we must adjust this table, likewise we can't change/add things + * The RDP hardware has some of these bit patterns wired up. If the hardware + * changes, we must adjust this table, likewise we can't change/add things * once the hardware is frozen. (actually, the RDP hardware only looks at * the lower 6 bits of the command byte) * @@ -198,7 +198,7 @@ #define G_TEXRECT 0xe4 /* -28 */ -/* +/* * The following commands are the "generated" RDP commands; the user * never sees them, the RSP microcode generates them. * @@ -231,8 +231,8 @@ /* masks to build RDP triangle commands: */ #define G_RDP_TRI_FILL_MASK 0x08 #define G_RDP_TRI_SHADE_MASK 0x04 -#define G_RDP_TRI_TXTR_MASK 0x02 -#define G_RDP_TRI_ZBUFF_MASK 0x01 +#define G_RDP_TRI_TXTR_MASK 0x02 +#define G_RDP_TRI_ZBUFF_MASK 0x01 /* * HACK: @@ -318,7 +318,7 @@ * * DO NOT USE THE LOW 8 BITS OF GEOMETRYMODE: * The weird bit-ordering is for the micro-code: the lower byte - * can be OR'd in with G_TRI_SHADE (11001100) to construct + * can be OR'd in with G_TRI_SHADE (11001100) to construct * the triangle command directly. Don't break it... * * DO NOT USE THE HIGH 8 BITS OF GEOMETRYMODE: @@ -332,7 +332,7 @@ * appropriately and use primcolor to see anything. * * G_SHADING_SMOOTH enabled means use all 3 colors of the triangle. - * If it is not set, then do 'flat shading', where only one vertex color + * If it is not set, then do 'flat shading', where only one vertex color * is used (and all 3 vertices are set to that same color by the ucode) * See the man page for gSP1Triangle(). * @@ -837,27 +837,27 @@ Z_CMP | Z_UPD | CVG_DST_FULL | ALPHA_CVG_SEL | \ ZMODE_OPA | \ GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - + #define RM_ZB_XLU_SURF(clk) \ Z_CMP | IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_XLU | \ GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - + #define RM_ZB_OPA_DECAL(clk) \ Z_CMP | CVG_DST_FULL | ALPHA_CVG_SEL | ZMODE_DEC | \ GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - + #define RM_ZB_XLU_DECAL(clk) \ Z_CMP | IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_DEC | \ GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - + #define RM_ZB_CLD_SURF(clk) \ Z_CMP | IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_XLU | \ GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - + #define RM_ZB_OVL_SURF(clk) \ Z_CMP | IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_DEC | \ GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - + #define RM_ZB_PCL_SURF(clk) \ Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | \ G_AC_DITHER | \ @@ -1044,7 +1044,7 @@ * element, we can't depend on the C compiler to align things * properly. * - * 64-bit structure alignment is enforced by wrapping structures with + * 64-bit structure alignment is enforced by wrapping structures with * unions that contain a dummy "long long int". Why this works is * explained in the ANSI C Spec, or on page 186 of the second edition * of K&R, "The C Programming Language". @@ -1108,14 +1108,14 @@ typedef struct { /* 20 bytes for above */ /* padding to bring structure size to 64 bit allignment */ - char dummy[4]; + char dummy[4]; } uSprite_t; -typedef union { +typedef union { uSprite_t s; - /* Need to make sure this is 64 bit aligned */ + /* Need to make sure this is 64 bit aligned */ long long int force_structure_allignment[3]; } uSprite; @@ -1194,7 +1194,7 @@ typedef union { */ #ifdef F3DEX_GBI_2 /* 0,4 are reserved by G_MTX */ -# define G_MV_MMTX 2 +# define G_MV_MMTX 2 # define G_MV_PMTX 6 # define G_MV_VIEWPORT 8 # define G_MV_LIGHT 10 @@ -1252,7 +1252,7 @@ typedef union { /* * These are offsets from the address in the dmem table - */ + */ #define G_MWO_NUMLIGHT 0x00 #define G_MWO_CLIP_RNX 0x04 #define G_MWO_CLIP_RNY 0x0c @@ -1334,7 +1334,7 @@ typedef union { * * Note: only directional (infinite) lights are currently supported. * - * Note: the weird order is for the DMEM alignment benefit of + * Note: the weird order is for the DMEM alignment benefit of * the microcode. * */ @@ -1497,6 +1497,23 @@ typedef struct { Tri tri; } Gtri; +typedef struct { + unsigned char cmd:8; + unsigned char pad:8; + unsigned char z4:4; + unsigned char z3:4; + unsigned char z2:4; + unsigned char z1:4; + unsigned char y4:4; + unsigned char x4:4; + unsigned char y3:4; + unsigned char x3:4; + unsigned char y2:4; + unsigned char x2:4; + unsigned char y1:4; + unsigned char x1:4; +} Gtri4; + typedef struct { int cmd:8; int pad1:24; @@ -1655,7 +1672,7 @@ typedef struct { /* * Textured rectangles are 128 bits not 64 bits - */ + */ typedef struct { unsigned long w0; unsigned long w1; @@ -1671,14 +1688,32 @@ typedef struct { unsigned int w1; } Gwords; +// xxxxxxxx 11223344 44555566 66666777 +// 88888888 99999999 9999aaaa aaaaaaaa +typedef struct { + unsigned int cmd:8; + unsigned int unk08:2; + unsigned int unk0a:2; + unsigned int unk0c:2; + unsigned int unk0e:4; + unsigned int unk12:4; + unsigned int flags:7; + unsigned int subcmd:3; + unsigned int unk20:8; + unsigned int tile1:12; + unsigned int tile2:12; +} GunkC0; + /* * This union is the fundamental type of the display list. * It is, by law, exactly 64 bits in size. */ typedef union { Gwords words; + u8 bytes[8]; Gdma dma; Gtri tri; + Gtri4 tri4; Gline3D line; Gpopmtx popmtx; Gsegment segment; @@ -1694,6 +1729,7 @@ typedef union { Gloadtile loadtile; /* use for loadblock also, th is dxt */ Gsettilesize settilesize; Gloadtlut loadtlut; + GunkC0 unkc0; long long int force_structure_alignment; } Gfx; @@ -1803,7 +1839,7 @@ typedef union { gsDma1p(G_VTX, v, sizeof(Vtx)*(n), ((n)-1)<<4|(v0)) #endif - + #ifdef F3DEX_GBI_2 # define gSPViewport(pkt, v) \ gDma2p((pkt), G_MOVEMEM, (v), sizeof(Vp), G_MV_VIEWPORT, 0) @@ -2062,7 +2098,7 @@ typedef union { /*** *** 1 Triangle - ***/ + ***/ #define gSP1Triangle(pkt, v0, v1, v2, flag) \ { \ Gfx *_g = (Gfx *)(pkt); \ @@ -2230,7 +2266,7 @@ typedef union { * Insert values into Matrix * * where = element of matrix (byte offset) - * num = new element (32 bit value replacing 2 int or 2 frac matrix + * num = new element (32 bit value replacing 2 int or 2 frac matrix * componants */ #ifdef F3DEX_GBI_2 @@ -2258,7 +2294,7 @@ typedef union { #define gsSPForceMatrix(mptr) \ gsDma2p(G_MOVEMEM,(mptr),sizeof(Mtx),G_MV_MATRIX,0), \ gsMoveWd(G_MW_FORCEMTX,0,0x00010000) - + #else /* F3DEX_GBI_2 */ #define gSPForceMatrix(pkt, mptr) \ { \ @@ -2306,7 +2342,7 @@ typedef union { /* * gSPBranchLessZ Branch DL if (vtx.z) less than or equal (zval). * - * dl = DL branch to + * dl = DL branch to * vtx = Vertex * zval = Screen depth * near = Near plane @@ -2353,7 +2389,7 @@ typedef union { /* * gSPBranchLessZraw Branch DL if (vtx.z) less than or equal (raw zval). * - * dl = DL branch to + * dl = DL branch to * vtx = Vertex * zval = Raw value of screen depth */ @@ -2454,7 +2490,7 @@ typedef union { #define NUMLIGHTS_7 7 /* * n should be one of: NUMLIGHTS_0, NUMLIGHTS_1, ..., NUMLIGHTS_7 - * NOTE: in addition to the number of directional lights specified, + * NOTE: in addition to the number of directional lights specified, * there is always 1 ambient light */ #define gSPNumLights(pkt, n) \ @@ -2466,7 +2502,7 @@ typedef union { #define LIGHT_2 2 #define LIGHT_3 3 #define LIGHT_4 4 -#define LIGHT_5 5 +#define LIGHT_5 5 #define LIGHT_6 6 #define LIGHT_7 7 #define LIGHT_8 8 @@ -2696,7 +2732,7 @@ typedef union { * min, max: range 0 to 1000: 0=nearplane, 1000=farplane * min is where fog begins (usually less than max and often 0) * max is where fog is thickest (usually 1000) - * + * */ #define gSPFogFactor(pkt, fm, fo) \ gMoveWd(pkt, G_MW_FOG, G_MWO_FOG, \ @@ -2736,7 +2772,7 @@ typedef union { _SHIFTL((level),11,3) | _SHIFTL((tile),8,3) | _SHIFTL((on),1,7)),\ (_SHIFTL((s),16,16) | _SHIFTL((t),0,16)) \ } -/* +/* * Different version of SPTexture macro, has an additional parameter * which is currently reserved in the microcode. */ @@ -2775,7 +2811,7 @@ typedef union { _SHIFTL((level),11,3)|_SHIFTL((tile),8,3)|_SHIFTL((on),0,8)), \ (_SHIFTL((s),16,16)|_SHIFTL((t),0,16)) \ } -/* +/* * Different version of SPTexture macro, has an additional parameter * which is currently reserved in the microcode. */ @@ -2975,7 +3011,7 @@ typedef union { gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 2, mode) #endif -/* 'blendmask' is not supported anymore. +/* 'blendmask' is not supported anymore. * The bits are reserved for future use. * Fri May 26 13:45:55 PDT 1995 */ @@ -3181,7 +3217,7 @@ typedef union { * * This command makes all othermode parameters set. * Do not use this command in the same DL with another g*SPSetOtherMode DLs. - * + * * [Usage] * gDPSetOtherMode(pkt, modeA, modeB) * @@ -3434,9 +3470,9 @@ typedef union { ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ } -/* +/* * Allow tmem address and render tile to be specified. - * The S at the end means odd lines are already word Swapped + * The S at the end means odd lines are already word Swapped */ #define gDPLoadMultiBlockS(pkt, timg, tmem, rtile, fmt, siz, width, \ height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ @@ -3652,13 +3688,13 @@ typedef union { ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ ((height)-1) << G_TEXTURE_IMAGE_FRAC) -/* +/* * Allows tmem and render tile to be specified. Useful when loading * several tiles at a time. * * Here is the static form of the pre-swapped texture block loading * See gDPLoadTextureBlockS() for reference. Basically, just don't - * calculate DxT, use 0 + * calculate DxT, use 0 */ #define gsDPLoadMultiBlockS(timg, tmem, rtile, fmt, siz, width, height, \ @@ -3742,7 +3778,7 @@ typedef union { } /* - * 4-bit load block. Allows tmem and render tile to be specified. Useful when + * 4-bit load block. Allows tmem and render tile to be specified. Useful when * loading multiple tiles. The S means odd lines are already word swapped. */ #define gDPLoadMultiBlock_4bS(pkt, timg, tmem, rtile, fmt, width, height,\ @@ -4177,7 +4213,7 @@ typedef union { G_IM_FMT_RGBA, G_IM_SIZ_16b, 4*16, 1, \ pal, 0, 0, 0, 0, 0, 0) -#endif /* _HW_VERSION_1 */ +#endif /* _HW_VERSION_1 */ /* * Load a 256-entry palette (for 8-bit CI textures) @@ -4219,7 +4255,7 @@ typedef union { gsDPLoadSync(), \ gsDPLoadTLUTCmd(G_TX_LOADTILE, 255), \ gsDPPipeSync() - + #else /* **** WORKAROUND hardware 1 load_tlut bug ****** */ #define gsDPLoadTLUT_pal256(dram) \ @@ -4274,7 +4310,7 @@ typedef union { G_IM_FMT_RGBA, G_IM_SIZ_16b, 4, count, \ 0, 0, 0, 0, 0, 0, 0) -#endif /* _HW_VERSION_1 */ +#endif /* _HW_VERSION_1 */ #define gDPSetScissor(pkt, mode, ulx, uly, lrx, lry) \ { \ @@ -4429,7 +4465,7 @@ typedef union { } /* Notice that textured rectangles are 128-bit commands, therefore - * gsDPTextureRectangle() should not be used in display lists + * gsDPTextureRectangle() should not be used in display lists * under normal circumstances (use gsSPTextureRectangle()). * That is also why there is no gDPTextureRectangle() macros. */ diff --git a/src/game/game_13b670.c b/src/game/game_13b670.c index a16be8424..7449b4b96 100644 --- a/src/game/game_13b670.c +++ b/src/game/game_13b670.c @@ -779,7 +779,7 @@ glabel var7f1b598c /* f13c078: 27bd0038 */ addiu $sp,$sp,0x38 ); -void func0f13c07c(s32 arg0) +void func0f13c07c(struct gfxvtx *vertex) { if (var8007f6e0 >= 0 && var8007f6f8 != var800a4180) { if (var8007f6e8 == 0) { @@ -813,7 +813,7 @@ void func0f13c07c(s32 arg0) var8007f6ec = 1; } - var800a418c[var8007f6f8].unk00 = arg0; + var800a418c[var8007f6f8].unk00 = (u16)vertex; // @TODO: Investigate this var8007f6f8++; var800a4190[var8007f6f4 - 1].unk01++; diff --git a/src/game/modeldef.c b/src/game/modeldef.c index b454696c7..bb5c27593 100644 --- a/src/game/modeldef.c +++ b/src/game/modeldef.c @@ -154,7 +154,7 @@ void modeldef0f1a7560(struct modelfiledata *modeldef, u16 filenum, u32 arg2, u32 vertices = NULL; } - s5 += tex0f1756c0((u32)modeldef + (s0 & 0xffffff) + sp84, s4, (u32)modeldef + (s5 & 0xffffff), arg4, vertices); + s5 += tex0f1756c0((Gfx *)((u32)modeldef + (s0 & 0xffffff) + sp84), s4, (Gfx *)((u32)modeldef + (s5 & 0xffffff)), arg4, (u32)vertices); } fileSetSize(filenum, modeldef, (((u32)modeldef + (s5 & 0xffffff)) - (u32)modeldef + 0xf) & ~0xf, arg5); diff --git a/src/game/tex.c b/src/game/tex.c index 312c3e5af..3d6d7a187 100644 --- a/src/game/tex.c +++ b/src/game/tex.c @@ -5,6 +5,7 @@ #include "game/texdecompress.h" #include "bss.h" #include "data.h" +#include "textures.h" #include "types.h" s32 g_TexLutMode; @@ -1264,7 +1265,7 @@ Gfx *tex0f1751e4(Gfx *gdl, struct texloadthing *arg1, s32 arg2, s32 arg3, s32 ar gDPPipeSync(gdl++); - var800844d0 = 1; + var800844d0 = true; return gdl; } @@ -1530,48 +1531,29 @@ glabel tex0f17563c GLOBAL_ASM( glabel tex0f1756c0 .late_rodata -glabel var7f1b7c30 -.word tex0f1756c0+0x544 # f175c04 -glabel var7f1b7c34 -.word tex0f1756c0+0x768 # f175e28 -glabel var7f1b7c38 -.word tex0f1756c0+0x768 # f175e28 -glabel var7f1b7c3c -.word tex0f1756c0+0x768 # f175e28 -glabel var7f1b7c40 -.word tex0f1756c0+0x768 # f175e28 -glabel var7f1b7c44 -.word tex0f1756c0+0x768 # f175e28 -glabel var7f1b7c48 -.word tex0f1756c0+0x768 # f175e28 -glabel var7f1b7c4c -.word tex0f1756c0+0x768 # f175e28 -glabel var7f1b7c50 -.word tex0f1756c0+0x768 # f175e28 -glabel var7f1b7c54 -.word tex0f1756c0+0x74c # f175e0c -glabel var7f1b7c58 -.word tex0f1756c0+0x70c # f175dcc -glabel var7f1b7c5c -.word tex0f1756c0+0x768 # f175e28 -glabel var7f1b7c60 -.word tex0f1756c0+0x768 # f175e28 -glabel var7f1b7c64 -.word tex0f1756c0+0x768 # f175e28 -glabel var7f1b7c68 -.word tex0f1756c0+0x544 # f175c04 -glabel var7f1b7c6c -.word tex0f1756c0+0x114 # f1757d4 -glabel var7f1b7c70 -.word tex0f1756c0+0x1c0 # f175880 -glabel var7f1b7c74 -.word tex0f1756c0+0x224 # f1758e4 -glabel var7f1b7c78 -.word tex0f1756c0+0x2bc # f17597c -glabel var7f1b7c7c -.word tex0f1756c0+0x2f8 # f1759b8 -glabel var7f1b7c80 -.word tex0f1756c0+0x330 # f1759f0 +glabel jtbl_var7f1b7c30 +.word .L0f175c04 +.word .L0f175e28 +.word .L0f175e28 +.word .L0f175e28 +.word .L0f175e28 +.word .L0f175e28 +.word .L0f175e28 +.word .L0f175e28 +.word .L0f175e28 +.word .L0f175e0c +.word .L0f175dcc +.word .L0f175e28 +.word .L0f175e28 +.word .L0f175e28 +.word .L0f175c04 +.word .L0f1757d4 +glabel jtbl_var7f1b7c70 +.word .L0f175880 +.word .L0f1758e4 +.word .L0f17597c +.word .L0f1759b8 +.word .L0f1759f0 .text /* f1756c0: 27bdfec8 */ addiu $sp,$sp,-312 /* f1756c4: afb00030 */ sw $s0,0x30($sp) @@ -1637,9 +1619,9 @@ glabel var7f1b7c80 /* f1757a0: 2f210010 */ sltiu $at,$t9,0x10 /* f1757a4: 102001a0 */ beqz $at,.L0f175e28 /* f1757a8: 0019c880 */ sll $t9,$t9,0x2 -/* f1757ac: 3c017f1b */ lui $at,%hi(var7f1b7c30) +/* f1757ac: 3c017f1b */ lui $at,%hi(jtbl_var7f1b7c30) /* f1757b0: 00390821 */ addu $at,$at,$t9 -/* f1757b4: 8c397c30 */ lw $t9,%lo(var7f1b7c30)($at) +/* f1757b4: 8c397c30 */ lw $t9,%lo(jtbl_var7f1b7c30)($at) /* f1757b8: 03200008 */ jr $t9 /* f1757bc: 00000000 */ nop .L0f1757c0: @@ -1648,6 +1630,7 @@ glabel var7f1b7c80 /* f1757c8: 8fb800e0 */ lw $t8,0xe0($sp) /* f1757cc: 10000197 */ b .L0f175e2c /* f1757d0: 8ea10000 */ lw $at,0x0($s5) +.L0f1757d4: /* f1757d4: 240c0001 */ addiu $t4,$zero,0x1 /* f1757d8: 13c00003 */ beqz $s8,.L0f1757e8 /* f1757dc: afac00e4 */ sw $t4,0xe4($sp) @@ -1689,11 +1672,12 @@ glabel var7f1b7c80 /* f175860: 2da10005 */ sltiu $at,$t5,0x5 /* f175864: 1020006f */ beqz $at,.L0f175a24 /* f175868: 000d6880 */ sll $t5,$t5,0x2 -/* f17586c: 3c017f1b */ lui $at,%hi(var7f1b7c70) +/* f17586c: 3c017f1b */ lui $at,%hi(jtbl_var7f1b7c70) /* f175870: 002d0821 */ addu $at,$at,$t5 -/* f175874: 8c2d7c70 */ lw $t5,%lo(var7f1b7c70)($at) +/* f175874: 8c2d7c70 */ lw $t5,%lo(jtbl_var7f1b7c70)($at) /* f175878: 01a00008 */ jr $t5 /* f17587c: 00000000 */ nop +.L0f175880: /* f175880: 8ea80004 */ lw $t0,0x4($s5) /* f175884: 00033582 */ srl $a2,$v1,0x16 /* f175888: 00033d02 */ srl $a3,$v1,0x14 @@ -1719,6 +1703,7 @@ glabel var7f1b7c80 /* f1758d8: 02202825 */ or $a1,$s1,$zero /* f1758dc: 10000051 */ b .L0f175a24 /* f1758e0: 0040b025 */ or $s6,$v0,$zero +.L0f1758e4: /* f1758e4: 8eb00004 */ lw $s0,0x4($s5) /* f1758e8: 8fa50144 */ lw $a1,0x144($sp) /* f1758ec: 00107b02 */ srl $t7,$s0,0xc @@ -1757,6 +1742,7 @@ glabel var7f1b7c80 /* f175970: 02202825 */ or $a1,$s1,$zero /* f175974: 1000002b */ b .L0f175a24 /* f175978: 0040b025 */ or $s6,$v0,$zero +.L0f17597c: /* f17597c: 00033582 */ srl $a2,$v1,0x16 /* f175980: 00033d02 */ srl $a3,$v1,0x14 /* f175984: 00031482 */ srl $v0,$v1,0x12 @@ -1772,6 +1758,7 @@ glabel var7f1b7c80 /* f1759ac: afb30014 */ sw $s3,0x14($sp) /* f1759b0: 1000001c */ b .L0f175a24 /* f1759b4: 0040b025 */ or $s6,$v0,$zero +.L0f1759b8: /* f1759b8: 00033582 */ srl $a2,$v1,0x16 /* f1759bc: 00033d02 */ srl $a3,$v1,0x14 /* f1759c0: 00031482 */ srl $v0,$v1,0x12 @@ -1786,6 +1773,7 @@ glabel var7f1b7c80 /* f1759e4: 02202825 */ or $a1,$s1,$zero /* f1759e8: 1000000e */ b .L0f175a24 /* f1759ec: 0040b025 */ or $s6,$v0,$zero +.L0f1759f0: /* f1759f0: 00033582 */ srl $a2,$v1,0x16 /* f1759f4: 00033d02 */ srl $a3,$v1,0x14 /* f1759f8: 00031482 */ srl $v0,$v1,0x12 @@ -1938,6 +1926,7 @@ glabel var7f1b7c80 /* f175bf8: 8eb9fffc */ lw $t9,-0x4($s5) /* f175bfc: 10000090 */ b .L0f175e40 /* f175c00: aed9fffc */ sw $t9,-0x4($s6) +.L0f175c04: /* f175c04: 240c0001 */ addiu $t4,$zero,0x1 /* f175c08: 13c00067 */ beqz $s8,.L0f175da8 /* f175c0c: afac0104 */ sw $t4,0x104($sp) @@ -2061,6 +2050,7 @@ glabel var7f1b7c80 /* f175dc0: 8eb8fffc */ lw $t8,-0x4($s5) /* f175dc4: 1000001e */ b .L0f175e40 /* f175dc8: aed8fffc */ sw $t8,-0x4($s6) +.L0f175dcc: /* f175dcc: 240d0001 */ addiu $t5,$zero,0x1 /* f175dd0: 001e102b */ sltu $v0,$zero,$s8 /* f175dd4: afad00e4 */ sw $t5,0xe4($sp) @@ -2078,6 +2068,7 @@ glabel var7f1b7c80 /* f175e00: 8eaefffc */ lw $t6,-0x4($s5) /* f175e04: 1000000e */ b .L0f175e40 /* f175e08: aecefffc */ sw $t6,-0x4($s6) +.L0f175e0c: /* f175e0c: 8ea10000 */ lw $at,0x0($s5) /* f175e10: 26d60008 */ addiu $s6,$s6,0x8 /* f175e14: 26b50008 */ addiu $s5,$s5,0x8 @@ -2147,6 +2138,331 @@ glabel var7f1b7c80 /* f175ef0: 27bd0138 */ addiu $sp,$sp,0x138 ); +// Mismatch: Extra move instruction in last half of G_VTX case +//s32 tex0f1756c0(Gfx *arg0, s32 arg1, Gfx *arg2, struct texturething *arg3, u32 arg4) +//{ +// struct texloadthing *v0; +// struct texloadthing *v0_2; +// Gfx *sp12c; +// s32 sp128; +// u32 tmp1; +// u32 tmp2; +// u32 tmp3; +// u32 tmp4; +// u32 tmp5; +// u32 tmp6; +// bool flag; +// s32 j; +// bool sp104; +// u8 animated; +// Gfx *s5; +// Gfx *s6; +// u32 spf4; +// s32 texturenum; +// s32 texturenum2; +// bool spe8; +// s32 spe4; +// s32 spe0; +// struct gfxvtx *spA0[16]; +// u8 sp90[16]; +// +// s32 i; +// +// sp12c = NULL; +// sp104 = true; +// animated = false; +// spe8 = false; +// spe4 = false; +// var800844d0 = false; +// spf4 = 0; +// s5 = arg0; +// s6 = arg2; +// +// sp128 = arg1 >> 3; +// +// tex0f173a08(); +// +// spe0 = func0f13c4f0(); +// +// if (spe0) { +// for (j = 0; j < 16; j++) { +// sp90[j] = 0; +// } +// } +// +// if (arg3 == NULL) { +// arg3 = &var800aabc8; +// } +// +// while (sp128 > 0) { +// switch (s5->texture.cmd) { +// case 0xc0: // Repurposed? +// spe4 = true; +// +// if (animated) { +// spe8 = true; +// } +// +// texturenum = s5->words.w1 & 0xfff; +// flag = s5->words.w0 & 0x200; +// +// texLoadFromTextureNum(texturenum, arg3); +// +// v0 = tex0f172e8c(texturenum, arg3); +// +// if (v0 != NULL) { +// spf4 = v0->unk0c_03; +// } else { +// spf4 = 0; +// } +// +// if (v0 != NULL) { +// s6 = tex0f1742e4(s6, sp12c, v0, sp104); +// sp104 = false; +// animated = false; +// +// switch (s5->unkc0.subcmd) { +// case 0: +// tmp6 = (s5->words.w1 >> 24) & 0xff; +// tmp1 = (s5->words.w0 >> 22) & 3; +// tmp2 = (s5->words.w0 >> 20) & 3; +// tmp3 = (s5->words.w0 >> 18) & 3; +// tmp4 = (s5->words.w0 >> 14) & 0xf; +// tmp5 = (s5->words.w0 >> 10) & 0xf; +// +// s6 = tex0f175490(s6, v0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, flag); +// break; +// case 1: +// texturenum2 = (s5->words.w1 >> 12) & 0xfff; +// texLoadFromTextureNum(texturenum2, arg3); +// v0_2 = tex0f172e8c(texturenum2, arg3); +// +// if (v0_2 != NULL) { +// tmp6 = (s5->words.w1 >> 24) & 0xff; +// tmp1 = (s5->words.w0 >> 22) & 3; +// tmp2 = (s5->words.w0 >> 20) & 3; +// tmp3 = (s5->words.w0 >> 18) & 3; +// tmp4 = (s5->words.w0 >> 14) & 0xf; +// tmp5 = (s5->words.w0 >> 10) & 0xf; +// +// s6 = tex0f175308(s6, v0, tmp1, tmp2, tmp3, v0_2, tmp4, tmp5, tmp6, flag); +// } +// break; +// case 2: +// tmp1 = (s5->words.w0 >> 22) & 3; +// tmp2 = (s5->words.w0 >> 20) & 3; +// tmp3 = (s5->words.w0 >> 18) & 3; +// +// s6 = tex0f1751e4(s6, v0, tmp1, tmp2, tmp3, flag); +// break; +// case 3: +// tmp1 = (s5->words.w0 >> 22) & 3; +// tmp2 = (s5->words.w0 >> 20) & 3; +// tmp3 = (s5->words.w0 >> 18) & 3; +// +// s6 = tex0f17563c(s6, v0, tmp1, tmp2, tmp3); +// break; +// case 4: +// tmp1 = (s5->words.w0 >> 22) & 3; +// tmp2 = (s5->words.w0 >> 20) & 3; +// tmp3 = (s5->words.w0 >> 18) & 3; +// +// s6 = tex0f1755dc(s6, v0, tmp1, tmp2, tmp3); +// break; +// } +// +// if (spe0 != 0) { +// if (texturenum == TEXTURE_06CB) { +// func0f13c2e8(1); +// animated = true; +// } +// +// if (texturenum == TEXTURE_0A6A) { +// func0f13c2e8(6); +// animated = true; +// } +// +// if (texturenum == TEXTURE_0A69) { +// func0f13c2e8(7); +// animated = true; +// } +// +// if (texturenum == TEXTURE_06E2) { +// func0f13c2e8(3); +// animated = true; +// } +// +// if (texturenum == TEXTURE_01C7 || texturenum == TEXTURE_0DAE) { +// func0f13c2e8(1); +// animated = true; +// } +// +// if (texturenum == TEXTURE_029B) { +// func0f13c2e8(4); +// animated = true; +// } +// +// if (texturenum == TEXTURE_090F) { +// func0f13c2e8(5); +// animated = true; +// } +// +// if (texturenum == TEXTURE_0A42) { +// func0f13c2e8(2); +// animated = true; +// } +// } +// } +// +// s5++; +// break; +// case G_VTX: +// { +// s32 start; +// s32 count; +// u32 offset; +// struct gfxvtx *vtx; +// +// if (spe0) { +// start = s5->bytes[1] & 0xf; +// count = ((u32)s5->bytes[1] >> 4) + 1; +// vtx = (struct gfxvtx *)(s5->dma.addr & 0x00ffffff); +// +// for (i = start; i < start + count; i++) { +// if (animated && sp90[i]) { +// func0f13c07c(spA0[i]); +// sp90[i] = 0; +// } +// +// spA0[i] = vtx; +// vtx++; +// } +// } +// +// if (spf4 && arg4) { +// // b7c +// u32 offset; +// struct gfxvtx *vtx; +// s32 i; +// +// count = (s5->dma.par >> 4) + 1; +// offset = s5->dma.addr & 0x00ffffff; +// i = 0; +// offset = (arg4 + offset); +// vtx = (struct gfxvtx *) offset; +// +// for (; i < count; i++) { +// vtx[i].unk08 >>= 1; +// vtx[i].unk0a >>= 1; +// } +// } +// } +// +// *s6 = *s5; +// s6++; +// s5++; +// break; +// case G_RDPPIPESYNC: +// var800844d0 = true; +// *s6 = *s5; +// s6++; +// s5++; +// break; +// case (u8)G_TRI4: +// case (u8)G_TRI1: +// if (animated) { +// if (s5->texture.cmd == (u8)G_TRI1) { +// sp90[s5->tri.tri.v[0] / 10] = 1; +// sp90[s5->tri.tri.v[1] / 10] = 1; +// sp90[s5->tri.tri.v[2] / 10] = 1; +// } else { +// // c68 +// if (s5->tri4.x1 != s5->tri4.y1 || s5->tri4.z1 != s5->tri4.y1) { +// sp90[s5->tri4.x1] = 1; +// sp90[s5->tri4.y1] = 1; +// sp90[s5->tri4.z1] = 1; +// } +// +// // cbc +// if (s5->tri4.x2 != s5->tri4.y2 || s5->tri4.z2 != s5->tri4.y2) { +// sp90[s5->tri4.x2] = 1; +// sp90[s5->tri4.y2] = 1; +// sp90[s5->tri4.z2] = 1; +// } +// +// // d0c +// if (s5->tri4.x3 != s5->tri4.y3 || s5->tri4.z3 != s5->tri4.y3) { +// sp90[s5->tri4.x3] = 1; +// sp90[s5->tri4.y3] = 1; +// sp90[s5->tri4.z3] = 1; +// } +// +// // d58 +// if (s5->tri4.x4 != s5->tri4.y4 || s5->tri4.z4 != s5->tri4.y4) { +// sp90[s5->tri4.x4] = 1; +// sp90[s5->tri4.y4] = 1; +// sp90[s5->tri4.z4] = 1; +// } +// } +// } +// +// sp104 = true; +// var800844d0 = false; +// +// *s6 = *s5; +// s6++; +// s5++; +// break; +// case (u8)G_TEXTURE: +// spe4 = true; +// +// if (animated) { +// spe8 = true; +// } +// +// animated = false; +// sp104 = false; +// +// sp12c = s6; +// *s6 = *s5; +// s6++; +// s5++; +// break; +// case (u8)G_SETOTHERMODE_H: +// *s6 = *s5; +// s6++; +// s5++; +// break; +// default: +// *s6 = *s5; +// s6++; +// s5++; +// break; +// } +// +// sp128--; +// +// if (spe4 || sp128 <= 0) { +// spe4 = false; +// +// if (spe8 || animated) { +// s32 i; +// +// spe8 = false; +// +// for (i = 0; i < 16; i++) { +// if (sp90[i]) { +// func0f13c07c(spA0[i]); +// sp90[i] = 0; +// } +// } +// } +// } +// } +// +// return (u32)s6 - (u32)arg2; +//} + void tex0f175ef4(Gfx *arg0, Gfx *arg1, s32 arg2) { arg2 = (arg2 >> 3); diff --git a/src/include/game/game_13b670.h b/src/include/game/game_13b670.h index 52caab866..fb389d42c 100644 --- a/src/include/game/game_13b670.h +++ b/src/include/game/game_13b670.h @@ -10,7 +10,7 @@ u32 func0f13b7bc(void); u32 func0f13b8a0(void); u32 func0f13bb5c(void); void func0f13bc48(s32 roomnum, struct gfxvtx *vertices); -void func0f13c07c(s32 arg0); +void func0f13c07c(struct gfxvtx *vertex); void func0f13c2e8(s16 arg0); void func0f13c370(s16 roomnum); void func0f13c3f4(void); diff --git a/src/include/game/tex.h b/src/include/game/tex.h index 25deecf2c..bf4796cc3 100644 --- a/src/include/game/tex.h +++ b/src/include/game/tex.h @@ -33,17 +33,17 @@ void tex0f173e50(struct texloadthing *arg0, s32 *arg1, s32 *arg2); s32 tex0f173f18(s32 arg0); s32 tex0f173f48(s32 arg0); u32 tex0f173f78(void); -u32 tex0f1742e4(void); +Gfx *tex0f1742e4(Gfx *arg0, Gfx *arg1, struct texloadthing *arg2, bool arg3); Gfx *tex0f1743a0(Gfx *gdl, struct texloadthing *arg1, s32 arg2); Gfx *tex0f1747a4(Gfx *gdl, struct texloadthing *arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, u32 arg7); u32 tex0f174b54(void); u32 tex0f174f30(void); -Gfx *tex0f1751e4(Gfx *gdl, struct texloadthing *arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5); -u32 tex0f175308(void); -u32 tex0f175490(void); -u32 tex0f1755dc(void); -u32 tex0f17563c(void); -s32 tex0f1756c0(s32 arg0, s32 arg1, s32 arg2, struct texturething *arg3, struct gfxvtx *arg4); +Gfx *tex0f1751e4(Gfx *gdl, struct texloadthing *arg1, s32 arg2, s32 arg3, s32 arg4, bool arg5); +Gfx *tex0f175308(Gfx *gdl, struct texloadthing *arg1, s32 arg2, s32 arg3, s32 arg4, struct texloadthing *arg5, s32 arg6, s32 arg7, s32 arg8, bool arg9); +Gfx *tex0f175490(Gfx *gdl, struct texloadthing *arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, bool arg8); +Gfx *tex0f1755dc(Gfx *gdl, struct texloadthing *arg1, s32 arg2, s32 arg3, s32 arg4); +Gfx *tex0f17563c(Gfx *gdl, struct texloadthing *arg1, s32 arg2, s32 arg3, s32 arg4); +s32 tex0f1756c0(Gfx *arg0, s32 arg1, Gfx *arg2, struct texturething *arg3, u32 arg4); void tex0f175ef4(Gfx *arg0, Gfx *arg1, s32 arg2); #endif diff --git a/src/include/gbiex.h b/src/include/gbiex.h index 3f54c30ea..56729e474 100644 --- a/src/include/gbiex.h +++ b/src/include/gbiex.h @@ -4,6 +4,9 @@ #include "data.h" #include "types.h" +#define G_SETCOLOR 0x07 +#define G_TRI4 0xb1 + /** * 04 rsp_uc05_vertex * @@ -18,7 +21,7 @@ #define gDPSetVerticeArray(pkt, ptr, numvertices) \ { \ Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = (_SHIFTL(0x04, 24, 8) \ + _g->words.w0 = (_SHIFTL(G_VTX, 24, 8) \ | _SHIFTL(numvertices - 1, 20, 4) \ | _SHIFTL(numvertices * sizeof(struct gfxvtx), 0, 20)); \ _g->words.w1 = (unsigned int)(ptr); \ @@ -39,7 +42,7 @@ #define gDPSetColorArray(pkt, ptr, numcolors) \ { \ Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = (_SHIFTL(0x07, 24, 8) \ + _g->words.w0 = (_SHIFTL(G_SETCOLOR, 24, 8) \ | _SHIFTL((numcolors - 1) * 4, 16, 8) \ | _SHIFTL(numcolors * 4, 0, 16)); \ _g->words.w1 = (unsigned int)(ptr); \ @@ -68,21 +71,21 @@ * 0000000f x1 */ #define gDPTri4(pkt, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = (_SHIFTL(0xb1, 24, 8) \ - | _SHIFTL(z4, 12, 4) \ - | _SHIFTL(z3, 8, 4) \ - | _SHIFTL(z2, 4, 4) \ - | _SHIFTL(z1, 0, 4)); \ - _g->words.w1 = (_SHIFTL(y4, 28, 4) \ - | _SHIFTL(x4, 24, 4) \ - | _SHIFTL(y3, 20, 4) \ - | _SHIFTL(x3, 16, 4) \ - | _SHIFTL(y2, 12, 4) \ - | _SHIFTL(x2, 8, 4) \ - | _SHIFTL(y1, 4, 4) \ - | _SHIFTL(x1, 0, 4)); \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + _g->words.w0 = (_SHIFTL(G_TRI4, 24, 8) \ + | _SHIFTL(z4, 12, 4) \ + | _SHIFTL(z3, 8, 4) \ + | _SHIFTL(z2, 4, 4) \ + | _SHIFTL(z1, 0, 4)); \ + _g->words.w1 = (_SHIFTL(y4, 28, 4) \ + | _SHIFTL(x4, 24, 4) \ + | _SHIFTL(y3, 20, 4) \ + | _SHIFTL(x3, 16, 4) \ + | _SHIFTL(y2, 12, 4) \ + | _SHIFTL(x2, 8, 4) \ + | _SHIFTL(y1, 4, 4) \ + | _SHIFTL(x1, 0, 4)); \ } #define gDPTri3(pkt, x1, y1, z1, x2, y2, z2, x3, y3, z3) \