#ifndef NOVA64_PPU_INTERFACE_H #define NOVA64_PPU_INTERFACE_H #include #include // Pixel format: RGB565 (uint16_t) typedef uint16_t pixel_t; /* ========================================================================== */ /* PPU Callback Typedefs */ /* ========================================================================== */ /** * @brief Transformation flags for hardware-accelerated sprite operations. */ typedef enum { NOVA64_TRANSFORM_NONE = 0, NOVA64_TRANSFORM_FLIP_H = 1 << 0, NOVA64_TRANSFORM_FLIP_V = 1 << 1, NOVA64_TRANSFORM_ROT_90 = 1 << 2, NOVA64_TRANSFORM_ROT_180 = 1 << 3, NOVA64_TRANSFORM_ROT_270 = 1 << 4 } nova64_transform_t; /** * @brief Callback to perform a solid color rectangle fill (e.g. clear/rects). * @param dst Pointer to destination buffer memory. * @param dst_stride Row stride (pitch) of destination buffer in pixels. * @param x Top-left X position in destination buffer. * @param y Top-left Y position in destination buffer. * @param w Width of rectangle to fill. * @param h Height of rectangle to fill. * @param color 16-bit RGB565 pixel color value. */ typedef void (*nova64_ppu_fill_rect_cb_t)(pixel_t *dst, uint32_t dst_stride, int32_t x, int32_t y, int32_t w, int32_t h, pixel_t color); /** * @brief Callback for hardware-accelerated block image transfer (opaque Blit). * @param src Pointer to source surface buffer. * @param src_stride Row stride (pitch) of source surface in pixels. * @param dst Pointer to destination buffer memory. * @param dst_stride Row stride (pitch) of destination buffer in pixels. * @param src_x X coordinate on source surface. * @param src_y Y coordinate on source surface. * @param dst_x X coordinate on destination buffer. * @param dst_y Y coordinate on destination buffer. * @param w Width of block to transfer. * @param h Height of block to transfer. */ typedef void (*nova64_ppu_blit_cb_t)(const pixel_t *src, uint32_t src_stride, pixel_t *dst, uint32_t dst_stride, int32_t src_x, int32_t src_y, int32_t dst_x, int32_t dst_y, int32_t w, int32_t h); /** * @brief Callback for transparent sprite blitting using color keying. * @param src Pointer to source surface buffer. * @param src_stride Row stride of source surface in pixels. * @param dst Pointer to destination buffer memory. * @param dst_stride Row stride of destination buffer in pixels. * @param src_x X coordinate on source surface. * @param src_y Y coordinate on source surface. * @param dst_x X coordinate on destination buffer. * @param dst_y Y coordinate on destination buffer. * @param w Width of block to transfer. * @param h Height of block to transfer. * @param key_color 16-bit color treated as fully transparent. */ typedef void (*nova64_ppu_blit_colorkey_cb_t)( const pixel_t *src, uint32_t src_stride, pixel_t *dst, uint32_t dst_stride, int32_t src_x, int32_t src_y, int32_t dst_x, int32_t dst_y, int32_t w, int32_t h, pixel_t key_color); /** * @brief Callback for alpha-blended surface composition. * @param src Pointer to source surface buffer. * @param src_stride Row stride of source surface in pixels. * @param dst Pointer to destination buffer memory. * @param dst_stride Row stride of destination buffer in pixels. * @param src_x X coordinate on source surface. * @param src_y Y coordinate on source surface. * @param dst_x X coordinate on destination buffer. * @param dst_y Y coordinate on destination buffer. * @param w Width of block to transfer. * @param h Height of block to transfer. * @param global_alpha Global opacity multiplier (0 = transparent, 255 = * opaque). */ typedef void (*nova64_ppu_blend_cb_t)(const pixel_t *src, uint32_t src_stride, pixel_t *dst, uint32_t dst_stride, int32_t src_x, int32_t src_y, int32_t dst_x, int32_t dst_y, int32_t w, int32_t h, uint8_t global_alpha); /** * @brief Callback for transformed image transfer (rotation & flipping). * @param src Pointer to source surface buffer. * @param src_stride Row stride of source surface in pixels. * @param dst Pointer to destination buffer memory. * @param dst_stride Row stride of destination buffer in pixels. * @param src_x X coordinate on source surface. * @param src_y Y coordinate on source surface. * @param dst_x X coordinate on destination buffer. * @param dst_y Y coordinate on destination buffer. * @param w Width of block to transfer. * @param h Height of block to transfer. * @param transform Rotation/Flip flags to apply during transfer. */ typedef void (*nova64_ppu_blit_transform_cb_t)( const pixel_t *src, uint32_t src_stride, pixel_t *dst, uint32_t dst_stride, int32_t src_x, int32_t src_y, int32_t dst_x, int32_t dst_y, int32_t w, int32_t h, nova64_transform_t transform); /** * @brief Callback for hardware-accelerated image scaling/resizing. * @param src Pointer to source surface buffer. * @param src_stride Row stride of source surface in pixels. * @param src_w Width of source rectangle. * @param src_h Height of source rectangle. * @param dst Pointer to destination buffer memory. * @param dst_stride Row stride of destination buffer in pixels. * @param dst_x Target X coordinate on destination buffer. * @param dst_y Target Y coordinate on destination buffer. * @param dst_w Target scaled width on destination buffer. * @param dst_h Target scaled height on destination buffer. */ typedef void (*nova64_ppu_blit_scale_cb_t)(const pixel_t *src, uint32_t src_stride, int32_t src_w, int32_t src_h, pixel_t *dst, uint32_t dst_stride, int32_t dst_x, int32_t dst_y, int32_t dst_w, int32_t dst_h); /** * @brief Callback to block CPU execution until all PPU/DMA2D hardware * operations finish. */ typedef void (*nova64_ppu_wait_idle_cb_t)(void); /** * @brief Callback to check if the PPU/DMA2D engine is currently processing a * job. * @return True if hardware is busy, false if idle. */ typedef bool (*nova64_ppu_is_busy_cb_t)(void); /* ========================================================================== */ /* PPU Interface Configuration Struct */ /* ========================================================================== */ /** * @brief Struct containing all PPU hardware abstraction callbacks. * Pass NULL for any unsupported or unneeded hardware acceleration * feature. */ typedef struct { nova64_ppu_fill_rect_cb_t fill_rect; nova64_ppu_blit_cb_t blit; nova64_ppu_blit_colorkey_cb_t blit_colorkey; nova64_ppu_blend_cb_t blend; nova64_ppu_blit_transform_cb_t blit_transform; nova64_ppu_blit_scale_cb_t blit_scale; nova64_ppu_wait_idle_cb_t wait_idle; nova64_ppu_is_busy_cb_t is_busy; } nova64_ppu_interface_t; #endif // NOVA64_PPU_INTERFACE_H