scaffolding for framebuffer functions

This commit is contained in:
Lukas Höppner
2026-08-12 22:44:54 +02:00
parent 84ba0a609a
commit 7c87a38a6a
9 changed files with 384 additions and 113 deletions
+4 -77
View File
@@ -1,6 +1,8 @@
#ifndef NOVA64_CORE_H
#define NOVA64_CORE_H
#include "nova64_io_interface.h"
#include "nova64_ppu_interface.h"
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
@@ -21,82 +23,6 @@
#endif
#endif
/* ========================================================================== */
/* I/O Callback Typedefs */
/* ========================================================================== */
/**
* @brief Callback to flush a frame buffer to the display.
* @param buffer Pointer to raw pixel data (e.g., RGB565 / RGBA8888).
* @param width Frame width in pixels.
* @param height Frame height in pixels.
*/
typedef void (*nova64_display_flush_cb_t)(const uint16_t *buffer,
uint16_t width, uint16_t height);
/**
* @brief Callback to output audio samples.
* @param samples Pointer to PCM audio sample buffer.
* @param count Number of samples in the buffer.
*/
typedef void (*nova64_audio_output_cb_t)(const int16_t *samples,
uint32_t count);
/**
* @brief Callback to read data from the SD card.
* @param slot_idx Zero-based cartridge slot index.
* @param file_path Null-terminated path to the file to read.
* @param destination_buffer Pointer to memory where file data should be copied.
* @param destination_length Maximum number of bytes available in the
* destination buffer.
* @return Number of bytes read on success, negative value on read error.
*/
typedef int32_t (*nova64_sd_read_file_cb_t)(uint32_t slot_idx,
const char *file_path,
uint8_t *destination_buffer,
uint32_t destination_length);
/**
* @brief Callback to retrieve the size of a file on the SD card.
* @param slot_idx Zero-based cartridge slot index.
* @param file_path Null-terminated path to the file.
* @return File size in bytes on success, negative value on error.
*/
typedef int32_t (*nova64_sd_get_file_size_cb_t)(uint32_t slot_idx,
const char *file_path);
/**
* @brief Callback triggered when a cartridge state change occurs (e.g.
* inserted/removed).
* @param slot_idx Zero-based cartridge slot index.
* @param is_inserted True if a cartridge is detected, false if ejected.
*/
typedef void (*nova64_cartridge_status_cb_t)(uint32_t slot_idx,
bool is_inserted);
/**
* @brief Callback for core log output.
* @param message Null-terminated UTF-8 log string.
*/
typedef void (*nova64_log_cb_t)(const char *message);
/* ========================================================================== */
/* I/O Interface Configuration Struct */
/* ========================================================================== */
/**
* @brief Struct containing all I/O hardware abstraction callbacks.
* Pass NULL for any unneeded callback.
*/
typedef struct {
nova64_display_flush_cb_t display_flush;
nova64_audio_output_cb_t audio_output;
nova64_sd_read_file_cb_t sd_read_file;
nova64_sd_get_file_size_cb_t sd_get_file_size;
nova64_cartridge_status_cb_t cartridge_status;
nova64_log_cb_t log_message;
} nova64_io_interface_t;
/* ========================================================================== */
/* Engine Core API */
/* ========================================================================== */
@@ -109,7 +35,8 @@ typedef struct {
* @return True if initialized successfully, false if already initialized or
* invalid.
*/
NOVA64_API bool nova64_init(const nova64_io_interface_t *io_interface);
NOVA64_API bool nova64_init(const nova64_io_interface_t *io_interface,
const nova64_ppu_interface_t *ppu_interface);
/**
* @brief Starts the main engine runtime and launches the FreeRTOS scheduler.