commit d69d150
neauoire
·
2023-11-10 17:32:34 +0000 UTC
parent 59edc06
Starting console process setup
5 files changed,
+40,
-18
+28,
-9
1@@ -35,16 +35,35 @@ console_listen(Uxn *u, int i, int argc, char **argv)
2 }
3
4 void
5-console_deo(Uint8 *d, Uint8 port)
6+start_fork(Uxn *u, Uint8 *d)
7 {
8+ /* TODO */
9+}
10+
11+void
12+kill_child(Uint8 *d)
13+{
14+ /* TODO */
15+}
16+
17+Uint8
18+console_dei(Uxn *u, Uint8 addr)
19+{
20+ /* TODO */
21+}
22+
23+void
24+console_deo(Uxn *u, Uint8 *d, Uint8 port)
25+{
26+ FILE *fd = NULL;
27 switch(port) {
28- case 0x8:
29- fputc(d[port], stdout);
30- fflush(stdout);
31- return;
32- case 0x9:
33- fputc(d[port], stderr);
34- fflush(stderr);
35- return;
36+ case 0x5: /* Console/dead */ start_fork(u, d); break;
37+ case 0x6: /* Console/exit*/ kill_child(d); break;
38+ case 0x8: fd = stdout; break;
39+ case 0x9: fd = stderr; break;
40+ }
41+ if(fd) {
42+ fputc(d[port], fd);
43+ fflush(fd);
44 }
45 }
+2,
-1
1@@ -20,4 +20,5 @@ WITH REGARD TO THIS SOFTWARE.
2
3 int console_input(Uxn *u, char c, int type);
4 void console_listen(Uxn *u, int i, int argc, char **argv);
5-void console_deo(Uint8 *d, Uint8 port);
6+Uint8 console_dei(Uxn *u, Uint8 addr);
7+void console_deo(Uxn *u, Uint8 *d, Uint8 port);
+6,
-6
1@@ -96,16 +96,16 @@ screen_debugger(Uxn *u)
2 int i;
3 for(i = 0; i < 0x08; i++) {
4 Uint8 pos = u->wst.ptr - 4 + i;
5- Uint8 color = i > 4 ? 0x01 : !pos ? 0xc
6- : i == 4 ? 0x8
7- : 0x2;
8+ Uint8 color = i > 4 ? 0x01 : !pos ? 0xc :
9+ i == 4 ? 0x8 :
10+ 0x2;
11 draw_byte(u->wst.dat[pos], i * 0x18 + 0x8, uxn_screen.height - 0x18, color);
12 }
13 for(i = 0; i < 0x08; i++) {
14 Uint8 pos = u->rst.ptr - 4 + i;
15- Uint8 color = i > 4 ? 0x01 : !pos ? 0xc
16- : i == 4 ? 0x8
17- : 0x2;
18+ Uint8 color = i > 4 ? 0x01 : !pos ? 0xc :
19+ i == 4 ? 0x8 :
20+ 0x2;
21 draw_byte(u->rst.dat[pos], i * 0x18 + 0x8, uxn_screen.height - 0x10, color);
22 }
23 screen_blit(uxn_screen.fg, arrow, 0, 0x68, uxn_screen.height - 0x20, 3, 0, 0, 0);
+2,
-1
1@@ -49,6 +49,7 @@ emu_dei(Uxn *u, Uint8 addr)
2 {
3 switch(addr & 0xf0) {
4 case 0x00: return system_dei(u, addr);
5+ case 0x10: return console_dei(u, addr);
6 case 0x20: return screen_dei(u, addr);
7 case 0xc0: return datetime_dei(u, addr);
8 }
9@@ -66,7 +67,7 @@ emu_deo(Uxn *u, Uint8 addr, Uint8 value)
10 if(p > 0x7 && p < 0xe)
11 screen_palette(&u->dev[0x8]);
12 break;
13- case 0x10: console_deo(&u->dev[d], p); break;
14+ case 0x10: console_deo(u, &u->dev[d], p); break;
15 case 0x20: screen_deo(u->ram, &u->dev[d], p); break;
16 case 0xa0: file_deo(0, u->ram, &u->dev[d], p); break;
17 case 0xb0: file_deo(1, u->ram, &u->dev[d], p); break;
+2,
-1
1@@ -23,6 +23,7 @@ emu_dei(Uxn *u, Uint8 addr)
2 {
3 switch(addr & 0xf0) {
4 case 0x00: return system_dei(u, addr);
5+ case 0x10: return console_dei(u, addr);
6 case 0xc0: return datetime_dei(u, addr);
7 }
8 return u->dev[addr];
9@@ -35,7 +36,7 @@ emu_deo(Uxn *u, Uint8 addr, Uint8 value)
10 u->dev[addr] = value;
11 switch(d) {
12 case 0x00: system_deo(u, &u->dev[d], p); break;
13- case 0x10: console_deo(&u->dev[d], p); break;
14+ case 0x10: console_deo(u, &u->dev[d], p); break;
15 case 0xa0: file_deo(0, u->ram, &u->dev[d], p); break;
16 case 0xb0: file_deo(1, u->ram, &u->dev[d], p); break;
17 }