Combined all system reboots
This commit is contained in:
parent
bd8b2026b8
commit
b737dfca85
|
@ -28,5 +28,6 @@ void screen_resize(Uint16 width, Uint16 height);
|
|||
void screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2);
|
||||
void screen_redraw(void);
|
||||
void screen_debugger(Uxn *u);
|
||||
|
||||
Uint8 screen_dei(Uxn *u, Uint8 addr);
|
||||
void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port);
|
||||
|
|
|
@ -96,11 +96,27 @@ system_version(char *name, char *date)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
system_reboot(Uxn *u, char *rom, int soft)
|
||||
{
|
||||
int i;
|
||||
for(i = 0x100 * soft; i < 0x10000; i++)
|
||||
u->ram[i] = 0;
|
||||
for(i = 0x0; i < 0x100; i++)
|
||||
u->dev[i] = 0;
|
||||
u->wst.ptr = 0;
|
||||
u->rst.ptr = 0;
|
||||
if(system_load(u, boot_rom))
|
||||
if(uxn_eval(u, PAGE_PROGRAM))
|
||||
boot_rom = rom;
|
||||
}
|
||||
|
||||
int
|
||||
system_init(Uxn *u, Uint8 *ram, char *rom)
|
||||
{
|
||||
u->ram = ram;
|
||||
if(!system_load(u, rom))
|
||||
if(!system_load(u, "boot.rom"))
|
||||
return system_error("Init", "Failed to load rom.");
|
||||
boot_rom = rom;
|
||||
return 1;
|
||||
|
|
|
@ -18,9 +18,11 @@ WITH REGARD TO THIS SOFTWARE.
|
|||
extern char *boot_rom;
|
||||
|
||||
void system_connect(Uint8 device, Uint8 ver, Uint16 dei, Uint16 deo);
|
||||
void system_reboot(Uxn *u, char *rom, int soft);
|
||||
void system_inspect(Uxn *u);
|
||||
int system_version(char *emulator, char *date);
|
||||
int system_load(Uxn *u, char *filename);
|
||||
void system_inspect(Uxn *u);
|
||||
int system_error(char *msg, const char *err);
|
||||
int system_init(Uxn *u, Uint8 *ram, char *rom);
|
||||
|
||||
void system_deo(Uxn *u, Uint8 *d, Uint8 port);
|
||||
|
|
42
src/uxnemu.c
42
src/uxnemu.c
|
@ -255,43 +255,14 @@ emu_init(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
emu_start(Uxn *u, char *rom)
|
||||
{
|
||||
exec_deadline = SDL_GetPerformanceCounter() + deadline_interval;
|
||||
screen_resize(WIDTH, HEIGHT);
|
||||
if(!uxn_eval(u, PAGE_PROGRAM))
|
||||
return system_error("Boot", "Failed to eval rom.");
|
||||
SDL_SetWindowTitle(emu_window, rom);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
emu_restart(Uxn *u)
|
||||
emu_restart(Uxn *u, char *rom, int soft)
|
||||
{
|
||||
screen_resize(WIDTH, HEIGHT);
|
||||
SDL_SetWindowTitle(emu_window, boot_rom);
|
||||
if(!emu_start(u, "launcher.rom"))
|
||||
emu_start(u, boot_rom);
|
||||
}
|
||||
|
||||
static int
|
||||
emu_restart_soft(Uxn *u)
|
||||
{
|
||||
int i;
|
||||
for(i = 0x100; i < 0x10000; i++)
|
||||
u->ram[i] = 0;
|
||||
for(i = 0x0; i < 0x100; i++)
|
||||
u->dev[i] = 0;
|
||||
u->wst.ptr = 0;
|
||||
u->rst.ptr = 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, boot_rom))
|
||||
return system_error("Boot", "Failed to load rom.");
|
||||
if(!uxn_eval(u, PAGE_PROGRAM))
|
||||
return system_error("Boot", "Failed to eval rom.");
|
||||
return 1;
|
||||
system_reboot(u, rom, soft);
|
||||
SDL_SetWindowTitle(emu_window, boot_rom);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -384,8 +355,7 @@ handle_events(Uxn *u)
|
|||
else if(event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_EXPOSED)
|
||||
emu_redraw(u);
|
||||
else if(event.type == SDL_DROPFILE) {
|
||||
screen_resize(WIDTH, HEIGHT);
|
||||
emu_start(u, event.drop.file);
|
||||
emu_restart(u, event.drop.file, 0);
|
||||
SDL_free(event.drop.file);
|
||||
}
|
||||
/* Audio */
|
||||
|
@ -416,9 +386,9 @@ handle_events(Uxn *u)
|
|||
else if(event.key.keysym.sym == SDLK_F3)
|
||||
capture_screen();
|
||||
else if(event.key.keysym.sym == SDLK_F4)
|
||||
emu_restart(u);
|
||||
emu_restart(u, boot_rom, 0);
|
||||
else if(event.key.keysym.sym == SDLK_F5)
|
||||
emu_restart_soft(u);
|
||||
emu_restart(u, boot_rom, 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;
|
||||
|
|
Loading…
Reference in New Issue