2020-10-03 15:22:44 +00:00
|
|
|
#include "global.h"
|
2020-06-05 17:18:39 +00:00
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
typedef void (*UcodeDisasCallback)(UCodeDisas*, u32);
|
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
#define F3DZEX_CONST(name) \
|
|
|
|
{ name, #name }
|
|
|
|
#define F3DZEX_FLAG(set, unset) \
|
|
|
|
{ set, #set, #unset }
|
|
|
|
#define F3DZEX_RENDERMODE(name, mask) \
|
|
|
|
{ #name, name, mask }
|
|
|
|
#define F3DZEX_SETRENDERMACRO(name, shift, len, value0, value1, value2, value3) \
|
|
|
|
{ \
|
|
|
|
name, shift, len, { \
|
|
|
|
{ #value0, value0 }, { #value1, value1 }, { #value2, value2 }, { #value3, value3 }, \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DISAS_LOG \
|
|
|
|
if (this->enableLog) \
|
|
|
|
osSyncPrintf
|
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
void* UCodeDisas_TranslateAddr(UCodeDisas* this, uintptr_t addr) {
|
|
|
|
uintptr_t physical = this->segments[SEGMENT_NUMBER(addr)] + SEGMENT_OFFSET(addr);
|
2021-11-30 23:40:42 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
return PHYSICAL_TO_VIRTUAL(physical);
|
|
|
|
}
|
|
|
|
|
|
|
|
F3dzexConst sUCodeDisasGeometryModes[] = {
|
|
|
|
F3DZEX_CONST(G_ZBUFFER), F3DZEX_CONST(G_TEXTURE_ENABLE),
|
|
|
|
F3DZEX_CONST(G_SHADE), F3DZEX_CONST(G_SHADING_SMOOTH),
|
|
|
|
F3DZEX_CONST(G_CULL_FRONT), F3DZEX_CONST(G_CULL_BACK),
|
|
|
|
F3DZEX_CONST(G_FOG), F3DZEX_CONST(G_LIGHTING),
|
|
|
|
F3DZEX_CONST(G_TEXTURE_GEN), F3DZEX_CONST(G_TEXTURE_GEN_LINEAR),
|
|
|
|
F3DZEX_CONST(G_LOD),
|
|
|
|
};
|
|
|
|
|
|
|
|
F3dzexFlag sUCodeDisasMtxFlags[] = {
|
|
|
|
F3DZEX_FLAG(G_MTX_PROJECTION, G_MTX_MODELVIEW),
|
|
|
|
F3DZEX_FLAG(G_MTX_LOAD, G_MTX_MUL),
|
|
|
|
F3DZEX_FLAG(G_MTX_PUSH, G_MTX_NOPUSH),
|
|
|
|
};
|
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
typedef enum { COMBINER_A = 1, COMBINER_B, COMBINER_C, COMBINER_D } CombinerArg;
|
|
|
|
|
|
|
|
const char* UCodeDisas_GetCombineColorName(u32 value, u32 arg) {
|
2020-06-05 17:18:39 +00:00
|
|
|
const char* ret = "?";
|
|
|
|
|
|
|
|
switch (value) {
|
|
|
|
case G_CCMUX_COMBINED:
|
|
|
|
ret = "COMBINED";
|
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
case G_CCMUX_TEXEL0:
|
|
|
|
ret = "TEXEL0";
|
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
case G_CCMUX_TEXEL1:
|
|
|
|
ret = "TEXEL1";
|
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
case G_CCMUX_PRIMITIVE:
|
|
|
|
ret = "PRIMITIVE";
|
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
case G_CCMUX_SHADE:
|
|
|
|
ret = "SHADE";
|
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
case G_CCMUX_ENVIRONMENT:
|
|
|
|
ret = "ENVIRONMENT";
|
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
|
|
|
case 6: // G_CCMUX_CENTER, G_CCMUX_SCALE, G_CCMUX_1
|
|
|
|
ret = (arg == COMBINER_B) ? "CENTER" : (arg == COMBINER_C) ? "SCALE" : "1";
|
2020-06-05 17:18:39 +00:00
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
|
|
|
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";
|
2020-06-05 17:18:39 +00:00
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
default:
|
2022-10-15 21:14:35 +00:00
|
|
|
if (arg == COMBINER_C) {
|
2020-06-05 17:18:39 +00:00
|
|
|
switch (value) {
|
|
|
|
case G_CCMUX_TEXEL0_ALPHA:
|
|
|
|
ret = "TEXEL0_ALPHA";
|
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
case G_CCMUX_TEXEL1_ALPHA:
|
|
|
|
ret = "TEXEL1_ALPHA";
|
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
case G_CCMUX_PRIMITIVE_ALPHA:
|
|
|
|
ret = "PRIMITIVE_ALPHA";
|
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
case G_CCMUX_SHADE_ALPHA:
|
|
|
|
ret = "SHADE_ALPHA";
|
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
case G_CCMUX_ENV_ALPHA:
|
|
|
|
ret = "ENV_ALPHA";
|
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
case G_CCMUX_LOD_FRACTION:
|
|
|
|
ret = "LOD_FRACTION";
|
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
case G_CCMUX_PRIM_LOD_FRAC:
|
|
|
|
ret = "PRIM_LOD_FRAC";
|
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
case G_CCMUX_K5:
|
|
|
|
ret = "K5";
|
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
default:
|
|
|
|
ret = "0";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ret = "0";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
const char* UCodeDisas_GetCombineAlphaName(u32 value, u32 arg) {
|
2020-06-05 17:18:39 +00:00
|
|
|
const char* ret = "?";
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
switch (value) {
|
2022-10-15 21:14:35 +00:00
|
|
|
case 0: // G_ACMUX_LOD_FRACTION, G_ACMUX_COMBINED
|
|
|
|
ret = (arg == COMBINER_C) ? "LOD_FRACTION" : "COMBINED";
|
2020-06-05 17:18:39 +00:00
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
case G_ACMUX_TEXEL0:
|
|
|
|
ret = "TEXEL0";
|
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
case G_ACMUX_TEXEL1:
|
|
|
|
ret = "TEXEL1";
|
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
case G_ACMUX_PRIMITIVE:
|
|
|
|
ret = "PRIMITIVE";
|
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
case G_ACMUX_SHADE:
|
|
|
|
ret = "SHADE";
|
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
case G_ACMUX_ENVIRONMENT:
|
|
|
|
ret = "ENVIRONMENT";
|
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
|
|
|
case 6: // G_ACMUX_PRIM_LOD_FRAC, G_ACMUX_1
|
|
|
|
ret = (arg == COMBINER_C) ? "PRIM_LOD_FRAC" : "1";
|
2020-06-05 17:18:39 +00:00
|
|
|
break;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
case G_ACMUX_0:
|
|
|
|
ret = "0";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UCodeDisas_Init(UCodeDisas* this) {
|
|
|
|
u32 i;
|
2021-11-30 23:40:42 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
bzero(this, sizeof(UCodeDisas));
|
|
|
|
for (i = 0; i < NUM_SEGMENTS; i++) {
|
|
|
|
this->segments[i] = gSegments[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UCodeDisas_Destroy(UCodeDisas* this) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void UCodeDisas_SetCurUCodeImpl(UCodeDisas* this, void* ptr) {
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
for (i = 0; i < this->ucodeInfoCount; i++) {
|
|
|
|
if (ptr == this->ucodeInfo[i].ptr) {
|
|
|
|
this->ucodeType = this->ucodeInfo[i].type;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i >= this->ucodeInfoCount) {
|
2021-09-04 13:33:19 +00:00
|
|
|
DISAS_LOG("マイクロコードが一致しなかった\n"); // "Microcode did not match"
|
2020-06-05 17:18:39 +00:00
|
|
|
this->ucodeType = UCODE_NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
void UCodeDisas_PrintGeometryMode(UCodeDisas* this, u32 mode) {
|
2020-06-05 17:18:39 +00:00
|
|
|
u32 first = true;
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_COUNT(sUCodeDisasGeometryModes); i++) {
|
2020-08-23 21:50:30 +00:00
|
|
|
if ((sUCodeDisasGeometryModes[i].value & mode) == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-06-05 17:18:39 +00:00
|
|
|
|
2020-08-23 21:50:30 +00:00
|
|
|
if (first) {
|
|
|
|
} else {
|
|
|
|
DISAS_LOG("|");
|
2020-06-05 17:18:39 +00:00
|
|
|
}
|
2020-08-23 21:50:30 +00:00
|
|
|
first = false;
|
|
|
|
|
|
|
|
DISAS_LOG("%s", sUCodeDisasGeometryModes[i].name);
|
2020-06-05 17:18:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
void UCodeDisas_PrintRenderMode(UCodeDisas* this, u32 mode) {
|
2020-06-05 17:18:39 +00:00
|
|
|
static F3dzexRenderMode sUCodeDisasRenderModeFlags[] = {
|
|
|
|
F3DZEX_RENDERMODE(AA_EN, 0x8),
|
|
|
|
F3DZEX_RENDERMODE(Z_CMP, 0x10),
|
|
|
|
F3DZEX_RENDERMODE(Z_UPD, 0x20),
|
|
|
|
F3DZEX_RENDERMODE(IM_RD, 0x40),
|
|
|
|
F3DZEX_RENDERMODE(CLR_ON_CVG, 0x80),
|
|
|
|
F3DZEX_RENDERMODE(CVG_DST_CLAMP, 0x300),
|
|
|
|
F3DZEX_RENDERMODE(CVG_DST_WRAP, 0x300),
|
|
|
|
F3DZEX_RENDERMODE(CVG_DST_FULL, 0x300),
|
|
|
|
F3DZEX_RENDERMODE(CVG_DST_SAVE, 0x300),
|
|
|
|
F3DZEX_RENDERMODE(ZMODE_OPA, 0xC00),
|
|
|
|
F3DZEX_RENDERMODE(ZMODE_INTER, 0xC00),
|
|
|
|
F3DZEX_RENDERMODE(ZMODE_XLU, 0xC00),
|
|
|
|
F3DZEX_RENDERMODE(ZMODE_DEC, 0xC00),
|
|
|
|
F3DZEX_RENDERMODE(CVG_X_ALPHA, 0x1000),
|
|
|
|
F3DZEX_RENDERMODE(ALPHA_CVG_SEL, 0x2000),
|
|
|
|
F3DZEX_RENDERMODE(FORCE_BL, 0x4000),
|
|
|
|
};
|
2022-10-15 21:14:35 +00:00
|
|
|
static const char* sBlenderInputNames[4][4] = {
|
2020-06-05 17:18:39 +00:00
|
|
|
{ "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_CLR_IN", "G_BL_CLR_MEM", "G_BL_CLR_BL", "G_BL_CLR_FOG" },
|
|
|
|
{ "G_BL_1MA", "G_BL_A_MEM", "G_BL_1", "G_BL_0" },
|
|
|
|
};
|
|
|
|
|
2020-08-23 21:50:30 +00:00
|
|
|
s32 i;
|
|
|
|
s32 a;
|
|
|
|
s32 b;
|
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sUCodeDisasRenderModeFlags); i++) {
|
2020-08-23 21:50:30 +00:00
|
|
|
if ((mode & sUCodeDisasRenderModeFlags[i].mask) != sUCodeDisasRenderModeFlags[i].value) {
|
|
|
|
continue;
|
2020-06-05 17:18:39 +00:00
|
|
|
}
|
2020-08-23 21:50:30 +00:00
|
|
|
|
|
|
|
DISAS_LOG("%s|", sUCodeDisasRenderModeFlags[i].name);
|
2020-06-05 17:18:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
a = (mode >> 18) & 0x3333;
|
|
|
|
b = (mode >> 16) & 0x3333;
|
|
|
|
|
|
|
|
// clang-format off
|
2020-08-23 21:50:30 +00:00
|
|
|
if (this->enableLog == 0) {} else { osSyncPrintf("\nGBL_c1(%s, %s, %s, %s)|",
|
2022-10-15 21:14:35 +00:00
|
|
|
sBlenderInputNames[0][a >> 12 & 3], sBlenderInputNames[1][a >> 8 & 3], sBlenderInputNames[2][a >> 4 & 3], sBlenderInputNames[3][a >> 0 & 3]);
|
2022-04-29 19:06:08 +00:00
|
|
|
}
|
2020-06-05 17:18:39 +00:00
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
if (this->enableLog) {
|
2022-10-15 21:14:35 +00:00
|
|
|
osSyncPrintf("\nGBL_c2(%s, %s, %s, %s)", sBlenderInputNames[0][b >> 12 & 3], sBlenderInputNames[1][b >> 8 & 3],
|
|
|
|
sBlenderInputNames[2][b >> 4 & 3], sBlenderInputNames[3][b >> 0 & 3]);
|
2020-06-05 17:18:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UCodeDisas_PrintVertices(UCodeDisas* this, Vtx* vtx, s32 count, s32 start) {
|
|
|
|
s32 i;
|
2022-10-15 21:14:35 +00:00
|
|
|
|
2020-06-05 17:18:39 +00:00
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
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],
|
|
|
|
vtx->n.ob[2], vtx->n.flag, vtx->n.tc[0], vtx->n.tc[1], vtx->n.n[0], vtx->n.n[1], vtx->n.n[2],
|
|
|
|
vtx->n.a, start + i);
|
|
|
|
} else {
|
|
|
|
DISAS_LOG("\n{{%6d, %6d, %6d, %d, %6d, %6d, %3d, %3d, %3d, %3d}}, /* vn%d */", vtx->v.ob[0], vtx->v.ob[1],
|
|
|
|
vtx->v.ob[2], vtx->v.flag, vtx->v.tc[0], vtx->v.tc[1], vtx->v.cn[0], vtx->v.cn[1], vtx->v.cn[2],
|
|
|
|
vtx->v.cn[3], start + i);
|
|
|
|
}
|
|
|
|
vtx++;
|
|
|
|
|
|
|
|
if (1) {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
void UCodeDisas_Disassemble(UCodeDisas* this, Gfx* ptr) {
|
2021-10-31 20:39:29 +00:00
|
|
|
u32 pad;
|
2022-10-15 21:14:35 +00:00
|
|
|
uintptr_t addr;
|
2021-11-15 00:02:33 +00:00
|
|
|
u32 rdpHalf;
|
2021-10-31 20:39:29 +00:00
|
|
|
u16 linkDlLow;
|
|
|
|
u8 sid;
|
2021-11-15 00:02:33 +00:00
|
|
|
u8 cmd;
|
2022-10-15 21:14:35 +00:00
|
|
|
s32 i;
|
2021-11-15 00:02:33 +00:00
|
|
|
u32 exit;
|
2022-10-15 21:14:35 +00:00
|
|
|
Gfx curGfx[1];
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
exit = false;
|
|
|
|
|
|
|
|
while (!exit) {
|
|
|
|
this->dlCnt++;
|
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
ptr = UCodeDisas_TranslateAddr(this, (uintptr_t)ptr);
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("%08x:", ptr);
|
2021-10-31 20:39:29 +00:00
|
|
|
|
2021-11-15 00:02:33 +00:00
|
|
|
*curGfx = *ptr;
|
2022-10-15 21:14:35 +00:00
|
|
|
cmd = curGfx->noop.cmd;
|
|
|
|
addr = (uintptr_t)UCodeDisas_TranslateAddr(this, (uintptr_t)curGfx->noop.value.addr);
|
2021-10-31 20:39:29 +00:00
|
|
|
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("%08x-%08x:", curGfx->words.w0, curGfx->words.w1);
|
2021-10-31 20:39:29 +00:00
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
for (i = 0; i < this->dlDepth; i++) {
|
2021-10-31 20:39:29 +00:00
|
|
|
DISAS_LOG(" ");
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case G_SPNOOP: {
|
|
|
|
DISAS_LOG("gsSPNoOp(),");
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_DL: {
|
2021-11-15 00:02:33 +00:00
|
|
|
Gdma dma = ptr->dma;
|
|
|
|
|
|
|
|
switch (dma.par) {
|
2022-10-15 21:14:35 +00:00
|
|
|
case G_DL_PUSH: {
|
2021-10-31 20:39:29 +00:00
|
|
|
DISAS_LOG("gsSPDisplayList(0x%08x),", dma.addr);
|
2022-06-16 00:15:44 +00:00
|
|
|
this->dlStack[this->dlDepth++] = (Gfx*)(ptr + 1);
|
2022-10-15 21:14:35 +00:00
|
|
|
ptr = (Gfx*)addr - 1;
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
case G_DL_NOPUSH: {
|
2021-10-31 20:39:29 +00:00
|
|
|
DISAS_LOG("gsSPBranchList(0x%08x),", dma.addr);
|
2022-10-15 21:14:35 +00:00
|
|
|
ptr = (Gfx*)addr - 1;
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_RDPHALF_1: {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("RDPHALF_1(0x%08x),", curGfx->dma.addr);
|
|
|
|
rdpHalf = curGfx->dma.addr;
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_TEXRECT: {
|
|
|
|
Gtexrect rect = *(Gtexrect*)ptr;
|
|
|
|
|
|
|
|
DISAS_LOG("gsSPTextureRectangle(%d,%d,%d,%d,%d,%d,%d,%d,%d),", rect.xl, rect.yl, rect.xh, rect.yh,
|
|
|
|
rect.tile, ptr[1].words.w1 >> 16, ptr[1].words.w1 & 0xFFFF, ptr[2].words.w1 >> 16,
|
|
|
|
ptr[2].words.w1 & 0xFFFF);
|
|
|
|
|
|
|
|
ptr += 3 - 1;
|
2021-10-31 20:39:29 +00:00
|
|
|
this->pipeSyncRequired = true;
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
2021-10-31 20:39:29 +00:00
|
|
|
|
2021-11-15 00:02:33 +00:00
|
|
|
case G_LOAD_UCODE: {
|
2022-10-15 21:14:35 +00:00
|
|
|
if (curGfx->dma.len == SP_UCODE_DATA_SIZE - 1) {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsSPLoadUcode(0x%08x, 0x%08x),", curGfx->dma.addr, rdpHalf);
|
2021-10-31 20:39:29 +00:00
|
|
|
} else {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsSPLoadUcodeEx(0x%08x, 0x%08x, 0x%05x),", curGfx->dma.addr, rdpHalf,
|
|
|
|
curGfx->dma.len + 1);
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
2022-06-16 00:15:44 +00:00
|
|
|
UCodeDisas_SetCurUCodeImpl(this, UCodeDisas_TranslateAddr(this, curGfx->dma.addr));
|
2021-10-31 20:39:29 +00:00
|
|
|
this->loaducodeCnt++;
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_ENDDL: {
|
|
|
|
DISAS_LOG("gsSPEndDisplayList(),");
|
|
|
|
if (this->dlDepth <= 0) {
|
|
|
|
exit = true;
|
|
|
|
} else {
|
2022-10-15 21:14:35 +00:00
|
|
|
ptr = this->dlStack[--this->dlDepth] - 1;
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_SETTILE: {
|
|
|
|
Gsettile settile = ptr->settile;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
DISAS_LOG("gsDPSetTile(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d),", settile.fmt, settile.siz, settile.line,
|
2021-11-15 00:02:33 +00:00
|
|
|
settile.tmem, settile.tile, settile.palette, (settile.ct << 1) + settile.mt, settile.maskt,
|
|
|
|
settile.shiftt, (settile.cs << 1) + settile.ms, settile.masks, settile.shifts);
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
if (this->tileSyncRequired) {
|
|
|
|
DISAS_LOG("### TileSyncが必要です。\n");
|
|
|
|
this->syncErr++;
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_LOADTILE: {
|
|
|
|
Gloadtile loadtile = ptr->loadtile;
|
|
|
|
|
|
|
|
DISAS_LOG("gsDPLoadTile(%d,%d,%d,%d,%d),", loadtile.tile, loadtile.sl, loadtile.tl, loadtile.sh,
|
|
|
|
loadtile.th);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_LOADBLOCK: {
|
|
|
|
Gloadtile loadtile = ptr->loadtile;
|
|
|
|
|
|
|
|
DISAS_LOG("gsDPLoadBlock(%d,%d,%d,%d,%d),", loadtile.tile, loadtile.sl, loadtile.tl, loadtile.sh,
|
|
|
|
loadtile.th);
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
if (this->loadSyncRequired) {
|
|
|
|
DISAS_LOG("### LoadSyncが必要です。\n");
|
|
|
|
this->syncErr++;
|
|
|
|
}
|
|
|
|
this->pipeSyncRequired = true;
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_SETTILESIZE: {
|
|
|
|
Gloadtile loadtile = ptr->loadtile;
|
|
|
|
|
|
|
|
DISAS_LOG("gsDPSetTileSize(%d,%d,%d,%d,%d),", loadtile.tile, loadtile.sl, loadtile.tl, loadtile.sh,
|
|
|
|
loadtile.th);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_LOADTLUT: {
|
|
|
|
Gloadtlut loadtlut = ptr->loadtlut;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
DISAS_LOG("gsDPLoadTLUTCmd(%d,%d),", loadtlut.tile, loadtlut.sh >> 2);
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_SETCOMBINE: {
|
2022-10-15 21:14:35 +00:00
|
|
|
Gsetcombine setcombine = ptr->setcombine;
|
2021-11-15 00:02:33 +00:00
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
DISAS_LOG("gsDPSetCombineLERP(%s,%s,%s,%s, %s,%s,%s,%s, %s,%s,%s,%s, %s,%s,%s,%s),",
|
2022-10-15 21:14:35 +00:00
|
|
|
UCodeDisas_GetCombineColorName(setcombine.a0, COMBINER_A),
|
|
|
|
UCodeDisas_GetCombineColorName(setcombine.b0, COMBINER_B),
|
|
|
|
UCodeDisas_GetCombineColorName(setcombine.c0, COMBINER_C),
|
|
|
|
UCodeDisas_GetCombineColorName(setcombine.d0, COMBINER_D),
|
|
|
|
|
|
|
|
UCodeDisas_GetCombineAlphaName(setcombine.Aa0, COMBINER_A),
|
|
|
|
UCodeDisas_GetCombineAlphaName(setcombine.Ab0, COMBINER_B),
|
|
|
|
UCodeDisas_GetCombineAlphaName(setcombine.Ac0, COMBINER_C),
|
|
|
|
UCodeDisas_GetCombineAlphaName(setcombine.Ad0, COMBINER_D),
|
|
|
|
|
|
|
|
UCodeDisas_GetCombineColorName(setcombine.a1, COMBINER_A),
|
|
|
|
UCodeDisas_GetCombineColorName(setcombine.b1, COMBINER_B),
|
|
|
|
UCodeDisas_GetCombineColorName(setcombine.c1, COMBINER_C),
|
|
|
|
UCodeDisas_GetCombineColorName(setcombine.d1, COMBINER_D),
|
|
|
|
|
|
|
|
UCodeDisas_GetCombineAlphaName(setcombine.Aa1, COMBINER_A),
|
|
|
|
UCodeDisas_GetCombineAlphaName(setcombine.Ab1, COMBINER_B),
|
|
|
|
UCodeDisas_GetCombineAlphaName(setcombine.Ac1, COMBINER_C),
|
|
|
|
UCodeDisas_GetCombineAlphaName(setcombine.Ad1, COMBINER_D));
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
if (this->pipeSyncRequired) {
|
|
|
|
DISAS_LOG("### PipeSyncが必要です。\n");
|
|
|
|
this->syncErr++;
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_SETOTHERMODE_H: {
|
2021-10-31 20:39:29 +00:00
|
|
|
static F3dzexSetModeMacro sUCodeDisasModeHMacros[] = {
|
|
|
|
F3DZEX_SETRENDERMACRO("SetAlphaDither", G_MDSFT_ALPHADITHER, 2, G_AD_PATTERN, G_AD_NOTPATTERN,
|
|
|
|
G_AD_NOISE, G_AD_DISABLE),
|
|
|
|
F3DZEX_SETRENDERMACRO("SetColorDither", G_MDSFT_RGBDITHER, 2, G_CD_MAGICSQ, G_CD_BAYER, G_CD_NOISE,
|
|
|
|
-1),
|
|
|
|
F3DZEX_SETRENDERMACRO("SetCombineKey", G_MDSFT_COMBKEY, 1, G_CK_NONE, G_CK_KEY, -1, -1),
|
|
|
|
F3DZEX_SETRENDERMACRO("SetTextureConvert", G_MDSFT_TEXTCONV, 3, G_TC_CONV, G_TC_FILTCONV, G_TC_FILT,
|
|
|
|
-1),
|
|
|
|
F3DZEX_SETRENDERMACRO("SetTextureFilter", G_MDSFT_TEXTFILT, 2, G_TF_POINT, G_TF_AVERAGE,
|
|
|
|
G_TF_BILERP, -1),
|
|
|
|
F3DZEX_SETRENDERMACRO("SetTextureLUT", G_MDSFT_TEXTLUT, 2, G_TT_NONE, G_TT_RGBA16, G_TT_IA16, -1),
|
|
|
|
F3DZEX_SETRENDERMACRO("SetTextureLOD", G_MDSFT_TEXTLOD, 1, G_TL_TILE, G_TL_LOD, -1, -1),
|
|
|
|
F3DZEX_SETRENDERMACRO("SetTextureDetail", G_MDSFT_TEXTDETAIL, 2, G_TD_CLAMP, G_TD_SHARPEN,
|
|
|
|
G_TD_DETAIL, -1),
|
|
|
|
F3DZEX_SETRENDERMACRO("SetTexturePersp", G_MDSFT_TEXTPERSP, 1, G_TP_PERSP, G_TP_NONE, -1, -1),
|
|
|
|
F3DZEX_SETRENDERMACRO("SetCycleType", G_MDSFT_CYCLETYPE, 2, G_CYC_1CYCLE, G_CYC_2CYCLE, G_CYC_COPY,
|
|
|
|
G_CYC_FILL),
|
|
|
|
F3DZEX_SETRENDERMACRO("SetColorDither", G_MDSFT_COLORDITHER, 2, G_CD_MAGICSQ, G_CD_BAYER,
|
|
|
|
G_CD_NOISE, -1),
|
|
|
|
F3DZEX_SETRENDERMACRO("PipelineMode", G_MDSFT_PIPELINE, 1, G_PM_1PRIMITIVE, G_PM_NPRIMITIVE, -1,
|
|
|
|
-1),
|
|
|
|
};
|
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
u32 len = curGfx->setothermodeH.len + 1;
|
|
|
|
u32 sft = (-curGfx->setothermodeH.sft - len) + 32;
|
|
|
|
u32 s2 = curGfx->setothermodeH.data * 1;
|
|
|
|
u32 j;
|
|
|
|
u32 k;
|
|
|
|
|
|
|
|
for (j = 0; j < ARRAY_COUNTU(sUCodeDisasModeHMacros); j++) {
|
|
|
|
if (sft == sUCodeDisasModeHMacros[j].shift) {
|
|
|
|
for (k = 0; k < ARRAY_COUNTU(sUCodeDisasModeHMacros[j].values); k++) {
|
|
|
|
if (s2 == sUCodeDisasModeHMacros[j].values[k].value) {
|
|
|
|
DISAS_LOG("gsDP%s(%s),", sUCodeDisasModeHMacros[j].name,
|
|
|
|
sUCodeDisasModeHMacros[j].values[k].name);
|
|
|
|
goto found_othermode_hi_macro;
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsSPSetOtherModeH(%d, %d, 0x%08x),", sft, len, s2);
|
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
found_othermode_hi_macro:
|
|
|
|
this->modeH &= ((1 - (1 << len)) << sft) - 1;
|
2021-11-15 00:02:33 +00:00
|
|
|
this->modeH |= s2;
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
if (this->pipeSyncRequired) {
|
|
|
|
DISAS_LOG("### PipeSyncが必要です。\n");
|
|
|
|
this->syncErr++;
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_SETOTHERMODE_L: {
|
2021-10-31 20:39:29 +00:00
|
|
|
static F3dzexSetModeMacro sUCodeDisasModeLMacros[] = {
|
|
|
|
F3DZEX_SETRENDERMACRO("gsDPSetAlphaCompare", G_MDSFT_ALPHACOMPARE, 2, G_AC_NONE, G_AC_THRESHOLD,
|
|
|
|
G_AC_DITHER, -1),
|
|
|
|
F3DZEX_SETRENDERMACRO("gsDPSetDepthSource", G_MDSFT_ZSRCSEL, 1, G_ZS_PIXEL, G_ZS_PRIM, -1, -1),
|
|
|
|
};
|
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
u32 len = curGfx->setothermodeL.len + 1;
|
|
|
|
u32 sft = (-curGfx->setothermodeL.sft - len) + 32;
|
|
|
|
u32 s2 = curGfx->setothermodeL.data * 1;
|
|
|
|
u32 j;
|
|
|
|
u32 k;
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
if (sft == G_MDSFT_RENDERMODE) {
|
|
|
|
DISAS_LOG("\ngsDPSetRenderBlender(");
|
2022-10-15 21:14:35 +00:00
|
|
|
UCodeDisas_PrintRenderMode(this, s2);
|
2021-10-31 20:39:29 +00:00
|
|
|
DISAS_LOG("\n),");
|
|
|
|
} else {
|
2022-10-15 21:14:35 +00:00
|
|
|
for (j = 0; j * 1 < ARRAY_COUNTU(sUCodeDisasModeLMacros); j++) {
|
|
|
|
if (sft == sUCodeDisasModeLMacros[j].shift) {
|
|
|
|
for (k = 0; k < ARRAY_COUNTU(sUCodeDisasModeLMacros[j].values); k++) {
|
|
|
|
if (s2 == sUCodeDisasModeLMacros[j].values[k].value) {
|
|
|
|
DISAS_LOG("gsDP%s(%s),", sUCodeDisasModeLMacros[j].name,
|
|
|
|
sUCodeDisasModeLMacros[j].values[k].name);
|
|
|
|
goto found_othermode_lo_macro;
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsSPSetOtherModeL(%d, %d, 0x%08x),", sft, len, s2);
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
found_othermode_lo_macro:
|
2021-10-31 20:39:29 +00:00
|
|
|
this->modeL &= (((1 - (1 << len)) << sft) - 1);
|
2021-11-15 00:02:33 +00:00
|
|
|
this->modeL |= s2;
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
if (this->pipeSyncRequired) {
|
|
|
|
DISAS_LOG("### PipeSyncが必要です。\n");
|
|
|
|
this->syncErr++;
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_RDPSETOTHERMODE: {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsDPSetOtherMode(0x%08x, 0x%08x),", curGfx->words.w0 & 0xFFFFFF, curGfx->words.w1);
|
2021-11-26 22:37:33 +00:00
|
|
|
this->modeH = curGfx->words.w0 & 0xFFF;
|
2021-11-15 00:02:33 +00:00
|
|
|
this->modeL = curGfx->words.w1;
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
if (this->pipeSyncRequired) {
|
|
|
|
DISAS_LOG("### PipeSyncが必要です。\n");
|
|
|
|
this->syncErr++;
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_SETSCISSOR: {
|
|
|
|
Gfillrect setscissor = ptr->fillrect;
|
2021-10-31 20:39:29 +00:00
|
|
|
const char* modeStr;
|
|
|
|
|
2021-12-06 00:11:38 +00:00
|
|
|
modeStr = (setscissor.pad == G_SC_NON_INTERLACE) ? "G_SC_NON_INTERLACE"
|
|
|
|
: (setscissor.pad == G_SC_ODD_INTERLACE) ? "G_SC_ODD_INTERLACE"
|
|
|
|
: (setscissor.pad == G_SC_EVEN_INTERLACE) ? "G_SC_EVEN_INTERLACE"
|
|
|
|
: "???";
|
2021-11-15 00:02:33 +00:00
|
|
|
|
2022-05-12 13:04:37 +00:00
|
|
|
if (setscissor.x0frac | setscissor.y0frac | setscissor.x1frac | setscissor.y1frac) {
|
2021-11-15 00:02:33 +00:00
|
|
|
if (1) {}
|
2021-10-31 20:39:29 +00:00
|
|
|
DISAS_LOG("gsDPSetScissorFrac(%s, %d, %d, %d, %d),", modeStr,
|
|
|
|
(setscissor.x0 << 2) + setscissor.x0frac, (setscissor.y0 << 2) + setscissor.y0frac,
|
|
|
|
(setscissor.x1 << 2) + setscissor.x1frac, (setscissor.y1 << 2) + setscissor.y1frac);
|
|
|
|
} else {
|
|
|
|
DISAS_LOG("gsDPSetScissor(%s, %d, %d, %d, %d),", modeStr, setscissor.x0, setscissor.y0,
|
|
|
|
setscissor.x1, setscissor.y1);
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
2021-10-31 20:39:29 +00:00
|
|
|
|
2021-11-15 00:02:33 +00:00
|
|
|
case G_FILLRECT: {
|
|
|
|
Gfillrect fillrect = ptr->fillrect;
|
|
|
|
|
|
|
|
DISAS_LOG("gsDPFillRectangle(%d, %d, %d, %d),", fillrect.x1, fillrect.y1, fillrect.x0, fillrect.y0);
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
this->pipeSyncRequired = true;
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_SETCIMG: {
|
2021-11-26 22:37:33 +00:00
|
|
|
u32 fmt = ((curGfx->words.w0 & 0xE00000) >> 0x15) & 0xFF;
|
|
|
|
u32 siz = ((curGfx->words.w0 & 0x180000) >> 0x13) & 0xFF;
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
DISAS_LOG("gsDPSetColorImage(G_IM_FMT_%s, G_IM_SIZ_%s, %d, 0x%08x(0x%08x) ),",
|
2021-12-06 00:11:38 +00:00
|
|
|
(fmt == G_IM_FMT_RGBA) ? "RGBA"
|
|
|
|
: (fmt == G_IM_FMT_YUV) ? "YUV"
|
|
|
|
: (fmt == G_IM_FMT_CI) ? "CI"
|
|
|
|
: (fmt == G_IM_FMT_IA) ? "IA"
|
|
|
|
: "I",
|
|
|
|
(siz == G_IM_SIZ_4b) ? "4b"
|
|
|
|
: (siz == G_IM_SIZ_8b) ? "8b"
|
|
|
|
: (siz == G_IM_SIZ_16b) ? "16b"
|
|
|
|
: "32b",
|
2021-11-26 22:37:33 +00:00
|
|
|
(curGfx->dma.len & 0xFFF) + 1, curGfx->setimg.dram, addr);
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
if (this->pipeSyncRequired) {
|
|
|
|
DISAS_LOG("### PipeSyncが必要です。\n");
|
|
|
|
this->syncErr++;
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_SETZIMG: {
|
2022-10-15 21:14:35 +00:00
|
|
|
DISAS_LOG("gsDPSetDepthImage(0x%08x(0x%08x)),", curGfx->setimg.dram, addr);
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
if (this->pipeSyncRequired) {
|
|
|
|
DISAS_LOG("### PipeSyncが必要です。\n");
|
|
|
|
this->syncErr++;
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_SETTIMG: {
|
2021-11-26 22:37:33 +00:00
|
|
|
u32 fmt = ((curGfx->words.w0 & 0xE00000) >> 0x15) & 0xFF;
|
|
|
|
u32 siz = ((curGfx->words.w0 & 0x180000) >> 0x13) & 0xFF;
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
DISAS_LOG("gsDPSetTextureImage(G_IM_FMT_%s, G_IM_SIZ_%s, %d, 0x%08x(0x%08x)),",
|
2021-12-06 00:11:38 +00:00
|
|
|
(fmt == G_IM_FMT_RGBA) ? "RGBA"
|
|
|
|
: (fmt == G_IM_FMT_YUV) ? "YUV"
|
|
|
|
: (fmt == G_IM_FMT_CI) ? "CI"
|
|
|
|
: (fmt == G_IM_FMT_IA) ? "IA"
|
|
|
|
: "I",
|
|
|
|
(siz == G_IM_SIZ_4b) ? "4b"
|
|
|
|
: (siz == G_IM_SIZ_8b) ? "8b"
|
|
|
|
: (siz == G_IM_SIZ_16b) ? "16b"
|
|
|
|
: "32b",
|
2021-11-26 22:37:33 +00:00
|
|
|
(curGfx->dma.len & 0xFFF) + 1, curGfx->setimg.dram, addr);
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_SETENVCOLOR: {
|
|
|
|
DISAS_LOG("gsDPSetEnvColor(%d, %d, %d, %d),", curGfx->setcolor.r, curGfx->setcolor.g,
|
|
|
|
curGfx->setcolor.b, curGfx->setcolor.a);
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
if (this->pipeSyncRequired) {
|
|
|
|
DISAS_LOG("### PipeSyncが必要です。\n");
|
|
|
|
this->syncErr++;
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_SETBLENDCOLOR: {
|
|
|
|
DISAS_LOG("gsDPSetBlendColor(%d, %d, %d, %d),", curGfx->setcolor.r, curGfx->setcolor.g,
|
|
|
|
curGfx->setcolor.b, curGfx->setcolor.a);
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
if (this->pipeSyncRequired) {
|
|
|
|
DISAS_LOG("### PipeSyncが必要です。\n");
|
|
|
|
this->syncErr++;
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_SETFOGCOLOR: {
|
|
|
|
DISAS_LOG("gsDPSetFogColor(%d, %d, %d, %d),", curGfx->setcolor.r, curGfx->setcolor.g,
|
|
|
|
curGfx->setcolor.b, curGfx->setcolor.a);
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
if (this->pipeSyncRequired) {
|
|
|
|
DISAS_LOG("### PipeSyncが必要です。\n");
|
|
|
|
this->syncErr++;
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_SETFILLCOLOR: {
|
2022-10-15 21:14:35 +00:00
|
|
|
DISAS_LOG("gsDPSetFillColor(0x%08x),", curGfx->setcolor.color);
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
if (this->pipeSyncRequired) {
|
|
|
|
DISAS_LOG("### PipeSyncが必要です。\n");
|
|
|
|
this->syncErr++;
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_SETPRIMDEPTH: {
|
2022-10-15 21:14:35 +00:00
|
|
|
DISAS_LOG("gsDPSetPrimDepth(%d, %d),", curGfx->setprimdepth.z, curGfx->setprimdepth.dz);
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
if (this->pipeSyncRequired) {
|
|
|
|
DISAS_LOG("### PipeSyncが必要です。\n");
|
|
|
|
this->syncErr++;
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_SETPRIMCOLOR: {
|
|
|
|
DISAS_LOG("gsDPSetPrimColor(%d, %d, %d, %d, %d, %d),", curGfx->setcolor.prim_min_level,
|
|
|
|
curGfx->setcolor.prim_level, curGfx->setcolor.r, curGfx->setcolor.g, curGfx->setcolor.b,
|
|
|
|
curGfx->setcolor.a);
|
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_RDPFULLSYNC: {
|
|
|
|
DISAS_LOG("gsDPFullSync(),");
|
2021-11-15 00:02:33 +00:00
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
if (this->pipeSyncRequired) {
|
|
|
|
DISAS_LOG("### PipeSyncが必要です。\n");
|
|
|
|
this->syncErr++;
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_RDPTILESYNC: {
|
|
|
|
DISAS_LOG("gsDPTileSync(),");
|
|
|
|
this->tileSyncRequired = false;
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_RDPPIPESYNC: {
|
|
|
|
DISAS_LOG("gsDPPipeSync(),");
|
|
|
|
this->pipeSyncRequired = false;
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_RDPLOADSYNC: {
|
|
|
|
DISAS_LOG("gsDPLoadSync(),");
|
|
|
|
this->loadSyncRequired = false;
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_NOOP: {
|
2021-11-15 00:02:33 +00:00
|
|
|
switch (curGfx->noop.type) {
|
|
|
|
case 0: {
|
|
|
|
if (curGfx->noop.value.u32 == 0) {
|
2021-10-31 20:39:29 +00:00
|
|
|
DISAS_LOG("gsDPNoOp(),");
|
|
|
|
} else {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsDPNoOpTag(%08x),", curGfx->noop.value.u32);
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case 1: {
|
2022-10-15 21:14:35 +00:00
|
|
|
DISAS_LOG("count_gsDPNoOpHere([%s:%d]),", curGfx->noop.value.str, curGfx->noop.len);
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case 7: {
|
2022-10-15 21:14:35 +00:00
|
|
|
DISAS_LOG("count_gsDPNoOpOpenDisp([%s:%d]),", curGfx->noop.value.str, curGfx->noop.len);
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case 8: {
|
2022-10-15 21:14:35 +00:00
|
|
|
DISAS_LOG("count_gsDPNoOpCloseDisp([%s:%d]),", curGfx->noop.value.str, curGfx->noop.len);
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case 2: {
|
2022-10-15 21:14:35 +00:00
|
|
|
DISAS_LOG("count_gsDPNoOpString(%c%s%c, %d),", '"', curGfx->noop.value.str, '"',
|
2021-11-15 00:02:33 +00:00
|
|
|
curGfx->noop.len);
|
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case 3: {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("count_gsDPNoOpWord(0x%08x, %d),", curGfx->noop.value.u32, curGfx->noop.len);
|
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case 4: {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("count_gsDPNoOpFloat(%8.3f, %d),", curGfx->noop.value.f32, curGfx->noop.len);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case 5: {
|
|
|
|
if (curGfx->noop.len == 0) {
|
2021-10-31 20:39:29 +00:00
|
|
|
DISAS_LOG("count_gsDPNoOpQuiet(),");
|
|
|
|
} else {
|
|
|
|
DISAS_LOG("count_gsDPNoOpVerbose(),");
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
this->enableLog = curGfx->noop.len;
|
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case 6: {
|
2022-10-15 21:14:35 +00:00
|
|
|
//! @bug arguments are not printed
|
2021-10-31 20:39:29 +00:00
|
|
|
DISAS_LOG("count_gsDPNoOpCallBack(%08x,%d),");
|
2022-10-15 21:14:35 +00:00
|
|
|
((UcodeDisasCallback)curGfx->noop.value.callback)(this, curGfx->noop.len);
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
default: {
|
|
|
|
DISAS_LOG("gsDPNoOpTag3(%02x, %08x, %04x),", curGfx->noop.type, curGfx->noop.value.u32,
|
|
|
|
curGfx->noop.len);
|
|
|
|
} break;
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
default: {
|
|
|
|
switch (this->ucodeType) {
|
|
|
|
case UCODE_F3DZEX:
|
|
|
|
case UCODE_UNK: {
|
2021-11-15 00:02:33 +00:00
|
|
|
switch (cmd) {
|
|
|
|
case G_MTX: {
|
2022-10-15 21:14:35 +00:00
|
|
|
Gdma2 gmtx = ptr->dma2;
|
2021-10-31 20:39:29 +00:00
|
|
|
u32 params;
|
2022-10-15 21:14:35 +00:00
|
|
|
MtxF mtxF;
|
|
|
|
s32 j = 0;
|
2021-11-15 00:02:33 +00:00
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
DISAS_LOG("gsSPMatrix(0x%08x(%08x), 0", gmtx.addr, addr);
|
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
params = gmtx.par ^ G_MTX_PUSH;
|
2021-10-31 20:39:29 +00:00
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
for (; j != ARRAY_COUNT(sUCodeDisasMtxFlags); j++) {
|
|
|
|
DISAS_LOG("|%s", (sUCodeDisasMtxFlags[j].value & params)
|
|
|
|
? sUCodeDisasMtxFlags[j].setName
|
|
|
|
: sUCodeDisasMtxFlags[j].unsetName);
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
2022-10-15 21:14:35 +00:00
|
|
|
DISAS_LOG("),", gmtx.addr); //! @bug gmtx.addr shouldn't be here
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
if (this->enableLog >= 2) {
|
2022-10-15 21:14:35 +00:00
|
|
|
MtxConv_L2F(&mtxF, (Mtx*)addr);
|
2021-10-31 20:39:29 +00:00
|
|
|
DISAS_LOG("\n");
|
2021-11-26 22:37:33 +00:00
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
//! @bug %.04x.%04x is a typo, should be %04x.%04x
|
2021-11-26 22:37:33 +00:00
|
|
|
// clang-format off
|
2021-10-31 20:39:29 +00:00
|
|
|
DISAS_LOG(
|
2021-11-26 22:37:33 +00:00
|
|
|
"/ %04x.%04x %04x.%04x %04x.%04x %.04x.%04x \\/ %12.6f %12.6f %12.6f %12.6f \\\n"
|
2021-10-31 20:39:29 +00:00
|
|
|
"| %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"
|
2021-11-26 22:37:33 +00:00
|
|
|
"\\ %04x.%04x %04x.%04x %04x.%04x %.04x.%04x /\\ %12.6f %12.6f %12.6f %12.6f /\n",
|
|
|
|
((Mtx*)addr)->intPart[0][0], ((Mtx*)addr)->fracPart[0][0],
|
|
|
|
((Mtx*)addr)->intPart[1][0], ((Mtx*)addr)->fracPart[1][0],
|
|
|
|
((Mtx*)addr)->intPart[2][0], ((Mtx*)addr)->fracPart[2][0],
|
|
|
|
((Mtx*)addr)->intPart[3][0], ((Mtx*)addr)->fracPart[3][0],
|
2022-10-15 21:14:35 +00:00
|
|
|
mtxF.mf[0][0], mtxF.mf[1][0], mtxF.mf[2][0], mtxF.mf[3][0],
|
2021-11-26 22:37:33 +00:00
|
|
|
((Mtx*)addr)->intPart[0][1], ((Mtx*)addr)->fracPart[0][1],
|
|
|
|
((Mtx*)addr)->intPart[1][1], ((Mtx*)addr)->fracPart[1][1],
|
|
|
|
((Mtx*)addr)->intPart[2][1], ((Mtx*)addr)->fracPart[2][1],
|
|
|
|
((Mtx*)addr)->intPart[3][1], ((Mtx*)addr)->fracPart[3][1],
|
2022-10-15 21:14:35 +00:00
|
|
|
mtxF.mf[0][1], mtxF.mf[1][1], mtxF.mf[2][1], mtxF.mf[3][1],
|
2021-11-26 22:37:33 +00:00
|
|
|
((Mtx*)addr)->intPart[0][2], ((Mtx*)addr)->fracPart[0][2],
|
|
|
|
((Mtx*)addr)->intPart[1][2], ((Mtx*)addr)->fracPart[1][2],
|
|
|
|
((Mtx*)addr)->intPart[2][2], ((Mtx*)addr)->fracPart[2][2],
|
|
|
|
((Mtx*)addr)->intPart[3][2], ((Mtx*)addr)->fracPart[3][2],
|
2022-10-15 21:14:35 +00:00
|
|
|
mtxF.mf[0][2], mtxF.mf[1][2], mtxF.mf[2][2], mtxF.mf[3][2],
|
2021-11-26 22:37:33 +00:00
|
|
|
((Mtx*)addr)->intPart[0][3], ((Mtx*)addr)->fracPart[0][3],
|
|
|
|
((Mtx*)addr)->intPart[1][3], ((Mtx*)addr)->fracPart[1][3],
|
|
|
|
((Mtx*)addr)->intPart[2][3], ((Mtx*)addr)->fracPart[2][3],
|
|
|
|
((Mtx*)addr)->intPart[3][3], ((Mtx*)addr)->fracPart[3][3],
|
2022-10-15 21:14:35 +00:00
|
|
|
mtxF.mf[0][3], mtxF.mf[1][3], mtxF.mf[2][3], mtxF.mf[3][3]);
|
2021-11-26 22:37:33 +00:00
|
|
|
// clang-format on
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_VTX: {
|
2021-11-15 00:02:33 +00:00
|
|
|
u32 numv = curGfx->words.w0;
|
|
|
|
u32 vbidx;
|
|
|
|
|
|
|
|
numv >>= 12;
|
2021-11-26 22:37:33 +00:00
|
|
|
numv &= 0xFF;
|
2022-10-15 21:14:35 +00:00
|
|
|
vbidx = (curGfx->vtx.par >> 1) - numv;
|
2021-11-15 00:02:33 +00:00
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
DISAS_LOG("gsSPVertex(0x%08x(0x%08x), %d, %d),", curGfx->vtx.addr, addr, numv, vbidx);
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
this->vtxCnt += numv;
|
|
|
|
this->spvtxCnt++;
|
|
|
|
|
|
|
|
if (this->enableLog >= 2) {
|
2022-06-16 00:15:44 +00:00
|
|
|
UCodeDisas_PrintVertices(this, (Vtx*)addr, numv, vbidx);
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_MODIFYVTX: {
|
|
|
|
DISAS_LOG("gsSPModifyVertex(%d, %s, %08x),", curGfx->dma.par,
|
2021-12-06 00:11:38 +00:00
|
|
|
(curGfx->dma.len == G_MWO_POINT_RGBA) ? "G_MWO_POINT_RGBA"
|
|
|
|
: (curGfx->dma.len == G_MWO_POINT_ST) ? "G_MWO_POINT_ST"
|
|
|
|
: (curGfx->dma.len == G_MWO_POINT_XYSCREEN) ? "G_MWO_POINT_XYSCREEN"
|
|
|
|
: (curGfx->dma.len == G_MWO_POINT_ZSCREEN) ? "G_MWO_POINT_ZSCREEN"
|
|
|
|
: "G_MWO_POINT_????",
|
2021-11-15 00:02:33 +00:00
|
|
|
curGfx->dma.addr);
|
|
|
|
this->vtxCnt += curGfx->dma.par;
|
2021-10-31 20:39:29 +00:00
|
|
|
this->spvtxCnt++;
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_TRI1: {
|
2022-10-15 21:14:35 +00:00
|
|
|
Gtri gtri = ptr->tri;
|
|
|
|
Tri tri = gtri.tri;
|
2021-11-15 00:02:33 +00:00
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
DISAS_LOG("gsSP1Triangle(%d, %d, %d),", tri.v[0] / 2, tri.v[1] / 2, tri.v[2] / 2);
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
this->tri1Cnt++;
|
2021-11-15 00:02:33 +00:00
|
|
|
this->pipeSyncRequired = true;
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_LINE3D: {
|
2022-10-15 21:14:35 +00:00
|
|
|
if (curGfx->line.wd == 0) {
|
|
|
|
DISAS_LOG("gsSPLine3D(%d, %d),", curGfx->line.v0, curGfx->line.v1);
|
2021-10-31 20:39:29 +00:00
|
|
|
} else {
|
2022-10-15 21:14:35 +00:00
|
|
|
DISAS_LOG("gsSPLineW3D(%d, %d, %d),", curGfx->line.v0, curGfx->line.v1,
|
|
|
|
curGfx->line.wd);
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
|
|
|
|
2021-11-15 00:02:33 +00:00
|
|
|
this->lineCnt++;
|
2021-10-31 20:39:29 +00:00
|
|
|
this->pipeSyncRequired = true;
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_TRI2: {
|
|
|
|
Gtri2 tri2 = ptr->tri2;
|
|
|
|
u32 v0, v1, v2;
|
|
|
|
u32 v3, v4, v5;
|
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
v0 = tri2.tri1.v[0] / 2;
|
|
|
|
v1 = tri2.tri1.v[1] / 2;
|
|
|
|
v2 = tri2.tri1.v[2] / 2;
|
2021-11-15 00:02:33 +00:00
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
v3 = tri2.tri2.v[0] / 2;
|
|
|
|
v4 = tri2.tri2.v[1] / 2;
|
|
|
|
v5 = tri2.tri2.v[2] / 2;
|
2021-11-15 00:02:33 +00:00
|
|
|
|
|
|
|
DISAS_LOG("gsSP2Triangles(%d, %d, %d, 0, %d, %d, %d, 0),", v0, v1, v2, v3, v4, v5);
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
this->tri2Cnt++;
|
|
|
|
this->pipeSyncRequired = true;
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_QUAD: {
|
2022-10-15 21:14:35 +00:00
|
|
|
Gquad quad = ptr->quad;
|
2021-11-15 00:02:33 +00:00
|
|
|
u32 v0, v1, v2, v3;
|
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
v0 = quad.tri1.v[0] / 2;
|
|
|
|
v1 = quad.tri1.v[1] / 2;
|
|
|
|
v2 = quad.tri1.v[2] / 2;
|
|
|
|
v3 = quad.tri2.v[2] / 2;
|
2021-11-15 00:02:33 +00:00
|
|
|
|
|
|
|
DISAS_LOG("gsSP1Quadrangle(%d, %d, %d, %d, 0),", v0, v1, v2, v3);
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
this->quadCnt++;
|
2021-11-15 00:02:33 +00:00
|
|
|
this->pipeSyncRequired = true;
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_CULLDL: {
|
2022-10-15 21:14:35 +00:00
|
|
|
DISAS_LOG("gsSPCullDisplayList(%d, %d),", (curGfx->cull.vstart_x2) / 2,
|
|
|
|
(curGfx->cull.vend_x2) / 2);
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_BRANCH_Z: {
|
2022-10-15 21:14:35 +00:00
|
|
|
addr = (uintptr_t)UCodeDisas_TranslateAddr(this, rdpHalf);
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsSPBranchLessZraw(0x%08x(0x%08x), %d, 0x%08x),", rdpHalf, addr,
|
|
|
|
(curGfx->words.w0 & 0xFFF) / 2, curGfx->words.w1);
|
2022-10-15 21:14:35 +00:00
|
|
|
ptr = (Gfx*)addr - 1;
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_TEXTURE: {
|
2022-10-15 21:14:35 +00:00
|
|
|
Gtexture texture = ptr->texture;
|
2021-11-15 00:02:33 +00:00
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
if (texture.lodscale == 0) {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsSPTexture(%d, %d, %d, %d, %s),", texture.s, texture.t, texture.level,
|
|
|
|
texture.tile, texture.on ? "G_ON" : "G_OFF");
|
2021-10-31 20:39:29 +00:00
|
|
|
} else {
|
|
|
|
DISAS_LOG("gsSPTextureL(%d, %d, %d, %d, %d, %s),", texture.s, texture.t,
|
2021-11-15 00:02:33 +00:00
|
|
|
texture.level, texture.lodscale, texture.tile,
|
2021-10-31 20:39:29 +00:00
|
|
|
texture.on ? "G_ON" : "G_OFF");
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_POPMTX: {
|
2022-10-15 21:14:35 +00:00
|
|
|
Gpopmtx popmtx = ptr->popmtx;
|
2021-11-15 00:02:33 +00:00
|
|
|
|
2022-10-15 21:14:35 +00:00
|
|
|
if (popmtx.param / 64 == 1) {
|
2021-10-31 20:39:29 +00:00
|
|
|
DISAS_LOG("gsSPPopMatrix(G_MTX_MODELVIEW),");
|
|
|
|
} else {
|
2022-10-15 21:14:35 +00:00
|
|
|
DISAS_LOG("gsSPPopMatrixN(G_MTX_MODELVIEW, %d),", popmtx.param / 64);
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_GEOMETRYMODE: {
|
2021-11-15 00:02:33 +00:00
|
|
|
u32 clearbits = curGfx->words.w0 & 0xFFFFFF;
|
|
|
|
u32 setbits = curGfx->words.w1 & 0xFFFFFF;
|
2021-10-31 20:39:29 +00:00
|
|
|
|
|
|
|
if (clearbits == 0) {
|
|
|
|
DISAS_LOG("gsSPLoadGeometryMode(");
|
2022-10-15 21:14:35 +00:00
|
|
|
UCodeDisas_PrintGeometryMode(this, setbits);
|
2021-10-31 20:39:29 +00:00
|
|
|
DISAS_LOG("),");
|
2021-11-15 00:02:33 +00:00
|
|
|
} else if (setbits == 0) {
|
|
|
|
DISAS_LOG("gsSPClearGeometryMode(");
|
2022-10-15 21:14:35 +00:00
|
|
|
UCodeDisas_PrintGeometryMode(this, ~clearbits);
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("),");
|
|
|
|
} else if (clearbits == 0xFFFFFF) {
|
|
|
|
DISAS_LOG("gsSPSetGeometryMode(");
|
2022-10-15 21:14:35 +00:00
|
|
|
UCodeDisas_PrintGeometryMode(this, setbits);
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("),");
|
2021-10-31 20:39:29 +00:00
|
|
|
} else {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsSPGeometryMode(");
|
2022-10-15 21:14:35 +00:00
|
|
|
UCodeDisas_PrintGeometryMode(this, ~clearbits);
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG(", ");
|
2022-10-15 21:14:35 +00:00
|
|
|
UCodeDisas_PrintGeometryMode(this, setbits);
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("),");
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
this->geometryMode &= clearbits;
|
|
|
|
this->geometryMode |= setbits;
|
2021-11-15 00:02:33 +00:00
|
|
|
break; // this break needs to be inside, but the other cases need their breaks to be
|
|
|
|
// outside...
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
|
|
|
|
case G_MOVEWORD: {
|
|
|
|
u32 pad;
|
|
|
|
Gdma dma = ptr->dma;
|
|
|
|
Gmovewd movewd = ptr->movewd;
|
|
|
|
|
|
|
|
movewd.index = dma.par;
|
|
|
|
movewd.offset = dma.len;
|
|
|
|
movewd.data = dma.addr;
|
|
|
|
switch (movewd.index) {
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_MW_SEGMENT: {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsSPSegment(%d, 0x%08x),", movewd.offset / 4, movewd.data);
|
|
|
|
this->segments[movewd.offset / 4] = movewd.data & 0xFFFFFF;
|
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_MW_CLIP: {
|
|
|
|
DISAS_LOG("gsSPClipRatio(FRUSTRATIO_%d), ",
|
2021-11-15 00:02:33 +00:00
|
|
|
(movewd.data != 0) ? movewd.data : -movewd.data);
|
|
|
|
ptr += 4 - 1;
|
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_MW_NUMLIGHT: {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsSPNumLights(%d), ", movewd.data / 24);
|
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_MW_LIGHTCOL: {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsSPLightColor(%d, %d), ", ((movewd.offset & 0xF0) >> 5) + 1,
|
|
|
|
movewd.data);
|
|
|
|
ptr += 2 - 1;
|
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_MW_FOG: {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsSPFogFactor(%d, %d),", movewd.data >> 16, movewd.data & 0xFFFF);
|
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_MW_PERSPNORM: {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsSPPerspNormalize(%d),", movewd.data);
|
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
default: {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsMoveWd(%d, %d, %d), ", movewd.index, movewd.offset, movewd.data);
|
|
|
|
} break;
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_MOVEMEM: {
|
|
|
|
Gmovemem movemem = ptr->movemem;
|
2021-10-31 20:39:29 +00:00
|
|
|
Vp_t* vp = (Vp_t*)addr;
|
|
|
|
|
2021-11-15 00:02:33 +00:00
|
|
|
switch (movemem.index) {
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_MV_VIEWPORT: {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsSPViewport(0x%08x(0x%08x)),", movemem.data, vp);
|
2021-10-31 20:39:29 +00:00
|
|
|
DISAS_LOG("\t# vscale=[%d %d %d %d], ", vp->vscale[0], vp->vscale[1],
|
|
|
|
vp->vscale[2], vp->vscale[3]);
|
|
|
|
DISAS_LOG("vtrans=[%d %d %d %d] ", vp->vtrans[0], vp->vtrans[1], vp->vtrans[2],
|
|
|
|
vp->vtrans[3]);
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_MV_MATRIX: {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsSPForceMatrix(0x%08x),", movemem.data);
|
2022-10-15 21:14:35 +00:00
|
|
|
ptr += 2 - 1;
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_MV_LIGHT: {
|
2022-05-12 13:04:37 +00:00
|
|
|
switch (movemem.offset * 8) {
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_MVO_LOOKATX: {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsSPLookAtX(0x%08x),", movemem.data);
|
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_MVO_LOOKATY: {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsSPLookAtY(0x%08x),", movemem.data);
|
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
default: {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsSPLight(0x%08x,%d),", movemem.data,
|
2022-10-15 21:14:35 +00:00
|
|
|
(movemem.offset * 8 - 0x18) / 0x18);
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
default: {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsMoveMem(0x%08x, %d, %d, %d),", movemem.data,
|
|
|
|
((movemem.size >> 3) + 1) * 8, movemem.index, movemem.offset * 8);
|
|
|
|
} break;
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-12-02 22:31:39 +00:00
|
|
|
default: {
|
|
|
|
DISAS_LOG("AnyDisplayList(),");
|
|
|
|
} break;
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case UCODE_S2DEX: {
|
2021-11-15 00:02:33 +00:00
|
|
|
switch (cmd) {
|
|
|
|
case G_BG_COPY: {
|
|
|
|
Gwords words = ptr->words;
|
|
|
|
|
|
|
|
DISAS_LOG("gsSPBgRectCopy(0x%08x(0x%08x)),", words.w1, addr);
|
2021-10-31 20:39:29 +00:00
|
|
|
this->pipeSyncRequired = true;
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_BG_1CYC: {
|
|
|
|
Gwords words = ptr->words;
|
|
|
|
|
|
|
|
DISAS_LOG("gsSPBgRect1Cyc(0x%08x(0x%08x)),", words.w1, addr);
|
2021-10-31 20:39:29 +00:00
|
|
|
this->pipeSyncRequired = true;
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_OBJ_SPRITE: {
|
|
|
|
Gwords words = ptr->words;
|
|
|
|
|
|
|
|
DISAS_LOG("gsSPObjSprite(0x%08x(0x%08x)),", words.w1, addr);
|
2021-10-31 20:39:29 +00:00
|
|
|
this->pipeSyncRequired = true;
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_OBJ_RECTANGLE: {
|
|
|
|
Gwords words = ptr->words;
|
|
|
|
|
|
|
|
DISAS_LOG("gsSPObjRectangle(0x%08x(0x%08x)),", words.w1, addr);
|
2021-10-31 20:39:29 +00:00
|
|
|
this->pipeSyncRequired = true;
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_OBJ_RECTANGLE_R: {
|
|
|
|
Gwords words = ptr->words;
|
|
|
|
|
|
|
|
DISAS_LOG("gsSPObjRectangleR(0x%08x(0x%08x)),", words.w1, addr);
|
2021-10-31 20:39:29 +00:00
|
|
|
this->pipeSyncRequired = true;
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case G_RDPHALF_0: {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("RDPHALF_0(0x%02x, 0x%08x, 0x%04x),", curGfx->dma.par, curGfx->dma.addr,
|
|
|
|
curGfx->dma.len);
|
|
|
|
sid = curGfx->dma.par;
|
|
|
|
rdpHalf = curGfx->dma.addr;
|
|
|
|
linkDlLow = curGfx->dma.len;
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_OBJ_MOVEMEM: {
|
|
|
|
Gdma dma = ptr->dma;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
if (dma.par == 23) {
|
|
|
|
DISAS_LOG("gsSPObjMatrix(0x%08x(0x%08x)),", dma.addr, addr);
|
|
|
|
} else {
|
|
|
|
DISAS_LOG("gsSPObjSubMatrix(0x%08x(0x%08x)),", dma.addr, addr);
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_OBJ_LOADTXTR: {
|
|
|
|
Gdma dma = ptr->dma;
|
|
|
|
|
|
|
|
DISAS_LOG("gsSPObjLoadTxtr(0x%08x(0x%08x)),", dma.addr, addr);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_OBJ_LDTX_SPRITE: {
|
|
|
|
Gdma dma = ptr->dma;
|
|
|
|
|
|
|
|
DISAS_LOG("gsSPObjLoadTxSprite(0x%08x(0x%08x)),", dma.addr, addr);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_OBJ_LDTX_RECT: {
|
|
|
|
Gdma dma = ptr->dma;
|
|
|
|
|
|
|
|
DISAS_LOG("gsSPObjLoadTxRect(0x%08x(0x%08x)),", dma.addr, addr);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_OBJ_LDTX_RECT_R: {
|
|
|
|
Gdma dma = ptr->dma;
|
|
|
|
|
|
|
|
DISAS_LOG("gsSPObjLoadTxRectR(0x%08x(0x%08x)),", dma.addr, addr);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_SELECT_DL: {
|
|
|
|
Gdma dma = ptr->dma;
|
2022-10-15 21:14:35 +00:00
|
|
|
uintptr_t dlAddr =
|
|
|
|
(uintptr_t)UCodeDisas_TranslateAddr(this, (dma.len << 16) | (linkDlLow));
|
|
|
|
uintptr_t dmaAddr = dma.addr;
|
2021-11-15 00:02:33 +00:00
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
if (dma.par == 0) {
|
|
|
|
DISAS_LOG("gsSPSelectDL(0x%08x, %d, 0x%08x, 0x%08x),", dlAddr, sid, rdpHalf,
|
2021-11-15 00:02:33 +00:00
|
|
|
dmaAddr);
|
2021-10-31 20:39:29 +00:00
|
|
|
} else {
|
|
|
|
DISAS_LOG("gsSPSelectBranchDL(0x%08x, %d, 0x%08x, 0x%08x),", dlAddr, sid, rdpHalf,
|
2021-11-15 00:02:33 +00:00
|
|
|
dmaAddr);
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
2021-10-31 20:39:29 +00:00
|
|
|
|
2021-11-15 00:02:33 +00:00
|
|
|
case G_MOVEWORD: {
|
|
|
|
u32 pad[2];
|
|
|
|
Gmovewd movewd = ptr->movewd;
|
|
|
|
|
|
|
|
switch (movewd.index) {
|
2021-10-31 20:39:29 +00:00
|
|
|
case 6: {
|
2021-11-15 00:02:33 +00:00
|
|
|
u32 segId = movewd.offset / 4;
|
|
|
|
|
|
|
|
DISAS_LOG("gsSPSegment(%d, 0x%08x),", segId, movewd.data);
|
|
|
|
this->segments[segId] = movewd.data & 0xFFFFFF;
|
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
case 8: {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsSPSetStatus(0x%08x, 0x%08x),", movewd.offset, movewd.data);
|
|
|
|
} break;
|
|
|
|
|
2021-10-31 20:39:29 +00:00
|
|
|
default: {
|
2021-11-15 00:02:33 +00:00
|
|
|
DISAS_LOG("gsMoveWd(%d, %d, %d), ", movewd.index, movewd.offset, movewd.data);
|
|
|
|
} break;
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case G_OBJ_RENDERMODE: {
|
|
|
|
Gdma dma = ptr->dma;
|
|
|
|
|
|
|
|
DISAS_LOG("gsSPObjRenderMode(0x%08x),", dma.addr);
|
|
|
|
} break;
|
|
|
|
|
2021-12-02 22:31:39 +00:00
|
|
|
default: {
|
|
|
|
DISAS_LOG("AnyDisplayList(),");
|
|
|
|
} break;
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-11-15 00:02:33 +00:00
|
|
|
} break;
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_LOG("\n");
|
|
|
|
|
2021-11-15 00:02:33 +00:00
|
|
|
ptr++;
|
2021-10-31 20:39:29 +00:00
|
|
|
}
|
|
|
|
}
|
2020-06-05 17:18:39 +00:00
|
|
|
|
|
|
|
void UCodeDisas_RegisterUCode(UCodeDisas* this, s32 count, UCodeInfo* ucodeArray) {
|
|
|
|
this->ucodeInfoCount = count;
|
|
|
|
this->ucodeInfo = ucodeArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UCodeDisas_SetCurUCode(UCodeDisas* this, void* ptr) {
|
|
|
|
UCodeDisas_SetCurUCodeImpl(this, ptr);
|
|
|
|
}
|