src/emu/devtempl.h
| r14329 | r14330 | |
| 54 | 54 | #define DT_HAS_RESET 0x0002 |
| 55 | 55 | #define DT_HAS_STOP 0x0004 |
| 56 | 56 | #define DT_HAS_EXECUTE 0x0008 |
| 57 | | #define DT_HAS_NVRAM 0x0010 |
| 58 | 57 | #define DT_HAS_CUSTOM_CONFIG 0x0040 |
| 59 | 58 | #define DT_HAS_ROM_REGION 0x0080 |
| 60 | 59 | #define DT_HAS_MACHINE_CONFIG 0x0100 |
| r14329 | r14330 | |
| 123 | 122 | #if ((DEVTEMPLATE_FEATURES) & DT_HAS_EXECUTE) |
| 124 | 123 | static DEVICE_EXECUTE( DEVTEMPLATE_ID(,) ); |
| 125 | 124 | #endif |
| 126 | | #if ((DEVTEMPLATE_FEATURES) & DT_HAS_NVRAM) |
| 127 | | static DEVICE_NVRAM( DEVTEMPLATE_ID(,) ); |
| 128 | | #endif |
| 129 | 125 | #if ((DEVTEMPLATE_FEATURES) & DT_HAS_CUSTOM_CONFIG) |
| 130 | 126 | static DEVICE_CUSTOM_CONFIG( DEVTEMPLATE_ID(,) ); |
| 131 | 127 | #endif |
| r14329 | r14330 | |
| 211 | 207 | #if ((DEVTEMPLATE_FEATURES) & DT_HAS_EXECUTE) |
| 212 | 208 | case DEVINFO_FCT_EXECUTE: info->execute = DEVTEMPLATE_ID1(DEVICE_EXECUTE_NAME()); break; |
| 213 | 209 | #endif |
| 214 | | #if ((DEVTEMPLATE_FEATURES) & DT_HAS_NVRAM) |
| 215 | | case DEVINFO_FCT_NVRAM: info->nvram = DEVTEMPLATE_ID1(DEVICE_NVRAM_NAME()); break; |
| 216 | | #endif |
| 217 | | |
| 218 | 210 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 219 | 211 | case DEVINFO_STR_NAME: strcpy(info->s, DEVTEMPLATE_NAME); break; |
| 220 | 212 | #ifdef DEVTEMPLATE_SHORTNAME |
| r14329 | r14330 | |
| 240 | 232 | #if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_EXECUTE) |
| 241 | 233 | static DEVICE_EXECUTE( DEVTEMPLATE_DERIVED_ID(,) ); |
| 242 | 234 | #endif |
| 243 | | #if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_NVRAM) |
| 244 | | static DEVICE_NVRAM( DEVTEMPLATE_DERIVED_ID(,) ); |
| 245 | | #endif |
| 246 | 235 | #if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_CUSTOM_CONFIG) |
| 247 | 236 | static DEVICE_CUSTOM_CONFIG( DEVTEMPLATE_DERIVED_ID(,) ); |
| 248 | 237 | #endif |
| r14329 | r14330 | |
| 296 | 285 | #if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_EXECUTE) |
| 297 | 286 | case DEVINFO_FCT_EXECUTE: info->execute = DEVTEMPLATE_DERIVED_ID1(DEVICE_EXECUTE_NAME()); break; |
| 298 | 287 | #endif |
| 299 | | #if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_NVRAM) |
| 300 | | case DEVINFO_FCT_NVRAM: info->nvram = DEVTEMPLATE_DERIVED_ID1(DEVICE_NVRAM_NAME()); break; |
| 301 | | #endif |
| 302 | 288 | |
| 303 | 289 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 304 | 290 | case DEVINFO_STR_NAME: strcpy(info->s, DEVTEMPLATE_DERIVED_NAME); break; |
| r14329 | r14330 | |
| 313 | 299 | #undef DT_HAS_RESET |
| 314 | 300 | #undef DT_HAS_STOP |
| 315 | 301 | #undef DT_HAS_EXECUTE |
| 316 | | #undef DT_HAS_NVRAM |
| 317 | 302 | #undef DT_HAS_CUSTOM_CONFIG |
| 318 | 303 | #undef DT_HAS_ROM_REGION |
| 319 | 304 | #undef DT_HAS_MACHINE_CONFIG |
src/emu/devlegcy.c
| r14329 | r14330 | |
| 271 | 271 | // should never get here |
| 272 | 272 | fatalerror("legacy_sound_device_base::sound_stream_update called; not applicable to legacy sound devices\n"); |
| 273 | 273 | } |
| 274 | | |
| 275 | | |
| 276 | | |
| 277 | | //************************************************************************** |
| 278 | | // LEGACY MEMORY DEVICE |
| 279 | | //************************************************************************** |
| 280 | | |
| 281 | | //------------------------------------------------- |
| 282 | | // legacy_memory_device_base - constructor |
| 283 | | //------------------------------------------------- |
| 284 | | |
| 285 | | legacy_memory_device_base::legacy_memory_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock, device_get_config_func get_config) |
| 286 | | : legacy_device_base(mconfig, type, tag, owner, clock, get_config), |
| 287 | | device_memory_interface(mconfig, *this) |
| 288 | | { |
| 289 | | memset(&m_space_config, 0, sizeof(m_space_config)); |
| 290 | | } |
| 291 | | |
| 292 | | |
| 293 | | //------------------------------------------------- |
| 294 | | // device_config_complete - update configuration |
| 295 | | // based on completed device setup |
| 296 | | //------------------------------------------------- |
| 297 | | |
| 298 | | void legacy_memory_device_base::device_config_complete() |
| 299 | | { |
| 300 | | m_space_config.m_name = "memory"; |
| 301 | | m_space_config.m_endianness = static_cast<endianness_t>(get_legacy_int(DEVINFO_INT_ENDIANNESS)); |
| 302 | | m_space_config.m_databus_width = get_legacy_int(DEVINFO_INT_DATABUS_WIDTH); |
| 303 | | m_space_config.m_addrbus_width = get_legacy_int(DEVINFO_INT_ADDRBUS_WIDTH); |
| 304 | | m_space_config.m_addrbus_shift = get_legacy_int(DEVINFO_INT_ADDRBUS_SHIFT); |
| 305 | | m_space_config.m_logaddr_width = m_space_config.m_addrbus_width; |
| 306 | | m_space_config.m_page_shift = 0; |
| 307 | | m_space_config.m_internal_map = reinterpret_cast<address_map_constructor>(get_legacy_fct(DEVINFO_PTR_INTERNAL_MEMORY_MAP)); |
| 308 | | m_space_config.m_default_map = reinterpret_cast<address_map_constructor>(get_legacy_fct(DEVINFO_PTR_DEFAULT_MEMORY_MAP)); |
| 309 | | } |
| 310 | | |
| 311 | | |
| 312 | | |
| 313 | | //************************************************************************** |
| 314 | | // LEGACY NVRAM DEVICE |
| 315 | | //************************************************************************** |
| 316 | | |
| 317 | | //------------------------------------------------- |
| 318 | | // legacy_nvram_device_base - constructor |
| 319 | | //------------------------------------------------- |
| 320 | | |
| 321 | | legacy_nvram_device_base::legacy_nvram_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock, device_get_config_func get_config) |
| 322 | | : legacy_device_base(mconfig, type, tag, owner, clock, get_config), |
| 323 | | device_nvram_interface(mconfig, *this) |
| 324 | | { |
| 325 | | } |
| 326 | | |
| 327 | | |
| 328 | | //------------------------------------------------- |
| 329 | | // nvram_default - generate the default NVRAM |
| 330 | | //------------------------------------------------- |
| 331 | | |
| 332 | | void legacy_nvram_device_base::nvram_default() |
| 333 | | { |
| 334 | | device_nvram_func nvram_func = reinterpret_cast<device_nvram_func>(get_legacy_fct(DEVINFO_FCT_NVRAM)); |
| 335 | | (*nvram_func)(this, NULL, FALSE); |
| 336 | | } |
| 337 | | |
| 338 | | |
| 339 | | //------------------------------------------------- |
| 340 | | // nvram_read - read NVRAM from the given file |
| 341 | | //------------------------------------------------- |
| 342 | | |
| 343 | | void legacy_nvram_device_base::nvram_read(emu_file &file) |
| 344 | | { |
| 345 | | device_nvram_func nvram_func = reinterpret_cast<device_nvram_func>(get_legacy_fct(DEVINFO_FCT_NVRAM)); |
| 346 | | (*nvram_func)(this, &file, FALSE); |
| 347 | | } |
| 348 | | |
| 349 | | |
| 350 | | //------------------------------------------------- |
| 351 | | // nvram_write - write NVRAM to the given file |
| 352 | | //------------------------------------------------- |
| 353 | | |
| 354 | | void legacy_nvram_device_base::nvram_write(emu_file &file) |
| 355 | | { |
| 356 | | device_nvram_func nvram_func = reinterpret_cast<device_nvram_func>(get_legacy_fct(DEVINFO_FCT_NVRAM)); |
| 357 | | (*nvram_func)(this, &file, TRUE); |
| 358 | | } |
src/emu/devlegcy.h
| r14329 | r14330 | |
| 215 | 215 | // reduced macros that are easier to use, and map to the above two macros |
| 216 | 216 | #define DECLARE_LEGACY_DEVICE(name, basename) _DECLARE_LEGACY_DEVICE(name, basename, basename##_device, legacy_device_base) |
| 217 | 217 | #define DECLARE_LEGACY_SOUND_DEVICE(name, basename) _DECLARE_LEGACY_DEVICE(name, basename, basename##_device, legacy_sound_device_base) |
| 218 | | #define DECLARE_LEGACY_MEMORY_DEVICE(name, basename) _DECLARE_LEGACY_DEVICE(name, basename, basename##_device, legacy_memory_device_base) |
| 219 | | #define DECLARE_LEGACY_NVRAM_DEVICE(name, basename) _DECLARE_LEGACY_DEVICE(name, basename, basename##_device, legacy_nvram_device_base) |
| 220 | 218 | #define DECLARE_LEGACY_IMAGE_DEVICE(name, basename) _DECLARE_LEGACY_DEVICE(name, basename, basename##_device, legacy_image_device_base) |
| 221 | 219 | |
| 222 | 220 | #define DEFINE_LEGACY_DEVICE(name, basename) _DEFINE_LEGACY_DEVICE(name, basename, basename##_device, legacy_device_base) |
| 223 | 221 | #define DEFINE_LEGACY_SOUND_DEVICE(name, basename) _DEFINE_LEGACY_DEVICE(name, basename, basename##_device, legacy_sound_device_base) |
| 224 | | #define DEFINE_LEGACY_MEMORY_DEVICE(name, basename) _DEFINE_LEGACY_DEVICE(name, basename, basename##_device, legacy_memory_device_base) |
| 225 | | #define DEFINE_LEGACY_NVRAM_DEVICE(name, basename) _DEFINE_LEGACY_DEVICE(name, basename, basename##_device, legacy_nvram_device_base) |
| 226 | 222 | #define DEFINE_LEGACY_IMAGE_DEVICE(name, basename) _DEFINE_LEGACY_DEVICE(name, basename, basename##_device, legacy_image_device_base) |
| 227 | 223 | |
| 228 | 224 | |
| r14329 | r14330 | |
| 251 | 247 | #define DEVICE_EXECUTE(name) INT32 DEVICE_EXECUTE_NAME(name)(device_t *device, INT32 clocks) |
| 252 | 248 | #define DEVICE_EXECUTE_CALL(name) DEVICE_EXECUTE_NAME(name)(device, clocks) |
| 253 | 249 | |
| 254 | | #define DEVICE_NVRAM_NAME(name) device_nvram_##name |
| 255 | | #define DEVICE_NVRAM(name) void DEVICE_NVRAM_NAME(name)(device_t *device, emu_file *file, int read_or_write) |
| 256 | | #define DEVICE_NVRAM_CALL(name) DEVICE_NVRAM_NAME(name)(device, file, read_or_write) |
| 257 | 250 | |
| 258 | | |
| 259 | | |
| 260 | 251 | //************************************************************************** |
| 261 | 252 | // DEVICE_CONFIGURATION_MACROS |
| 262 | 253 | //************************************************************************** |
| r14329 | r14330 | |
| 466 | 457 | |
| 467 | 458 | |
| 468 | 459 | |
| 469 | | // ======================> legacy_memory_device_base |
| 470 | | |
| 471 | | // legacy_memory_device is a legacy_device_base with a memory interface |
| 472 | | class legacy_memory_device_base : public legacy_device_base, |
| 473 | | public device_memory_interface |
| 474 | | { |
| 475 | | protected: |
| 476 | | // construction/destruction |
| 477 | | legacy_memory_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock, device_get_config_func get_config); |
| 478 | | |
| 479 | | // device overrides |
| 480 | | virtual void device_config_complete(); |
| 481 | | |
| 482 | | // device_memory_interface overrides |
| 483 | | virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const { return (spacenum == 0) ? &m_space_config : NULL; } |
| 484 | | |
| 485 | | // internal state |
| 486 | | address_space_config m_space_config; |
| 487 | | }; |
| 488 | | |
| 489 | | |
| 490 | | |
| 491 | | // ======================> legacy_nvram_device |
| 492 | | |
| 493 | | // legacy_nvram_device is a legacy_device_base with a nvram interface |
| 494 | | class legacy_nvram_device_base : public legacy_device_base, |
| 495 | | public device_nvram_interface |
| 496 | | { |
| 497 | | protected: |
| 498 | | // construction/destruction |
| 499 | | legacy_nvram_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock, device_get_config_func get_config); |
| 500 | | |
| 501 | | // device_nvram_interface overrides |
| 502 | | virtual void nvram_default(); |
| 503 | | virtual void nvram_read(emu_file &file); |
| 504 | | virtual void nvram_write(emu_file &file); |
| 505 | | }; |
| 506 | | |
| 507 | | |
| 508 | | |
| 509 | 460 | // ======================> legacy_image_device |
| 510 | 461 | |
| 511 | 462 | // legacy_image_device is a legacy_device_base with a image interface |