diff --git a/src/uxn.c b/src/uxn.c index 9efac2a..7b6fc8f 100644 --- a/src/uxn.c +++ b/src/uxn.c @@ -97,10 +97,10 @@ uxn_eval(Uxn *u, Uint16 pc) case 0x34: /* LDA2 */ t=T2; SET(2, 0) N = ram[t++]; T = ram[t]; break; case 0x15: /* STA */ t=T2;n=L; SET(3,-3) ram[t] = n; break; case 0x35: /* STA2 */ t=T2;n=N2; SET(4,-4) ram[t++] = n >> 8; ram[t] = n; break; - case 0x16: /* DEI */ t=T; SET(1, 0) T = emu_dei(u, t); break; - case 0x36: /* DEI2 */ t=T; SET(1, 1) N = emu_dei(u, t++); T = emu_dei(u, t); break; - case 0x17: /* DEO */ t=T;n=N; SET(2,-2) emu_deo(u, t, n); break; - case 0x37: /* DEO2 */ t=T;n=N;l=L; SET(3,-3) emu_deo(u, t++, l); emu_deo(u, t, n); break; + case 0x16: /* DEI */ t=T; SET(1, 0) T = emu_dei(t); break; + case 0x36: /* DEI2 */ t=T; SET(1, 1) N = emu_dei(t++); T = emu_dei(t); break; + case 0x17: /* DEO */ t=T;n=N; SET(2,-2) emu_deo(t, n); break; + case 0x37: /* DEO2 */ t=T;n=N;l=L; SET(3,-3) emu_deo(t++, l); emu_deo(t, n); break; case 0x18: /* ADD */ t=T;n=N; SET(2,-1) T = n + t; break; case 0x38: /* ADD2 */ t=T2;n=N2; SET(4,-2) T2_(n + t) break; case 0x19: /* SUB */ t=T;n=N; SET(2,-1) T = n - t; break; diff --git a/src/uxn.h b/src/uxn.h index f7a88a3..25d12db 100644 --- a/src/uxn.h +++ b/src/uxn.h @@ -35,8 +35,8 @@ typedef struct Uxn { /* required functions */ -extern Uint8 emu_dei(Uxn *u, Uint8 addr); -extern void emu_deo(Uxn *u, Uint8 addr, Uint8 value); +extern Uint8 emu_dei(Uint8 addr); +extern void emu_deo(Uint8 addr, Uint8 value); extern Uxn uxn; /* built-ins */ diff --git a/src/uxn11.c b/src/uxn11.c index dece440..750e222 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -45,32 +45,32 @@ clamp(int val, int min, int max) } Uint8 -emu_dei(Uxn *u, Uint8 addr) +emu_dei(Uint8 addr) { switch(addr & 0xf0) { - case 0x00: return system_dei(u, addr); - case 0x10: return console_dei(u, addr); - case 0x20: return screen_dei(u, addr); - case 0xc0: return datetime_dei(u, addr); + case 0x00: return system_dei(&uxn, addr); + case 0x10: return console_dei(&uxn, addr); + case 0x20: return screen_dei(&uxn, addr); + case 0xc0: return datetime_dei(&uxn, addr); } - return u->dev[addr]; + return uxn.dev[addr]; } void -emu_deo(Uxn *u, Uint8 addr, Uint8 value) +emu_deo(Uint8 addr, Uint8 value) { Uint8 p = addr & 0x0f, d = addr & 0xf0; - u->dev[addr] = value; + uxn.dev[addr] = value; switch(d) { case 0x00: - system_deo(u, &u->dev[d], p); + system_deo(&uxn, &uxn.dev[d], p); if(p > 0x7 && p < 0xe) - screen_palette(&u->dev[0x8]); + screen_palette(&uxn.dev[0x8]); break; - case 0x10: console_deo(u, &u->dev[d], p); break; - case 0x20: screen_deo(u->ram, &u->dev[d], p); break; - case 0xa0: file_deo(0, u->ram, &u->dev[d], p); break; - case 0xb0: file_deo(1, u->ram, &u->dev[d], p); break; + case 0x10: console_deo(&uxn, &uxn.dev[d], p); break; + case 0x20: screen_deo(uxn.ram, &uxn.dev[d], p); break; + case 0xa0: file_deo(0, uxn.ram, &uxn.dev[d], p); break; + case 0xb0: file_deo(1, uxn.ram, &uxn.dev[d], p); break; } } @@ -272,7 +272,7 @@ main(int argc, char **argv) int i = 1; char *rom; if(i != argc && argv[i][0] == '-' && argv[i][1] == 'v') { - fprintf(stdout, "Uxn11 - Varvara Emulator, 5 Jun 2024.\n"); + fprintf(stdout, "Uxn11 - Varvara Emulator, 29 Jun 2024.\n"); i++; } rom = i == argc ? "boot.rom" : argv[i++]; @@ -285,7 +285,7 @@ main(int argc, char **argv) return 0; } /* Game Loop */ - u.dev[0x17] = argc - i; + uxn.dev[0x17] = argc - i; if(uxn_eval(&uxn, PAGE_PROGRAM)) { console_listen(&uxn, i, argc, argv); emu_run(&uxn); diff --git a/src/uxncli.c b/src/uxncli.c index 34ba894..0b0d686 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -21,26 +21,26 @@ WITH REGARD TO THIS SOFTWARE. Uxn uxn; Uint8 -emu_dei(Uxn *u, Uint8 addr) +emu_dei(Uint8 addr) { switch(addr & 0xf0) { - case 0x00: return system_dei(u, addr); - case 0x10: return console_dei(u, addr); - case 0xc0: return datetime_dei(u, addr); + case 0x00: return system_dei(&uxn, addr); + case 0x10: return console_dei(&uxn, addr); + case 0xc0: return datetime_dei(&uxn, addr); } - return u->dev[addr]; + return uxn.dev[addr]; } void -emu_deo(Uxn *u, Uint8 addr, Uint8 value) +emu_deo(Uint8 addr, Uint8 value) { Uint8 p = addr & 0x0f, d = addr & 0xf0; - u->dev[addr] = value; + uxn.dev[addr] = value; switch(d) { - case 0x00: system_deo(u, &u->dev[d], p); break; - case 0x10: console_deo(u, &u->dev[d], p); break; - case 0xa0: file_deo(0, u->ram, &u->dev[d], p); break; - case 0xb0: file_deo(1, u->ram, &u->dev[d], p); break; + case 0x00: system_deo(&uxn, &uxn.dev[d], p); break; + case 0x10: console_deo(&uxn, &uxn.dev[d], p); break; + case 0xa0: file_deo(0, uxn.ram, &uxn.dev[d], p); break; + case 0xb0: file_deo(1, uxn.ram, &uxn.dev[d], p); break; } } @@ -72,7 +72,7 @@ main(int argc, char **argv) return system_error("usage", "uxncli [-v] file.rom [args..]"); /* Read flags */ if(argv[i][0] == '-' && argv[i][1] == 'v') - return system_version("Uxncli - Console Varvara Emulator", "18 Mar 2024"); + return system_version("Uxncli - Console Varvara Emulator", "29 Jun 2024"); if(!system_boot(&uxn, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++])) return system_error("Init", "Failed to initialize uxn."); /* Game Loop */