From 435d4d30fd9a211c1a3e7265d20172b824a38b94 Mon Sep 17 00:00:00 2001 From: 68bit Date: Sun, 9 Feb 2020 11:40:57 +1100 Subject: swtpc09: OS9 support, misc fixes. --- src/mame/drivers/swtpc09.cpp | 89 ++++++++++++++++++++++++++++++++------------ src/mame/includes/swtpc09.h | 4 ++ src/mame/machine/swtpc09.cpp | 41 +++++++++++++++++--- src/mame/mame.lst | 3 +- 4 files changed, 107 insertions(+), 30 deletions(-) diff --git a/src/mame/drivers/swtpc09.cpp b/src/mame/drivers/swtpc09.cpp index ebb5a755ed8..678d9e8df51 100644 --- a/src/mame/drivers/swtpc09.cpp +++ b/src/mame/drivers/swtpc09.cpp @@ -12,14 +12,12 @@ 2. swtpc09i MP-09 with SBUG rom + HDrom, MP-ID, MP-S2, MP-T, DMAF2, PIAIDE. Will boot Flex operating system - TODO: finish ide part and get this one working. 3. swtpc09u MP-09 with UniBUG rom, MP-ID, MP-S2, DMAF2. Will boot UniFlex operating system 4. swtpc09d3 MP-09 with UniBUG U3 rom, MP-ID, MP-S2, DMAF3. Will boot UniFlex operating system - TODO: add Harddisk support, DMAF3 has WD1000 interface ***************************************************************************/ @@ -27,9 +25,9 @@ #include "includes/swtpc09.h" #include "bus/ss50/interface.h" #include "formats/flex_dsk.h" +#include "formats/os9_dsk.h" #include "formats/uniflex_dsk.h" - /************************************************************************** Address maps @@ -197,6 +195,29 @@ void swtpc09_state::uniflex_dmaf3_mem(address_map &map) map(0xff800, 0xfffff).rom().region("bankdev", 0xff800); } +void swtpc09_state::os9_mem(address_map &map) +{ + map(0x00000, 0xfffff).ram(); // by default everything is ram, 1MB ram emulated + map(0x0e000, 0x0e7ff).rw(FUNC(swtpc09_state::unmapped_r), FUNC(swtpc09_state::unmapped_w)); + + // 0x0e004, 0x0e005 ACIA + map(0x0e000, 0x0e00f).rw("io0", FUNC(ss50_interface_port_device::read), FUNC(ss50_interface_port_device::write)); + // 0x0e014 0x0e018-0x0e01b DC5 FDC + map(0x0e010, 0x0e01f).rw("io1", FUNC(ss50_interface_port_device::read), FUNC(ss50_interface_port_device::write)); + map(0x0e020, 0x0e02f).rw("io2", FUNC(ss50_interface_port_device::read), FUNC(ss50_interface_port_device::write)); + map(0x0e030, 0x0e03f).rw("io3", FUNC(ss50_interface_port_device::read), FUNC(ss50_interface_port_device::write)); + // MPT + map(0x0e040, 0x0e04f).rw("io4", FUNC(ss50_interface_port_device::read), FUNC(ss50_interface_port_device::write)); + map(0x0e050, 0x0e05f).rw("io5", FUNC(ss50_interface_port_device::read), FUNC(ss50_interface_port_device::write)); + map(0x0e060, 0x0e06f).rw("io6", FUNC(ss50_interface_port_device::read), FUNC(ss50_interface_port_device::write)); + map(0x0e070, 0x0e07f).rw("io7", FUNC(ss50_interface_port_device::read), FUNC(ss50_interface_port_device::write)); + + // MPID + map(0x0e080, 0x0e083).mirror(0xc).rw(m_pia, FUNC(pia6821_device::read), FUNC(pia6821_device::write)); + map(0x0e090, 0x0e097).mirror(0x8).rw(m_ptm, FUNC(ptm6840_device::read), FUNC(ptm6840_device::write)); + + map(0x0e400, 0x0ffff).rom().region("bankdev", 0x0e400); +} /* Input ports */ static INPUT_PORTS_START( swtpc09 ) @@ -234,36 +255,39 @@ static INPUT_PORTS_START( swtpc09 ) PORT_CONFSETTING(0, "Low (x1)") PORT_CONFSETTING(1, "High (x4)") - // Debug aid to hard code the density. The FLEX format uses single - // density for track zero. Many virtual disks 'fix' the format to be - // purely double density and often without properly implementing - // driver support for that. This setting is an aid to report - // unexpected usage, and it attempts to correct that. It is possible - // to patch the software to work with these pure double density disks. + // Debug aid to hard code the density. The OS9 format can use single + // density for track zero head zero. The FLEX format can use single + // density for track zero on all heads, and many virtual disks 'fix' + // the format to be purely double density and often without properly + // implementing driver support for that. This setting is an aid to + // report unexpected usage, and it attempts to correct that. PORT_START("FLOPPY_EXPECTED_DENSITY") - PORT_CONFNAME(0xff, 0, "DMAF2/3 expected density") + PORT_CONFNAME(0x7, 0, "DMAF2/3 expected density") PORT_CONFSETTING(0, "-") PORT_CONFSETTING(1, "single density") - PORT_CONFSETTING(2, "double density, with single density track zero") - PORT_CONFSETTING(3, "double density") + PORT_CONFSETTING(2, "double density, with single density track zero head zero") + PORT_CONFSETTING(3, "double density, with single density track zero all heads") + PORT_CONFSETTING(4, "double density") // Debug aid, to check that the sector head or side is set as expected // for the sector ID being read for the FLEX floppy disk format. Many // FLEX disk images were developed for vitural machines that have - // little regard for the actual head and can work off the sector ID - // and their drivers can set the head incorrectly. E.g. a disk with 18 - // sectors per side might have a drive set to switch heads for sectors - // above 10. Another issue is that double density disk images are - // often 'fixed' so that they are pure double density without being - // single density onthe first track, and the drivers might still set - // the head based track zero being single density. This aid is not - // intended to be a substitute for fixing the drivers but it does help - // work through the issues while patching the disks. + // little regard for the actual number of heads and can work off the + // sector ID and their drivers can set the head incorrectly. E.g. a + // disk with 18 sectors per side might have a driver incorrectly switch + // heads for sectors above 10. Another issue is that double density + // disk images are often 'fixed' so that they are pure double density + // without being single density on the first track, and the drivers + // might still set the head based on track zero being single + // density. This aid is not intended to be a substitute for fixing the + // drivers but it does help work through the issues while patching the + // disks. PORT_START("FLOPPY_EXPECTED_SECTORS") - PORT_CONFNAME(0xff, 0, "DMAF2/3 expected sectors per side") + PORT_CONFNAME(0xff, 0, "DMAF2/3 FLEX expected sectors per side") PORT_CONFSETTING(0, "-") PORT_CONFSETTING(10, "10") // 5 1/4" single density 256B PORT_CONFSETTING(15, "15") // 8" single density 256B + PORT_CONFSETTING(16, "16") // 5 1/4" double density 256B, 8" DD 512B PORT_CONFSETTING(18, "18") // 5 1/4" double density 256B PORT_CONFSETTING(26, "26") // 8" double density 256B PORT_CONFSETTING(36, "36") // 3.5" 1.4M QD 256B @@ -272,10 +296,11 @@ static INPUT_PORTS_START( swtpc09 ) // driver sticks to that and if using a double density disk then set a // single density size here. PORT_START("FLOPPY_TRACK_ZERO_EXPECTED_SECTORS") - PORT_CONFNAME(0xff, 0, "DMAF2/3 track zero expected sectors per side") + PORT_CONFNAME(0xff, 0, "DMAF2/3 FLEX track zero expected sectors per side") PORT_CONFSETTING(0, "-") PORT_CONFSETTING(10, "10") // 5 1/4" single density 256B PORT_CONFSETTING(15, "15") // 8" single density 256B + PORT_CONFSETTING(16, "16") // 5 1/4" double density 256B, 8" DD 512B PORT_CONFSETTING(18, "18") // 5 1/4" double density 256B PORT_CONFSETTING(26, "26") // 8" double density 256B PORT_CONFSETTING(36, "36") // 3.5" 1.4M QD 256B @@ -539,6 +564,17 @@ void swtpc09_state::swtpc09d3(machine_config &config) } +/* MPU09, MPID, MPS2, DC5, MPT */ +void swtpc09_state::swtpc09o(machine_config &config) +{ + swtpc09_base(config); + m_bankdev->set_addrmap(AS_PROGRAM, &swtpc09_state::os9_mem); + + subdevice("io1")->set_default_option("dc5"); + subdevice("io1")->set_option_device_input_defaults("dc5", DEVICE_INPUT_DEFAULTS_NAME(dc5)); + subdevice("io4")->set_default_option("mpt"); +} + /* ROM definition */ ROM_START( swtpc09 ) @@ -562,6 +598,12 @@ ROM_START( swtpc09d3 ) ROM_LOAD ( "uos3.bin", 0xff800, 0x00800, CRC(e95eb3e0) SHA1(3e971d3b7e143bc87e4b506e18a8c928c089c25a) ) ROM_END +ROM_START( swtpc09o ) + ROM_REGION(0x100000, "bankdev", 0) + ROM_SYSTEM_BIOS(0, "os9l1v12", "OS9 Level 1 version 1.2") + ROMX_LOAD("os9l1v12.bin", 0x0e400, 0x01c00, CRC(f2ee7523) SHA1(4e47f672c43ee2dbb5f332feb276d2c109f08e78), ROM_BIOS(0)) +ROM_END + /* Driver */ // YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS @@ -569,3 +611,4 @@ COMP( 1980, swtpc09, 0, 0, swtpc09, swtpc09, swtpc09_state, init_ COMP( 1980, swtpc09i, swtpc09, 0, swtpc09i, swtpc09, swtpc09_state, init_swtpc09i, "SWTPC", "swtpc S/09 Sbug + piaide", MACHINE_NO_SOUND_HW ) COMP( 1980, swtpc09u, swtpc09, 0, swtpc09u, swtpc09, swtpc09_state, init_swtpc09u, "SWTPC", "swtpc S/09 UNIBug + DMAF2", MACHINE_NO_SOUND_HW ) COMP( 1980, swtpc09d3, swtpc09, 0, swtpc09d3, swtpc09, swtpc09_state, init_swtpc09d3, "SWTPC", "swtpc S/09 UNIBug + DMAF3", MACHINE_NO_SOUND_HW ) +COMP( 1980, swtpc09o, swtpc09, 0, swtpc09o, swtpc09, swtpc09_state, init_swtpc09o, "SWTPC", "swtpc S/09 OS9", MACHINE_NO_SOUND_HW ) diff --git a/src/mame/includes/swtpc09.h b/src/mame/includes/swtpc09.h index ada157e8f7f..10b76d24754 100644 --- a/src/mame/includes/swtpc09.h +++ b/src/mame/includes/swtpc09.h @@ -59,11 +59,13 @@ public: void swtpc09d3(machine_config &config); void swtpc09u(machine_config &config); void swtpc09(machine_config &config); + void swtpc09o(machine_config &config); void init_swtpc09(); void init_swtpc09i(); void init_swtpc09u(); void init_swtpc09d3(); + void init_swtpc09o(); DECLARE_INPUT_CHANGED_MEMBER(maincpu_clock_change); DECLARE_INPUT_CHANGED_MEMBER(fdc_clock_change); @@ -135,6 +137,7 @@ private: void mp09_mem(address_map &map); void uniflex_dmaf2_mem(address_map &map); void uniflex_dmaf3_mem(address_map &map); + void os9_mem(address_map &map); virtual void machine_start() override; virtual void machine_reset() override; @@ -186,6 +189,7 @@ private: emu_timer *m_floppy_motor_timer; floppy_image_device *m_fdc_floppy; // Current selected floppy. uint8_t m_fdc_side; // Current floppy side. + uint8_t m_fdc_dden; // Current dden state. uint8_t m_dmaf3_via_porta; uint8_t m_dmaf3_via_portb; uint8_t m_active_interrupt; diff --git a/src/mame/machine/swtpc09.cpp b/src/mame/machine/swtpc09.cpp index ddf424b02e8..792dab4ff1d 100644 --- a/src/mame/machine/swtpc09.cpp +++ b/src/mame/machine/swtpc09.cpp @@ -20,6 +20,7 @@ #define UNIFLEX_DMAF2 2 #define UNIFLEX_DMAF3 3 #define FLEX_DC5_PIAIDE 4 +#define OS9_DC5 4 READ8_MEMBER(swtpc09_state::unmapped_r) @@ -138,8 +139,7 @@ void swtpc09_state::validate_floppy_side(uint8_t cmd) } } } - - if (expected_sectors) + else if (expected_sectors) { uint8_t expected_side = sector > expected_sectors ? 1 : 0; @@ -169,13 +169,13 @@ uint8_t swtpc09_state::validate_fdc_dden(uint8_t dden) return 1; case 2: { - // Double density with track zero single density. + // Double density with track zero head zero single density. uint8_t track = m_fdc->track_r(); - if (track == 0) + if (track == 0 && m_fdc_side == 0) { if (!dden) - logerror("%s Unexpected DDEN %d for single density trak 0\n", machine().describe_context(), dden); + logerror("%s Unexpected DDEN %d for single density track 0 head 0\n", machine().describe_context(), dden); return 1; } if (dden) @@ -183,6 +183,21 @@ uint8_t swtpc09_state::validate_fdc_dden(uint8_t dden) return 0; } case 3: + { + // Double density with track zero all heads single density. + uint8_t track = m_fdc->track_r(); + + if (track == 0) + { + if (!dden) + logerror("%s Unexpected DDEN %d for single density track 0\n", machine().describe_context(), dden); + return 1; + } + if (dden) + logerror("%s Unexpected DDEN %d for double density\n", machine().describe_context(), dden); + return 0; + } + case 4: // Pure double density. if (dden) logerror("%s Unexpected DDEN %d for double density\n", machine().describe_context(), dden); @@ -229,6 +244,7 @@ WRITE8_MEMBER ( swtpc09_state::dmaf2_fdc_w ) if (offset == 0) { validate_floppy_side(data); + m_fdc->dden_w(validate_fdc_dden(m_fdc_dden)); data = validate_fdc_sector_size(data); } @@ -298,6 +314,7 @@ WRITE8_MEMBER ( swtpc09_state::dmaf2_control_reg_w ) uint8_t dden = BIT(data, 5); dden = validate_fdc_dden(dden); m_fdc->dden_w(dden); + m_fdc_dden = dden; } /* common interrupt handler */ @@ -410,6 +427,7 @@ WRITE8_MEMBER ( swtpc09_state::dmaf3_fdc_w ) if (offset == 0) { validate_floppy_side(data); + m_fdc->dden_w(validate_fdc_dden(m_fdc_dden)); data = validate_fdc_sector_size(data); } @@ -517,6 +535,7 @@ WRITE8_MEMBER ( swtpc09_state::dmaf3_control_reg_w ) uint8_t dden = BIT(data, 5); dden = validate_fdc_dden(dden); m_fdc->dden_w(dden); + m_fdc_dden = dden; } // DMAF3 WD1000 hard disk controller. @@ -605,6 +624,8 @@ READ8_MEMBER(swtpc09_state::main_r) { if (offset < 0xff00) return m_banked_space->read_byte(dat_translate(offset)); + else if (m_system_type == OS9_DC5) + return m_banked_space->read_byte(offset | 0x0ff00); else return m_banked_space->read_byte(offset | 0xfff00); } @@ -613,13 +634,14 @@ WRITE8_MEMBER(swtpc09_state::main_w) { if (offset < 0xff00) m_banked_space->write_byte(dat_translate(offset), data); + else if (m_system_type == OS9_DC5) + m_banked_space->write_byte(offset | 0x0ff00, data); else m_banked_space->write_byte(offset | 0xfff00, data); } /* MC6844 DMA controller I/O */ - void swtpc09_state::m6844_update_interrupt() { uint8_t interrupt = 0; @@ -983,6 +1005,7 @@ void swtpc09_state::machine_start() m_active_interrupt = false; m_fdc_side = 0; + m_fdc_dden = 0; // Start with the IRQ disabled? m_dmaf2_interrupt_enable = 0; @@ -1014,6 +1037,7 @@ void swtpc09_state::machine_start() save_item(NAME(m_fdc_status)); save_item(NAME(m_floppy_motor_on)); save_item(NAME(m_fdc_side)); + save_item(NAME(m_fdc_dden)); save_item(NAME(m_dmaf3_via_porta)); save_item(NAME(m_dmaf3_via_portb)); save_item(NAME(m_active_interrupt)); @@ -1053,3 +1077,8 @@ void swtpc09_state::init_swtpc09d3() // UniFLEX numbers sectors from 1. m_hdc->set_sector_base(1); } + +void swtpc09_state::init_swtpc09o() +{ + m_system_type = OS9_DC5; +} diff --git a/src/mame/mame.lst b/src/mame/mame.lst index 6bd2a4c47da..ada212182f5 100644 --- a/src/mame/mame.lst +++ b/src/mame/mame.lst @@ -37834,8 +37834,9 @@ swtpcm // MPA2 MPC Mikbug rom @source:swtpc09.cpp swtpc09 // S09, DMF2 Floppy SBUG rom - FLEX swtpc09d3 // S09, DMF3 Floppy UNIBUG U3 rom - UniFLEX U3 -swtpc09i // S09, DC4 Floppy + PIA IDE SBUG rom - FLEX +swtpc09i // S09, DC5 Floppy + PIA IDE SBUG rom - FLEX swtpc09u // S09, DMF2 Floppy UNIBUG rom - UniFLEX +swtpc09o // S09, DC5 Floppy - OS9 @source:swtpc8212.cpp swtpc8212 // Terminal -- cgit v1.2.3