aboutsummaryrefslogtreecommitdiffstats
path: root/src/renderer.h
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-06-04 10:30:53 +0200
committerBad Diode <bd@badd10de.dev>2021-06-04 10:30:53 +0200
commit76343003abd8bc686e6bb5ca4bcb77cb33b76e10 (patch)
treee3fbcd37b5697396ffea25f2fe4eac3b1f5f5433 /src/renderer.h
parent5ca4491aa46b7090189685fecf422ee7316de724 (diff)
downloadstepper-76343003abd8bc686e6bb5ca4bcb77cb33b76e10.tar.gz
stepper-76343003abd8bc686e6bb5ca4bcb77cb33b76e10.zip
Add text drawing support for framebuffer
Diffstat (limited to 'src/renderer.h')
-rw-r--r--src/renderer.h34
1 files changed, 34 insertions, 0 deletions
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 @@
1#ifndef RENDERER_H
2#define RENDERER_H
3
4#include "gba/gba.h"
5
6// The frontbuffer is located at the beginning of the VRAM, and requires 20KB of
7// video memory for 32 * 20 tiles at 4bpp.
8#define FRONTBUF ((u32*)(MEM_VRAM))
9
10// Adjust both of these if the location of the map changes. Each screnblock
11// requires less than 2KB.
12#define FRONTBUF_TILEMAP ((u16*)(MEM_VRAM + KB(20)))
13#define FRONTBUF_SB 10
14
15// The backbuffer is located at the end of the VRAM. This can allow us to use
16// more backgrounds but eats into the available memory for sprites. This should
17// be fine for non sprite intensive applications. If more sprite memory is
18// needed, the backbuffer can be located at the end of the background memory
19// instead (64KB - 20KB).
20#define BACKBUF ((u32*)(MEM_VRAM + KB(96) - KB(20)))
21
22// The font data is located at the end of the frontbuffer memory, after the tile
23// map and requires 8KB for 256 8x8 characters at 4bpp. This, along with the
24// tilemap information allow us to store the frontbuffer and font for a text
25// background in the first 2 charblocks (32KB).
26#define FONT_DATA ((u32*)(MEM_VRAM + KB(22)))
27#define FONT_TILEMAP ((u16*)(MEM_VRAM + KB(30)))
28#define FONT_SB 15
29#define FONT_OFFSET 192
30
31void draw_pixel(u16 x, u16 y, u8 color);
32void draw_tile(u16 x, u16 y, Tile *tile, bool merge);
33
34#endif // RENDERER__H