diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 46 | ||||
-rw-r--r-- | src/uxn.c | 174 | ||||
-rw-r--r-- | src/uxn.h | 6 |
3 files changed, 169 insertions, 57 deletions
@@ -229,22 +229,22 @@ init_uxn(Uxn *u) { | |||
229 | memcpy(u->ram.dat + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); | 229 | memcpy(u->ram.dat + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); |
230 | 230 | ||
231 | // Prepare devices. | 231 | // Prepare devices. |
232 | portuxn(u, 0x0, "system", system_talk); | 232 | uxn_port(u, 0x0, "system", system_talk); |
233 | portuxn(u, 0x1, "console", console_talk); | 233 | uxn_port(u, 0x1, "console", console_talk); |
234 | devscreen = portuxn(u, 0x2, "screen", screen_talk); | 234 | devscreen = uxn_port(u, 0x2, "screen", screen_talk); |
235 | devaudio = portuxn(u, 0x3, "audio0", audio_talk); | 235 | devaudio = uxn_port(u, 0x3, "audio0", audio_talk); |
236 | portuxn(u, 0x4, "audio1", audio_talk); | 236 | uxn_port(u, 0x4, "audio1", audio_talk); |
237 | portuxn(u, 0x5, "audio2", audio_talk); | 237 | uxn_port(u, 0x5, "audio2", audio_talk); |
238 | portuxn(u, 0x6, "audio3", audio_talk); | 238 | uxn_port(u, 0x6, "audio3", audio_talk); |
239 | portuxn(u, 0x7, "---", nil_talk); | 239 | uxn_port(u, 0x7, "---", nil_talk); |
240 | devctrl = portuxn(u, 0x8, "controller", nil_talk); | 240 | devctrl = uxn_port(u, 0x8, "controller", nil_talk); |
241 | devmouse = portuxn(u, 0x9, "mouse", nil_talk); | 241 | devmouse = uxn_port(u, 0x9, "mouse", nil_talk); |
242 | portuxn(u, 0xa, "file", file_talk); | 242 | uxn_port(u, 0xa, "file", file_talk); |
243 | portuxn(u, 0xb, "datetime", datetime_talk); | 243 | uxn_port(u, 0xb, "datetime", datetime_talk); |
244 | portuxn(u, 0xc, "---", nil_talk); | 244 | uxn_port(u, 0xc, "---", nil_talk); |
245 | portuxn(u, 0xd, "---", nil_talk); | 245 | uxn_port(u, 0xd, "---", nil_talk); |
246 | portuxn(u, 0xe, "---", nil_talk); | 246 | uxn_port(u, 0xe, "---", nil_talk); |
247 | portuxn(u, 0xf, "---", nil_talk); | 247 | uxn_port(u, 0xf, "---", nil_talk); |
248 | mempoke16(devscreen->dat, 2, ppu.hor * 8); | 248 | mempoke16(devscreen->dat, 2, ppu.hor * 8); |
249 | mempoke16(devscreen->dat, 4, ppu.ver * 8); | 249 | mempoke16(devscreen->dat, 4, ppu.ver * 8); |
250 | } | 250 | } |
@@ -258,7 +258,7 @@ handle_input(Uxn *u) { | |||
258 | switch (ctrl_methods[ctrl_idx]) { | 258 | switch (ctrl_methods[ctrl_idx]) { |
259 | case CONTROL_CONTROLLER: { | 259 | case CONTROL_CONTROLLER: { |
260 | devctrl->dat[2] = 0; | 260 | devctrl->dat[2] = 0; |
261 | evaluxn(u, mempeek16(devctrl->dat, 0)); | 261 | uxn_eval(u, mempeek16(devctrl->dat, 0)); |
262 | devctrl->dat[3] = 0; | 262 | devctrl->dat[3] = 0; |
263 | } break; | 263 | } break; |
264 | case CONTROL_MOUSE: { | 264 | case CONTROL_MOUSE: { |
@@ -266,7 +266,7 @@ handle_input(Uxn *u) { | |||
266 | devmouse->dat[7] = 0; | 266 | devmouse->dat[7] = 0; |
267 | mempoke16(devmouse->dat, 0x2, -10); | 267 | mempoke16(devmouse->dat, 0x2, -10); |
268 | mempoke16(devmouse->dat, 0x4, -10); | 268 | mempoke16(devmouse->dat, 0x4, -10); |
269 | evaluxn(u, mempeek16(devmouse->dat, 0)); | 269 | uxn_eval(u, mempeek16(devmouse->dat, 0)); |
270 | } break; | 270 | } break; |
271 | case CONTROL_KEYBOARD: { | 271 | case CONTROL_KEYBOARD: { |
272 | toggle_keyboard(); | 272 | toggle_keyboard(); |
@@ -327,7 +327,7 @@ handle_input(Uxn *u) { | |||
327 | *flag &= ~0x80; | 327 | *flag &= ~0x80; |
328 | } | 328 | } |
329 | 329 | ||
330 | evaluxn(u, mempeek16(devctrl->dat, 0)); | 330 | uxn_eval(u, mempeek16(devctrl->dat, 0)); |
331 | devctrl->dat[3] = 0; | 331 | devctrl->dat[3] = 0; |
332 | } else if (ctrl_methods[ctrl_idx] == CONTROL_MOUSE) { | 332 | } else if (ctrl_methods[ctrl_idx] == CONTROL_MOUSE) { |
333 | // Detect "mouse key press". | 333 | // Detect "mouse key press". |
@@ -367,7 +367,7 @@ handle_input(Uxn *u) { | |||
367 | // Eval mouse. | 367 | // Eval mouse. |
368 | mempoke16(devmouse->dat, 0x2, mouse.x); | 368 | mempoke16(devmouse->dat, 0x2, mouse.x); |
369 | mempoke16(devmouse->dat, 0x4, mouse.y); | 369 | mempoke16(devmouse->dat, 0x4, mouse.y); |
370 | evaluxn(u, mempeek16(devmouse->dat, 0)); | 370 | uxn_eval(u, mempeek16(devmouse->dat, 0)); |
371 | } else if (ctrl_methods[ctrl_idx] == CONTROL_KEYBOARD) { | 371 | } else if (ctrl_methods[ctrl_idx] == CONTROL_KEYBOARD) { |
372 | if (key_tap(KEY_LEFT)) { | 372 | if (key_tap(KEY_LEFT)) { |
373 | update_cursor(cursor_position - 1); | 373 | update_cursor(cursor_position - 1); |
@@ -411,7 +411,7 @@ handle_input(Uxn *u) { | |||
411 | devctrl->dat[3] = symbol; | 411 | devctrl->dat[3] = symbol; |
412 | } break; | 412 | } break; |
413 | } | 413 | } |
414 | evaluxn(u, mempeek16(devctrl->dat, 0)); | 414 | uxn_eval(u, mempeek16(devctrl->dat, 0)); |
415 | devctrl->dat[3] = 0; | 415 | devctrl->dat[3] = 0; |
416 | } | 416 | } |
417 | } | 417 | } |
@@ -445,12 +445,12 @@ int main(void) { | |||
445 | init_sound(); | 445 | init_sound(); |
446 | 446 | ||
447 | // Main loop. | 447 | // Main loop. |
448 | evaluxn(&u, 0x0100); | 448 | uxn_eval(&u, 0x0100); |
449 | PROF_INIT(); | 449 | PROF_INIT(); |
450 | while(true) { | 450 | while(true) { |
451 | bios_vblank_wait(); | 451 | bios_vblank_wait(); |
452 | PROF(handle_input(&u), input_cycles); | 452 | PROF(handle_input(&u), input_cycles); |
453 | PROF(evaluxn(&u, mempeek16(devscreen->dat, 0)), eval_cycles); | 453 | PROF(uxn_eval(&u, mempeek16(devscreen->dat, 0)), eval_cycles); |
454 | PROF(sound_mix(), mix_cycles); | 454 | PROF(sound_mix(), mix_cycles); |
455 | PROF_SHOW(); | 455 | PROF_SHOW(); |
456 | PROF(flipbuf(&ppu), flip_cycles); | 456 | PROF(flipbuf(&ppu), flip_cycles); |
@@ -30,35 +30,21 @@ See etc/mkuxn-fast.moon for instructions. | |||
30 | 30 | ||
31 | IWRAM_CODE | 31 | IWRAM_CODE |
32 | int | 32 | int |
33 | evaluxn(Uxn *u, u16 vec) | 33 | uxn_eval(Uxn *u, u16 vec) |
34 | { | 34 | { |
35 | u8 instr; | 35 | u8 instr; |
36 | if(u->dev[0].dat[0xf]) | 36 | if(!vec || u->dev[0].dat[0xf]) |
37 | return 0; | 37 | return 0; |
38 | u->ram.ptr = vec; | 38 | u->ram.ptr = vec; |
39 | if(u->wst.ptr > 0xf8) u->wst.ptr = 0xf8; | 39 | if(u->wst.ptr > 0xf8) u->wst.ptr = 0xf8; |
40 | while(u->ram.ptr) { | 40 | while((instr = u->ram.dat[u->ram.ptr++])) { |
41 | instr = u->ram.dat[u->ram.ptr++]; | ||
42 | switch(instr) { | 41 | switch(instr) { |
43 | #pragma GCC diagnostic push | 42 | #pragma GCC diagnostic push |
44 | #pragma GCC diagnostic ignored "-Wunused-value" | 43 | #pragma GCC diagnostic ignored "-Wunused-value" |
45 | #pragma GCC diagnostic ignored "-Wunused-variable" | 44 | #pragma GCC diagnostic ignored "-Wunused-variable" |
46 | case 0x00: /* BRK */ | 45 | case 0x00: /* LIT */ |
47 | case 0x20: /* BRK2 */ | 46 | case 0x80: /* LITk */ |
48 | case 0x40: /* BRKr */ | 47 | __asm__("evaluxn_00_LIT:"); |
49 | case 0x60: /* BRK2r */ | ||
50 | case 0x80: /* BRKk */ | ||
51 | case 0xa0: /* BRK2k */ | ||
52 | case 0xc0: /* BRKkr */ | ||
53 | case 0xe0: /* BRK2kr */ | ||
54 | __asm__("evaluxn_00_BRK:"); | ||
55 | { | ||
56 | u->ram.ptr = 0; | ||
57 | } | ||
58 | break; | ||
59 | case 0x01: /* LIT */ | ||
60 | case 0x81: /* LITk */ | ||
61 | __asm__("evaluxn_01_LIT:"); | ||
62 | { | 48 | { |
63 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr++); | 49 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr++); |
64 | #ifndef NO_STACK_CHECKS | 50 | #ifndef NO_STACK_CHECKS |
@@ -70,6 +56,19 @@ evaluxn(Uxn *u, u16 vec) | |||
70 | u->wst.ptr += 1; | 56 | u->wst.ptr += 1; |
71 | } | 57 | } |
72 | break; | 58 | break; |
59 | case 0x01: /* INC */ | ||
60 | __asm__("evaluxn_01_INC:"); | ||
61 | { | ||
62 | u8 a = u->wst.dat[u->wst.ptr - 1]; | ||
63 | u->wst.dat[u->wst.ptr - 1] = a + 1; | ||
64 | #ifndef NO_STACK_CHECKS | ||
65 | if(__builtin_expect(u->wst.ptr < 1, 0)) { | ||
66 | u->wst.error = 1; | ||
67 | goto error; | ||
68 | } | ||
69 | #endif | ||
70 | } | ||
71 | break; | ||
73 | case 0x02: /* POP */ | 72 | case 0x02: /* POP */ |
74 | __asm__("evaluxn_02_POP:"); | 73 | __asm__("evaluxn_02_POP:"); |
75 | { | 74 | { |
@@ -522,9 +521,9 @@ evaluxn(Uxn *u, u16 vec) | |||
522 | u->wst.ptr -= 1; | 521 | u->wst.ptr -= 1; |
523 | } | 522 | } |
524 | break; | 523 | break; |
525 | case 0x21: /* LIT2 */ | 524 | case 0x20: /* LIT2 */ |
526 | case 0xa1: /* LIT2k */ | 525 | case 0xa0: /* LIT2k */ |
527 | __asm__("evaluxn_21_LIT2:"); | 526 | __asm__("evaluxn_20_LIT2:"); |
528 | { | 527 | { |
529 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr++); | 528 | u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr++); |
530 | u->wst.dat[u->wst.ptr + 1] = mempeek8(u->ram.dat, u->ram.ptr++); | 529 | u->wst.dat[u->wst.ptr + 1] = mempeek8(u->ram.dat, u->ram.ptr++); |
@@ -537,6 +536,20 @@ evaluxn(Uxn *u, u16 vec) | |||
537 | u->wst.ptr += 2; | 536 | u->wst.ptr += 2; |
538 | } | 537 | } |
539 | break; | 538 | break; |
539 | case 0x21: /* INC2 */ | ||
540 | __asm__("evaluxn_21_INC2:"); | ||
541 | { | ||
542 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); | ||
543 | u->wst.dat[u->wst.ptr - 2] = (a + 1) >> 8; | ||
544 | u->wst.dat[u->wst.ptr - 1] = (a + 1) & 0xff; | ||
545 | #ifndef NO_STACK_CHECKS | ||
546 | if(__builtin_expect(u->wst.ptr < 2, 0)) { | ||
547 | u->wst.error = 1; | ||
548 | goto error; | ||
549 | } | ||
550 | #endif | ||
551 | } | ||
552 | break; | ||
540 | case 0x22: /* POP2 */ | 553 | case 0x22: /* POP2 */ |
541 | __asm__("evaluxn_22_POP2:"); | 554 | __asm__("evaluxn_22_POP2:"); |
542 | { | 555 | { |
@@ -1024,9 +1037,9 @@ evaluxn(Uxn *u, u16 vec) | |||
1024 | u->wst.ptr -= 1; | 1037 | u->wst.ptr -= 1; |
1025 | } | 1038 | } |
1026 | break; | 1039 | break; |
1027 | case 0x41: /* LITr */ | 1040 | case 0x40: /* LITr */ |
1028 | case 0xc1: /* LITkr */ | 1041 | case 0xc0: /* LITkr */ |
1029 | __asm__("evaluxn_41_LITr:"); | 1042 | __asm__("evaluxn_40_LITr:"); |
1030 | { | 1043 | { |
1031 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr++); | 1044 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr++); |
1032 | #ifndef NO_STACK_CHECKS | 1045 | #ifndef NO_STACK_CHECKS |
@@ -1038,6 +1051,19 @@ evaluxn(Uxn *u, u16 vec) | |||
1038 | u->rst.ptr += 1; | 1051 | u->rst.ptr += 1; |
1039 | } | 1052 | } |
1040 | break; | 1053 | break; |
1054 | case 0x41: /* INCr */ | ||
1055 | __asm__("evaluxn_41_INCr:"); | ||
1056 | { | ||
1057 | u8 a = u->rst.dat[u->rst.ptr - 1]; | ||
1058 | u->rst.dat[u->rst.ptr - 1] = a + 1; | ||
1059 | #ifndef NO_STACK_CHECKS | ||
1060 | if(__builtin_expect(u->rst.ptr < 1, 0)) { | ||
1061 | u->rst.error = 1; | ||
1062 | goto error; | ||
1063 | } | ||
1064 | #endif | ||
1065 | } | ||
1066 | break; | ||
1041 | case 0x42: /* POPr */ | 1067 | case 0x42: /* POPr */ |
1042 | __asm__("evaluxn_42_POPr:"); | 1068 | __asm__("evaluxn_42_POPr:"); |
1043 | { | 1069 | { |
@@ -1490,9 +1516,9 @@ evaluxn(Uxn *u, u16 vec) | |||
1490 | u->rst.ptr -= 1; | 1516 | u->rst.ptr -= 1; |
1491 | } | 1517 | } |
1492 | break; | 1518 | break; |
1493 | case 0x61: /* LIT2r */ | 1519 | case 0x60: /* LIT2r */ |
1494 | case 0xe1: /* LIT2kr */ | 1520 | case 0xe0: /* LIT2kr */ |
1495 | __asm__("evaluxn_61_LIT2r:"); | 1521 | __asm__("evaluxn_60_LIT2r:"); |
1496 | { | 1522 | { |
1497 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr++); | 1523 | u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr++); |
1498 | u->rst.dat[u->rst.ptr + 1] = mempeek8(u->ram.dat, u->ram.ptr++); | 1524 | u->rst.dat[u->rst.ptr + 1] = mempeek8(u->ram.dat, u->ram.ptr++); |
@@ -1505,6 +1531,20 @@ evaluxn(Uxn *u, u16 vec) | |||
1505 | u->rst.ptr += 2; | 1531 | u->rst.ptr += 2; |
1506 | } | 1532 | } |
1507 | break; | 1533 | break; |
1534 | case 0x61: /* INC2r */ | ||
1535 | __asm__("evaluxn_61_INC2r:"); | ||
1536 | { | ||
1537 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); | ||
1538 | u->rst.dat[u->rst.ptr - 2] = (a + 1) >> 8; | ||
1539 | u->rst.dat[u->rst.ptr - 1] = (a + 1) & 0xff; | ||
1540 | #ifndef NO_STACK_CHECKS | ||
1541 | if(__builtin_expect(u->rst.ptr < 2, 0)) { | ||
1542 | u->rst.error = 1; | ||
1543 | goto error; | ||
1544 | } | ||
1545 | #endif | ||
1546 | } | ||
1547 | break; | ||
1508 | case 0x62: /* POP2r */ | 1548 | case 0x62: /* POP2r */ |
1509 | __asm__("evaluxn_62_POP2r:"); | 1549 | __asm__("evaluxn_62_POP2r:"); |
1510 | { | 1550 | { |
@@ -1992,6 +2032,24 @@ evaluxn(Uxn *u, u16 vec) | |||
1992 | u->rst.ptr -= 1; | 2032 | u->rst.ptr -= 1; |
1993 | } | 2033 | } |
1994 | break; | 2034 | break; |
2035 | case 0x81: /* INCk */ | ||
2036 | __asm__("evaluxn_81_INCk:"); | ||
2037 | { | ||
2038 | u8 a = u->wst.dat[u->wst.ptr - 1]; | ||
2039 | u->wst.dat[u->wst.ptr] = a + 1; | ||
2040 | #ifndef NO_STACK_CHECKS | ||
2041 | if(__builtin_expect(u->wst.ptr < 1, 0)) { | ||
2042 | u->wst.error = 1; | ||
2043 | goto error; | ||
2044 | } | ||
2045 | if(__builtin_expect(u->wst.ptr > 254, 0)) { | ||
2046 | u->wst.error = 2; | ||
2047 | goto error; | ||
2048 | } | ||
2049 | #endif | ||
2050 | u->wst.ptr += 1; | ||
2051 | } | ||
2052 | break; | ||
1995 | case 0x82: /* POPk */ | 2053 | case 0x82: /* POPk */ |
1996 | __asm__("evaluxn_82_POPk:"); | 2054 | __asm__("evaluxn_82_POPk:"); |
1997 | { | 2055 | { |
@@ -2515,6 +2573,25 @@ evaluxn(Uxn *u, u16 vec) | |||
2515 | u->wst.ptr += 1; | 2573 | u->wst.ptr += 1; |
2516 | } | 2574 | } |
2517 | break; | 2575 | break; |
2576 | case 0xa1: /* INC2k */ | ||
2577 | __asm__("evaluxn_a1_INC2k:"); | ||
2578 | { | ||
2579 | u16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); | ||
2580 | u->wst.dat[u->wst.ptr] = (a + 1) >> 8; | ||
2581 | u->wst.dat[u->wst.ptr + 1] = (a + 1) & 0xff; | ||
2582 | #ifndef NO_STACK_CHECKS | ||
2583 | if(__builtin_expect(u->wst.ptr < 2, 0)) { | ||
2584 | u->wst.error = 1; | ||
2585 | goto error; | ||
2586 | } | ||
2587 | if(__builtin_expect(u->wst.ptr > 253, 0)) { | ||
2588 | u->wst.error = 2; | ||
2589 | goto error; | ||
2590 | } | ||
2591 | #endif | ||
2592 | u->wst.ptr += 2; | ||
2593 | } | ||
2594 | break; | ||
2518 | case 0xa2: /* POP2k */ | 2595 | case 0xa2: /* POP2k */ |
2519 | __asm__("evaluxn_a2_POP2k:"); | 2596 | __asm__("evaluxn_a2_POP2k:"); |
2520 | { | 2597 | { |
@@ -3062,6 +3139,24 @@ evaluxn(Uxn *u, u16 vec) | |||
3062 | u->wst.ptr += 2; | 3139 | u->wst.ptr += 2; |
3063 | } | 3140 | } |
3064 | break; | 3141 | break; |
3142 | case 0xc1: /* INCkr */ | ||
3143 | __asm__("evaluxn_c1_INCkr:"); | ||
3144 | { | ||
3145 | u8 a = u->rst.dat[u->rst.ptr - 1]; | ||
3146 | u->rst.dat[u->rst.ptr] = a + 1; | ||
3147 | #ifndef NO_STACK_CHECKS | ||
3148 | if(__builtin_expect(u->rst.ptr < 1, 0)) { | ||
3149 | u->rst.error = 1; | ||
3150 | goto error; | ||
3151 | } | ||
3152 | if(__builtin_expect(u->rst.ptr > 254, 0)) { | ||
3153 | u->rst.error = 2; | ||
3154 | goto error; | ||
3155 | } | ||
3156 | #endif | ||
3157 | u->rst.ptr += 1; | ||
3158 | } | ||
3159 | break; | ||
3065 | case 0xc2: /* POPkr */ | 3160 | case 0xc2: /* POPkr */ |
3066 | __asm__("evaluxn_c2_POPkr:"); | 3161 | __asm__("evaluxn_c2_POPkr:"); |
3067 | { | 3162 | { |
@@ -3585,6 +3680,25 @@ evaluxn(Uxn *u, u16 vec) | |||
3585 | u->rst.ptr += 1; | 3680 | u->rst.ptr += 1; |
3586 | } | 3681 | } |
3587 | break; | 3682 | break; |
3683 | case 0xe1: /* INC2kr */ | ||
3684 | __asm__("evaluxn_e1_INC2kr:"); | ||
3685 | { | ||
3686 | u16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); | ||
3687 | u->rst.dat[u->rst.ptr] = (a + 1) >> 8; | ||
3688 | u->rst.dat[u->rst.ptr + 1] = (a + 1) & 0xff; | ||
3689 | #ifndef NO_STACK_CHECKS | ||
3690 | if(__builtin_expect(u->rst.ptr < 2, 0)) { | ||
3691 | u->rst.error = 1; | ||
3692 | goto error; | ||
3693 | } | ||
3694 | if(__builtin_expect(u->rst.ptr > 253, 0)) { | ||
3695 | u->rst.error = 2; | ||
3696 | goto error; | ||
3697 | } | ||
3698 | #endif | ||
3699 | u->rst.ptr += 2; | ||
3700 | } | ||
3701 | break; | ||
3588 | case 0xe2: /* POP2kr */ | 3702 | case 0xe2: /* POP2kr */ |
3589 | __asm__("evaluxn_e2_POP2kr:"); | 3703 | __asm__("evaluxn_e2_POP2kr:"); |
3590 | { | 3704 | { |
@@ -4143,7 +4257,7 @@ error: | |||
4143 | } | 4257 | } |
4144 | 4258 | ||
4145 | Device * | 4259 | Device * |
4146 | portuxn(Uxn *u, u8 id, char *name, void (*talkfn)(Device *d, u8 b0, u8 w)) | 4260 | uxn_port(Uxn *u, u8 id, char *name, void (*talkfn)(Device *d, u8 b0, u8 w)) |
4147 | { | 4261 | { |
4148 | Device *d = &u->dev[id]; | 4262 | Device *d = &u->dev[id]; |
4149 | d->addr = id * 0x10; | 4263 | d->addr = id * 0x10; |
@@ -49,8 +49,6 @@ static inline u8 devpeek8(Device *d, u8 a) { d->talk(d, a & 0x0f, 0); return d-> | |||
49 | static inline void devpoke16(Device *d, u8 a, u16 b) { devpoke8(d, a, b >> 8); devpoke8(d, a + 1, b); } | 49 | static inline void devpoke16(Device *d, u8 a, u16 b) { devpoke8(d, a, b >> 8); devpoke8(d, a + 1, b); } |
50 | static inline u16 devpeek16(Device *d, u16 a) { return (devpeek8(d, a) << 8) + devpeek8(d, a + 1); } | 50 | static inline u16 devpeek16(Device *d, u16 a) { return (devpeek8(d, a) << 8) + devpeek8(d, a + 1); } |
51 | 51 | ||
52 | int loaduxn(Uxn *c, char *filepath); | 52 | int uxn_eval(Uxn *u, u16 vec); |
53 | int bootuxn(Uxn *c); | 53 | Device *uxn_port(Uxn *u, u8 id, char *name, void (*talkfn)(Device *, u8, u8)); |
54 | int evaluxn(Uxn *u, u16 vec); | ||
55 | Device *portuxn(Uxn *u, u8 id, char *name, void (*talkfn)(Device *, u8, u8)); | ||
56 | #endif // UXNGBA_UXN_H | 54 | #endif // UXNGBA_UXN_H |