Files
goldeneye-pc-port/port/src/system.c
T
James Dansereau cd6cc158b6 Add PC port scaffolding (CMake build + port layer)
Initial scaffolding for a PC port of GoldenEye 007, modeled on the
Perfect Dark PC port (same Rare "Indy" engine). The N64 build
(Makefile + IDA) is untouched; the PC build is a parallel CMake build.

Build:
- CMakeLists.txt: SDL2 + zlib + OpenGL. Compiles src/game/*.c + curated
  engine files + libultra audio/gu + port/. Per-region macro sets
  (ROMID US/EU/JP) mirror the N64 Makefile's LCDEFS exactly.
- build-pc.sh, cmake/: configure+build helper and target/SDL2 modules.

Port layer (port/):
- video/audio/input/fs/romdata/config/system/mixer: stubs with
  TODO(Phase N) markers and correct interfaces.
- libultra.c: libultra OS shims (message queues, VI, PI, AI, EEPROM,
  controller, PFS/motor no-ops, region-gated osTvType).
- gesched.c: software-RSP scheduler replacing src/sched.c task submission.
- n64stubs.c: inert stubs for N64-boot + rmon symbols.
- random.c: PRNG ported verbatim from src/random.s (bit-exact).
- ucode.c: RSP/ASP/GSP microcode segment markers (dummies; Phase 3 TODO).

Docs:
- docs/PCPortResearch.md: architecture, GE-specific deltas, phased plan,
  and the scaffolding review (findings A1-A4/B1-B4/C1-C2 + resolutions).
- PORTING.md: top-level entry point.

See docs/PCPortResearch.md for the full plan.
2026-08-17 19:17:06 -04:00

82 lines
1.8 KiB
C

/*
* Platform primitives: time, logging, paths, exit.
*
* Modelled on the PD port's port/src/system.c (~315 lines).
*
* STATUS: scaffolding stub — implement during Phase 1.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "platform.h"
#include "system.h"
/* --- Time --------------------------------------------------------------- */
uint64_t sysGetMicroseconds(void)
{
/* TODO(Phase 1): use a monotonic clock.
* - Windows: QueryPerformanceCounter
* - POSIX: clock_gettime(CLOCK_MONOTONIC)
*/
return 0;
}
int64_t sysGetTime(void)
{
/* TODO(Phase 1): wall clock (time(NULL)). */
return 0;
}
void sysSleep(uint32_t micros)
{
/* TODO(Phase 1): Sleep() / usleep(). */
(void)micros;
}
/* --- Logging ------------------------------------------------------------ */
void sysLogPrintf(enum LogLevel level, const char *fmt, ...)
{
static const char *tags[] = { "ERROR", "WARN ", "INFO ", "DEBUG" };
va_list ap;
fprintf(stderr, "[%s] ", tags[level]);
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
fprintf(stderr, "\n");
}
/* --- Paths -------------------------------------------------------------- */
static char exeDir[512] = ".";
const char *sysGetExeDir(void)
{
/* TODO(Phase 1): resolve the executable's directory.
* - Windows: GetModuleFileName
* - Linux: readlink /proc/self/exe
* - macOS: _NSGetExecutablePath
*/
return exeDir;
}
const char *sysResolvePath(const char *path)
{
static char out[1024];
/* TODO(Phase 1): expand "$S/" (data dir) and "$E/" (exe dir) prefixes. */
strncpy(out, path, sizeof(out) - 1);
out[sizeof(out) - 1] = 0;
return out;
}
/* --- Lifecycle ---------------------------------------------------------- */
void sysExit(int code)
{
exit(code);
}