diff --git a/src/emu/emuopts.c b/src/emu/emuopts.c index fd6e1e2e43b..d3da990cfe4 100644 --- a/src/emu/emuopts.c +++ b/src/emu/emuopts.c @@ -195,6 +195,8 @@ const options_entry emu_options::s_option_entries[] = { OPTION_RAMSIZE ";ram", NULL, OPTION_STRING, "size of RAM (if supported by driver)" }, { OPTION_CONFIRM_QUIT, "0", OPTION_BOOLEAN, "display confirm quit screen on exit" }, { OPTION_UI_MOUSE, "0", OPTION_BOOLEAN, "display ui mouse cursor" }, + { OPTION_AUTOBOOT_COMMAND ";ab", NULL, OPTION_STRING, "command to execute after machine boot" }, + { OPTION_AUTOBOOT_DELAY, "2", OPTION_INTEGER, "timer delay in sec to trigger command execution on autoboot" }, { NULL } }; diff --git a/src/emu/emuopts.h b/src/emu/emuopts.h index 94e8a184db9..92da803d98a 100644 --- a/src/emu/emuopts.h +++ b/src/emu/emuopts.h @@ -199,6 +199,8 @@ enum #define OPTION_CONFIRM_QUIT "confirm_quit" #define OPTION_UI_MOUSE "ui_mouse" +#define OPTION_AUTOBOOT_COMMAND "autoboot_command" +#define OPTION_AUTOBOOT_DELAY "autoboot_delay" //************************************************************************** // TYPE DEFINITIONS @@ -352,6 +354,9 @@ public: bool confirm_quit() const { return bool_value(OPTION_CONFIRM_QUIT); } bool ui_mouse() const { return bool_value(OPTION_UI_MOUSE); } + + const char *autoboot_command() const { return value(OPTION_AUTOBOOT_COMMAND); } + int autoboot_delay() const { return int_value(OPTION_AUTOBOOT_DELAY); } // device-specific options const char *device_option(device_image_interface &image); diff --git a/src/emu/machine.c b/src/emu/machine.c index 412ebb290a5..41c215c559e 100644 --- a/src/emu/machine.c +++ b/src/emu/machine.c @@ -232,6 +232,13 @@ const char *running_machine::describe_context() return m_context; } +TIMER_CALLBACK_MEMBER(running_machine::autoboot_callback) +{ + if (strlen(options().autoboot_command())!=0) { + ioport().natkeyboard().post_utf8(options().autoboot_command()); + ioport().natkeyboard().post_utf8("\r"); + } +} //------------------------------------------------- // start - initialize the emulated machine @@ -322,6 +329,9 @@ void running_machine::start() // set up the cheat engine m_cheat = auto_alloc(*this, cheat_manager(*this)); + /* allocate a timer */ + m_autoboot_timer = scheduler().timer_alloc(timer_expired_delegate(FUNC(running_machine::autoboot_callback), this)); + // disallow save state registrations starting here m_save.allow_registration(false); } @@ -839,8 +849,11 @@ void running_machine::soft_reset(void *ptr, INT32 param) // call all registered reset callbacks call_notifiers(MACHINE_NOTIFY_RESET); + // setup autoboot if needed + m_autoboot_timer->adjust(attotime(options().autoboot_delay(),0),0); + // now we're running - m_current_phase = MACHINE_PHASE_RUNNING; + m_current_phase = MACHINE_PHASE_RUNNING; } diff --git a/src/emu/machine.h b/src/emu/machine.h index e4c4c137a8b..855a554cda4 100644 --- a/src/emu/machine.h +++ b/src/emu/machine.h @@ -329,6 +329,8 @@ private: void stop_all_devices(); void presave_all_devices(); void postload_all_devices(); + + TIMER_CALLBACK_MEMBER(autoboot_callback); // internal state const machine_config & m_config; // reference to the constructed machine_config @@ -415,6 +417,7 @@ private: memory_manager m_memory; // memory manager ioport_manager m_ioport; // I/O port manager device_scheduler m_scheduler; // scheduler object + emu_timer *m_autoboot_timer; // autoboot timer };