Mario Kart 64
Loading...
Searching...
No Matches
Engine.h
Go to the documentation of this file.
1#pragma once
2
3#define LOAD_ASSET(path) \
4(path == NULL ? NULL \
5 : (GameEngine_OTRSigCheck((const char*) path) ? ResourceGetDataByName((const char*) path) : path))
6 #define LOAD_ASSET_RAW(path) ResourceGetDataByName((const char*) path)
7
8 #ifdef __cplusplus
9 #include <vector>
10 #include <SDL2/SDL.h>
11#include <graphic/Fast3D/Fast3dWindow.h>
12#include <graphic/Fast3D/interpreter.h>
13#include "libultraship/src/Context.h"
14
15#ifndef IDYES
16#define IDYES 6
17#endif
18#ifndef IDNO
19#define IDNO 7
20#endif
21
22#define SAMPLES_HIGH 448
23#define SAMPLES_LOW 432
24#define AUDIO_FRAMES_PER_UPDATE 2
25#define NUM_AUDIO_CHANNELS 2
26#define SAMPLES_PER_FRAME (SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 2)
27
28Fast::Interpreter* GetInterpreter();
29
30struct CtlEntry;
31struct AudioBankSample;
33
34class GameEngine {
35 public:
36 static GameEngine* Instance;
37
38 std::shared_ptr<Ship::Context> context;
39 std::vector<CtlEntry*> banksTable;
40 std::vector<std::string> sequenceTable;
41 std::vector<AudioSequenceData*> audioSequenceTable;
42 std::vector<std::string> archiveFiles;
43
44 ImFont* fontStandard;
45 ImFont* fontStandardLarger;
46 ImFont* fontStandardLargest;
47 ImFont* fontMono;
48 ImFont* fontMonoLarger;
49 ImFont* fontMonoLargest;
50
51 std::unordered_map<std::string, uint8_t> bankMapTable;
52 GameEngine();
53 static bool GenAssetFile();
54 static void Create();
55
56 void AudioInit();
57 static void HandleAudioThread();
58 static void StartAudioFrame();
59 static void EndAudioFrame();
60 static void AudioExit();
61
62 static uint32_t GetInterpolationFPS();
63 static uint32_t GetInterpolationFrameCount();
64 void StartFrame() const;
65 static void RunCommands(Gfx* Commands, const std::vector<std::unordered_map<Mtx*, MtxF>>& mtx_replacements);
66 void ProcessFrame(void (*run_one_game_iter)()) const;
67 static void Destroy();
68 static void ProcessGfxCommands(Gfx* commands);
69 static uint8_t GetBankIdByName(const std::string& name);
70 static int ShowYesNoBox(const char* title, const char* box);
71 static void ShowMessage(const char* title, const char* message, SDL_MessageBoxFlags type = SDL_MESSAGEBOX_ERROR);
72 float OTRGetAspectRatio(void);
73 float OTRGetDimensionFromLeftEdge(float v);
74 float OTRGetDimensionFromRightEdge(float v);
75 int16_t OTRGetRectDimensionFromLeftEdge(float v);
76 int16_t OTRGetRectDimensionFromRightEdge(float v);
77 uint32_t OTRGetGameRenderWidth();
78 uint32_t OTRGetGameRenderHeight();
79 uint32_t OTRGetGameViewportWidth();
80 uint32_t OTRGetGameViewportHeight();
81 uint32_t OTRCalculateCenterOfAreaFromRightEdge(int32_t center);
82 uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center);
83 private:
84 ImFont* CreateFontWithSize(float size, std::string fontPath = "");
85};
86
87#endif
88
89#ifdef __cplusplus
90extern "C" {
91#endif
96struct CtlEntry* GameEngine_LoadBank(uint8_t bankId);
97uint8_t GameEngine_IsBankLoaded(uint8_t bankId);
98void GameEngine_UnloadBank(uint8_t bankId);
99struct AudioSequenceData* GameEngine_LoadSequence(uint8_t seqId);
101uint8_t GameEngine_IsSequenceLoaded(uint8_t seqId);
102void GameEngine_UnloadSequence(uint8_t seqId);
103// bool GameEngine_OTRSigCheck(char* imgData); -> align_asset_macro.h
104float OTRGetAspectRatio(void);
105float OTRGetDimensionFromLeftEdge(float v);
106float OTRGetDimensionFromRightEdge(float v);
107int16_t OTRGetRectDimensionFromLeftEdge(float v);
108int16_t OTRGetRectDimensionFromRightEdge(float v);
109uint32_t OTRGetGameRenderWidth(void);
110uint32_t OTRGetGameRenderHeight(void);
111uint32_t OTRGetGameViewportWidth();
112uint32_t OTRGetGameViewportHeight();
113uint32_t OTRCalculateCenterOfAreaFromRightEdge(int32_t center);
114uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center);
115#ifdef __cplusplus
116}
117#endif
118
uint32_t OTRGetGameRenderWidth()
Definition Engine.cpp:790
float OTRGetAspectRatio()
Definition Engine.cpp:747
uint32_t OTRGetGameViewportWidth()
Definition Engine.cpp:799
float OTRGetDimensionFromRightEdge(float v)
Definition Engine.cpp:759
uint32_t OTRCalculateCenterOfAreaFromRightEdge(int32_t center)
Definition Engine.cpp:781
Fast::Interpreter * GetInterpreter()
Definition Engine.cpp:55
int16_t OTRGetRectDimensionFromRightEdge(float v)
Definition Engine.cpp:763
uint32_t OTRGetGameRenderHeight()
Definition Engine.cpp:795
uint32_t OTRGetGameViewportHeight()
Definition Engine.cpp:803
uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center)
Definition Engine.cpp:785
int16_t OTRGetRectDimensionFromLeftEdge(float v)
Definition Engine.cpp:755
float OTRGetDimensionFromLeftEdge(float v)
Definition Engine.cpp:751
void GameEngine_UnloadSequence(uint8_t seqId)
Definition Engine.cpp:668
uint32_t OTRGetGameViewportWidth()
Definition Engine.cpp:799
float OTRGetDimensionFromRightEdge(float v)
Definition Engine.cpp:759
uint32_t OTRCalculateCenterOfAreaFromRightEdge(int32_t center)
Definition Engine.cpp:781
uint32_t GameEngine_GetSampleRate()
Definition Engine.cpp:594
void GameEngine_UnloadBank(uint8_t bankId)
Definition Engine.cpp:638
uint8_t GameEngine_IsBankLoaded(uint8_t bankId)
Definition Engine.cpp:632
uint32_t OTRGetGameRenderHeight(void)
Definition Engine.cpp:795
void GameEngine_ProcessGfxCommands(Gfx *commands)
uint32_t GameEngine_GetSequenceCount()
Definition Engine.cpp:659
int16_t OTRGetRectDimensionFromRightEdge(float v)
Definition Engine.cpp:763
struct CtlEntry * GameEngine_LoadBank(uint8_t bankId)
Definition Engine.cpp:611
uint8_t GameEngine_IsSequenceLoaded(uint8_t seqId)
Definition Engine.cpp:664
uint32_t GameEngine_GetSamplesPerFrame()
Definition Engine.cpp:607
float OTRGetAspectRatio(void)
Definition Engine.cpp:747
float GameEngine_GetAspectRatio()
Definition Engine.cpp:673
struct AudioSequenceData * GameEngine_LoadSequence(uint8_t seqId)
Definition Engine.cpp:643
uint32_t OTRGetGameViewportHeight()
Definition Engine.cpp:803
uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center)
Definition Engine.cpp:785
uint32_t OTRGetGameRenderWidth(void)
Definition Engine.cpp:790
int16_t OTRGetRectDimensionFromLeftEdge(float v)
Definition Engine.cpp:755
float OTRGetDimensionFromLeftEdge(float v)
Definition Engine.cpp:751
Definition internal.h:134
Definition AudioSequence.h:7
Definition internal.h:172
u8 bankId
Definition internal.h:173