Create Simulator target scaffold
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
#include "nova64_core.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
#include "task.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(ESP_PLATFORM)
|
||||
/* ESP32-spezifische Header für Low-Power & Watchdog */
|
||||
#include "esp_pm.h"
|
||||
#include "esp_rom_sys.h"
|
||||
#include "esp_task_wdt.h"
|
||||
#elif defined(_WIN32)
|
||||
/* Windows API für Schlafen im Desktop-Thread */
|
||||
#include <windows.h>
|
||||
#else
|
||||
/* POSIX / Linux / macOS Sleep */
|
||||
#define _POSIX_C_SOURCE 199309L
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
static bool is_initialized = false;
|
||||
static QueueHandle_t event_queue = NULL;
|
||||
|
||||
|
||||
NOVA64_API bool nova64_init_io(const nova64_io_interface_t *io_interface) {
|
||||
printf("[Nova64 Core] System Initializing...\n");
|
||||
|
||||
event_queue = xQueueCreate(10, sizeof(uint32_t));
|
||||
|
||||
is_initialized = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
NOVA64_API int32_t nova64_process_tick(uint32_t delta_ms) {
|
||||
if (!is_initialized)
|
||||
return -1;
|
||||
// Core Game-Logic & State Machine Ticks
|
||||
return 0; // OK
|
||||
}
|
||||
|
||||
NOVA64_API uint32_t nova64_get_version(void) {
|
||||
return 0x010000; // v1.0.0
|
||||
}
|
||||
|
||||
/* FreeRTOS hook: called by the kernel when the idle task runs.
|
||||
* Required because configUSE_IDLE_HOOK is enabled in FreeRTOSConfig.h
|
||||
*/
|
||||
void vApplicationIdleHook(void) {
|
||||
#if defined(ESP_PLATFORM)
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// ESP32-specific idle hook code
|
||||
// -------------------------------------------------------------------------
|
||||
#if CONFIG_ESP_TASK_WDT
|
||||
// Feed the watchdog to prevent reset
|
||||
esp_task_wdt_reset();
|
||||
#endif
|
||||
asm volatile("wfi"); // Wait for interrupt to save power
|
||||
|
||||
#elif defined(_WIN32)
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Windows-specific idle hook code
|
||||
// -------------------------------------------------------------------------
|
||||
Sleep(1); // Sleep for 1 millisecond to yield CPU
|
||||
|
||||
#else
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// POSIX-specific idle hook code
|
||||
// -------------------------------------------------------------------------
|
||||
struct timespec ts = {0, 1000000}; // 1 millisecond
|
||||
nanosleep(&ts, NULL);
|
||||
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user