diff options
author | Bad Diode <bd@badd10de.dev> | 2023-08-29 16:07:10 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-08-29 16:07:10 +0200 |
commit | 50a369576e85c8ff6187ca808101a9008690be15 (patch) | |
tree | d2e2de99ade1f80422af83ebfae2f248454e513a | |
parent | 261fffa6e9772efd1c7648f7d11b4da3e19cf5dd (diff) | |
download | uxngba-50a369576e85c8ff6187ca808101a9008690be15.tar.gz uxngba-50a369576e85c8ff6187ca808101a9008690be15.zip |
Fix DEO to work consistently with existing deo_fn
-rw-r--r-- | src/main.c | 90 | ||||
-rw-r--r-- | src/uxn-core.s | 48 |
2 files changed, 92 insertions, 46 deletions
@@ -36,28 +36,37 @@ extern uintptr_t deo_map[16]; | |||
36 | extern uintptr_t dei_map[16]; | 36 | extern uintptr_t dei_map[16]; |
37 | extern uintptr_t wst_ptr; | 37 | extern uintptr_t wst_ptr; |
38 | extern uintptr_t rst_ptr; | 38 | extern uintptr_t rst_ptr; |
39 | extern u8 device_0[16]; | ||
40 | extern u8 device_1[16]; | ||
41 | extern u8 device_2[16]; | ||
42 | extern u8 device_3[16]; | ||
43 | extern u8 device_4[16]; | ||
44 | extern u8 device_5[16]; | ||
45 | extern u8 device_6[16]; | ||
46 | extern u8 device_7[16]; | ||
47 | extern u8 device_8[16]; | ||
48 | extern u8 device_a[16]; | ||
49 | extern u8 device_b[16]; | ||
50 | extern u8 device_c[16]; | ||
51 | extern u8 device_d[16]; | ||
52 | extern u8 device_e[16]; | ||
53 | extern u8 device_f[16]; | ||
39 | 54 | ||
40 | EWRAM_BSS | 55 | EWRAM_BSS |
41 | u8 uxn_ram[KB(64)]; | 56 | u8 uxn_ram[KB(64)]; |
42 | 57 | ||
43 | void | 58 | void |
44 | stub_a(u8 port, u16 val) { | 59 | deo_console(u8 *dev, u8 port) { |
45 | (void)port; | ||
46 | (void)val; | ||
47 | txt_printf("a"); | ||
48 | } | ||
49 | |||
50 | void | ||
51 | deo_console(u8 port, u16 val) { | ||
52 | switch(port) { | 60 | switch(port) { |
53 | case 0x8: | 61 | case 0x8: |
54 | txt_putc(val); | 62 | txt_putc(dev[port]); |
55 | return; | 63 | return; |
56 | case 0x9: | 64 | case 0x9: |
57 | txt_printf("ERROR: %c"); | 65 | txt_printf("ERROR: %c"); |
58 | txt_putc(val); | 66 | txt_putc(dev[port]); |
59 | return; | 67 | return; |
60 | } | 68 | } |
69 | txt_printf("\n"); | ||
61 | } | 70 | } |
62 | 71 | ||
63 | void | 72 | void |
@@ -190,10 +199,10 @@ init_uxn() { | |||
190 | // 0x60, 0x00, 0x03, 0x80, 0xff, 0x00, 0xa0, 0xaa, 0xbb, 0xa0, 0xcc, 0xdd, 0x6c | 199 | // 0x60, 0x00, 0x03, 0x80, 0xff, 0x00, 0xa0, 0xaa, 0xbb, 0xa0, 0xcc, 0xdd, 0x6c |
191 | // 0x80, 0x01, 0x20, 0x00, 0x03, 0x80, 0xff, 0x00, 0xa0, 0xaa, 0xbb, 0xa0, 0xcc, 0xdd, | 200 | // 0x80, 0x01, 0x20, 0x00, 0x03, 0x80, 0xff, 0x00, 0xa0, 0xaa, 0xbb, 0xa0, 0xcc, 0xdd, |
192 | // DEO/DEO2 | 201 | // DEO/DEO2 |
193 | // 0x80, 0x68, 0x80, 0x18, 0x17, 0x80, 0x65, 0x80, 0x18, 0x17, 0x80, 0x6c, 0x80, 0x18, 0x17, 0x80, | 202 | 0x80, 0x68, 0x80, 0x18, 0x17, 0x80, 0x65, 0x80, 0x18, 0x17, 0x80, 0x6c, 0x80, 0x18, 0x17, 0x80, |
194 | // 0x6c, 0x80, 0x18, 0x17, 0x80, 0x6f, 0x80, 0x18, 0x17, 0x80, 0x0a, 0x80, 0x18, 0x17, | ||
195 | 0xa0, 0x00, 0x68, 0x80, 0x18, 0x37, 0x80, 0x65, 0x80, 0x18, 0x17, 0x80, 0x6c, 0x80, 0x18, 0x17, 0x80, | ||
196 | 0x6c, 0x80, 0x18, 0x17, 0x80, 0x6f, 0x80, 0x18, 0x17, 0x80, 0x0a, 0x80, 0x18, 0x17, | 203 | 0x6c, 0x80, 0x18, 0x17, 0x80, 0x6f, 0x80, 0x18, 0x17, 0x80, 0x0a, 0x80, 0x18, 0x17, |
204 | // 0xa0, 0x00, 0x68, 0x80, 0x18, 0x37, 0x80, 0x65, 0x80, 0x18, 0x17, 0x80, 0x6c, 0x80, 0x18, 0x17, 0x80, | ||
205 | // 0x6c, 0x80, 0x18, 0x17, 0x80, 0x6f, 0x80, 0x18, 0x17, 0x80, 0x0a, 0x80, 0x18, 0x17, | ||
197 | }; | 206 | }; |
198 | memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); | 207 | memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); |
199 | } | 208 | } |
@@ -244,10 +253,9 @@ main(void) { | |||
244 | rst[i] = 0; | 253 | rst[i] = 0; |
245 | // TODO: Init device memory. | 254 | // TODO: Init device memory. |
246 | } | 255 | } |
247 | deo_map[0] = stub_a; | 256 | // TODO: ... |
248 | deo_map[1] = deo_console; | 257 | deo_map[1] = deo_console; |
249 | deo_map[2] = stub_c; | 258 | // TODO: ... |
250 | // ... | ||
251 | 259 | ||
252 | uxn_eval_asm(PAGE_PROGRAM); | 260 | uxn_eval_asm(PAGE_PROGRAM); |
253 | 261 | ||
@@ -260,31 +268,31 @@ main(void) { | |||
260 | // } | 268 | // } |
261 | // txt_printf("\n\n"); | 269 | // txt_printf("\n\n"); |
262 | 270 | ||
263 | txt_printf("WST ("); | 271 | // txt_printf("WST ("); |
264 | txt_printf("SIZE: %d)", wst_ptr - (uintptr_t)wst); | 272 | // txt_printf("SIZE: %d)", wst_ptr - (uintptr_t)wst); |
265 | for (size_t i = 0; i < 64; i++) { | 273 | // for (size_t i = 0; i < 64; i++) { |
266 | if (i % 8 == 0) { | 274 | // if (i % 8 == 0) { |
267 | txt_printf("\n"); | 275 | // txt_printf("\n"); |
268 | } | 276 | // } |
269 | if (i >= (wst_ptr - (uintptr_t)wst)) { | 277 | // if (i >= (wst_ptr - (uintptr_t)wst)) { |
270 | txt_printf("%02x ", 0); | 278 | // txt_printf("%02x ", 0); |
271 | } else { | 279 | // } else { |
272 | txt_printf("%02x ", wst[i]); | 280 | // txt_printf("%02x ", wst[i]); |
273 | } | 281 | // } |
274 | } | 282 | // } |
275 | txt_printf("\n\n"); | 283 | // txt_printf("\n\n"); |
276 | txt_printf("RST ("); | 284 | // txt_printf("RST ("); |
277 | txt_printf("SIZE: %d)", rst_ptr - (uintptr_t)rst); | 285 | // txt_printf("SIZE: %d)", rst_ptr - (uintptr_t)rst); |
278 | for (size_t i = 0; i < 64; i++) { | 286 | // for (size_t i = 0; i < 64; i++) { |
279 | if (i % 8 == 0) { | 287 | // if (i % 8 == 0) { |
280 | txt_printf("\n"); | 288 | // txt_printf("\n"); |
281 | } | 289 | // } |
282 | if (i >= (rst_ptr - (uintptr_t)rst)) { | 290 | // if (i >= (rst_ptr - (uintptr_t)rst)) { |
283 | txt_printf("%02x ", 0); | 291 | // txt_printf("%02x ", 0); |
284 | } else { | 292 | // } else { |
285 | txt_printf("%02x ", rst[i]); | 293 | // txt_printf("%02x ", rst[i]); |
286 | } | 294 | // } |
287 | } | 295 | // } |
288 | // txt_printf("\n\n"); | 296 | // txt_printf("\n\n"); |
289 | // txt_printf("RAM (ZP)\n"); | 297 | // txt_printf("RAM (ZP)\n"); |
290 | // for (size_t i = 0; i < 64; i++) { | 298 | // for (size_t i = 0; i < 64; i++) { |
diff --git a/src/uxn-core.s b/src/uxn-core.s index c73d44c..17f57a3 100644 --- a/src/uxn-core.s +++ b/src/uxn-core.s | |||
@@ -18,7 +18,39 @@ rst: .space 256 | |||
18 | rst_ptr: .word rst | 18 | rst_ptr: .word rst |
19 | 19 | ||
20 | .global device_data | 20 | .global device_data |
21 | device_data: .space 256 | 21 | device_data: |
22 | .global device_0 | ||
23 | device_0: .space 16 | ||
24 | .global device_1 | ||
25 | device_1: .space 16 | ||
26 | .global device_2 | ||
27 | device_2: .space 16 | ||
28 | .global device_3 | ||
29 | device_3: .space 16 | ||
30 | .global device_4 | ||
31 | device_4: .space 16 | ||
32 | .global device_5 | ||
33 | device_5: .space 16 | ||
34 | .global device_6 | ||
35 | device_6: .space 16 | ||
36 | .global device_7 | ||
37 | device_7: .space 16 | ||
38 | .global device_8 | ||
39 | device_8: .space 16 | ||
40 | .global device_9 | ||
41 | device_9: .space 16 | ||
42 | .global device_a | ||
43 | device_a: .space 16 | ||
44 | .global device_b | ||
45 | device_b: .space 16 | ||
46 | .global device_c | ||
47 | device_c: .space 16 | ||
48 | .global device_d | ||
49 | device_d: .space 16 | ||
50 | .global device_e | ||
51 | device_e: .space 16 | ||
52 | .global device_f | ||
53 | device_f: .space 16 | ||
22 | 54 | ||
23 | @ UXN evaluation function. | 55 | @ UXN evaluation function. |
24 | @ | 56 | @ |
@@ -824,8 +856,11 @@ deo: | |||
824 | adr r6, deo_map | 856 | adr r6, deo_map |
825 | ldr r6, [r6, r4, lsl #2] | 857 | ldr r6, [r6, r4, lsl #2] |
826 | stmfd sp!, {r0, r7, lr} | 858 | stmfd sp!, {r0, r7, lr} |
827 | mov r0, r3 | 859 | adr r0, device_data |
828 | mov r1, r5 | 860 | lsl r4, #4 |
861 | add r0, r4 | ||
862 | strb r5, [r0, r3] | ||
863 | mov r1, r3 | ||
829 | mov lr, pc | 864 | mov lr, pc |
830 | bx r6 | 865 | bx r6 |
831 | ldmfd sp!, {r0, r7, lr} | 866 | ldmfd sp!, {r0, r7, lr} |
@@ -841,8 +876,11 @@ deo2: | |||
841 | adr r6, deo_map | 876 | adr r6, deo_map |
842 | ldr r6, [r6, r4, lsl #2] | 877 | ldr r6, [r6, r4, lsl #2] |
843 | stmfd sp!, {r0, r7, lr} | 878 | stmfd sp!, {r0, r7, lr} |
844 | mov r0, r3 | 879 | adr r0, device_data |
845 | mov r1, r5 | 880 | lsl r4, #4 |
881 | add r0, r4 | ||
882 | strh r5, [r0, r3] | ||
883 | mov r1, r3 | ||
846 | mov lr, pc | 884 | mov lr, pc |
847 | bx r6 | 885 | bx r6 |
848 | ldmfd sp!, {r0, r7, lr} | 886 | ldmfd sp!, {r0, r7, lr} |