1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-27 07:07:09 +00:00

gbi.h and ucode_disas.c cleanups (#1267)

* Merge GfxMod and Gfx, various ucode_disas improvements, gdSPDefMtx, gbi.h formatting improvements

* Suggested changes

* Further suggested changes

* Fix matrix

Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>

* Formatting changes

Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>

* Clarify Gnoop callback

* the thing

Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>

* Switch spaces, uintptr

Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
This commit is contained in:
Tharo 2022-10-15 22:14:35 +01:00 committed by GitHub
parent fd24ad6e67
commit 0b38f6e678
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 3370 additions and 2896 deletions

View file

@ -1679,7 +1679,7 @@ void DebugArena_Cleanup(void);
u8 DebugArena_IsInitialized(void); u8 DebugArena_IsInitialized(void);
void UCodeDisas_Init(UCodeDisas*); void UCodeDisas_Init(UCodeDisas*);
void UCodeDisas_Destroy(UCodeDisas*); void UCodeDisas_Destroy(UCodeDisas*);
// void UCodeDisas_Disassemble(UCodeDisas*, Gfx*); void UCodeDisas_Disassemble(UCodeDisas*, Gfx*);
void UCodeDisas_RegisterUCode(UCodeDisas*, s32, UCodeInfo*); void UCodeDisas_RegisterUCode(UCodeDisas*, s32, UCodeInfo*);
void UCodeDisas_SetCurUCode(UCodeDisas*, void*); void UCodeDisas_SetCurUCode(UCodeDisas*, void*);
Acmd* AudioSynth_Update(Acmd* cmdStart, s32* cmdCnt, s16* aiStart, s32 aiBufLen); Acmd* AudioSynth_Update(Acmd* cmdStart, s32* cmdCnt, s16* aiStart, s32 aiBufLen);

File diff suppressed because it is too large Load diff

View file

@ -23,20 +23,12 @@ typedef float f32;
typedef double f64; typedef double f64;
typedef long int Mtx_t[4][4];
typedef union {
Mtx_t m;
struct {
u16 intPart[4][4];
u16 fracPart[4][4];
};
long long int force_structure_alignment;
} Mtx;
typedef float MtxF_t[4][4]; typedef float MtxF_t[4][4];
typedef union { typedef union {
MtxF_t mf; MtxF_t mf;
struct { struct {
// Note: The order displayed here is the transpose of the order in which matrices are typically written.
// For example, [xw, yw, zw] is the translation part of the matrix, not [wx, wy, wz].
float xx, yx, zx, wx, float xx, yx, zx, wx,
xy, yy, zy, wy, xy, yy, zy, wy,
xz, yz, zz, wz, xz, yz, zz, wz,

View file

@ -1628,7 +1628,7 @@ typedef struct {
} UCodeInfo; // size = 0x8 } UCodeInfo; // size = 0x8
typedef struct { typedef struct {
/* 0x00 */ u32 segments[NUM_SEGMENTS]; /* 0x00 */ uintptr_t segments[NUM_SEGMENTS];
/* 0x40 */ Gfx* dlStack[18]; /* 0x40 */ Gfx* dlStack[18];
/* 0x88 */ s32 dlDepth; /* 0x88 */ s32 dlDepth;
/* 0x8C */ u32 dlCnt; /* 0x8C */ u32 dlCnt;

View file

@ -1,12 +1,12 @@
#include "global.h" #include "global.h"
// clang-format off // clang-format off
Mtx gMtxClear = { Mtx gMtxClear = gdSPDefMtx(
65536, 0, 1, 0, 1.0f, 0.0f, 0.0f, 0.0f,
0, 65536, 0, 1, 0.0f, 1.0f, 0.0f, 0.0f,
0, 0, 0, 0, 0.0f, 0.0f, 1.0f, 0.0f,
0, 0, 0, 0, 0.0f, 0.0f, 0.0f, 1.0f
}; );
MtxF gMtxFClear = { MtxF gMtxFClear = {
1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,

View file

@ -1,5 +1,7 @@
#include "global.h" #include "global.h"
typedef void (*UcodeDisasCallback)(UCodeDisas*, u32);
#define F3DZEX_CONST(name) \ #define F3DZEX_CONST(name) \
{ name, #name } { name, #name }
#define F3DZEX_FLAG(set, unset) \ #define F3DZEX_FLAG(set, unset) \
@ -17,8 +19,8 @@
if (this->enableLog) \ if (this->enableLog) \
osSyncPrintf osSyncPrintf
void* UCodeDisas_TranslateAddr(UCodeDisas* this, u32 addr) { void* UCodeDisas_TranslateAddr(UCodeDisas* this, uintptr_t addr) {
u32 physical = this->segments[SEGMENT_NUMBER(addr)] + SEGMENT_OFFSET(addr); uintptr_t physical = this->segments[SEGMENT_NUMBER(addr)] + SEGMENT_OFFSET(addr);
return PHYSICAL_TO_VIRTUAL(physical); return PHYSICAL_TO_VIRTUAL(physical);
} }
@ -38,61 +40,82 @@ F3dzexFlag sUCodeDisasMtxFlags[] = {
F3DZEX_FLAG(G_MTX_PUSH, G_MTX_NOPUSH), F3DZEX_FLAG(G_MTX_PUSH, G_MTX_NOPUSH),
}; };
const char* UCodeDisas_ParseCombineColor(u32 value, u32 idx) { typedef enum { COMBINER_A = 1, COMBINER_B, COMBINER_C, COMBINER_D } CombinerArg;
const char* UCodeDisas_GetCombineColorName(u32 value, u32 arg) {
const char* ret = "?"; const char* ret = "?";
switch (value) { switch (value) {
case G_CCMUX_COMBINED: case G_CCMUX_COMBINED:
ret = "COMBINED"; ret = "COMBINED";
break; break;
case G_CCMUX_TEXEL0: case G_CCMUX_TEXEL0:
ret = "TEXEL0"; ret = "TEXEL0";
break; break;
case G_CCMUX_TEXEL1: case G_CCMUX_TEXEL1:
ret = "TEXEL1"; ret = "TEXEL1";
break; break;
case G_CCMUX_PRIMITIVE: case G_CCMUX_PRIMITIVE:
ret = "PRIMITIVE"; ret = "PRIMITIVE";
break; break;
case G_CCMUX_SHADE: case G_CCMUX_SHADE:
ret = "SHADE"; ret = "SHADE";
break; break;
case G_CCMUX_ENVIRONMENT: case G_CCMUX_ENVIRONMENT:
ret = "ENVIRONMENT"; ret = "ENVIRONMENT";
break; break;
case 6:
ret = (idx == 2) ? "CENTER" : (idx == 3) ? "SCALE" : "1"; case 6: // G_CCMUX_CENTER, G_CCMUX_SCALE, G_CCMUX_1
ret = (arg == COMBINER_B) ? "CENTER" : (arg == COMBINER_C) ? "SCALE" : "1";
break; break;
case 7:
ret = (idx == 1) ? "NOISE" : (idx == 2) ? "K4" : (idx == 3) ? "COMBINED_ALPHA" : "0"; case 7: // G_CCMUX_NOISE, G_CCMUX_K4, G_CCMUX_COMBINED_ALPHA, G_CCMUX_0
ret = (arg == COMBINER_A) ? "NOISE"
: (arg == COMBINER_B) ? "K4"
: (arg == COMBINER_C) ? "COMBINED_ALPHA"
: "0";
break; break;
default: default:
if (idx == 3) { if (arg == COMBINER_C) {
switch (value) { switch (value) {
case G_CCMUX_TEXEL0_ALPHA: case G_CCMUX_TEXEL0_ALPHA:
ret = "TEXEL0_ALPHA"; ret = "TEXEL0_ALPHA";
break; break;
case G_CCMUX_TEXEL1_ALPHA: case G_CCMUX_TEXEL1_ALPHA:
ret = "TEXEL1_ALPHA"; ret = "TEXEL1_ALPHA";
break; break;
case G_CCMUX_PRIMITIVE_ALPHA: case G_CCMUX_PRIMITIVE_ALPHA:
ret = "PRIMITIVE_ALPHA"; ret = "PRIMITIVE_ALPHA";
break; break;
case G_CCMUX_SHADE_ALPHA: case G_CCMUX_SHADE_ALPHA:
ret = "SHADE_ALPHA"; ret = "SHADE_ALPHA";
break; break;
case G_CCMUX_ENV_ALPHA: case G_CCMUX_ENV_ALPHA:
ret = "ENV_ALPHA"; ret = "ENV_ALPHA";
break; break;
case G_CCMUX_LOD_FRACTION: case G_CCMUX_LOD_FRACTION:
ret = "LOD_FRACTION"; ret = "LOD_FRACTION";
break; break;
case G_CCMUX_PRIM_LOD_FRAC: case G_CCMUX_PRIM_LOD_FRAC:
ret = "PRIM_LOD_FRAC"; ret = "PRIM_LOD_FRAC";
break; break;
case G_CCMUX_K5: case G_CCMUX_K5:
ret = "K5"; ret = "K5";
break; break;
default: default:
ret = "0"; ret = "0";
break; break;
@ -104,30 +127,38 @@ const char* UCodeDisas_ParseCombineColor(u32 value, u32 idx) {
return ret; return ret;
} }
const char* UCodeDisas_ParseCombineAlpha(u32 value, u32 idx) { const char* UCodeDisas_GetCombineAlphaName(u32 value, u32 arg) {
const char* ret = "?"; const char* ret = "?";
switch (value) { switch (value) {
case 0: case 0: // G_ACMUX_LOD_FRACTION, G_ACMUX_COMBINED
ret = (idx == 3) ? "LOD_FRACTION" : "COMBINED"; ret = (arg == COMBINER_C) ? "LOD_FRACTION" : "COMBINED";
break; break;
case G_ACMUX_TEXEL0: case G_ACMUX_TEXEL0:
ret = "TEXEL0"; ret = "TEXEL0";
break; break;
case G_ACMUX_TEXEL1: case G_ACMUX_TEXEL1:
ret = "TEXEL1"; ret = "TEXEL1";
break; break;
case G_ACMUX_PRIMITIVE: case G_ACMUX_PRIMITIVE:
ret = "PRIMITIVE"; ret = "PRIMITIVE";
break; break;
case G_ACMUX_SHADE: case G_ACMUX_SHADE:
ret = "SHADE"; ret = "SHADE";
break; break;
case G_ACMUX_ENVIRONMENT: case G_ACMUX_ENVIRONMENT:
ret = "ENVIRONMENT"; ret = "ENVIRONMENT";
break; break;
case 6:
ret = (idx == 3) ? "PRIM_LOD_FRAC" : "1"; case 6: // G_ACMUX_PRIM_LOD_FRAC, G_ACMUX_1
ret = (arg == COMBINER_C) ? "PRIM_LOD_FRAC" : "1";
break; break;
case G_ACMUX_0: case G_ACMUX_0:
ret = "0"; ret = "0";
break; break;
@ -162,7 +193,7 @@ void UCodeDisas_SetCurUCodeImpl(UCodeDisas* this, void* ptr) {
} }
} }
void UCodeDisas_ParseGeometryMode(UCodeDisas* this, u32 mode) { void UCodeDisas_PrintGeometryMode(UCodeDisas* this, u32 mode) {
u32 first = true; u32 first = true;
s32 i; s32 i;
@ -181,7 +212,7 @@ void UCodeDisas_ParseGeometryMode(UCodeDisas* this, u32 mode) {
} }
} }
void UCodeDisas_ParseRenderMode(UCodeDisas* this, u32 mode) { void UCodeDisas_PrintRenderMode(UCodeDisas* this, u32 mode) {
static F3dzexRenderMode sUCodeDisasRenderModeFlags[] = { static F3dzexRenderMode sUCodeDisasRenderModeFlags[] = {
F3DZEX_RENDERMODE(AA_EN, 0x8), F3DZEX_RENDERMODE(AA_EN, 0x8),
F3DZEX_RENDERMODE(Z_CMP, 0x10), F3DZEX_RENDERMODE(Z_CMP, 0x10),
@ -200,7 +231,7 @@ void UCodeDisas_ParseRenderMode(UCodeDisas* this, u32 mode) {
F3DZEX_RENDERMODE(ALPHA_CVG_SEL, 0x2000), F3DZEX_RENDERMODE(ALPHA_CVG_SEL, 0x2000),
F3DZEX_RENDERMODE(FORCE_BL, 0x4000), F3DZEX_RENDERMODE(FORCE_BL, 0x4000),
}; };
static const char* D_8012DDDC[4][4] = { static const char* sBlenderInputNames[4][4] = {
{ "G_BL_CLR_IN", "G_BL_CLR_MEM", "G_BL_CLR_BL", "G_BL_CLR_FOG" }, { "G_BL_CLR_IN", "G_BL_CLR_MEM", "G_BL_CLR_BL", "G_BL_CLR_FOG" },
{ "G_BL_A_IN", "G_BL_A_FOG", "G_BL_A_SHADE", "G_BL_0" }, { "G_BL_A_IN", "G_BL_A_FOG", "G_BL_A_SHADE", "G_BL_0" },
{ "G_BL_CLR_IN", "G_BL_CLR_MEM", "G_BL_CLR_BL", "G_BL_CLR_FOG" }, { "G_BL_CLR_IN", "G_BL_CLR_MEM", "G_BL_CLR_BL", "G_BL_CLR_FOG" },
@ -224,18 +255,19 @@ void UCodeDisas_ParseRenderMode(UCodeDisas* this, u32 mode) {
// clang-format off // clang-format off
if (this->enableLog == 0) {} else { osSyncPrintf("\nGBL_c1(%s, %s, %s, %s)|", if (this->enableLog == 0) {} else { osSyncPrintf("\nGBL_c1(%s, %s, %s, %s)|",
D_8012DDDC[0][a >> 12 & 3], D_8012DDDC[1][a >> 8 & 3], D_8012DDDC[2][a >> 4 & 3], D_8012DDDC[3][a >> 0 & 3]); sBlenderInputNames[0][a >> 12 & 3], sBlenderInputNames[1][a >> 8 & 3], sBlenderInputNames[2][a >> 4 & 3], sBlenderInputNames[3][a >> 0 & 3]);
} }
// clang-format on // clang-format on
if (this->enableLog) { if (this->enableLog) {
osSyncPrintf("\nGBL_c2(%s, %s, %s, %s)", D_8012DDDC[0][b >> 12 & 3], D_8012DDDC[1][b >> 8 & 3], osSyncPrintf("\nGBL_c2(%s, %s, %s, %s)", sBlenderInputNames[0][b >> 12 & 3], sBlenderInputNames[1][b >> 8 & 3],
D_8012DDDC[2][b >> 4 & 3], D_8012DDDC[3][b >> 0 & 3]); sBlenderInputNames[2][b >> 4 & 3], sBlenderInputNames[3][b >> 0 & 3]);
} }
} }
void UCodeDisas_PrintVertices(UCodeDisas* this, Vtx* vtx, s32 count, s32 start) { void UCodeDisas_PrintVertices(UCodeDisas* this, Vtx* vtx, s32 count, s32 start) {
s32 i; s32 i;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (this->geometryMode & G_LIGHTING) { if (this->geometryMode & G_LIGHTING) {
DISAS_LOG("\n{{%6d, %6d, %6d, %d, %6d, %6d, %3d, %3d, %3d, %3d}}, /* vc%d */", vtx->n.ob[0], vtx->n.ob[1], DISAS_LOG("\n{{%6d, %6d, %6d, %d, %6d, %6d, %3d, %3d, %3d, %3d}}, /* vc%d */", vtx->n.ob[0], vtx->n.ob[1],
@ -252,225 +284,32 @@ void UCodeDisas_PrintVertices(UCodeDisas* this, Vtx* vtx, s32 count, s32 start)
} }
} }
// Todo: clean this up void UCodeDisas_Disassemble(UCodeDisas* this, Gfx* ptr) {
typedef struct {
s8 cmd;
u8 v0;
u8 v1;
u8 wd;
u32 pad; u32 pad;
} Gline3DFix; uintptr_t addr;
typedef struct {
int cmd : 8;
u32 pad : 4;
u32 numv : 8;
s32 pad2 : 4;
u8 vbidx;
} Gvtx;
typedef struct {
u8 pad : 8;
u8 v0 : 8;
u8 v1 : 8;
u8 v2 : 8;
} Gtrimod;
typedef struct {
int cmd : 8;
int pad : 24;
Gtrimod tri;
} Gtri1;
typedef struct {
Gtrimod tri1;
Gtrimod tri2;
} Gtri2;
typedef struct {
u8 pad : 8;
u8 v0 : 8;
u8 v1 : 8;
u8 v2 : 8;
u8 pad1 : 8;
u8 pad2 : 8;
u8 pad3 : 8;
u8 v3 : 8;
} Gquadmod;
typedef struct {
u16 pad;
u16 vstart;
u16 pad2;
u16 vend;
} Gcull;
typedef struct {
u16 pad;
u16 vstart;
u16 pad2;
u16 vend;
} Gbranchz;
typedef struct {
int cmd : 8;
u8 pad;
u8 prim_min_level;
u8 prim_level;
u8 r;
u8 g;
u8 b;
u8 a;
} GsetcolorMod;
typedef struct {
u8 cmd;
char pad[3];
u16 z;
u16 d;
} Gsetprimdepth;
typedef struct {
u8 cmd;
u8 type;
u16 len;
union {
u32 u32;
f32 f32;
} value;
} Gnoop;
typedef struct {
u8 cmd;
u8 pad[2];
u8 params;
u32 addr;
} Gmatrix;
typedef struct {
u8 cmd;
u32 a : 4;
u32 c : 5;
u32 z : 3;
u32 x : 3;
u32 e : 4;
u32 g : 5;
u32 b : 4;
u32 f : 4;
u32 v : 3;
u32 t : 3;
u32 d : 3;
u32 y : 3;
u32 w : 3;
u32 h : 3;
u32 u : 3;
u32 s : 3;
} GsetcombineMod;
typedef struct {
u32 cmd : 8;
u32 pad0 : 8;
u32 sft : 8;
u32 len : 8;
u32 data : 32;
} GsetothermodeMod;
typedef struct {
s32 cmd : 8;
u32 offset : 16;
u32 index : 8;
u32 data;
} Gmovewd;
typedef struct {
s32 cmd : 8;
u32 size : 8;
u32 offset : 8;
u32 index : 8;
u32 data;
} Gmovemem;
typedef struct {
u8 cmd : 8;
u8 lodscale : 8;
u8 pad : 2;
u8 level : 3;
u8 tile : 3;
unsigned char on;
unsigned short s;
unsigned short t;
} Gtexturemod;
typedef struct {
int cmd : 8;
int pad1 : 24;
u32 param : 26;
unsigned char pad3 : 6;
} Gpopmtxmod;
typedef union {
Gwords words;
Gnoop noop;
Gmatrix matrix;
Gdma dma;
Gtri1 tri1;
Gtri2 tri2;
Gquadmod quad;
Gcull cull;
Gline3D line;
Gline3DFix linefix;
Gmovewd movewd;
Gmovemem movemem;
Gpopmtx popmtx;
Gpopmtxmod popmtxmod;
Gsegment segment;
GsetothermodeH setothermodeH;
GsetothermodeL setothermodeL;
GsetothermodeMod setothermode;
Gtexture texture;
Gtexturemod texmod;
Gperspnorm perspnorm;
Gsetimg setimg;
GsetcombineMod setcombine;
GsetcolorMod setcolor; // mod
Gfillrect fillrect; /* use for setscissor also */
Gsettile settile;
Gloadtile loadtile; /* use for loadblock also, th is dxt */
Gsettilesize settilesize;
Gloadtlut loadtlut;
Gsetprimdepth setprimdepth;
Gvtx vtx;
long long int force_structure_alignment;
} GfxMod;
void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
u32 pad;
u32 addr;
u32 rdpHalf; u32 rdpHalf;
u16 linkDlLow; u16 linkDlLow;
u8 sid; u8 sid;
u8 cmd; u8 cmd;
s32 i0; s32 i;
u32 exit; u32 exit;
GfxMod curGfx[1]; Gfx curGfx[1];
exit = false; exit = false;
while (!exit) { while (!exit) {
this->dlCnt++; this->dlCnt++;
ptr = UCodeDisas_TranslateAddr(this, (u32)ptr); ptr = UCodeDisas_TranslateAddr(this, (uintptr_t)ptr);
DISAS_LOG("%08x:", ptr); DISAS_LOG("%08x:", ptr);
*curGfx = *ptr; *curGfx = *ptr;
cmd = curGfx->dma.cmd; cmd = curGfx->noop.cmd;
addr = (u32)UCodeDisas_TranslateAddr(this, curGfx->dma.addr); addr = (uintptr_t)UCodeDisas_TranslateAddr(this, (uintptr_t)curGfx->noop.value.addr);
DISAS_LOG("%08x-%08x:", curGfx->words.w0, curGfx->words.w1); DISAS_LOG("%08x-%08x:", curGfx->words.w0, curGfx->words.w1);
for (i0 = 0; i0 < this->dlDepth; i0++) { for (i = 0; i < this->dlDepth; i++) {
DISAS_LOG(" "); DISAS_LOG(" ");
} }
@ -483,15 +322,15 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
Gdma dma = ptr->dma; Gdma dma = ptr->dma;
switch (dma.par) { switch (dma.par) {
case 0: { case G_DL_PUSH: {
DISAS_LOG("gsSPDisplayList(0x%08x),", dma.addr); DISAS_LOG("gsSPDisplayList(0x%08x),", dma.addr);
this->dlStack[this->dlDepth++] = (Gfx*)(ptr + 1); this->dlStack[this->dlDepth++] = (Gfx*)(ptr + 1);
ptr = (GfxMod*)addr - 1; ptr = (Gfx*)addr - 1;
} break; } break;
case 1: { case G_DL_NOPUSH: {
DISAS_LOG("gsSPBranchList(0x%08x),", dma.addr); DISAS_LOG("gsSPBranchList(0x%08x),", dma.addr);
ptr = (GfxMod*)addr - 1; ptr = (Gfx*)addr - 1;
} break; } break;
} }
} break; } break;
@ -513,7 +352,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
} break; } break;
case G_LOAD_UCODE: { case G_LOAD_UCODE: {
if (curGfx->dma.len == 0x7FF) { if (curGfx->dma.len == SP_UCODE_DATA_SIZE - 1) {
DISAS_LOG("gsSPLoadUcode(0x%08x, 0x%08x),", curGfx->dma.addr, rdpHalf); DISAS_LOG("gsSPLoadUcode(0x%08x, 0x%08x),", curGfx->dma.addr, rdpHalf);
} else { } else {
DISAS_LOG("gsSPLoadUcodeEx(0x%08x, 0x%08x, 0x%05x),", curGfx->dma.addr, rdpHalf, DISAS_LOG("gsSPLoadUcodeEx(0x%08x, 0x%08x, 0x%05x),", curGfx->dma.addr, rdpHalf,
@ -528,7 +367,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
if (this->dlDepth <= 0) { if (this->dlDepth <= 0) {
exit = true; exit = true;
} else { } else {
ptr = (GfxMod*)this->dlStack[--this->dlDepth] - 1; ptr = this->dlStack[--this->dlDepth] - 1;
} }
} break; } break;
@ -579,20 +418,28 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
} break; } break;
case G_SETCOMBINE: { case G_SETCOMBINE: {
GsetcombineMod setcombine = ptr->setcombine; Gsetcombine setcombine = ptr->setcombine;
DISAS_LOG("gsDPSetCombineLERP(%s,%s,%s,%s, %s,%s,%s,%s, %s,%s,%s,%s, %s,%s,%s,%s),", DISAS_LOG("gsDPSetCombineLERP(%s,%s,%s,%s, %s,%s,%s,%s, %s,%s,%s,%s, %s,%s,%s,%s),",
UCodeDisas_ParseCombineColor(setcombine.a, 1), UCodeDisas_ParseCombineColor(setcombine.b, 2), UCodeDisas_GetCombineColorName(setcombine.a0, COMBINER_A),
UCodeDisas_ParseCombineColor(setcombine.c, 3), UCodeDisas_ParseCombineColor(setcombine.d, 4), UCodeDisas_GetCombineColorName(setcombine.b0, COMBINER_B),
UCodeDisas_GetCombineColorName(setcombine.c0, COMBINER_C),
UCodeDisas_GetCombineColorName(setcombine.d0, COMBINER_D),
UCodeDisas_ParseCombineAlpha(setcombine.z, 1), UCodeDisas_ParseCombineAlpha(setcombine.y, 2), UCodeDisas_GetCombineAlphaName(setcombine.Aa0, COMBINER_A),
UCodeDisas_ParseCombineAlpha(setcombine.x, 3), UCodeDisas_ParseCombineAlpha(setcombine.w, 4), UCodeDisas_GetCombineAlphaName(setcombine.Ab0, COMBINER_B),
UCodeDisas_GetCombineAlphaName(setcombine.Ac0, COMBINER_C),
UCodeDisas_GetCombineAlphaName(setcombine.Ad0, COMBINER_D),
UCodeDisas_ParseCombineColor(setcombine.e, 1), UCodeDisas_ParseCombineColor(setcombine.f, 2), UCodeDisas_GetCombineColorName(setcombine.a1, COMBINER_A),
UCodeDisas_ParseCombineColor(setcombine.g, 3), UCodeDisas_ParseCombineColor(setcombine.h, 4), UCodeDisas_GetCombineColorName(setcombine.b1, COMBINER_B),
UCodeDisas_GetCombineColorName(setcombine.c1, COMBINER_C),
UCodeDisas_GetCombineColorName(setcombine.d1, COMBINER_D),
UCodeDisas_ParseCombineAlpha(setcombine.v, 1), UCodeDisas_ParseCombineAlpha(setcombine.u, 2), UCodeDisas_GetCombineAlphaName(setcombine.Aa1, COMBINER_A),
UCodeDisas_ParseCombineAlpha(setcombine.t, 3), UCodeDisas_ParseCombineAlpha(setcombine.s, 4)); UCodeDisas_GetCombineAlphaName(setcombine.Ab1, COMBINER_B),
UCodeDisas_GetCombineAlphaName(setcombine.Ac1, COMBINER_C),
UCodeDisas_GetCombineAlphaName(setcombine.Ad1, COMBINER_D));
if (this->pipeSyncRequired) { if (this->pipeSyncRequired) {
DISAS_LOG("### PipeSyncが必要です。\n"); DISAS_LOG("### PipeSyncが必要です。\n");
@ -624,34 +471,33 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
-1), -1),
}; };
u32 len = curGfx->setothermode.len + 1; u32 len = curGfx->setothermodeH.len + 1;
u32 sft = (-curGfx->setothermode.sft - len) + 32; u32 sft = (-curGfx->setothermodeH.sft - len) + 32;
u32 s2 = curGfx->setothermode.data * 1; u32 s2 = curGfx->setothermodeH.data * 1;
u32 i1; u32 j;
u32 i2; u32 k;
for (i1 = 0; i1 < ARRAY_COUNTU(sUCodeDisasModeHMacros); i1++) { for (j = 0; j < ARRAY_COUNTU(sUCodeDisasModeHMacros); j++) {
if (sft == sUCodeDisasModeHMacros[i1].shift) { if (sft == sUCodeDisasModeHMacros[j].shift) {
for (i2 = 0; i2 < 4; i2++) { for (k = 0; k < ARRAY_COUNTU(sUCodeDisasModeHMacros[j].values); k++) {
if (s2 == sUCodeDisasModeHMacros[i1].values[i2].value) { if (s2 == sUCodeDisasModeHMacros[j].values[k].value) {
DISAS_LOG("gsDP%s(%s),", sUCodeDisasModeHMacros[i1].name, DISAS_LOG("gsDP%s(%s),", sUCodeDisasModeHMacros[j].name,
sUCodeDisasModeHMacros[i1].values[i2].name); sUCodeDisasModeHMacros[j].values[k].name);
goto block_1; goto found_othermode_hi_macro;
} }
} }
} }
} }
DISAS_LOG("gsSPSetOtherModeH(%d, %d, 0x%08x),", sft, len, s2); DISAS_LOG("gsSPSetOtherModeH(%d, %d, 0x%08x),", sft, len, s2);
block_1: found_othermode_hi_macro:
this->modeH &= (((1 - (1 << len)) << sft) - 1); this->modeH &= ((1 - (1 << len)) << sft) - 1;
this->modeH |= s2; this->modeH |= s2;
if (this->pipeSyncRequired) { if (this->pipeSyncRequired) {
DISAS_LOG("### PipeSyncが必要です。\n"); DISAS_LOG("### PipeSyncが必要です。\n");
this->syncErr++; this->syncErr++;
} }
} break; } break;
case G_SETOTHERMODE_L: { case G_SETOTHERMODE_L: {
@ -661,24 +507,24 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
F3DZEX_SETRENDERMACRO("gsDPSetDepthSource", G_MDSFT_ZSRCSEL, 1, G_ZS_PIXEL, G_ZS_PRIM, -1, -1), F3DZEX_SETRENDERMACRO("gsDPSetDepthSource", G_MDSFT_ZSRCSEL, 1, G_ZS_PIXEL, G_ZS_PRIM, -1, -1),
}; };
u32 len = curGfx->setothermode.len + 1; u32 len = curGfx->setothermodeL.len + 1;
u32 sft = (-curGfx->setothermode.sft - len) + 32; u32 sft = (-curGfx->setothermodeL.sft - len) + 32;
u32 s2 = curGfx->setothermode.data * 1; u32 s2 = curGfx->setothermodeL.data * 1;
u32 i1; u32 j;
u32 i2; u32 k;
if (sft == G_MDSFT_RENDERMODE) { if (sft == G_MDSFT_RENDERMODE) {
DISAS_LOG("\ngsDPSetRenderBlender("); DISAS_LOG("\ngsDPSetRenderBlender(");
UCodeDisas_ParseRenderMode(this, s2); UCodeDisas_PrintRenderMode(this, s2);
DISAS_LOG("\n),"); DISAS_LOG("\n),");
} else { } else {
for (i1 = 0; i1 * 1 < ARRAY_COUNTU(sUCodeDisasModeLMacros); i1++) { for (j = 0; j * 1 < ARRAY_COUNTU(sUCodeDisasModeLMacros); j++) {
if (sft == sUCodeDisasModeLMacros[i1].shift) { if (sft == sUCodeDisasModeLMacros[j].shift) {
for (i2 = 0; i2 < 4; i2++) { for (k = 0; k < ARRAY_COUNTU(sUCodeDisasModeLMacros[j].values); k++) {
if (s2 == sUCodeDisasModeLMacros[i1].values[i2].value) { if (s2 == sUCodeDisasModeLMacros[j].values[k].value) {
DISAS_LOG("gsDP%s(%s),", sUCodeDisasModeLMacros[i1].name, DISAS_LOG("gsDP%s(%s),", sUCodeDisasModeLMacros[j].name,
sUCodeDisasModeLMacros[i1].values[i2].name); sUCodeDisasModeLMacros[j].values[k].name);
goto block_2; goto found_othermode_lo_macro;
} }
} }
} }
@ -686,7 +532,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
DISAS_LOG("gsSPSetOtherModeL(%d, %d, 0x%08x),", sft, len, s2); DISAS_LOG("gsSPSetOtherModeL(%d, %d, 0x%08x),", sft, len, s2);
} }
block_2: found_othermode_lo_macro:
this->modeL &= (((1 - (1 << len)) << sft) - 1); this->modeL &= (((1 - (1 << len)) << sft) - 1);
this->modeL |= s2; this->modeL |= s2;
@ -758,7 +604,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
} break; } break;
case G_SETZIMG: { case G_SETZIMG: {
DISAS_LOG("gsDPSetDepthImage(0x%08x(0x%08x)),", curGfx->words.w1, addr); DISAS_LOG("gsDPSetDepthImage(0x%08x(0x%08x)),", curGfx->setimg.dram, addr);
if (this->pipeSyncRequired) { if (this->pipeSyncRequired) {
DISAS_LOG("### PipeSyncが必要です。\n"); DISAS_LOG("### PipeSyncが必要です。\n");
@ -814,7 +660,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
} break; } break;
case G_SETFILLCOLOR: { case G_SETFILLCOLOR: {
DISAS_LOG("gsDPSetFillColor(0x%08x),", curGfx->words.w1); DISAS_LOG("gsDPSetFillColor(0x%08x),", curGfx->setcolor.color);
if (this->pipeSyncRequired) { if (this->pipeSyncRequired) {
DISAS_LOG("### PipeSyncが必要です。\n"); DISAS_LOG("### PipeSyncが必要です。\n");
@ -823,7 +669,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
} break; } break;
case G_SETPRIMDEPTH: { case G_SETPRIMDEPTH: {
DISAS_LOG("gsDPSetPrimDepth(%d, %d),", curGfx->setprimdepth.z, curGfx->setprimdepth.d); DISAS_LOG("gsDPSetPrimDepth(%d, %d),", curGfx->setprimdepth.z, curGfx->setprimdepth.dz);
if (this->pipeSyncRequired) { if (this->pipeSyncRequired) {
DISAS_LOG("### PipeSyncが必要です。\n"); DISAS_LOG("### PipeSyncが必要です。\n");
@ -872,19 +718,19 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
} break; } break;
case 1: { case 1: {
DISAS_LOG("count_gsDPNoOpHere([%s:%d]),", curGfx->noop.value.u32, curGfx->noop.len); DISAS_LOG("count_gsDPNoOpHere([%s:%d]),", curGfx->noop.value.str, curGfx->noop.len);
} break; } break;
case 7: { case 7: {
DISAS_LOG("count_gsDPNoOpOpenDisp([%s:%d]),", curGfx->noop.value.u32, curGfx->noop.len); DISAS_LOG("count_gsDPNoOpOpenDisp([%s:%d]),", curGfx->noop.value.str, curGfx->noop.len);
} break; } break;
case 8: { case 8: {
DISAS_LOG("count_gsDPNoOpCloseDisp([%s:%d]),", curGfx->noop.value.u32, curGfx->noop.len); DISAS_LOG("count_gsDPNoOpCloseDisp([%s:%d]),", curGfx->noop.value.str, curGfx->noop.len);
} break; } break;
case 2: { case 2: {
DISAS_LOG("count_gsDPNoOpString(%c%s%c, %d),", '"', curGfx->noop.value.u32, '"', DISAS_LOG("count_gsDPNoOpString(%c%s%c, %d),", '"', curGfx->noop.value.str, '"',
curGfx->noop.len); curGfx->noop.len);
} break; } break;
@ -906,9 +752,9 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
} break; } break;
case 6: { case 6: {
/*! @bug arguments are not printed */ //! @bug arguments are not printed
DISAS_LOG("count_gsDPNoOpCallBack(%08x,%d),"); DISAS_LOG("count_gsDPNoOpCallBack(%08x,%d),");
((void (*)(UCodeDisas*, u32))curGfx->noop.value.u32)(this, curGfx->noop.len); ((UcodeDisasCallback)curGfx->noop.value.callback)(this, curGfx->noop.len);
} break; } break;
default: { default: {
@ -924,27 +770,27 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
case UCODE_UNK: { case UCODE_UNK: {
switch (cmd) { switch (cmd) {
case G_MTX: { case G_MTX: {
Gmatrix gmtx = ptr->matrix; Gdma2 gmtx = ptr->dma2;
u32 params; u32 params;
MtxF mtx; MtxF mtxF;
s32 i1 = 0; s32 j = 0;
DISAS_LOG("gsSPMatrix(0x%08x(%08x), 0", gmtx.addr, addr); DISAS_LOG("gsSPMatrix(0x%08x(%08x), 0", gmtx.addr, addr);
params = (gmtx.params ^ G_MTX_PUSH); params = gmtx.par ^ G_MTX_PUSH;
for (; i1 != ARRAY_COUNT(sUCodeDisasMtxFlags); i1++) { for (; j != ARRAY_COUNT(sUCodeDisasMtxFlags); j++) {
DISAS_LOG("|%s", (sUCodeDisasMtxFlags[i1].value & params) DISAS_LOG("|%s", (sUCodeDisasMtxFlags[j].value & params)
? sUCodeDisasMtxFlags[i1].setName ? sUCodeDisasMtxFlags[j].setName
: sUCodeDisasMtxFlags[i1].unsetName); : sUCodeDisasMtxFlags[j].unsetName);
} }
DISAS_LOG("),", gmtx.addr); /*! @bug gmtx.addr shouldn't be here*/ DISAS_LOG("),", gmtx.addr); //! @bug gmtx.addr shouldn't be here
if (this->enableLog >= 2) { if (this->enableLog >= 2) {
MtxConv_L2F(&mtx, (Mtx*)addr); MtxConv_L2F(&mtxF, (Mtx*)addr);
DISAS_LOG("\n"); DISAS_LOG("\n");
/*! @bug %.04x.%04x is a typo, should be %04x.%04x */ //! @bug %.04x.%04x is a typo, should be %04x.%04x
// clang-format off // clang-format off
DISAS_LOG( DISAS_LOG(
"/ %04x.%04x %04x.%04x %04x.%04x %.04x.%04x \\/ %12.6f %12.6f %12.6f %12.6f \\\n" "/ %04x.%04x %04x.%04x %04x.%04x %.04x.%04x \\/ %12.6f %12.6f %12.6f %12.6f \\\n"
@ -955,22 +801,22 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
((Mtx*)addr)->intPart[1][0], ((Mtx*)addr)->fracPart[1][0], ((Mtx*)addr)->intPart[1][0], ((Mtx*)addr)->fracPart[1][0],
((Mtx*)addr)->intPart[2][0], ((Mtx*)addr)->fracPart[2][0], ((Mtx*)addr)->intPart[2][0], ((Mtx*)addr)->fracPart[2][0],
((Mtx*)addr)->intPart[3][0], ((Mtx*)addr)->fracPart[3][0], ((Mtx*)addr)->intPart[3][0], ((Mtx*)addr)->fracPart[3][0],
mtx.mf[0][0], mtx.mf[1][0], mtx.mf[2][0], mtx.mf[3][0], mtxF.mf[0][0], mtxF.mf[1][0], mtxF.mf[2][0], mtxF.mf[3][0],
((Mtx*)addr)->intPart[0][1], ((Mtx*)addr)->fracPart[0][1], ((Mtx*)addr)->intPart[0][1], ((Mtx*)addr)->fracPart[0][1],
((Mtx*)addr)->intPart[1][1], ((Mtx*)addr)->fracPart[1][1], ((Mtx*)addr)->intPart[1][1], ((Mtx*)addr)->fracPart[1][1],
((Mtx*)addr)->intPart[2][1], ((Mtx*)addr)->fracPart[2][1], ((Mtx*)addr)->intPart[2][1], ((Mtx*)addr)->fracPart[2][1],
((Mtx*)addr)->intPart[3][1], ((Mtx*)addr)->fracPart[3][1], ((Mtx*)addr)->intPart[3][1], ((Mtx*)addr)->fracPart[3][1],
mtx.mf[0][1], mtx.mf[1][1], mtx.mf[2][1], mtx.mf[3][1], mtxF.mf[0][1], mtxF.mf[1][1], mtxF.mf[2][1], mtxF.mf[3][1],
((Mtx*)addr)->intPart[0][2], ((Mtx*)addr)->fracPart[0][2], ((Mtx*)addr)->intPart[0][2], ((Mtx*)addr)->fracPart[0][2],
((Mtx*)addr)->intPart[1][2], ((Mtx*)addr)->fracPart[1][2], ((Mtx*)addr)->intPart[1][2], ((Mtx*)addr)->fracPart[1][2],
((Mtx*)addr)->intPart[2][2], ((Mtx*)addr)->fracPart[2][2], ((Mtx*)addr)->intPart[2][2], ((Mtx*)addr)->fracPart[2][2],
((Mtx*)addr)->intPart[3][2], ((Mtx*)addr)->fracPart[3][2], ((Mtx*)addr)->intPart[3][2], ((Mtx*)addr)->fracPart[3][2],
mtx.mf[0][2], mtx.mf[1][2], mtx.mf[2][2], mtx.mf[3][2], mtxF.mf[0][2], mtxF.mf[1][2], mtxF.mf[2][2], mtxF.mf[3][2],
((Mtx*)addr)->intPart[0][3], ((Mtx*)addr)->fracPart[0][3], ((Mtx*)addr)->intPart[0][3], ((Mtx*)addr)->fracPart[0][3],
((Mtx*)addr)->intPart[1][3], ((Mtx*)addr)->fracPart[1][3], ((Mtx*)addr)->intPart[1][3], ((Mtx*)addr)->fracPart[1][3],
((Mtx*)addr)->intPart[2][3], ((Mtx*)addr)->fracPart[2][3], ((Mtx*)addr)->intPart[2][3], ((Mtx*)addr)->fracPart[2][3],
((Mtx*)addr)->intPart[3][3], ((Mtx*)addr)->fracPart[3][3], ((Mtx*)addr)->intPart[3][3], ((Mtx*)addr)->fracPart[3][3],
mtx.mf[0][3], mtx.mf[1][3], mtx.mf[2][3], mtx.mf[3][3]); mtxF.mf[0][3], mtxF.mf[1][3], mtxF.mf[2][3], mtxF.mf[3][3]);
// clang-format on // clang-format on
} }
} break; } break;
@ -981,9 +827,9 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
numv >>= 12; numv >>= 12;
numv &= 0xFF; numv &= 0xFF;
vbidx = (curGfx->vtx.vbidx >> 1) - numv; vbidx = (curGfx->vtx.par >> 1) - numv;
DISAS_LOG("gsSPVertex(0x%08x(0x%08x), %d, %d),", curGfx->words.w1, addr, numv, vbidx); DISAS_LOG("gsSPVertex(0x%08x(0x%08x), %d, %d),", curGfx->vtx.addr, addr, numv, vbidx);
this->vtxCnt += numv; this->vtxCnt += numv;
this->spvtxCnt++; this->spvtxCnt++;
@ -1006,21 +852,21 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
} break; } break;
case G_TRI1: { case G_TRI1: {
Gtri1 gtri = ptr->tri1; Gtri gtri = ptr->tri;
Gtrimod tri = gtri.tri; Tri tri = gtri.tri;
DISAS_LOG("gsSP1Triangle(%d, %d, %d),", tri.v0 / 2, tri.v1 / 2, tri.v2 / 2); DISAS_LOG("gsSP1Triangle(%d, %d, %d),", tri.v[0] / 2, tri.v[1] / 2, tri.v[2] / 2);
this->tri1Cnt++; this->tri1Cnt++;
this->pipeSyncRequired = true; this->pipeSyncRequired = true;
} break; } break;
case G_LINE3D: { case G_LINE3D: {
if (curGfx->linefix.wd == 0) { if (curGfx->line.wd == 0) {
DISAS_LOG("gsSPLine3D(%d, %d),", curGfx->linefix.v0, curGfx->linefix.v1); DISAS_LOG("gsSPLine3D(%d, %d),", curGfx->line.v0, curGfx->line.v1);
} else { } else {
DISAS_LOG("gsSPLineW3D(%d, %d, %d),", curGfx->linefix.v0, curGfx->linefix.v1, DISAS_LOG("gsSPLineW3D(%d, %d, %d),", curGfx->line.v0, curGfx->line.v1,
curGfx->linefix.wd); curGfx->line.wd);
} }
this->lineCnt++; this->lineCnt++;
@ -1032,13 +878,13 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
u32 v0, v1, v2; u32 v0, v1, v2;
u32 v3, v4, v5; u32 v3, v4, v5;
v0 = tri2.tri1.v0 / 2; v0 = tri2.tri1.v[0] / 2;
v1 = tri2.tri1.v1 / 2; v1 = tri2.tri1.v[1] / 2;
v2 = tri2.tri1.v2 / 2; v2 = tri2.tri1.v[2] / 2;
v3 = tri2.tri2.v0 / 2; v3 = tri2.tri2.v[0] / 2;
v4 = tri2.tri2.v1 / 2; v4 = tri2.tri2.v[1] / 2;
v5 = tri2.tri2.v2 / 2; v5 = tri2.tri2.v[2] / 2;
DISAS_LOG("gsSP2Triangles(%d, %d, %d, 0, %d, %d, %d, 0),", v0, v1, v2, v3, v4, v5); DISAS_LOG("gsSP2Triangles(%d, %d, %d, 0, %d, %d, %d, 0),", v0, v1, v2, v3, v4, v5);
@ -1047,13 +893,13 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
} break; } break;
case G_QUAD: { case G_QUAD: {
Gquadmod quad = ptr->quad; Gquad quad = ptr->quad;
u32 v0, v1, v2, v3; u32 v0, v1, v2, v3;
v0 = quad.v0 / 2; v0 = quad.tri1.v[0] / 2;
v1 = quad.v1 / 2; v1 = quad.tri1.v[1] / 2;
v2 = quad.v2 / 2; v2 = quad.tri1.v[2] / 2;
v3 = quad.v3 / 2; v3 = quad.tri2.v[2] / 2;
DISAS_LOG("gsSP1Quadrangle(%d, %d, %d, %d, 0),", v0, v1, v2, v3); DISAS_LOG("gsSP1Quadrangle(%d, %d, %d, %d, 0),", v0, v1, v2, v3);
@ -1062,19 +908,19 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
} break; } break;
case G_CULLDL: { case G_CULLDL: {
DISAS_LOG("gsSPCullDisplayList(%d, %d),", (curGfx->cull.vstart) / 2, DISAS_LOG("gsSPCullDisplayList(%d, %d),", (curGfx->cull.vstart_x2) / 2,
(curGfx->cull.vend) / 2); (curGfx->cull.vend_x2) / 2);
} break; } break;
case G_BRANCH_Z: { case G_BRANCH_Z: {
addr = (u32)UCodeDisas_TranslateAddr(this, rdpHalf); addr = (uintptr_t)UCodeDisas_TranslateAddr(this, rdpHalf);
DISAS_LOG("gsSPBranchLessZraw(0x%08x(0x%08x), %d, 0x%08x),", rdpHalf, addr, DISAS_LOG("gsSPBranchLessZraw(0x%08x(0x%08x), %d, 0x%08x),", rdpHalf, addr,
(curGfx->words.w0 & 0xFFF) / 2, curGfx->words.w1); (curGfx->words.w0 & 0xFFF) / 2, curGfx->words.w1);
ptr = (GfxMod*)addr - 1; ptr = (Gfx*)addr - 1;
} break; } break;
case G_TEXTURE: { case G_TEXTURE: {
Gtexturemod texture = ptr->texmod; Gtexture texture = ptr->texture;
if (texture.lodscale == 0) { if (texture.lodscale == 0) {
DISAS_LOG("gsSPTexture(%d, %d, %d, %d, %s),", texture.s, texture.t, texture.level, DISAS_LOG("gsSPTexture(%d, %d, %d, %d, %s),", texture.s, texture.t, texture.level,
@ -1087,12 +933,12 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
} break; } break;
case G_POPMTX: { case G_POPMTX: {
Gpopmtxmod popmtx = ptr->popmtxmod; Gpopmtx popmtx = ptr->popmtx;
if (popmtx.param == 1) { if (popmtx.param / 64 == 1) {
DISAS_LOG("gsSPPopMatrix(G_MTX_MODELVIEW),"); DISAS_LOG("gsSPPopMatrix(G_MTX_MODELVIEW),");
} else { } else {
DISAS_LOG("gsSPPopMatrixN(G_MTX_MODELVIEW, %d),", popmtx.param); DISAS_LOG("gsSPPopMatrixN(G_MTX_MODELVIEW, %d),", popmtx.param / 64);
} }
} break; } break;
@ -1102,21 +948,21 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
if (clearbits == 0) { if (clearbits == 0) {
DISAS_LOG("gsSPLoadGeometryMode("); DISAS_LOG("gsSPLoadGeometryMode(");
UCodeDisas_ParseGeometryMode(this, setbits); UCodeDisas_PrintGeometryMode(this, setbits);
DISAS_LOG("),"); DISAS_LOG("),");
} else if (setbits == 0) { } else if (setbits == 0) {
DISAS_LOG("gsSPClearGeometryMode("); DISAS_LOG("gsSPClearGeometryMode(");
UCodeDisas_ParseGeometryMode(this, ~clearbits); UCodeDisas_PrintGeometryMode(this, ~clearbits);
DISAS_LOG("),"); DISAS_LOG("),");
} else if (clearbits == 0xFFFFFF) { } else if (clearbits == 0xFFFFFF) {
DISAS_LOG("gsSPSetGeometryMode("); DISAS_LOG("gsSPSetGeometryMode(");
UCodeDisas_ParseGeometryMode(this, setbits); UCodeDisas_PrintGeometryMode(this, setbits);
DISAS_LOG("),"); DISAS_LOG("),");
} else { } else {
DISAS_LOG("gsSPGeometryMode("); DISAS_LOG("gsSPGeometryMode(");
UCodeDisas_ParseGeometryMode(this, ~clearbits); UCodeDisas_PrintGeometryMode(this, ~clearbits);
DISAS_LOG(", "); DISAS_LOG(", ");
UCodeDisas_ParseGeometryMode(this, setbits); UCodeDisas_PrintGeometryMode(this, setbits);
DISAS_LOG("),"); DISAS_LOG("),");
} }
@ -1185,7 +1031,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
case G_MV_MATRIX: { case G_MV_MATRIX: {
DISAS_LOG("gsSPForceMatrix(0x%08x),", movemem.data); DISAS_LOG("gsSPForceMatrix(0x%08x),", movemem.data);
ptr += 1; ptr += 2 - 1;
} break; } break;
case G_MV_LIGHT: { case G_MV_LIGHT: {
@ -1200,7 +1046,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
default: { default: {
DISAS_LOG("gsSPLight(0x%08x,%d),", movemem.data, DISAS_LOG("gsSPLight(0x%08x,%d),", movemem.data,
(movemem.offset * 8 - 24) / 24); (movemem.offset * 8 - 0x18) / 0x18);
} break; } break;
} }
} break; } break;
@ -1299,8 +1145,9 @@ void UCodeDisas_Disassemble(UCodeDisas* this, GfxMod* ptr) {
case G_SELECT_DL: { case G_SELECT_DL: {
Gdma dma = ptr->dma; Gdma dma = ptr->dma;
u32 dlAddr = (u32)UCodeDisas_TranslateAddr(this, (dma.len << 16) | (linkDlLow)); uintptr_t dlAddr =
u32 dmaAddr = dma.addr; (uintptr_t)UCodeDisas_TranslateAddr(this, (dma.len << 16) | (linkDlLow));
uintptr_t dmaAddr = dma.addr;
if (dma.par == 0) { if (dma.par == 0) {
DISAS_LOG("gsSPSelectDL(0x%08x, %d, 0x%08x, 0x%08x),", dlAddr, sid, rdpHalf, DISAS_LOG("gsSPSelectDL(0x%08x, %d, 0x%08x, 0x%08x),", dlAddr, sid, rdpHalf,