From 7992d541153e32f5bfa94a48829af4f3a03b4a2e Mon Sep 17 00:00:00 2001 From: neauoire Date: Tue, 29 Aug 2023 09:41:00 -0700 Subject: [PATCH] (uxn.c) Removed needless masking of opcode lookup --- src/uxn.c | 27 +++++++++++++-------------- src/uxncli.c | 2 +- src/uxnemu.c | 2 +- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/uxn.c b/src/uxn.c index d62b61d..91b54bb 100644 --- a/src/uxn.c +++ b/src/uxn.c @@ -34,23 +34,22 @@ WITH REGARD TO THIS SOFTWARE. int uxn_eval(Uxn *u, Uint16 pc) { - int t, n, l, k, r; - Uint8 *ram = u->ram, *ptr, ins; - Stack *s; + int t, n, l, r; + Uint8 *ram = u->ram; if(!pc || u->dev[0x0f]) return 0; for(;;) { - ins = ram[pc++]; - k = ins & 0x80 ? 0xff : 0; - s = ins & 0x40 ? &u->rst : &u->wst; - ptr = s->dat + s->ptr - 1; - switch(ins & 0x1f ? ins & 0x3f : (0 - (ins >> 5)) & 0xff) { + int ins = ram[pc++]; + int k = ins & 0x80 ? 0xff : 0; + Stack *s = ins & 0x40 ? &u->rst : &u->wst; + Uint8 *ptr = s->dat + s->ptr - 1; + switch(ins & 0x1f ? ins & 0x3f : (0 - (ins >> 5))) { /* IMM */ - case 0x00: /* BRK */ return 1; - case 0xff: /* JCI */ if(!s->dat[--s->ptr]) { pc += 2; break; } /* else fallthrough */ - case 0xfe: /* JMI */ pc += PEEK2(ram + pc) + 2; break; - case 0xfd: /* JSI */ SET(0, 2) PUT2(pc + 2) pc += PEEK2(ram + pc) + 2; break; - case 0xfc: /* LITr */ case 0xfa: SET(0, 1) PUT1(ram[pc++]) break; - case 0xfb: /* LIT2r*/ case 0xf9: SET(0, 2) PUT2(PEEK2(ram + pc)) pc += 2; break; + case -0: /* BRK */ return 1; + case -1: /* JCI */ if(!s->dat[--s->ptr]) { pc += 2; break; } /* else fallthrough */ + case -2: /* JMI */ pc += PEEK2(ram + pc) + 2; break; + case -3: /* JSI */ SET(0, 2) PUT2(pc + 2) pc += PEEK2(ram + pc) + 2; break; + case -4: /* LITr */ case -6: SET(0, 1) PUT1(ram[pc++]) break; + case -5: /* LIT2r*/ case -7: SET(0, 2) PUT2(PEEK2(ram + pc)) pc += 2; break; /* ALU */ case 0x01: /* INC */ t=T; SET(1, 0) PUT1(t + 1) break; case 0x21: /* INC2 */ t=T2; SET(2, 0) PUT2(t + 1) break; diff --git a/src/uxncli.c b/src/uxncli.c index 0bd4877..e74f6c1 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -72,7 +72,7 @@ main(int argc, char **argv) system_connect(0xc, DATETIME_VERSION, DATETIME_DEIMASK, DATETIME_DEOMASK); /* Read flags */ if(argv[i][0] == '-' && argv[i][1] == 'v') - return system_version("Uxncli - Console Varvara Emulator", "19 Aug 2023"); + return system_version("Uxncli - Console Varvara Emulator", "29 Aug 2023"); if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++])) return system_error("Init", "Failed to initialize uxn."); /* Game Loop */ diff --git a/src/uxnemu.c b/src/uxnemu.c index 9c6a461..9b24390 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -516,7 +516,7 @@ main(int argc, char **argv) system_connect(0xc, DATETIME_VERSION, DATETIME_DEIMASK, DATETIME_DEOMASK); /* Read flags */ if(argv[i][0] == '-' && argv[i][1] == 'v') - return system_version("Uxnemu - Graphical Varvara Emulator", "19 Aug 2023"); + return system_version("Uxnemu - Graphical Varvara Emulator", "29 Aug 2023"); if(strcmp(argv[i], "-2x") == 0 || strcmp(argv[i], "-3x") == 0) set_zoom(argv[i++][1] - '0', 0); if(!emu_init())