1
Fork 0
sm64/src/game/game_init.h

92 lines
2.5 KiB
C
Raw Normal View History

2020-06-02 12:44:34 -04:00
#ifndef GAME_INIT_H
#define GAME_INIT_H
2019-08-25 00:46:40 -04:00
2020-06-02 12:44:34 -04:00
#include <PR/ultratypes.h>
#include <PR/gbi.h>
#include <PR/os_cont.h>
#include <PR/os_message.h>
#include "types.h"
2019-08-25 00:46:40 -04:00
#include "memory.h"
2019-10-05 15:08:05 -04:00
#ifdef USE_SYSTEM_MALLOC
#define GFX_POOL_SIZE 1
#else
2021-07-12 23:17:54 -04:00
#define GFX_POOL_SIZE 6400 // Size of how large the master display list (gDisplayListHead) can be
#endif
2020-06-02 12:44:34 -04:00
struct GfxPool {
Gfx buffer[GFX_POOL_SIZE];
struct SPTask spTask;
};
2019-08-25 00:46:40 -04:00
struct DemoInput
2019-10-05 15:08:05 -04:00
{
2019-11-03 14:36:27 -05:00
u8 timer; // time until next input. if this value is 0, it means the demo is over
2019-10-05 15:08:05 -04:00
s8 rawStickX;
s8 rawStickY;
2019-11-03 14:36:27 -05:00
u8 buttonMask;
2019-08-25 00:46:40 -04:00
};
extern struct Controller gControllers[3];
extern OSContStatus gControllerStatuses[4];
extern OSContPad gControllerPads[4];
extern OSMesgQueue gGameVblankQueue;
2021-07-12 23:17:54 -04:00
extern OSMesgQueue gGfxVblankQueue;
extern OSMesg gGameMesgBuf[1];
extern OSMesg gGfxMesgBuf[1];
2019-08-25 00:46:40 -04:00
extern struct VblankHandler gGameVblankHandler;
2019-11-03 14:36:27 -05:00
extern uintptr_t gPhysicalFrameBuffers[3];
extern uintptr_t gPhysicalZBuffer;
2021-07-12 23:17:54 -04:00
extern void *gMarioAnimsMemAlloc;
extern void *gDemoInputsMemAlloc;
2019-08-25 00:46:40 -04:00
extern struct SPTask *gGfxSPTask;
#ifdef USE_SYSTEM_MALLOC
extern struct AllocOnlyPool *gGfxAllocOnlyPool;
extern Gfx *gDisplayListHeadInChunk;
extern Gfx *gDisplayListEndInChunk;
#else
2019-08-25 00:46:40 -04:00
extern Gfx *gDisplayListHead;
extern u8 *gGfxPoolEnd;
#endif
2019-08-25 00:46:40 -04:00
extern struct GfxPool *gGfxPool;
extern u8 gControllerBits;
extern s8 gEepromProbe;
2020-12-03 14:26:38 -05:00
extern void (*gGoddardVblankCallback)(void);
2019-08-25 00:46:40 -04:00
extern struct Controller *gPlayer1Controller;
extern struct Controller *gPlayer2Controller;
extern struct Controller *gPlayer3Controller;
extern struct DemoInput *gCurrDemoInput;
extern u16 gDemoInputListID;
extern struct DemoInput gRecordedDemoInput;
// this area is the demo input + the header. when the demo is loaded in, there is a header the size
// of a single word next to the input list. this word is the current ID count.
2021-07-12 23:17:54 -04:00
extern struct DmaHandlerList gMarioAnimsBuf;
extern struct DmaHandlerList gDemoInputsBuf;
2019-08-25 00:46:40 -04:00
extern u8 gMarioAnims[];
extern u8 gDemoInputs[];
2021-07-12 23:17:54 -04:00
extern u16 sRenderingFrameBuffer;
2020-04-03 14:57:26 -04:00
extern u32 gGlobalTimer;
2020-06-02 12:44:34 -04:00
void setup_game_memory(void);
void thread5_game_loop(UNUSED void *arg);
void clear_frame_buffer(s32 color);
void clear_viewport(Vp *viewport, s32 color);
2020-04-03 14:57:26 -04:00
void make_viewport_clip_rect(Vp *viewport);
2021-07-12 23:17:54 -04:00
void init_rcp(void);
2020-06-02 12:44:34 -04:00
void end_master_display_list(void);
2021-07-12 23:17:54 -04:00
void render_init(void);
void select_gfx_pool(void);
2020-06-02 12:44:34 -04:00
void display_and_vsync(void);
2020-04-03 14:57:26 -04:00
#ifdef USE_SYSTEM_MALLOC
Gfx **alloc_next_dl(void);
#define gDisplayListHead (*(gDisplayListEndInChunk - gDisplayListHeadInChunk >= 2 ? &gDisplayListHeadInChunk : alloc_next_dl()))
#endif
2020-06-02 12:44:34 -04:00
#endif // GAME_INIT_H