uxn

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

commit de7b24e820cba42eb6a2448d0ec26f921a31aa98
parent a394dcb999525ac56ea37d0563d35849964b6d6a
Author: neauoire <aliceffekt@gmail.com>
Date:   Sun, 13 Aug 2023 18:48:32 -0700

Added soft reboot

Diffstat:
MREADME.md | 4++--
Msrc/devices/screen.c | 2+-
Msrc/devices/screen.h | 1+
Msrc/uxnemu.c | 17+++++++++++++++++
4 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md @@ -88,7 +88,6 @@ uxnemu orca.rom | shim ## GUI Emulator Options -- `-1x` Force small scale - `-2x` Force medium scale - `-3x` Force large scale @@ -97,7 +96,8 @@ uxnemu orca.rom | shim - `F1` toggle zoom - `F2` toggle debug - `F3` capture screen -- `F4` load launcher.rom +- `F4` reboot +- `F5` soft reboot ### GUI Buttons diff --git a/src/devices/screen.c b/src/devices/screen.c @@ -38,7 +38,7 @@ screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2) if(y2 > uxn_screen.y2) uxn_screen.y2 = y2; } -static void +void screen_fill(Uint8 *layer, int x1, int y1, int x2, int y2, int color) { int x, y, width = uxn_screen.width, height = uxn_screen.height; diff --git a/src/devices/screen.h b/src/devices/screen.h @@ -22,6 +22,7 @@ typedef struct UxnScreen { extern UxnScreen uxn_screen; extern int emu_resize(int width, int height); +void screen_fill(Uint8 *layer, int x1, int y1, int x2, int y2, int color); void screen_palette(Uint8 *addr); void screen_resize(Uint16 width, Uint16 height); void screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2); diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -279,6 +279,21 @@ emu_restart(Uxn *u) emu_start(u, rom_path, 0); } +static int +emu_restart_soft(Uxn *u) +{ + int i; + for(i = 0x100; i < 0x10000; i++) + u->ram[i] = 0; + screen_fill(uxn_screen.bg, 0, 0, uxn_screen.width, uxn_screen.height, 0); + screen_fill(uxn_screen.fg, 0, 0, uxn_screen.width, uxn_screen.height, 0); + if(!system_load(u, rom_path)) + return system_error("Boot", "Failed to load rom."); + if(!uxn_eval(u, PAGE_PROGRAM)) + return system_error("Boot", "Failed to eval rom."); + return 1; +} + static void capture_screen(void) { @@ -402,6 +417,8 @@ handle_events(Uxn *u) capture_screen(); else if(event.key.keysym.sym == SDLK_F4) emu_restart(u); + else if(event.key.keysym.sym == SDLK_F5) + emu_restart_soft(u); ksym = event.key.keysym.sym; if(SDL_PeepEvents(&event, 1, SDL_PEEKEVENT, SDL_KEYUP, SDL_KEYUP) == 1 && ksym == event.key.keysym.sym) return 1;