diff options
Diffstat (limited to 'src/devices/bus/ti99/gromport/cartridges.cpp')
-rw-r--r-- | src/devices/bus/ti99/gromport/cartridges.cpp | 173 |
1 files changed, 94 insertions, 79 deletions
diff --git a/src/devices/bus/ti99/gromport/cartridges.cpp b/src/devices/bus/ti99/gromport/cartridges.cpp index 23303650f8f..3f7e0b88b10 100644 --- a/src/devices/bus/ti99/gromport/cartridges.cpp +++ b/src/devices/bus/ti99/gromport/cartridges.cpp @@ -15,20 +15,23 @@ #include "emu.h" #include "cartridges.h" +#define LOG_WARN (1U<<1) // Warnings +#define LOG_CONFIG (1U<<2) // Configuration +#define LOG_CHANGE (1U<<3) // Cart change +#define LOG_BANKSWITCH (1U<<4) // Bank switch operation +#define LOG_CRU (1U<<5) // CRU access +#define LOG_READ (1U<<6) // Read operation +#define LOG_WRITE (1U<<7) // Write operation +#define LOG_GROM (1U<<8) // GROM access +#define LOG_RPK (1U<<9) // RPK handler + +#define VERBOSE ( LOG_WARN ) +#include "logmacro.h" + DEFINE_DEVICE_TYPE_NS(TI99_CART, bus::ti99::gromport, ti99_cartridge_device, "ti99cart", "TI-99 cartridge") namespace bus { namespace ti99 { namespace gromport { -#define TRACE_CONFIG 0 -#define TRACE_CHANGE 0 -#define TRACE_ILLWRITE 1 -#define TRACE_BANKSWITCH 0 -#define TRACE_CRU 0 -#define TRACE_READ 0 -#define TRACE_WRITE 0 -#define TRACE_RPK 0 -#define TRACE_GROM 0 - #define CARTGROM_TAG "grom_contents" #define CARTROM_TAG "rom_contents" #define GROM3_TAG "grom3" @@ -114,7 +117,7 @@ void ti99_cartridge_device::prepare_cartridge() for (int i=0; i < 5; i++) m_pcb->m_grom[i] = nullptr; m_pcb->m_grom_size = loaded_through_softlist() ? get_software_region_length("grom") : m_rpk->get_resource_length("grom_socket"); - if (TRACE_CONFIG) logerror("grom_socket.size=0x%04x\n", m_pcb->m_grom_size); + LOGMASKED(LOG_CONFIG, "grom_socket.size=0x%04x\n", m_pcb->m_grom_size); if (m_pcb->m_grom_size > 0) { @@ -135,7 +138,7 @@ void ti99_cartridge_device::prepare_cartridge() m_pcb->m_rom_size = loaded_through_softlist() ? get_software_region_length("rom") : m_rpk->get_resource_length("rom_socket"); if (m_pcb->m_rom_size > 0) { - if (TRACE_CONFIG) logerror("rom size=0x%04x\n", m_pcb->m_rom_size); + LOGMASKED(LOG_CONFIG, "rom size=0x%04x\n", m_pcb->m_rom_size); regr = memregion(CARTROM_TAG); rom_ptr = loaded_through_softlist() ? get_software_region("rom") : m_rpk->get_contents_of_socket("rom_socket"); memcpy(regr->base(), rom_ptr, m_pcb->m_rom_size); @@ -210,11 +213,11 @@ image_init_result ti99_cartridge_device::call_load() { // File name is in m_basename // return true = error - if (TRACE_CHANGE) logerror("Loading %s in slot %s\n", basename()); + LOGMASKED(LOG_CHANGE, "Loading %s in slot %s\n", basename()); if (loaded_through_softlist()) { - if (TRACE_CONFIG) logerror("Using softlists\n"); + LOGMASKED(LOG_CONFIG, "Using softlists\n"); int i = 0; const char* pcb = get_feature("pcb"); do @@ -226,7 +229,7 @@ image_init_result ti99_cartridge_device::call_load() } i++; } while (sw_pcbdefs[i].id != 0); - if (TRACE_CONFIG) logerror("Cartridge type is %s (%d)\n", pcb, m_pcbtype); + LOGMASKED(LOG_CONFIG, "Cartridge type is %s (%d)\n", pcb, m_pcbtype); m_rpk = nullptr; } else @@ -249,51 +252,51 @@ image_init_result ti99_cartridge_device::call_load() switch (m_pcbtype) { case PCB_STANDARD: - if (TRACE_CONFIG) logerror("Standard PCB\n"); + LOGMASKED(LOG_CONFIG, "Standard PCB\n"); m_pcb = std::make_unique<ti99_standard_cartridge>(); break; case PCB_PAGED12K: - if (TRACE_CONFIG) logerror("Paged PCB 12K\n"); + LOGMASKED(LOG_CONFIG, "Paged PCB 12K\n"); m_pcb = std::make_unique<ti99_paged12k_cartridge>(); break; case PCB_PAGED16K: - if (TRACE_CONFIG) logerror("Paged PCB 16K\n"); + LOGMASKED(LOG_CONFIG, "Paged PCB 16K\n"); m_pcb = std::make_unique<ti99_paged16k_cartridge>(); break; case PCB_PAGED7: - if (TRACE_CONFIG) logerror("Paged PCB 7000\n"); + LOGMASKED(LOG_CONFIG, "Paged PCB 7000\n"); m_pcb = std::make_unique<ti99_paged7_cartridge>(); break; case PCB_MINIMEM: - if (TRACE_CONFIG) logerror("Minimem PCB\n"); + LOGMASKED(LOG_CONFIG, "Minimem PCB\n"); m_pcb = std::make_unique<ti99_minimem_cartridge>(); break; case PCB_SUPER: - if (TRACE_CONFIG) logerror("Superspace PCB\n"); + LOGMASKED(LOG_CONFIG, "Superspace PCB\n"); m_pcb = std::make_unique<ti99_super_cartridge>(); break; case PCB_MBX: - if (TRACE_CONFIG) logerror("MBX PCB\n"); + LOGMASKED(LOG_CONFIG, "MBX PCB\n"); m_pcb = std::make_unique<ti99_mbx_cartridge>(); break; case PCB_PAGED379I: - if (TRACE_CONFIG) logerror("Paged379i PCB\n"); + LOGMASKED(LOG_CONFIG, "Paged379i PCB\n"); m_pcb = std::make_unique<ti99_paged379i_cartridge>(); break; case PCB_PAGED378: - if (TRACE_CONFIG) logerror("Paged378 PCB\n"); + LOGMASKED(LOG_CONFIG, "Paged378 PCB\n"); m_pcb = std::make_unique<ti99_paged378_cartridge>(); break; case PCB_PAGED377: - if (TRACE_CONFIG) logerror("Paged377 PCB\n"); + LOGMASKED(LOG_CONFIG, "Paged377 PCB\n"); m_pcb = std::make_unique<ti99_paged377_cartridge>(); break; case PCB_PAGEDCRU: - if (TRACE_CONFIG) logerror("PagedCRU PCB\n"); + LOGMASKED(LOG_CONFIG, "PagedCRU PCB\n"); m_pcb = std::make_unique<ti99_pagedcru_cartridge>(); break; case PCB_GROMEMU: - if (TRACE_CONFIG) logerror("Grom Emulation PCB\n"); + LOGMASKED(LOG_CONFIG, "Grom Emulation PCB\n"); m_pcb = std::make_unique<ti99_gromemu_cartridge>(); break; } @@ -308,7 +311,7 @@ image_init_result ti99_cartridge_device::call_load() void ti99_cartridge_device::call_unload() { - if (TRACE_CHANGE) logerror("Unload\n"); + LOGMASKED(LOG_CHANGE, "Unload\n"); if (m_rpk != nullptr) { m_rpk->close(); // will write NVRAM contents @@ -373,9 +376,9 @@ WRITE_LINE_MEMBER( ti99_cartridge_device::romgq_line ) /* Combined select lines */ -WRITE8_MEMBER(ti99_cartridge_device::set_gromlines) +void ti99_cartridge_device::set_gromlines(line_state mline, line_state moline, line_state gsq) { - if (m_pcb != nullptr) m_pcb->set_gromlines(space, offset, data); + if (m_pcb != nullptr) m_pcb->set_gromlines(mline, moline, gsq); } WRITE_LINE_MEMBER(ti99_cartridge_device::gclock_in) @@ -462,24 +465,24 @@ void ti99_cartridge_pcb::set_cartridge(ti99_cartridge_device *cart) m_cart = cart; } -READ8Z_MEMBER(ti99_cartridge_pcb::gromreadz) +void ti99_cartridge_pcb::gromreadz(uint8_t* value) { for (auto & elem : m_grom) { if (elem != nullptr) { - elem->readz(space, offset, value, mem_mask); + elem->readz(value); } } } -WRITE8_MEMBER(ti99_cartridge_pcb::gromwrite) +void ti99_cartridge_pcb::gromwrite(uint8_t data) { for (auto & elem : m_grom) { if (elem != nullptr) { - elem->write(space, offset, data, mem_mask); + elem->write(data); } } } @@ -501,7 +504,7 @@ READ8Z_MEMBER(ti99_cartridge_pcb::readz) else { // Will not return anything when not selected (preceding gsq=ASSERT) - gromreadz(space, offset, value, mem_mask); + gromreadz(value); } } @@ -509,12 +512,12 @@ WRITE8_MEMBER(ti99_cartridge_pcb::write) { if (m_romspace_selected) { - if (TRACE_ILLWRITE) m_cart->logerror("Cannot write to ROM space at %04x\n", offset); + LOGMASKED(LOG_WARN, "Cannot write to ROM space at %04x\n", offset); } else { // Will not change anything when not selected (preceding gsq=ASSERT) - gromwrite(space, offset, data, mem_mask); + gromwrite(data); } } @@ -542,14 +545,14 @@ WRITE_LINE_MEMBER( ti99_cartridge_pcb::romgq_line ) /* Combined select lines */ -WRITE8_MEMBER(ti99_cartridge_pcb::set_gromlines) +void ti99_cartridge_pcb::set_gromlines(line_state mline, line_state moline, line_state gsq) { for (auto& elem : m_grom) { if (elem != nullptr) { - elem->set_lines(space, offset, data); - if (data==ASSERT_LINE) m_grom_idle = false; + elem->set_lines(mline, moline, gsq); + if (gsq==ASSERT_LINE) m_grom_idle = false; } } } @@ -606,7 +609,7 @@ READ8Z_MEMBER(ti99_paged12k_cartridge::readz) else { // Will not return anything when not selected (preceding gsq=ASSERT) - gromreadz(space, offset, value, mem_mask); + gromreadz(value); } } @@ -615,12 +618,13 @@ WRITE8_MEMBER(ti99_paged12k_cartridge::write) if (m_romspace_selected) { m_rom_page = (offset >> 1) & 1; - if (TRACE_BANKSWITCH) if ((offset & 1)==0) m_cart->logerror("Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); + if ((offset & 1)==0) + LOGMASKED(LOG_WARN, "Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); } else { // Will not change anything when not selected (preceding gsq=ASSERT) - gromwrite(space, offset, data, mem_mask); + gromwrite(data); } } @@ -654,7 +658,7 @@ READ8Z_MEMBER(ti99_paged16k_cartridge::readz) else { // Will not return anything when not selected (preceding gsq=ASSERT) - gromreadz(space, offset, value, mem_mask); + gromreadz(value); } } @@ -663,12 +667,13 @@ WRITE8_MEMBER(ti99_paged16k_cartridge::write) if (m_romspace_selected) { m_rom_page = (offset >> 1) & 1; - if (TRACE_BANKSWITCH) if ((offset & 1)==0) m_cart->logerror("Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); + if ((offset & 1)==0) + LOGMASKED(LOG_BANKSWITCH, "Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); } else { // Will not change anything when not selected (preceding gsq=ASSERT) - gromwrite(space, offset, data, mem_mask); + gromwrite(data); } } @@ -709,7 +714,7 @@ READ8Z_MEMBER(ti99_minimem_cartridge::readz) } else { - gromreadz(space, offset, value, mem_mask); + gromreadz(value); } } @@ -720,7 +725,7 @@ WRITE8_MEMBER(ti99_minimem_cartridge::write) { if ((offset & 0x1000)==0x0000) { - if (TRACE_ILLWRITE) m_cart->logerror("Write access to cartridge ROM at address %04x ignored", offset); + LOGMASKED(LOG_WARN, "Write access to cartridge ROM at address %04x ignored", offset); } else { @@ -729,7 +734,7 @@ WRITE8_MEMBER(ti99_minimem_cartridge::write) } else { - gromwrite(space, offset, data, mem_mask); + gromwrite(data); } } @@ -777,7 +782,7 @@ READ8Z_MEMBER(ti99_super_cartridge::readz) } else { - gromreadz(space, offset, value, mem_mask); + gromreadz(value); } } @@ -790,7 +795,7 @@ WRITE8_MEMBER(ti99_super_cartridge::write) } else { - gromwrite(space, offset, data, mem_mask); + gromwrite(data); } } @@ -826,7 +831,7 @@ READ8Z_MEMBER(ti99_super_cartridge::crureadz) if ((offset & 0xfff0) == 0x0800) { - if (TRACE_CRU) m_cart->logerror("CRU accessed at %04x\n", offset); + LOGMASKED(LOG_CRU, "CRU accessed at %04x\n", offset); uint8_t val = 0x02 << (m_ram_page << 1); *value = (val >> ((offset - 0x0800)>>1)) & 0xff; } @@ -836,11 +841,12 @@ WRITE8_MEMBER(ti99_super_cartridge::cruwrite) { if ((offset & 0xfff0) == 0x0800) { - if (TRACE_CRU) m_cart->logerror("CRU accessed at %04x\n", offset); + LOGMASKED(LOG_CRU, "CRU accessed at %04x\n", offset); if (data != 0) { m_ram_page = (offset-0x0802)>>2; - if (TRACE_BANKSWITCH) if ((offset & 1)==0) m_cart->logerror("Set RAM page = %d (CRU address %04x)\n", m_ram_page, offset); + if ((offset & 1)==0) + LOGMASKED(LOG_BANKSWITCH, "Set RAM page = %d (CRU address %04x)\n", m_ram_page, offset); } } } @@ -894,7 +900,7 @@ READ8Z_MEMBER(ti99_mbx_cartridge::readz) { // Also reads the value of 6ffe *value = m_ram_ptr[offset & 0x03ff]; - if (TRACE_READ) m_cart->logerror("%04x (RAM) -> %02x\n", offset + 0x6000, *value); + LOGMASKED(LOG_READ, "%04x (RAM) -> %02x\n", offset + 0x6000, *value); } else { @@ -905,13 +911,13 @@ READ8Z_MEMBER(ti99_mbx_cartridge::readz) else // 7000 area *value = m_rom_ptr[(offset & 0x0fff) | (m_rom_page << 12)]; - if (TRACE_READ) m_cart->logerror("%04x(%04x) -> %02x\n", offset + 0x6000, offset | (m_rom_page<<13), *value); + LOGMASKED(LOG_READ, "%04x(%04x) -> %02x\n", offset + 0x6000, offset | (m_rom_page<<13), *value); } } } else { - gromreadz(space, offset, value, mem_mask); + gromreadz(value); } } @@ -926,18 +932,19 @@ WRITE8_MEMBER(ti99_mbx_cartridge::write) { // Valid values are 0, 1, 2, 3 m_rom_page = data & 3; - if (TRACE_BANKSWITCH) if ((offset & 1)==0) m_cart->logerror("Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); + if ((offset & 1)==0) + LOGMASKED(LOG_BANKSWITCH, "Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); } if (m_ram_ptr != nullptr) m_ram_ptr[offset & 0x03ff] = data; else - if (TRACE_ILLWRITE) m_cart->logerror("Write access to %04x but no RAM present\n", offset+0x6000); + LOGMASKED(LOG_WARN, "Write access to %04x but no RAM present\n", offset+0x6000); } } else { - gromwrite(space, offset, data, mem_mask); + gromwrite(data); } } @@ -981,12 +988,12 @@ READ8Z_MEMBER(ti99_paged7_cartridge::readz) else // 7000 area *value = m_rom_ptr[(offset & 0x0fff) | (m_rom_page << 12)]; - if (TRACE_READ) m_cart->logerror("%04x(%04x) -> %02x\n", offset + 0x6000, offset | (m_rom_page<<13), *value); + LOGMASKED(LOG_READ, "%04x(%04x) -> %02x\n", offset + 0x6000, offset | (m_rom_page<<13), *value); } } else { - gromreadz(space, offset, value, mem_mask); + gromreadz(value); } } @@ -1000,12 +1007,13 @@ WRITE8_MEMBER(ti99_paged7_cartridge::write) { // Valid values are 0, 1, 2, 3 m_rom_page = (offset>>1) & 3; - if (TRACE_BANKSWITCH) if ((offset & 1)==0) m_cart->logerror("Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); + if ((offset & 1)==0) + LOGMASKED(LOG_BANKSWITCH, "Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); } } else { - gromwrite(space, offset, data, mem_mask); + gromwrite(data); } } @@ -1078,7 +1086,8 @@ WRITE8_MEMBER(ti99_paged379i_cartridge::write) // The page is determined by the inverted outputs. m_rom_page = (~offset)>>1 & mask; - if (TRACE_BANKSWITCH) if ((offset & 1)==0) m_cart->logerror("Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); + if ((offset & 1)==0) + LOGMASKED(LOG_BANKSWITCH, "Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); } } @@ -1119,7 +1128,8 @@ WRITE8_MEMBER(ti99_paged378_cartridge::write) if (m_romspace_selected) { m_rom_page = ((offset >> 1)&0x003f); - if (TRACE_BANKSWITCH) if ((offset & 1)==0) m_cart->logerror("Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); + if ((offset & 1)==0) + LOGMASKED(LOG_BANKSWITCH, "Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); } } @@ -1158,7 +1168,8 @@ WRITE8_MEMBER(ti99_paged377_cartridge::write) if (m_romspace_selected) { m_rom_page = ((offset >> 1)&0x00ff); - if (TRACE_BANKSWITCH) if ((offset & 1)==0) m_cart->logerror("Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); + if ((offset & 1)==0) + LOGMASKED(LOG_BANKSWITCH, "Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); } } @@ -1231,7 +1242,7 @@ WRITE8_MEMBER(ti99_pagedcru_cartridge::cruwrite) if (data != 0 && bit > 0) { m_rom_page = (bit-1)/2; - if (TRACE_BANKSWITCH) m_cart->logerror("Set ROM page = %d (CRU address %d)\n", m_rom_page, offset); + LOGMASKED(LOG_BANKSWITCH, "Set ROM page = %d (CRU address %d)\n", m_rom_page, offset); } } } @@ -1281,13 +1292,13 @@ WRITE8_MEMBER(ti99_pagedcru_cartridge::cruwrite) ******************************************************************************/ -WRITE8_MEMBER(ti99_gromemu_cartridge::set_gromlines) +void ti99_gromemu_cartridge::set_gromlines(line_state mline, line_state moline, line_state gsq) { if (m_grom_ptr != nullptr) { - m_grom_selected = (data != CLEAR_LINE); - m_grom_read_mode = ((offset & GROM_M_LINE)!=0); - m_grom_address_mode = ((offset & GROM_MO_LINE)!=0); + m_grom_selected = (gsq == ASSERT_LINE); + m_grom_read_mode = (mline == ASSERT_LINE); + m_grom_address_mode = (moline == ASSERT_LINE); } } @@ -1328,7 +1339,8 @@ WRITE8_MEMBER(ti99_gromemu_cartridge::write) return; // no paging } m_rom_page = (offset >> 1) & 1; - if (TRACE_BANKSWITCH) if ((offset & 1)==0) m_cart->logerror("Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); + if ((offset & 1)==0) + LOGMASKED(LOG_BANKSWITCH, "Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); } else { @@ -1380,7 +1392,7 @@ WRITE8_MEMBER(ti99_gromemu_cartridge::gromemuwrite) } else { - if (TRACE_ILLWRITE) m_cart->logerror("Ignoring write to GROM area at address %04x\n", m_grom_address); + LOGMASKED(LOG_WARN, "Ignoring write to GROM area at address %04x\n", m_grom_address); } } @@ -1432,6 +1444,9 @@ DTD: ****************************************************************************/ +#undef LOG_OUTPUT_FUNC +#define LOG_OUTPUT_FUNC printf + /**************************************** RPK class ****************************************/ @@ -1447,7 +1462,7 @@ ti99_cartridge_device::rpk::rpk(emu_options& options, const char* sysname) ti99_cartridge_device::rpk::~rpk() { - if (TRACE_RPK) printf("gromport/RPK: Destroy RPK\n"); + LOGMASKED(LOG_RPK, "[RPK handler] Destroy RPK\n"); } /* @@ -1563,7 +1578,7 @@ std::unique_ptr<ti99_cartridge_device::rpk_socket> ti99_cartridge_device::rpk_re file = rom_resource_node->get_attribute_string("file", nullptr); if (file == nullptr) throw rpk_exception(RPK_INVALID_LAYOUT, "<rom> must have a 'file' attribute"); - if (TRACE_RPK) printf("gromport/RPK: Loading ROM contents for socket '%s' from file %s\n", socketname, file); + LOGMASKED(LOG_RPK, "[RPK handler] Loading ROM contents for socket '%s' from file %s\n", socketname, file); // check for crc crcstr = rom_resource_node->get_attribute_string("crc", nullptr); @@ -1651,7 +1666,7 @@ std::unique_ptr<ti99_cartridge_device::rpk_socket> ti99_cartridge_device::rpk_re contents = global_alloc_array_clear<uint8_t>(length); if (contents==nullptr) throw rpk_exception(RPK_OUT_OF_MEMORY); - if (TRACE_RPK) printf("gromport/RPK: Allocating RAM buffer (%d bytes) for socket '%s'\n", length, socketname); + LOGMASKED(LOG_RPK, "[RPK handler] Allocating RAM buffer (%d bytes) for socket '%s'\n", length, socketname); // That's it for pure RAM. Now check whether the RAM is "persistent", i.e. NVRAM. // In that case we must load it from the NVRAM directory. @@ -1670,7 +1685,7 @@ std::unique_ptr<ti99_cartridge_device::rpk_socket> ti99_cartridge_device::rpk_re } ram_pname = std::string(system_name).append(PATH_SEPARATOR).append(ram_filename); // load, and fill rest with 00 - if (TRACE_RPK) printf("gromport/RPK: Loading NVRAM contents from '%s'\n", ram_pname.c_str()); + LOGMASKED(LOG_RPK, "[RPK handler] Loading NVRAM contents from '%s'\n", ram_pname.c_str()); // Load the NVRAM contents int bytes_read = 0; @@ -1756,7 +1771,7 @@ ti99_cartridge_device::rpk* ti99_cartridge_device::rpk_reader::open(emu_options // We'll try to find the PCB type on the provided type list. char const *const pcb_type = pcb_node->get_attribute_string("type", nullptr); if (!pcb_type) throw rpk_exception(RPK_INVALID_LAYOUT, "<pcb> must have a 'type' attribute"); - if (TRACE_RPK) printf("gromport/RPK: Cartridge says it has PCB type '%s'\n", pcb_type); + LOGMASKED(LOG_RPK, "[RPK handler] Cartridge says it has PCB type '%s'\n", pcb_type); i=0; do |