uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 3dafa868cb307b45b3785ebb0e4dafc933b9b110
parent 7529e119cdd4a5aab4309d16f117f62400d855bc
Author: neauoire <aliceffekt@gmail.com>
Date:   Sun,  4 Apr 2021 20:35:52 -0700

Minor cleanup

Diffstat:
Mbuild.sh | 2+-
Msrc/emulator.c | 6++++++
Msrc/uxn.c | 7++-----
Msrc/uxn.h | 3---
4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/build.sh b/build.sh @@ -28,7 +28,7 @@ else fi echo "Assembling.." -./bin/assembler projects/examples/dev.audio.usm bin/boot.rom +./bin/assembler projects/examples/dev.controller.usm bin/boot.rom echo "Running.." if [ "${2}" = '--cli' ]; diff --git a/src/emulator.c b/src/emulator.c @@ -99,6 +99,12 @@ setflag(Uint8 *a, char flag, int b) *a &= (~flag); } +int +getflag(Uint8 *a, char flag) +{ + return *a & flag; +} + #pragma mark - Paint void diff --git a/src/uxn.c b/src/uxn.c @@ -16,15 +16,12 @@ WITH REGARD TO THIS SOFTWARE. #pragma mark - Operations /* clang-format off */ -int getflag(Uint8 *a, char flag) { return *a & flag; } Uint8 devpoke8(Uxn *u, Uint8 id, Uint8 b0, Uint8 b1){ return id < 0x10 ? u->dev[id].poke(u, PAGE_DEVICE + id * 0x10, b0, b1) : b1; } - void push8(Stack *s, Uint8 a) { if (s->ptr == 0xff) { s->error = 2; return; } s->dat[s->ptr++] = a; } Uint8 pop8(Stack *s) { if (s->ptr == 0) { s->error = 1; return 0; } return s->dat[--s->ptr]; } Uint8 peek8(Stack *s, Uint8 a) { if (s->ptr < a + 1) s->error = 1; return s->dat[s->ptr - a - 1]; } void mempoke8(Uxn *u, Uint16 a, Uint8 b) { u->ram.dat[a] = (a & 0xff00) == PAGE_DEVICE ? devpoke8(u, (a & 0xff) >> 4, a & 0xf, b) : b; } Uint8 mempeek8(Uxn *u, Uint16 a) { return u->ram.dat[a]; } - void push16(Stack *s, Uint16 a) { push8(s, a >> 8); push8(s, a); } Uint16 pop16(Stack *s) { return pop8(s) + (pop8(s) << 8); } Uint16 peek16(Stack *s, Uint8 a) { return peek8(s, a * 2) + (peek8(s, a * 2 + 1) << 8); } @@ -118,6 +115,7 @@ int haltuxn(Uxn *u, char *name, int id) { printf("Halted: %s#%04x, at 0x%04x\n", name, id, u->ram.ptr); + u->ram.ptr = 0; return 0; } @@ -148,8 +146,7 @@ evaluxn(Uxn *u, Uint16 vec) u->wst.error = 0; u->rst.error = 0; while(u->ram.ptr) { - Uint8 instr = u->ram.dat[u->ram.ptr++]; - if(!stepuxn(u, instr)) + if(!stepuxn(u, u->ram.dat[u->ram.ptr++])) return 0; } return 1; diff --git a/src/uxn.h b/src/uxn.h @@ -16,8 +16,6 @@ typedef signed char Sint8; typedef unsigned short Uint16; typedef signed short Sint16; -#define FLAG_LIT1 0x04 -#define FLAG_LIT2 0x08 #define PAGE_DEVICE 0x0100 #define PAGE_VECTORS 0x0200 @@ -44,7 +42,6 @@ typedef struct Uxn { Device dev[16]; } Uxn; -int getflag(Uint8 *status, char flag); int loaduxn(Uxn *c, char *filepath); int bootuxn(Uxn *c); int evaluxn(Uxn *u, Uint16 vec);