uxn

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

commit 465b85d579f93af9ad41742beda733acf10a594b
parent c60dbfe872a8026a24395823c12fd73cd36cc7a8
Author: neauoire <aliceffekt@gmail.com>
Date:   Sun, 21 Mar 2021 13:52:38 -0700

About to move the device page

Diffstat:
Mbuild.sh | 2+-
Memulator.c | 4++--
Muxn.c | 12++++++------
Muxn.h | 1+
4 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/build.sh b/build.sh @@ -20,5 +20,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr # cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator # run -./bin/assembler projects/software/left.usm bin/boot.rom +./bin/assembler projects/software/noodle.usm bin/boot.rom ./bin/emulator bin/boot.rom diff --git a/emulator.c b/emulator.c @@ -409,7 +409,7 @@ file_poke(Uint8 *m, Uint16 ptr, Uint8 b0, Uint8 b1) Uint8 system_poke(Uint8 *m, Uint16 ptr, Uint8 b0, Uint8 b1) { - loadtheme(&m[0xfff8]); + loadtheme(&m[PAGE_DEVICE + 0x00f8]); (void)ptr; (void)b0; return b1; @@ -431,7 +431,7 @@ start(Uxn *u) { int ticknext = 0; evaluxn(u, u->vreset); - loadtheme(u->ram.dat + 0xfff8); + loadtheme(u->ram.dat + PAGE_DEVICE + 0x00f8); if(screen.reqdraw) redraw(pixels, u); while(1) { diff --git a/uxn.c b/uxn.c @@ -18,8 +18,8 @@ WITH REGARD TO THIS SOFTWARE. /* clang-format off */ void setflag(Uint8 *a, char flag, int b) { if(b) *a |= flag; else *a &= (~flag); } int getflag(Uint8 *a, char flag) { return *a & flag; } -Uint8 devpoke8(Uxn *u, Uint8 id, Uint8 b0, Uint8 b1){ return id < u->devices ? u->dev[id].poke(u->ram.dat, 0xff00 + id * 0x10, b0, b1) : b1; } -void mempoke8(Uxn *u, Uint16 a, Uint8 b) { u->ram.dat[a] = a >= 0xff00 ? devpoke8(u, (a & 0xff) >> 4, a & 0xf, b) : b; } +Uint8 devpoke8(Uxn *u, Uint8 id, Uint8 b0, Uint8 b1){ return id < u->devices ? u->dev[id].poke(u->ram.dat, PAGE_DEVICE + id * 0x10, b0, b1) : b1; } +void mempoke8(Uxn *u, Uint16 a, Uint8 b) { u->ram.dat[a] = a >= PAGE_DEVICE ? devpoke8(u, (a & 0xff) >> 4, a & 0xf, b) : b; } Uint8 mempeek8(Uxn *u, Uint16 a) { return u->ram.dat[a]; } void mempoke16(Uxn *u, Uint16 a, Uint16 b) { mempoke8(u, a, b >> 8); mempoke8(u, a + 1, b); } Uint16 mempeek16(Uxn *u, Uint16 a) { return (mempeek8(u, a) << 8) + mempeek8(u, a + 1); } @@ -212,9 +212,9 @@ loaduxn(Uxn *u, char *filepath) if(!(f = fopen(filepath, "rb"))) return haltuxn(u, "Missing input rom.", 0); fread(u->ram.dat, sizeof(u->ram.dat), 1, f); - u->vreset = mempeek16(u, 0xfff0); - u->vframe = mempeek16(u, 0xfff2); - u->verror = mempeek16(u, 0xfff4); + u->vreset = mempeek16(u, PAGE_DEVICE + 0x00f0); + u->vframe = mempeek16(u, PAGE_DEVICE + 0x00f2); + u->verror = mempeek16(u, PAGE_DEVICE + 0x00f4); printf("Uxn loaded[%s] vrst:%04x vfrm:%04x verr:%04x.\n", filepath, u->vreset, @@ -227,7 +227,7 @@ Device * portuxn(Uxn *u, char *name, Uint8 (*pofn)(Uint8 *m, Uint16 ptr, Uint8 b0, Uint8 b1)) { Device *d = &u->dev[u->devices++]; - d->addr = 0xff00 + (u->devices - 1) * 0x10; + d->addr = PAGE_DEVICE + (u->devices - 1) * 0x10; d->poke = pofn; printf("Device #%d: %s, at 0x%04x \n", u->devices - 1, name, d->addr); return d; diff --git a/uxn.h b/uxn.h @@ -20,6 +20,7 @@ typedef signed short Sint16; #define FLAG_SHORT 0x02 #define FLAG_RETURN 0x04 #define FLAG_COND 0x08 +#define PAGE_DEVICE 0xff00 typedef struct { Uint8 ptr;