diff --git a/src/emu/deprecat.h b/src/emu/deprecat.h index 934f38c459b..70a34b02b7f 100644 --- a/src/emu/deprecat.h +++ b/src/emu/deprecat.h @@ -31,9 +31,7 @@ *************************************/ #define MDRV_CPU_VBLANK_INT_HACK(_func, _rate) \ - TOKEN_UINT32_PACK2(MCONFIG_TOKEN_DIEXEC_VBLANK_INT, 8, _rate, 24), \ - TOKEN_PTR(cpu_interrupt, _func), \ - TOKEN_PTR(stringptr, NULL), \ + device_config_execute_interface::static_set_vblank_int(device, _func, NULL, _rate); \ diff --git a/src/emu/devcpu.h b/src/emu/devcpu.h index f974d455fd4..aa89e3f03af 100644 --- a/src/emu/devcpu.h +++ b/src/emu/devcpu.h @@ -420,7 +420,7 @@ protected: public: // basic information getters virtual const rom_entry *rom_region() const { return reinterpret_cast(get_legacy_config_ptr(DEVINFO_PTR_ROM_REGION)); } - virtual const machine_config_token *machine_config_tokens() const { return reinterpret_cast(get_legacy_config_ptr(DEVINFO_PTR_MACHINE_CONFIG)); } + virtual machine_config_constructor machine_config_additions() const { return reinterpret_cast(get_legacy_config_ptr(DEVINFO_PTR_MACHINE_CONFIG)); } protected: // device_config_execute_interface overrides diff --git a/src/emu/devintrf.c b/src/emu/devintrf.c index 25dca3bac86..37be4a93051 100644 --- a/src/emu/devintrf.c +++ b/src/emu/devintrf.c @@ -272,17 +272,6 @@ void device_config_interface::interface_config_complete() } -//------------------------------------------------- -// interface_process_token - default token -// processing for a given interface -//------------------------------------------------- - -bool device_config_interface::interface_process_token(UINT32 entrytype, const machine_config_token *&tokens) -{ - return false; -} - - //------------------------------------------------- // interface_validity_check - default validation // for a device after the configuration has been @@ -317,8 +306,6 @@ device_config::device_config(const machine_config &mconfig, device_type type, co m_tag(tag), m_config_complete(false) { - memset(m_inline_data, 0, sizeof(m_inline_data)); - // derive the clock from our owner if requested if ((m_clock & 0xff000000) == 0xff000000) { @@ -353,124 +340,6 @@ void device_config::config_complete() } -//------------------------------------------------- -// process_token - process tokens -//------------------------------------------------- - -void device_config::process_token(UINT32 entrytype, const machine_config_token *&tokens) -{ - int size, offset, bits, index; - UINT32 data32; - UINT64 data64; - bool processed = false; - - // first process stuff we know about - switch (entrytype) - { - // specify device clock - case MCONFIG_TOKEN_DEVICE_CLOCK: - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, m_clock, 32); - processed = true; - break; - - // specify pointer to static device configuration - case MCONFIG_TOKEN_DEVICE_CONFIG: - m_static_config = TOKEN_GET_PTR(tokens, voidptr); - processed = true; - break; - - // provide inline device data packed into a 16-bit space - case MCONFIG_TOKEN_DEVICE_INLINE_DATA16: - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT32_UNPACK3(tokens, entrytype, 8, index, 8, data32, 16); - assert(index >= 0 && index < ARRAY_LENGTH(m_inline_data)); - m_inline_data[index] = data32; - processed = true; - break; - - // provide inline device data packed into a 32-bit space - case MCONFIG_TOKEN_DEVICE_INLINE_DATA32: - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, index, 8); - assert(index >= 0 && index < ARRAY_LENGTH(m_inline_data)); - m_inline_data[index] = TOKEN_GET_UINT32(tokens); - processed = true; - break; - - // provide inline device data packed into a 64-bit space - case MCONFIG_TOKEN_DEVICE_INLINE_DATA64: - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, index, 8); - assert(index >= 0 && index < ARRAY_LENGTH(m_inline_data)); - TOKEN_EXTRACT_UINT64(tokens, m_inline_data[index]); - processed = true; - break; - - // provide inline device data packed into a 32-bit word - case MCONFIG_TOKEN_DEVICE_CONFIG_DATA32: - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT32_UNPACK3(tokens, entrytype, 8, size, 4, offset, 12); - data32 = TOKEN_GET_UINT32(tokens); - switch (size) - { - case 1: *(UINT8 *) ((UINT8 *)downcast(this)->inline_config() + offset) = data32; break; - case 2: *(UINT16 *)((UINT8 *)downcast(this)->inline_config() + offset) = data32; break; - case 4: *(UINT32 *)((UINT8 *)downcast(this)->inline_config() + offset) = data32; break; - } - processed = true; - break; - - // provide inline device data packed into a 64-bit word - case MCONFIG_TOKEN_DEVICE_CONFIG_DATA64: - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT32_UNPACK3(tokens, entrytype, 8, size, 4, offset, 12); - TOKEN_EXTRACT_UINT64(tokens, data64); - switch (size) - { - case 1: *(UINT8 *) ((UINT8 *)downcast(this)->inline_config() + offset) = data64; break; - case 2: *(UINT16 *)((UINT8 *)downcast(this)->inline_config() + offset) = data64; break; - case 4: *(UINT32 *)((UINT8 *)downcast(this)->inline_config() + offset) = data64; break; - case 8: *(UINT64 *)((UINT8 *)downcast(this)->inline_config() + offset) = data64; break; - } - processed = true; - break; - - // provide inline floating-point device data packed into a fixed-point 32-bit word - case MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP32: - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT32_UNPACK4(tokens, entrytype, 8, size, 4, bits, 6, offset, 12); - data32 = TOKEN_GET_UINT32(tokens); - switch (size) - { - case 4: *(float *)((UINT8 *)downcast(this)->inline_config() + offset) = (float)(INT32)data32 / (float)(1 << bits); break; - case 8: *(double *)((UINT8 *)downcast(this)->inline_config() + offset) = (double)(INT32)data32 / (double)(1 << bits); break; - } - processed = true; - break; - } - - // anything else might be handled by one of our interfaces - for (device_config_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) - if (intf->interface_process_token(entrytype, tokens)) - { - assert(!processed); - processed = true; - } - - // or it might be processed by the device itself - if (device_process_token(entrytype, tokens)) - { - assert(!processed); - processed = true; - } - - // regardless, *somebody* must handle it - if (!processed) - throw emu_fatalerror("Unhandled token %d for device '%s'", entrytype, tag()); -} - - //------------------------------------------------- // validity_check - validate a device after the // configuration has been constructed @@ -505,18 +374,6 @@ void device_config::device_config_complete() } -//------------------------------------------------- -// device_process_token - process basic device -// tokens -//------------------------------------------------- - -bool device_config::device_process_token(UINT32 entrytype, const machine_config_token *&tokens) -{ - // handle nothing by default - return false; -} - - //------------------------------------------------- // device_validity_check - validate a device after // the configuration has been constructed @@ -541,12 +398,12 @@ const rom_entry *device_config::rom_region() const //------------------------------------------------- -// machine_config_tokens - return a pointer to -// a set of machine configuration tokens -// describing sub-devices for this device +// machine_config - return a pointer to a machine +// config constructor describing sub-devices for +// this device //------------------------------------------------- -const machine_config_token *device_config::machine_config_tokens() const +machine_config_constructor device_config::machine_config_additions() const { return NULL; } diff --git a/src/emu/devintrf.h b/src/emu/devintrf.h index 03f8c812d7b..6c94f52ff57 100644 --- a/src/emu/devintrf.h +++ b/src/emu/devintrf.h @@ -66,32 +66,13 @@ // configure devices #define MDRV_DEVICE_CONFIG(_config) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEVICE_CONFIG, 8), \ - TOKEN_PTR(voidptr, &(_config)), + device_config::static_set_static_config(device, &(_config)); \ #define MDRV_DEVICE_CONFIG_CLEAR() \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEVICE_CONFIG, 8), \ - TOKEN_PTR(voidptr, NULL), + device_config::static_set_static_config(device, NULL); \ #define MDRV_DEVICE_CLOCK(_clock) \ - TOKEN_UINT64_PACK2(MCONFIG_TOKEN_DEVICE_CLOCK, 8, _clock, 32), - -#define MDRV_DEVICE_INLINE_DATA16(_index, _data) \ - TOKEN_UINT32_PACK3(MCONFIG_TOKEN_DEVICE_INLINE_DATA16, 8, _index, 8, (UINT16)(_data), 16), \ - -#define MDRV_DEVICE_INLINE_DATA32(_index, _data) \ - TOKEN_UINT32_PACK2(MCONFIG_TOKEN_DEVICE_INLINE_DATA32, 8, _index, 8), \ - TOKEN_UINT32((UINT32)(_data)), - -#define MDRV_DEVICE_INLINE_DATA64(_index, _data) \ - TOKEN_UINT32_PACK2(MCONFIG_TOKEN_DEVICE_INLINE_DATA64, 8, _index, 8), \ - TOKEN_UINT64((UINT64)(_data)), - -#ifdef PTR64 -#define MDRV_DEVICE_INLINE_DATAPTR(_index, _data) MDRV_DEVICE_INLINE_DATA64(_index, (FPTR)(_data)) -#else -#define MDRV_DEVICE_INLINE_DATAPTR(_index, _data) MDRV_DEVICE_INLINE_DATA32(_index, (FPTR)(_data)) -#endif + device_config::static_set_clock(device, _clock); \ @@ -110,7 +91,6 @@ class device_execute_interface; class device_memory_interface; class device_state_interface; struct rom_entry; -union machine_config_token; class machine_config; @@ -265,9 +245,12 @@ public: const void *static_config() const { return m_static_config; } // methods that wrap both interface-level and device-level behavior - void process_token(UINT32 entrytype, const machine_config_token *&tokens); void config_complete(); bool validity_check(const game_driver &driver) const; + + // configuration helpers + static void static_set_clock(device_config *device, UINT32 clock) { device->m_clock = clock; } + static void static_set_static_config(device_config *device, const void *config) { device->m_static_config = config; } //------------------- begin derived class overrides @@ -276,14 +259,13 @@ public: // optional operation overrides protected: - virtual bool device_process_token(UINT32 entrytype, const machine_config_token *&tokens); virtual void device_config_complete(); virtual bool device_validity_check(const game_driver &driver) const; public: // optional information overrides virtual const rom_entry *rom_region() const; - virtual const machine_config_token *machine_config_tokens() const; + virtual machine_config_constructor machine_config_additions() const; //------------------- end derived class overrides @@ -298,7 +280,6 @@ protected: const machine_config & m_machine_config; // reference to the machine's configuration const void * m_static_config; // static device configuration - UINT64 m_inline_data[16]; // array of inline configuration values astring m_name; // name of the device @@ -333,7 +314,6 @@ public: // optional operation overrides virtual void interface_config_complete(); - virtual bool interface_process_token(UINT32 entrytype, const machine_config_token *&tokens); virtual bool interface_validity_check(const game_driver &driver) const; protected: @@ -416,7 +396,7 @@ public: // machine and ROM configuration getters ... pass through to underlying config const rom_entry *rom_region() const { return m_baseconfig.rom_region(); } - const machine_config_token *machine_config_tokens() const { return m_baseconfig.machine_config_tokens(); } + machine_config_constructor machine_config_additions() const { return m_baseconfig.machine_config_additions(); } public: running_machine * machine; diff --git a/src/emu/devlegcy.c b/src/emu/devlegcy.c index c3cd3d8bd23..9eb8e416003 100644 --- a/src/emu/devlegcy.c +++ b/src/emu/devlegcy.c @@ -127,6 +127,65 @@ const char *legacy_device_config_base::get_legacy_config_string(UINT32 state) co } +//------------------------------------------------- +// static_set_inline32 - configuration helper to +// set a 32-bit value in the inline configuration +//------------------------------------------------- + +void legacy_device_config_base::static_set_inline32(device_config *device, UINT32 offset, UINT32 size, UINT32 value) +{ + legacy_device_config_base *legacy = downcast(device); + void *dest = reinterpret_cast(legacy->m_inline_config) + offset; + if (size == 1) + *reinterpret_cast(dest) = value; + else if (size == 2) + *reinterpret_cast(dest) = value; + else if (size == 4) + *reinterpret_cast(dest) = value; + else + throw emu_fatalerror("Unexpected size %d in legacy_device_config_base::static_set_inline32", size); +} + + +//------------------------------------------------- +// static_set_inline64 - configuration helper to +// set a 64-bit value in the inline configuration +//------------------------------------------------- + +void legacy_device_config_base::static_set_inline64(device_config *device, UINT32 offset, UINT32 size, UINT64 value) +{ + legacy_device_config_base *legacy = downcast(device); + void *dest = reinterpret_cast(legacy->m_inline_config) + offset; + if (size == 1) + *reinterpret_cast(dest) = value; + else if (size == 2) + *reinterpret_cast(dest) = value; + else if (size == 4) + *reinterpret_cast(dest) = value; + else if (size == 8) + *reinterpret_cast(dest) = value; + else + throw emu_fatalerror("Unexpected size %d in legacy_device_config_base::static_set_inline64", size); +} + + +//------------------------------------------------- +// static_set_inline_float - configuration helper +// to set a floating-point value in the inline +// configuration +//------------------------------------------------- + +void legacy_device_config_base::static_set_inline_float(device_config *device, UINT32 offset, UINT32 size, float value) +{ + legacy_device_config_base *legacy = downcast(device); + void *dest = reinterpret_cast(legacy->m_inline_config) + offset; + if (size == 4) + *reinterpret_cast(dest) = value; + else + throw emu_fatalerror("Unexpected size %d in legacy_device_config_base::static_set_inline_float", size); +} + + //------------------------------------------------- // device_validity_check - perform validity // checks on a device configuration diff --git a/src/emu/devlegcy.h b/src/emu/devlegcy.h index 7cbd8a38f14..88c1bc3c808 100644 --- a/src/emu/devlegcy.h +++ b/src/emu/devlegcy.h @@ -275,10 +275,11 @@ const device_type name = configclass::static_alloc_device_config // DEVICE_CONFIGURATION_MACROS //************************************************************************** +#define structsizeof(_struct, _field) sizeof(((_struct *)NULL)->_field) + // inline device configurations that require 32 bits of storage in the token #define MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(_size, _offset, _val) \ - TOKEN_UINT32_PACK3(MCONFIG_TOKEN_DEVICE_CONFIG_DATA32, 8, _size, 4, _offset, 12), \ - TOKEN_UINT32((UINT32)(_val)), + legacy_device_config_base::static_set_inline32(device, _offset, _size, (UINT32)(_val)); #define MDRV_DEVICE_CONFIG_DATA32(_struct, _field, _val) \ MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(structsizeof(_struct, _field), offsetof(_struct, _field), _val) @@ -301,8 +302,7 @@ const device_type name = configclass::static_alloc_device_config // inline device configurations that require 32 bits of fixed-point storage in the token #define MDRV_DEVICE_CONFIG_DATAFP32_EXPLICIT(_size, _offset, _val, _fixbits) \ - TOKEN_UINT32_PACK4(MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP32, 8, _size, 4, _fixbits, 6, _offset, 12), \ - TOKEN_UINT32((INT32)((float)(_val) * (float)(1 << (_fixbits)))), + legacy_device_config_base::static_set_inline_float(device, _offset, _size, (float)(_val)); #define MDRV_DEVICE_CONFIG_DATAFP32(_struct, _field, _val, _fixbits) \ MDRV_DEVICE_CONFIG_DATAFP32_EXPLICIT(structsizeof(_struct, _field), offsetof(_struct, _field), _val, _fixbits) @@ -325,8 +325,7 @@ const device_type name = configclass::static_alloc_device_config // inline device configurations that require 64 bits of storage in the token #define MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(_size, _offset, _val) \ - TOKEN_UINT32_PACK3(MCONFIG_TOKEN_DEVICE_CONFIG_DATA64, 8, _size, 4, _offset, 12), \ - TOKEN_UINT64((UINT64)(_val)), + legacy_device_config_base::static_set_inline64(device, _offset, _size, (UINT64)(_val)); #define MDRV_DEVICE_CONFIG_DATA64(_struct, _field, _val) \ MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(structsizeof(_struct, _field), offsetof(_struct, _field), _val) @@ -373,6 +372,8 @@ const device_type name = configclass::static_alloc_device_config //************************************************************************** union deviceinfo; +class machine_config; +class device_config; char *get_temp_string_buffer(void); resource_pool &machine_get_pool(running_machine &machine); @@ -402,7 +403,7 @@ union deviceinfo device_execute_func execute; // DEVINFO_FCT_EXECUTE device_nvram_func nvram; // DEVINFO_FCT_NVRAM const rom_entry * romregion; // DEVINFO_PTR_ROM_REGION - const machine_config_token *machine_config; // DEVINFO_PTR_MACHINE_CONFIG + machine_config_constructor machine_config; // DEVINFO_PTR_MACHINE_CONFIG address_map_constructor internal_map8; // DEVINFO_PTR_INTERNAL_MEMORY_MAP address_map_constructor internal_map16; // DEVINFO_PTR_INTERNAL_MEMORY_MAP address_map_constructor internal_map32; // DEVINFO_PTR_INTERNAL_MEMORY_MAP @@ -433,11 +434,16 @@ protected: // basic information getters public: virtual const rom_entry *rom_region() const { return reinterpret_cast(get_legacy_config_ptr(DEVINFO_PTR_ROM_REGION)); } - virtual const machine_config_token *machine_config_tokens() const { return reinterpret_cast(get_legacy_config_ptr(DEVINFO_PTR_MACHINE_CONFIG)); } + virtual machine_config_constructor machine_config_additions() const { return reinterpret_cast(get_legacy_config_ptr(DEVINFO_PTR_MACHINE_CONFIG)); } // access to legacy inline configuartion void *inline_config() const { return m_inline_config; } + // inline configuration helpers + static void static_set_inline32(device_config *device, UINT32 offset, UINT32 size, UINT32 value); + static void static_set_inline64(device_config *device, UINT32 offset, UINT32 size, UINT64 value); + static void static_set_inline_float(device_config *device, UINT32 offset, UINT32 size, float value); + protected: // overrides virtual bool device_validity_check(const game_driver &driver) const; diff --git a/src/emu/diexec.c b/src/emu/diexec.c index eb6dfe8eca5..4d34e6e4520 100644 --- a/src/emu/diexec.c +++ b/src/emu/diexec.c @@ -78,7 +78,7 @@ device_config_execute_interface::device_config_execute_interface(const machine_c m_vblank_interrupts_per_frame(0), m_vblank_interrupt_screen(NULL), m_timed_interrupt(NULL), - m_timed_interrupt_period(0) + m_timed_interrupt_period(attotime_zero) { } @@ -92,6 +92,51 @@ device_config_execute_interface::~device_config_execute_interface() } +//------------------------------------------------- +// static_set_disable - configuration helper to +// set the disabled state of a device +//------------------------------------------------- + +void device_config_execute_interface::static_set_disable(device_config *device) +{ + device_config_execute_interface *exec = dynamic_cast(device); + if (exec == NULL) + throw emu_fatalerror("MDRV_DEVICE_DISABLE called on device '%s' with no execute interface", device->tag()); + exec->m_disabled = true; +} + + +//------------------------------------------------- +// static_set_vblank_int - configuration helper +// to set up VBLANK interrupts on the device +//------------------------------------------------- + +void device_config_execute_interface::static_set_vblank_int(device_config *device, device_interrupt_func function, const char *tag, int rate) +{ + device_config_execute_interface *exec = dynamic_cast(device); + if (exec == NULL) + throw emu_fatalerror("MDRV_DEVICE_VBLANK_INT called on device '%s' with no execute interface", device->tag()); + exec->m_vblank_interrupt = function; + exec->m_vblank_interrupts_per_frame = rate; + exec->m_vblank_interrupt_screen = tag; +} + + +//------------------------------------------------- +// static_set_periodic_int - configuration helper +// to set up periodic interrupts on the device +//------------------------------------------------- + +void device_config_execute_interface::static_set_periodic_int(device_config *device, device_interrupt_func function, attotime rate) +{ + device_config_execute_interface *exec = dynamic_cast(device); + if (exec == NULL) + throw emu_fatalerror("MDRV_DEVICE_PERIODIC_INT called on device '%s' with no execute interface", device->tag()); + exec->m_timed_interrupt = function; + exec->m_timed_interrupt_period = rate; +} + + //------------------------------------------------- // execute_clocks_to_cycles - convert the number // of clocks to cycles, rounding down if necessary @@ -160,39 +205,6 @@ UINT32 device_config_execute_interface::execute_default_irq_vector() const } -//------------------------------------------------- -// interface_process_token - token processing for -// the sound interface -//------------------------------------------------- - -bool device_config_execute_interface::interface_process_token(UINT32 entrytype, const machine_config_token *&tokens) -{ - switch (entrytype) - { - // disable a device - case MCONFIG_TOKEN_DIEXEC_DISABLE: - m_disabled = true; - return true; - - // VBLANK interrupt - case MCONFIG_TOKEN_DIEXEC_VBLANK_INT: - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, m_vblank_interrupts_per_frame, 24); - m_vblank_interrupt = TOKEN_GET_PTR(tokens, cpu_interrupt); - m_vblank_interrupt_screen = TOKEN_GET_STRING(tokens); - return true; - - // timed interrupt - case MCONFIG_TOKEN_DIEXEC_PERIODIC_INT: - m_timed_interrupt = TOKEN_GET_PTR(tokens, cpu_interrupt); - TOKEN_EXTRACT_UINT64(tokens, m_timed_interrupt_period); - return true; - } - - return false; -} - - //------------------------------------------------- // interface_validity_check - validation for a // device after the configuration has been @@ -234,12 +246,12 @@ bool device_config_execute_interface::interface_validity_check(const game_driver error = true; } - if (m_timed_interrupt != NULL && m_timed_interrupt_period == 0) + if (m_timed_interrupt != NULL && attotime_compare(m_timed_interrupt_period, attotime_zero) == 0) { mame_printf_error("%s: %s device '%s' has a timer interrupt handler with 0 period!\n", driver.source_file, driver.name, devconfig->tag()); error = true; } - else if (m_timed_interrupt == NULL && m_timed_interrupt_period != 0) + else if (m_timed_interrupt == NULL && attotime_compare(m_timed_interrupt_period, attotime_zero) != 0) { mame_printf_error("%s: %s device '%s' has a no timer interrupt handler but has a non-0 period given!\n", driver.source_file, driver.name, devconfig->tag()); error = true; @@ -548,7 +560,7 @@ void device_execute_interface::interface_pre_start() // allocate timers if we need them if (m_execute_config.m_vblank_interrupts_per_frame > 1) m_partial_frame_timer = timer_alloc(&m_machine, static_trigger_partial_frame_interrupt, (void *)this); - if (m_execute_config.m_timed_interrupt_period != 0) + if (attotime_compare(m_execute_config.m_timed_interrupt_period, attotime_zero) != 0) m_timedint_timer = timer_alloc(&m_machine, static_trigger_periodic_interrupt, (void *)this); // register for save states @@ -624,9 +636,9 @@ void device_execute_interface::interface_post_reset() } // reconfigure periodic interrupts - if (m_execute_config.m_timed_interrupt_period != 0) + if (attotime_compare(m_execute_config.m_timed_interrupt_period, attotime_zero) != 0) { - attotime timedint_period = UINT64_ATTOTIME_TO_ATTOTIME(m_execute_config.m_timed_interrupt_period); + attotime timedint_period = m_execute_config.m_timed_interrupt_period; assert(m_timedint_timer != NULL); timer_adjust_periodic(m_timedint_timer, timedint_period, 0, timedint_period); } diff --git a/src/emu/diexec.h b/src/emu/diexec.h index 27d1cd0b28f..809c6dbae61 100644 --- a/src/emu/diexec.h +++ b/src/emu/diexec.h @@ -109,17 +109,13 @@ enum //************************************************************************** #define MDRV_DEVICE_DISABLE() \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DIEXEC_DISABLE, 8), \ + device_config_execute_interface::static_set_disable(device); \ #define MDRV_DEVICE_VBLANK_INT(_tag, _func) \ - TOKEN_UINT32_PACK2(MCONFIG_TOKEN_DIEXEC_VBLANK_INT, 8, 0, 24), \ - TOKEN_PTR(device_interrupt, _func), \ - TOKEN_PTR(stringptr, _tag), \ + device_config_execute_interface::static_set_vblank_int(device, _func, _tag); \ #define MDRV_DEVICE_PERIODIC_INT(_func, _rate) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DIEXEC_PERIODIC_INT, 8), \ - TOKEN_PTR(device_interrupt, _func), \ - TOKEN_UINT64(UINT64_ATTOTIME_IN_HZ(_rate)), \ + device_config_execute_interface::static_set_periodic_int(device, _func, ATTOTIME_IN_HZ(_rate)); \ @@ -164,6 +160,11 @@ public: UINT32 input_lines() const { return execute_input_lines(); } UINT32 default_irq_vector() const { return execute_default_irq_vector(); } + // static inline helpers + static void static_set_disable(device_config *device); + static void static_set_vblank_int(device_config *device, device_interrupt_func function, const char *tag, int rate = 0); + static void static_set_periodic_int(device_config *device, device_interrupt_func function, attotime rate); + protected: // clock and cycle information getters virtual UINT64 execute_clocks_to_cycles(UINT64 clocks) const; @@ -176,7 +177,6 @@ protected: virtual UINT32 execute_default_irq_vector() const; // optional operation overrides - virtual bool interface_process_token(UINT32 entrytype, const machine_config_token *&tokens); virtual bool interface_validity_check(const game_driver &driver) const; bool m_disabled; @@ -184,7 +184,7 @@ protected: int m_vblank_interrupts_per_frame; // usually 1 const char * m_vblank_interrupt_screen; // the screen that causes the VBLANK interrupt device_interrupt_func m_timed_interrupt; // for interrupts not tied to VBLANK - UINT64 m_timed_interrupt_period; // period for periodic interrupts + attotime m_timed_interrupt_period; // period for periodic interrupts }; diff --git a/src/emu/dimemory.c b/src/emu/dimemory.c index 79d22a81a0b..d522ab3abcd 100644 --- a/src/emu/dimemory.c +++ b/src/emu/dimemory.c @@ -144,26 +144,18 @@ const address_space_config *device_config_memory_interface::memory_space_config( //------------------------------------------------- -// interface_process_token - token processing for -// the memory interface +// static_set_vblank_int - configuration helper +// to set up VBLANK interrupts on the device //------------------------------------------------- -bool device_config_memory_interface::interface_process_token(UINT32 entrytype, const machine_config_token *&tokens) +void device_config_memory_interface::static_set_addrmap(device_config *device, int spacenum, address_map_constructor map) { - UINT32 data32; - - switch (entrytype) - { - // specify device address map - case MCONFIG_TOKEN_DIMEMORY_MAP: - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, data32, 8); - assert(data32 < ARRAY_LENGTH(m_address_map)); - m_address_map[data32] = TOKEN_GET_PTR(tokens, addrmap); - return true; - } - - return false; + device_config_memory_interface *memory = dynamic_cast(device); + if (memory == NULL) + throw emu_fatalerror("MDRV_DEVICE_ADDRESS_MAP called on device '%s' with no memory interface", device->tag()); + if (spacenum >= ARRAY_LENGTH(memory->m_address_map)) + throw emu_fatalerror("MDRV_DEVICE_ADDRESS_MAP called with out-of-range space number %d", device->tag(), spacenum); + memory->m_address_map[spacenum] = map; } diff --git a/src/emu/dimemory.h b/src/emu/dimemory.h index 88aab52b8c3..362c86c1497 100644 --- a/src/emu/dimemory.h +++ b/src/emu/dimemory.h @@ -82,8 +82,7 @@ const int TRANSLATE_FETCH_DEBUG = (TRANSLATE_FETCH | TRANSLATE_DEBUG_MASK); //************************************************************************** #define MDRV_DEVICE_ADDRESS_MAP(_space, _map) \ - TOKEN_UINT32_PACK2(MCONFIG_TOKEN_DIMEMORY_MAP, 8, _space, 8), \ - TOKEN_PTR(addrmap, (address_map_constructor)ADDRESS_MAP_NAME(_map)), + device_config_memory_interface::static_set_addrmap(device, _space, ADDRESS_MAP_NAME(_map)); #define MDRV_DEVICE_PROGRAM_MAP(_map) \ MDRV_DEVICE_ADDRESS_MAP(AS_PROGRAM, _map) @@ -116,12 +115,14 @@ public: address_map_constructor address_map(int spacenum = 0) const { return (spacenum < ARRAY_LENGTH(m_address_map)) ? m_address_map[spacenum] : NULL; } const address_space_config *space_config(int spacenum = 0) const { return memory_space_config(spacenum); } + // static inline helpers + static void static_set_addrmap(device_config *device, int spacenum, address_map_constructor map); + protected: // required overrides virtual const address_space_config *memory_space_config(int spacenum) const = 0; // optional operation overrides - virtual bool interface_process_token(UINT32 entrytype, const machine_config_token *&tokens); virtual bool interface_validity_check(const game_driver &driver) const; address_map_constructor m_address_map[ADDRESS_SPACES]; // address maps for each address space diff --git a/src/emu/disound.c b/src/emu/disound.c index fefe0953191..2a0abf16810 100644 --- a/src/emu/disound.c +++ b/src/emu/disound.c @@ -68,41 +68,34 @@ device_config_sound_interface::~device_config_sound_interface() //------------------------------------------------- -// interface_process_token - token processing for -// the sound interface +// static_add_route - configuration helper to add +// a new route to the device //------------------------------------------------- -bool device_config_sound_interface::interface_process_token(UINT32 entrytype, const machine_config_token *&tokens) +void device_config_sound_interface::static_add_route(device_config *device, UINT32 output, const char *target, double gain, UINT32 input) { - switch (entrytype) - { - // custom config 1 is a new route - case MCONFIG_TOKEN_DISOUND_ROUTE: - { - // put back the token that was originally fetched so we can grab a packed 64-bit token - TOKEN_UNGET_UINT32(tokens); + device_config_sound_interface *sound = dynamic_cast(device); + if (sound == NULL) + throw emu_fatalerror("MDRV_SOUND_ROUTE called on device '%s' with no sound interface", device->tag()); - // extract data - int output, input; - UINT32 gain; - TOKEN_GET_UINT64_UNPACK4(tokens, entrytype, 8, output, 12, input, 12, gain, 32); - float fgain = (float)gain * (1.0f / (float)(1 << 24)); - const char *target = TOKEN_GET_STRING(tokens); + sound_route **routeptr; + for (routeptr = &sound->m_route_list; *routeptr != NULL; routeptr = &(*routeptr)->m_next) ; + *routeptr = global_alloc(sound_route(output, input, gain, target)); +} - // allocate a new route - sound_route **routeptr; - for (routeptr = &m_route_list; *routeptr != NULL; routeptr = &(*routeptr)->m_next) ; - *routeptr = global_alloc(sound_route(output, input, fgain, target)); - return true; - } - // custom config 2 resets the sound routes - case MCONFIG_TOKEN_DISOUND_RESET: - reset_routes(); - return true; - } +//------------------------------------------------- +// static_reset_routes - configuration helper to +// reset all existing routes to the device +//------------------------------------------------- - return false; +void device_config_sound_interface::static_reset_routes(device_config *device) +{ + device_config_sound_interface *sound = dynamic_cast(device); + if (sound == NULL) + throw emu_fatalerror("MDRV_SOUND_ROUTES_RESET called on device '%s' with no sound interface", device->tag()); + + sound->reset_routes(); } diff --git a/src/emu/disound.h b/src/emu/disound.h index b14cc7fcd7c..04a4df62466 100644 --- a/src/emu/disound.h +++ b/src/emu/disound.h @@ -76,14 +76,13 @@ const int ALL_OUTPUTS = MAX_OUTPUTS; // special value indicating all outputs fo MDRV_DEVICE_CONFIG(_config) #define MDRV_SOUND_ROUTE_EX(_output, _target, _gain, _input) \ - TOKEN_UINT64_PACK4(MCONFIG_TOKEN_DISOUND_ROUTE, 8, _output, 12, _input, 12, ((float)(_gain) * (float)(1 << 24)), 32), \ - TOKEN_PTR(stringptr, _target), + device_config_sound_interface::static_add_route(device, _output, _target, _gain, _input); \ #define MDRV_SOUND_ROUTE(_output, _target, _gain) \ MDRV_SOUND_ROUTE_EX(_output, _target, _gain, 0) #define MDRV_SOUND_ROUTES_RESET() \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DISOUND_RESET, 8), + device_config_sound_interface::static_reset_routes(device); \ @@ -118,9 +117,12 @@ public: sound_route * m_route_list; // list of sound routes + // static inline helpers + static void static_add_route(device_config *device, UINT32 output, const char *target, double gain, UINT32 input = 0); + static void static_reset_routes(device_config *device); + protected: // optional operation overrides - virtual bool interface_process_token(UINT32 entrytype, const machine_config_token *&tokens); virtual bool interface_validity_check(const game_driver &driver) const; void reset_routes(); diff --git a/src/emu/driver.h b/src/emu/driver.h index 4dea59a728f..8c56d8ae0d2 100644 --- a/src/emu/driver.h +++ b/src/emu/driver.h @@ -67,7 +67,7 @@ struct game_driver const char * description; /* full name of the game */ const char * year; /* year the game was released */ const char * manufacturer; /* manufacturer of the game */ - const machine_config_token *machine_config; /* machine driver tokens */ + machine_config_constructor machine_config; /* machine driver tokens */ const input_port_token *ipt; /* pointer to array of input port tokens */ void (*driver_init)(running_machine *machine); /* DRIVER_INIT callback */ const rom_entry * rom; /* pointer to list of ROMs for the game */ diff --git a/src/emu/emu.h b/src/emu/emu.h index 4330ffaf2ae..1ad1eb7e272 100644 --- a/src/emu/emu.h +++ b/src/emu/emu.h @@ -69,6 +69,12 @@ #include "memory.h" #include "addrmap.h" +// define machine_config_constructor here due to circular dependency +// between devices and the machine config +class machine_config; +class device_config; +typedef void (*machine_config_constructor)(machine_config &config, device_config *owner); + // devices and callbacks #include "devintrf.h" #include "devcb.h" diff --git a/src/emu/image.c b/src/emu/image.c index 0743f7250de..e8c28d01ee3 100644 --- a/src/emu/image.c +++ b/src/emu/image.c @@ -517,10 +517,10 @@ void image_add_device_with_subdevices(device_t *owner, device_type type, const c device_config *devconfig = type(*config, owner->subtag(tempstring,tag), &owner->baseconfig(), clock); running_device *device = device_list->append(devconfig->tag(), devconfig->alloc_device(*owner->machine)); - const machine_config_token *tokens = device->machine_config_tokens(); - if (tokens != NULL) + machine_config_constructor machconfig = device->machine_config_additions(); + if (machconfig != NULL) { - config->detokenize(tokens,devconfig); + (*machconfig)(*config, devconfig); for (const device_config *config_dev = config->m_devicelist.first(); config_dev != NULL; config_dev = config_dev->next()) { if (config_dev->owner()==devconfig) { diff --git a/src/emu/machine/7474.c b/src/emu/machine/7474.c index 415cdcb5c12..3e231e17a5a 100644 --- a/src/emu/machine/7474.c +++ b/src/emu/machine/7474.c @@ -75,30 +75,52 @@ device_t *ttl7474_device_config::alloc_device(running_machine &machine) const } - //------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete +// static_set_target_tag - configuration helper +// to set the target tag //------------------------------------------------- -void ttl7474_device_config::device_config_complete() +void ttl7474_device_config::static_set_target_tag(device_config *device, const char *tag) { - m_target_tag = reinterpret_cast(m_inline_data[INLINE_TARGET_TAG]); - m_base_output_cb = reinterpret_cast(m_inline_data[INLINE_OUTPUT_CB]); - m_base_comp_output_cb = reinterpret_cast(m_inline_data[INLINE_COMP_OUTPUT_CB]); + ttl7474_device_config *ttl7474 = downcast(device); + ttl7474->m_output_cb.tag = tag; + ttl7474->m_comp_output_cb.tag = tag; +} - m_output_cb.type = DEVCB_TYPE_DEVICE; - m_output_cb.tag = m_target_tag; - m_output_cb.writeline = m_base_output_cb; - m_output_cb.writedevice = NULL; - m_output_cb.writespace = NULL; - m_comp_output_cb.type = DEVCB_TYPE_DEVICE; - m_comp_output_cb.tag = m_target_tag; - m_comp_output_cb.writeline = m_base_comp_output_cb; - m_comp_output_cb.writedevice = NULL; - m_comp_output_cb.writespace = NULL; +//------------------------------------------------- +// static_set_output_cb - configuration helper +// to set the output callback +//------------------------------------------------- + +void ttl7474_device_config::static_set_output_cb(device_config *device, write_line_device_func callback) +{ + ttl7474_device_config *ttl7474 = downcast(device); + if (callback != NULL) + { + ttl7474->m_output_cb.type = DEVCB_TYPE_DEVICE; + ttl7474->m_output_cb.writeline = callback; + } + else + ttl7474->m_output_cb.type = DEVCB_TYPE_NULL; +} + + +//------------------------------------------------- +// static_set_comp_output_cb - configuration +// helper to set the comp. output callback +//------------------------------------------------- + +void ttl7474_device_config::static_set_comp_output_cb(device_config *device, write_line_device_func callback) +{ + ttl7474_device_config *ttl7474 = downcast(device); + if (callback != NULL) + { + ttl7474->m_comp_output_cb.type = DEVCB_TYPE_DEVICE; + ttl7474->m_comp_output_cb.writeline = callback; + } + else + ttl7474->m_comp_output_cb.type = DEVCB_TYPE_NULL; } diff --git a/src/emu/machine/7474.h b/src/emu/machine/7474.h index 1d34c794ec7..405bc65d35e 100644 --- a/src/emu/machine/7474.h +++ b/src/emu/machine/7474.h @@ -63,13 +63,13 @@ MDRV_7474_COMP_OUTPUT_CB(_comp_output_cb) #define MDRV_7474_TARGET_TAG(_target_tag) \ - MDRV_DEVICE_INLINE_DATAPTR(ttl7474_device_config::INLINE_TARGET_TAG, _target_tag) + ttl7474_device_config::static_set_target_tag(device, _target_tag); \ #define MDRV_7474_OUTPUT_CB(_cb) \ - MDRV_DEVICE_INLINE_DATAPTR(ttl7474_device_config::INLINE_OUTPUT_CB, _cb) + ttl7474_device_config::static_set_output_cb(device, _cb); \ #define MDRV_7474_COMP_OUTPUT_CB(_cb) \ - MDRV_DEVICE_INLINE_DATAPTR(ttl7474_device_config::INLINE_COMP_OUTPUT_CB, _cb) + ttl7474_device_config::static_set_comp_output_cb(device, _cb); \ @@ -91,23 +91,13 @@ public: static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); virtual device_t *alloc_device(running_machine &machine) const; - // inline configuration indexes go here - enum - { - INLINE_TARGET_TAG, - INLINE_OUTPUT_CB, - INLINE_COMP_OUTPUT_CB - }; + // inline configuration helpers + static void static_set_target_tag(device_config *device, const char *tag); + static void static_set_output_cb(device_config *device, write_line_device_func callback); + static void static_set_comp_output_cb(device_config *device, write_line_device_func callback); protected: - // device_config overrides - virtual void device_config_complete(); - // internal state goes here - const char *m_target_tag; - void (*m_base_output_cb)(device_t *device, INT32); - void (*m_base_comp_output_cb)(device_t *device, INT32); - devcb_write_line m_output_cb; devcb_write_line m_comp_output_cb; }; diff --git a/src/emu/machine/eeprom.c b/src/emu/machine/eeprom.c index 409b8773a5e..ea5a692ec8f 100644 --- a/src/emu/machine/eeprom.c +++ b/src/emu/machine/eeprom.c @@ -107,28 +107,55 @@ device_t *eeprom_device_config::alloc_device(running_machine &machine) const //------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete +// static_set_interface - configuration helper +// to set the interface //------------------------------------------------- -void eeprom_device_config::device_config_complete() +void eeprom_device_config::static_set_interface(device_config *device, const eeprom_interface &interface) { - // extract inline configuration from raw data - const eeprom_interface *intf = reinterpret_cast(m_inline_data[INLINE_INTERFACE]); - m_default_data = reinterpret_cast(m_inline_data[INLINE_DATAPTR]); - m_default_data_size = m_inline_data[INLINE_DATASIZE]; - m_default_value = m_inline_data[INLINE_DEFVALUE]; + eeprom_device_config *eeprom = downcast(device); + *static_cast(eeprom) = interface; - // inherit a copy of the static data - if (intf != NULL) - *static_cast(this) = *intf; - - // now describe our address space - if (m_data_bits == 8) - m_space_config = address_space_config("eeprom", ENDIANNESS_BIG, 8, m_address_bits, 0, *ADDRESS_MAP_NAME(eeprom_map8)); + // describe our address space + if (eeprom->m_data_bits == 8) + eeprom->m_space_config = address_space_config("eeprom", ENDIANNESS_BIG, 8, eeprom->m_address_bits, 0, *ADDRESS_MAP_NAME(eeprom_map8)); else - m_space_config = address_space_config("eeprom", ENDIANNESS_BIG, 16, m_address_bits * 2, 0, *ADDRESS_MAP_NAME(eeprom_map16)); + eeprom->m_space_config = address_space_config("eeprom", ENDIANNESS_BIG, 16, eeprom->m_address_bits * 2, 0, *ADDRESS_MAP_NAME(eeprom_map16)); +} + + +//------------------------------------------------- +// static_set_default_data - configuration helpers +// to set the default data +//------------------------------------------------- + +void eeprom_device_config::static_set_default_data(device_config *device, const UINT8 *data, UINT32 size) +{ + eeprom_device_config *eeprom = downcast(device); +if (eeprom->m_data_bits != 8) mame_printf_warning("16-bit EEPROM set with 8-bit data\n"); +// assert(eeprom->m_data_bits == 8); + eeprom->m_default_data = data; + eeprom->m_default_data_size = size; +} + +void eeprom_device_config::static_set_default_data(device_config *device, const UINT16 *data, UINT32 size) +{ + eeprom_device_config *eeprom = downcast(device); +if (eeprom->m_data_bits != 16) mame_printf_warning("8-bit EEPROM set with 16-bit data\n"); +// assert(eeprom->m_data_bits == 16); + eeprom->m_default_data = reinterpret_cast(data); + eeprom->m_default_data_size = size; +} + + +//------------------------------------------------- +// static_set_default_value - configuration helper +// to set the default value +//------------------------------------------------- + +void eeprom_device_config::static_set_default_value(device_config *device, UINT16 value) +{ + downcast(device)->m_default_value = 0x10000 | value; } @@ -141,12 +168,7 @@ bool eeprom_device_config::device_validity_check(const game_driver &driver) cons { bool error = false; - if (m_inline_data[INLINE_INTERFACE] == 0) - { - mame_printf_error("%s: %s eeprom device '%s' did not specify an interface\n", driver.source_file, driver.name, tag()); - error = true; - } - else if (m_data_bits != 8 && m_data_bits != 16) + if (m_data_bits != 8 && m_data_bits != 16) { mame_printf_error("%s: %s eeprom device '%s' specified invalid data width %d\n", driver.source_file, driver.name, tag(), m_data_bits); error = true; diff --git a/src/emu/machine/eeprom.h b/src/emu/machine/eeprom.h index 41efe5ffa44..74e85c608ad 100644 --- a/src/emu/machine/eeprom.h +++ b/src/emu/machine/eeprom.h @@ -19,7 +19,7 @@ #define MDRV_EEPROM_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, EEPROM, 0) \ - MDRV_DEVICE_INLINE_DATAPTR(eeprom_device_config::INLINE_INTERFACE, &_interface) + eeprom_device_config::static_set_interface(device, _interface); \ #define MDRV_EEPROM_93C46_ADD(_tag) \ MDRV_EEPROM_ADD(_tag, eeprom_interface_93C46) @@ -28,11 +28,10 @@ MDRV_EEPROM_ADD(_tag, eeprom_interface_93C66B) #define MDRV_EEPROM_DATA(_data, _size) \ - MDRV_DEVICE_INLINE_DATAPTR(eeprom_device_config::INLINE_DATAPTR, &_data) \ - MDRV_DEVICE_INLINE_DATA16(eeprom_device_config::INLINE_DATASIZE, _size) + eeprom_device_config::static_set_default_data(device, _data, _size); \ #define MDRV_EEPROM_DEFAULT_VALUE(_value) \ - MDRV_DEVICE_INLINE_DATA32(eeprom_device_config::INLINE_DEFVALUE, 0x10000 | ((_value) & 0xffff)) + eeprom_device_config::static_set_default_value(device, _value); \ @@ -76,28 +75,26 @@ public: static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); virtual device_t *alloc_device(running_machine &machine) const; - // inline configuration indexes - enum - { - INLINE_INTERFACE, - INLINE_DATAPTR, - INLINE_DATASIZE, - INLINE_DEFVALUE - }; + // inline configuration helpers + static void static_set_interface(device_config *deviec, const eeprom_interface &interface); + static void static_set_default_data(device_config *device, const UINT8 *data, UINT32 size); + static void static_set_default_data(device_config *device, const UINT16 *data, UINT32 size); + static void static_set_default_value(device_config *device, UINT16 value); protected: // device_config overrides - virtual void device_config_complete(); virtual bool device_validity_check(const game_driver &driver) const; // device_config_memory_interface overrides virtual const address_space_config *memory_space_config(int spacenum = 0) const; // device-specific configuration + address_space_config m_space_config; + + // internal state const UINT8 * m_default_data; int m_default_data_size; UINT32 m_default_value; - address_space_config m_space_config; }; diff --git a/src/emu/machine/i2cmem.c b/src/emu/machine/i2cmem.c index 12559810206..94efd738d1b 100644 --- a/src/emu/machine/i2cmem.c +++ b/src/emu/machine/i2cmem.c @@ -109,6 +109,18 @@ device_t *i2cmem_device_config::alloc_device( running_machine &machine ) const } +//------------------------------------------------- +// static_set_interface - set the device +// configuration +//------------------------------------------------- + +void i2cmem_device_config::static_set_interface(device_config *device, const i2cmem_interface &interface) +{ + i2cmem_device_config *i2cmem = downcast(device); + *static_cast(i2cmem) = interface; +} + + //------------------------------------------------- // device_config_complete - perform any // operations now that the configuration is @@ -117,15 +129,6 @@ device_t *i2cmem_device_config::alloc_device( running_machine &machine ) const void i2cmem_device_config::device_config_complete() { - // extract inline configuration from raw data - const i2cmem_interface *intf = reinterpret_cast( m_inline_data[ INLINE_INTERFACE ] ); - - // inherit a copy of the static data - if( intf != NULL ) - { - *static_cast(this) = *intf; - } - m_space_config = address_space_config( "i2cmem", ENDIANNESS_BIG, 8, m_address_bits, 0, *ADDRESS_MAP_NAME( i2cmem_map8 ) ); } @@ -138,13 +141,6 @@ void i2cmem_device_config::device_config_complete() bool i2cmem_device_config::device_validity_check( const game_driver &driver ) const { bool error = false; - - if( m_inline_data[ INLINE_INTERFACE ] == 0 ) - { - mame_printf_error( "%s: %s i2cmem device '%s' did not specify an interface\n", driver.source_file, driver.name, tag() ); - error = true; - } - return error; } diff --git a/src/emu/machine/i2cmem.h b/src/emu/machine/i2cmem.h index 10b92edd55b..d73a54f24b7 100644 --- a/src/emu/machine/i2cmem.h +++ b/src/emu/machine/i2cmem.h @@ -26,7 +26,7 @@ #define MDRV_I2CMEM_ADD( _tag, _interface ) \ MDRV_DEVICE_ADD( _tag, I2CMEM, 0 ) \ - MDRV_DEVICE_INLINE_DATAPTR( i2cmem_device_config::INLINE_INTERFACE, &_interface ) + i2cmem_device_config::static_set_interface(device, _interface); //************************************************************************** @@ -61,11 +61,8 @@ public: static device_config *static_alloc_device_config( const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock ); virtual device_t *alloc_device( running_machine &machine ) const; - // inline configuration indexes - enum - { - INLINE_INTERFACE - }; + // inline configuration + static void static_set_interface(device_config *device, const i2cmem_interface &interface); protected: // device_config overrides diff --git a/src/emu/machine/ldcore.h b/src/emu/machine/ldcore.h index 12bbc6cb589..3409cc0571c 100644 --- a/src/emu/machine/ldcore.h +++ b/src/emu/machine/ldcore.h @@ -148,7 +148,7 @@ struct _ldplayer_interface size_t statesize; /* size of the state */ const char * name; /* name of the player */ const rom_entry * romregion; /* pointer to ROM region information */ - const machine_config_token *machine_config; /* pointer to machine configuration */ + machine_config_constructor machine_config; /* pointer to machine configuration */ laserdisc_init_func init; /* initialization callback */ laserdisc_vsync_func vsync; /* vsync begin callback */ laserdisc_update_func update; /* update callback (line 16) */ diff --git a/src/emu/mconfig.c b/src/emu/mconfig.c index 0e10d39cbda..5d0ad0b3f80 100644 --- a/src/emu/mconfig.c +++ b/src/emu/mconfig.c @@ -49,7 +49,7 @@ // machine_config - constructor //------------------------------------------------- -machine_config::machine_config(const machine_config_token *tokens) +machine_config::machine_config(machine_config_constructor constructor) : m_driver_data_alloc(NULL), m_minimum_quantum(attotime_zero), m_perfect_cpu_quantum(NULL), @@ -72,8 +72,25 @@ machine_config::machine_config(const machine_config_token *tokens) m_sound_reset(NULL), m_parse_level(0) { - // parse tokens into the config - detokenize(tokens); + // construct the config + (*constructor)(*this, NULL); + + // process any device-specific machine configurations + for (device_config *devconfig = m_devicelist.first(); devconfig != NULL; devconfig = devconfig->next()) + if (!devconfig->m_config_complete) + { + machine_config_constructor additions = devconfig->machine_config_additions(); + if (additions != NULL) + (*additions)(*this, devconfig); + } + + // then notify all devices that their configuration is complete + for (device_config *devconfig = m_devicelist.first(); devconfig != NULL; devconfig = devconfig->next()) + if (!devconfig->m_config_complete) + { + devconfig->config_complete(); + devconfig->m_config_complete = true; + } } @@ -87,219 +104,56 @@ machine_config::~machine_config() //------------------------------------------------- -// detokenize - detokenize a machine config +// device_add - configuration helper to add a +// new device //------------------------------------------------- -void machine_config::detokenize(const machine_config_token *tokens, const device_config *owner) +device_config *machine_config::device_add(device_config *owner, const char *tag, device_type type, UINT32 clock) { - device_config *device = NULL; astring tempstring; - - // increase the parse level - m_parse_level++; - - // loop over tokens until we hit the end - UINT32 entrytype = MCONFIG_TOKEN_INVALID; - while (entrytype != MCONFIG_TOKEN_END) - { - device_type devtype; - const char *tag; - UINT64 data64; - UINT32 clock; - - // unpack the token from the first entry - TOKEN_GET_UINT32_UNPACK1(tokens, entrytype, 8); - switch (entrytype) - { - // end - case MCONFIG_TOKEN_END: - break; - - // including - case MCONFIG_TOKEN_INCLUDE: - detokenize(TOKEN_GET_PTR(tokens, tokenptr), owner); - break; - - // device management - case MCONFIG_TOKEN_DEVICE_ADD: - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, clock, 32); - devtype = TOKEN_GET_PTR(tokens, devtype); - tag = owner->subtag(tempstring, TOKEN_GET_STRING(tokens)); - device = m_devicelist.append(tag, (*devtype)(*this, tag, owner, clock)); - break; - - case MCONFIG_TOKEN_DEVICE_REPLACE: - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, clock, 32); - devtype = TOKEN_GET_PTR(tokens, devtype); - tag = owner->subtag(tempstring, TOKEN_GET_STRING(tokens)); - device = m_devicelist.replace(tag, (*devtype)(*this, tag, owner, clock)); - break; - - case MCONFIG_TOKEN_DEVICE_REMOVE: - tag = TOKEN_GET_STRING(tokens); - m_devicelist.remove(owner->subtag(tempstring, tag)); - device = NULL; - break; - - case MCONFIG_TOKEN_DEVICE_MODIFY: - tag = TOKEN_GET_STRING(tokens); - device = m_devicelist.find(owner->subtag(tempstring, tag).cstr()); - if (device == NULL) - fatalerror("Unable to find device: tag=%s\n", tempstring.cstr()); - break; - - case MCONFIG_TOKEN_DEVICE_CLOCK: - case MCONFIG_TOKEN_DEVICE_CONFIG: - case MCONFIG_TOKEN_DEVICE_INLINE_DATA16: - case MCONFIG_TOKEN_DEVICE_INLINE_DATA32: - case MCONFIG_TOKEN_DEVICE_INLINE_DATA64: - - case MCONFIG_TOKEN_DIEXEC_DISABLE: - case MCONFIG_TOKEN_DIEXEC_VBLANK_INT: - case MCONFIG_TOKEN_DIEXEC_PERIODIC_INT: - - case MCONFIG_TOKEN_DIMEMORY_MAP: - - case MCONFIG_TOKEN_DISOUND_ROUTE: - case MCONFIG_TOKEN_DISOUND_RESET: - - case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_1: - case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_2: - case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_3: - case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_4: - case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_5: - case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_6: - case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_7: - case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_8: - case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_9: - case MCONFIG_TOKEN_DEVICE_CONFIG_DATA32: - case MCONFIG_TOKEN_DEVICE_CONFIG_DATA64: - case MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP32: - case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_FREE: - assert(device != NULL); - device->process_token(entrytype, tokens); - break; - - - // core parameters - case MCONFIG_TOKEN_DRIVER_DATA: - m_driver_data_alloc = TOKEN_GET_PTR(tokens, driver_data_alloc); - break; - - case MCONFIG_TOKEN_QUANTUM_TIME: - TOKEN_EXTRACT_UINT64(tokens, data64); - m_minimum_quantum = UINT64_ATTOTIME_TO_ATTOTIME(data64); - break; - - case MCONFIG_TOKEN_QUANTUM_PERFECT_CPU: - m_perfect_cpu_quantum = TOKEN_GET_STRING(tokens); - break; - - case MCONFIG_TOKEN_WATCHDOG_VBLANK: - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, m_watchdog_vblank_count, 24); - break; - - case MCONFIG_TOKEN_WATCHDOG_TIME: - TOKEN_EXTRACT_UINT64(tokens, data64); - m_watchdog_time = UINT64_ATTOTIME_TO_ATTOTIME(data64); - break; - - // core functions - case MCONFIG_TOKEN_MACHINE_START: - m_machine_start = TOKEN_GET_PTR(tokens, machine_start); - break; - - case MCONFIG_TOKEN_MACHINE_RESET: - m_machine_reset = TOKEN_GET_PTR(tokens, machine_reset); - break; - - case MCONFIG_TOKEN_NVRAM_HANDLER: - m_nvram_handler = TOKEN_GET_PTR(tokens, nvram_handler); - break; - - case MCONFIG_TOKEN_MEMCARD_HANDLER: - m_memcard_handler = TOKEN_GET_PTR(tokens, memcard_handler); - break; - - // core video parameters - case MCONFIG_TOKEN_VIDEO_ATTRIBUTES: - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, m_video_attributes, 24); - break; - - case MCONFIG_TOKEN_GFXDECODE: - m_gfxdecodeinfo = TOKEN_GET_PTR(tokens, gfxdecode); - break; - - case MCONFIG_TOKEN_PALETTE_LENGTH: - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, m_total_colors, 24); - break; - - case MCONFIG_TOKEN_DEFAULT_LAYOUT: - m_default_layout = TOKEN_GET_STRING(tokens); - break; - - // core video functions - case MCONFIG_TOKEN_PALETTE_INIT: - m_init_palette = TOKEN_GET_PTR(tokens, palette_init); - break; - - case MCONFIG_TOKEN_VIDEO_START: - m_video_start = TOKEN_GET_PTR(tokens, video_start); - break; - - case MCONFIG_TOKEN_VIDEO_RESET: - m_video_reset = TOKEN_GET_PTR(tokens, video_reset); - break; - - case MCONFIG_TOKEN_VIDEO_EOF: - m_video_eof = TOKEN_GET_PTR(tokens, video_eof); - break; - - case MCONFIG_TOKEN_VIDEO_UPDATE: - m_video_update = TOKEN_GET_PTR(tokens, video_update); - break; - - // core sound functions - case MCONFIG_TOKEN_SOUND_START: - m_sound_start = TOKEN_GET_PTR(tokens, sound_start); - break; - - case MCONFIG_TOKEN_SOUND_RESET: - m_sound_reset = TOKEN_GET_PTR(tokens, sound_reset); - break; - - default: - fatalerror("Invalid token %d in machine config\n", entrytype); - break; - } - } - - // if we started at parse level 0 (and are thus at level 1), do post-processing - if (m_parse_level == 1) - { - // process any device-specific machine configurations - for (const device_config *devconfig = m_devicelist.first(); devconfig != NULL; devconfig = devconfig->next()) - if (!devconfig->m_config_complete) - { - tokens = devconfig->machine_config_tokens(); - if (tokens != NULL) - detokenize(tokens, devconfig); - } - - // then notify all devices that their configuration is complete - for (device_config *devconfig = m_devicelist.first(); devconfig != NULL; devconfig = devconfig->next()) - if (!devconfig->m_config_complete) - { - devconfig->config_complete(); - devconfig->m_config_complete = true; - } - } - - // bump down the parse level - m_parse_level--; + const char *fulltag = owner->subtag(tempstring, tag); + return m_devicelist.append(fulltag, (*type)(*this, fulltag, owner, clock)); +} + + +//------------------------------------------------- +// device_replace - configuration helper to +// replace one device with a new device +//------------------------------------------------- + +device_config *machine_config::device_replace(device_config *owner, const char *tag, device_type type, UINT32 clock) +{ + astring tempstring; + const char *fulltag = owner->subtag(tempstring, tag); + return m_devicelist.replace(fulltag, (*type)(*this, fulltag, owner, clock)); +} + + +//------------------------------------------------- +// device_remove - configuration helper to +// remove a device +//------------------------------------------------- + +device_config *machine_config::device_remove(device_config *owner, const char *tag) +{ + astring tempstring; + const char *fulltag = owner->subtag(tempstring, tag); + m_devicelist.remove(fulltag); + return NULL; +} + + +//------------------------------------------------- +// device_find - configuration helper to +// locate a device +//------------------------------------------------- + +device_config *machine_config::device_find(device_config *owner, const char *tag) +{ + astring tempstring; + const char *fulltag = owner->subtag(tempstring, tag); + device_config *device = m_devicelist.find(fulltag); + if (device == NULL) + throw emu_fatalerror("Unable to find device: tag=%s\n", fulltag); + return device; } diff --git a/src/emu/mconfig.h b/src/emu/mconfig.h index 4180746515f..558430a8d39 100644 --- a/src/emu/mconfig.h +++ b/src/emu/mconfig.h @@ -47,6 +47,42 @@ #define __MCONFIG_H__ +//************************************************************************** +// CONSTANTS +//************************************************************************** + +// by convention, tags should all lowercase and between 2-15 characters +#define MIN_TAG_LENGTH 2 +#define MAX_TAG_LENGTH 15 + + + +// ----- flags for video_attributes ----- + +// should VIDEO_UPDATE by called at the start of VBLANK or at the end? +#define VIDEO_UPDATE_BEFORE_VBLANK 0x0000 +#define VIDEO_UPDATE_AFTER_VBLANK 0x0004 + +// indicates VIDEO_UPDATE will add container bits its +#define VIDEO_SELF_RENDER 0x0008 + +// automatically extend the palette creating a darker copy for shadows +#define VIDEO_HAS_SHADOWS 0x0010 + +// automatically extend the palette creating a brighter copy for highlights +#define VIDEO_HAS_HIGHLIGHTS 0x0020 + +// Mish 181099: See comments in video/generic.c for details +#define VIDEO_BUFFERS_SPRITERAM 0x0040 + +// force VIDEO_UPDATE to be called even for skipped frames +#define VIDEO_ALWAYS_UPDATE 0x0080 + +// calls VIDEO_UPDATE for every visible scanline, even for skipped frames +#define VIDEO_UPDATE_SCANLINE 0x0100 + + + #define NVRAM_HANDLER_NAME(name) nvram_handler_##name #define NVRAM_HANDLER(name) void NVRAM_HANDLER_NAME(name)(running_machine *machine, mame_file *file, int read_or_write) #define NVRAM_HANDLER_CALL(name) NVRAM_HANDLER_NAME(name)(machine, file, read_or_write) @@ -106,8 +142,18 @@ #define video_update_0 NULL + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// forward references +struct gfx_decode_entry; class driver_data_t; + + +// various callback functions typedef void (*nvram_handler_func)(running_machine *machine, mame_file *file, int read_or_write); typedef void (*memcard_handler_func)(running_machine *machine, mame_file *file, int action); typedef void (*machine_start_func)(running_machine *machine); @@ -118,128 +164,14 @@ typedef void (*video_start_func)(running_machine *machine); typedef void (*video_reset_func)(running_machine *machine); typedef void (*palette_init_func)(running_machine *machine, const UINT8 *color_prom); typedef void (*video_eof_func)(running_machine *machine); -typedef UINT32 (*video_update_func)(device_t *screen, bitmap_t *bitmap, const rectangle *cliprect); +typedef UINT32 (*video_update_func)(screen_device *screen, bitmap_t *bitmap, const rectangle *cliprect); typedef driver_data_t *(*driver_data_alloc_func)(running_machine &machine); -/*************************************************************************** - CONSTANTS -***************************************************************************/ - -// by convention, tags should all lowercase and between 2-15 characters -#define MIN_TAG_LENGTH 2 -#define MAX_TAG_LENGTH 15 - - -// token types -enum -{ - MCONFIG_TOKEN_INVALID, - MCONFIG_TOKEN_END, - MCONFIG_TOKEN_INCLUDE, - - MCONFIG_TOKEN_DRIVER_DATA, - MCONFIG_TOKEN_QUANTUM_TIME, - MCONFIG_TOKEN_QUANTUM_PERFECT_CPU, - MCONFIG_TOKEN_WATCHDOG_VBLANK, - MCONFIG_TOKEN_WATCHDOG_TIME, - - MCONFIG_TOKEN_MACHINE_START, - MCONFIG_TOKEN_MACHINE_RESET, - MCONFIG_TOKEN_NVRAM_HANDLER, - MCONFIG_TOKEN_MEMCARD_HANDLER, - - MCONFIG_TOKEN_VIDEO_ATTRIBUTES, - MCONFIG_TOKEN_GFXDECODE, - MCONFIG_TOKEN_PALETTE_LENGTH, - MCONFIG_TOKEN_DEFAULT_LAYOUT, - - MCONFIG_TOKEN_PALETTE_INIT, - MCONFIG_TOKEN_VIDEO_START, - MCONFIG_TOKEN_VIDEO_RESET, - MCONFIG_TOKEN_VIDEO_EOF, - MCONFIG_TOKEN_VIDEO_UPDATE, - - MCONFIG_TOKEN_SOUND_START, - MCONFIG_TOKEN_SOUND_RESET, - - MCONFIG_TOKEN_DEVICE_ADD, - MCONFIG_TOKEN_DEVICE_REPLACE, - MCONFIG_TOKEN_DEVICE_REMOVE, - MCONFIG_TOKEN_DEVICE_MODIFY, - - // device-specific tokens - MCONFIG_TOKEN_DEVICE_CLOCK, - MCONFIG_TOKEN_DEVICE_CONFIG, - MCONFIG_TOKEN_DEVICE_INLINE_DATA16, - MCONFIG_TOKEN_DEVICE_INLINE_DATA32, - MCONFIG_TOKEN_DEVICE_INLINE_DATA64, - - // execute interface-specific tokens - MCONFIG_TOKEN_DIEXEC_DISABLE, - MCONFIG_TOKEN_DIEXEC_VBLANK_INT, - MCONFIG_TOKEN_DIEXEC_PERIODIC_INT, - - // memory interface-specific tokens - MCONFIG_TOKEN_DIMEMORY_MAP, - - // sound interface-specific tokens - MCONFIG_TOKEN_DISOUND_ROUTE, - MCONFIG_TOKEN_DISOUND_RESET, - - // legacy custom tokens - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_1, - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_2, - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_3, - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_4, - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_5, - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_6, - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_7, - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_8, - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_9, - - MCONFIG_TOKEN_DEVICE_CONFIG_DATA32, - MCONFIG_TOKEN_DEVICE_CONFIG_DATA64, - MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP32, - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_FREE, -}; - - -// ----- flags for video_attributes ----- - -// should VIDEO_UPDATE by called at the start of VBLANK or at the end? -#define VIDEO_UPDATE_BEFORE_VBLANK 0x0000 -#define VIDEO_UPDATE_AFTER_VBLANK 0x0004 - -// indicates VIDEO_UPDATE will add container bits its -#define VIDEO_SELF_RENDER 0x0008 - -// automatically extend the palette creating a darker copy for shadows -#define VIDEO_HAS_SHADOWS 0x0010 - -// automatically extend the palette creating a brighter copy for highlights -#define VIDEO_HAS_HIGHLIGHTS 0x0020 - -// Mish 181099: See comments in video/generic.c for details -#define VIDEO_BUFFERS_SPRITERAM 0x0040 - -// force VIDEO_UPDATE to be called even for skipped frames -#define VIDEO_ALWAYS_UPDATE 0x0080 - -// calls VIDEO_UPDATE for every visible scanline, even for skipped frames -#define VIDEO_UPDATE_SCANLINE 0x0100 - - - -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -// forward references -struct gfx_decode_entry; - +// ======================> address_map_entry +// machine configuration definition class machine_config { DISABLE_COPYING(machine_config); @@ -247,11 +179,9 @@ class machine_config friend class running_machine; public: - machine_config(const machine_config_token *tokens); + machine_config(machine_config_constructor constructor); ~machine_config(); - void detokenize(const machine_config_token *tokens, const device_config *owner = NULL); - driver_data_alloc_func m_driver_data_alloc; // allocator for driver data attotime m_minimum_quantum; // minimum scheduling quantum @@ -281,176 +211,129 @@ public: device_config_list m_devicelist; // list of device configs + // helpers during configuration; not for general use + device_config *device_add(device_config *owner, const char *tag, device_type type, UINT32 clock); + device_config *device_replace(device_config *owner, const char *tag, device_type type, UINT32 clock); + device_config *device_remove(device_config *owner, const char *tag); + device_config *device_find(device_config *owner, const char *tag); + private: int m_parse_level; // nested parsing level }; -/*************************************************************************** - MACROS FOR BUILDING MACHINE DRIVERS -***************************************************************************/ - -// this type is used to encode machine configuration definitions -union machine_config_token -{ - TOKEN_COMMON_FIELDS - const machine_config_token *tokenptr; - const gfx_decode_entry *gfxdecode; - address_map_constructor addrmap; - device_type devtype; - nvram_handler_func nvram_handler; - memcard_handler_func memcard_handler; - machine_start_func machine_start; - machine_reset_func machine_reset; - sound_start_func sound_start; - sound_reset_func sound_reset; - video_start_func video_start; - video_reset_func video_reset; - palette_init_func palette_init; - video_eof_func video_eof; - video_update_func video_update; - device_interrupt_func cpu_interrupt; - driver_data_alloc_func driver_data_alloc; -}; - - -// helper macro for returning the size of a field within a struct; similar to offsetof() -#define structsizeof(_struct, _field) sizeof(((_struct *)NULL)->_field) - -#define DEVCONFIG_OFFSETOF(_class, _member) \ - ((FPTR)&static_cast<_class *>(reinterpret_cast(1000000))->_member - 1000000) - -#define DEVCONFIG_SIZEOF(_class, _member) \ - sizeof(reinterpret_cast<_class *>(NULL)->_member) - +//************************************************************************** +// MACHINE CONFIG MACROS +//************************************************************************** // start/end tags for the machine driver -#define MACHINE_DRIVER_NAME(_name) \ - machine_config_##_name +#define MACHINE_DRIVER_NAME(_name) construct_machine_config_##_name #define MACHINE_DRIVER_START(_name) \ - const machine_config_token MACHINE_DRIVER_NAME(_name)[] = { +void MACHINE_DRIVER_NAME(_name)(machine_config &config, device_config *owner) \ +{ \ + device_config *device = NULL; \ + const char *tag; \ + astring tempstring; \ + (void)device; \ + (void)tag; \ #define MACHINE_DRIVER_END \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_END, 8) }; +} // use this to declare external references to a machine driver #define MACHINE_DRIVER_EXTERN(_name) \ - extern const machine_config_token MACHINE_DRIVER_NAME(_name)[] + extern void MACHINE_DRIVER_NAME(_name)(machine_config &config, device_config *owner) // importing data from other machine drivers #define MDRV_IMPORT_FROM(_name) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_INCLUDE, 8), \ - TOKEN_PTR(tokenptr, MACHINE_DRIVER_NAME(_name)), + MACHINE_DRIVER_NAME(_name)(config, owner); // core parameters #define MDRV_DRIVER_DATA(_class) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DRIVER_DATA, 8), \ - TOKEN_PTR(m_driver_data_alloc, _class::alloc), + config.m_driver_data_alloc = &_class::alloc; \ #define MDRV_QUANTUM_TIME(_time) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_QUANTUM_TIME, 8), \ - TOKEN_UINT64(UINT64_ATTOTIME_IN_##_time), + config.m_minimum_quantum = ATTOTIME_IN_##_time; \ #define MDRV_QUANTUM_PERFECT_CPU(_cputag) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_QUANTUM_PERFECT_CPU, 8), \ - TOKEN_STRING(_cputag), + config.m_perfect_cpu_quantum = _cputag; \ #define MDRV_WATCHDOG_VBLANK_INIT(_count) \ - TOKEN_UINT32_PACK2(MCONFIG_TOKEN_WATCHDOG_VBLANK, 8, _count, 24), + config.m_watchdog_vblank_count = _count; \ #define MDRV_WATCHDOG_TIME_INIT(_time) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_WATCHDOG_TIME, 8), \ - TOKEN_UINT64(UINT64_ATTOTIME_IN_##_time), + config.m_watchdog_time = ATTOTIME_IN_##_time; \ // core functions #define MDRV_MACHINE_START(_func) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_MACHINE_START, 8), \ - TOKEN_PTR(machine_start, MACHINE_START_NAME(_func)), + config.m_machine_start = MACHINE_START_NAME(_func); \ #define MDRV_MACHINE_RESET(_func) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_MACHINE_RESET, 8), \ - TOKEN_PTR(machine_reset, MACHINE_RESET_NAME(_func)), + config.m_machine_reset = MACHINE_RESET_NAME(_func); \ #define MDRV_NVRAM_HANDLER(_func) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_NVRAM_HANDLER, 8), \ - TOKEN_PTR(nvram_handler, NVRAM_HANDLER_NAME(_func)), + config.m_nvram_handler = NVRAM_HANDLER_NAME(_func); \ #define MDRV_MEMCARD_HANDLER(_func) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_MEMCARD_HANDLER, 8), \ - TOKEN_PTR(memcard_handler, MEMCARD_HANDLER_NAME(_func)), + config.m_memcard_handler = MEMCARD_HANDLER_NAME(_func); \ // core video parameters #define MDRV_VIDEO_ATTRIBUTES(_flags) \ - TOKEN_UINT32_PACK2(MCONFIG_TOKEN_VIDEO_ATTRIBUTES, 8, _flags, 24), + config.m_video_attributes = _flags; \ #define MDRV_GFXDECODE(_gfx) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_GFXDECODE, 8), \ - TOKEN_PTR(gfxdecode, GFXDECODE_NAME(_gfx)), + config.m_gfxdecodeinfo = GFXDECODE_NAME(_gfx); \ #define MDRV_PALETTE_LENGTH(_length) \ - TOKEN_UINT32_PACK2(MCONFIG_TOKEN_PALETTE_LENGTH, 8, _length, 24), + config.m_total_colors = _length; \ #define MDRV_DEFAULT_LAYOUT(_layout) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEFAULT_LAYOUT, 8), \ - TOKEN_STRING(&(_layout)[0]), + config.m_default_layout = &(_layout)[0]; \ // core video functions #define MDRV_PALETTE_INIT(_func) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_PALETTE_INIT, 8), \ - TOKEN_PTR(palette_init, PALETTE_INIT_NAME(_func)), + config.m_init_palette = PALETTE_INIT_NAME(_func); \ #define MDRV_VIDEO_START(_func) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_VIDEO_START, 8), \ - TOKEN_PTR(video_start, VIDEO_START_NAME(_func)), + config.m_video_start = VIDEO_START_NAME(_func); \ #define MDRV_VIDEO_RESET(_func) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_VIDEO_RESET, 8), \ - TOKEN_PTR(video_reset, VIDEO_RESET_NAME(_func)), + config.m_video_reset = VIDEO_RESET_NAME(_func); \ #define MDRV_VIDEO_EOF(_func) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_VIDEO_EOF, 8), \ - TOKEN_PTR(video_eof, VIDEO_EOF_NAME(_func)), + config.m_video_eof = VIDEO_EOF_NAME(_func); \ #define MDRV_VIDEO_UPDATE(_func) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_VIDEO_UPDATE, 8), \ - TOKEN_PTR(video_update, VIDEO_UPDATE_NAME(_func)), + config.m_video_update = VIDEO_UPDATE_NAME(_func); \ // core sound functions #define MDRV_SOUND_START(_func) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_SOUND_START, 8), \ - TOKEN_PTR(sound_start, SOUND_START_NAME(_func)), + config.m_sound_start = SOUND_START_NAME(_func); \ #define MDRV_SOUND_RESET(_func) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_SOUND_RESET, 8), \ - TOKEN_PTR(sound_reset, SOUND_RESET_NAME(_func)), + config.m_sound_reset = SOUND_RESET_NAME(_func); \ // add/remove devices #define MDRV_DEVICE_ADD(_tag, _type, _clock) \ - TOKEN_UINT64_PACK2(MCONFIG_TOKEN_DEVICE_ADD, 8, _clock, 32), \ - TOKEN_PTR(devtype, _type), \ - TOKEN_STRING(_tag), + device = config.device_add(owner, _tag, _type, _clock); \ #define MDRV_DEVICE_REPLACE(_tag, _type, _clock) \ - TOKEN_UINT64_PACK2(MCONFIG_TOKEN_DEVICE_REPLACE, 8, _clock, 32), \ - TOKEN_PTR(devtype, _type), \ - TOKEN_STRING(_tag), + device = config.device_replace(owner, _tag, _type, _clock); \ #define MDRV_DEVICE_REMOVE(_tag) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEVICE_REMOVE, 8), \ - TOKEN_STRING(_tag), + device = config.device_remove(owner, _tag); \ #define MDRV_DEVICE_MODIFY(_tag) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEVICE_MODIFY, 8), \ - TOKEN_STRING(_tag), + device = config.device_find(owner, _tag); \ #endif /* __MCONFIG_H__ */ diff --git a/src/emu/sound.c b/src/emu/sound.c index 71657f3a048..b00b154643d 100644 --- a/src/emu/sound.c +++ b/src/emu/sound.c @@ -496,17 +496,16 @@ device_t *speaker_device_config::alloc_device(running_machine &machine) const //------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete +// static_set_position - configuration helper to +// set the speaker position //------------------------------------------------- -void speaker_device_config::device_config_complete() +void speaker_device_config::static_set_position(device_config *device, double x, double y, double z) { - // move inline data into its final home - m_x = static_cast(static_cast(m_inline_data[INLINE_X])) / (double)(1 << 24); - m_y = static_cast(static_cast(m_inline_data[INLINE_Y])) / (double)(1 << 24); - m_z = static_cast(static_cast(m_inline_data[INLINE_Z])) / (double)(1 << 24); + speaker_device_config *speaker = downcast(device); + speaker->m_x = x; + speaker->m_y = y; + speaker->m_z = z; } diff --git a/src/emu/sound.h b/src/emu/sound.h index dec01f6a4d5..b50539d7195 100644 --- a/src/emu/sound.h +++ b/src/emu/sound.h @@ -49,19 +49,11 @@ public: static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); virtual device_t *alloc_device(running_machine &machine) const; - // indexes to inline data - enum - { - INLINE_X, - INLINE_Y, - INLINE_Z - }; + // inline configuration helpers + static void static_set_position(device_config *device, double x, double y, double z); protected: - // device_config overrides - virtual void device_config_complete(); - - // internal state + // inline configuration state double m_x; double m_y; double m_z; @@ -133,9 +125,7 @@ extern const device_type SPEAKER; /* add/remove speakers */ #define MDRV_SPEAKER_ADD(_tag, _x, _y, _z) \ MDRV_DEVICE_ADD(_tag, SPEAKER, 0) \ - MDRV_DEVICE_INLINE_DATA32(speaker_device_config::INLINE_X, (INT32)((_x) * (double)(1 << 24))) \ - MDRV_DEVICE_INLINE_DATA32(speaker_device_config::INLINE_Y, (INT32)((_y) * (double)(1 << 24))) \ - MDRV_DEVICE_INLINE_DATA32(speaker_device_config::INLINE_Z, (INT32)((_z) * (double)(1 << 24))) + speaker_device_config::static_set_position(device, _x, _y, _z); \ #define MDRV_SPEAKER_STANDARD_MONO(_tag) \ MDRV_SPEAKER_ADD(_tag, 0.0, 0.0, 1.0) diff --git a/src/emu/sound/okim6295.c b/src/emu/sound/okim6295.c index 158560eafeb..024b8028afe 100644 --- a/src/emu/sound/okim6295.c +++ b/src/emu/sound/okim6295.c @@ -118,15 +118,14 @@ device_t *okim6295_device_config::alloc_device(running_machine &machine) const //------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete +// static_set_pin7 - configuration helper to set +// the pin 7 state //------------------------------------------------- -void okim6295_device_config::device_config_complete() +void okim6295_device_config::static_set_pin7(device_config *device, int pin7) { - // copy the pin7 state from inline data - m_pin7 = m_inline_data[INLINE_PIN7]; + okim6295_device_config *okim6295 = downcast(device); + okim6295->m_pin7 = pin7; } diff --git a/src/emu/sound/okim6295.h b/src/emu/sound/okim6295.h index 68d72d5822f..68d83cfdb91 100644 --- a/src/emu/sound/okim6295.h +++ b/src/emu/sound/okim6295.h @@ -40,7 +40,7 @@ enum MDRV_OKIM6295_PIN7(_pin7) #define MDRV_OKIM6295_PIN7(_pin7) \ - MDRV_DEVICE_INLINE_DATA16(okim6295_device_config::INLINE_PIN7, _pin7) + okim6295_device_config::static_set_pin7(device, _pin7); \ @@ -89,19 +89,17 @@ public: static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); virtual device_t *alloc_device(running_machine &machine) const; - // inline configuration indexes - enum - { - INLINE_PIN7 - }; + // inline configuration helpers + static void static_set_pin7(device_config *device, int pin7); protected: // device_config overrides - virtual void device_config_complete(); virtual const address_space_config *memory_space_config(int spacenum = 0) const; // internal state const address_space_config m_space_config; + + // inline data UINT8 m_pin7; }; diff --git a/src/emu/timer.c b/src/emu/timer.c index c6b35eb7370..709351a83c1 100644 --- a/src/emu/timer.c +++ b/src/emu/timer.c @@ -943,8 +943,8 @@ timer_device_config::timer_device_config(const machine_config &mconfig, const ch m_type(TIMER_TYPE_GENERIC), m_callback(NULL), m_ptr(NULL), - m_start_delay(0), - m_period(0), + m_start_delay(attotime_zero), + m_period(attotime_zero), m_param(0), m_screen(NULL), m_first_vpos(0), @@ -975,23 +975,93 @@ device_t *timer_device_config::alloc_device(running_machine &machine) const //------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete +// static_configure_generic - configuration +// helper to set up a generic timer //------------------------------------------------- -void timer_device_config::device_config_complete() +void timer_device_config::static_configure_generic(device_config *device, timer_device_fired_func callback) { - // move inline data into its final home - m_type = static_cast(m_inline_data[INLINE_TYPE]); - m_callback = reinterpret_cast(m_inline_data[INLINE_CALLBACK]); - m_ptr = reinterpret_cast(m_inline_data[INLINE_PTR]); - m_start_delay = static_cast(m_inline_data[INLINE_DELAY]); - m_period = static_cast(m_inline_data[INLINE_PERIOD]); - m_param = static_cast(m_inline_data[INLINE_PARAM]); - m_screen = reinterpret_cast(m_inline_data[INLINE_SCREEN]); - m_first_vpos = static_cast(m_inline_data[INLINE_FIRST_VPOS]); - m_increment = static_cast(m_inline_data[INLINE_INCREMENT]); + timer_device_config *timer = downcast(device); + timer->m_type = TIMER_TYPE_GENERIC; + timer->m_callback = callback; +} + + +//------------------------------------------------- +// static_configure_periodic - configuration +// helper to set up a periodic timer +//------------------------------------------------- + +void timer_device_config::static_configure_periodic(device_config *device, timer_device_fired_func callback, attotime period) +{ + timer_device_config *timer = downcast(device); + timer->m_type = TIMER_TYPE_PERIODIC; + timer->m_callback = callback; + timer->m_period = period; +} + + +//------------------------------------------------- +// static_configure_scanline - configuration +// helper to set up a scanline timer +//------------------------------------------------- + +void timer_device_config::static_configure_scanline(device_config *device, timer_device_fired_func callback, const char *screen, int first_vpos, int increment) +{ + timer_device_config *timer = downcast(device); + timer->m_type = TIMER_TYPE_SCANLINE; + timer->m_callback = callback; + timer->m_screen = screen; + timer->m_first_vpos = first_vpos; + timer->m_increment = increment; +} + + +//------------------------------------------------- +// static_set_callback - configuration helper +// to set the callback +//------------------------------------------------- + +void timer_device_config::static_set_callback(device_config *device, timer_device_fired_func callback) +{ + timer_device_config *timer = downcast(device); + timer->m_callback = callback; +} + + +//------------------------------------------------- +// static_set_start_delay - configuration helper +// to set the starting delay +//------------------------------------------------- + +void timer_device_config::static_set_start_delay(device_config *device, attotime delay) +{ + timer_device_config *timer = downcast(device); + timer->m_start_delay = delay; +} + + +//------------------------------------------------- +// static_set_param - configuration helper to set +// the integer parameter +//------------------------------------------------- + +void timer_device_config::static_set_param(device_config *device, int param) +{ + timer_device_config *timer = downcast(device); + timer->m_param = param; +} + + +//------------------------------------------------- +// static_set_ptr - configuration helper to set +// the pointer parameter +//------------------------------------------------- + +void timer_device_config::static_set_ptr(device_config *device, void *ptr) +{ + timer_device_config *timer = downcast(device); + timer->m_ptr = ptr; } @@ -1008,16 +1078,16 @@ bool timer_device_config::device_validity_check(const game_driver &driver) const switch (m_type) { case TIMER_TYPE_GENERIC: - if (m_screen != NULL || m_first_vpos != 0 || m_start_delay != 0) + if (m_screen != NULL || m_first_vpos != 0 || attotime_compare(m_start_delay, attotime_zero) != 0) mame_printf_warning("%s: %s generic timer '%s' specified parameters for a scanline timer\n", driver.source_file, driver.name, tag()); - if (m_period != 0 || m_start_delay != 0) + if (attotime_compare(m_period, attotime_zero) != 0 || attotime_compare(m_start_delay, attotime_zero) != 0) mame_printf_warning("%s: %s generic timer '%s' specified parameters for a periodic timer\n", driver.source_file, driver.name, tag()); break; case TIMER_TYPE_PERIODIC: if (m_screen != NULL || m_first_vpos != 0) mame_printf_warning("%s: %s periodic timer '%s' specified parameters for a scanline timer\n", driver.source_file, driver.name, tag()); - if (m_period <= 0) + if (attotime_compare(m_period, attotime_zero) <= 0) { mame_printf_error("%s: %s periodic timer '%s' specified invalid period\n", driver.source_file, driver.name, tag()); error = true; @@ -1025,7 +1095,7 @@ bool timer_device_config::device_validity_check(const game_driver &driver) const break; case TIMER_TYPE_SCANLINE: - if (m_period != 0 || m_start_delay != 0) + if (attotime_compare(m_period, attotime_zero) != 0 || attotime_compare(m_start_delay, attotime_zero) != 0) mame_printf_warning("%s: %s scanline timer '%s' specified parameters for a periodic timer\n", driver.source_file, driver.name, tag()); if (m_param != 0) mame_printf_warning("%s: %s scanline timer '%s' specified parameter which is ignored\n", driver.source_file, driver.name, tag()); @@ -1104,14 +1174,14 @@ void timer_device::device_reset() { // convert the period into attotime attotime period = attotime_never; - if (m_config.m_period > 0) + if (attotime_compare(m_config.m_period, attotime_zero) > 0) { - period = UINT64_ATTOTIME_TO_ATTOTIME(m_config.m_period); + period = m_config.m_period; // convert the start_delay into attotime attotime start_delay = attotime_zero; - if (m_config.m_start_delay > 0) - start_delay = UINT64_ATTOTIME_TO_ATTOTIME(m_config.m_start_delay); + if (attotime_compare(m_config.m_start_delay, attotime_zero) > 0) + start_delay = m_config.m_start_delay; // allocate and start the backing timer timer_adjust_periodic(m_timer, start_delay, m_config.m_param, period); diff --git a/src/emu/timer.h b/src/emu/timer.h index 5551e9ddcaf..0018e3e4356 100644 --- a/src/emu/timer.h +++ b/src/emu/timer.h @@ -80,37 +80,30 @@ struct timer_execution_state #define MDRV_TIMER_ADD(_tag, _callback) \ MDRV_DEVICE_ADD(_tag, TIMER, 0) \ - MDRV_DEVICE_INLINE_DATA16(timer_device_config::INLINE_TYPE, timer_device_config::TIMER_TYPE_GENERIC) \ - MDRV_DEVICE_INLINE_DATAPTR(timer_device_config::INLINE_CALLBACK, _callback) + timer_device_config::static_configure_generic(device, _callback); \ #define MDRV_TIMER_ADD_PERIODIC(_tag, _callback, _period) \ MDRV_DEVICE_ADD(_tag, TIMER, 0) \ - MDRV_DEVICE_INLINE_DATA16(timer_device_config::INLINE_TYPE, timer_device_config::TIMER_TYPE_PERIODIC) \ - MDRV_DEVICE_INLINE_DATAPTR(timer_device_config::INLINE_CALLBACK, _callback) \ - MDRV_DEVICE_INLINE_DATA64(timer_device_config::INLINE_PERIOD, UINT64_ATTOTIME_IN_##_period) + timer_device_config::static_configure_periodic(device, _callback, ATTOTIME_IN_##_period); \ #define MDRV_TIMER_ADD_SCANLINE(_tag, _callback, _screen, _first_vpos, _increment) \ MDRV_DEVICE_ADD(_tag, TIMER, 0) \ - MDRV_DEVICE_INLINE_DATA16(timer_device_config::INLINE_TYPE, timer_device_config::TIMER_TYPE_SCANLINE) \ - MDRV_DEVICE_INLINE_DATAPTR(timer_device_config::INLINE_CALLBACK, _callback) \ - MDRV_DEVICE_INLINE_DATAPTR(timer_device_config::INLINE_SCREEN, _screen) \ - MDRV_DEVICE_INLINE_DATA16(timer_device_config::INLINE_FIRST_VPOS, _first_vpos) \ - MDRV_DEVICE_INLINE_DATA16(timer_device_config::INLINE_INCREMENT, _increment) + timer_device_config::static_configure_scanline(device, _callback, _screen, _first_vpos, _increment); \ #define MDRV_TIMER_MODIFY(_tag) \ MDRV_DEVICE_MODIFY(_tag) #define MDRV_TIMER_CALLBACK(_callback) \ - MDRV_DEVICE_INLINE_DATA32(timer_device_config::INLINE_CALLBACK, _callback) + timer_device_config::static_set_callback(device, _callback); \ #define MDRV_TIMER_START_DELAY(_start_delay) \ - MDRV_DEVICE_INLINE_DATA64(timer_device_config::INLINE_DELAY, UINT64_ATTOTIME_IN_##_start_delay) + timer_device_config::static_set_start_delay(device, ATTOTIME_IN_##_start_delay); \ #define MDRV_TIMER_PARAM(_param) \ - MDRV_DEVICE_INLINE_DATA32(timer_device_config::INLINE_PARAM, _param) + timer_device_config::static_set_param(device, _param); \ #define MDRV_TIMER_PTR(_ptr) \ - MDRV_DEVICE_INLINE_DATAPTR(timer_device_config::INLINE_PTR, _ptr) + timer_device_config::static_set_ptr(device, (void *)(_ptr)); \ @@ -233,19 +226,18 @@ public: static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); virtual device_t *alloc_device(running_machine &machine) const; - // indexes to inline data - enum - { - INLINE_TYPE, - INLINE_CALLBACK, - INLINE_PERIOD, - INLINE_SCREEN, - INLINE_FIRST_VPOS, - INLINE_INCREMENT, - INLINE_DELAY, - INLINE_PARAM, - INLINE_PTR - }; + // inline configuration helpers + static void static_configure_generic(device_config *device, timer_device_fired_func callback); + static void static_configure_periodic(device_config *device, timer_device_fired_func callback, attotime period); + static void static_configure_scanline(device_config *device, timer_device_fired_func callback, const char *screen, int first_vpos, int increment); + static void static_set_callback(device_config *device, timer_device_fired_func callback); + static void static_set_start_delay(device_config *device, attotime delay); + static void static_set_param(device_config *device, int param); + static void static_set_ptr(device_config *device, void *ptr); + +private: + // device_config overrides + virtual bool device_validity_check(const game_driver &driver) const; // timer types enum timer_type @@ -255,19 +247,14 @@ public: TIMER_TYPE_GENERIC }; -private: - // device_config overrides - virtual void device_config_complete(); - virtual bool device_validity_check(const game_driver &driver) const; - // configuration data timer_type m_type; // type of timer timer_device_fired_func m_callback; // the timer's callback function void * m_ptr; // the pointer parameter passed to the timer callback // periodic timers only - UINT64 m_start_delay; // delay before the timer fires for the first time - UINT64 m_period; // period of repeated timer firings + attotime m_start_delay; // delay before the timer fires for the first time + attotime m_period; // period of repeated timer firings INT32 m_param; // the integer parameter passed to the timer callback // scanline timers only diff --git a/src/emu/video.c b/src/emu/video.c index c0050a90ff6..d27fe989c8e 100644 --- a/src/emu/video.c +++ b/src/emu/video.c @@ -1721,29 +1721,114 @@ device_t *screen_device_config::alloc_device(running_machine &machine) const //------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete +// static_set_format - configuration helper +// to set the bitmap format //------------------------------------------------- -void screen_device_config::device_config_complete() +void screen_device_config::static_set_format(device_config *device, bitmap_format format) { - // move inline data into its final home - m_type = static_cast(m_inline_data[INLINE_TYPE]); - m_width = static_cast(m_inline_data[INLINE_WIDTH]); - m_height = static_cast(m_inline_data[INLINE_HEIGHT]); - m_visarea.min_x = static_cast(m_inline_data[INLINE_VIS_MINX]); - m_visarea.min_y = static_cast(m_inline_data[INLINE_VIS_MINY]); - m_visarea.max_x = static_cast(m_inline_data[INLINE_VIS_MAXX]); - m_visarea.max_y = static_cast(m_inline_data[INLINE_VIS_MAXY]); - m_oldstyle_vblank_supplied = (m_inline_data[INLINE_OLDVBLANK] != 0); - m_refresh = m_inline_data[INLINE_REFRESH]; - m_vblank = m_inline_data[INLINE_VBLANK]; - m_format = static_cast(m_inline_data[INLINE_FORMAT]); - m_xoffset = static_cast(static_cast(m_inline_data[INLINE_XOFFSET])) / (double)(1 << 24); - m_yoffset = static_cast(static_cast(m_inline_data[INLINE_YOFFSET])) / (double)(1 << 24); - m_xscale = (m_inline_data[INLINE_XSCALE] == 0) ? 1.0 : (static_cast(static_cast(m_inline_data[INLINE_XSCALE])) / (double)(1 << 24)); - m_yscale = (m_inline_data[INLINE_YSCALE] == 0) ? 1.0 : (static_cast(static_cast(m_inline_data[INLINE_YSCALE])) / (double)(1 << 24)); + screen_device_config *screen = downcast(device); + screen->m_format = format; +} + + +//------------------------------------------------- +// static_set_type - configuration helper +// to set the screen type +//------------------------------------------------- + +void screen_device_config::static_set_type(device_config *device, screen_type_enum type) +{ + screen_device_config *screen = downcast(device); + screen->m_type = type; +} + + +//------------------------------------------------- +// static_set_raw - configuration helper +// to set the raw screen parameters +//------------------------------------------------- + +void screen_device_config::static_set_raw(device_config *device, UINT32 pixclock, UINT16 htotal, UINT16 hbend, UINT16 hbstart, UINT16 vtotal, UINT16 vbend, UINT16 vbstart) +{ + screen_device_config *screen = downcast(device); + screen->m_refresh = HZ_TO_ATTOSECONDS(pixclock) * htotal * vtotal; + screen->m_vblank = screen->m_refresh / vtotal * (vtotal - (vbstart - vbend)); + screen->m_width = htotal; + screen->m_height = vtotal; + screen->m_visarea.min_x = hbend; + screen->m_visarea.max_x = hbstart - 1; + screen->m_visarea.min_y = vbend; + screen->m_visarea.max_y = vbstart - 1; +} + + +//------------------------------------------------- +// static_set_refresh - configuration helper +// to set the refresh rate +//------------------------------------------------- + +void screen_device_config::static_set_refresh(device_config *device, attoseconds_t rate) +{ + screen_device_config *screen = downcast(device); + screen->m_refresh = rate; +} + + +//------------------------------------------------- +// static_set_vblank_time - configuration helper +// to set the VBLANK duration +//------------------------------------------------- + +void screen_device_config::static_set_vblank_time(device_config *device, attoseconds_t time) +{ + screen_device_config *screen = downcast(device); + screen->m_vblank = time; + screen->m_oldstyle_vblank_supplied = true; +} + + +//------------------------------------------------- +// static_set_size - configuration helper to set +// the width/height of the screen +//------------------------------------------------- + +void screen_device_config::static_set_size(device_config *device, UINT16 width, UINT16 height) +{ + screen_device_config *screen = downcast(device); + screen->m_width = width; + screen->m_height = height; +} + + +//------------------------------------------------- +// static_set_visarea - configuration helper to +// set the visible area of the screen +//------------------------------------------------- + +void screen_device_config::static_set_visarea(device_config *device, INT16 minx, INT16 maxx, INT16 miny, INT16 maxy) +{ + screen_device_config *screen = downcast(device); + screen->m_visarea.min_x = minx; + screen->m_visarea.max_x = maxx; + screen->m_visarea.min_y = miny; + screen->m_visarea.max_y = maxy; +} + + +//------------------------------------------------- +// static_set_default_position - configuration +// helper to set the default position and scale +// factors for the screen +//------------------------------------------------- + +void screen_device_config::static_set_default_position(device_config *device, double xscale, double xoffs, double yscale, double yoffs) +{ + screen_device_config *screen = downcast(device); + screen->m_xscale = xscale; + screen->m_xoffset = xoffs; + screen->m_yscale = yscale; + screen->m_yoffset = yoffs; } diff --git a/src/emu/video.h b/src/emu/video.h index b05c96d1e41..76a3ea92967 100644 --- a/src/emu/video.h +++ b/src/emu/video.h @@ -108,32 +108,21 @@ public: float xscale() const { return m_xscale; } float yscale() const { return m_yscale; } - // indexes to inline data - enum - { - INLINE_TYPE, - INLINE_FORMAT, - INLINE_REFRESH, - INLINE_VBLANK, - INLINE_WIDTH, - INLINE_HEIGHT, - INLINE_VIS_MINX, - INLINE_VIS_MAXX, - INLINE_VIS_MINY, - INLINE_VIS_MAXY, - INLINE_XOFFSET, - INLINE_XSCALE, - INLINE_YOFFSET, - INLINE_YSCALE, - INLINE_OLDVBLANK - }; + // inline configuration helpers + static void static_set_format(device_config *device, bitmap_format format); + static void static_set_type(device_config *device, screen_type_enum type); + static void static_set_raw(device_config *device, UINT32 pixclock, UINT16 htotal, UINT16 hbend, UINT16 hbstart, UINT16 vtotal, UINT16 vbend, UINT16 vbstart); + static void static_set_refresh(device_config *device, attoseconds_t rate); + static void static_set_vblank_time(device_config *device, attoseconds_t time); + static void static_set_size(device_config *device, UINT16 width, UINT16 height); + static void static_set_visarea(device_config *device, INT16 minx, INT16 maxx, INT16 miny, INT16 maxy); + static void static_set_default_position(device_config *device, double xscale, double xoffs, double yscale, double yoffs); private: // device_config overrides - virtual void device_config_complete(); virtual bool device_validity_check(const game_driver &driver) const; - // configuration data + // inline configuration data screen_type_enum m_type; // type of screen int m_width, m_height; // default total width/height (HTOTAL, VTOTAL) rectangle m_visarea; // default visible area (HBLANK end/start, VBLANK end/start) @@ -279,49 +268,34 @@ extern const device_type SCREEN; #define MDRV_SCREEN_ADD(_tag, _type) \ MDRV_DEVICE_ADD(_tag, SCREEN, 0) \ - MDRV_SCREEN_TYPE(_type) + MDRV_SCREEN_TYPE(_type) \ #define MDRV_SCREEN_MODIFY(_tag) \ MDRV_DEVICE_MODIFY(_tag) #define MDRV_SCREEN_FORMAT(_format) \ - MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_FORMAT, _format) + screen_device_config::static_set_format(device, _format); \ #define MDRV_SCREEN_TYPE(_type) \ - MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_TYPE, SCREEN_TYPE_##_type) + screen_device_config::static_set_type(device, SCREEN_TYPE_##_type); \ #define MDRV_SCREEN_RAW_PARAMS(_pixclock, _htotal, _hbend, _hbstart, _vtotal, _vbend, _vbstart) \ - MDRV_DEVICE_INLINE_DATA64(screen_device_config::INLINE_REFRESH, HZ_TO_ATTOSECONDS(_pixclock) * (_htotal) * (_vtotal)) \ - MDRV_DEVICE_INLINE_DATA64(screen_device_config::INLINE_VBLANK, ((HZ_TO_ATTOSECONDS(_pixclock) * (_htotal) * (_vtotal)) / (_vtotal)) * ((_vtotal) - ((_vbstart) - (_vbend)))) \ - MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_WIDTH, _htotal) \ - MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_HEIGHT, _vtotal) \ - MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_VIS_MINX, _hbend) \ - MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_VIS_MAXX, (_hbstart) - 1) \ - MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_VIS_MINY, _vbend) \ - MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_VIS_MAXY, (_vbstart) - 1) + screen_device_config::static_set_raw(device, _pixclock, _htotal, _hbend, _hbstart, _vtotal, _vbend, _vbstart); #define MDRV_SCREEN_REFRESH_RATE(_rate) \ - MDRV_DEVICE_INLINE_DATA64(screen_device_config::INLINE_REFRESH, HZ_TO_ATTOSECONDS(_rate)) + screen_device_config::static_set_refresh(device, HZ_TO_ATTOSECONDS(_rate)); \ #define MDRV_SCREEN_VBLANK_TIME(_time) \ - MDRV_DEVICE_INLINE_DATA64(screen_device_config::INLINE_VBLANK, _time) \ - MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_OLDVBLANK, true) + screen_device_config::static_set_vblank_time(device, _time); \ #define MDRV_SCREEN_SIZE(_width, _height) \ - MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_WIDTH, _width) \ - MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_HEIGHT, _height) + screen_device_config::static_set_size(device, _width, _height); \ #define MDRV_SCREEN_VISIBLE_AREA(_minx, _maxx, _miny, _maxy) \ - MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_VIS_MINX, _minx) \ - MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_VIS_MAXX, _maxx) \ - MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_VIS_MINY, _miny) \ - MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_VIS_MAXY, _maxy) + screen_device_config::static_set_visarea(device, _minx, _maxx, _miny, _maxy); \ #define MDRV_SCREEN_DEFAULT_POSITION(_xscale, _xoffs, _yscale, _yoffs) \ - MDRV_DEVICE_INLINE_DATA32(screen_device_config::INLINE_XOFFSET, (INT32)((_xoffs) * (double)(1 << 24))) \ - MDRV_DEVICE_INLINE_DATA32(screen_device_config::INLINE_XSCALE, (INT32)((_xscale) * (double)(1 << 24))) \ - MDRV_DEVICE_INLINE_DATA32(screen_device_config::INLINE_YOFFSET, (INT32)((_yoffs) * (double)(1 << 24))) \ - MDRV_DEVICE_INLINE_DATA32(screen_device_config::INLINE_YSCALE, (INT32)((_yscale) * (double)(1 << 24))) + screen_device_config::static_set_default_position(device, _xscale, _xoffs, _yscale, _yoffs); \ diff --git a/src/mame/drivers/goldstar.c b/src/mame/drivers/goldstar.c index 20aedf3f425..5cfe29c00c9 100644 --- a/src/mame/drivers/goldstar.c +++ b/src/mame/drivers/goldstar.c @@ -5855,6 +5855,7 @@ static MACHINE_DRIVER_START( cmasterc ) MACHINE_DRIVER_END +#ifdef UNUSED_CODE static MACHINE_DRIVER_START( cmnobmp ) MDRV_DRIVER_DATA(goldstar_state) @@ -5891,6 +5892,7 @@ static MACHINE_DRIVER_START( cmnobmp ) MDRV_SOUND_CONFIG(cm_ay8910_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_DRIVER_END +#endif static MACHINE_DRIVER_START( cmast91 ) diff --git a/src/mame/drivers/itgamble.c b/src/mame/drivers/itgamble.c index 4ad8685f77b..0f0dc952e3c 100644 --- a/src/mame/drivers/itgamble.c +++ b/src/mame/drivers/itgamble.c @@ -217,6 +217,7 @@ static MACHINE_DRIVER_START( mnumber ) MACHINE_DRIVER_END +#ifdef UNUSED_CODE static MACHINE_DRIVER_START( ejollyx5 ) MDRV_IMPORT_FROM(itgamble) @@ -227,6 +228,7 @@ static MACHINE_DRIVER_START( ejollyx5 ) MDRV_OKIM6295_REPLACE("oki", MNUMBER_SND_CLOCK/16, OKIM6295_PIN7_HIGH) /* clock frequency & pin 7 not verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END +#endif /************************* diff --git a/src/mame/drivers/norautp.c b/src/mame/drivers/norautp.c index c9d6d6d7d75..c9ada0190b1 100644 --- a/src/mame/drivers/norautp.c +++ b/src/mame/drivers/norautp.c @@ -848,10 +848,12 @@ static ADDRESS_MAP_START( norautx4_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x6000, 0x67ff) AM_RAM AM_BASE_SIZE_GENERIC(nvram) /* 6116 */ ADDRESS_MAP_END +#ifdef UNUSED_CODE static ADDRESS_MAP_START( norautx8_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x7fff) AM_ROM /* need to be checked */ AM_RANGE(0xc000, 0xc7ff) AM_RAM AM_BASE_SIZE_GENERIC(nvram) /* 6116 */ ADDRESS_MAP_END +#endif static ADDRESS_MAP_START( kimble_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0xbfff) AM_ROM @@ -1322,6 +1324,7 @@ static MACHINE_DRIVER_START( norautx4 ) MACHINE_DRIVER_END +#ifdef UNUSED_CODE static MACHINE_DRIVER_START( norautx8 ) MDRV_IMPORT_FROM(noraut_base) @@ -1330,6 +1333,7 @@ static MACHINE_DRIVER_START( norautx8 ) MDRV_CPU_PROGRAM_MAP(norautx8_map) MDRV_CPU_VBLANK_INT("screen", irq0_line_hold) MACHINE_DRIVER_END +#endif static MACHINE_DRIVER_START( kimble ) diff --git a/src/mame/drivers/taito_l.c b/src/mame/drivers/taito_l.c index e2e303e04f6..0dcd1541192 100644 --- a/src/mame/drivers/taito_l.c +++ b/src/mame/drivers/taito_l.c @@ -2323,6 +2323,7 @@ static MACHINE_DRIVER_START( evilston ) MDRV_TC0140SYT_ADD("tc0140syt", taitol_tc0140syt_intf) MACHINE_DRIVER_END +#ifdef UNUSED_CODE static MACHINE_DRIVER_START( lagirl ) /* basic machine hardware */ @@ -2336,6 +2337,7 @@ static MACHINE_DRIVER_START( lagirl ) MDRV_MACHINE_RESET(cachat) MACHINE_DRIVER_END +#endif ROM_START( raimais ) diff --git a/src/mame/drivers/tecmo.c b/src/mame/drivers/tecmo.c index b0e09aa0ee1..c99ef4210fc 100644 --- a/src/mame/drivers/tecmo.c +++ b/src/mame/drivers/tecmo.c @@ -736,6 +736,7 @@ static MACHINE_DRIVER_START( silkworm ) MDRV_CPU_PROGRAM_MAP(silkworm_map) MACHINE_DRIVER_END +#ifdef UNUSED_CODE static MACHINE_DRIVER_START( backfirt ) /* basic machine hardware */ @@ -772,6 +773,7 @@ static MACHINE_DRIVER_START( backfirt ) /* no MSM on this PCB */ MACHINE_DRIVER_END +#endif /*************************************************************************** diff --git a/src/mame/includes/galaxian.h b/src/mame/includes/galaxian.h index 6869a8f07c2..cc067785b00 100644 --- a/src/mame/includes/galaxian.h +++ b/src/mame/includes/galaxian.h @@ -56,7 +56,7 @@ WRITE8_HANDLER( scramble_background_blue_w ); WRITE8_HANDLER( galaxian_gfxbank_w ); -TIMER_CALLBACK( galaxian_stars_blink_timer ); +TIMER_DEVICE_CALLBACK( galaxian_stars_blink_timer ); /* video extension callbacks */ typedef void (*galaxian_extend_tile_info_func)(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x); diff --git a/src/mame/video/galaxian.c b/src/mame/video/galaxian.c index c23842acd47..f46e35a46b2 100644 --- a/src/mame/video/galaxian.c +++ b/src/mame/video/galaxian.c @@ -879,7 +879,7 @@ static void stars_update_origin(running_machine *machine) * *************************************/ -TIMER_CALLBACK( galaxian_stars_blink_timer ) +TIMER_DEVICE_CALLBACK( galaxian_stars_blink_timer ) { stars_blink_state++; } diff --git a/src/mame/video/gp9001.c b/src/mame/video/gp9001.c index 54819443087..f418714d05c 100644 --- a/src/mame/video/gp9001.c +++ b/src/mame/video/gp9001.c @@ -205,9 +205,10 @@ device_t *gp9001vdp_device_config::alloc_device(running_machine &machine) const return auto_alloc(&machine, gp9001vdp_device(machine, *this)); } -void gp9001vdp_device_config::device_config_complete() +void gp9001vdp_device_config::static_set_gfx_region(device_config *device, int gfxregion) { - m_gfxregion = m_inline_data[0]; + gp9001vdp_device_config *vdp = downcast(device); + vdp->m_gfxregion = gfxregion; } bool gp9001vdp_device_config::device_validity_check(const game_driver &driver) const diff --git a/src/mame/video/gp9001.h b/src/mame/video/gp9001.h index 9978f5e8303..6a15e00bd98 100644 --- a/src/mame/video/gp9001.h +++ b/src/mame/video/gp9001.h @@ -8,13 +8,12 @@ class gp9001vdp_device_config : public device_config, public: static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); virtual device_t *alloc_device(running_machine &machine) const; + static void static_set_gfx_region(device_config *device, int gfxregion); protected: - virtual void device_config_complete(); virtual bool device_validity_check(const game_driver &driver) const; virtual const address_space_config *memory_space_config(int spacenum = 0) const; address_space_config m_space_config; UINT8 m_gfxregion; - }; class gp9001vdp_device : public device_t, @@ -102,12 +101,12 @@ ADDRESS_MAP_EXTERN( gp9001vdp1_map, 16 ); /* vdp map 0, gfx region 0 */ #define MDRV_DEVICE_ADD_VDP0 \ MDRV_DEVICE_ADD("gp9001vdp0", gp9001vdp_, 0) \ - MDRV_DEVICE_INLINE_DATA16(0, 0) \ + gp9001vdp_device_config::static_set_gfx_region(device, 0); \ /* vdp map 1, gfx region 2 */ #define MDRV_DEVICE_ADD_VDP1 \ MDRV_DEVICE_ADD("gp9001vdp1", gp9001vdp_, 0) \ - MDRV_DEVICE_INLINE_DATA16(0, 2) \ + gp9001vdp_device_config::static_set_gfx_region(device, 2); \ // access to VDP