oot/include/z64game.h
mzxrules 4639914583
Reduce overlay dependencies on global.h (6) (#2468)
* add some headers, split some of z64.h

* MtxClear -> IdentityMtx

* more misc cleanups

* move D_80116280 to header, fix build issue

* remove z64.h

* Revert "MtxClear -> IdentityMtx"

This reverts commit 8fc74c0672f72b91ae4068e73228fc46fe9465d4.

* split z64path.h and z64skin.h functions

* z64face_reaction.h

* cleanup overlay global references

* trim padding

* bss
2025-02-13 18:15:14 -05:00

67 lines
2.2 KiB
C

#ifndef Z64GAME_H
#define Z64GAME_H
// This file is named "game" after game.c for now, this may change later with the system name
#include "ultra64/ultratypes.h"
#include "libu64/pad.h"
#include "tha.h"
struct GraphicsContext;
typedef struct GameAllocEntry {
/* 0x00 */ struct GameAllocEntry* next;
/* 0x04 */ struct GameAllocEntry* prev;
/* 0x08 */ u32 size;
/* 0x0C */ u32 unk_0C;
} GameAllocEntry; // size = 0x10
typedef struct GameAlloc {
/* 0x00 */ GameAllocEntry base;
/* 0x10 */ GameAllocEntry* head;
} GameAlloc; // size = 0x14
// Used in Graph_GetNextGameState in graph.c
#define DEFINE_GAMESTATE_INTERNAL(typeName, enumName) enumName,
#define DEFINE_GAMESTATE(typeName, enumName, name) DEFINE_GAMESTATE_INTERNAL(typeName, enumName)
typedef enum GameStateId {
#include "tables/gamestate_table.h"
GAMESTATE_ID_MAX
} GameStateId;
#undef DEFINE_GAMESTATE
#undef DEFINE_GAMESTATE_INTERNAL
struct GameState;
typedef void (*GameStateFunc)(struct GameState* gameState);
typedef struct GameState {
/* 0x00 */ struct GraphicsContext* gfxCtx;
/* 0x04 */ GameStateFunc main;
/* 0x08 */ GameStateFunc destroy; // "cleanup"
/* 0x0C */ GameStateFunc init;
/* 0x10 */ u32 size;
/* 0x14 */ Input input[MAXCONTROLLERS];
/* 0x74 */ TwoHeadArena tha;
/* 0x84 */ GameAlloc alloc;
/* 0x98 */ u32 running;
/* 0x9C */ u32 frames;
/* 0xA0 */ u32 inPreNMIState;
} GameState; // size = 0xA4
void GameState_ReqPadData(GameState* gameState);
void GameState_Update(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);
u32 GameState_IsRunning(GameState* gameState);
#if DEBUG_FEATURES
void* GameState_Alloc(GameState* gameState, size_t size, const char* file, int line);
#define GAME_STATE_ALLOC(gameState, size, file, line) GameState_Alloc(gameState, size, file, line)
#else
#define GAME_STATE_ALLOC(gameState, size, file, line) THA_AllocTailAlign16(&(gameState)->tha, size)
#endif
#endif