From dc1501e7a078fefb13cd2173530e021a241155d0 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Tue, 24 Sep 2024 13:45:53 -0400 Subject: [PATCH] create ucode_disas.h (#2222) * ucode_disas.h * create UcodeType * bss --- include/functions.h | 5 --- include/gfx.h | 35 --------------- include/ucode_disas.h | 49 +++++++++++++++++++++ src/boot/z_std_dma.c | 2 +- src/code/graph.c | 13 +++--- src/code/main.c | 2 +- src/code/ucode_disas.c | 9 ++-- src/code/z_bgcheck.c | 2 +- src/code/z_camera.c | 2 +- src/code/z_collision_check.c | 2 +- src/code/z_common_data.c | 2 +- src/code/z_kankyo.c | 4 +- src/overlays/actors/ovl_Fishing/z_fishing.c | 2 +- 13 files changed, 70 insertions(+), 59 deletions(-) create mode 100644 include/ucode_disas.h diff --git a/include/functions.h b/include/functions.h index 82598e415c..e146c89301 100644 --- a/include/functions.h +++ b/include/functions.h @@ -940,11 +940,6 @@ void* DebugArena_ReallocDebug(void* ptr, u32 newSize, const char* file, int line void DebugArena_FreeDebug(void* ptr, const char* file, int line); void DebugArena_Display(void); #endif -void UCodeDisas_Init(UCodeDisas*); -void UCodeDisas_Destroy(UCodeDisas*); -void UCodeDisas_Disassemble(UCodeDisas*, Gfx*); -void UCodeDisas_RegisterUCode(UCodeDisas*, s32, UCodeInfo*); -void UCodeDisas_SetCurUCode(UCodeDisas*, void*); Acmd* AudioSynth_Update(Acmd* cmdStart, s32* cmdCnt, s16* aiStart, s32 aiBufLen); void AudioHeap_DiscardFont(s32 fontId); void AudioHeap_ReleaseNotesForFont(s32 fontId); diff --git a/include/gfx.h b/include/gfx.h index 5414cd5ade..d14590a45f 100644 --- a/include/gfx.h +++ b/include/gfx.h @@ -126,41 +126,6 @@ typedef enum SetupDL { /* 71 */ SETUPDL_MAX } SetupDL; -#define UCODE_NULL 0 -#define UCODE_F3DZEX 1 -#define UCODE_UNK 2 -#define UCODE_S2DEX 3 - -typedef struct UCodeInfo { - /* 0x00 */ u32 type; - /* 0x04 */ void* ptr; -} UCodeInfo; // size = 0x8 - -typedef struct UCodeDisas { - /* 0x00 */ uintptr_t segments[NUM_SEGMENTS]; - /* 0x40 */ Gfx* dlStack[18]; - /* 0x88 */ s32 dlDepth; - /* 0x8C */ u32 dlCnt; - /* 0x90 */ u32 vtxCnt; - /* 0x94 */ u32 spvtxCnt; - /* 0x98 */ u32 tri1Cnt; - /* 0x9C */ u32 tri2Cnt; - /* 0xA0 */ u32 quadCnt; - /* 0xA4 */ u32 lineCnt; - /* 0xA8 */ u32 loaducodeCnt; - /* 0xAC */ u32 pipeSyncRequired; - /* 0xB0 */ u32 tileSyncRequired; - /* 0xB4 */ u32 loadSyncRequired; - /* 0xB8 */ u32 syncErr; - /* 0xBC */ s32 enableLog; - /* 0xC0 */ s32 ucodeType; - /* 0xC4 */ s32 ucodeInfoCount; - /* 0xC8 */ UCodeInfo* ucodeInfo; - /* 0xCC */ u32 modeH; - /* 0xD0 */ u32 modeL; - /* 0xD4 */ u32 geometryMode; -} UCodeDisas; // size = 0xD8 - void* Graph_Alloc(GraphicsContext* gfxCtx, size_t size); void* Graph_Alloc2(GraphicsContext* gfxCtx, size_t size); diff --git a/include/ucode_disas.h b/include/ucode_disas.h new file mode 100644 index 0000000000..d1fc901335 --- /dev/null +++ b/include/ucode_disas.h @@ -0,0 +1,49 @@ +#ifndef UCODE_DISAS_H +#define UCODE_DISAS_H + +#include "ultra64.h" + +typedef enum UcodeType { + /* 0 */ UCODE_TYPE_NULL, + /* 1 */ UCODE_TYPE_F3DZEX, + /* 2 */ UCODE_TYPE_UNK, // Likely F3DEX2 or a similar variant + /* 3 */ UCODE_TYPE_S2DEX +} UcodeType; + +typedef struct UCodeInfo { + /* 0x00 */ u32 type; + /* 0x04 */ void* ptr; +} UCodeInfo; // size = 0x8 + +typedef struct UCodeDisas { + /* 0x00 */ uintptr_t segments[NUM_SEGMENTS]; + /* 0x40 */ Gfx* dlStack[18]; + /* 0x88 */ s32 dlDepth; + /* 0x8C */ u32 dlCnt; + /* 0x90 */ u32 vtxCnt; + /* 0x94 */ u32 spvtxCnt; + /* 0x98 */ u32 tri1Cnt; + /* 0x9C */ u32 tri2Cnt; + /* 0xA0 */ u32 quadCnt; + /* 0xA4 */ u32 lineCnt; + /* 0xA8 */ u32 loaducodeCnt; + /* 0xAC */ u32 pipeSyncRequired; + /* 0xB0 */ u32 tileSyncRequired; + /* 0xB4 */ u32 loadSyncRequired; + /* 0xB8 */ u32 syncErr; + /* 0xBC */ s32 enableLog; + /* 0xC0 */ s32 ucodeType; + /* 0xC4 */ s32 ucodeInfoCount; + /* 0xC8 */ UCodeInfo* ucodeInfo; + /* 0xCC */ u32 modeH; + /* 0xD0 */ u32 modeL; + /* 0xD4 */ u32 geometryMode; +} UCodeDisas; // size = 0xD8 + +void UCodeDisas_Init(UCodeDisas*); +void UCodeDisas_Destroy(UCodeDisas*); +void UCodeDisas_Disassemble(UCodeDisas*, Gfx*); +void UCodeDisas_RegisterUCode(UCodeDisas*, s32, UCodeInfo*); +void UCodeDisas_SetCurUCode(UCodeDisas*, void*); + +#endif diff --git a/src/boot/z_std_dma.c b/src/boot/z_std_dma.c index a04a4b95c9..07ce265359 100644 --- a/src/boot/z_std_dma.c +++ b/src/boot/z_std_dma.c @@ -27,7 +27,7 @@ #endif #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.2:102" + "ntsc-1.2:108" StackEntry sDmaMgrStackInfo; OSMesgQueue sDmaMgrMsgQueue; diff --git a/src/code/graph.c b/src/code/graph.c index 95affaf823..5aadf9cc80 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -1,6 +1,7 @@ #include "global.h" #include "fault.h" #include "terminal.h" +#include "ucode_disas.h" #define GFXPOOL_HEAD_MAGIC 0x1234 #define GFXPOOL_TAIL_MAGIC 0x5678 @@ -22,15 +23,15 @@ OSTime sGraphPrevTaskTimeStart; FaultClient sGraphFaultClient; UCodeInfo D_8012D230[3] = { - { UCODE_F3DZEX, gspF3DZEX2_NoN_PosLight_fifoTextStart }, - { UCODE_UNK, NULL }, - { UCODE_S2DEX, gspS2DEX2d_fifoTextStart }, + { UCODE_TYPE_F3DZEX, gspF3DZEX2_NoN_PosLight_fifoTextStart }, + { UCODE_TYPE_UNK, NULL }, + { UCODE_TYPE_S2DEX, gspS2DEX2d_fifoTextStart }, }; UCodeInfo D_8012D248[3] = { - { UCODE_F3DZEX, gspF3DZEX2_NoN_PosLight_fifoTextStart }, - { UCODE_UNK, NULL }, - { UCODE_S2DEX, gspS2DEX2d_fifoTextStart }, + { UCODE_TYPE_F3DZEX, gspF3DZEX2_NoN_PosLight_fifoTextStart }, + { UCODE_TYPE_UNK, NULL }, + { UCODE_TYPE_S2DEX, gspS2DEX2d_fifoTextStart }, }; void Graph_FaultClient(void) { diff --git a/src/code/main.c b/src/code/main.c index 456f03f5d0..010fd9050c 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -23,7 +23,7 @@ extern struct IrqMgr gIrqMgr; #endif #pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \ - "ntsc-1.2:160" + "ntsc-1.2:166" extern u8 _buffersSegmentEnd[]; diff --git a/src/code/ucode_disas.c b/src/code/ucode_disas.c index c0bab3f994..e2e782e71b 100644 --- a/src/code/ucode_disas.c +++ b/src/code/ucode_disas.c @@ -1,4 +1,5 @@ #include "global.h" +#include "ucode_disas.h" typedef struct F3dzexConst { /* 0x00 */ u32 value; @@ -223,7 +224,7 @@ void UCodeDisas_SetCurUCodeImpl(UCodeDisas* this, void* ptr) { } if (i >= this->ucodeInfoCount) { DISAS_LOG(T("マイクロコードが一致しなかった\n", "Microcode did not match\n")); - this->ucodeType = UCODE_NULL; + this->ucodeType = UCODE_TYPE_NULL; } } @@ -800,8 +801,8 @@ void UCodeDisas_Disassemble(UCodeDisas* this, Gfx* ptr) { default: { switch (this->ucodeType) { - case UCODE_F3DZEX: - case UCODE_UNK: { + case UCODE_TYPE_F3DZEX: + case UCODE_TYPE_UNK: { switch (cmd) { case G_MTX: { Gdma2 gmtx = ptr->dma2; @@ -1098,7 +1099,7 @@ void UCodeDisas_Disassemble(UCodeDisas* this, Gfx* ptr) { } } break; - case UCODE_S2DEX: { + case UCODE_TYPE_S2DEX: { switch (cmd) { case G_BG_COPY: { Gwords words = ptr->words; diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 3bebeecd5e..dcc2a0df33 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -1,7 +1,7 @@ #include "global.h" #include "terminal.h" -#pragma increment_block_number "ntsc-1.2:148" +#pragma increment_block_number "ntsc-1.2:152" u16 DynaSSNodeList_GetNextNodeIdx(DynaSSNodeList* nodeList); void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* sector); diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 58a4cf900d..7464b6ffd3 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -3638,7 +3638,7 @@ s32 Camera_KeepOn3(Camera* camera) { } #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.2:104" + "ntsc-1.2:110" s32 Camera_KeepOn4(Camera* camera) { static Vec3f D_8015BD50; diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index 27629dd829..1f6bb36cd2 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -5,7 +5,7 @@ #include "overlays/effects/ovl_Effect_Ss_HitMark/z_eff_ss_hitmark.h" -#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.2:216" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.2:224" typedef s32 (*ColChkResetFunc)(PlayState*, Collider*); typedef void (*ColChkApplyFunc)(PlayState*, CollisionCheckContext*, Collider*); diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index dcd0ee4d2e..1c70bfb0f4 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -3,7 +3,7 @@ #include "versions.h" #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ntsc-1.2:192" + "ntsc-1.2:224" ALIGNED(16) SaveContext gSaveContext; u32 D_8015FA88; diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 13b07c761f..402840aca1 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -7,7 +7,7 @@ #include "assets/objects/gameplay_keep/gameplay_keep.h" #include "assets/objects/gameplay_field_keep/gameplay_field_keep.h" -#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.2:0" +#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.2:0" typedef enum LightningBoltState { /* 0x00 */ LIGHTNING_BOLT_START, @@ -212,7 +212,7 @@ s16 sLightningFlashAlpha; s16 sSunDepthTestX; s16 sSunDepthTestY; -#pragma increment_block_number "gc-eu:240 gc-eu-mq:240 gc-jp:216 gc-jp-ce:216 gc-jp-mq:216 gc-us:216 gc-us-mq:216" \ +#pragma increment_block_number "gc-eu:112 gc-eu-mq:112 gc-jp:216 gc-jp-ce:216 gc-jp-mq:216 gc-us:216 gc-us-mq:216" \ "ntsc-1.2:224" LightNode* sNGameOverLightNode; diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.c index 3860420ff4..1fe68463ff 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -16,7 +16,7 @@ #include "cic6105.h" #endif -#pragma increment_block_number "gc-eu:125 gc-eu-mq:125 gc-jp:127 gc-jp-ce:127 gc-jp-mq:127 gc-us:127 gc-us-mq:127" +#pragma increment_block_number "gc-eu:131 gc-eu-mq:131 gc-jp:133 gc-jp-ce:133 gc-jp-mq:133 gc-us:133 gc-us-mq:133" #define FLAGS ACTOR_FLAG_4