aboutsummaryrefslogtreecommitdiffstats
path: root/src/renderer.c
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-06-04 10:53:24 +0200
committerBad Diode <bd@badd10de.dev>2021-06-04 10:53:24 +0200
commitaedaa7ade0ed623d09b18a34023f2e02201e67e6 (patch)
tree98af99d9c83c00ba8b1bff64c1cf59380a0df3e4 /src/renderer.c
parent0578a6db65f81f868c527aadfb57a89875d09d94 (diff)
downloadstepper-aedaa7ade0ed623d09b18a34023f2e02201e67e6.tar.gz
stepper-aedaa7ade0ed623d09b18a34023f2e02201e67e6.zip
Add slow rect drawing primitive to renderer
Diffstat (limited to 'src/renderer.c')
-rw-r--r--src/renderer.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/renderer.c b/src/renderer.c
index 076d698..4aa583d 100644
--- a/src/renderer.c
+++ b/src/renderer.c
@@ -46,6 +46,32 @@ draw_pixel(u16 x, u16 y, u8 color) {
46 46
47IWRAM_CODE 47IWRAM_CODE
48void 48void
49draw_rect(int x0, int y0, int x1, int y1, u8 clr) {
50 if (x0 > x1) {
51 int tmp = x0;
52 x0 = x1;
53 x1 = tmp;
54 }
55 if (y0 > y1) {
56 int tmp = y0;
57 y0 = y1;
58 y1 = tmp;
59 }
60 int dx = x1 - x0;
61 int dy = y1 - y0;
62 // TODO: SLOW should be vectorized.
63 for (int i = 0; i <= dx; ++i) {
64 draw_pixel(x0 + i, y0, clr);
65 draw_pixel(x0 + i, y1, clr);
66 }
67 for (int i = 0; i <= dy; ++i) {
68 draw_pixel(x0, y0 + i, clr);
69 draw_pixel(x1, y0 + i, clr);
70 }
71}
72
73IWRAM_CODE
74void
49draw_tile(u16 x, u16 y, Tile *tile, bool merge) { 75draw_tile(u16 x, u16 y, Tile *tile, bool merge) {
50 BOUNDCHECK_SCREEN(x, y); 76 BOUNDCHECK_SCREEN(x, y);
51 77