~rabbits/uxn-playdate

b56db4a8e5c84c87dc6228a76cb73d5e43bc162d — Devine Lu Linvega 12 days ago 7c7b57f
Use global macros in uxn core
1 files changed, 3 insertions(+), 7 deletions(-)

M src/uxn.c
M src/uxn.c => src/uxn.c +3 -7
@@ 17,18 17,14 @@ WITH REGARD TO THIS SOFTWARE.

#define HALT(c) { return uxn_halt(u, instr, (c), pc - 1); }
#define JUMP(x) { if(m2) pc = (x); else pc += (Sint8)(x); }

#define PUSH8(x) { if(s->ptr == 0xff) HALT(2) s->dat[s->ptr++] = (x); }
#define PUSH16(x) { if((tsp = s->ptr) >= 0xfe) HALT(2) t = (x); s->dat[tsp] = t >> 8; s->dat[tsp + 1] = t; s->ptr = tsp + 2; }
#define PUSH16(x) { if((tsp = s->ptr) >= 0xfe) HALT(2) t = (x); POKE16(&s->dat[tsp], t); s->ptr = tsp + 2; }
#define PUSH(x) { if(m2) { PUSH16(x) } else { PUSH8(x) } }

#define POP8(o) { if(*sp == 0x00) HALT(1) o = s->dat[--*sp]; }
#define POP16(o) { if((tsp = *sp) <= 0x01) HALT(1) o = s->dat[tsp - 1] | (s->dat[tsp - 2] << 8); *sp = tsp - 2; }
#define POP16(o) { if((tsp = *sp) <= 0x01) HALT(1) o = PEEK16(&s->dat[tsp - 2]); *sp = tsp - 2; }
#define POP(o) { if(m2) { POP16(o) } else { POP8(o) } }

#define POKE(x, y) { if(m2) { t = (y); u->ram[(x)] = t >> 8; u->ram[(x) + 1] = t; } else { u->ram[(x)] = (y); } }
#define POKE(x, y) { if(m2) { t = (y); POKE16(u->ram + x, t) } else { u->ram[(x)] = (y); } }
#define PEEK(o, x) { if(m2) { o = PEEK16(u->ram + x); } else o = u->ram[(x)]; }

#define DEVR(o, x) { o = u->dei(u, x); if(m2) o = (o << 8) | u->dei(u, (x) + 1); }
#define DEVW(x, y) { if(m2) { u->deo(u, (x), (y) >> 8); u->deo(u, (x) + 1, (y)); } else { u->deo(u, x, (y)); } }