diff options
Diffstat (limited to 'src/mame/machine/mbee.cpp')
-rw-r--r-- | src/mame/machine/mbee.cpp | 133 |
1 files changed, 92 insertions, 41 deletions
diff --git a/src/mame/machine/mbee.cpp b/src/mame/machine/mbee.cpp index aac736ed3d1..6daefa6fbb9 100644 --- a/src/mame/machine/mbee.cpp +++ b/src/mame/machine/mbee.cpp @@ -27,7 +27,7 @@ WRITE_LINE_MEMBER( mbee_state::pio_ardy ) m_centronics->write_strobe((state) ? 0 : 1); } -void mbee_state::pio_port_b_w(uint8_t data) +void mbee_state::pio_port_b_w(u8 data) { /* PIO port B - d5..d2 not emulated d7 interrupt from network or rtc or vsync or not used (see config switch) @@ -43,9 +43,9 @@ void mbee_state::pio_port_b_w(uint8_t data) m_speaker->level_w(BIT(data, 6)); } -uint8_t mbee_state::pio_port_b_r() +u8 mbee_state::pio_port_b_r() { - uint8_t data = 0; + u8 data = 0; if (m_cassette->input() > 0.03) data |= 1; @@ -55,16 +55,16 @@ uint8_t mbee_state::pio_port_b_r() switch (m_io_config->read() & 0xc0) { case 0x00: - data |= (uint8_t)m_b7_vs << 7; + data |= (u8)m_b7_vs << 7; break; case 0x40: - data |= (uint8_t)m_b7_rtc << 7; + data |= (u8)m_b7_rtc << 7; break; case 0x80: data |= 0x80; break; } - data |= (uint8_t)m_b2 << 1; // key pressed on new keyboard + data |= (u8)m_b2 << 1; // key pressed on new keyboard return data; } @@ -88,7 +88,7 @@ WRITE_LINE_MEMBER( mbee_state::fdc_drq_w ) m_fdc_rq = (m_fdc_rq & 1) | (state << 1); } -uint8_t mbee_state::fdc_status_r() +u8 mbee_state::fdc_status_r() { /* d7 indicate if IRQ or DRQ is occurring (1=happening) d6..d0 not used */ @@ -96,7 +96,7 @@ uint8_t mbee_state::fdc_status_r() return m_fdc_rq ? 0xff : 0x7f; } -void mbee_state::fdc_motor_w(uint8_t data) +void mbee_state::fdc_motor_w(u8 data) { /* d7..d4 not used d3 density (1=MFM) @@ -147,7 +147,7 @@ TIMER_DEVICE_CALLBACK_MEMBER( mbee_state::newkb_timer ) if (!BIT(m_features, 2)) return; - uint8_t i, j, pressed; + u8 i, j, pressed; // find what has changed for (i = 0; i < 15; i++) @@ -161,7 +161,7 @@ TIMER_DEVICE_CALLBACK_MEMBER( mbee_state::newkb_timer ) if (BIT(pressed^m_newkb_was_pressed[i], j)) { // put it in the queue - uint8_t code = (i << 3) | j | (BIT(pressed, j) ? 0x80 : 0); + u8 code = (i << 3) | j | (BIT(pressed, j) ? 0x80 : 0); m_newkb_q[m_newkb_q_pos] = code; if (m_newkb_q_pos < (std::size(m_newkb_q)-1)) m_newkb_q_pos++; @@ -179,9 +179,9 @@ TIMER_DEVICE_CALLBACK_MEMBER( mbee_state::newkb_timer ) m_pio->port_b_write(pio_port_b_r()); } -uint8_t mbee_state::port18_r() +u8 mbee_state::port18_r() { - uint8_t i, data = m_newkb_q[0]; // get oldest key + u8 i, data = m_newkb_q[0]; // get oldest key if (m_newkb_q_pos) { @@ -202,13 +202,13 @@ uint8_t mbee_state::port18_r() ************************************************************/ -uint8_t mbee_state::speed_low_r() +u8 mbee_state::speed_low_r() { m_maincpu->set_unscaled_clock(3375000); return 0xff; } -uint8_t mbee_state::speed_high_r() +u8 mbee_state::speed_high_r() { m_maincpu->set_unscaled_clock(6750000); return 0xff; @@ -222,17 +222,17 @@ uint8_t mbee_state::speed_high_r() ************************************************************/ -void mbee_state::port04_w(uint8_t data) // address +void mbee_state::port04_w(u8 data) // address { m_rtc->write(0, data); } -void mbee_state::port06_w(uint8_t data) // write +void mbee_state::port06_w(u8 data) // write { m_rtc->write(1, data); } -uint8_t mbee_state::port07_r() // read +u8 mbee_state::port07_r() // read { return m_rtc->read(1); } @@ -265,16 +265,16 @@ WRITE_LINE_MEMBER( mbee_state::rtc_irq_w ) ************************************************************/ -void mbee_state::setup_banks(uint8_t data, bool first_time, uint8_t b_mask) +void mbee_state::setup_banks(u8 data, bool first_time, u8 b_mask) { b_mask &= 7; u32 dbank = m_ramsize / 0x1000; u8 extra_bits = data & 0xc0; data &= 0x3f; // (bits 0-5 are referred to as S0-S5) address_space &mem = m_maincpu->space(AS_PROGRAM); - uint8_t *prom = memregion("pals")->base(); - uint8_t b_data = bitswap<8>(data, 7,5,3,2,4,6,1,0) & 0x3b; // arrange data bits to S0,S1,-,S4,S2,S3 - uint8_t b_bank, b_byte, b_byte_t, b_addr, p_bank = 1; + u8 *prom = memregion("pals")->base(); + u8 b_data = bitswap<8>(data, 7,5,3,2,4,6,1,0) & 0x3b; // arrange data bits to S0,S1,-,S4,S2,S3 + u8 b_bank, b_byte, b_byte_t, b_addr, p_bank = 1; uint16_t b_vid; if (first_time || (b_data != m_bank_array[0])) // if same data as last time, leave now @@ -377,21 +377,18 @@ void mbee_state::port50_w(u8 data) Output the PAK number to choose an optional PAK ROM. The bios will support 256 PAKs, although normally only - 8 are available in hardware. Each PAK is normally a 4K - ROM. If 8K ROMs are used, the 2nd half becomes PAK+8, + 8 are available in hardware. Each PAK is normally a 8K + ROM. If 16K ROMs are used, the 2nd half becomes PAK+8, thus 16 PAKs in total. This is used in the PC85 models. ************************************************************/ -void mbee_state::port0a_w(uint8_t data) +void mbee_state::port0a_w(u8 data) { - m_0a = data; - - if (m_pak) - m_pak->set_entry(data & 15); + m_0a = data & 15; } -uint8_t mbee_state::telcom_low_r() +u8 mbee_state::telcom_low_r() { /* Read of port 0A - set Telcom rom to first half */ if (m_telcom) @@ -400,7 +397,7 @@ uint8_t mbee_state::telcom_low_r() return m_0a; } -uint8_t mbee_state::telcom_high_r() +u8 mbee_state::telcom_high_r() { /* Read of port 10A - set Telcom rom to 2nd half */ if (m_telcom) @@ -409,6 +406,31 @@ uint8_t mbee_state::telcom_high_r() return m_0a; } +u8 mbee_state::pakrom_r(offs_t offset) +{ + u8 data = m_0a & 7; + + if (m_pakrom[data] && m_pakrom[data]->exists()) + { + if (BIT(m_0a, 3)) + { + if (m_pakrom_extended[data]) + return m_pakrom[data]->read_rom(0x2000 | offset); + else + return 0xff; + } + else + return m_pakrom[data]->read_rom(offset); + } + else + { + m_pakrom_extended[data] = false; + if (m_pak) + return m_p_pak[(m_0a<<13)|offset]; + else + return 0xff; + } +} /*********************************************************** @@ -458,13 +480,6 @@ void mbee_state::machine_start() m_telcom->configure_entries(0, 2, t, 0x1000); } - // PAKs fitted - if (m_pak) - { - u8 *p = memregion("pakrom")->base(); - m_pak->configure_entries(0, 16, p, 0x2000); - } - // videoram m_vram = make_unique_clear<u8[]>(0x0800); save_pointer(NAME(m_vram), 0x0800); @@ -525,6 +540,14 @@ void mbee_state::machine_start() m_bankw[b_bank]->configure_entry(banks, d); // dummy rom } } + + // set pak index to true for 16k roms + if (m_pak) + for (u8 i = 8; i < 16; i++) + m_pakrom_extended[i & 7] = (m_p_pak[(i<<13)] == 0xff) ? false : true; + else + for (u8 i = 0; i < 8; i++) + m_pakrom_extended[i] = false; } void mbee_state::machine_reset() @@ -544,9 +567,6 @@ void mbee_state::machine_reset() if (m_telcom) m_telcom->set_entry(0); - if (m_pak) - m_pak->set_entry(5); - m_maincpu->set_pc(m_size); // init new kbd @@ -614,7 +634,7 @@ QUICKLOAD_LOAD_MEMBER(mbee_state::quickload_cb) } uint16_t i, j; - uint8_t data; + u8 data; size_t quickload_size = image.length(); if (image.is_filetype("mwb")) @@ -703,3 +723,34 @@ QUICKLOAD_LOAD_MEMBER(mbee_state::quickload_cb) return image_init_result::PASS; } +image_init_result mbee_state::load_cart(device_image_interface &image, generic_slot_device *slot, u8 pak_index) +{ + u32 size = slot->common_get_size("rom"); + + if (size > 0x4000) + { + image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); + return image_init_result::FAIL; + } + + m_pakrom_extended[pak_index] = (size > 0x2000) ? true : false; + + slot->rom_alloc(m_pakrom_extended ? 0x4000 : 0x2000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); // we alloc the amount for a real rom + slot->common_load_rom(slot->get_rom_base(), size, "rom"); + + // Validate the rom + u8 bytes[3] = { slot->read_rom(0), slot->read_rom(1), slot->read_rom(2) }; + logerror ("Rom header = %02X %02X %02X\n", bytes[0], bytes[1], bytes[2]); + if ((bytes[0] != 0xc3) || ((bytes[2] & 0xe0) != 0xc0)) + { + image.seterror(IMAGE_ERROR_UNSPECIFIED, "Not a PAK rom"); + slot->call_unload(); + if (m_pak) + m_pakrom_extended[pak_index] = (m_p_pak[((pak_index+8)<<13)] == 0xff) ? false : true; + else + m_pakrom_extended[pak_index] = false; + return image_init_result::FAIL; + } + + return image_init_result::PASS; +} |