summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAnghelo Carvajal <angheloalf95@gmail.com>2023-08-09 20:51:25 -0400
committerGitHub <noreply@github.com>2023-08-09 20:51:25 -0400
commitc7729c05c07cf0d60a70cd6c4f456069604a1f43 (patch)
tree00b8cfc29935ffad5d4081fc9e65c21d3059f8e0 /include
parentcfa703f013a1e595a418e47ac05df06e9ae4f9b8 (diff)
`game.c` OK (#37)
* C file * game_dt * game_ct * fix offsets and building * game_init_hyral and SetGameFrame * more funcs * game_main * game_get_controller and func_800D2E00_jp * Input * game_draw_last * a few attempts * game_draw_first * improve func_800D2E58_jp a bit * format * migrate data and bss * what * whoops * name bss * minor cleanup * match game.c Co-authored-by: Derek Hensley <hensley.derek58@gmail.com> * fix malloc function wrongly named * Update src/code/game.c Co-authored-by: Derek Hensley <hensley.derek58@gmail.com> * review --------- Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/67E840.h8
-rw-r--r--include/69E2C0.h7
-rw-r--r--include/6E0F50.h2
-rw-r--r--include/6EDD10.h2
-rw-r--r--include/TwoHeadArena.h3
-rw-r--r--include/attributes.h12
-rw-r--r--include/code_variables.h18
-rw-r--r--include/debug.h3
-rw-r--r--include/game.h104
-rw-r--r--include/gfx.h39
-rw-r--r--include/gfxalloc.h4
-rw-r--r--include/graph.h6
-rw-r--r--include/m_controller.h6
-rw-r--r--include/padmgr.h5
-rw-r--r--include/speed_meter.h18
-rw-r--r--include/unknown_structs.h7
16 files changed, 174 insertions, 70 deletions
diff --git a/include/67E840.h b/include/67E840.h
index aa16414..cefd38d 100644
--- a/include/67E840.h
+++ b/include/67E840.h
@@ -3,6 +3,8 @@
#include "ultra64.h"
+struct GameState;
+
// void func_8005ABA0_jp();
// void func_8005ABE0_jp();
// void func_8005ACA8_jp();
@@ -176,10 +178,10 @@
// void func_8005EE00_jp();
// void func_8005EE20_jp();
// void func_8005EEA0_jp();
-// void mBGM_main();
+void mBGM_main(struct GameState* gameState);
// void mBGM_ct();
-// void func_8005F020_jp();
-// void func_8005F13C_jp();
+void func_8005F020_jp(void);
+void mBGM_cleanup(void);
// void func_8005F250_jp();
#endif
diff --git a/include/69E2C0.h b/include/69E2C0.h
index 313f773..f95158e 100644
--- a/include/69E2C0.h
+++ b/include/69E2C0.h
@@ -3,15 +3,18 @@
#include "ultra64.h"
+struct Input;
+struct GraphicsContext;
+
// void func_8007A620_jp();
// void func_8007A630_jp();
// void Debug_Print_output();
// void func_8007A74C_jp();
// void Debug_Print2_output();
-// void Debug_mode_input();
+void Debug_mode_input(struct Input *input);
// void Debug_mode_output_sub();
// void Debug_mode_zelda_malloc_info_output();
-// void Debug_mode_output();
+void Debug_mode_output(struct GraphicsContext* gfxCtx);
// void func_8007B410_jp();
// void func_8007B44C_jp();
// void func_8007B49C_jp();
diff --git a/include/6E0F50.h b/include/6E0F50.h
index f9b1c52..888d213 100644
--- a/include/6E0F50.h
+++ b/include/6E0F50.h
@@ -38,7 +38,7 @@
// void fade_black_draw();
// void func_800BE094_jp();
// void func_800BE0E4_jp();
-// void func_800BE12C_jp();
+Gfx *func_800BE12C_jp(Gfx *gfx, s32 arg1, s32 arg2, s32 arg3, s32 arg4);
// void func_800BE184_jp();
// void func_800BE1D4_jp();
// void func_800BE27C_jp();
diff --git a/include/6EDD10.h b/include/6EDD10.h
index 1aa2f79..087c3af 100644
--- a/include/6EDD10.h
+++ b/include/6EDD10.h
@@ -13,6 +13,6 @@
// void func_800CA2DC_jp();
// void func_800CA350_jp();
// void func_800CA570_jp();
-// void mTM_time();
+void mTM_time(void);
#endif
diff --git a/include/TwoHeadArena.h b/include/TwoHeadArena.h
index d5d0e0e..e5b62e2 100644
--- a/include/TwoHeadArena.h
+++ b/include/TwoHeadArena.h
@@ -2,8 +2,9 @@
#define TWO_HEAD_ARENA_H
#include "ultra64.h"
+#include "libc/stdint.h"
-typedef struct {
+typedef struct TwoHeadArena {
/* 0x00 */ size_t size;
/* 0x04 */ void* start;
/* 0x08 */ void* head;
diff --git a/include/attributes.h b/include/attributes.h
index c2045fa..69ce0b9 100644
--- a/include/attributes.h
+++ b/include/attributes.h
@@ -10,7 +10,9 @@
#ifndef FALLTHROUGH
- #if __STDC_VERSION__ >= 202000L
+ #ifdef PERMUTER
+ #define FALLTHROUGH
+ #elif __STDC_VERSION__ >= 202000L
#define FALLTHROUGH [[fallthrough]]
#else
#define FALLTHROUGH __attribute__((fallthrough))
@@ -18,7 +20,9 @@
#endif
#ifndef NORETURN
- #if __STDC_VERSION__ >= 202000L
+ #ifdef PERMUTER
+ #define NORETURN
+ #elif __STDC_VERSION__ >= 202000L
#define NORETURN [[noreturn]]
#elif __STDC_VERSION__ >= 201112L
#define NORETURN _Noreturn
@@ -28,7 +32,9 @@
#endif
#ifndef UNUSED
- #if __STDC_VERSION__ >= 202000L
+ #ifdef PERMUTER
+ #define UNUSED
+ #elif __STDC_VERSION__ >= 202000L
#define UNUSED [[maybe_unused]]
#else
#define UNUSED __attribute__((unused))
diff --git a/include/code_variables.h b/include/code_variables.h
index 111a6a6..6ed39f3 100644
--- a/include/code_variables.h
+++ b/include/code_variables.h
@@ -810,7 +810,7 @@
// extern UNK_TYPE D_8010EF60_jp;
// extern UNK_TYPE D_8010EF70_jp;
// extern UNK_TYPE D_8010EF80_jp;
-// extern UNK_TYPE gamePT;
+
// extern UNK_TYPE D_8010EFA0_jp;
extern vs32 D_8010EFB0_jp; // TODO: Determine where this goes
// extern UNK_TYPE D_8010EFB8_jp;
@@ -842,7 +842,7 @@ extern vs32 D_8010EFB0_jp; // TODO: Determine where this goes
// extern UNK_TYPE D_8010FD54_jp;
// extern UNK_TYPE D_8010FD58_jp;
// extern UNK_TYPE D_8010FD5C_jp;
-// extern UNK_TYPE D_8010FD60_jp;
+extern s32 zurumode_flag;
// extern UNK_TYPE D_8010FD70_jp;
// extern UNK_TYPE D_80110000_jp;
// extern UNK_TYPE D_80110D70_jp;
@@ -1512,9 +1512,7 @@ extern vs32 D_8010EFB0_jp; // TODO: Determine where this goes
// extern UNK_TYPE RO_STR_80117C80_jp;
// extern UNK_TYPE RO_STR_80117CA0_jp;
// extern UNK_TYPE RO_STR_80117CC0_jp;
-// extern UNK_TYPE RO_80117CE0_jp;
-// extern UNK_TYPE RO_STR_80117D00_jp;
-// extern UNK_TYPE RO_STR_80117D0C_jp;
+
// extern UNK_TYPE RO_STR_80117D20_jp;
// extern UNK_TYPE RO_STR_80117D3C_jp;
// extern UNK_TYPE RO_STR_80117D50_jp;
@@ -1848,7 +1846,7 @@ extern vs32 D_8010EFB0_jp; // TODO: Determine where this goes
// extern UNK_TYPE B_80138818_jp;
// extern UNK_TYPE B_80138E40_jp;
// extern UNK_TYPE B_80138E44_jp;
-// extern UNK_TYPE B_80138E50_jp;
+extern struct_debug_mode *debug_mode;
// extern UNK_TYPE debug_display;
// extern UNK_TYPE B_80138E70_jp;
// extern UNK_TYPE B_80138E73_jp;
@@ -2006,13 +2004,7 @@ extern vs32 D_8010EFB0_jp; // TODO: Determine where this goes
// extern UNK_TYPE B_80144FB8_jp;
// extern UNK_TYPE B_80144FC0_jp;
// extern UNK_TYPE B_80145014_jp;
-// extern UNK_TYPE B_80145020_jp;
-// extern UNK_TYPE B_80145040_jp;
-// extern UNK_TYPE B_80145044_jp;
-// extern UNK_TYPE B_80145048_jp;
-// extern UNK_TYPE B_FLT_8014504C_jp;
-// extern UNK_TYPE B_FLT_80145050_jp;
-// extern UNK_TYPE B_FLT_80145054_jp;
+
// extern UNK_TYPE B_80145060_jp;
// extern UNK_TYPE B_80145070_jp;
// extern UNK_TYPE B_80145080_jp;
diff --git a/include/debug.h b/include/debug.h
index 81e2cf9..6769129 100644
--- a/include/debug.h
+++ b/include/debug.h
@@ -2,8 +2,9 @@
#define DEBUG_H
#include "ultra64.h"
+#include "attributes.h"
-// void _dbg_hungup();
+void _dbg_hungup(const char *filename, int line) NORETURN;
// void Reset();
#endif
diff --git a/include/game.h b/include/game.h
index 49eca3f..3795c9c 100644
--- a/include/game.h
+++ b/include/game.h
@@ -2,31 +2,87 @@
#define GAME_H
#include "ultra64.h"
-#include "gfx.h"
+#include "TwoHeadArena.h"
+#include "gamealloc.h"
+#include "padutils.h"
+#include "unk.h"
+
+struct GameState;
+struct GraphicsContext;
+struct struct_80145020_jp;
+
+
+typedef void (*GameStateFunc)(struct GameState* gameState);
typedef struct GameState {
- /* 0x00 */ GraphicsContext* gfxCtx;
- /* 0x04 */ char pad[0x74];
- /* 0x74 */ TwoHeadArena heap;
-} GameState; // size = ??
-
-// void func_800D2E00_jp();
-// void func_800D2E58_jp();
-// void game_debug_draw_last();
-// void game_draw_first();
-// void game_draw_last();
-// void game_get_controller();
-// void SetGameFrame();
-// void game_main();
-// void game_init_hyral();
-// void game_resize_hyral();
-// void game_ct();
-// void game_dt();
-// void game_get_next_game_init();
-// void game_get_next_game_class_size();
-// void game_is_doing();
-// void game_getFreeBytes();
-// void game_goto_next_game_play();
-// void game_goto_next_game_name_famicom_emu();
+ /* 0x00 */ struct GraphicsContext* gfxCtx;
+ /* 0x04 */ GameStateFunc main;
+ /* 0x08 */ GameStateFunc destroy;
+ /* 0x0C */ GameStateFunc init;
+ /* 0x10 */ size_t size;
+ /* 0x14 */ Input input[MAXCONTROLLERS];
+ /* 0x74 */ s32 unk_74;
+ /* 0x78 */ TwoHeadArena heap;
+ /* 0x88 */ GameAlloc alloc;
+ /* 0x9C */ UNK_TYPE1 unk_9C[0x3];
+ /* 0x9F */ u8 running;
+ /* 0xA0 */ s32 unk_A0;
+} GameState; // size >= 0xA4, size <= 0xE0
+
+void func_800D2E00_jp(GameState* gameState);
+void func_800D2E58_jp(u16 button, Gfx** gfxP);
+void game_debug_draw_last(GameState* gameState, struct GraphicsContext* gfxCtx);
+void game_draw_first(struct GraphicsContext* gfxCtx);
+void game_draw_last(struct GraphicsContext* gfxCtx);
+void game_get_controller(GameState* gameState);
+void SetGameFrame(s32 divisor);
+void game_main(GameState* gameState);
+void game_init_hyral(GameState* gameState, size_t size);
+void game_resize_hyral(GameState* gameState, size_t size);
+void game_ct(GameState* gameState, GameStateFunc init, struct GraphicsContext* gfxCtx);
+void game_dt(GameState* gameState);
+GameStateFunc game_get_next_game_init(GameState* gameState);
+size_t game_get_next_game_class_size(GameState* gameState);
+s32 game_is_doing(GameState* gameState);
+s32 game_getFreeBytes(GameState* gameState);
+void game_goto_next_game_play(GameState* gameState);
+void game_goto_next_game_name_famicom_emu(GameState* gameState);
+
+
+// .data
+
+extern GameState* gamePT;
+
+// .bss
+
+extern struct struct_80145020_jp B_80145020_jp;
+extern s16 B_80145040_jp;
+extern GameState* game_class_p;
+extern u8 game_GameFrame;
+extern f32 game_GameFrameF;
+extern f32 game_GameFrame_2F;
+extern f32 game_GameFrame__1F;
+
+
+#define CONTROLLER1(gameState) (&(gameState)->input[0])
+#define CONTROLLER2(gameState) (&(gameState)->input[1])
+#define CONTROLLER3(gameState) (&(gameState)->input[2])
+#define CONTROLLER4(gameState) (&(gameState)->input[3])
+
+#define STOP_GAMESTATE(curState) \
+ do { \
+ GameState* state = curState; \
+ \
+ state->running = false; \
+ } while(0)
+
+#define SET_NEXT_GAMESTATE(curState, nextInit, nextSize) \
+ do { \
+ GameState* state = curState; \
+ \
+ (state)->init = nextInit; \
+ (state)->size = nextSize; \
+ } while (0)
+
#endif
diff --git a/include/gfx.h b/include/gfx.h
index 8d46a1a..3d693fe 100644
--- a/include/gfx.h
+++ b/include/gfx.h
@@ -2,28 +2,51 @@
#define GFX_H
#include "ultra64.h"
+#include "attributes.h"
+#include "alignment.h"
#include "THA_GA.h"
+#include "unk.h"
#define GRAPH_ALLOC(gfxCtx, size) ((void*)((gfxCtx)->polyOpa.d = (Gfx*)((u8*)(gfxCtx)->polyOpa.d - ALIGN16(size))))
typedef struct GraphicsContext {
- /* 0x000 */ char pad[0x290];
- /* 0x298 */ TwoHeadGfxArena polyOpa;
- /* 0x2A8 */ TwoHeadGfxArena polyXlu;
-} GraphicsContext; // size = ??
+ /* 0x000 */ UNK_TYPE1 unk_000[0x8];
+ /* 0x008 */ UNK_PTR unk_008;
+ /* 0x00C */ UNK_TYPE1 unk_00C[0x250];
+ /* 0x25C */ OSViMode* unk_25C;
+ /* 0x260 */ UNK_TYPE1 unk_260[0x20];
+ /* 0x280 */ TwoHeadGfxArena overlay;
+ /* 0x290 */ TwoHeadGfxArena polyOpa;
+ /* 0x2A0 */ TwoHeadGfxArena polyXlu;
+ /* 0x2B0 */ TwoHeadGfxArena unk_2B0;
+ /* 0x2C0 */ TwoHeadGfxArena unk_2C0;
+ /* 0x2D0 */ TwoHeadGfxArena unk_2D0;
+ /* 0x2E0 */ UNK_TYPE1 unk_2E0[0x4];
+ /* 0x2E4 */ s32 unk_2E4;
+ /* 0x2E8 */ UNK_TYPE1 unk_2E8[0x4];
+ /* 0x2EC */ s32 unk_2EC;
+ /* 0x2F0 */ u8 unk_2F0;
+ /* 0x2F1 */ UNK_TYPE1 unk_2F1[0x1];
+ /* 0x2F2 */ u8 unk_2F2;
+ /* 0x2F3 */ UNK_TYPE1 unk_2F3[0x1];
+ /* 0x2F4 */ UNK_TYPE1 unk_2F4[0x8];
+ /* 0x2FC */ f32 unk_2FC;
+ /* 0x300 */ f32 unk_300;
+} GraphicsContext; // size >= 0x304
-#define WORK_DISP __gfxCtx->work.p
+#define OVERLAY_DISP __gfxCtx->overlay.p
#define POLY_OPA_DISP __gfxCtx->polyOpa.p
#define POLY_XLU_DISP __gfxCtx->polyXlu.p
-#define OVERLAY_DISP __gfxCtx->overlay.p
-#define DEBUG_DISP __gfxCtx->debug.p
+#define UNK_2B0_DISP __gfxCtx->unk_2B0.p
+#define UNK_2C0_DISP __gfxCtx->unk_2C0.p
+#define UNK_2D0_DISP __gfxCtx->unk_2D0.p
// __gfxCtx shouldn't be used directly.
// Use the DISP macros defined above when writing to display buffers.
#define OPEN_DISPS(gfxCtx) \
{ \
GraphicsContext* __gfxCtx = gfxCtx; \
- s32 __dispPad
+ s32 __dispPad UNUSED
#define CLOSE_DISPS(gfxCtx) \
(void)0; \
diff --git a/include/gfxalloc.h b/include/gfxalloc.h
index 1b48ada..dab0fb6 100644
--- a/include/gfxalloc.h
+++ b/include/gfxalloc.h
@@ -3,8 +3,8 @@
#include "ultra64.h"
-// void gfxopen();
-// void gfxclose();
+Gfx* gfxopen(Gfx* gfxHead);
+void gfxclose(Gfx* gfxHead, Gfx* gfx);
// void gfxalloc();
#endif
diff --git a/include/graph.h b/include/graph.h
index 053f558..210aea4 100644
--- a/include/graph.h
+++ b/include/graph.h
@@ -3,14 +3,16 @@
#include "ultra64.h"
+struct GraphicsContext;
+
// void func_800D38E0_jp();
// void graph_setup_double_buffer();
// void game_get_next_game_dlftbl();
// void func_800D3C94_jp();
// void graph_ct();
// void graph_dt();
-// void func_800D3E14_jp();
-// void func_800D3E40_jp();
+void func_800D3E14_jp(struct GraphicsContext *gfxCtx);
+void func_800D3E40_jp(struct GraphicsContext *gfxCtx);
// void graph_task_set00();
// void graph_draw_finish();
// void graph_main();
diff --git a/include/m_controller.h b/include/m_controller.h
index 72bf692..7370fdc 100644
--- a/include/m_controller.h
+++ b/include/m_controller.h
@@ -3,8 +3,10 @@
#include "ultra64.h"
-// void mCon_ct();
-// void mCon_dt();
+struct GameState;
+
+void mCon_ct(struct GameState* gameState);
+void mCon_dt(struct GameState* gameState);
// void mCon_calc();
// void mCon_main();
// void chkButton();
diff --git a/include/padmgr.h b/include/padmgr.h
index 27f10d2..887188c 100644
--- a/include/padmgr.h
+++ b/include/padmgr.h
@@ -2,6 +2,7 @@
#define PADMGR_H
#include "ultra64.h"
+#include "padutils.h"
// void padmgr_LockSerialMesgQ();
// void padmgr_UnlockSerialMesgQ();
@@ -17,8 +18,8 @@
// void padmgr_HandleRetraceMsg();
// void padmgr_HandlePreNMIMsg();
// void padmgr_RequestPadData_NonLock();
-// void padmgr_RequestPadData();
-// void padmgr_ClearPadData();
+void padmgr_RequestPadData(Input inputs[4], s32 arg1);
+void padmgr_ClearPadData(Input inputs[4]);
// void padmgr_MainProc();
// void padmgr_Init();
// void func_800D763C_jp();
diff --git a/include/speed_meter.h b/include/speed_meter.h
index 16772bf..09b9dcc 100644
--- a/include/speed_meter.h
+++ b/include/speed_meter.h
@@ -2,15 +2,23 @@
#define SPEED_METER_H
#include "ultra64.h"
+#include "unk.h"
+
+struct GameState;
+struct GraphicsContext;
+
+typedef struct struct_80145020_jp {
+ /* 0x00 */ UNK_TYPE1 unk_00[0x20];
+} struct_80145020_jp; // size <= 0x20
// void func_800D88A0_jp();
-// void func_800D88B0_jp();
-// void func_800D88D4_jp();
-// void func_800D88E0_jp();
-// void func_800D8A54_jp();
+void func_800D88B0_jp(struct_80145020_jp *arg0);
+void func_800D88D4_jp(struct_80145020_jp *arg0);
+void func_800D88E0_jp(struct_80145020_jp *arg0);
+void func_800D8A54_jp(struct_80145020_jp *arg0, struct GraphicsContext* gfxCtx);
// void func_800D8DD4_jp();
// void func_800D8E18_jp();
-// void func_800D9018_jp();
+void func_800D9018_jp(struct_80145020_jp *arg0, struct GraphicsContext* gfxCtx, struct GameState *gameState);
// void func_800D93F4_jp();
#endif
diff --git a/include/unknown_structs.h b/include/unknown_structs.h
index a10218f..9564498 100644
--- a/include/unknown_structs.h
+++ b/include/unknown_structs.h
@@ -6,5 +6,12 @@
#include "libc/stdbool.h"
#include "unk.h"
+typedef struct struct_debug_mode {
+ /* 0x000 */ UNK_TYPE1 unk_000[0xD4];
+ /* 0x0D4 */ s16 unk_0D4;
+ /* 0x0D6 */ UNK_TYPE1 unk_0D6[0x2];
+ /* 0x0D8 */ UNK_TYPE1 unk_0D8[0x38];
+ /* 0x110 */ s16 gameframe;
+} struct_debug_mode; // size >= 0x114
#endif