Core Native GBA 0.0.17
create your own game-engine with just lua for nitendo game boy advance console.
Loading...
Searching...
No Matches
draw_queue.c
Go to the documentation of this file.
1#include "zeebo.h"
2
3static uint16_t index_cmd = 0;
4static uint16_t page1_cmd = 0;
5static uint16_t page2_cmd = 0;
6static uint16_t index_param = 0;
7static uint16_t page_current = 0;
8
9static uint8_t queue_command[2048];
10static uint8_t queue_param[8192];
11
12static uint8_t clojure_cmd;
13
14static void draw_cmd_clojure(uint8_t a, uint8_t b, uint8_t c, uint8_t d)
15{
16 draw_queue_push(clojure_cmd, a, b, c, d);
17}
18
20{
21 clojure_cmd = cmd;
22 return draw_cmd_clojure;
23}
24
25void draw_queue_push(uint8_t cmd, uint8_t a, uint8_t b, uint8_t c, uint8_t d)
26{
27 if (index_cmd < sizeof(queue_command)) {
28 queue_command[index_cmd++] = cmd;
33 }
34}
35
36void draw_queue_page(uint8_t page)
37{
38 page_current = page & 1;
39 if (page_current) {
41 index_cmd = sizeof(queue_command) / 2;
42 index_param = sizeof(queue_param) / 2;
43 } else {
45 index_cmd = 0;
46 index_param = 0;
47 }
48}
49
50void draw_queue_burn(uint8_t page)
51{
52 uint16_t index = page & 1? sizeof(queue_command)/2: 0;
53 uint16_t param = index * 4;
54 uint16_t final = index_cmd;
55
56 if ((page & 1) != page_current) {
57 final = index == 0? page1_cmd: page2_cmd;
58 }
59
60 static const cmd_t commands[] = {
65 };
66
67 while (index < final) {
68 uint8_t cmd = queue_command[index] - 48;
69 if (cmd < sizeof(commands) / sizeof(commands[0]) && commands[cmd] != NULL) {
70 uint8_t param_1 = queue_param[param++];
71 uint8_t param_2 = queue_param[param++];
72 uint8_t param_3 = queue_param[param++];
73 uint8_t param_4 = queue_param[param++];
74 commands[cmd](param_1, param_2, param_3, param_4);
75 }
76 index++;
77 }
78}
void draw_cmd_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
Definition draw_color.c:10
void draw_cmd_mode(uint8_t drawmode, uint8_t flushmode, uint8_t change_mode, uint8_t change_flush)
Definition draw_color.c:40
void draw_cmd_line(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2)
Definition draw_line.c:3
void draw_queue_burn(uint8_t page)
Definition draw_queue.c:50
cmd_t draw_queue_clojure(uint8_t cmd)
Definition draw_queue.c:19
static uint8_t queue_command[2048]
Definition draw_queue.c:9
void draw_queue_page(uint8_t page)
Definition draw_queue.c:36
static uint16_t page2_cmd
Definition draw_queue.c:5
static uint16_t index_cmd
Definition draw_queue.c:3
static void draw_cmd_clojure(uint8_t a, uint8_t b, uint8_t c, uint8_t d)
Definition draw_queue.c:14
static uint16_t page_current
Definition draw_queue.c:7
static uint16_t page1_cmd
Definition draw_queue.c:4
static uint8_t clojure_cmd
Definition draw_queue.c:12
static uint8_t queue_param[8192]
Definition draw_queue.c:10
void draw_queue_push(uint8_t cmd, uint8_t a, uint8_t b, uint8_t c, uint8_t d)
Definition draw_queue.c:25
static uint16_t index_param
Definition draw_queue.c:6
void draw_cmd_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h)
Definition draw_rect.c:3
void(* cmd_t)(uint8_t, uint8_t, uint8_t, uint8_t)
Definition zeebo.h:8