Mario Kart 64
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 <graphic/Fast3D/Fast3dWindow.h>
14#include <graphic/Fast3D/interpreter.h>
15#include "libultraship/src/Context.h"
16
17#ifndef IDYES
18#define IDYES 6
19#endif
20#ifndef IDNO
21#define IDNO 7
22#endif
23
24#define SAMPLES_HIGH 448
25#define SAMPLES_LOW 432
26#define AUDIO_FRAMES_PER_UPDATE 2
27#define NUM_AUDIO_CHANNELS 2
28#define SAMPLES_PER_FRAME (SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 2)
29
30Fast::Interpreter* GetInterpreter();
31
32struct CtlEntry;
33struct AudioBankSample;
35
36class GameEngine {
37 public:
38 static GameEngine* Instance;
39
40 std::shared_ptr<Ship::Context> context;
41 std::vector<CtlEntry*> banksTable;
42 std::vector<std::string> sequenceTable;
43 std::vector<AudioSequenceData*> audioSequenceTable;
44 std::vector<std::string> archiveFiles;
45
46 ImFont* fontStandard;
47 ImFont* fontStandardLarger;
48 ImFont* fontStandardLargest;
49 ImFont* fontMono;
50 ImFont* fontMonoLarger;
51 ImFont* fontMonoLargest;
52
53 HMAS* gHMAS;
54
55 std::unordered_map<std::string, uint8_t> bankMapTable;
56 GameEngine();
57 static bool GenAssetFile();
58 static void Create();
59
60 void AudioInit();
61 static void HandleAudioThread();
62 static void StartAudioFrame();
63 static void EndAudioFrame();
64 static void AudioExit();
65
66
67
68 static uint32_t GetInterpolationFPS();
69 static uint32_t GetInterpolationFrameCount();
70 void StartFrame() const;
71 static void RunCommands(Gfx* Commands, const std::vector<std::unordered_map<Mtx*, MtxF>>& mtx_replacements);
72 void ProcessFrame(void (*run_one_game_iter)()) const;
73 static void Destroy();
74 static void ProcessGfxCommands(Gfx* commands);
75 static uint8_t GetBankIdByName(const std::string& name);
76 static int ShowYesNoBox(const char* title, const char* box);
77 static void ShowMessage(const char* title, const char* message, SDL_MessageBoxFlags type = SDL_MESSAGEBOX_ERROR);
78 float OTRGetAspectRatio(void);
79 float OTRGetDimensionFromLeftEdge(float v);
80 float OTRGetDimensionFromRightEdge(float v);
81 int16_t OTRGetRectDimensionFromLeftEdge(float v);
82 int16_t OTRGetRectDimensionFromRightEdge(float v);
83 uint32_t OTRGetGameRenderWidth();
84 uint32_t OTRGetGameRenderHeight();
85 uint32_t OTRGetGameViewportWidth();
86 uint32_t OTRGetGameViewportHeight();
87 uint32_t OTRCalculateCenterOfAreaFromRightEdge(int32_t center);
88 uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center);
89 private:
90 ImFont* CreateFontWithSize(float size, std::string fontPath = "");
91};
92
93#endif
94
95#ifdef __cplusplus
96extern "C" {
97#endif
102struct CtlEntry* GameEngine_LoadBank(uint8_t bankId);
103uint8_t GameEngine_IsBankLoaded(uint8_t bankId);
104void GameEngine_UnloadBank(uint8_t bankId);
105struct AudioSequenceData* GameEngine_LoadSequence(uint8_t seqId);
107uint8_t GameEngine_IsSequenceLoaded(uint8_t seqId);
108void GameEngine_UnloadSequence(uint8_t seqId);
109// bool GameEngine_OTRSigCheck(char* imgData); -> align_asset_macro.h
110float OTRGetAspectRatio(void);
111float OTRGetDimensionFromLeftEdge(float v);
112float OTRGetDimensionFromRightEdge(float v);
113int16_t OTRGetRectDimensionFromLeftEdge(float v);
114int16_t OTRGetRectDimensionFromRightEdge(float v);
115uint32_t OTRGetGameRenderWidth(void);
116uint32_t OTRGetGameRenderHeight(void);
117uint32_t OTRGetGameViewportWidth();
118uint32_t OTRGetGameViewportHeight();
119uint32_t OTRCalculateCenterOfAreaFromRightEdge(int32_t center);
120uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center);
121int32_t GameEngine_ResourceGetTexTypeByName(const char* name);
122#ifdef __cplusplus
123}
124#endif
125
uint32_t OTRGetGameRenderWidth()
Definition Engine.cpp:834
float OTRGetAspectRatio()
Definition Engine.cpp:791
uint32_t OTRGetGameViewportWidth()
Definition Engine.cpp:843
float OTRGetDimensionFromRightEdge(float v)
Definition Engine.cpp:803
uint32_t OTRCalculateCenterOfAreaFromRightEdge(int32_t center)
Definition Engine.cpp:825
Fast::Interpreter * GetInterpreter()
Definition Engine.cpp:56
int16_t OTRGetRectDimensionFromRightEdge(float v)
Definition Engine.cpp:807
uint32_t OTRGetGameRenderHeight()
Definition Engine.cpp:839
uint32_t OTRGetGameViewportHeight()
Definition Engine.cpp:847
uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center)
Definition Engine.cpp:829
int16_t OTRGetRectDimensionFromLeftEdge(float v)
Definition Engine.cpp:799
float OTRGetDimensionFromLeftEdge(float v)
Definition Engine.cpp:795
void GameEngine_UnloadSequence(uint8_t seqId)
Definition Engine.cpp:701
uint32_t OTRGetGameViewportWidth()
Definition Engine.cpp:843
float OTRGetDimensionFromRightEdge(float v)
Definition Engine.cpp:803
uint32_t OTRCalculateCenterOfAreaFromRightEdge(int32_t center)
Definition Engine.cpp:825
uint32_t GameEngine_GetSampleRate()
Definition Engine.cpp:627
void GameEngine_UnloadBank(uint8_t bankId)
Definition Engine.cpp:671
uint8_t GameEngine_IsBankLoaded(uint8_t bankId)
Definition Engine.cpp:665
uint32_t OTRGetGameRenderHeight(void)
Definition Engine.cpp:839
void GameEngine_ProcessGfxCommands(Gfx *commands)
uint32_t GameEngine_GetSequenceCount()
Definition Engine.cpp:692
int16_t OTRGetRectDimensionFromRightEdge(float v)
Definition Engine.cpp:807
struct CtlEntry * GameEngine_LoadBank(uint8_t bankId)
Definition Engine.cpp:644
int32_t GameEngine_ResourceGetTexTypeByName(const char *name)
Definition Engine.cpp:721
uint8_t GameEngine_IsSequenceLoaded(uint8_t seqId)
Definition Engine.cpp:697
uint32_t GameEngine_GetSamplesPerFrame()
Definition Engine.cpp:640
float OTRGetAspectRatio(void)
Definition Engine.cpp:791
float GameEngine_GetAspectRatio()
Definition Engine.cpp:706
struct AudioSequenceData * GameEngine_LoadSequence(uint8_t seqId)
Definition Engine.cpp:676
uint32_t OTRGetGameViewportHeight()
Definition Engine.cpp:847
uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center)
Definition Engine.cpp:829
uint32_t OTRGetGameRenderWidth(void)
Definition Engine.cpp:834
int16_t OTRGetRectDimensionFromLeftEdge(float v)
Definition Engine.cpp:799
float OTRGetDimensionFromLeftEdge(float v)
Definition Engine.cpp:795
Definition internal.h:134
Definition AudioSequence.h:7
Definition internal.h:172
u8 bankId
Definition internal.h:173