Browse code

Added soft reboot

neauoire authored on 14/08/2023 01:48:32
Showing 4 changed files
... ...
@@ -88,7 +88,6 @@ uxnemu orca.rom | shim
88 88
 
89 89
 ## GUI Emulator Options
90 90
 
91
-- `-1x` Force small scale
92 91
 - `-2x` Force medium scale
93 92
 - `-3x` Force large scale
94 93
 
... ...
@@ -97,7 +96,8 @@ uxnemu orca.rom | shim
97 96
 - `F1` toggle zoom
98 97
 - `F2` toggle debug
99 98
 - `F3` capture screen
100
-- `F4` load launcher.rom
99
+- `F4` reboot
100
+- `F5` soft reboot
101 101
 
102 102
 ### GUI Buttons
103 103
 
... ...
@@ -38,7 +38,7 @@ screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2)
38 38
 	if(y2 > uxn_screen.y2) uxn_screen.y2 = y2;
39 39
 }
40 40
 
41
-static void
41
+void
42 42
 screen_fill(Uint8 *layer, int x1, int y1, int x2, int y2, int color)
43 43
 {
44 44
 	int x, y, width = uxn_screen.width, height = uxn_screen.height;
... ...
@@ -22,6 +22,7 @@ typedef struct UxnScreen {
22 22
 extern UxnScreen uxn_screen;
23 23
 extern int emu_resize(int width, int height);
24 24
 
25
+void screen_fill(Uint8 *layer, int x1, int y1, int x2, int y2, int color);
25 26
 void screen_palette(Uint8 *addr);
26 27
 void screen_resize(Uint16 width, Uint16 height);
27 28
 void screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2);
... ...
@@ -279,6 +279,21 @@ emu_restart(Uxn *u)
279 279
 		emu_start(u, rom_path, 0);
280 280
 }
281 281
 
282
+static int
283
+emu_restart_soft(Uxn *u)
284
+{
285
+	int i;
286
+	for(i = 0x100; i < 0x10000; i++)
287
+		u->ram[i] = 0;
288
+	screen_fill(uxn_screen.bg, 0, 0, uxn_screen.width, uxn_screen.height, 0);
289
+	screen_fill(uxn_screen.fg, 0, 0, uxn_screen.width, uxn_screen.height, 0);
290
+	if(!system_load(u, rom_path))
291
+		return system_error("Boot", "Failed to load rom.");
292
+	if(!uxn_eval(u, PAGE_PROGRAM))
293
+		return system_error("Boot", "Failed to eval rom.");
294
+	return 1;
295
+}
296
+
282 297
 static void
283 298
 capture_screen(void)
284 299
 {
... ...
@@ -402,6 +417,8 @@ handle_events(Uxn *u)
402 417
 				capture_screen();
403 418
 			else if(event.key.keysym.sym == SDLK_F4)
404 419
 				emu_restart(u);
420
+			else if(event.key.keysym.sym == SDLK_F5)
421
+				emu_restart_soft(u);
405 422
 			ksym = event.key.keysym.sym;
406 423
 			if(SDL_PeepEvents(&event, 1, SDL_PEEKEVENT, SDL_KEYUP, SDL_KEYUP) == 1 && ksym == event.key.keysym.sym)
407 424
 				return 1;