src/emu/memory.c
| r8831 | r8832 | |
| 213 | 213 | #define VERBOSE (0) |
| 214 | 214 | #define TEST_HANDLER (0) |
| 215 | 215 | |
| 216 | | #define VPRINTF(x) do { if (VERBOSE) mame_printf_debug x; } while (0) |
| 216 | #define VPRINTF(x) do { if (VERBOSE) printf x; } while (0) |
| 217 | 217 | |
| 218 | 218 | |
| 219 | 219 | |
| r8831 | r8832 | |
| 2357 | 2357 | |
| 2358 | 2358 | void address_space::unmap(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read_or_write readorwrite, bool quiet) |
| 2359 | 2359 | { |
| 2360 | VPRINTF(("address_space::unmap(%s-%s mask=%s mirror=%s, %s, %s)\n", |
| 2361 | core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars), |
| 2362 | core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars), |
| 2363 | (readorwrite == ROW_READ) ? "read" : (readorwrite == ROW_WRITE) ? "write" : (readorwrite == ROW_READWRITE) ? "read/write" : "??", |
| 2364 | quiet ? "quiet" : "normal")); |
| 2365 | |
| 2360 | 2366 | // read space |
| 2361 | 2367 | if (readorwrite == ROW_READ || readorwrite == ROW_READWRITE) |
| 2362 | 2368 | read().map_range(addrstart, addrend, addrmask, addrmirror, quiet ? STATIC_NOP : STATIC_UNMAP); |
| r8831 | r8832 | |
| 2374 | 2380 | |
| 2375 | 2381 | void address_space::install_port(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *rtag, const char *wtag) |
| 2376 | 2382 | { |
| 2383 | VPRINTF(("address_space::install_port(%s-%s mask=%s mirror=%s, read=\"%s\" / write=\"%s\")\n", |
| 2384 | core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars), |
| 2385 | core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars), |
| 2386 | (rtag != NULL) ? rtag : "(none)", (wtag != NULL) ? wtag : "(none)")); |
| 2387 | |
| 2377 | 2388 | // read handler |
| 2378 | 2389 | if (rtag != NULL) |
| 2379 | 2390 | { |
| r8831 | r8832 | |
| 2411 | 2422 | |
| 2412 | 2423 | void address_space::install_bank(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *rtag, const char *wtag) |
| 2413 | 2424 | { |
| 2425 | VPRINTF(("address_space::install_bank(%s-%s mask=%s mirror=%s, read=\"%s\" / write=\"%s\")\n", |
| 2426 | core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars), |
| 2427 | core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars), |
| 2428 | (rtag != NULL) ? rtag : "(none)", (wtag != NULL) ? wtag : "(none)")); |
| 2429 | |
| 2414 | 2430 | // map the read bank |
| 2415 | 2431 | if (rtag != NULL) |
| 2416 | 2432 | { |
| r8831 | r8832 | |
| 2439 | 2455 | { |
| 2440 | 2456 | memory_private *memdata = m_machine.memory_data; |
| 2441 | 2457 | |
| 2458 | VPRINTF(("address_space::install_ram(%s-%s mask=%s mirror=%s, %s, %p)\n", |
| 2459 | core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars), |
| 2460 | core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars), |
| 2461 | (readorwrite == ROW_READ) ? "read" : (readorwrite == ROW_WRITE) ? "write" : (readorwrite == ROW_READWRITE) ? "read/write" : "??", |
| 2462 | baseptr)); |
| 2463 | |
| 2442 | 2464 | // map for read |
| 2443 | 2465 | if (readorwrite == ROW_READ || readorwrite == ROW_READWRITE) |
| 2444 | 2466 | { |
| r8831 | r8832 | |
| 2508 | 2530 | |
| 2509 | 2531 | UINT8 *address_space::install_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read8_delegate handler, UINT64 unitmask) |
| 2510 | 2532 | { |
| 2533 | VPRINTF(("address_space::install_handler(%s-%s mask=%s mirror=%s, %s, %s)\n", |
| 2534 | core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars), |
| 2535 | core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars), |
| 2536 | handler.name(), core_i64_hex_format(unitmask, data_width() / 4))); |
| 2537 | |
| 2511 | 2538 | UINT32 entry = read().map_range(addrstart, addrend, addrmask, addrmirror); |
| 2512 | 2539 | read().handler_read(entry).set_delegate(handler, unitmask); |
| 2513 | 2540 | generate_memdump(machine); |
| r8831 | r8832 | |
| 2516 | 2543 | |
| 2517 | 2544 | UINT8 *address_space::install_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, write8_delegate handler, UINT64 unitmask) |
| 2518 | 2545 | { |
| 2546 | VPRINTF(("address_space::install_handler(%s-%s mask=%s mirror=%s, %s, %s)\n", |
| 2547 | core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars), |
| 2548 | core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars), |
| 2549 | handler.name(), core_i64_hex_format(unitmask, data_width() / 4))); |
| 2550 | |
| 2519 | 2551 | UINT32 entry = write().map_range(addrstart, addrend, addrmask, addrmirror); |
| 2520 | 2552 | write().handler_write(entry).set_delegate(handler, unitmask); |
| 2521 | 2553 | generate_memdump(machine); |
| r8831 | r8832 | |
| 2537 | 2569 | |
| 2538 | 2570 | UINT8 *address_space::install_legacy_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read8_space_func rhandler, const char *rname, UINT64 unitmask) |
| 2539 | 2571 | { |
| 2572 | VPRINTF(("address_space::install_legacy_handler(%s-%s mask=%s mirror=%s, %s, %s) [read8]\n", |
| 2573 | core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars), |
| 2574 | core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars), |
| 2575 | rname, core_i64_hex_format(unitmask, data_width() / 4))); |
| 2576 | |
| 2540 | 2577 | UINT32 entry = read().map_range(addrstart, addrend, addrmask, addrmirror); |
| 2541 | 2578 | read().handler_read(entry).set_legacy_func(*this, rhandler, rname, unitmask); |
| 2542 | 2579 | generate_memdump(machine); |
| r8831 | r8832 | |
| 2545 | 2582 | |
| 2546 | 2583 | UINT8 *address_space::install_legacy_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, write8_space_func whandler, const char *wname, UINT64 unitmask) |
| 2547 | 2584 | { |
| 2585 | VPRINTF(("address_space::install_legacy_handler(%s-%s mask=%s mirror=%s, %s, %s) [write8]\n", |
| 2586 | core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars), |
| 2587 | core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars), |
| 2588 | wname, core_i64_hex_format(unitmask, data_width() / 4))); |
| 2589 | |
| 2548 | 2590 | UINT32 entry = write().map_range(addrstart, addrend, addrmask, addrmirror); |
| 2549 | 2591 | write().handler_write(entry).set_legacy_func(*this, whandler, wname, unitmask); |
| 2550 | 2592 | generate_memdump(machine); |
| r8831 | r8832 | |
| 2565 | 2607 | |
| 2566 | 2608 | UINT8 *address_space::install_legacy_handler(device_t &device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read8_device_func rhandler, const char *rname, UINT64 unitmask) |
| 2567 | 2609 | { |
| 2610 | VPRINTF(("address_space::install_legacy_handler(%s-%s mask=%s mirror=%s, %s, %s, \"%s\") [read8]\n", |
| 2611 | core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars), |
| 2612 | core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars), |
| 2613 | rname, core_i64_hex_format(unitmask, data_width() / 4), device.tag())); |
| 2614 | |
| 2568 | 2615 | UINT32 entry = read().map_range(addrstart, addrend, addrmask, addrmirror); |
| 2569 | 2616 | read().handler_read(entry).set_legacy_func(device, rhandler, rname, unitmask); |
| 2570 | 2617 | generate_memdump(machine); |
| r8831 | r8832 | |
| 2573 | 2620 | |
| 2574 | 2621 | UINT8 *address_space::install_legacy_handler(device_t &device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, write8_device_func whandler, const char *wname, UINT64 unitmask) |
| 2575 | 2622 | { |
| 2623 | VPRINTF(("address_space::install_legacy_handler(%s-%s mask=%s mirror=%s, %s, %s, \"%s\") [write8]\n", |
| 2624 | core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars), |
| 2625 | core_i64_hex_format(addrmask, m_addrchars), core_i64_hex_format(addrmirror, m_addrchars), |
| 2626 | wname, core_i64_hex_format(unitmask, data_width() / 4), device.tag())); |
| 2627 | |
| 2576 | 2628 | UINT32 entry = write().map_range(addrstart, addrend, addrmask, addrmirror); |
| 2577 | 2629 | write().handler_write(entry).set_legacy_func(device, whandler, wname, unitmask); |
| 2578 | 2630 | generate_memdump(machine); |
| r8831 | r8832 | |
| 3049 | 3101 | { |
| 3050 | 3102 | handler_entry &curentry = handler(scanentry); |
| 3051 | 3103 | |
| 3052 | | // exact match takes precedence, and in fact doesn't need any |
| 3053 | | // further configuration or population |
| 3104 | // exact match takes precedence |
| 3054 | 3105 | if (curentry.matches_exactly(bytestart, byteend, bytemask)) |
| 3055 | | return scanentry; |
| 3106 | { |
| 3107 | entry = scanentry; |
| 3108 | break; |
| 3109 | } |
| 3056 | 3110 | |
| 3057 | 3111 | // unpopulated is our second choice |
| 3058 | 3112 | if (entry == STATIC_INVALID && !curentry.populated()) |