40 lines
1.2 KiB
C
40 lines
1.2 KiB
C
#ifndef NOVA64_FRAMEBUFFER_H
|
|
#define NOVA64_FRAMEBUFFER_H
|
|
|
|
#include "nova64_core.h"
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
// Display dimensions
|
|
#define NOVA64_DISPLAY_WIDTH 480
|
|
#define NOVA64_DISPLAY_HEIGHT 800
|
|
#define NOVA64_DISPLAY_PIXELS (NOVA64_DISPLAY_WIDTH * NOVA64_DISPLAY_HEIGHT)
|
|
|
|
// Pixel format: RGB565 (uint16_t)
|
|
typedef uint16_t pixel_t;
|
|
|
|
// Framebuffer size in bytes (768,000 bytes)
|
|
#define NOVA64_FRAMEBUFFER_SIZE_BYTES (NOVA64_DISPLAY_PIXELS * sizeof(pixel_t))
|
|
|
|
// Alignment requirement for PPU/DMA2D on ESP32-P4 (cache line alignment)
|
|
#define NOVA64_DMA_ALIGNMENT 64
|
|
|
|
typedef struct {
|
|
pixel_t *front_buffer; // Buffer currently being read by display/MIPI-DSI
|
|
pixel_t *back_buffer; // Buffer currently being written to by WASM/PPU
|
|
|
|
volatile bool vsync_pending; // True when a buffer swap has been requested
|
|
uint32_t frame_count; // Frame counter
|
|
} nova64_framebuffer_t;
|
|
|
|
// Global instance access
|
|
NOVA64_API nova64_framebuffer_t nova64_framebuffer;
|
|
|
|
// Function prototypes
|
|
bool nova64_framebuffer_init(void);
|
|
void nova64_framebuffer_destroy(void);
|
|
void nova64_framebuffer_swap(void);
|
|
void nova64_framebuffer_clear(pixel_t color);
|
|
|
|
#endif // NOVA64_FRAMEBUFFER_H
|