Skip to content

Commit

Permalink
MEGA65: fast boot mode
Browse files Browse the repository at this point in the history
With the -fastboot switch, Xemu uses the "sleepless" timing during the
RESET HYPPO trap to speed up booting. Can be useful if called from
scripts with parameters like -prg and such to make the experience
faster. It's usless if -sleepless is used anyway, since then the
sleepless timing is always applied.
  • Loading branch information
lgblgblgb committed Jul 26, 2023
1 parent 55317e7 commit 8c1c8cd
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions targets/mega65/configdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ static const struct xemutools_configdef_switch_st switch_options[] = {
{ "curskeyjoy", "Cursor keys as joystick [makes your emulator unsable to move cursor in BASIC/etc!]", &hid_joy_on_cursor_keys },
{ "showscanlines", "Show scanlines in V200 modes", &configdb.show_scanlines },
{ "allowscanlines", "Allow user programs to control scanline visibility", &configdb.allow_scanlines },
{ "fastboot", "Try to use sleepless emulation mode during booting", &configdb.fastboot },
{ NULL }
};

Expand Down
1 change: 1 addition & 0 deletions targets/mega65/configdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ struct configdb_st {
int noopl3;
int sidmask;
int audiobuffersize;
int fastboot;
};

extern struct configdb_st configdb;
Expand Down
1 change: 1 addition & 0 deletions targets/mega65/hypervisor.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ static inline void first_leave ( void )
vic4_set_videostd(configdb.videostd, "in hypervisor.c, requested as boot/reset default");
// OK, that's enough
hdos_notify_system_start_end();
xemu_sleepless_temporary_mode(0); // turn off temporary sleepless mode which may have been enabled before
DEBUGPRINT("HYPERVISOR: first return after RESET, end of processing workarounds." NL);
}

Expand Down
1 change: 1 addition & 0 deletions targets/mega65/mega65.c
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@ int main ( int argc, char **argv )
configdb.umon = XUMON_DEFAULT_PORT;
xumon_init(configdb.umon);
#endif
xemu_sleepless_temporary_mode(configdb.fastboot);
if (configdb.prg) {
inject_register_prg(configdb.prg, configdb.prgmode);
} else {
Expand Down
20 changes: 20 additions & 0 deletions xemu/emutools.c
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,26 @@ void xemu_timekeeping_start ( void )
}


void xemu_sleepless_temporary_mode ( const int enable )
{
static int enabled = 0;
if ((enable && enabled) || (!enable && !enabled))
return;
enabled = enable;
static int sleepless_old = 0;
if (enable) {
DEBUGPRINT("TIMING: enabling temporary sleepless mode: %s" NL, emu_is_sleepless ? "already sleepless" : "OK");
sleepless_old = emu_is_sleepless;
emu_is_sleepless = 1;
} else {
DEBUGPRINT("TIMING: disabling temporary sleepless mode: %s" NL, sleepless_old ? "constant sleepless" : "OK");
emu_is_sleepless = sleepless_old;
if (!emu_is_sleepless)
xemu_timekeeping_start();
}
}


void xemu_render_dummy_frame ( Uint32 colour, int texture_x_size, int texture_y_size )
{
int tail;
Expand Down
1 change: 1 addition & 0 deletions xemu/emutools.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ extern int xemu_post_init (
);
extern int xemu_set_icon_from_xpm ( char *xpm[] );
extern void xemu_timekeeping_start ( void );
extern void xemu_sleepless_temporary_mode ( const int enable );
extern void xemu_render_dummy_frame ( Uint32 colour, int texture_x_size, int texture_y_size );
extern Uint32 *xemu_start_pixel_buffer_access ( int *texture_tail );
extern void xemu_update_screen ( void );
Expand Down

1 comment on commit 8c1c8cd

@lgblgblgb
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also useful for #352

Please sign in to comment.