mirror of
https://github.com/zeldaret/oot.git
synced 2024-11-23 22:09:43 +00:00
Match `game.c
` - OK (#1644)
This commit is contained in:
parent
68b41d6b0d
commit
9f169a67cd
@ -1299,9 +1299,7 @@ void func_800C213C(PreRender* this, Gfx** gfxP);
|
||||
void PreRender_RestoreFramebuffer(PreRender* this, Gfx** gfxP);
|
||||
void PreRender_CopyImageRegion(PreRender* this, Gfx** gfxP);
|
||||
void PreRender_ApplyFilters(PreRender* this);
|
||||
void GameState_FaultPrint(void);
|
||||
void GameState_SetFBFilter(Gfx** gfxP);
|
||||
void GameState_DrawInputDisplay(u16 input, Gfx** gfxP);
|
||||
void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx);
|
||||
void GameState_SetFrameBuffer(GraphicsContext* gfxCtx);
|
||||
void GameState_ReqPadData(GameState* gameState);
|
||||
@ -1312,7 +1310,9 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g
|
||||
void GameState_Destroy(GameState* gameState);
|
||||
GameStateFunc GameState_GetInit(GameState* gameState);
|
||||
u32 GameState_IsRunning(GameState* gameState);
|
||||
#ifdef 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);
|
||||
void* GameAlloc_Malloc(GameAlloc* this, u32 size);
|
||||
|
@ -191,6 +191,8 @@ extern struct GraphicsContext* __gfxCtx;
|
||||
#define ZELDA_ARENA_FREE(size, file, line) ZeldaArena_FreeDebug(size, file, line)
|
||||
#define LOG_UTILS_CHECK_NULL_POINTER(exp, ptr, file, line) LogUtils_CheckNullPointer(exp, ptr, file, line)
|
||||
#define LOG_UTILS_CHECK_VALID_POINTER(exp, ptr, file, line) LogUtils_CheckValidPointer(exp, ptr, file, line)
|
||||
#define HUNGUP_AND_CRASH(file, line) Fault_AddHungupAndCrash(file, line)
|
||||
#define GAME_ALLOC_MALLOC(alloc, size, file, line) GameAlloc_MallocDebug(alloc, size, file, line)
|
||||
|
||||
#else
|
||||
|
||||
@ -219,6 +221,8 @@ extern struct GraphicsContext* __gfxCtx;
|
||||
#define ZELDA_ARENA_FREE(size, file, line) ZeldaArena_Free(size)
|
||||
#define LOG_UTILS_CHECK_NULL_POINTER(exp, ptr, file, line) (void)0
|
||||
#define LOG_UTILS_CHECK_VALID_POINTER(exp, ptr, file, line) (void)0
|
||||
#define HUNGUP_AND_CRASH(file, line) LogUtils_HungupThread(file, line)
|
||||
#define GAME_ALLOC_MALLOC(alloc, size, file, line) GameAlloc_Malloc(alloc, size)
|
||||
|
||||
#endif /* OOT_DEBUG */
|
||||
|
||||
|
@ -1,6 +1,12 @@
|
||||
#include "global.h"
|
||||
#include "terminal.h"
|
||||
|
||||
#ifdef OOT_DEBUG
|
||||
#define VI_MODE_EDITOR_INACTIVE (R_VI_MODE_EDIT_STATE == VI_MODE_EDIT_STATE_INACTIVE)
|
||||
#else
|
||||
#define VI_MODE_EDITOR_INACTIVE true
|
||||
#endif
|
||||
|
||||
SpeedMeter D_801664D0;
|
||||
VisCvg sVisCvg;
|
||||
VisZBuf sVisZBuf;
|
||||
@ -9,6 +15,7 @@ ViMode sViMode;
|
||||
FaultClient sGameFaultClient;
|
||||
u16 sLastButtonPressed;
|
||||
|
||||
#ifdef OOT_DEBUG
|
||||
void GameState_FaultPrint(void) {
|
||||
static char sBtnChars[] = "ABZSuldr*+LRudlr";
|
||||
s32 i;
|
||||
@ -21,6 +28,7 @@ void GameState_FaultPrint(void) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void GameState_SetFBFilter(Gfx** gfxP) {
|
||||
Gfx* gfx = *gfxP;
|
||||
@ -62,6 +70,7 @@ void GameState_SetFBFilter(Gfx** gfxP) {
|
||||
}
|
||||
|
||||
void func_800C4344(GameState* gameState) {
|
||||
#ifdef OOT_DEBUG
|
||||
Input* selectedInput;
|
||||
s32 hexDumpSize;
|
||||
u16 inputCompareValue;
|
||||
@ -111,8 +120,10 @@ void func_800C4344(GameState* gameState) {
|
||||
LogUtils_LogHexDump((void*)(0x80000000 + (R_PRINT_MEMORY_ADDR << 8)), hexDumpSize);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef OOT_DEBUG
|
||||
void GameState_DrawInputDisplay(u16 input, Gfx** gfxP) {
|
||||
static const u16 sInpDispBtnColors[] = {
|
||||
GPACK_RGBA5551(255, 255, 0, 1), GPACK_RGBA5551(255, 255, 0, 1), GPACK_RGBA5551(255, 255, 0, 1),
|
||||
@ -143,6 +154,7 @@ void GameState_DrawInputDisplay(u16 input, Gfx** gfxP) {
|
||||
|
||||
*gfxP = gfx;
|
||||
}
|
||||
#endif
|
||||
|
||||
void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) {
|
||||
Gfx* newDList;
|
||||
@ -157,6 +169,7 @@ void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) {
|
||||
GameState_SetFBFilter(&newDList);
|
||||
}
|
||||
|
||||
#ifdef OOT_DEBUG
|
||||
sLastButtonPressed = gameState->input[0].press.button | gameState->input[0].cur.button;
|
||||
if (R_DISABLE_INPUT_DISPLAY == 0) {
|
||||
GameState_DrawInputDisplay(sLastButtonPressed, &newDList);
|
||||
@ -172,14 +185,16 @@ void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) {
|
||||
newDList = GfxPrint_Close(&printer);
|
||||
GfxPrint_Destroy(&printer);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (R_ENABLE_ARENA_DBG < 0) {
|
||||
#ifdef OOT_DEBUG
|
||||
s32 pad;
|
||||
|
||||
DebugArena_Display();
|
||||
SystemArena_Display();
|
||||
// "%08x bytes left until the death of Hyrule (game_alloc)"
|
||||
PRINTF("ハイラル滅亡まであと %08x バイト(game_alloc)\n", THA_GetRemaining(&gameState->tha));
|
||||
#endif
|
||||
R_ENABLE_ARENA_DBG = 0;
|
||||
}
|
||||
|
||||
@ -248,6 +263,7 @@ void GameState_Update(GameState* gameState) {
|
||||
|
||||
func_800C4344(gameState);
|
||||
|
||||
#ifdef OOT_DEBUG
|
||||
if (SREG(63) == 1u) {
|
||||
if (R_VI_MODE_EDIT_STATE < VI_MODE_EDIT_STATE_INACTIVE) {
|
||||
R_VI_MODE_EDIT_STATE = VI_MODE_EDIT_STATE_INACTIVE;
|
||||
@ -321,6 +337,7 @@ void GameState_Update(GameState* gameState) {
|
||||
D_80009430 = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (R_PAUSE_BG_PRERENDER_STATE != (u32)PAUSE_BG_PRERENDER_PROCESS) {
|
||||
GameState_Draw(gameState, gfxCtx);
|
||||
@ -334,14 +351,15 @@ void GameState_InitArena(GameState* gameState, size_t size) {
|
||||
void* arena;
|
||||
|
||||
PRINTF("ハイラル確保 サイズ=%u バイト\n"); // "Hyrule reserved size = %u bytes"
|
||||
arena = GameAlloc_MallocDebug(&gameState->alloc, size, "../game.c", 992);
|
||||
arena = GAME_ALLOC_MALLOC(&gameState->alloc, size, "../game.c", 992);
|
||||
|
||||
if (arena != NULL) {
|
||||
THA_Init(&gameState->tha, arena, size);
|
||||
PRINTF("ハイラル確保成功\n"); // "Successful Hyral"
|
||||
} else {
|
||||
THA_Init(&gameState->tha, NULL, 0);
|
||||
PRINTF("ハイラル確保失敗\n"); // "Failure to secure Hyrule"
|
||||
Fault_AddHungupAndCrash("../game.c", 999);
|
||||
HUNGUP_AND_CRASH("../game.c", 999);
|
||||
}
|
||||
}
|
||||
|
||||
@ -369,15 +387,19 @@ void GameState_Realloc(GameState* gameState, size_t size) {
|
||||
}
|
||||
|
||||
PRINTF("ハイラル再確保 サイズ=%u バイト\n", size); // "Hyral reallocate size = %u bytes"
|
||||
gameArena = GameAlloc_MallocDebug(alloc, size, "../game.c", 1033);
|
||||
|
||||
gameArena = GAME_ALLOC_MALLOC(alloc, size, "../game.c", 1033);
|
||||
if (gameArena != NULL) {
|
||||
THA_Init(&gameState->tha, gameArena, size);
|
||||
PRINTF("ハイラル再確保成功\n"); // "Successful reacquisition of Hyrule"
|
||||
} else {
|
||||
THA_Init(&gameState->tha, NULL, 0);
|
||||
PRINTF("ハイラル再確保失敗\n"); // "Failure to secure Hyral"
|
||||
|
||||
#ifdef OOT_DEBUG
|
||||
SystemArena_Display();
|
||||
Fault_AddHungupAndCrash("../game.c", 1044);
|
||||
#endif
|
||||
HUNGUP_AND_CRASH("../game.c", 1044);
|
||||
}
|
||||
}
|
||||
|
||||
@ -392,24 +414,25 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g
|
||||
gameState->destroy = NULL;
|
||||
gameState->running = 1;
|
||||
startTime = osGetTime();
|
||||
gameState->size = 0;
|
||||
gameState->init = NULL;
|
||||
endTime = osGetTime();
|
||||
gameState->size = gameState->init = 0;
|
||||
|
||||
// "game_set_next_game_null processing time %d us"
|
||||
PRINTF("game_set_next_game_null 処理時間 %d us\n", OS_CYCLES_TO_USEC(endTime - startTime));
|
||||
startTime = endTime;
|
||||
GameAlloc_Init(&gameState->alloc);
|
||||
{
|
||||
s32 requiredScopeTemp;
|
||||
endTime = osGetTime();
|
||||
// "game_set_next_game_null processing time %d us"
|
||||
PRINTF("game_set_next_game_null 処理時間 %d us\n", OS_CYCLES_TO_USEC(endTime - startTime));
|
||||
startTime = endTime;
|
||||
GameAlloc_Init(&gameState->alloc);
|
||||
}
|
||||
|
||||
endTime = osGetTime();
|
||||
// "gamealloc_init processing time %d us"
|
||||
PRINTF("gamealloc_init 処理時間 %d us\n", OS_CYCLES_TO_USEC(endTime - startTime));
|
||||
|
||||
startTime = endTime;
|
||||
GameState_InitArena(gameState, 0x100000);
|
||||
|
||||
R_UPDATE_RATE = 3;
|
||||
init(gameState);
|
||||
|
||||
endTime = osGetTime();
|
||||
// "init processing time %d us"
|
||||
PRINTF("init 処理時間 %d us\n", OS_CYCLES_TO_USEC(endTime - startTime));
|
||||
@ -419,18 +442,19 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g
|
||||
VisCvg_Init(&sVisCvg);
|
||||
VisZBuf_Init(&sVisZBuf);
|
||||
VisMono_Init(&sVisMono);
|
||||
if (R_VI_MODE_EDIT_STATE == VI_MODE_EDIT_STATE_INACTIVE) {
|
||||
if (VI_MODE_EDITOR_INACTIVE) {
|
||||
ViMode_Init(&sViMode);
|
||||
}
|
||||
SpeedMeter_Init(&D_801664D0);
|
||||
Rumble_Init();
|
||||
osSendMesg(&gameState->gfxCtx->queue, NULL, OS_MESG_BLOCK);
|
||||
|
||||
endTime = osGetTime();
|
||||
// "Other initialization processing time %d us"
|
||||
PRINTF("その他初期化 処理時間 %d us\n", OS_CYCLES_TO_USEC(endTime - startTime));
|
||||
|
||||
#ifdef OOT_DEBUG
|
||||
Fault_AddClient(&sGameFaultClient, GameState_FaultPrint, NULL, NULL);
|
||||
#endif
|
||||
|
||||
PRINTF("game コンストラクタ終了\n"); // "game constructor end"
|
||||
}
|
||||
@ -449,13 +473,16 @@ void GameState_Destroy(GameState* gameState) {
|
||||
VisCvg_Destroy(&sVisCvg);
|
||||
VisZBuf_Destroy(&sVisZBuf);
|
||||
VisMono_Destroy(&sVisMono);
|
||||
if (R_VI_MODE_EDIT_STATE == VI_MODE_EDIT_STATE_INACTIVE) {
|
||||
if (VI_MODE_EDITOR_INACTIVE) {
|
||||
ViMode_Destroy(&sViMode);
|
||||
}
|
||||
THA_Destroy(&gameState->tha);
|
||||
GameAlloc_Cleanup(&gameState->alloc);
|
||||
|
||||
#ifdef OOT_DEBUG
|
||||
SystemArena_Display();
|
||||
Fault_RemoveClient(&sGameFaultClient);
|
||||
#endif
|
||||
|
||||
PRINTF("game デストラクタ終了\n"); // "game destructor end"
|
||||
}
|
||||
@ -472,6 +499,7 @@ u32 GameState_IsRunning(GameState* gameState) {
|
||||
return gameState->running;
|
||||
}
|
||||
|
||||
#ifdef OOT_DEBUG
|
||||
void* GameState_Alloc(GameState* gameState, size_t size, char* file, s32 line) {
|
||||
void* ret;
|
||||
|
||||
@ -501,6 +529,7 @@ void* GameState_Alloc(GameState* gameState, size_t size, char* file, s32 line) {
|
||||
void* GameState_AllocEndAlign16(GameState* gameState, size_t size) {
|
||||
return THA_AllocTailAlign16(&gameState->tha, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
s32 GameState_GetArenaSize(GameState* gameState) {
|
||||
return THA_GetRemaining(&gameState->tha);
|
||||
|
Loading…
Reference in New Issue
Block a user