Starship/src/port/Engine.h

87 lines
3.1 KiB
C
Raw Normal View History

#pragma once
2024-04-06 14:25:40 -06:00
#define LOAD_ASSET(path) (path == NULL ? NULL : (GameEngine_OTRSigCheck((const char*) path) ? ResourceGetDataByName((const char*) path) : path))
2024-04-06 04:25:11 -06:00
#define LOAD_ASSET_RAW(path) ResourceGetDataByName((const char*) path)
2025-01-31 18:20:12 -06:00
typedef enum {
SF64_VER_US = 0x94F1D5A7,
SF64_VER_EU = 0x6EE9ADE7,
SF64_VER_JP = 0x3728D3E1
} SF64Version;
#ifdef __cplusplus
#include <vector>
2025-01-15 19:36:12 -06:00
#include <SDL2/SDL.h>
#include <Fast3D/gfx_pc.h>
2024-04-03 02:18:17 -06:00
#include "libultraship/src/Context.h"
2025-01-15 19:29:43 -06:00
#ifndef IDYES
#define IDYES 6
#endif
#ifndef IDNO
#define IDNO 7
#endif
class GameEngine {
public:
static GameEngine* Instance;
2024-05-20 22:29:07 -06:00
std::shared_ptr<Ship::Context> context;
GameEngine();
2025-01-15 21:25:58 -06:00
void StartFrame() const;
2025-03-08 18:36:42 -06:00
static bool GenAssetFile(bool exitOnFail = true);
static void Create();
2024-10-25 22:39:32 -06:00
static void HandleAudioThread();
static void StartAudioFrame();
static void EndAudioFrame();
static void AudioInit();
static void AudioExit();
2024-10-16 11:53:41 -06:00
static void RunCommands(Gfx* Commands, const std::vector<std::unordered_map<Mtx*, MtxF>>& mtx_replacements);
static void Destroy();
static uint32_t GetInterpolationFPS();
static uint32_t GetInterpolationFrameCount();
2025-01-15 21:25:58 -06:00
static void ProcessGfxCommands(Gfx* commands);
2025-01-15 19:29:43 -06:00
static int ShowYesNoBox(const char* title, const char* box);
2025-01-15 19:36:12 -06:00
static void ShowMessage(const char* title, const char* message, SDL_MessageBoxFlags type = SDL_MESSAGEBOX_ERROR);
2025-01-31 18:20:12 -06:00
static bool HasVersion(SF64Version ver);
};
2024-10-29 02:06:14 -06:00
extern "C" void* GameEngine_Malloc(size_t size);
#define memallocn(type, n) (type*) GameEngine_Malloc(sizeof(type) * n)
#define memalloc(type) memallocn(type, 1)
#else
2024-10-29 02:06:14 -06:00
#include <stdint.h>
2025-01-31 18:20:12 -06:00
bool GameEngine_HasVersion(SF64Version ver);
void GameEngine_ProcessGfxCommands(Gfx* commands);
float GameEngine_GetAspectRatio();
2024-04-07 18:01:42 -06:00
uint8_t GameEngine_OTRSigCheck(char* imgData);
uint32_t OTRGetCurrentWidth(void);
uint32_t OTRGetCurrentHeight(void);
float OTRGetAspectRatio(void);
float OTRGetHUDAspectRatio();
int32_t OTRConvertHUDXToScreenX(int32_t v);
float OTRGetDimensionFromLeftEdge(float v);
float OTRGetDimensionFromRightEdge(float v);
int16_t OTRGetRectDimensionFromLeftEdge(float v);
int16_t OTRGetRectDimensionFromRightEdge(float v);
2025-01-11 11:17:45 -03:00
float OTRGetDimensionFromLeftEdgeForcedAspect(float v, float aspectRatio);
float OTRGetDimensionFromRightEdgeForcedAspect(float v, float aspectRatio);
int16_t OTRGetRectDimensionFromLeftEdgeForcedAspect(float v, float aspectRatio);
int16_t OTRGetRectDimensionFromRightEdgeForcedAspect(float v, float aspectRatio);
float OTRGetDimensionFromLeftEdgeOverride(float v);
float OTRGetDimensionFromRightEdgeOverride(float v);
int16_t OTRGetRectDimensionFromLeftEdgeOverride(float v);
int16_t OTRGetRectDimensionFromRightEdgeOverride(float v);
uint32_t OTRGetGameRenderWidth();
uint32_t OTRGetGameRenderHeight();
2024-10-29 02:06:14 -06:00
void* GameEngine_Malloc(size_t size);
void GameEngine_GetTextureInfo(const char* path, int32_t* width, int32_t* height, float* scale, bool* custom);
void gDPSetTileSizeInterp(Gfx* pkt, int t, float uls, float ult, float lrs, float lrt);
uint32_t GameEngine_GetInterpolationFrameCount();
2024-10-29 02:06:14 -06:00
#define memalloc(size) GameEngine_Malloc(size)
#endif