summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAnghelo Carvajal <angheloalf95@gmail.com>2023-06-06 08:54:18 -0400
committerGitHub <noreply@github.com>2023-06-06 08:54:18 -0400
commita0701c170b5861572eab29bc9f0aed92aa0e11d9 (patch)
tree6c058b279148e7d76e8a586c3bc4d5e1f5f183de /include
parent4cce44466170344b68b146cfbec6d9597d0910bb (diff)
`z64game.h` (#1250)
* z64game.h * grrrrr * fix missing stuff * Update include/z64game.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update include/z64game.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * review * global.h to the top * reiew * fix --------- Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>
Diffstat (limited to 'include')
-rw-r--r--include/functions.h19
-rw-r--r--include/macros.h15
-rw-r--r--include/variables.h5
-rw-r--r--include/z64.h49
-rw-r--r--include/z64game.h104
-rw-r--r--include/z_prenmi.h10
-rw-r--r--include/z_title_setup.h8
7 files changed, 115 insertions, 95 deletions
diff --git a/include/functions.h b/include/functions.h
index 71aa14729..626bfc261 100644
--- a/include/functions.h
+++ b/include/functions.h
@@ -1874,25 +1874,6 @@ void AudioMgr_ThreadEntry(void* arg);
void AudioMgr_Unlock(AudioMgr* audioMgr);
void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedContext* sched, IrqMgr* irqMgr);
-void Game_UpdateFramerateVariables(s32 divisor);
-void Game_SetFramerateDivisor(GameState* gameState, s32 divisor);
-void GameState_SetFBFilter(Gfx** gfx, void* zbuffer);
-void Game_Nop80173534(GameState* gameState);
-void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx);
-void GameState_SetFrameBuffer(GraphicsContext* gfxCtx);
-void func_801736DC(GraphicsContext* gfxCtx);
-void Game_UpdateInput(GameState* gameState);
-void Game_Update(GameState* gameState);
-void Game_IncrementFrameCount(GameState* gameState);
-void GameState_InitArena(GameState* gameState, size_t size);
-void GameState_Realloc(GameState* gameState, size_t size);
-void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* gfxCtx);
-void GameState_Destroy(GameState* gameState);
-GameStateFunc GameState_GetInit(GameState* gameState);
-size_t GameState_GetSize(GameState* gameState);
-u32 GameState_IsRunning(GameState* gameState);
-s32 GameState_GetArenaSize(GameState* gameState);
-s32 func_80173B48(GameState* gameState);
void GameAlloc_Log(GameAlloc* this);
void* GameAlloc_Malloc(GameAlloc* this, size_t size);
void GameAlloc_Free(GameAlloc* this, void* data);
diff --git a/include/macros.h b/include/macros.h
index 25ccb3d37..9f2305e01 100644
--- a/include/macros.h
+++ b/include/macros.h
@@ -28,21 +28,6 @@
#define GET_ACTIVE_CAM(play) ((play)->cameraPtrs[(play)->activeCamId])
-#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)
-
#define GET_PLAYER(play) ((Player*)(play)->actorCtx.actorLists[ACTORCAT_PLAYER].first)
#define GET_FIRST_ENEMY(play) ((Actor*)(play)->actorCtx.actorLists[ACTORCAT_ENEMY].first)
diff --git a/include/variables.h b/include/variables.h
index fef772123..ba1548f0f 100644
--- a/include/variables.h
+++ b/include/variables.h
@@ -745,10 +745,7 @@ extern Input* D_801D0D60;
// extern UNK_TYPE2 D_801D14E4;
// extern UNK_TYPE2 D_801D14E8;
// extern UNK_TYPE4 D_801D14F0;
-extern s32 gFramerateDivisor;
-extern f32 gFramerateDivisorF;
-extern f32 gFramerateDivisorHalf;
-extern f32 gFramerateDivisorThird;
+
extern u32 retryCount;
extern u32 cfbIdx[3];
extern s32 gScreenWidth;
diff --git a/include/z64.h b/include/z64.h
index 637f28dc4..1b9cabdc9 100644
--- a/include/z64.h
+++ b/include/z64.h
@@ -44,6 +44,7 @@
#include "z64effect.h"
#include "z64frameadvance.h"
#include "z64game_over.h"
+#include "z64game.h"
#include "z64interface.h"
#include "z64item.h"
#include "z64light.h"
@@ -407,54 +408,6 @@ typedef struct {
/* 0x844 */ void* fb;
} FaultThreadStruct; // size = 0x848
-struct GameState;
-
-typedef void (*GameStateFunc)(struct GameState* gameState);
-
-typedef struct {
- /* 0x00 */ void* loadedRamAddr;
- /* 0x04 */ uintptr_t vromStart; // if applicable
- /* 0x08 */ uintptr_t vromEnd; // if applicable
- /* 0x0C */ void* vramStart; // if applicable
- /* 0x10 */ void* vramEnd; // if applicable
- /* 0x14 */ UNK_PTR unk_14;
- /* 0x18 */ GameStateFunc init; // initializes and executes the given context
- /* 0x1C */ GameStateFunc destroy; // deconstructs the context, and sets the next context to load
- /* 0x20 */ UNK_PTR unk_20;
- /* 0x24 */ UNK_PTR unk_24;
- /* 0x28 */ UNK_TYPE unk_28;
- /* 0x2C */ size_t instanceSize;
-} GameStateOverlay; // size = 0x30
-
-typedef struct GameAllocEntry {
- /* 0x0 */ struct GameAllocEntry* next;
- /* 0x4 */ struct GameAllocEntry* prev;
- /* 0x8 */ size_t size;
- /* 0xC */ u32 unk_0C;
-} GameAllocEntry; // size = 0x10
-
-typedef struct GameAlloc {
- /* 0x00 */ GameAllocEntry base;
- /* 0x10 */ GameAllocEntry* head;
-} GameAlloc; // size = 0x14
-
-typedef struct GameState {
- /* 0x00 */ GraphicsContext* gfxCtx;
- /* 0x04 */ GameStateFunc main;
- /* 0x08 */ GameStateFunc destroy;
- /* 0x0C */ GameStateFunc init; // Usually the current game state's init, though after stopping, the graph thread will look here to determine the next game state to load.
- /* 0x10 */ size_t size;
- /* 0x14 */ Input input[MAXCONTROLLERS];
- /* 0x74 */ TwoHeadArena heap;
- /* 0x84 */ GameAlloc alloc;
- /* 0x98 */ UNK_TYPE1 pad98[0x3];
- /* 0x9B */ u8 running; // If 0, switch to next game state
- /* 0x9C */ u32 frames;
- /* 0xA0 */ u8 padA0[0x2];
- /* 0xA2 */ u8 framerateDivisor; // game speed?
- /* 0xA3 */ u8 unk_A3;
-} GameState; // size = 0xA4
-
struct PlayState;
typedef s32 (*ColChkResetFunc)(struct PlayState*, Collider*);
diff --git a/include/z64game.h b/include/z64game.h
new file mode 100644
index 000000000..c5551edc7
--- /dev/null
+++ b/include/z64game.h
@@ -0,0 +1,104 @@
+#ifndef Z64_GAME_H
+#define Z64_GAME_H
+
+#include "ultra64.h"
+#include "libc/stdbool.h"
+#include "libc/stdint.h"
+#include "io/controller.h"
+#include "tha.h"
+#include "padmgr.h"
+
+struct GraphicsContext;
+struct GameState;
+
+
+typedef void (*GameStateFunc)(struct GameState* gameState);
+
+typedef struct {
+ /* 0x00 */ void* loadedRamAddr;
+ /* 0x04 */ uintptr_t vromStart; // if applicable
+ /* 0x08 */ uintptr_t vromEnd; // if applicable
+ /* 0x0C */ void* vramStart; // if applicable
+ /* 0x10 */ void* vramEnd; // if applicable
+ /* 0x14 */ UNK_PTR unk_14;
+ /* 0x18 */ GameStateFunc init; // initializes and executes the given context
+ /* 0x1C */ GameStateFunc destroy; // deconstructs the context, and sets the next context to load
+ /* 0x20 */ UNK_PTR unk_20;
+ /* 0x24 */ UNK_PTR unk_24;
+ /* 0x28 */ UNK_TYPE unk_28;
+ /* 0x2C */ size_t instanceSize;
+} GameStateOverlay; // size = 0x30
+
+typedef struct GameAllocEntry {
+ /* 0x0 */ struct GameAllocEntry* next;
+ /* 0x4 */ struct GameAllocEntry* prev;
+ /* 0x8 */ size_t size;
+ /* 0xC */ u32 unk_0C;
+} GameAllocEntry; // size = 0x10
+
+typedef struct GameAlloc {
+ /* 0x00 */ GameAllocEntry base;
+ /* 0x10 */ GameAllocEntry* head;
+} GameAlloc; // size = 0x14
+
+typedef struct GameState {
+ /* 0x00 */ struct GraphicsContext* gfxCtx;
+ /* 0x04 */ GameStateFunc main;
+ /* 0x08 */ GameStateFunc destroy;
+ /* 0x0C */ GameStateFunc init; // Usually the current game state's init, though after stopping, the graph thread will look here to determine the next game state to load.
+ /* 0x10 */ size_t size;
+ /* 0x14 */ Input input[MAXCONTROLLERS];
+ /* 0x74 */ TwoHeadArena heap;
+ /* 0x84 */ GameAlloc alloc;
+ /* 0x98 */ UNK_TYPE1 pad98[0x3];
+ /* 0x9B */ u8 running; // If 0, switch to next game state
+ /* 0x9C */ u32 frames;
+ /* 0xA0 */ u8 padA0[0x2];
+ /* 0xA2 */ u8 framerateDivisor;
+ /* 0xA3 */ u8 unk_A3;
+} GameState; // size = 0xA4
+
+
+void Game_UpdateFramerateVariables(s32 divisor);
+void Game_SetFramerateDivisor(GameState* gameState, s32 divisor);
+void GameState_SetFBFilter(Gfx** gfx, void* zbuffer);
+void Game_Nop80173534(GameState* gameState);
+void GameState_Draw(GameState* gameState, struct GraphicsContext* gfxCtx);
+void GameState_SetFrameBuffer(struct GraphicsContext* gfxCtx);
+void func_801736DC(struct GraphicsContext* gfxCtx);
+void Game_UpdateInput(GameState* gameState);
+void Game_Update(GameState* gameState);
+void Game_IncrementFrameCount(GameState* gameState);
+void GameState_InitArena(GameState* gameState, size_t size);
+void GameState_Realloc(GameState* gameState, size_t size);
+void GameState_Init(GameState* gameState, GameStateFunc init, struct GraphicsContext* gfxCtx);
+void GameState_Destroy(GameState* gameState);
+GameStateFunc GameState_GetInit(GameState* gameState);
+size_t GameState_GetSize(GameState* gameState);
+u32 GameState_IsRunning(GameState* gameState);
+s32 GameState_GetArenaSize(GameState* gameState);
+s32 func_80173B48(GameState* gameState);
+
+extern s32 gFramerateDivisor;
+extern f32 gFramerateDivisorF;
+extern f32 gFramerateDivisorHalf;
+extern f32 gFramerateDivisorThird;
+
+
+#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/z_prenmi.h b/include/z_prenmi.h
index 04c3f5f16..7be3eb16f 100644
--- a/include/z_prenmi.h
+++ b/include/z_prenmi.h
@@ -1,15 +1,15 @@
#ifndef Z64PRENMI_H
#define Z64PRENMI_H
-#include "global.h"
-
-void PreNMI_Destroy(GameState* thisx);
-void PreNMI_Init(GameState* thisx);
+#include "z64game.h"
typedef struct {
/* 0x00 */ GameState state;
/* 0xA4 */ u32 timer;
- /* 0xA8 */ UNK_TYPE4 unkA8;
+ /* 0xA8 */ s32 unk_A8;
} PreNMIState; // size = 0xAC
+void PreNMI_Destroy(GameState* thisx);
+void PreNMI_Init(GameState* thisx);
+
#endif
diff --git a/include/z_title_setup.h b/include/z_title_setup.h
index 3b299af97..1bd7c7d7d 100644
--- a/include/z_title_setup.h
+++ b/include/z_title_setup.h
@@ -1,13 +1,13 @@
#ifndef Z64TITLE_SETUP_H
#define Z64TITLE_SETUP_H
-#include "global.h"
-
-void Setup_Destroy(GameState* gameState);
-void Setup_Init(GameState* thisx);
+#include "z64game.h"
typedef struct {
/* 0x00 */ GameState state;
} SetupState; // size = 0xA4
+void Setup_Destroy(GameState* gameState);
+void Setup_Init(GameState* thisx);
+
#endif