commit 66ece0d
Devine Lu Linvega
·
2025-05-13 18:01:45 +0000 UTC
parent 38bccf5
Fixed lil bug in core
2 files changed,
+8,
-18
+4,
-9
1@@ -37,9 +37,7 @@ static Window window;
2 @|Uxn --------------------------------------------------------------- */
3
4 typedef unsigned char Uint8;
5-typedef signed char Sint8;
6 typedef unsigned short Uint16;
7-typedef signed short Sint16;
8 typedef unsigned int Uint32;
9
10 typedef struct {
11@@ -76,21 +74,18 @@ static Uxn uxn;
12 /* Microcode */
13
14 #define REM if(_r) uxn.rst.ptr -= 1 + _2; else uxn.wst.ptr -= 1 + _2;
15-#define JMI c = uxn.ram[pc++] << 8 | uxn.ram[pc++];
16-#define JMP(x) { if(_2) pc = x; else pc += (Sint8)x; }
17-
18+#define JMI c = uxn.ram[pc] << 8 | uxn.ram[pc+1], pc += 2;
19+#define JMP(x) { if(_2) pc = x; else pc += (signed char)x; }
20 #define DEC(s) uxn.s.dat[--uxn.s.ptr]
21 #define PO1(o) { if(_r) o = DEC(rst); else o = DEC(wst); }
22 #define PO2(o) { PO1(o) if(_r) o |= DEC(rst) << 8; else o |= DEC(wst) << 8; }
23 #define POx(o) { if(_2) PO2(o) else PO1(o) }
24 #define GOT(o) { if(_2) PO1(o[1]) PO1(o[0]) }
25-
26 #define INC(s) uxn.s.dat[uxn.s.ptr++]
27 #define RP1(i) { if(_r) INC(wst) = i; else INC(rst) = i; }
28 #define PU1(i) { if(_r) INC(rst) = i; else INC(wst) = i; }
29 #define PUx(i) { if(_2) { c = (i); PU1(c >> 8) PU1(c) } else PU1(i) }
30 #define PUT(i) { PU1(i[0]) if(_2) PU1(i[1]) }
31-
32 #define DEI(i,o) o[0] = emu_dei(i); if(_2) o[1] = emu_dei(i + 1); PUT(o)
33 #define DEO(i,j) emu_deo(i, j[0]); if(_2) emu_deo(i + 1, j[1]);
34 #define PEK(i,o,m) o[0] = uxn.ram[i]; if(_2) o[1] = uxn.ram[(i + 1) & m]; PUT(o)
35@@ -128,8 +123,8 @@ uxn_eval(Uint16 pc)
36 /* STH */ OPC(0x0f,GOT(x),RP1(x[0]) if(_2) RP1(x[1]))
37 /* LDZ */ OPC(0x10,PO1(a),PEK(a, x, 0xff))
38 /* STZ */ OPC(0x11,PO1(a) GOT(y),POK(a, y, 0xff))
39- /* LDR */ OPC(0x12,PO1(a),PEK(pc + (Sint8)a, x, 0xffff))
40- /* STR */ OPC(0x13,PO1(a) GOT(y),POK(pc + (Sint8)a, y, 0xffff))
41+ /* LDR */ OPC(0x12,PO1(a),PEK(pc + (signed char)a, x, 0xffff))
42+ /* STR */ OPC(0x13,PO1(a) GOT(y),POK(pc + (signed char)a, y, 0xffff))
43 /* LDA */ OPC(0x14,PO2(a),PEK(a, x, 0xffff))
44 /* STA */ OPC(0x15,PO2(a) GOT(y),POK(a, y, 0xffff))
45 /* DEI */ OPC(0x16,PO1(a),DEI(a, x))
+4,
-9
1@@ -24,9 +24,7 @@ cc -DNDEBUG -O2 -g0 -s src/uxncli.c -lutil -o bin/uxncli
2 @|Uxn --------------------------------------------------------------- */
3
4 typedef unsigned char Uint8;
5-typedef signed char Sint8;
6 typedef unsigned short Uint16;
7-typedef signed short Sint16;
8 typedef unsigned int Uint32;
9
10 typedef struct {
11@@ -61,21 +59,18 @@ static Uxn uxn;
12 /* Microcode */
13
14 #define REM if(_r) uxn.rst.ptr -= 1 + _2; else uxn.wst.ptr -= 1 + _2;
15-#define JMI c = uxn.ram[pc++] << 8 | uxn.ram[pc++];
16-#define JMP(x) { if(_2) pc = x; else pc += (Sint8)x; }
17-
18+#define JMI c = uxn.ram[pc] << 8 | uxn.ram[pc+1], pc += 2;
19+#define JMP(x) { if(_2) pc = x; else pc += (signed char)x; }
20 #define DEC(s) uxn.s.dat[--uxn.s.ptr]
21 #define PO1(o) { if(_r) o = DEC(rst); else o = DEC(wst); }
22 #define PO2(o) { PO1(o) if(_r) o |= DEC(rst) << 8; else o |= DEC(wst) << 8; }
23 #define POx(o) { if(_2) PO2(o) else PO1(o) }
24 #define GOT(o) { if(_2) PO1(o[1]) PO1(o[0]) }
25-
26 #define INC(s) uxn.s.dat[uxn.s.ptr++]
27 #define RP1(i) { if(_r) INC(wst) = i; else INC(rst) = i; }
28 #define PU1(i) { if(_r) INC(rst) = i; else INC(wst) = i; }
29 #define PUx(i) { if(_2) { c = (i); PU1(c >> 8) PU1(c) } else PU1(i) }
30 #define PUT(i) { PU1(i[0]) if(_2) PU1(i[1]) }
31-
32 #define DEI(i,o) o[0] = emu_dei(i); if(_2) o[1] = emu_dei(i + 1); PUT(o)
33 #define DEO(i,j) emu_deo(i, j[0]); if(_2) emu_deo(i + 1, j[1]);
34 #define PEK(i,o,m) o[0] = uxn.ram[i]; if(_2) o[1] = uxn.ram[(i + 1) & m]; PUT(o)
35@@ -113,8 +108,8 @@ uxn_eval(Uint16 pc)
36 /* STH */ OPC(0x0f,GOT(x),RP1(x[0]) if(_2) RP1(x[1]))
37 /* LDZ */ OPC(0x10,PO1(a),PEK(a, x, 0xff))
38 /* STZ */ OPC(0x11,PO1(a) GOT(y),POK(a, y, 0xff))
39- /* LDR */ OPC(0x12,PO1(a),PEK(pc + (Sint8)a, x, 0xffff))
40- /* STR */ OPC(0x13,PO1(a) GOT(y),POK(pc + (Sint8)a, y, 0xffff))
41+ /* LDR */ OPC(0x12,PO1(a),PEK(pc + (signed char)a, x, 0xffff))
42+ /* STR */ OPC(0x13,PO1(a) GOT(y),POK(pc + (signed char)a, y, 0xffff))
43 /* LDA */ OPC(0x14,PO2(a),PEK(a, x, 0xffff))
44 /* STA */ OPC(0x15,PO2(a) GOT(y),POK(a, y, 0xffff))
45 /* DEI */ OPC(0x16,PO1(a),DEI(a, x))