commit b3fcbe9
Devine Lu Linvega
·
2024-07-01 15:11:07 +0000 UTC
parent 9b9aae5
Let the console_input do the cast
4 files changed,
+18,
-31
+4,
-5
1@@ -82,12 +82,11 @@ clean_after_child(void)
2 }
3
4 int
5-console_input(char c, int type)
6+console_input(Uint8 c, int type)
7 {
8- Uint8 *d = &uxn.dev[0x10];
9- d[0x2] = c;
10- d[0x7] = type;
11- return uxn_eval(PEEK2(d));
12+ uxn.dev[0x12] = c;
13+ uxn.dev[0x17] = type;
14+ return uxn_eval(PEEK2(&uxn.dev[0x10]));
15 }
16
17 void
+1,
-1
1@@ -14,7 +14,7 @@ WITH REGARD TO THIS SOFTWARE.
2 #define CONSOLE_EOA 0x3
3 #define CONSOLE_END 0x4
4
5-int console_input(char c, int type);
6+int console_input(Uint8 c, int type);
7 void console_listen(int i, int argc, char **argv);
8 Uint8 console_dei(Uint8 addr);
9 void console_deo(Uint8 port);
+1,
-1
1@@ -172,7 +172,7 @@ emu_event(void)
2 if(e->button == 4)
3 mouse_scroll(0, 1);
4 else if(e->button == 5)
5- mouse_scroll( 0, -1);
6+ mouse_scroll(0, -1);
7 else if(e->button == 6)
8 mouse_scroll(1, 0);
9 else if(e->button == 7)
+12,
-24
1@@ -34,9 +34,9 @@ emu_dei(Uint8 addr)
2 void
3 emu_deo(Uint8 addr, Uint8 value)
4 {
5- Uint8 p = addr & 0x0f, d = addr & 0xf0;
6+ Uint8 p = addr & 0x0f;
7 uxn.dev[addr] = value;
8- switch(d) {
9+ switch(addr & 0xf0) {
10 case 0x00: system_deo(p); break;
11 case 0x10: console_deo(p); break;
12 case 0xa0: file_deo(0, p); break;
13@@ -44,26 +44,6 @@ emu_deo(Uint8 addr, Uint8 value)
14 }
15 }
16
17-static void
18-emu_run(void)
19-{
20- while(!uxn.dev[0x0f]) {
21- int c = fgetc(stdin);
22- if(c == EOF) {
23- console_input(0x00, CONSOLE_END);
24- break;
25- }
26- console_input((Uint8)c, CONSOLE_STD);
27- }
28-}
29-
30-static int
31-emu_end(void)
32-{
33- free(uxn.ram);
34- return uxn.dev[0x0f] & 0x7f;
35-}
36-
37 int
38 main(int argc, char **argv)
39 {
40@@ -79,7 +59,15 @@ main(int argc, char **argv)
41 uxn.dev[0x17] = argc - i;
42 if(uxn_eval(PAGE_PROGRAM) && PEEK2(uxn.dev + 0x10)) {
43 console_listen(i, argc, argv);
44- emu_run();
45+ while(!uxn.dev[0x0f]) {
46+ int c = fgetc(stdin);
47+ if(c == EOF) {
48+ console_input(0x00, CONSOLE_END);
49+ break;
50+ }
51+ console_input(c, CONSOLE_STD);
52+ }
53 }
54- return emu_end();
55+ free(uxn.ram);
56+ return uxn.dev[0x0f] & 0x7f;
57 }