diff options
| -rw-r--r-- | include/cfbinfo.h | 25 | ||||
| -rw-r--r-- | include/code_variables.h | 2 | ||||
| -rw-r--r-- | linker_scripts/jp/symbol_addrs_code.txt | 4 | ||||
| -rw-r--r-- | src/code/cfbinfo.c | 75 | ||||
| -rw-r--r-- | src/code/graph.c | 18 | ||||
| -rw-r--r-- | yamls/jp/code.yaml | 6 |
6 files changed, 102 insertions, 28 deletions
diff --git a/include/cfbinfo.h b/include/cfbinfo.h index b8241da..77bef96 100644 --- a/include/cfbinfo.h +++ b/include/cfbinfo.h @@ -4,21 +4,22 @@ #include "ultra64.h" #include "unk.h" -typedef struct cfbStruct { +typedef struct CfbInfo { /* 0x00 */ void* unk_00; - /* 0x04 */ UNK_PTR unk_04; - /* 0x08 */ UNK_TYPE1 unk_08[0x1]; - /* 0x09 */ u8 unk_09; + /* 0x04 */ UNK_PTR swapBuffer; + /* 0x08 */ u8 state; + /* 0x09 */ s8 unk_09; /* 0x0A */ u8 unk_0A; /* 0x0B */ s8 unk_0B; - /* 0x0C */ OSViMode* unk_0C; - /* 0x10 */ s32 unk_10; - /* 0x14 */ f32 unk_14; - /* 0x18 */ f32 unk_18; -} cfbStruct; // size >= 0x1C + /* 0x0C */ OSViMode* viMode; + /* 0x10 */ s32 viFeatures; + /* 0x14 */ f32 xScale; + /* 0x18 */ f32 yScale; +} CfbInfo; // size = 0x1C -cfbStruct* func_800D2C10_jp(void); -// void func_800D2CB4_jp(); -// void func_800D2CDC_jp(); + +CfbInfo* func_800D2C10_jp(void); +void func_800D2CB4_jp(CfbInfo* cfb); +void func_800D2CDC_jp(CfbInfo* cfb); #endif diff --git a/include/code_variables.h b/include/code_variables.h index e7d8a9f..42b5de2 100644 --- a/include/code_variables.h +++ b/include/code_variables.h @@ -1923,8 +1923,6 @@ extern u16 D_80000400[]; // extern UNK_TYPE B_80144D04_jp; // extern UNK_TYPE B_80144D0C_jp; // extern UNK_TYPE B_80144D14_jp; -// extern UNK_TYPE B_80144FC0_jp; -// extern UNK_TYPE B_80145014_jp; // extern UNK_TYPE B_80145390_jp; // extern UNK_TYPE B_80145610_jp; diff --git a/linker_scripts/jp/symbol_addrs_code.txt b/linker_scripts/jp/symbol_addrs_code.txt index 21b9ba8..d3f3609 100644 --- a/linker_scripts/jp/symbol_addrs_code.txt +++ b/linker_scripts/jp/symbol_addrs_code.txt @@ -5665,6 +5665,7 @@ jtbl_80117C50_jp = 0x80117C50; // type:jtbl RO_STR_80117C80_jp = 0x80117C80; // type:asciz RO_STR_80117CA0_jp = 0x80117CA0; // type:asciz RO_STR_80117CC0_jp = 0x80117CC0; // type:asciz +RO_STR_80117CD0_jp = 0x80117CD0; // type:asciz RO_80117CE0_jp = 0x80117CE0; // type:u16 RO_STR_80117D00_jp = 0x80117D00; // type:asciz RO_STR_80117D0C_jp = 0x80117D0C; // type:asciz @@ -6151,8 +6152,7 @@ B_80144E00_jp = 0x80144E00; // B_80144FB2_jp = 0x80144FB2; // type:s8 B_80144FB3_jp = 0x80144FB3; // type:s8 B_80144FB8_jp = 0x80144FB8; // -B_80144FC0_jp = 0x80144FC0; // type:u8 -B_80145014_jp = 0x80145014; // +B_80144FC0_jp = 0x80144FC0; // size:0x54 B_80145020_jp = 0x80145020; // B_80145040_jp = 0x80145040; // type:s16 game_class_p = 0x80145044; // diff --git a/src/code/cfbinfo.c b/src/code/cfbinfo.c new file mode 100644 index 0000000..e8851ce --- /dev/null +++ b/src/code/cfbinfo.c @@ -0,0 +1,75 @@ +#include "cfbinfo.h" + +#include "libc/stdbool.h" +#include "libc64/sleep.h" +#include "libu64/debug.h" + +#include "idle.h" +#include "irqmgr.h" +#include "macros.h" +#include "viconfig.h" +#include "6FD410.h" + +CfbInfo sCfbInfos[3]; + +CfbInfo* func_800D2C10_jp(void) { + s32 i; + CfbInfo* cfb; + s32 attempts = 0; + +retry: + i = 0; + while (true) { + cfb = &sCfbInfos[i]; + if (cfb->state == 0) { + break; + } + + i++; + if (i == ARRAY_COUNT(sCfbInfos)) { + if (attempts++ > 10000) { + _dbg_hungup("../cfbinfo.c", 0x27); + } + usleep(100); + (void)""; + goto retry; + } + } + bzero(cfb, sizeof(CfbInfo)); + cfb->state = 1; + + // (reservation) + (void)"(予約)"; + return cfb; +} + +void func_800D2CB4_jp(CfbInfo* cfb) { + if (cfb->unk_0B != 0) { + cfb->unk_0B = 0; + B_80146080_jp = 3; + } + cfb->state = 0; +} + +void func_800D2CDC_jp(CfbInfo* cfb) { + if ((ResetStatus < 2) && (cfb->swapBuffer != NULL)) { + osViSwapBuffer(cfb->swapBuffer); + cfb->unk_0A = cfb->unk_09; + cfb->state = 4; + if (cfb->viMode != NULL) { + gViConfigMode = *cfb->viMode; + gViConfigFeatures = cfb->viFeatures; + gViConfigXScale = cfb->xScale; + gViConfigYScale = cfb->yScale; + if (!gViConfigBlack) { + osViSetMode(cfb->viMode); + osViSetSpecialFeatures(cfb->viFeatures); + osViSetXScale(cfb->xScale); + osViSetYScale(cfb->yScale); + } + if (!gViConfigBlack) {} + } + } else { + func_800D2CB4_jp(cfb); + } +} diff --git a/src/code/graph.c b/src/code/graph.c index 1fe2a06..4c53048 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -264,23 +264,23 @@ void graph_task_set00(GraphicsContext* gfxCtx) { scTask->msg = NULL; { - cfbStruct* cfb = func_800D2C10_jp(); + CfbInfo* cfb = func_800D2C10_jp(); cfb->unk_00 = gfxCtx->unk_2E4; - cfb->unk_04 = NULL; + cfb->swapBuffer = NULL; cfb->unk_09 = game_GameFrame; - cfb->unk_0C = NULL; + cfb->viMode = NULL; if (scTask->flags & OS_SC_SWAPBUFFER) { - cfb->unk_04 = gfxCtx->unk_2E4; + cfb->swapBuffer = gfxCtx->unk_2E4; if (gfxCtx->unk_2F2 != 0) { gfxCtx->unk_2F2 = 0; - cfb->unk_0C = gfxCtx->unk_25C; - cfb->unk_10 = gfxCtx->unk_2EC; - cfb->unk_14 = gfxCtx->unk_2FC; - cfb->unk_18 = gfxCtx->unk_300; + cfb->viMode = gfxCtx->unk_25C; + cfb->viFeatures = gfxCtx->unk_2EC; + cfb->xScale = gfxCtx->unk_2FC; + cfb->yScale = gfxCtx->unk_300; } if (B_80146080_jp == 1) { - B_80146084_jp = cfb->unk_04; + B_80146084_jp = cfb->swapBuffer; cfb->unk_0B = 1; B_80146080_jp = 2; } diff --git a/yamls/jp/code.yaml b/yamls/jp/code.yaml index 1f7eceb..03939af 100644 --- a/yamls/jp/code.yaml +++ b/yamls/jp/code.yaml @@ -94,7 +94,7 @@ - [0x6F5390, c, code/TwoHeadArena] - [0x6F5550, c, code/audio] - [0x6F6230, c, code/audioMgr] - - [0x6F68B0, asm, code/cfbinfo] + - [0x6F68B0, c, code/cfbinfo] - [0x6F6AA0, c, code/game] - [0x6F73C0, c, code/gamealloc] - [0x6F7500, c, code/gfxalloc] @@ -271,7 +271,7 @@ - [0x73B880, .rodata, code/m_roll_lib] - [0x73B890, .rodata, code/audio] - [0x73B920, .rodata, code/audioMgr] - - [0x73B960, rodata, code/73B960] + - [0x73B960, .rodata, code/cfbinfo] - [0x73B980, .rodata, code/game] - [0x73B9C0, .rodata, code/graph] - [0x73BA50, .rodata, code/irqmgr] @@ -325,7 +325,7 @@ - { start: 0x73F4D0, type: .bss, vram: 0x80144670, name: code/m_submenu } - { start: 0x73F4D0, type: bss, vram: 0x80144690, name: code/80144690 } - { start: 0x73F4D0, type: .bss, vram: 0x80144D20, name: code/audioMgr } - - { start: 0x73F4D0, type: bss, vram: 0x80144FC0, name: code/80144FC0 } + - { start: 0x73F4D0, type: .bss, vram: 0x80144FC0, name: code/cfbinfo } - { start: 0x73F4D0, type: .bss, vram: 0x80145020, name: code/game } - { start: 0x73F4D0, type: bss, vram: 0x80145060, name: code/graph } - { start: 0x73F4D0, type: .bss, vram: 0x80145390, name: code/irqmgr } |
