From e738b79785852050ce8b83e369a7fc4dd46a071b Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Mon, 18 Jan 2010 09:34:43 +0000 Subject: Correct a long-standing design flaw: device configuration state is now separate from runtime device state. I have larger plans for devices, so there is some temporary scaffolding to hold everything together, but this first step does separate things out. There is a new class 'running_device' which represents the state of a live device. A list of these running_devices sits in machine->devicelist and is created when a running_machine is instantiated. To access the configuration state, use device->baseconfig() which returns a reference to the configuration. The list of running_devices in machine->devicelist has a 1:1 correspondance with the list of device configurations in machine->config->devicelist, and most navigation options work equally on either (scanning by class, type, etc.) For the most part, drivers will now deal with running_device objects instead of const device_config objects. In fact, in order to do this patch, I did the following global search & replace: const device_config -> running_device device->static_config -> device->baseconfig().static_config device->inline_config -> device->baseconfig().inline_config and then fixed up the compiler errors that fell out. Some specifics: Removed device_get_info_* functions and replaced them with methods called get_config_*. Added methods for get_runtime_* to access runtime state from the running_device. DEVICE_GET_INFO callbacks are only passed a device_config *. This means they have no access to the token or runtime state at all. For most cases this is fine. Added new DEVICE_GET_RUNTIME_INFO callback that is passed the running_device for accessing data that is live at runtime. In the future this will go away to make room for a cleaner mechanism. Cleaned up the handoff of memory regions from the memory subsystem to the devices. --- src/ldplayer/ldplayer.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/ldplayer') diff --git a/src/ldplayer/ldplayer.c b/src/ldplayer/ldplayer.c index 0a84537e554..34ee75fb118 100644 --- a/src/ldplayer/ldplayer.c +++ b/src/ldplayer/ldplayer.c @@ -72,7 +72,7 @@ static emu_timer *pr8210_bit_timer; static UINT32 pr8210_command_buffer_in, pr8210_command_buffer_out; static UINT8 pr8210_command_buffer[10]; -static void (*execute_command)(const device_config *laserdisc, int command); +static void (*execute_command)(running_device *laserdisc, int command); @@ -87,7 +87,7 @@ static void free_string(running_machine *machine) } -static chd_file *get_disc(const device_config *device) +static chd_file *get_disc(running_device *device) { mame_file *image_file = NULL; chd_file *image_chd = NULL; @@ -152,7 +152,7 @@ static chd_file *get_disc(const device_config *device) * *************************************/ -static void process_commands(const device_config *laserdisc) +static void process_commands(running_device *laserdisc) { input_port_value controls = input_port_read(laserdisc->machine, "controls"); int number; @@ -227,7 +227,7 @@ static void process_commands(const device_config *laserdisc) static TIMER_CALLBACK( vsync_update ) { - const device_config *laserdisc = machine->config->devicelist.first(LASERDISC); + running_device *laserdisc = machine->devicelist.first(LASERDISC); int vblank_scanline; attotime target; @@ -250,7 +250,7 @@ static MACHINE_START( ldplayer ) static TIMER_CALLBACK( autoplay ) { - const device_config *laserdisc = machine->config->devicelist.first(LASERDISC); + running_device *laserdisc = machine->devicelist.first(LASERDISC); /* start playing */ (*execute_command)(laserdisc, CMD_PLAY); @@ -284,7 +284,7 @@ INLINE void pr8210_add_command(UINT8 command) static TIMER_CALLBACK( pr8210_bit_off_callback ) { - const device_config *laserdisc = (const device_config *)ptr; + running_device *laserdisc = (running_device *)ptr; /* deassert the control line */ laserdisc_line_w(laserdisc, LASERDISC_LINE_CONTROL, CLEAR_LINE); @@ -294,7 +294,7 @@ static TIMER_CALLBACK( pr8210_bit_off_callback ) static TIMER_CALLBACK( pr8210_bit_callback ) { attotime duration = ATTOTIME_IN_MSEC(30); - const device_config *laserdisc = (const device_config *)ptr; + running_device *laserdisc = (running_device *)ptr; UINT8 bitsleft = param >> 16; UINT8 data = param; @@ -323,7 +323,7 @@ static TIMER_CALLBACK( pr8210_bit_callback ) static MACHINE_START( pr8210 ) { - const device_config *laserdisc = machine->config->devicelist.first(LASERDISC); + running_device *laserdisc = machine->devicelist.first(LASERDISC); MACHINE_START_CALL(ldplayer); pr8210_bit_timer = timer_alloc(machine, pr8210_bit_callback, (void *)laserdisc); } @@ -336,7 +336,7 @@ static MACHINE_RESET( pr8210 ) } -static void pr8210_execute(const device_config *laserdisc, int command) +static void pr8210_execute(running_device *laserdisc, int command) { static const UINT8 digits[10] = { 0x01, 0x11, 0x09, 0x19, 0x05, 0x15, 0x0d, 0x1d, 0x03, 0x13 }; @@ -452,7 +452,7 @@ static void pr8210_execute(const device_config *laserdisc, int command) * *************************************/ -static void ldv1000_execute(const device_config *laserdisc, int command) +static void ldv1000_execute(running_device *laserdisc, int command) { static const UINT8 digits[10] = { 0x3f, 0x0f, 0x8f, 0x4f, 0x2f, 0xaf, 0x6f, 0x1f, 0x9f, 0x5f }; switch (command) -- cgit v1.2.3-70-g09d2