Starship/src/port/Engine.h

65 lines
1.9 KiB
C
Raw Normal View History

#pragma once
2024-04-06 23:25:40 +03:00
#define LOAD_ASSET(path) (path == NULL ? NULL : (GameEngine_OTRSigCheck((const char*) path) ? ResourceGetDataByName((const char*) path) : path))
2024-04-06 13:25:11 +03:00
#define LOAD_ASSET_RAW(path) ResourceGetDataByName((const char*) path)
2024-10-29 11:06:14 +03:00
struct GamePool {
unsigned long chunk;
unsigned long cursor;
unsigned long length;
void* memory;
};
#ifdef __cplusplus
#include <vector>
#include <Fast3D/gfx_pc.h>
2024-04-03 11:18:17 +03:00
#include "libultraship/src/Context.h"
2024-11-12 19:21:26 +03:00
class GameEngine {
public:
static GameEngine* Instance;
2024-05-21 07:29:07 +03:00
std::shared_ptr<Ship::Context> context;
GameEngine();
static void Create();
void StartFrame() const;
2024-10-26 07:39:32 +03:00
static void HandleAudioThread();
static void StartAudioFrame();
static void EndAudioFrame();
static void AudioInit();
static void AudioExit();
2024-10-16 20:53:41 +03:00
static void RunCommands(Gfx* Commands, const std::vector<std::unordered_map<Mtx*, MtxF>>& mtx_replacements);
void ProcessFrame(void (*run_one_game_iter)()) const;
static void Destroy();
2024-04-02 08:13:52 +03:00
static void ProcessGfxCommands(Gfx* commands);
2024-10-16 20:53:41 +03:00
static uint32_t GetInterpolationFPS();
};
2024-10-29 11:06:14 +03: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 11:06:14 +03:00
#include <stdint.h>
void GameEngine_ProcessGfxCommands(Gfx* commands);
float GameEngine_GetAspectRatio();
2024-04-08 03:01:42 +03:00
uint8_t GameEngine_OTRSigCheck(char* imgData);
uint32_t OTRGetCurrentWidth(void);
uint32_t OTRGetCurrentHeight(void);
float OTRGetAspectRatio(void);
int32_t OTRConvertHUDXToScreenX(int32_t v);
float OTRGetDimensionFromLeftEdge(float v);
float OTRGetDimensionFromRightEdge(float v);
int16_t OTRGetRectDimensionFromLeftEdge(float v);
int16_t OTRGetRectDimensionFromRightEdge(float v);
uint32_t OTRGetGameRenderWidth();
uint32_t OTRGetGameRenderHeight();
2024-10-29 11:06:14 +03:00
void* GameEngine_Malloc(size_t size);
#define memalloc(size) GameEngine_Malloc(size)
#endif