The MESS Driver Lifecycle
When does my code get called?
This page is outdated and needs to be updated for the current
MAME and
MESS version.
Imagine we want to create, update, or understand a MESS driver. We have all these wonderful ADDRESS_MAP, MACHINE_RESET, VIDEO_START, DEVICE_INIT, etc. structures and functions we can use. The key to implementing the things properly is understanding the MESS driver lifecycle; knowing when what is created and/or available when a driver is started or reset (soft or hard reset).
This information can be found in the MAME and MESS source code. Most of which is available in the mame.c file. Additional information can be found on the mamedev wiki.
The section where information is used or code is called that we have defined in our own driver or cpu core code have been marked in bold.
create_machine() to create the machine structure
reset_machine() to initialize the machine strucutre
mame_validitycheck() to perform validity checks on all compiled drivers
game start/hard reset
reset_machine() to initialize the machine strucutre
init_resource_tracking()
begin_resource_tracking()
init_machine()
cpuintrf_init() to determine which CPUs are available
sndintrf_init() to determine which sound chips are available
fileio_init() to initialize file I/O info
config_init() to initialize the configuration system
output_init() to initialize the output system
state_init() to initialize the save state system
state_save_allow_registration() to allow save state registrations
drawgfx_init() to initialize rendering globals
palette_init() to initialize palette system
render_init() to initialize the rendering system
ui_init() to initialize the user interface
generic_machine_init() to initialize generic machine structures
generic_video_init() to initialize generic video structures
timer_init() and register soft_reset_timer handler to reset the timer system
osd_init() to do platform specific initialization
code_init() to initialize the input system
input_port_init() to set up the input ports from the driver's INPUT_PORTs
rom_init() to load the system's ROMs
memory_init() to process the system's memory maps from the driver's ADDRESS_MAPs
cpuexec_init() to initialize the CPUs
cpuint_init() to initialize the CPU interrupts
devices_init (
MESS specific)
inputx_init() to initialize natural keyboard support
devices_allocate() to create the device information structures
ram_init() to initialize the RAM settings
image_init() to initialize all devices
for each device type
DEVICE_INIT(image)
-
for each device of type
image_from_device_and_index() to identify the image
image_load() to load the image
image verify
DEVICE_CREATE(image,format,args) or DEVICE_LOAD(image)
mame_debug_init() to set up the debugger
DRIVER_INIT()
video_init() to start the video system
sound_init() to start the audio system
MACHINE_START()
SOUND_START()
VIDEO_START()
free disposable memory regions
saveload_init() to set up for save/load
cheat_init() to initialize the cheat system
config_load_settings() to load the configuration file
nvram_load() to load the system's NVRAM by calling NVRAM_HANDLER() if available
ui_display_startup_screens() to display the startup screens
begin_resource_tracking()
soft_reset() (can also be initiated while the machine is running)
end_resource_tracking()
begin_resource_tracking()
state_save_allow_registrations() to allow save state registrations
cpuint_reset
MACHINE_RESET()
SOUND_RESET()
VIDEO_RESET()
call everything on the reset callback lit
state_save_allow_registrations() to disallow save state registrations
while running
execute cpu slices and video_frame_update
end_resource_tracking() to free all auto_mallocs and timers
nvram_save() to save the system's NVRAM by calling NVRAM_HANDLER() if available
config_save_settings() to save the system's configuration
call exit routines
exit_resource_tracking()
empty exit, reset, and pause callback lists
destroy_machine