summaryrefslogtreecommitdiff
path: root/src/code/graph.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/code/graph.c')
-rw-r--r--src/code/graph.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/src/code/graph.c b/src/code/graph.c
index e5309966c..3d53f891c 100644
--- a/src/code/graph.c
+++ b/src/code/graph.c
@@ -116,24 +116,15 @@ void Graph_InitTHGA(GraphicsContext* gfxCtx) {
GameStateOverlay* Graph_GetNextGameState(GameState* gameState) {
void* gameStateInitFunc = GameState_GetInit(gameState);
- if (gameStateInitFunc == Setup_Init) {
- return &gGameStateOverlayTable[0];
- }
- if (gameStateInitFunc == MapSelect_Init) {
- return &gGameStateOverlayTable[1];
- }
- if (gameStateInitFunc == ConsoleLogo_Init) {
- return &gGameStateOverlayTable[2];
- }
- if (gameStateInitFunc == Play_Init) {
- return &gGameStateOverlayTable[3];
- }
- if (gameStateInitFunc == TitleSetup_Init) {
- return &gGameStateOverlayTable[4];
- }
- if (gameStateInitFunc == FileSelect_Init) {
- return &gGameStateOverlayTable[5];
+ // Generates code to match gameStateInitFunc to a gamestate entry and returns it if found
+#define DEFINE_GAMESTATE_INTERNAL(typeName, enumName) \
+ if (gameStateInitFunc == typeName##_Init) { \
+ return &gGameStateOverlayTable[enumName]; \
}
+#define DEFINE_GAMESTATE(typeName, enumName, name) DEFINE_GAMESTATE_INTERNAL(typeName, enumName)
+#include "tables/gamestate_table.h"
+#undef DEFINE_GAMESTATE
+#undef DEFINE_GAMESTATE_INTERNAL
LOG_ADDRESS("game_init_func", gameStateInitFunc, "../graph.c", 696);
return NULL;
@@ -421,16 +412,14 @@ void Graph_ThreadEntry(void* arg0) {
GraphicsContext gfxCtx;
GameState* gameState;
u32 size;
- GameStateOverlay* nextOvl;
+ GameStateOverlay* nextOvl = &gGameStateOverlayTable[GAMESTATE_SETUP];
GameStateOverlay* ovl;
char faultMsg[0x50];
- nextOvl = &gGameStateOverlayTable[0];
-
osSyncPrintf("グラフィックスレッド実行開始\n"); // "Start graphic thread execution"
Graph_Init(&gfxCtx);
- while (nextOvl) {
+ while (nextOvl != NULL) {
ovl = nextOvl;
Overlay_LoadGameState(ovl);