From 4df6dd82cd9e82c7c2bb28bf3d5f80b264e01baa Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sat, 17 Aug 2024 10:04:48 -0700 Subject: [PATCH] (uxn.c) Separate macros for separate actions --- src/uxn.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/uxn.c b/src/uxn.c index 86a7cc1..fa39927 100644 --- a/src/uxn.c +++ b/src/uxn.c @@ -34,14 +34,19 @@ WITH REGARD TO THIS SOFTWARE. #define PUx(y) if(_2) { PU2(y) } else PU1(y) #define PU2(y) tt = (y); PU1(tt >> 8) PU1(tt) #define PU1(y) if(_r) INC(rst) = y; else INC(wst) = y; -#define PUR(y) if(_r) INC(wst) = y; else INC(rst) = y; + #define GET(o,p) if(_2) PO1(p) PO1(o) #define PUT(y,z) PU1(y) if(_2) PU1(z) -#define DEI(i,o,p) o =emu_dei(i); if(_2) p =emu_dei(i + 1); +#define DEI(i,o,p) o = emu_dei(i); if(_2) p = emu_dei(i + 1); #define DEO(i,y,z) emu_deo(i, y); if(_2) emu_deo(i + 1, z); #define PEK(i,o,p,r) o = uxn.ram[i]; if(_2) r = i + 1, p = uxn.ram[r]; #define POK(i,y,z,r) uxn.ram[i] = y; if(_2) r = i + 1, uxn.ram[r] = z; +#define PUTr(y,z) PF1(y) if(_2) PF1(z) +#define PFx(y) if(_2) { PF2(y) } else PF1(y) +#define PF2(y) tt = (y); PF1(tt >> 8) PF1(tt) +#define PF1(y) if(_r) INC(wst) = y; else INC(rst) = y; + int uxn_eval(Uint16 pc) { @@ -73,7 +78,7 @@ uxn_eval(Uint16 pc) /* JMP */ OPC(0x0c, POx(a),JMP(a)) /* JCN */ OPC(0x0d, POx(a) PO1(b), if(b) JMP(a)) /* JSR */ OPC(0x0e, POx(a),PF2(pc) JMP(a)) - /* STH */ OPC(0x0f, GET(a,b),PUR(a) if(_2) PUR(b)) + /* STH */ OPC(0x0f, GET(a,b), PUTr(a,b)) /* LDZ */ OPC(0x10, PO1(a),PEK(a,b,c,t) PUT(b,c)) /* STZ */ OPC(0x11, PO1(a) GET(b,c),POK(a,b,c,t)) /* LDR */ OPC(0x12, PO1(a),PEK(pc+(Sint8)a,b,c,tt) PUT(b,c))