... | ... |
@@ -1,4 +1,5 @@ |
1 | 1 |
#include "../uxn.h" |
2 |
+#include "system.h" |
|
2 | 3 |
|
3 | 4 |
#include <stdio.h> |
4 | 5 |
|
... | ... |
@@ -27,3 +28,25 @@ uxn_halt(Uxn *u, Uint8 error, Uint16 addr) |
27 | 28 |
fprintf(stderr, "Halted: %s#%04x, at 0x%04x\n", errors[error], u->ram[addr], addr); |
28 | 29 |
return 0; |
29 | 30 |
} |
31 |
+ |
|
32 |
+/* IO */ |
|
33 |
+ |
|
34 |
+Uint8 |
|
35 |
+system_dei(Device *d, Uint8 port) |
|
36 |
+{ |
|
37 |
+ switch(port) { |
|
38 |
+ case 0x2: return d->u->wst.ptr; |
|
39 |
+ case 0x3: return d->u->rst.ptr; |
|
40 |
+ default: return d->dat[port]; |
|
41 |
+ } |
|
42 |
+} |
|
43 |
+ |
|
44 |
+void |
|
45 |
+system_deo(Device *d, Uint8 port) |
|
46 |
+{ |
|
47 |
+ switch(port) { |
|
48 |
+ case 0x2: d->u->wst.ptr = d->dat[port]; break; |
|
49 |
+ case 0x3: d->u->rst.ptr = d->dat[port]; break; |
|
50 |
+ default: system_deo_special(d, port); |
|
51 |
+ } |
|
52 |
+} |
30 | 53 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,14 @@ |
1 |
+/* |
|
2 |
+Copyright (c) 2022 Devine Lu Linvega, Andrew Alderwick |
|
3 |
+ |
|
4 |
+Permission to use, copy, modify, and distribute this software for any |
|
5 |
+purpose with or without fee is hereby granted, provided that the above |
|
6 |
+copyright notice and this permission notice appear in all copies. |
|
7 |
+ |
|
8 |
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
9 |
+WITH REGARD TO THIS SOFTWARE. |
|
10 |
+*/ |
|
11 |
+ |
|
12 |
+Uint8 system_dei(Device *d, Uint8 port); |
|
13 |
+void system_deo(Device *d, Uint8 port); |
|
14 |
+void system_deo_special(Device *d, Uint8 port); |
... | ... |
@@ -3,6 +3,7 @@ |
3 | 3 |
#include <unistd.h> |
4 | 4 |
#include <time.h> |
5 | 5 |
#include "uxn.h" |
6 |
+#include "devices/system.h" |
|
6 | 7 |
#include "devices/file.h" |
7 | 8 |
|
8 | 9 |
/* |
... | ... |
@@ -45,26 +46,12 @@ inspect(Stack *s, char *name) |
45 | 46 |
|
46 | 47 |
#pragma mark - Devices |
47 | 48 |
|
48 |
-static Uint8 |
|
49 |
-system_dei(Device *d, Uint8 port) |
|
49 |
+void |
|
50 |
+system_deo_special(Device *d, Uint8 port) |
|
50 | 51 |
{ |
51 |
- switch(port) { |
|
52 |
- case 0x2: return d->u->wst.ptr; |
|
53 |
- case 0x3: return d->u->rst.ptr; |
|
54 |
- default: return d->dat[port]; |
|
55 |
- } |
|
56 |
-} |
|
57 |
- |
|
58 |
-static void |
|
59 |
-system_deo(Device *d, Uint8 port) |
|
60 |
-{ |
|
61 |
- switch(port) { |
|
62 |
- case 0x2: d->u->wst.ptr = d->dat[port]; break; |
|
63 |
- case 0x3: d->u->rst.ptr = d->dat[port]; break; |
|
64 |
- case 0xe: |
|
52 |
+ if(port == 0xe) { |
|
65 | 53 |
inspect(&d->u->wst, "Working-stack"); |
66 | 54 |
inspect(&d->u->rst, "Return-stack"); |
67 |
- break; |
|
68 | 55 |
} |
69 | 56 |
} |
70 | 57 |
|
... | ... |
@@ -8,6 +8,7 @@ |
8 | 8 |
#pragma GCC diagnostic ignored "-Wpedantic" |
9 | 9 |
#pragma clang diagnostic ignored "-Wtypedef-redefinition" |
10 | 10 |
#include <SDL.h> |
11 |
+#include "devices/system.h" |
|
11 | 12 |
#include "devices/screen.h" |
12 | 13 |
#include "devices/audio.h" |
13 | 14 |
#include "devices/file.h" |
... | ... |
@@ -169,23 +170,9 @@ init(void) |
169 | 170 |
|
170 | 171 |
#pragma mark - Devices |
171 | 172 |
|
172 |
-static Uint8 |
|
173 |
-system_dei(Device *d, Uint8 port) |
|
174 |
-{ |
|
175 |
- switch(port) { |
|
176 |
- case 0x2: return d->u->wst.ptr; |
|
177 |
- case 0x3: return d->u->rst.ptr; |
|
178 |
- default: return d->dat[port]; |
|
179 |
- } |
|
180 |
-} |
|
181 |
- |
|
182 |
-static void |
|
183 |
-system_deo(Device *d, Uint8 port) |
|
173 |
+void |
|
174 |
+system_deo_special(Device *d, Uint8 port) |
|
184 | 175 |
{ |
185 |
- switch(port) { |
|
186 |
- case 0x2: d->u->wst.ptr = d->dat[port]; break; |
|
187 |
- case 0x3: d->u->rst.ptr = d->dat[port]; break; |
|
188 |
- } |
|
189 | 176 |
if(port > 0x7 && port < 0xe) |
190 | 177 |
screen_palette(&uxn_screen, &d->dat[0x8]); |
191 | 178 |
} |