0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-22 22:05:11 +00:00

(uxn.c) Removed needless masking of opcode lookup

This commit is contained in:
neauoire 2023-08-29 09:41:00 -07:00
parent a18f8697f0
commit 7992d54115
3 changed files with 15 additions and 16 deletions

View file

@ -34,23 +34,22 @@ WITH REGARD TO THIS SOFTWARE.
int int
uxn_eval(Uxn *u, Uint16 pc) uxn_eval(Uxn *u, Uint16 pc)
{ {
int t, n, l, k, r; int t, n, l, r;
Uint8 *ram = u->ram, *ptr, ins; Uint8 *ram = u->ram;
Stack *s;
if(!pc || u->dev[0x0f]) return 0; if(!pc || u->dev[0x0f]) return 0;
for(;;) { for(;;) {
ins = ram[pc++]; int ins = ram[pc++];
k = ins & 0x80 ? 0xff : 0; int k = ins & 0x80 ? 0xff : 0;
s = ins & 0x40 ? &u->rst : &u->wst; Stack *s = ins & 0x40 ? &u->rst : &u->wst;
ptr = s->dat + s->ptr - 1; Uint8 *ptr = s->dat + s->ptr - 1;
switch(ins & 0x1f ? ins & 0x3f : (0 - (ins >> 5)) & 0xff) { switch(ins & 0x1f ? ins & 0x3f : (0 - (ins >> 5))) {
/* IMM */ /* IMM */
case 0x00: /* BRK */ return 1; case -0: /* BRK */ return 1;
case 0xff: /* JCI */ if(!s->dat[--s->ptr]) { pc += 2; break; } /* else fallthrough */ case -1: /* JCI */ if(!s->dat[--s->ptr]) { pc += 2; break; } /* else fallthrough */
case 0xfe: /* JMI */ pc += PEEK2(ram + pc) + 2; break; case -2: /* JMI */ pc += PEEK2(ram + pc) + 2; break;
case 0xfd: /* JSI */ SET(0, 2) PUT2(pc + 2) pc += PEEK2(ram + pc) + 2; break; case -3: /* 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 -4: /* LITr */ case -6: SET(0, 1) PUT1(ram[pc++]) break;
case 0xfb: /* LIT2r*/ case 0xf9: SET(0, 2) PUT2(PEEK2(ram + pc)) pc += 2; break; case -5: /* LIT2r*/ case -7: SET(0, 2) PUT2(PEEK2(ram + pc)) pc += 2; break;
/* ALU */ /* ALU */
case 0x01: /* INC */ t=T; SET(1, 0) PUT1(t + 1) break; case 0x01: /* INC */ t=T; SET(1, 0) PUT1(t + 1) break;
case 0x21: /* INC2 */ t=T2; SET(2, 0) PUT2(t + 1) break; case 0x21: /* INC2 */ t=T2; SET(2, 0) PUT2(t + 1) break;

View file

@ -72,7 +72,7 @@ main(int argc, char **argv)
system_connect(0xc, DATETIME_VERSION, DATETIME_DEIMASK, DATETIME_DEOMASK); system_connect(0xc, DATETIME_VERSION, DATETIME_DEIMASK, DATETIME_DEOMASK);
/* Read flags */ /* Read flags */
if(argv[i][0] == '-' && argv[i][1] == 'v') 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++])) if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
return system_error("Init", "Failed to initialize uxn."); return system_error("Init", "Failed to initialize uxn.");
/* Game Loop */ /* Game Loop */

View file

@ -516,7 +516,7 @@ main(int argc, char **argv)
system_connect(0xc, DATETIME_VERSION, DATETIME_DEIMASK, DATETIME_DEOMASK); system_connect(0xc, DATETIME_VERSION, DATETIME_DEIMASK, DATETIME_DEOMASK);
/* Read flags */ /* Read flags */
if(argv[i][0] == '-' && argv[i][1] == 'v') 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) if(strcmp(argv[i], "-2x") == 0 || strcmp(argv[i], "-3x") == 0)
set_zoom(argv[i++][1] - '0', 0); set_zoom(argv[i++][1] - '0', 0);
if(!emu_init()) if(!emu_init())