From 76343003abd8bc686e6bb5ca4bcb77cb33b76e10 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Fri, 4 Jun 2021 10:30:53 +0200 Subject: Add text drawing support for framebuffer --- src/renderer.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/renderer.h (limited to 'src/renderer.h') diff --git a/src/renderer.h b/src/renderer.h new file mode 100644 index 0000000..8bc2069 --- /dev/null +++ b/src/renderer.h @@ -0,0 +1,34 @@ +#ifndef RENDERER_H +#define RENDERER_H + +#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 + +void draw_pixel(u16 x, u16 y, u8 color); +void draw_tile(u16 x, u16 y, Tile *tile, bool merge); + +#endif // RENDERER__H -- cgit v1.2.1