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

Run format.sh

This commit is contained in:
Random 2020-04-04 18:38:05 +02:00
parent f818fb5299
commit fed29c029c
3 changed files with 90 additions and 131 deletions

View file

@ -1360,14 +1360,12 @@ typedef struct {
/* 0x20 */ f32 unk_20; /* 0x20 */ f32 unk_20;
} UnkQuakeCalcStruct; // size = 0x24 } UnkQuakeCalcStruct; // size = 0x24
typedef struct typedef struct {
{
/* 0x00 */ u32 idx; /* 0x00 */ u32 idx;
/* 0x04 */ void* ptr; /* 0x04 */ void* ptr;
} UcodeInfo; // size = 0x8 } UcodeInfo; // size = 0x8
typedef struct typedef struct {
{
/* 0x00 */ u32 segments[NUM_SEGMENTS]; /* 0x00 */ u32 segments[NUM_SEGMENTS];
/* 0x40 */ u32 dl_stack[18]; /* 0x40 */ u32 dl_stack[18];
/* 0x88 */ u32 dl_depth; /* 0x88 */ u32 dl_depth;
@ -1392,8 +1390,7 @@ typedef struct
/* 0xD4 */ u32 geometryMode; /* 0xD4 */ u32 geometryMode;
} UcodeDisas; // size = 0xD8 } UcodeDisas; // size = 0xD8
typedef struct typedef struct {
{
/* 0x00 */ u16* fb1; /* 0x00 */ u16* fb1;
/* 0x04 */ u16* swapbuffer; /* 0x04 */ u16* swapbuffer;
/* 0x08 */ OSViMode* viMode; /* 0x08 */ OSViMode* viMode;

View file

@ -14,45 +14,37 @@ CfbInfo sGraphCfbInfos[3];
FaultClient sGraphUcodeFaultClient; FaultClient sGraphUcodeFaultClient;
UcodeInfo D_8012D230[3] = { UcodeInfo D_8012D230[3] = {
{ 1, D_80155F50 }, { 1, D_80155F50 }, { 2, NULL }, { 3, D_801120C0 + 0xFB0 }, // D_80113070
{ 2, NULL },
{ 3, D_801120C0+0xFB0 }, // D_80113070
}; };
UcodeInfo D_8012D248[3] = { UcodeInfo D_8012D248[3] = {
{ 1, D_80155F50 }, { 1, D_80155F50 }, { 2, NULL }, { 3, D_801120C0 + 0xFB0 }, // D_80113070
{ 2, NULL },
{ 3, D_801120C0+0xFB0 }, // D_80113070
}; };
void Graph_FaultClient() void Graph_FaultClient() {
{
void* nextFb; void* nextFb;
void* newFb; void* newFb;
nextFb = osViGetNextFramebuffer(); nextFb = osViGetNextFramebuffer();
newFb = ((u32)SysCfb_GetFbPtr(0) != (u32)nextFb) newFb = ((u32)SysCfb_GetFbPtr(0) != (u32)nextFb) ? SysCfb_GetFbPtr(0) : SysCfb_GetFbPtr(1);
? SysCfb_GetFbPtr(0)
: SysCfb_GetFbPtr(1);
osViSwapBuffer(newFb); osViSwapBuffer(newFb);
Fault_WaitForInput(); Fault_WaitForInput();
osViSwapBuffer(nextFb); osViSwapBuffer(nextFb);
} }
void Graph_DisassembleUCode(void* arg0) void Graph_DisassembleUCode(void* arg0) {
{
UcodeDisas disassembler; UcodeDisas disassembler;
if (HREG(80) == 7 && HREG(81) != 0) if (HREG(80) == 7 && HREG(81) != 0) {
{
func_800D7F5C(&disassembler); func_800D7F5C(&disassembler);
disassembler.enableLog = HREG(83); disassembler.enableLog = HREG(83);
func_800DAC80(&disassembler, 3, D_8012D230); func_800DAC80(&disassembler, 3, D_8012D230);
func_800DAC90(&disassembler, D_80155F50); func_800DAC90(&disassembler, D_80155F50);
func_800D8400(&disassembler, arg0); func_800D8400(&disassembler, arg0);
HREG(93) = disassembler.dl_cnt; HREG(93) = disassembler.dl_cnt;
HREG(84) = disassembler.tri2_cnt * 2 + disassembler.tri1_cnt + (disassembler.quad_cnt * 2) + disassembler.line_cnt; HREG(84) =
disassembler.tri2_cnt * 2 + disassembler.tri1_cnt + (disassembler.quad_cnt * 2) + disassembler.line_cnt;
HREG(85) = disassembler.vtx_cnt; HREG(85) = disassembler.vtx_cnt;
HREG(86) = disassembler.spvtx_cnt; HREG(86) = disassembler.spvtx_cnt;
HREG(87) = disassembler.tri1_cnt; HREG(87) = disassembler.tri1_cnt;
@ -61,8 +53,7 @@ void Graph_DisassembleUCode(void* arg0)
HREG(90) = disassembler.line_cnt; HREG(90) = disassembler.line_cnt;
HREG(91) = disassembler.sync_err; HREG(91) = disassembler.sync_err;
HREG(92) = disassembler.loaducode_cnt; HREG(92) = disassembler.loaducode_cnt;
if (HREG(82) == 1 || HREG(82) == 2) if (HREG(82) == 1 || HREG(82) == 2) {
{
osSyncPrintf("vtx_cnt=%d\n", disassembler.vtx_cnt); osSyncPrintf("vtx_cnt=%d\n", disassembler.vtx_cnt);
osSyncPrintf("spvtx_cnt=%d\n", disassembler.spvtx_cnt); osSyncPrintf("spvtx_cnt=%d\n", disassembler.spvtx_cnt);
osSyncPrintf("tri1_cnt=%d\n", disassembler.tri1_cnt); osSyncPrintf("tri1_cnt=%d\n", disassembler.tri1_cnt);
@ -78,8 +69,7 @@ void Graph_DisassembleUCode(void* arg0)
} }
} }
void Graph_UCodeFaultClient(void* arg0) void Graph_UCodeFaultClient(void* arg0) {
{
UcodeDisas disassembler; UcodeDisas disassembler;
func_800D7F5C(&disassembler); func_800D7F5C(&disassembler);
@ -90,8 +80,7 @@ void Graph_UCodeFaultClient(void* arg0)
func_800D7FC4(&disassembler); func_800D7FC4(&disassembler);
} }
void* Graph_InitTHGA(GraphicsContext* gfxCtx) void* Graph_InitTHGA(GraphicsContext* gfxCtx) {
{
GfxPool* pool; GfxPool* pool;
pool = &gGfxPools[gfxCtx->gfxPoolIdx & 1]; pool = &gGfxPools[gfxCtx->gfxPoolIdx & 1];
@ -112,8 +101,7 @@ void* Graph_InitTHGA(GraphicsContext* gfxCtx)
gfxCtx->unk_014 = 0; gfxCtx->unk_014 = 0;
} }
GameStateOverlay* Graph_GetNextGameState() GameStateOverlay* Graph_GetNextGameState() {
{
void* game_init_func; void* game_init_func;
game_init_func = func_800C546C(); game_init_func = func_800C546C();
@ -136,12 +124,12 @@ GameStateOverlay* Graph_GetNextGameState()
return &gGameStateOverlayTable[5]; return &gGameStateOverlayTable[5];
} }
LogUtils_LogThreadId("../graph.c", 696); osSyncPrintf("game_init_func = %08x\n", game_init_func); LogUtils_LogThreadId("../graph.c", 696);
osSyncPrintf("game_init_func = %08x\n", game_init_func);
return NULL; return NULL;
} }
void Graph_Ct(GraphicsContext* gfxCtx) void Graph_Ct(GraphicsContext* gfxCtx) {
{
bzero(gfxCtx, sizeof(GraphicsContext)); bzero(gfxCtx, sizeof(GraphicsContext));
gfxCtx->gfxPoolIdx = 0; gfxCtx->gfxPoolIdx = 0;
gfxCtx->fbIdx = 0; gfxCtx->fbIdx = 0;
@ -154,16 +142,14 @@ void Graph_Ct(GraphicsContext* gfxCtx)
Fault_AddClient(&sGraphFaultClient, Graph_FaultClient, 0, 0); Fault_AddClient(&sGraphFaultClient, Graph_FaultClient, 0, 0);
} }
void Graph_Dt(GraphicsContext* gfxCtx) void Graph_Dt(GraphicsContext* gfxCtx) {
{
func_800D3210(); func_800D3210();
Fault_RemoveClient(&sGraphFaultClient); Fault_RemoveClient(&sGraphFaultClient);
} }
// Close to matching, reordering at the end // Close to matching, reordering at the end
#ifdef NON_MATCHING #ifdef NON_MATCHING
void Graph_TaskSet00(GraphicsContext* gfxCtx) void Graph_TaskSet00(GraphicsContext* gfxCtx) {
{
static u32 D_8012D260 = 0; static u32 D_8012D260 = 0;
static s32 sGraphCfbInfoIdx = 0; static s32 sGraphCfbInfoIdx = 0;
@ -187,8 +173,7 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx)
osRecvMesg(mq, &msg, OS_MESG_BLOCK); osRecvMesg(mq, &msg, OS_MESG_BLOCK);
osStopTimer(&timer); osStopTimer(&timer);
if (msg == (OSMesg)666) if (msg == (OSMesg)666) {
{
osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf(VT_FGCOL(RED));
osSyncPrintf("RCPが帰ってきませんでした。"); // "RCP did not return." osSyncPrintf("RCPが帰ってきませんでした。"); // "RCP did not return."
osSyncPrintf(VT_RST); osSyncPrintf(VT_RST);
@ -197,8 +182,7 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx)
LogUtils_LogHexDump(gGfxSPTaskYieldBuffer, sizeof(gGfxSPTaskYieldBuffer)); LogUtils_LogHexDump(gGfxSPTaskYieldBuffer, sizeof(gGfxSPTaskYieldBuffer));
SREG(6) = -1; SREG(6) = -1;
if (D_8012D260) if (D_8012D260) {
{
temp = D_8012D260; temp = D_8012D260;
HREG(80) = 7; HREG(80) = 7;
HREG(81) = 1; HREG(81) = 1;
@ -210,12 +194,12 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx)
} }
osRecvMesg(mq, &msg, OS_MESG_NOBLOCK); osRecvMesg(mq, &msg, OS_MESG_NOBLOCK);
D_8012D260 = gfxCtx->workBuffer; D_8012D260 = gfxCtx->workBuffer;
if (gfxCtx->callback) if (gfxCtx->callback) {
gfxCtx->callback(gfxCtx, gfxCtx->callbackParam); gfxCtx->callback(gfxCtx, gfxCtx->callbackParam);
}
time = osGetTime(); time = osGetTime();
if (D_8016A550) if (D_8016A550) {
{
D_8016A558 = (D_8016A558 + time) - D_8016A550; D_8016A558 = (D_8016A558 + time) - D_8016A550;
D_8016A550 = time; D_8016A550 = time;
} }
@ -246,8 +230,7 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx)
scTask->next = NULL; scTask->next = NULL;
scTask->flags = OS_SC_RCP_MASK | OS_SC_SWAPBUFFER | OS_SC_LAST_TASK; scTask->flags = OS_SC_RCP_MASK | OS_SC_SWAPBUFFER | OS_SC_LAST_TASK;
if (SREG(33) & 1) if (SREG(33) & 1) {
{
SREG(33) &= ~1; SREG(33) &= ~1;
scTask->flags &= ~OS_SC_SWAPBUFFER; scTask->flags &= ~OS_SC_SWAPBUFFER;
gfxCtx->fbIdx--; gfxCtx->fbIdx--;
@ -281,8 +264,7 @@ u32 sGraphCfbInfoIdx = 0;
// Very close to matching, stack usage // Very close to matching, stack usage
#ifdef NON_MATCHING #ifdef NON_MATCHING
void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
{
u32 problem; // 0xC4 -> 0xD4 u32 problem; // 0xC4 -> 0xD4
Gfx* gfxArr[5]; // 0xB0 -> 0xC0 Gfx* gfxArr[5]; // 0xB0 -> 0xC0
Gfx* gfxArr2[9]; // 0x8C -> 0x9C Gfx* gfxArr2[9]; // 0x8C -> 0x9C
@ -401,7 +383,8 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState)
} }
sGraph_UpdateTime = time; sGraph_UpdateTime = time;
if (D_8012DBC0 && (!~(gameState->input[0].padPressed | ~Z_TRIG)) && (!~(gameState->input[0].raw.pad | ~(L_TRIG | R_TRIG)))) { if (D_8012DBC0 && (!~(gameState->input[0].padPressed | ~Z_TRIG)) &&
(!~(gameState->input[0].raw.pad | ~(L_TRIG | R_TRIG)))) {
gSaveContext.game_mode = 0; gSaveContext.game_mode = 0;
SET_NEXT_GAMESTATE(gameState, func_80801E44, char[0x240]); // TODO : SelectContext SET_NEXT_GAMESTATE(gameState, func_80801E44, char[0x240]); // TODO : SelectContext
gameState->running = false; gameState->running = false;
@ -418,8 +401,7 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState)
#pragma GLOBAL_ASM("asm/non_matchings/code/graph/Graph_Update.s") #pragma GLOBAL_ASM("asm/non_matchings/code/graph/Graph_Update.s")
#endif #endif
void Graph_ThreadEntry(void* arg0) void Graph_ThreadEntry(void* arg0) {
{
GraphicsContext gfxCtx; GraphicsContext gfxCtx;
GameState* gameState; GameState* gameState;
u32 size; u32 size;
@ -433,8 +415,7 @@ void Graph_ThreadEntry(void* arg0)
osSyncPrintf("グラフィックスレッド実行開始\n"); osSyncPrintf("グラフィックスレッド実行開始\n");
Graph_Ct(&gfxCtx); Graph_Ct(&gfxCtx);
while(nextOvl) while (nextOvl) {
{
ovl = nextOvl; ovl = nextOvl;
Overlay_LoadGameState(ovl); Overlay_LoadGameState(ovl);
@ -444,8 +425,7 @@ void Graph_ThreadEntry(void* arg0)
gameState = SystemArena_MallocDebug(size, "../graph.c", 1196); gameState = SystemArena_MallocDebug(size, "../graph.c", 1196);
if (!gameState) if (!gameState) {
{
// Failure to secure // Failure to secure
osSyncPrintf("確保失敗\n"); osSyncPrintf("確保失敗\n");
@ -463,42 +443,34 @@ void Graph_ThreadEntry(void* arg0)
func_800C5360(gameState); // Game_Dt func_800C5360(gameState); // Game_Dt
SystemArena_FreeDebug(gameState, "../graph.c", 1227); SystemArena_FreeDebug(gameState, "../graph.c", 1227);
Overlay_FreeGameState(ovl); Overlay_FreeGameState(ovl);
} }
Graph_Dt(&gfxCtx); Graph_Dt(&gfxCtx);
// End of graphic thread execution // End of graphic thread execution
osSyncPrintf("グラフィックスレッド実行終了\n"); osSyncPrintf("グラフィックスレッド実行終了\n");
} }
void* Graph_Alloc(GraphicsContext* gfxCtx, size_t size) void* Graph_Alloc(GraphicsContext* gfxCtx, size_t size) {
{
TwoHeadGfxArena* thga = &gfxCtx->polyOpa; TwoHeadGfxArena* thga = &gfxCtx->polyOpa;
if (HREG(59) == 1) if (HREG(59) == 1) {
{ osSyncPrintf("graph_alloc siz=%d thga size=%08x bufp=%08x head=%08x tail=%08x\n", size, thga->size, thga->bufp,
osSyncPrintf("graph_alloc siz=%d thga size=%08x bufp=%08x head=%08x tail=%08x\n", size, thga->size, thga->p, thga->d);
thga->bufp, thga->p, thga->d);
} }
return THGA_AllocEnd(&gfxCtx->polyOpa, ALIGN16(size)); return THGA_AllocEnd(&gfxCtx->polyOpa, ALIGN16(size));
} }
void* Graph_Alloc2(GraphicsContext* gfxCtx, size_t size) void* Graph_Alloc2(GraphicsContext* gfxCtx, size_t size) {
{
TwoHeadGfxArena* thga = &gfxCtx->polyOpa; TwoHeadGfxArena* thga = &gfxCtx->polyOpa;
if (HREG(59) == 1) if (HREG(59) == 1) {
{ osSyncPrintf("graph_alloc siz=%d thga size=%08x bufp=%08x head=%08x tail=%08x\n", size, thga->size, thga->bufp,
osSyncPrintf("graph_alloc siz=%d thga size=%08x bufp=%08x head=%08x tail=%08x\n", size, thga->size, thga->p, thga->d);
thga->bufp, thga->p, thga->d);
} }
return THGA_AllocEnd(&gfxCtx->polyOpa, ALIGN16(size)); return THGA_AllocEnd(&gfxCtx->polyOpa, ALIGN16(size));
} }
void Graph_OpenDisp(Gfx** gfxArr, GraphicsContext* gfxCtx, const char* file, s32 line) void Graph_OpenDisp(Gfx** gfxArr, GraphicsContext* gfxCtx, const char* file, s32 line) {
{ if (HREG(80) == 7 && HREG(82) != 4) {
if (HREG(80) == 7 && HREG(82) != 4)
{
gfxArr[0] = gfxCtx->polyOpa.p; gfxArr[0] = gfxCtx->polyOpa.p;
gfxArr[1] = gfxCtx->polyXlu.p; gfxArr[1] = gfxCtx->polyXlu.p;
gfxArr[2] = gfxCtx->overlay.p; gfxArr[2] = gfxCtx->overlay.p;
@ -509,40 +481,38 @@ void Graph_OpenDisp(Gfx** gfxArr, GraphicsContext* gfxCtx, const char* file, s32
} }
} }
void Graph_CloseDisp(Gfx** gfxArr, GraphicsContext* gfxCtx, const char* file, s32 line) void Graph_CloseDisp(Gfx** gfxArr, GraphicsContext* gfxCtx, const char* file, s32 line) {
{ if (HREG(80) == 7 && HREG(82) != 4) {
if (HREG(80) == 7 && HREG(82) != 4) if (gfxArr[0] + 1 == gfxCtx->polyOpa.p) {
{
if (gfxArr[0] + 1 == gfxCtx->polyOpa.p)
gfxCtx->polyOpa.p = gfxArr[0]; gfxCtx->polyOpa.p = gfxArr[0];
else } else {
gDPNoOpCloseDisp(gfxCtx->polyOpa.p++, file, line); gDPNoOpCloseDisp(gfxCtx->polyOpa.p++, file, line);
}
if (gfxArr[1] + 1 == gfxCtx->polyXlu.p) if (gfxArr[1] + 1 == gfxCtx->polyXlu.p) {
gfxCtx->polyXlu.p = gfxArr[1]; gfxCtx->polyXlu.p = gfxArr[1];
else } else {
gDPNoOpCloseDisp(gfxCtx->polyXlu.p++, file, line); gDPNoOpCloseDisp(gfxCtx->polyXlu.p++, file, line);
}
if (gfxArr[2] + 1 == gfxCtx->overlay.p) if (gfxArr[2] + 1 == gfxCtx->overlay.p) {
gfxCtx->overlay.p = gfxArr[2]; gfxCtx->overlay.p = gfxArr[2];
else } else {
gDPNoOpCloseDisp(gfxCtx->overlay.p++, file, line); gDPNoOpCloseDisp(gfxCtx->overlay.p++, file, line);
} }
} }
}
Gfx* Graph_GfxPlusOne(Gfx* gfx) Gfx* Graph_GfxPlusOne(Gfx* gfx) {
{
return gfx + 1; return gfx + 1;
} }
Gfx* Graph_BranchDlist(Gfx* gfx, Gfx* dst) Gfx* Graph_BranchDlist(Gfx* gfx, Gfx* dst) {
{
gSPBranchList(gfx, dst); gSPBranchList(gfx, dst);
return dst; return dst;
} }
void* Graph_DlistAlloc(Gfx** gfx, u32 size) void* Graph_DlistAlloc(Gfx** gfx, u32 size) {
{
u8* ptr; u8* ptr;
Gfx* dst; Gfx* dst;

View file

@ -2,21 +2,13 @@
#define GAMESTATE_OVERLAY(name, init, destroy, size) \ #define GAMESTATE_OVERLAY(name, init, destroy, size) \
{ \ { \
NULL, \ NULL, (u32)_ovl_##name##SegmentRomStart, (u32)_ovl_##name##SegmentRomEnd, _ovl_##name##SegmentStart, \
(u32)_ovl_##name##SegmentRomStart, (u32)_ovl_##name##SegmentRomEnd, \ _ovl_##name##SegmentEnd, 0, init, destroy, 0, 0, 0, size \
_ovl_##name##SegmentStart, _ovl_##name##SegmentEnd, \
0, init, destroy, 0, 0, 0, size \
} }
#define GAMESTATE_OVERLAY_INTERNAL(init, destroy, size) \ #define GAMESTATE_OVERLAY_INTERNAL(init, destroy, size) \
{ \ { NULL, 0, 0, NULL, NULL, 0, init, destroy, 0, 0, 0, size }
NULL, \
0, 0, \
NULL, NULL, \
0, init, destroy, 0, 0, 0, size \
}
GameStateOverlay gGameStateOverlayTable[] = GameStateOverlay gGameStateOverlayTable[] = {
{
GAMESTATE_OVERLAY_INTERNAL(TitleSetup_Init, TitleSetup_Destroy, sizeof(GameState)), GAMESTATE_OVERLAY_INTERNAL(TitleSetup_Init, TitleSetup_Destroy, sizeof(GameState)),
GAMESTATE_OVERLAY(select, func_80801E44, func_80801E0C, 0x240), // TODO : sizeof(SelectContext) GAMESTATE_OVERLAY(select, func_80801E44, func_80801E0C, 0x240), // TODO : sizeof(SelectContext)
GAMESTATE_OVERLAY(title, Title_Init, Title_Destroy, sizeof(TitleContext)), GAMESTATE_OVERLAY(title, Title_Init, Title_Destroy, sizeof(TitleContext)),