From deb9c48fbd3dc5854de4ae3a04dc999029c10ae0 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Sat, 22 Apr 2023 21:12:14 +0200 Subject: Add new renderer and prepare for render overhaul --- src/renderer.h | 45 +++++++++++---------------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) (limited to 'src/renderer.h') diff --git a/src/renderer.h b/src/renderer.h index 4620c27..e6637ef 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -3,31 +3,6 @@ #include "gba/gba.h" -// The frontbuffer is located at the beginning of the VRAM, and requires 20KB of -// video memory for 32 * 20 tiles at 4bpp. -#define FRONTBUF ((u32*)(MEM_VRAM)) - -// Adjust both of these if the location of the map changes. Each screnblock -// requires less than 2KB. -#define FRONTBUF_TILEMAP ((u16*)(MEM_VRAM + KB(20))) -#define FRONTBUF_SB 10 - -// The backbuffer is located at the end of the VRAM. This can allow us to use -// more backgrounds but eats into the available memory for sprites. This should -// be fine for non sprite intensive applications. If more sprite memory is -// needed, the backbuffer can be located at the end of the background memory -// instead (64KB - 20KB). -#define BACKBUF ((u32*)(MEM_VRAM + KB(96) - KB(20))) - -// The font data is located at the end of the frontbuffer memory, after the tile -// map and requires 8KB for 256 8x8 characters at 4bpp. This, along with the -// tilemap information allow us to store the frontbuffer and font for a text -// background in the first 2 charblocks (32KB). -#define FONT_DATA ((u32*)(MEM_VRAM + KB(22))) -#define FONT_TILEMAP ((u16*)(MEM_VRAM + KB(30))) -#define FONT_SB 15 -#define FONT_OFFSET 192 - // Draws a pixel to the given (x, y) position on the framebuffer. All drawing // functions use paletted colors (clr: 0-15). void draw_pixel(size_t x, size_t y, u8 clr); @@ -41,17 +16,19 @@ void draw_rect(size_t x0, size_t y0, size_t x1, size_t y1, u8 clr); // Draw a filled rectangle between (x0, y0) and (x1, y1) (x0 <= x1 and y0 <= y1). void draw_filled_rect(size_t x0, size_t y0, size_t x1, size_t y1, u8 clr); -// Draw a 8x8 tile starting at the (x, y) position. If the merge parameter is -// set, colors will be added together instead of replaced. This could lead to -// some merging issues if we are not careful with the chosen colors. The tile -// color will be multiplied by the given clr parameter, which is useful to -// change the color of flat tiles. -void draw_tile(size_t x, size_t y, Tile *tile, u8 clr, bool merge); +// Fills the framebuffer with the given color. +void screen_fill(u8 clr); + +// Draws a chr sprite (16 * u8). The first 8 bytes correspond to ch0 and the +// last 8 to ch1. If clr is 0 the regular 4bit color will be used, from clr 1-14 +// the given color will overwrite the existing one. Color 15 will "clear" the +// sprite instead. +void draw_chr(size_t x, size_t y, u8 *sprite, u8 clr, u8 flip_x, u8 flip_y); -// Fills the framebuffer with color 0. -void clear_screen(void); +// Draws a 1bpp icn sprite in the given color. +void draw_icn(size_t x, size_t y, u8 *sprite, u8 clr, u8 flip_x, u8 flip_y); -// Copies the content of dirty tiles from the backbuffer into the frontbuffer. +// Copies data and performs page flipping if needed. // To be called exactly once at the beginning of the VBlank. void flip_buffer(void); -- cgit v1.2.1