mirror of
https://github.com/zeldaret/oot.git
synced 2024-11-25 09:45:02 +00:00
Gamealloc, Graph, and Graphalloc retail OK (#1675)
* Gamealloc OK * Graph + Graphalloc OK * PR review * gfxalloc * new lines * Remove imposter
This commit is contained in:
parent
a0d31dba68
commit
06379c3109
19 changed files with 202 additions and 158 deletions
|
@ -1318,16 +1318,12 @@ GameStateFunc GameState_GetInit(GameState* gameState);
|
|||
u32 GameState_IsRunning(GameState* gameState);
|
||||
#if OOT_DEBUG
|
||||
void* GameState_Alloc(GameState* gameState, size_t size, char* file, s32 line);
|
||||
#endif
|
||||
void func_800C55D0(GameAlloc* this);
|
||||
void* GameAlloc_MallocDebug(GameAlloc* this, u32 size, const char* file, s32 line);
|
||||
#endif
|
||||
void* GameAlloc_Malloc(GameAlloc* this, u32 size);
|
||||
void GameAlloc_Free(GameAlloc* this, void* data);
|
||||
void GameAlloc_Cleanup(GameAlloc* this);
|
||||
void GameAlloc_Init(GameAlloc* this);
|
||||
void Graph_FaultClient(void);
|
||||
void Graph_DisassembleUCode(Gfx* workBuf);
|
||||
void Graph_UCodeFaultClient(Gfx* workBuf);
|
||||
void Graph_InitTHGA(GraphicsContext* gfxCtx);
|
||||
GameStateOverlay* Graph_GetNextGameState(GameState* gameState);
|
||||
void Graph_Init(GraphicsContext* gfxCtx);
|
||||
|
@ -1337,11 +1333,13 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState);
|
|||
void Graph_ThreadEntry(void*);
|
||||
void* Graph_Alloc(GraphicsContext* gfxCtx, size_t size);
|
||||
void* Graph_Alloc2(GraphicsContext* gfxCtx, size_t size);
|
||||
#if OOT_DEBUG
|
||||
void Graph_OpenDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, s32 line);
|
||||
void Graph_CloseDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, s32 line);
|
||||
Gfx* Graph_GfxPlusOne(Gfx* gfx);
|
||||
Gfx* Graph_BranchDlist(Gfx* gfx, Gfx* dst);
|
||||
void* Graph_DlistAlloc(Gfx** gfxP, u32 size);
|
||||
#endif
|
||||
Gfx* Gfx_Open(Gfx* gfx);
|
||||
Gfx* Gfx_Close(Gfx* gfx, Gfx* dst);
|
||||
void* Gfx_Alloc(Gfx** gfxP, u32 size);
|
||||
ListAlloc* ListAlloc_Init(ListAlloc* this);
|
||||
void* ListAlloc_Alloc(ListAlloc* this, u32 size);
|
||||
void ListAlloc_Free(ListAlloc* this, void* data);
|
||||
|
|
1
spec
1
spec
|
@ -400,6 +400,7 @@ beginseg
|
|||
include "$(BUILD_DIR)/src/code/game.o"
|
||||
include "$(BUILD_DIR)/src/code/gamealloc.o"
|
||||
include "$(BUILD_DIR)/src/code/graph.o"
|
||||
include "$(BUILD_DIR)/src/code/gfxalloc.o"
|
||||
include "$(BUILD_DIR)/src/code/listalloc.o"
|
||||
include "$(BUILD_DIR)/src/code/main.o"
|
||||
include "$(BUILD_DIR)/src/code/padmgr.o"
|
||||
|
|
|
@ -78,7 +78,7 @@ void FlagSet_Update(PlayState* play) {
|
|||
s32 pad;
|
||||
|
||||
polyOpa = POLY_OPA_DISP;
|
||||
gfx = Graph_GfxPlusOne(polyOpa);
|
||||
gfx = Gfx_Open(polyOpa);
|
||||
gSPDisplayList(OVERLAY_DISP++, gfx);
|
||||
|
||||
GfxPrint_Init(&printer);
|
||||
|
@ -171,7 +171,7 @@ void FlagSet_Update(PlayState* play) {
|
|||
GfxPrint_Destroy(&printer);
|
||||
|
||||
gSPEndDisplayList(gfx++);
|
||||
Graph_BranchDlist(polyOpa, gfx);
|
||||
Gfx_Close(polyOpa, gfx);
|
||||
POLY_OPA_DISP = gfx;
|
||||
}
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) {
|
|||
|
||||
OPEN_DISPS(gfxCtx, "../game.c", 746);
|
||||
|
||||
newDList = Graph_GfxPlusOne(polyOpaP = POLY_OPA_DISP);
|
||||
newDList = Gfx_Open(polyOpaP = POLY_OPA_DISP);
|
||||
gSPDisplayList(OVERLAY_DISP++, newDList);
|
||||
|
||||
if (R_ENABLE_FB_FILTER == 1) {
|
||||
|
@ -193,7 +193,7 @@ void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) {
|
|||
}
|
||||
|
||||
gSPEndDisplayList(newDList++);
|
||||
Graph_BranchDlist(polyOpaP, newDList);
|
||||
Gfx_Close(polyOpaP, newDList);
|
||||
POLY_OPA_DISP = newDList;
|
||||
|
||||
if (1) {}
|
||||
|
@ -230,11 +230,11 @@ void func_800C49F4(GraphicsContext* gfxCtx) {
|
|||
|
||||
OPEN_DISPS(gfxCtx, "../game.c", 846);
|
||||
|
||||
newDlist = Graph_GfxPlusOne(polyOpaP = POLY_OPA_DISP);
|
||||
newDlist = Gfx_Open(polyOpaP = POLY_OPA_DISP);
|
||||
gSPDisplayList(OVERLAY_DISP++, newDlist);
|
||||
|
||||
gSPEndDisplayList(newDlist++);
|
||||
Graph_BranchDlist(polyOpaP, newDlist);
|
||||
Gfx_Close(polyOpaP, newDlist);
|
||||
POLY_OPA_DISP = newDlist;
|
||||
|
||||
if (1) {}
|
||||
|
|
|
@ -12,6 +12,7 @@ void GameAlloc_Log(GameAlloc* this) {
|
|||
}
|
||||
}
|
||||
|
||||
#if OOT_DEBUG
|
||||
void* GameAlloc_MallocDebug(GameAlloc* this, u32 size, const char* file, s32 line) {
|
||||
GameAllocEntry* ptr = SystemArena_MallocDebug(size + sizeof(GameAllocEntry), file, line);
|
||||
|
||||
|
@ -27,6 +28,7 @@ void* GameAlloc_MallocDebug(GameAlloc* this, u32 size, const char* file, s32 lin
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void* GameAlloc_Malloc(GameAlloc* this, u32 size) {
|
||||
GameAllocEntry* ptr = SYSTEM_ARENA_MALLOC(size + sizeof(GameAllocEntry), "../gamealloc.c", 93);
|
||||
|
|
25
src/code/gfxalloc.c
Normal file
25
src/code/gfxalloc.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include "global.h"
|
||||
|
||||
Gfx* Gfx_Open(Gfx* gfx) {
|
||||
return gfx + 1;
|
||||
}
|
||||
|
||||
Gfx* Gfx_Close(Gfx* gfx, Gfx* dst) {
|
||||
gSPBranchList(gfx, dst);
|
||||
return dst;
|
||||
}
|
||||
|
||||
void* Gfx_Alloc(Gfx** gfxP, u32 size) {
|
||||
u8* ptr;
|
||||
Gfx* dst;
|
||||
|
||||
size = ALIGN8(size);
|
||||
|
||||
ptr = (u8*)(*gfxP + 1);
|
||||
|
||||
dst = (Gfx*)(ptr + size);
|
||||
gSPBranchList(*gfxP, dst);
|
||||
|
||||
*gfxP = dst;
|
||||
return ptr;
|
||||
}
|
257
src/code/graph.c
257
src/code/graph.c
|
@ -30,6 +30,7 @@ UCodeInfo D_8012D248[3] = {
|
|||
{ UCODE_S2DEX, gspS2DEX2d_fifoTextStart },
|
||||
};
|
||||
|
||||
#if OOT_DEBUG
|
||||
void Graph_FaultClient(void) {
|
||||
void* nextFb = osViGetNextFramebuffer();
|
||||
void* newFb = (SysCfb_GetFbPtr(0) != nextFb) ? SysCfb_GetFbPtr(0) : SysCfb_GetFbPtr(1);
|
||||
|
@ -93,6 +94,7 @@ void Graph_UCodeFaultClient(Gfx* workBuf) {
|
|||
UCodeDisas_Disassemble(&disassembler, workBuf);
|
||||
UCodeDisas_Destroy(&disassembler);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Graph_InitTHGA(GraphicsContext* gfxCtx) {
|
||||
GfxPool* pool = &gGfxPools[gfxCtx->gfxPoolIdx & 1];
|
||||
|
@ -139,13 +141,17 @@ void Graph_Init(GraphicsContext* gfxCtx) {
|
|||
gfxCtx->xScale = gViConfigXScale;
|
||||
gfxCtx->yScale = gViConfigYScale;
|
||||
osCreateMesgQueue(&gfxCtx->queue, gfxCtx->msgBuff, ARRAY_COUNT(gfxCtx->msgBuff));
|
||||
#if OOT_DEBUG
|
||||
func_800D31F0();
|
||||
Fault_AddClient(&sGraphFaultClient, Graph_FaultClient, NULL, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Graph_Destroy(GraphicsContext* gfxCtx) {
|
||||
#if OOT_DEBUG
|
||||
func_800D3210();
|
||||
Fault_RemoveClient(&sGraphFaultClient);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Graph_TaskSet00(GraphicsContext* gfxCtx) {
|
||||
|
@ -157,109 +163,122 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx) {
|
|||
OSMesg msg;
|
||||
OSTask_t* task = &gfxCtx->task.list.t;
|
||||
OSScTask* scTask = &gfxCtx->task;
|
||||
CfbInfo* cfb;
|
||||
|
||||
gGfxTaskSentToNextReadyMinusAudioThreadUpdateTime =
|
||||
osGetTime() - sGraphPrevTaskTimeStart - gAudioThreadUpdateTimeAcc;
|
||||
|
||||
osSetTimer(&timer, OS_USEC_TO_CYCLES(3000000), 0, &gfxCtx->queue, (OSMesg)666);
|
||||
{
|
||||
CfbInfo* cfb;
|
||||
|
||||
osRecvMesg(&gfxCtx->queue, &msg, OS_MESG_BLOCK);
|
||||
osStopTimer(&timer);
|
||||
osSetTimer(&timer, OS_USEC_TO_CYCLES(3000000), 0, &gfxCtx->queue, (OSMesg)666);
|
||||
|
||||
if (msg == (OSMesg)666) {
|
||||
PRINTF(VT_FGCOL(RED));
|
||||
PRINTF("RCPが帰ってきませんでした。"); // "RCP did not return."
|
||||
PRINTF(VT_RST);
|
||||
osRecvMesg(&gfxCtx->queue, &msg, OS_MESG_BLOCK);
|
||||
osStopTimer(&timer);
|
||||
|
||||
LogUtils_LogHexDump((void*)PHYS_TO_K1(SP_BASE_REG), 0x20);
|
||||
LogUtils_LogHexDump((void*)PHYS_TO_K1(DPC_BASE_REG), 0x20);
|
||||
LogUtils_LogHexDump(gGfxSPTaskYieldBuffer, sizeof(gGfxSPTaskYieldBuffer));
|
||||
if (msg == (OSMesg)666) {
|
||||
#if OOT_DEBUG
|
||||
PRINTF(VT_FGCOL(RED));
|
||||
PRINTF("RCPが帰ってきませんでした。"); // "RCP did not return."
|
||||
PRINTF(VT_RST);
|
||||
|
||||
SREG(6) = -1;
|
||||
if (sPrevTaskWorkBuffer != NULL) {
|
||||
R_HREG_MODE = HREG_MODE_UCODE_DISAS;
|
||||
R_UCODE_DISAS_TOGGLE = 1;
|
||||
R_UCODE_DISAS_LOG_LEVEL = 2;
|
||||
Graph_DisassembleUCode(sPrevTaskWorkBuffer);
|
||||
LogUtils_LogHexDump((void*)PHYS_TO_K1(SP_BASE_REG), 0x20);
|
||||
LogUtils_LogHexDump((void*)PHYS_TO_K1(DPC_BASE_REG), 0x20);
|
||||
LogUtils_LogHexDump(gGfxSPTaskYieldBuffer, sizeof(gGfxSPTaskYieldBuffer));
|
||||
|
||||
SREG(6) = -1;
|
||||
if (sPrevTaskWorkBuffer != NULL) {
|
||||
R_HREG_MODE = HREG_MODE_UCODE_DISAS;
|
||||
R_UCODE_DISAS_TOGGLE = 1;
|
||||
R_UCODE_DISAS_LOG_LEVEL = 2;
|
||||
Graph_DisassembleUCode(sPrevTaskWorkBuffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
Fault_AddHungupAndCrashImpl("RCP is HUNG UP!!", "Oh! MY GOD!!");
|
||||
}
|
||||
|
||||
Fault_AddHungupAndCrashImpl("RCP is HUNG UP!!", "Oh! MY GOD!!");
|
||||
osRecvMesg(&gfxCtx->queue, &msg, OS_MESG_NOBLOCK);
|
||||
|
||||
#if OOT_DEBUG
|
||||
sPrevTaskWorkBuffer = gfxCtx->workBuffer;
|
||||
#endif
|
||||
|
||||
if (gfxCtx->callback != NULL) {
|
||||
gfxCtx->callback(gfxCtx, gfxCtx->callbackParam);
|
||||
}
|
||||
|
||||
timeNow = osGetTime();
|
||||
if (gAudioThreadUpdateTimeStart != 0) {
|
||||
// The audio thread update is running
|
||||
// Add the time already spent to the accumulator and leave the rest for the next cycle
|
||||
|
||||
gAudioThreadUpdateTimeAcc += timeNow - gAudioThreadUpdateTimeStart;
|
||||
gAudioThreadUpdateTimeStart = timeNow;
|
||||
}
|
||||
gAudioThreadUpdateTimeTotalPerGfxTask = gAudioThreadUpdateTimeAcc;
|
||||
gAudioThreadUpdateTimeAcc = 0;
|
||||
|
||||
sGraphPrevTaskTimeStart = osGetTime();
|
||||
|
||||
task->type = M_GFXTASK;
|
||||
task->flags = OS_SC_DRAM_DLIST;
|
||||
task->ucode_boot = SysUcode_GetUCodeBoot();
|
||||
task->ucode_boot_size = SysUcode_GetUCodeBootSize();
|
||||
task->ucode = SysUcode_GetUCode();
|
||||
task->ucode_data = SysUcode_GetUCodeData();
|
||||
task->ucode_size = SP_UCODE_SIZE;
|
||||
task->ucode_data_size = SP_UCODE_DATA_SIZE;
|
||||
task->dram_stack = gGfxSPTaskStack;
|
||||
task->dram_stack_size = sizeof(gGfxSPTaskStack);
|
||||
task->output_buff = gGfxSPTaskOutputBuffer;
|
||||
task->output_buff_size = gGfxSPTaskOutputBuffer + ARRAY_COUNT(gGfxSPTaskOutputBuffer);
|
||||
task->data_ptr = (u64*)gfxCtx->workBuffer;
|
||||
|
||||
OPEN_DISPS(gfxCtx, "../graph.c", 828);
|
||||
task->data_size = (uintptr_t)WORK_DISP - (uintptr_t)gfxCtx->workBuffer;
|
||||
CLOSE_DISPS(gfxCtx, "../graph.c", 830);
|
||||
|
||||
task->yield_data_ptr = gGfxSPTaskYieldBuffer;
|
||||
|
||||
if (1) {}
|
||||
|
||||
task->yield_data_size = sizeof(gGfxSPTaskYieldBuffer);
|
||||
|
||||
scTask->next = NULL;
|
||||
scTask->flags = OS_SC_NEEDS_RSP | OS_SC_NEEDS_RDP | OS_SC_SWAPBUFFER | OS_SC_LAST_TASK;
|
||||
if (R_GRAPH_TASKSET00_FLAGS & 1) {
|
||||
R_GRAPH_TASKSET00_FLAGS &= ~1;
|
||||
scTask->flags &= ~OS_SC_SWAPBUFFER;
|
||||
gfxCtx->fbIdx--;
|
||||
}
|
||||
|
||||
scTask->msgQueue = &gfxCtx->queue;
|
||||
scTask->msg = NULL;
|
||||
|
||||
{ s16 pad; }
|
||||
|
||||
cfb = &sGraphCfbInfos[sGraphCfbInfoIdx];
|
||||
|
||||
sGraphCfbInfoIdx = (sGraphCfbInfoIdx + 1) % ARRAY_COUNT(sGraphCfbInfos);
|
||||
cfb->framebuffer = gfxCtx->curFrameBuffer;
|
||||
cfb->swapBuffer = gfxCtx->curFrameBuffer;
|
||||
|
||||
cfb->viMode = gfxCtx->viMode;
|
||||
cfb->viFeatures = gfxCtx->viFeatures;
|
||||
cfb->xScale = gfxCtx->xScale;
|
||||
cfb->yScale = gfxCtx->yScale;
|
||||
cfb->unk_10 = 0;
|
||||
cfb->updateRate = R_UPDATE_RATE;
|
||||
|
||||
scTask->framebuffer = cfb;
|
||||
|
||||
{ s16 pad2; }
|
||||
|
||||
gfxCtx->schedMsgQueue = &gScheduler.cmdQueue;
|
||||
|
||||
osSendMesg(&gScheduler.cmdQueue, (OSMesg)scTask, OS_MESG_BLOCK);
|
||||
Sched_Notify(&gScheduler);
|
||||
}
|
||||
|
||||
osRecvMesg(&gfxCtx->queue, &msg, OS_MESG_NOBLOCK);
|
||||
|
||||
sPrevTaskWorkBuffer = gfxCtx->workBuffer;
|
||||
if (gfxCtx->callback != NULL) {
|
||||
gfxCtx->callback(gfxCtx, gfxCtx->callbackParam);
|
||||
}
|
||||
|
||||
timeNow = osGetTime();
|
||||
if (gAudioThreadUpdateTimeStart != 0) {
|
||||
// The audio thread update is running
|
||||
// Add the time already spent to the accumulator and leave the rest for the next cycle
|
||||
|
||||
gAudioThreadUpdateTimeAcc += timeNow - gAudioThreadUpdateTimeStart;
|
||||
gAudioThreadUpdateTimeStart = timeNow;
|
||||
}
|
||||
gAudioThreadUpdateTimeTotalPerGfxTask = gAudioThreadUpdateTimeAcc;
|
||||
gAudioThreadUpdateTimeAcc = 0;
|
||||
|
||||
sGraphPrevTaskTimeStart = osGetTime();
|
||||
|
||||
task->type = M_GFXTASK;
|
||||
task->flags = OS_SC_DRAM_DLIST;
|
||||
task->ucode_boot = SysUcode_GetUCodeBoot();
|
||||
task->ucode_boot_size = SysUcode_GetUCodeBootSize();
|
||||
task->ucode = SysUcode_GetUCode();
|
||||
task->ucode_data = SysUcode_GetUCodeData();
|
||||
task->ucode_size = SP_UCODE_SIZE;
|
||||
task->ucode_data_size = SP_UCODE_DATA_SIZE;
|
||||
task->dram_stack = gGfxSPTaskStack;
|
||||
task->dram_stack_size = sizeof(gGfxSPTaskStack);
|
||||
task->output_buff = gGfxSPTaskOutputBuffer;
|
||||
task->output_buff_size = gGfxSPTaskOutputBuffer + ARRAY_COUNT(gGfxSPTaskOutputBuffer);
|
||||
task->data_ptr = (u64*)gfxCtx->workBuffer;
|
||||
|
||||
OPEN_DISPS(gfxCtx, "../graph.c", 828);
|
||||
task->data_size = (uintptr_t)WORK_DISP - (uintptr_t)gfxCtx->workBuffer;
|
||||
CLOSE_DISPS(gfxCtx, "../graph.c", 830);
|
||||
|
||||
{ s32 pad2; } // Necessary to match stack usage
|
||||
|
||||
task->yield_data_ptr = gGfxSPTaskYieldBuffer;
|
||||
task->yield_data_size = sizeof(gGfxSPTaskYieldBuffer);
|
||||
|
||||
scTask->next = NULL;
|
||||
scTask->flags = OS_SC_NEEDS_RSP | OS_SC_NEEDS_RDP | OS_SC_SWAPBUFFER | OS_SC_LAST_TASK;
|
||||
if (R_GRAPH_TASKSET00_FLAGS & 1) {
|
||||
R_GRAPH_TASKSET00_FLAGS &= ~1;
|
||||
scTask->flags &= ~OS_SC_SWAPBUFFER;
|
||||
gfxCtx->fbIdx--;
|
||||
}
|
||||
|
||||
scTask->msgQueue = &gfxCtx->queue;
|
||||
scTask->msg = NULL;
|
||||
|
||||
cfb = &sGraphCfbInfos[sGraphCfbInfoIdx++];
|
||||
cfb->framebuffer = gfxCtx->curFrameBuffer;
|
||||
cfb->swapBuffer = gfxCtx->curFrameBuffer;
|
||||
cfb->viMode = gfxCtx->viMode;
|
||||
cfb->viFeatures = gfxCtx->viFeatures;
|
||||
cfb->xScale = gfxCtx->xScale;
|
||||
cfb->yScale = gfxCtx->yScale;
|
||||
cfb->unk_10 = 0;
|
||||
cfb->updateRate = R_UPDATE_RATE;
|
||||
|
||||
scTask->framebuffer = cfb;
|
||||
sGraphCfbInfoIdx %= ARRAY_COUNT(sGraphCfbInfos);
|
||||
|
||||
if (1) {}
|
||||
|
||||
gfxCtx->schedMsgQueue = &gScheduler.cmdQueue;
|
||||
|
||||
osSendMesg(&gScheduler.cmdQueue, (OSMesg)scTask, OS_MESG_BLOCK);
|
||||
Sched_Notify(&gScheduler);
|
||||
}
|
||||
|
||||
void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
|
||||
|
@ -268,6 +287,7 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
|
|||
gameState->inPreNMIState = false;
|
||||
Graph_InitTHGA(gfxCtx);
|
||||
|
||||
#if OOT_DEBUG
|
||||
OPEN_DISPS(gfxCtx, "../graph.c", 966);
|
||||
|
||||
gDPNoOpString(WORK_DISP++, "WORK_DISP 開始", 0);
|
||||
|
@ -276,10 +296,12 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
|
|||
gDPNoOpString(OVERLAY_DISP++, "OVERLAY_DISP 開始", 0);
|
||||
|
||||
CLOSE_DISPS(gfxCtx, "../graph.c", 975);
|
||||
#endif
|
||||
|
||||
GameState_ReqPadData(gameState);
|
||||
GameState_Update(gameState);
|
||||
|
||||
#if OOT_DEBUG
|
||||
OPEN_DISPS(gfxCtx, "../graph.c", 987);
|
||||
|
||||
gDPNoOpString(WORK_DISP++, "WORK_DISP 終了", 0);
|
||||
|
@ -288,6 +310,7 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
|
|||
gDPNoOpString(OVERLAY_DISP++, "OVERLAY_DISP 終了", 0);
|
||||
|
||||
CLOSE_DISPS(gfxCtx, "../graph.c", 996);
|
||||
#endif
|
||||
|
||||
OPEN_DISPS(gfxCtx, "../graph.c", 999);
|
||||
|
||||
|
@ -300,6 +323,7 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
|
|||
|
||||
CLOSE_DISPS(gfxCtx, "../graph.c", 1028);
|
||||
|
||||
#if OOT_DEBUG
|
||||
if (R_HREG_MODE == HREG_MODE_PLAY && R_PLAY_ENABLE_UCODE_DISAS == 2) {
|
||||
R_HREG_MODE = HREG_MODE_UCODE_DISAS;
|
||||
R_UCODE_DISAS_TOGGLE = -1;
|
||||
|
@ -326,6 +350,7 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
|
|||
R_UCODE_DISAS_TOGGLE = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
problem = false;
|
||||
|
||||
|
@ -377,7 +402,7 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
|
|||
|
||||
{
|
||||
OSTime timeNow = osGetTime();
|
||||
s32 pad[4];
|
||||
s32 pad;
|
||||
|
||||
gRSPGfxTimeTotal = gRSPGfxTimeAcc;
|
||||
gRSPAudioTimeTotal = gRSPAudioTimeAcc;
|
||||
|
@ -392,19 +417,29 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
|
|||
sGraphPrevUpdateEndTime = timeNow;
|
||||
}
|
||||
|
||||
#if OOT_DEBUG
|
||||
if (gIsCtrlr2Valid && CHECK_BTN_ALL(gameState->input[0].press.button, BTN_Z) &&
|
||||
CHECK_BTN_ALL(gameState->input[0].cur.button, BTN_L | BTN_R)) {
|
||||
gSaveContext.gameMode = GAMEMODE_NORMAL;
|
||||
SET_NEXT_GAMESTATE(gameState, MapSelect_Init, MapSelectState);
|
||||
{
|
||||
GameState* state = gameState;
|
||||
|
||||
SET_NEXT_GAMESTATE(state, MapSelect_Init, MapSelectState);
|
||||
}
|
||||
gameState->running = false;
|
||||
}
|
||||
|
||||
if (gIsCtrlr2Valid && PreNmiBuff_IsResetting(gAppNmiBufferPtr) && !gameState->inPreNMIState) {
|
||||
// "To reset mode"
|
||||
PRINTF(VT_COL(YELLOW, BLACK) "PRE-NMIによりリセットモードに移行します\n" VT_RST);
|
||||
SET_NEXT_GAMESTATE(gameState, PreNMI_Init, PreNMIState);
|
||||
{
|
||||
GameState* state = gameState;
|
||||
|
||||
SET_NEXT_GAMESTATE(state, PreNMI_Init, PreNMIState);
|
||||
}
|
||||
gameState->running = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Graph_ThreadEntry(void* arg0) {
|
||||
|
@ -413,7 +448,6 @@ void Graph_ThreadEntry(void* arg0) {
|
|||
u32 size;
|
||||
GameStateOverlay* nextOvl = &gGameStateOverlayTable[GAMESTATE_SETUP];
|
||||
GameStateOverlay* ovl;
|
||||
char faultMsg[0x50];
|
||||
|
||||
PRINTF("グラフィックスレッド実行開始\n"); // "Start graphic thread execution"
|
||||
Graph_Init(&gfxCtx);
|
||||
|
@ -428,10 +462,15 @@ void Graph_ThreadEntry(void* arg0) {
|
|||
gameState = SYSTEM_ARENA_MALLOC(size, "../graph.c", 1196);
|
||||
|
||||
if (gameState == NULL) {
|
||||
#if OOT_DEBUG
|
||||
char faultMsg[0x50];
|
||||
PRINTF("確保失敗\n"); // "Failure to secure"
|
||||
|
||||
sprintf(faultMsg, "CLASS SIZE= %d bytes", size);
|
||||
Fault_AddHungupAndCrashImpl("GAME CLASS MALLOC FAILED", faultMsg);
|
||||
#else
|
||||
Fault_AddHungupAndCrash("../graph.c", 1200);
|
||||
#endif
|
||||
}
|
||||
|
||||
GameState_Init(gameState, ovl->init, &gfxCtx);
|
||||
|
@ -469,6 +508,7 @@ void* Graph_Alloc2(GraphicsContext* gfxCtx, size_t size) {
|
|||
return THGA_AllocTail(&gfxCtx->polyOpa, ALIGN16(size));
|
||||
}
|
||||
|
||||
#if OOT_DEBUG
|
||||
void Graph_OpenDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, s32 line) {
|
||||
if (R_HREG_MODE == HREG_MODE_UCODE_DISAS && R_UCODE_DISAS_LOG_MODE != 4) {
|
||||
dispRefs[0] = gfxCtx->polyOpa.p;
|
||||
|
@ -502,27 +542,4 @@ void Graph_CloseDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Gfx* Graph_GfxPlusOne(Gfx* gfx) {
|
||||
return gfx + 1;
|
||||
}
|
||||
|
||||
Gfx* Graph_BranchDlist(Gfx* gfx, Gfx* dst) {
|
||||
gSPBranchList(gfx, dst);
|
||||
return dst;
|
||||
}
|
||||
|
||||
void* Graph_DlistAlloc(Gfx** gfxP, u32 size) {
|
||||
u8* ptr;
|
||||
Gfx* dst;
|
||||
|
||||
size = ALIGN8(size);
|
||||
|
||||
ptr = (u8*)(*gfxP + 1);
|
||||
|
||||
dst = (Gfx*)(ptr + size);
|
||||
gSPBranchList(*gfxP, dst);
|
||||
|
||||
*gfxP = dst;
|
||||
return ptr;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -283,7 +283,7 @@ void Debug_DrawText(GraphicsContext* gfxCtx) {
|
|||
|
||||
GfxPrint_Init(&printer);
|
||||
opaStart = POLY_OPA_DISP;
|
||||
gfx = Graph_GfxPlusOne(POLY_OPA_DISP);
|
||||
gfx = Gfx_Open(POLY_OPA_DISP);
|
||||
gSPDisplayList(OVERLAY_DISP++, gfx);
|
||||
GfxPrint_Open(&printer, gfx);
|
||||
|
||||
|
@ -299,7 +299,7 @@ void Debug_DrawText(GraphicsContext* gfxCtx) {
|
|||
|
||||
gfx = GfxPrint_Close(&printer);
|
||||
gSPEndDisplayList(gfx++);
|
||||
Graph_BranchDlist(opaStart, gfx);
|
||||
Gfx_Close(opaStart, gfx);
|
||||
POLY_OPA_DISP = gfx;
|
||||
|
||||
if (1) {}
|
||||
|
|
|
@ -2211,11 +2211,11 @@ void CutsceneHandler_RunScript(PlayState* play, CutsceneContext* csCtx) {
|
|||
OPEN_DISPS(play->state.gfxCtx, "../z_demo.c", 4101);
|
||||
|
||||
prevDisplayList = POLY_OPA_DISP;
|
||||
displayList = Graph_GfxPlusOne(POLY_OPA_DISP);
|
||||
displayList = Gfx_Open(POLY_OPA_DISP);
|
||||
gSPDisplayList(OVERLAY_DISP++, displayList);
|
||||
Cutscene_DrawDebugInfo(play, &displayList, csCtx);
|
||||
gSPEndDisplayList(displayList++);
|
||||
Graph_BranchDlist(prevDisplayList, displayList);
|
||||
Gfx_Close(prevDisplayList, displayList);
|
||||
POLY_OPA_DISP = displayList;
|
||||
|
||||
CLOSE_DISPS(play->state.gfxCtx, "../z_demo.c", 4108);
|
||||
|
|
|
@ -958,11 +958,11 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
|
|||
OPEN_DISPS(play->state.gfxCtx, "../z_kankyo.c", 1682);
|
||||
|
||||
prevDisplayList = POLY_OPA_DISP;
|
||||
displayList = Graph_GfxPlusOne(POLY_OPA_DISP);
|
||||
displayList = Gfx_Open(POLY_OPA_DISP);
|
||||
gSPDisplayList(OVERLAY_DISP++, displayList);
|
||||
Environment_PrintDebugInfo(play, &displayList);
|
||||
gSPEndDisplayList(displayList++);
|
||||
Graph_BranchDlist(prevDisplayList, displayList);
|
||||
Gfx_Close(prevDisplayList, displayList);
|
||||
POLY_OPA_DISP = displayList;
|
||||
if (1) {}
|
||||
CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 1690);
|
||||
|
|
|
@ -3013,19 +3013,19 @@ void Message_Draw(PlayState* play) {
|
|||
watchVar = gSaveContext.save.info.scarecrowLongSongSet;
|
||||
Message_DrawDebugVariableChanged(&watchVar, play->state.gfxCtx);
|
||||
if (BREG(0) != 0 && play->msgCtx.textId != 0) {
|
||||
plusOne = Graph_GfxPlusOne(polyOpaP = POLY_OPA_DISP);
|
||||
plusOne = Gfx_Open(polyOpaP = POLY_OPA_DISP);
|
||||
gSPDisplayList(OVERLAY_DISP++, plusOne);
|
||||
Message_DrawDebugText(play, &plusOne);
|
||||
gSPEndDisplayList(plusOne++);
|
||||
Graph_BranchDlist(polyOpaP, plusOne);
|
||||
Gfx_Close(polyOpaP, plusOne);
|
||||
POLY_OPA_DISP = plusOne;
|
||||
}
|
||||
if (1) {}
|
||||
plusOne = Graph_GfxPlusOne(polyOpaP = POLY_OPA_DISP);
|
||||
plusOne = Gfx_Open(polyOpaP = POLY_OPA_DISP);
|
||||
gSPDisplayList(OVERLAY_DISP++, plusOne);
|
||||
Message_DrawMain(play, &plusOne);
|
||||
gSPEndDisplayList(plusOne++);
|
||||
Graph_BranchDlist(polyOpaP, plusOne);
|
||||
Gfx_Close(polyOpaP, plusOne);
|
||||
POLY_OPA_DISP = plusOne;
|
||||
CLOSE_DISPS(play->state.gfxCtx, "../z_message_PAL.c", 3582);
|
||||
}
|
||||
|
|
|
@ -1085,7 +1085,7 @@ void Play_Draw(PlayState* this) {
|
|||
Gfx* gfxP;
|
||||
Gfx* sp1CC = POLY_OPA_DISP;
|
||||
|
||||
gfxP = Graph_GfxPlusOne(sp1CC);
|
||||
gfxP = Gfx_Open(sp1CC);
|
||||
gSPDisplayList(OVERLAY_DISP++, gfxP);
|
||||
|
||||
if ((this->transitionMode == TRANS_MODE_INSTANCE_RUNNING) ||
|
||||
|
@ -1109,7 +1109,7 @@ void Play_Draw(PlayState* this) {
|
|||
}
|
||||
|
||||
gSPEndDisplayList(gfxP++);
|
||||
Graph_BranchDlist(sp1CC, gfxP);
|
||||
Gfx_Close(sp1CC, gfxP);
|
||||
POLY_OPA_DISP = gfxP;
|
||||
}
|
||||
|
||||
|
|
|
@ -1362,7 +1362,7 @@ void Gfx_SetupDL_59Opa(GraphicsContext* gfxCtx) {
|
|||
}
|
||||
|
||||
Gfx* Gfx_BranchTexScroll(Gfx** gfxP, u32 x, u32 y, s32 width, s32 height) {
|
||||
Gfx* displayList = Graph_DlistAlloc(gfxP, 3 * sizeof(Gfx));
|
||||
Gfx* displayList = Gfx_Alloc(gfxP, 3 * sizeof(Gfx));
|
||||
|
||||
gDPTileSync(displayList);
|
||||
gDPSetTileSize(displayList + 1, G_TX_RENDERTILE, x, y, x + ((width - 1) << 2), y + ((height - 1) << 2));
|
||||
|
|
|
@ -146,14 +146,14 @@ void VisMono_Draw(VisMono* this, Gfx** gfxP) {
|
|||
if (this->tlut) {
|
||||
tlut = this->tlut;
|
||||
} else {
|
||||
tlut = Graph_DlistAlloc(&gfx, 256 * G_IM_SIZ_16b_BYTES);
|
||||
tlut = Gfx_Alloc(&gfx, 256 * G_IM_SIZ_16b_BYTES);
|
||||
VisMono_DesaturateTLUT(this, tlut);
|
||||
}
|
||||
|
||||
if (this->dList) {
|
||||
dList = this->dList;
|
||||
} else {
|
||||
dList = Graph_DlistAlloc(&gfx, VISMONO_DLSIZE * sizeof(Gfx));
|
||||
dList = Gfx_Alloc(&gfx, VISMONO_DLSIZE * sizeof(Gfx));
|
||||
dListEnd = VisMono_DesaturateDList(this, dList);
|
||||
|
||||
if (!(dListEnd <= dList + VISMONO_DLSIZE)) {
|
||||
|
|
|
@ -570,13 +570,13 @@ void EnMag_Draw(Actor* thisx, PlayState* play) {
|
|||
OPEN_DISPS(play->state.gfxCtx, "../z_en_mag.c", 1151);
|
||||
|
||||
gfxRef = POLY_OPA_DISP;
|
||||
gfx = Graph_GfxPlusOne(gfxRef);
|
||||
gfx = Gfx_Open(gfxRef);
|
||||
gSPDisplayList(OVERLAY_DISP++, gfx);
|
||||
|
||||
EnMag_DrawInner(thisx, play, &gfx);
|
||||
|
||||
gSPEndDisplayList(gfx++);
|
||||
Graph_BranchDlist(gfxRef, gfx);
|
||||
Gfx_Close(gfxRef, gfx);
|
||||
POLY_OPA_DISP = gfx;
|
||||
|
||||
CLOSE_DISPS(play->state.gfxCtx, "../z_en_mag.c", 1161);
|
||||
|
|
|
@ -124,13 +124,13 @@ void KaleidoScope_DrawDebugEditor(PlayState* play) {
|
|||
PRIMITIVE, 0);
|
||||
|
||||
gfxRef = POLY_OPA_DISP;
|
||||
gfx = Graph_GfxPlusOne(gfxRef);
|
||||
gfx = Gfx_Open(gfxRef);
|
||||
gSPDisplayList(OVERLAY_DISP++, gfx);
|
||||
|
||||
KaleidoScope_DrawDebugEditorText(&gfx);
|
||||
|
||||
gSPEndDisplayList(gfx++);
|
||||
Graph_BranchDlist(gfxRef, gfx);
|
||||
Gfx_Close(gfxRef, gfx);
|
||||
POLY_OPA_DISP = gfx;
|
||||
|
||||
gDPPipeSync(POLY_OPA_DISP++);
|
||||
|
|
|
@ -366,7 +366,7 @@ void KaleidoScope_SetupPlayerPreRender(PlayState* play) {
|
|||
OPEN_DISPS(play->state.gfxCtx, "../z_kaleido_scope_PAL.c", 496);
|
||||
|
||||
gfxRef = POLY_OPA_DISP;
|
||||
gfx = Graph_GfxPlusOne(gfxRef);
|
||||
gfx = Gfx_Open(gfxRef);
|
||||
gSPDisplayList(WORK_DISP++, gfx);
|
||||
|
||||
PreRender_SetValues(&sPlayerPreRender, PAUSE_EQUIP_PLAYER_WIDTH, PAUSE_EQUIP_PLAYER_HEIGHT, fbuf, NULL);
|
||||
|
@ -374,7 +374,7 @@ void KaleidoScope_SetupPlayerPreRender(PlayState* play) {
|
|||
PreRender_DrawCoverage(&sPlayerPreRender, &gfx);
|
||||
|
||||
gSPEndDisplayList(gfx++);
|
||||
Graph_BranchDlist(gfxRef, gfx);
|
||||
Gfx_Close(gfxRef, gfx);
|
||||
POLY_OPA_DISP = gfx;
|
||||
|
||||
R_GRAPH_TASKSET00_FLAGS |= 1;
|
||||
|
|
|
@ -91,6 +91,7 @@ DB40,8001EA40,src/code/z_actor.s
|
|||
8F400,800A0300,src/code/game.s
|
||||
8FB80,800A0A80,src/code/gamealloc.s
|
||||
8FCC0,800A0BC0,src/code/graph.s
|
||||
90660,800A1560,src/code/gfxalloc.s
|
||||
906C0,800A15C0,src/code/listalloc.s
|
||||
90810,800A1710,src/code/main.s
|
||||
90B70,800A1A70,src/code/padmgr.s
|
||||
|
|
|
|
@ -2099,9 +2099,9 @@ Graph_Update = 0x800A1148; // type:func
|
|||
Graph_ThreadEntry = 0x800A13FC; // type:func
|
||||
Graph_Alloc = 0x800A14F4; // type:func
|
||||
Graph_Alloc2 = 0x800A1528; // type:func
|
||||
Graph_GfxPlusOne = 0x800A1560; // type:func
|
||||
Graph_BranchDlist = 0x800A156C; // type:func
|
||||
Graph_DlistAlloc = 0x800A1584; // type:func
|
||||
Gfx_Open = 0x800A1560; // type:func
|
||||
Gfx_Close = 0x800A156C; // type:func
|
||||
Gfx_Alloc = 0x800A1584; // type:func
|
||||
ListAlloc_Init = 0x800A15C0; // type:func
|
||||
ListAlloc_Alloc = 0x800A15D4; // type:func
|
||||
ListAlloc_Free = 0x800A1640; // type:func
|
||||
|
|
Loading…
Reference in a new issue