commit 71490d7

neauoire  ·  2023-08-29 16:42:06 +0000 UTC
parent cdb0f0e
(uxn.c) Removed needed masking for opcode lookup
3 files changed,  +15, -16
+13, -14
 1@@ -34,23 +34,22 @@ WITH REGARD TO THIS SOFTWARE.
 2 int
 3 uxn_eval(Uxn *u, Uint16 pc)
 4 {
 5-	int t, n, l, k, r;
 6-	Uint8 *ram = u->ram, *ptr, ins;
 7-	Stack *s;
 8+	int t, n, l, r;
 9+	Uint8 *ram = u->ram;
10 	if(!pc || u->dev[0x0f]) return 0;
11 	for(;;) {
12-		ins = ram[pc++];
13-		k = ins & 0x80 ? 0xff : 0;
14-		s = ins & 0x40 ? &u->rst : &u->wst;
15-		ptr = s->dat + s->ptr - 1;
16-		switch(ins & 0x1f ? ins & 0x3f : (0 - (ins >> 5)) & 0xff) {
17+		int ins = ram[pc++];
18+		int k = ins & 0x80 ? 0xff : 0;
19+		Stack *s = ins & 0x40 ? &u->rst : &u->wst;
20+		Uint8 *ptr = s->dat + s->ptr - 1;
21+		switch(ins & 0x1f ? ins & 0x3f : (0 - (ins >> 5))) {
22 			/* IMM */
23-			case 0x00: /* BRK   */                          return 1;
24-			case 0xff: /* JCI   */                          if(!s->dat[--s->ptr]) { pc += 2; break; } /* else fallthrough */
25-			case 0xfe: /* JMI   */                          pc += PEEK2(ram + pc) + 2; break;
26-			case 0xfd: /* JSI   */                SET(0, 2) PUT2(pc + 2) pc += PEEK2(ram + pc) + 2; break;
27-			case 0xfc: /* LITr */ case 0xfa:      SET(0, 1) PUT1(ram[pc++]) break;
28-			case 0xfb: /* LIT2r*/ case 0xf9:      SET(0, 2) PUT2(PEEK2(ram + pc)) pc += 2; break;
29+			case -0:   /* BRK  */                           return 1;
30+			case -1:   /* JCI  */                           if(!s->dat[--s->ptr]) { pc += 2; break; } /* else fallthrough */
31+			case -2:   /* JMI  */                           pc += PEEK2(ram + pc) + 2; break;
32+			case -3:   /* JSI  */                 SET(0, 2) PUT2(pc + 2) pc += PEEK2(ram + pc) + 2; break;
33+			case -4:   /* LITr */ case -6:        SET(0, 1) PUT1(ram[pc++]) break;
34+			case -5:   /* LIT2r*/ case -7:        SET(0, 2) PUT2(PEEK2(ram + pc)) pc += 2; break;
35 			/* ALU */
36 			case 0x01: /* INC  */ t=T;            SET(1, 0) PUT1(t + 1) break;
37 			case 0x21: /* INC2 */ t=T2;           SET(2, 0) PUT2(t + 1) break;
+1, -1
1@@ -270,7 +270,7 @@ main(int argc, char **argv)
2 	system_connect(0xf, LINK_VERSION, LINK_DEIMASK, LINK_DEOMASK);
3 	/* Read flags */
4 	if(argv[i][0] == '-' && argv[i][1] == 'v')
5-		return system_version("Uxn11 - Graphical Varvara Emulator", "25 Aug 2023");
6+		return system_version("Uxn11 - Graphical Varvara Emulator", "29 Aug 2023");
7 	if(!emu_init())
8 		return system_error("Init", "Failed to initialize varvara.");
9 	if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
+1, -1
1@@ -76,7 +76,7 @@ main(int argc, char **argv)
2 	system_connect(0xf, LINK_VERSION, LINK_DEIMASK, LINK_DEOMASK);
3 	/* Read flags */
4 	if(argv[i][0] == '-' && argv[i][1] == 'v')
5-		return system_version("Uxncli - Console Varvara Emulator", "25 Aug 2023");
6+		return system_version("Uxncli - Console Varvara Emulator", "29 Aug 2023");
7 	if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
8 		return system_error("Init", "Failed to initialize uxn.");
9 	/* Game Loop */