summaryrefslogtreecommitdiffstats
path: root/src/renderer.h
blob: f056f6a01864afb7039050288e03daedda1b34c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#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);
void flip_buffer(void);
void renderer_init(void);

#endif // RENDERER__H