uxn

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

commit 15d09cf15b4d6f7bb811227fb45bd6825d3de244
parent c6a628e6ae1045d386294d569489da371a154c85
Author: neauoire <aliceffekt@gmail.com>
Date:   Sat, 19 Aug 2023 07:34:14 -0700

Added stack pointer accessors to system device

Diffstat:
Msrc/devices/screen.c | 2+-
Msrc/devices/system.c | 16++++++++++++++++
Msrc/devices/system.h | 7++++---
Msrc/uxncli.c | 3++-
Msrc/uxnemu.c | 3++-
5 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/src/devices/screen.c b/src/devices/screen.c @@ -120,7 +120,7 @@ screen_resize(Uint16 width, Uint16 height) { Uint8 *bg, *fg; Uint32 *pixels = NULL; - if(width < 0x8 || height < 0x8 || width >= 0x400 || height >= 0x400) + if(width < 0x8 || height < 0x8 || width >= 0x800 || height >= 0x800) return; if(uxn_screen.width == width && uxn_screen.height == height) return; diff --git a/src/devices/system.c b/src/devices/system.c @@ -116,6 +116,16 @@ system_init(Uxn *u, Uint8 *ram, char *rom) /* IO */ +Uint8 +system_dei(Uxn *u, Uint8 addr) +{ + switch(addr) { + case 0x4: return u->wst.ptr; + case 0x5: return u->rst.ptr; + default: return u->dev[addr]; + } +} + void system_deo(Uxn *u, Uint8 *d, Uint8 port) { @@ -134,6 +144,12 @@ system_deo(Uxn *u, Uint8 *d, Uint8 port) ram[dst + (Uint16)(b_addr + i)] = ram[src + (Uint16)(a_addr + i)]; } break; + case 0x4: + u->wst.ptr = d[4]; + break; + case 0x5: + u->rst.ptr = d[5]; + break; case 0xe: system_inspect(u); break; diff --git a/src/devices/system.h b/src/devices/system.h @@ -9,9 +9,9 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ -#define SYSTEM_VERSION 1 -#define SYSTEM_DEIMASK 0x0000 -#define SYSTEM_DEOMASK 0xff08 +#define SYSTEM_VERSION 2 +#define SYSTEM_DEIMASK 0x0030 +#define SYSTEM_DEOMASK 0xff38 #define RAM_PAGES 0x10 @@ -24,4 +24,5 @@ int system_version(Uxn *u, char *emulator, char *date); int system_error(char *msg, const char *err); int system_init(Uxn *u, Uint8 *ram, char *rom); +Uint8 system_dei(Uxn *u, Uint8 addr); void system_deo(Uxn *u, Uint8 *d, Uint8 port); diff --git a/src/uxncli.c b/src/uxncli.c @@ -24,6 +24,7 @@ Uint8 emu_dei(Uxn *u, Uint8 addr) { switch(addr & 0xf0) { + case 0x00: return system_dei(u, addr); case 0xc0: return datetime_dei(u, addr); } return u->dev[addr]; @@ -73,7 +74,7 @@ main(int argc, char **argv) system_connect(&u, 0xc, DATETIME_VERSION, DATETIME_DEIMASK, DATETIME_DEOMASK); /* Read flags */ if(argv[i][0] == '-' && argv[i][1] == 'v') - return system_version(&u, "Uxncli - Console Varvara Emulator", "17 Aug 2023"); + return system_version(&u, "Uxncli - Console Varvara Emulator", "19 Aug 2023"); if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++])) return system_error("Init", "Failed to initialize uxn."); /* Game Loop */ diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -96,6 +96,7 @@ emu_dei(Uxn *u, Uint8 addr) { Uint8 p = addr & 0x0f, d = addr & 0xf0; switch(d) { + case 0x00: return system_dei(u, addr); case 0x20: return screen_dei(u, addr); case 0x30: return audio_dei(0, &u->dev[d], p); case 0x40: return audio_dei(1, &u->dev[d], p); @@ -516,7 +517,7 @@ main(int argc, char **argv) system_connect(&u, 0xc, DATETIME_VERSION, DATETIME_DEIMASK, DATETIME_DEOMASK); /* Read flags */ if(argv[i][0] == '-' && argv[i][1] == 'v') - return system_version(&u, "Uxnemu - Graphical Varvara Emulator", "17 Aug 2023"); + return system_version(&u, "Uxnemu - Graphical Varvara Emulator", "19 Aug 2023"); if(strcmp(argv[i], "-2x") == 0 || strcmp(argv[i], "-3x") == 0) set_zoom(argv[i++][1] - '0', 0); if(!emu_init())