aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/main.c b/src/main.c
index 5e0aad1..bf30628 100644
--- a/src/main.c
+++ b/src/main.c
@@ -45,7 +45,7 @@ static Device *devmouse;
45static Mouse mouse = {SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2}; 45static Mouse mouse = {SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2};
46 46
47void 47void
48nil_talk(Device *d, Uint8 b0, Uint8 w) { 48nil_talk(Device *d, u8 b0, u8 w) {
49 (void)d; 49 (void)d;
50 (void)b0; 50 (void)b0;
51 (void)w; 51 (void)w;
@@ -66,50 +66,50 @@ console_talk(Device *d, u8 b0, u8 w) {
66} 66}
67 67
68void 68void
69system_talk(Device *d, Uint8 b0, Uint8 w) { 69system_talk(Device *d, u8 b0, u8 w) {
70 if(!w) { 70 if(!w) {
71 d->dat[0x2] = d->u->wst.ptr; 71 d->dat[0x2] = d->u->wst.ptr;
72 d->dat[0x3] = d->u->rst.ptr; 72 d->dat[0x3] = d->u->rst.ptr;
73 } else { 73 } else {
74 putcolors(&ppu, &d->dat[0x8]); 74 putcolors(&d->dat[0x8]);
75 } 75 }
76 (void)b0; 76 (void)b0;
77} 77}
78 78
79IWRAM_CODE 79IWRAM_CODE
80void 80void
81screen_talk(Device *d, Uint8 b0, Uint8 w) { 81screen_talk(Device *d, u8 b0, u8 w) {
82 if(w && b0 == 0xe) { 82 if(w && b0 == 0xe) {
83 Uint16 x = mempeek16(d->dat, 0x8); 83 u16 x = mempeek16(d->dat, 0x8);
84 Uint16 y = mempeek16(d->dat, 0xa); 84 u16 y = mempeek16(d->dat, 0xa);
85 Uint8 *addr = &d->mem[mempeek16(d->dat, 0xc)]; 85 u8 *addr = &d->mem[mempeek16(d->dat, 0xc)];
86 Uint8 *layer = d->dat[0xe] >> 4 & 0x1 ? ppu.fg : ppu.bg; 86 u8 *layer = d->dat[0xe] >> 4 & 0x1 ? ppu.fg : ppu.bg;
87 Uint8 mode = d->dat[0xe] >> 5; 87 u8 mode = d->dat[0xe] >> 5;
88 if(!mode) { 88 if(!mode) {
89 putpixel(&ppu, layer, x, y, d->dat[0xe] & 0x3); 89 putpixel(layer, x, y, d->dat[0xe] & 0x3);
90 } else if(mode-- & 0x1) { 90 } else if(mode-- & 0x1) {
91 puticn(&ppu, layer, x, y, addr, d->dat[0xe] & 0xf, mode & 0x2, mode & 0x4); 91 puticn(layer, x, y, addr, d->dat[0xe] & 0xf, mode & 0x2, mode & 0x4);
92 } else { 92 } else {
93 putchr(&ppu, layer, x, y, addr, d->dat[0xe] & 0xf, mode & 0x2, mode & 0x4); 93 putchr(layer, x, y, addr, d->dat[0xe] & 0xf, mode & 0x2, mode & 0x4);
94 } 94 }
95 } 95 }
96} 96}
97 97
98void 98void
99datetime_talk(Device *d, Uint8 b0, Uint8 w) { 99datetime_talk(Device *d, u8 b0, u8 w) {
100 (void)d; 100 (void)d;
101 (void)b0; 101 (void)b0;
102 (void)w; 102 (void)w;
103} 103}
104 104
105void 105void
106file_talk(Device *d, Uint8 b0, Uint8 w) { 106file_talk(Device *d, u8 b0, u8 w) {
107 Uint8 read = b0 == 0xd; 107 u8 read = b0 == 0xd;
108 if(w && (read || b0 == 0xf)) { 108 if(w && (read || b0 == 0xf)) {
109 char *name = (char *)&d->mem[mempeek16(d->dat, 0x8)]; 109 char *name = (char *)&d->mem[mempeek16(d->dat, 0x8)];
110 Uint16 result = 0, length = mempeek16(d->dat, 0xa); 110 u16 result = 0, length = mempeek16(d->dat, 0xa);
111 Uint16 offset = mempeek16(d->dat, 0x4); 111 u16 offset = mempeek16(d->dat, 0x4);
112 Uint16 addr = mempeek16(d->dat, b0 - 1); 112 u16 addr = mempeek16(d->dat, b0 - 1);
113 int file_idx = fs_open_file(name, read ? OPEN_READ : OPEN_WRITE); 113 int file_idx = fs_open_file(name, read ? OPEN_READ : OPEN_WRITE);
114 if (file_idx >= 0) { 114 if (file_idx >= 0) {
115 if (read) { 115 if (read) {
@@ -177,7 +177,7 @@ handle_input(Uxn *u) {
177 if (control_method == CONTROL_CONTROLLER) { 177 if (control_method == CONTROL_CONTROLLER) {
178 // TODO: We don't need ifs if we use KEY_INPUTS directly and mayvbe just 178 // TODO: We don't need ifs if we use KEY_INPUTS directly and mayvbe just
179 // swap some things if needed. 179 // swap some things if needed.
180 Uint8 *flag = &devctrl->dat[2]; 180 u8 *flag = &devctrl->dat[2];
181 if (key_pressed(KEY_A)) { 181 if (key_pressed(KEY_A)) {
182 *flag |= 0x01; 182 *flag |= 0x01;
183 } else { 183 } else {
@@ -223,7 +223,7 @@ handle_input(Uxn *u) {
223 devctrl->dat[3] = 0; 223 devctrl->dat[3] = 0;
224 } else if (control_method == CONTROL_MOUSE) { 224 } else if (control_method == CONTROL_MOUSE) {
225 // Detect "mouse key press". 225 // Detect "mouse key press".
226 Uint8 flag = devmouse->dat[6]; 226 u8 flag = devmouse->dat[6];
227 if (key_tap(KEY_B)) { 227 if (key_tap(KEY_B)) {
228 flag |= 0x01; 228 flag |= 0x01;
229 } else if (key_released(KEY_B)) { 229 } else if (key_released(KEY_B)) {
@@ -265,7 +265,7 @@ handle_input(Uxn *u) {
265 265
266static Uxn u; 266static Uxn u;
267EWRAM_BSS 267EWRAM_BSS
268static Uint8 umem[65536]; 268static u8 umem[65536];
269 269
270int main(void) { 270int main(void) {
271 // Initialize filesystem. 271 // Initialize filesystem.