mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-11 21:21:57 -04:00
Move some OS functionality to rely on Aurora
This commit is contained in:
+1
-1
@@ -67,7 +67,7 @@ target_include_directories(game_debug PUBLIC
|
||||
extern/aurora/include/dolphin
|
||||
${CMAKE_BINARY_DIR}/../${DUSK_TP_VERSION}/include
|
||||
build/${DUSK_TP_VERSION}/include)
|
||||
target_link_libraries(game_debug PUBLIC aurora::core aurora::gx aurora::si aurora::vi aurora::pad aurora::mtx)
|
||||
target_link_libraries(game_debug PUBLIC aurora::core aurora::gx aurora::si aurora::vi aurora::pad aurora::mtx aurora::os)
|
||||
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
add_library(game SHARED ${DOLZEL_FILES} ${Z2AUDIOLIB_FILES} ${SSYSTEM_FILES} ${JSYSTEM_FILES} ${REL_FILES} ${DUSK_FILES})
|
||||
|
||||
@@ -349,7 +349,11 @@ void J3DGDSetTexImgAttr(GXTexMapID id, u16 width, u16 height, GXTexFmt format) {
|
||||
}
|
||||
|
||||
void J3DGDSetTexImgPtr(GXTexMapID id, void* image_ptr) {
|
||||
#if TARGET_PC
|
||||
puts("J3DGDSetTexImgPtr is a stub");
|
||||
#else
|
||||
J3DGDWriteBPCmd(BP_IMAGE_PTR(OSCachedToPhysical(image_ptr) >> 5, J3DGDTexImage3Ids[id]));
|
||||
#endif
|
||||
}
|
||||
|
||||
void J3DGDSetTexImgPtrRaw(GXTexMapID id, u32 image_ptr_raw) {
|
||||
|
||||
@@ -46,34 +46,6 @@ static bool PerfInitialized = false;
|
||||
// General OS
|
||||
// ==========================================================================
|
||||
|
||||
|
||||
// Credits: Super Monkey Ball
|
||||
|
||||
static u64 GetGCTicks() {
|
||||
#if __APPLE__
|
||||
return mach_absolute_time() * MachToDolphinNum / MachToDolphinDenom;
|
||||
#elif __linux__ || __FreeBSD__
|
||||
struct timespec tp;
|
||||
clock_gettime(CLOCK_MONOTONIC, &tp);
|
||||
|
||||
return ((tp.tv_sec * 1000000000ull) + tp.tv_nsec) * OS_CORE_CLOCK / 1000000000ull;
|
||||
#elif _WIN32
|
||||
if (!PerfInitialized) {
|
||||
QueryPerformanceFrequency(&PerfFrequency);
|
||||
PerfInitialized = true;
|
||||
}
|
||||
LARGE_INTEGER perf;
|
||||
QueryPerformanceCounter(&perf);
|
||||
|
||||
perf.QuadPart *= OS_CORE_CLOCK;
|
||||
perf.QuadPart /= PerfFrequency.QuadPart;
|
||||
|
||||
return perf.QuadPart;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
u32 OSGetConsoleType() {
|
||||
return OS_CONSOLE_RETAIL1;
|
||||
}
|
||||
@@ -82,10 +54,6 @@ u32 OSGetSoundMode() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
void OSInit() {
|
||||
// Thread system is lazy-initialized via OSGetCurrentThread()
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
// Message Queue (thread-safe implementation)
|
||||
// ==========================================================================
|
||||
@@ -232,45 +200,6 @@ int OSJamMessage(OSMessageQueue* mq, void* msg, s32 flags) {
|
||||
// Arena Functions
|
||||
// ==========================================================================
|
||||
|
||||
static void* sArenaLo = nullptr;
|
||||
static void* sArenaHi = nullptr;
|
||||
|
||||
void* OSGetArenaHi(void) {
|
||||
return sArenaHi;
|
||||
}
|
||||
|
||||
void* OSGetArenaLo(void) {
|
||||
return sArenaLo;
|
||||
}
|
||||
|
||||
void OSSetArenaHi(void* newHi) {
|
||||
sArenaHi = newHi;
|
||||
}
|
||||
|
||||
void OSSetArenaLo(void* newLo) {
|
||||
sArenaLo = newLo;
|
||||
}
|
||||
|
||||
void* OSAllocFromArenaLo(u32 size, u32 align) {
|
||||
if (!sArenaLo || !sArenaHi) return nullptr;
|
||||
|
||||
uintptr_t lo = (uintptr_t)sArenaLo;
|
||||
if (align > 0) {
|
||||
lo = (lo + align - 1) & ~((uintptr_t)align - 1);
|
||||
}
|
||||
|
||||
uintptr_t hi = (uintptr_t)sArenaHi;
|
||||
if (lo + size > hi) {
|
||||
OSReport("[PC-Arena] OSAllocFromArenaLo: out of arena space (need %u, have %u)\n",
|
||||
size, (u32)(hi - lo));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* result = (void*)lo;
|
||||
sArenaLo = (void*)(lo + size);
|
||||
return result;
|
||||
}
|
||||
|
||||
void* OSInitAlloc(void* arenaStart, void* arenaEnd, int maxHeaps) {
|
||||
return arenaStart;
|
||||
}
|
||||
@@ -289,14 +218,6 @@ void OSTicksToCalendarTime(OSTime ticks, OSCalendarTime* td) {
|
||||
if (td) memset(td, 0, sizeof(OSCalendarTime));
|
||||
}
|
||||
|
||||
OSTime OSGetTime(void) {
|
||||
return (OSTime)GetGCTicks();
|
||||
}
|
||||
|
||||
OSTick OSGetTick(void) {
|
||||
return (OSTick)GetGCTicks();
|
||||
}
|
||||
|
||||
u16 OSGetFontEncode() { return 0; }
|
||||
|
||||
char* OSGetFontTexture(char* string, void** image, s32* x, s32* y, s32* width) { return 0; }
|
||||
|
||||
+2
-11
@@ -231,19 +231,11 @@ int game_main(int argc, char* argv[]) {
|
||||
config.windowHeight = 480;
|
||||
config.configPath = ".";
|
||||
config.logCallback = &aurora_log_callback;
|
||||
config.mem1Size = 256 * 1024 * 1024;
|
||||
|
||||
auroraInfo = aurora_initialize(argc, argv, &config);
|
||||
|
||||
// 2. Setup Virtual Game RAM
|
||||
// Simulates Gamecube RAM (24MB + Audio etc, we take 256MB)
|
||||
#define GAME_RAM_SIZE (256 * 1024 * 1024)
|
||||
void* virtualGameRam = calloc(1, GAME_RAM_SIZE);
|
||||
if (!virtualGameRam) {
|
||||
printf("Fatal: Failed to allocate game RAM\n");
|
||||
return -1;
|
||||
}
|
||||
OSSetArenaLo(virtualGameRam);
|
||||
OSSetArenaHi((char*)virtualGameRam + GAME_RAM_SIZE);
|
||||
OSInit();
|
||||
|
||||
// 3. Init DVD Emulation
|
||||
DvdEmu::setBasePath("data");
|
||||
@@ -269,7 +261,6 @@ int game_main(int argc, char* argv[]) {
|
||||
main01();
|
||||
|
||||
aurora_shutdown();
|
||||
free(virtualGameRam);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user