(uxn.c) tighter switch
This commit is contained in:
parent
91257363c2
commit
d53473175c
29
src/uxn.c
29
src/uxn.c
|
@ -31,21 +31,22 @@ uxn_eval(Uxn *u, Uint16 pc)
|
||||||
Uint16 tt, a, b, c;
|
Uint16 tt, a, b, c;
|
||||||
if(!pc || u->dev[0x0f]) return 0;
|
if(!pc || u->dev[0x0f]) return 0;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
Uint8 ins = ram[pc++], opc = ins & 0x1f, m2 = ins & 0x20;
|
Uint8 ins = ram[pc++], m2 = ins & 0x20;
|
||||||
Stack *s = ins & 0x40 ? &u->rst : &u->wst;
|
Stack *s = ins & 0x40 ? &u->rst : &u->wst;
|
||||||
if(ins & 0x80)
|
if(ins & 0x80) kp = s->ptr, sp = &kp;
|
||||||
kp = s->ptr, sp = &kp;
|
else sp = &s->ptr;
|
||||||
else
|
/* OPC */
|
||||||
sp = &s->ptr;
|
switch(ins & 0x1f) {
|
||||||
/* Opcodes */
|
/* IMM */
|
||||||
switch(opc ? opc : ins) {
|
case 0x00: case 0x20:
|
||||||
/* Immediate */
|
switch(ins) {
|
||||||
case 0x00: /* BRK */ return 1;
|
case 0x00: /* BRK */ return 1;
|
||||||
case 0x20: /* JCI */ POP1(b) if(!b) { pc += 2; break; } /* else fallthrough */
|
case 0x20: /* JCI */ POP1(b) if(!b) { pc += 2; break; } /* fall-through */
|
||||||
case 0x40: /* JMI */ pc += PEEK2(ram + pc) + 2; break;
|
case 0x40: /* JMI */ pc += PEEK2(ram + pc) + 2; break;
|
||||||
case 0x60: /* JSI */ PUSH2(pc + 2) pc += PEEK2(ram + pc) + 2; break;
|
case 0x60: /* JSI */ PUSH2(pc + 2) pc += PEEK2(ram + pc) + 2; break;
|
||||||
case 0x80: case 0xc0: /* LIT */ PUSH1(ram[pc++]) break;
|
case 0x80: case 0xc0: /* LIT */ PUSH1(ram[pc++]) break;
|
||||||
case 0xa0: case 0xe0: /* LIT2 */ PUSH1(ram[pc++]) PUSH1(ram[pc++]) break;
|
case 0xa0: case 0xe0: /* LIT2 */ PUSH1(ram[pc++]) PUSH1(ram[pc++]) break;
|
||||||
|
} break;
|
||||||
/* ALU */
|
/* ALU */
|
||||||
case 0x01: /* INC */ POPx(a) PUSHx(a + 1) break;
|
case 0x01: /* INC */ POPx(a) PUSHx(a + 1) break;
|
||||||
case 0x02: /* POP */ POPx(a) break;
|
case 0x02: /* POP */ POPx(a) break;
|
||||||
|
|
|
@ -261,7 +261,7 @@ main(int argc, char **argv)
|
||||||
return system_error("usage", "uxn11 [-v] file.rom [args...]");
|
return system_error("usage", "uxn11 [-v] file.rom [args...]");
|
||||||
/* Read flags */
|
/* Read flags */
|
||||||
if(argv[i][0] == '-' && argv[i][1] == 'v')
|
if(argv[i][0] == '-' && argv[i][1] == 'v')
|
||||||
return system_version("Uxn11 - Graphical Varvara Emulator", "31 Oct 2023");
|
return system_version("Uxn11 - Graphical Varvara Emulator", "9 Nov 2023");
|
||||||
if(!emu_init())
|
if(!emu_init())
|
||||||
return system_error("Init", "Failed to initialize varvara.");
|
return system_error("Init", "Failed to initialize varvara.");
|
||||||
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++]))
|
||||||
|
|
|
@ -70,7 +70,7 @@ main(int argc, char **argv)
|
||||||
return system_error("usage", "uxncli [-v] file.rom [args..]");
|
return system_error("usage", "uxncli [-v] file.rom [args..]");
|
||||||
/* 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", "31 Oct 2023");
|
return system_version("Uxncli - Console Varvara Emulator", "9 Nov 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 */
|
||||||
|
|
Loading…
Reference in New Issue