SpaghettiKart
Loading...
Searching...
No Matches
Engine.h
Go to the documentation of this file.
1#pragma once
2
3#include "port/audio/HMAS.h"
4
5#define LOAD_ASSET(path) \
6(path == NULL ? NULL \
7 : (GameEngine_OTRSigCheck((const char*) path) ? ResourceGetDataByName((const char*) path) : path))
8 #define LOAD_ASSET_RAW(path) ResourceGetDataByName((const char*) path)
9
10 #ifdef __cplusplus
11 #include <vector>
12 #include <SDL2/SDL.h>
13#include <fast/Fast3dWindow.h>
14#include <fast/interpreter.h>
15#include "ship/Context.h"
16#include <unordered_map>
17
18#ifndef IDYES
19#define IDYES 6
20#endif
21#ifndef IDNO
22#define IDNO 7
23#endif
24
25#define SAMPLES_HIGH 448
26#define SAMPLES_LOW 432
27#define AUDIO_FRAMES_PER_UPDATE 2
28#define NUM_AUDIO_CHANNELS 2
29#define SAMPLES_PER_FRAME (SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 2)
30
31Fast::Interpreter* GetInterpreter();
32
33struct CtlEntry;
34struct AudioBankSample;
36
37class GameEngine {
38 public:
39 static GameEngine* Instance;
40
41 std::shared_ptr<Ship::Context> context;
42 std::vector<CtlEntry*> banksTable;
43 std::vector<std::string> sequenceTable;
44 std::vector<AudioSequenceData*> audioSequenceTable;
45 std::vector<std::string> archiveFiles;
46
47 ImFont* fontStandard;
48 ImFont* fontStandardLarger;
49 ImFont* fontStandardLargest;
50 ImFont* fontMono;
51 ImFont* fontMonoLarger;
52 ImFont* fontMonoLargest;
53
54 HMAS* gHMAS;
55
56 std::unordered_map<std::string, uint8_t> bankMapTable;
57 GameEngine();
58 static bool GenAssetFile();
59 static void Create();
60
61 void AudioInit();
62 static void HandleAudioThread();
63 static void StartAudioFrame();
64 static void EndAudioFrame();
65 static void AudioExit();
66
67
68
69 static uint32_t GetInterpolationFPS();
70 static uint32_t GetInterpolationFrameCount();
71 void StartFrame() const;
72 static void RunCommands(Gfx* pool, const std::vector<std::unordered_map<Mtx*, MtxF>>& mtx_replacements);
73 void ProcessFrame(void (*run_one_game_iter)()) const;
74 static void Destroy();
75 static void ProcessGfxCommands(Gfx* pool);
76 static uint8_t GetBankIdByName(const std::string& name);
77 static int ShowYesNoBox(const char* title, const char* box);
78 static void ShowMessage(const char* title, const char* message, SDL_MessageBoxFlags type = SDL_MESSAGEBOX_ERROR);
79 float OTRGetAspectRatio(void);
80 float OTRGetDimensionFromLeftEdge(float v);
81 float OTRGetDimensionFromRightEdge(float v);
82 int16_t OTRGetRectDimensionFromLeftEdge(float v);
83 int16_t OTRGetRectDimensionFromRightEdge(float v);
84 uint32_t OTRGetGameRenderWidth();
85 uint32_t OTRGetGameRenderHeight();
86 uint32_t OTRGetGameViewportWidth();
87 uint32_t OTRGetGameViewportHeight();
88 uint32_t OTRCalculateCenterOfAreaFromRightEdge(int32_t center);
89 uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center);
90 private:
91 ImFont* CreateFontWithSize(float size, std::string fontPath = "");
92};
93
94#endif
95
96#ifdef __cplusplus
97extern "C" {
98#endif
100uint32_t GameEngine_GetSampleRate();
103struct CtlEntry* GameEngine_LoadBank(uint8_t bankId);
104uint8_t GameEngine_IsBankLoaded(uint8_t bankId);
105void GameEngine_UnloadBank(uint8_t bankId);
106struct AudioSequenceData* GameEngine_LoadSequence(uint8_t seqId);
108uint8_t GameEngine_IsSequenceLoaded(uint8_t seqId);
109void GameEngine_UnloadSequence(uint8_t seqId);
110// bool GameEngine_OTRSigCheck(char* imgData); -> align_asset_macro.h
111float OTRGetAspectRatio(void);
112float OTRGetDimensionFromLeftEdge(float v);
113float OTRGetDimensionFromRightEdge(float v);
114int16_t OTRGetRectDimensionFromLeftEdge(float v);
115int16_t OTRGetRectDimensionFromRightEdge(float v);
116uint32_t OTRGetGameRenderWidth(void);
117uint32_t OTRGetGameRenderHeight(void);
118uint32_t OTRGetGameViewportWidth();
119uint32_t OTRGetGameViewportHeight();
120uint32_t OTRCalculateCenterOfAreaFromRightEdge(int32_t center);
121uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center);
122int32_t GameEngine_ResourceGetTexTypeByName(const char* name);
123#ifdef __cplusplus
124}
125#endif
126
uint32_t OTRGetGameRenderWidth()
Definition Engine.cpp:805
float OTRGetAspectRatio()
Definition Engine.cpp:762
uint32_t OTRGetGameViewportWidth()
Definition Engine.cpp:814
float OTRGetDimensionFromRightEdge(float v)
Definition Engine.cpp:774
uint32_t OTRCalculateCenterOfAreaFromRightEdge(int32_t center)
Definition Engine.cpp:796
Fast::Interpreter * GetInterpreter()
Definition Engine.cpp:59
int16_t OTRGetRectDimensionFromRightEdge(float v)
Definition Engine.cpp:778
uint32_t OTRGetGameRenderHeight()
Definition Engine.cpp:810
uint32_t OTRGetGameViewportHeight()
Definition Engine.cpp:818
uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center)
Definition Engine.cpp:800
int16_t OTRGetRectDimensionFromLeftEdge(float v)
Definition Engine.cpp:770
float OTRGetDimensionFromLeftEdge(float v)
Definition Engine.cpp:766
void GameEngine_UnloadSequence(uint8_t seqId)
Definition Engine.cpp:694
uint32_t OTRGetGameViewportWidth()
Definition Engine.cpp:814
float OTRGetDimensionFromRightEdge(float v)
Definition Engine.cpp:774
uint32_t OTRCalculateCenterOfAreaFromRightEdge(int32_t center)
Definition Engine.cpp:796
uint32_t GameEngine_GetSampleRate()
Definition Engine.cpp:620
void GameEngine_UnloadBank(uint8_t bankId)
Definition Engine.cpp:664
uint8_t GameEngine_IsBankLoaded(uint8_t bankId)
Definition Engine.cpp:658
uint32_t OTRGetGameRenderHeight(void)
Definition Engine.cpp:810
void GameEngine_ProcessGfxCommands(Gfx *commands)
uint32_t GameEngine_GetSequenceCount()
Definition Engine.cpp:685
int16_t OTRGetRectDimensionFromRightEdge(float v)
Definition Engine.cpp:778
struct CtlEntry * GameEngine_LoadBank(uint8_t bankId)
Definition Engine.cpp:637
int32_t GameEngine_ResourceGetTexTypeByName(const char *name)
Definition Engine.cpp:714
uint8_t GameEngine_IsSequenceLoaded(uint8_t seqId)
Definition Engine.cpp:690
uint32_t GameEngine_GetSamplesPerFrame()
Definition Engine.cpp:633
float OTRGetAspectRatio(void)
Definition Engine.cpp:762
float GameEngine_GetAspectRatio()
Definition Engine.cpp:699
struct AudioSequenceData * GameEngine_LoadSequence(uint8_t seqId)
Definition Engine.cpp:669
uint32_t OTRGetGameViewportHeight()
Definition Engine.cpp:818
uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center)
Definition Engine.cpp:800
uint32_t OTRGetGameRenderWidth(void)
Definition Engine.cpp:805
int16_t OTRGetRectDimensionFromLeftEdge(float v)
Definition Engine.cpp:770
float OTRGetDimensionFromLeftEdge(float v)
Definition Engine.cpp:766
Definition internal.h:134
Definition AudioSequence.h:7
Definition internal.h:172
u8 bankId
Definition internal.h:173