Added soft reboot

This commit is contained in:
neauoire 2023-08-13 18:48:32 -07:00
parent a394dcb999
commit de7b24e820
4 changed files with 21 additions and 3 deletions

View File

@ -88,7 +88,6 @@ uxnemu orca.rom | shim
## GUI Emulator Options ## GUI Emulator Options
- `-1x` Force small scale
- `-2x` Force medium scale - `-2x` Force medium scale
- `-3x` Force large scale - `-3x` Force large scale
@ -97,7 +96,8 @@ uxnemu orca.rom | shim
- `F1` toggle zoom - `F1` toggle zoom
- `F2` toggle debug - `F2` toggle debug
- `F3` capture screen - `F3` capture screen
- `F4` load launcher.rom - `F4` reboot
- `F5` soft reboot
### GUI Buttons ### GUI Buttons

View File

@ -38,7 +38,7 @@ screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2)
if(y2 > uxn_screen.y2) uxn_screen.y2 = 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) 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; int x, y, width = uxn_screen.width, height = uxn_screen.height;

View File

@ -22,6 +22,7 @@ typedef struct UxnScreen {
extern UxnScreen uxn_screen; extern UxnScreen uxn_screen;
extern int emu_resize(int width, int height); 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_palette(Uint8 *addr);
void screen_resize(Uint16 width, Uint16 height); void screen_resize(Uint16 width, Uint16 height);
void screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2); void screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2);

View File

@ -279,6 +279,21 @@ emu_restart(Uxn *u)
emu_start(u, rom_path, 0); 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 static void
capture_screen(void) capture_screen(void)
{ {
@ -402,6 +417,8 @@ handle_events(Uxn *u)
capture_screen(); capture_screen();
else if(event.key.keysym.sym == SDLK_F4) else if(event.key.keysym.sym == SDLK_F4)
emu_restart(u); emu_restart(u);
else if(event.key.keysym.sym == SDLK_F5)
emu_restart_soft(u);
ksym = event.key.keysym.sym; ksym = event.key.keysym.sym;
if(SDL_PeepEvents(&event, 1, SDL_PEEKEVENT, SDL_KEYUP, SDL_KEYUP) == 1 && ksym == event.key.keysym.sym) if(SDL_PeepEvents(&event, 1, SDL_PEEKEVENT, SDL_KEYUP, SDL_KEYUP) == 1 && ksym == event.key.keysym.sym)
return 1; return 1;