aboutsummaryrefslogtreecommitdiffstats
path: root/src/renderer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderer.h')
-rw-r--r--src/renderer.h45
1 files changed, 11 insertions, 34 deletions
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 @@
3 3
4#include "gba/gba.h" 4#include "gba/gba.h"
5 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
31// Draws a pixel to the given (x, y) position on the framebuffer. All drawing 6// Draws a pixel to the given (x, y) position on the framebuffer. All drawing
32// functions use paletted colors (clr: 0-15). 7// functions use paletted colors (clr: 0-15).
33void draw_pixel(size_t x, size_t y, u8 clr); 8void 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);
41// Draw a filled rectangle between (x0, y0) and (x1, y1) (x0 <= x1 and y0 <= y1). 16// Draw a filled rectangle between (x0, y0) and (x1, y1) (x0 <= x1 and y0 <= y1).
42void draw_filled_rect(size_t x0, size_t y0, size_t x1, size_t y1, u8 clr); 17void draw_filled_rect(size_t x0, size_t y0, size_t x1, size_t y1, u8 clr);
43 18
44// Draw a 8x8 tile starting at the (x, y) position. If the merge parameter is 19// Fills the framebuffer with the given color.
45// set, colors will be added together instead of replaced. This could lead to 20void screen_fill(u8 clr);
46// some merging issues if we are not careful with the chosen colors. The tile 21
47// color will be multiplied by the given clr parameter, which is useful to 22// Draws a chr sprite (16 * u8). The first 8 bytes correspond to ch0 and the
48// change the color of flat tiles. 23// last 8 to ch1. If clr is 0 the regular 4bit color will be used, from clr 1-14
49void draw_tile(size_t x, size_t y, Tile *tile, u8 clr, bool merge); 24// the given color will overwrite the existing one. Color 15 will "clear" the
25// sprite instead.
26void draw_chr(size_t x, size_t y, u8 *sprite, u8 clr, u8 flip_x, u8 flip_y);
50 27
51// Fills the framebuffer with color 0. 28// Draws a 1bpp icn sprite in the given color.
52void clear_screen(void); 29void draw_icn(size_t x, size_t y, u8 *sprite, u8 clr, u8 flip_x, u8 flip_y);
53 30
54// Copies the content of dirty tiles from the backbuffer into the frontbuffer. 31// Copies data and performs page flipping if needed.
55// To be called exactly once at the beginning of the VBlank. 32// To be called exactly once at the beginning of the VBlank.
56void flip_buffer(void); 33void flip_buffer(void);
57 34