diff --git a/src/mess/drivers/pt68k4.c b/src/mess/drivers/pt68k4.c index 80c1d8c7371..8c5a864f254 100644 --- a/src/mess/drivers/pt68k4.c +++ b/src/mess/drivers/pt68k4.c @@ -1,5 +1,5 @@ // license:MAME -// copyright-holders:Robbbert +// copyright-holders:Robbbert, R. Belmont /*************************************************************************** Peripheral Technology PT68K4 @@ -7,20 +7,13 @@ 2011-01-03 Skeleton driver. 2013-09-30 Connected to a terminal 2014-01-03 Connect real DUARTs, FDC, and TimeKeeper. Settings now save properly, floppies can be read. + 2014-01-19 ISA bus and compatible cards, PC keyboard support, speaker support This has the appearance of a PC, including pc power supply, slots, etc on a conventional pc-like motherboard and case. Some pics: http://www.wormfood.net/old_computers/ -Note: bios 0 works with the terminal. When first started, set terminal - to 19200 baud and press Enter to get the logo. Enter HE to get a - list of commands. Terminate numeric entries with a Space (not Enter!). - - bios 1 works now too, but it's weird. Set the terminal to 2400 baud - then press F3 reset and hit a key or 2. When garbage starts spewing, - bump the terminal to 9600 baud and press "O Enter". The menu should appear. - Chips: 68230 Parallel Interface/Timer @ FE0081 68681 DUART/Timer (x2) @ FE0001 and FE0041 @@ -30,41 +23,44 @@ Chips: WD1002 HDD controller @ FE0141-FE014F. "Monk" BIOS also supports an 8-bit ISA IDE card. Video: ISA MDA or CGA/EGA/VGA-style boards - MDA maps VRAM at D60001, 6845 address at FA0769, 6845 data at FA076B, control latch at FA0771 - CGA maps VRAM at D70001, 6845 address at FA07A9, 6845 data at FA07AB, control port at FA07B1, color set at FA07B3, CGA status at FA07B5 - ISA memory is C00001-DFFFFF odd bytes only. So the MDA B0000 framebuffer becames (B0000*2) + C00001 = D60001. ISA I/O is at FA0001-FBFFFF odd bytes only, and the mapping is similar. HUMBUG BIOS tests MDA and CGA VRAM to determine existence, falls back to serial console if neither exists. If both exist, MDA is used. VRAM is every other byte for ISA cards. (Only 8 bit cards are supported). - OP3 on DUART1 drives a speaker. n68681 needs to handle "OP3 is timer/counter output" mode. + OP3 on DUART1 drives a speaker. + IP2 on DUART1 signals if a new keyboard scan code is available. IRQs: 2: 68230 PIT 4: DUART2 - 5: keyboard has a new scan code and DUART1 + 5: DUART1 6: PC FDC IRQ -TODO: 68230 device. Better hardware documentation would be nice too. - ISA interface and keyboard port would greatly improve usability. - How to handle ISA transparently so cards map themselves automatically? +TODO: 68230 device. Better hardware documentation would be nice too, and working OS disks. ****************************************************************************/ #include "emu.h" #include "cpu/m68000/m68000.h" -#include "machine/terminal.h" #include "machine/n68681.h" #include "machine/timekpr.h" #include "machine/pc_fdc.h" #include "formats/imd_dsk.h" +#include "machine/isa.h" +#include "machine/isa_cards.h" +#include "bus/pc_kbd/pc_kbdc.h" +#include "bus/pc_kbd/keyboards.h" +#include "sound/speaker.h" +#define M68K_TAG "maincpu" #define DUART1_TAG "duart1" #define DUART2_TAG "duart2" #define TIMEKEEPER_TAG "timekpr" -#define PCFDC_TAG "pcfdc" +#define ISABUS_TAG "isa" +#define KBDC_TAG "pc_kbdc" +#define SPEAKER_TAG "speaker" class pt68k4_state : public driver_device { @@ -72,20 +68,29 @@ public: pt68k4_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) , m_p_base(*this, "rambase") - , m_maincpu(*this, "maincpu") + , m_maincpu(*this, M68K_TAG) , m_duart1(*this, DUART1_TAG) , m_duart2(*this, DUART2_TAG) + , m_isa(*this, ISABUS_TAG) + , m_speaker(*this, SPEAKER_TAG) { } DECLARE_READ8_MEMBER(hiram_r); DECLARE_WRITE8_MEMBER(hiram_w); DECLARE_READ8_MEMBER(keyboard_r); DECLARE_WRITE8_MEMBER(keyboard_w); + DECLARE_READ8_MEMBER(isa_memory_r); + DECLARE_WRITE8_MEMBER(isa_memory_w); + DECLARE_READ8_MEMBER(isa_io_r); + DECLARE_WRITE8_MEMBER(isa_io_w); + + DECLARE_WRITE8_MEMBER(duart1_out); DECLARE_WRITE_LINE_MEMBER(duart1_irq); DECLARE_WRITE_LINE_MEMBER(duart2_irq); - DECLARE_FLOPPY_FORMATS( floppy_formats ); + DECLARE_WRITE_LINE_MEMBER(keyboard_clock_w); + DECLARE_WRITE_LINE_MEMBER(keyboard_data_w); private: virtual void machine_reset(); @@ -93,19 +98,86 @@ private: required_device m_maincpu; required_device m_duart1; required_device m_duart2; + required_device m_isa; + required_device m_speaker; UINT8 m_hiram[0x800]; + + bool m_kclk; + UINT8 m_kdata; + UINT8 m_scancode; + UINT8 m_kbdflag; + int m_kbit; }; -FLOPPY_FORMATS_MEMBER( pt68k4_state::floppy_formats ) - FLOPPY_IMD_FORMAT -FLOPPY_FORMATS_END +// AT keyboard interface - done in TTL instead of an 804x +WRITE_LINE_MEMBER(pt68k4_state::keyboard_clock_w) +{ +// printf("KCLK: %d\n", state ? 1 : 0); + + // rising edge? + if ((state == ASSERT_LINE) && (!m_kclk)) + { + if (m_kbit >= 1 && m_kbit <= 8) + { + m_scancode >>= 1; + m_scancode |= m_kdata; + } + + // stop bit? + if (m_kbit == 9) + { +// printf("scancode %02x\n", m_scancode); + m_kbit = 0; + m_kbdflag = 0x80; + m_duart1->ip2_w(CLEAR_LINE); + } + else + { + m_kbit++; + } + } + + m_kclk = (state == ASSERT_LINE) ? true : false; +} + +WRITE_LINE_MEMBER(pt68k4_state::keyboard_data_w) +{ +// printf("KDATA: %d\n", state ? 1 : 0); + m_kdata = (state == ASSERT_LINE) ? 0x80 : 0x00; +} + +WRITE8_MEMBER(pt68k4_state::duart1_out) +{ + m_speaker->level_w((data >> 3) & 1); +} + +READ8_MEMBER(pt68k4_state::isa_memory_r) +{ + return m_isa->prog_r(space, offset); +} + +WRITE8_MEMBER(pt68k4_state::isa_memory_w) +{ + m_isa->prog_w(space, offset, data); +} + +READ8_MEMBER(pt68k4_state::isa_io_r) +{ + return m_isa->io_r(space, offset); +} + +WRITE8_MEMBER(pt68k4_state::isa_io_w) +{ + m_isa->io_w(space, offset, data); +} static ADDRESS_MAP_START(pt68k4_mem, AS_PROGRAM, 16, pt68k4_state) ADDRESS_MAP_UNMAP_HIGH AM_RANGE(0x000000, 0x0fffff) AM_RAM AM_SHARE("rambase") // 1MB RAM (OS9 needs more) AM_RANGE(0xf80000, 0xf8ffff) AM_ROM AM_REGION("roms", 0) - AM_RANGE(0xfa07e0, 0xfa07ef) AM_DEVICE8(PCFDC_TAG, pc_fdc_at_device, map, 0x00ff) + AM_RANGE(0xc00000, 0xdfffff) AM_READWRITE8(isa_memory_r, isa_memory_w, 0x00ff) + AM_RANGE(0xfa0000, 0xfbffff) AM_READWRITE8(isa_io_r, isa_io_w, 0x00ff) AM_RANGE(0xfe0000, 0xfe001f) AM_DEVREADWRITE8(DUART1_TAG, duartn68681_device, read, write, 0x00ff) AM_RANGE(0xfe0040, 0xfe005f) AM_DEVREADWRITE8(DUART2_TAG, duartn68681_device, read, write, 0x00ff) AM_RANGE(0xfe01c0, 0xfe01c3) AM_READWRITE8(keyboard_r, keyboard_w, 0x00ff) @@ -117,14 +189,26 @@ ADDRESS_MAP_END static INPUT_PORTS_START( pt68k4 ) INPUT_PORTS_END -/* built in keyboard: offset 0 reads 0x80 if key ready, 0 if not. If key ready, offset 1 reads scancode. Write (and read?) to offs 0 clears key ready? */ +/* built in keyboard: offset 0 reads 0x80 if key ready, 0 if not. If key ready, offset 1 reads scancode. Read or write to offs 0 clears key ready */ READ8_MEMBER(pt68k4_state::keyboard_r) { - return 0; + if (offset == 0) + { + UINT8 rv = m_kbdflag; + + m_kbdflag = 0; + m_duart1->ip2_w(ASSERT_LINE); + + return rv; + } + + return m_scancode; } WRITE8_MEMBER(pt68k4_state::keyboard_w) { + m_kbdflag = 0; + m_duart1->ip2_w(ASSERT_LINE); } READ8_MEMBER(pt68k4_state::hiram_r) @@ -143,6 +227,14 @@ void pt68k4_state::machine_reset() memcpy((UINT8*)m_p_base.target(), user1, 8); m_maincpu->reset(); + + m_kclk = true; + m_kbit = 0; + m_scancode = 0; + m_kbdflag = 0; + + // set line to asserted (no key code ready) + m_duart1->ip2_w(ASSERT_LINE); } WRITE_LINE_MEMBER(pt68k4_state::duart1_irq) @@ -155,32 +247,70 @@ WRITE_LINE_MEMBER(pt68k4_state::duart2_irq) m_maincpu->set_input_line(M68K_IRQ_4, state); } -static SLOT_INTERFACE_START( pt68k_floppies ) - SLOT_INTERFACE( "525dd", FLOPPY_525_DD ) - SLOT_INTERFACE( "525hd", FLOPPY_525_HD ) - SLOT_INTERFACE( "35dd", FLOPPY_35_DD ) - SLOT_INTERFACE( "35hd", FLOPPY_35_HD ) +// these are cards supported by the HUMBUG and Monk BIOSes +SLOT_INTERFACE_START( pt68k4_isa8_cards ) + SLOT_INTERFACE("mda", ISA8_MDA) + SLOT_INTERFACE("cga", ISA8_CGA) + SLOT_INTERFACE("ega", ISA8_EGA) // Monk only + SLOT_INTERFACE("vga", ISA8_VGA) // Monk only + SLOT_INTERFACE("fdc_at", ISA8_FDC_AT) + SLOT_INTERFACE("wdxt_gen", ISA8_WDXT_GEN) + SLOT_INTERFACE("lpt", ISA8_LPT) + SLOT_INTERFACE("xtide", ISA8_XTIDE) // Monk only SLOT_INTERFACE_END +static const isa8bus_interface pt68k4_isabus_intf = +{ + // interrupts + DEVCB_NULL, + DEVCB_NULL, + DEVCB_NULL, + DEVCB_NULL, + DEVCB_NULL, + DEVCB_NULL, + + // dma request + DEVCB_NULL, + DEVCB_NULL, + DEVCB_NULL, +}; + +static const pc_kbdc_interface pc_kbdc_intf = +{ + DEVCB_DRIVER_LINE_MEMBER(pt68k4_state, keyboard_clock_w), + DEVCB_DRIVER_LINE_MEMBER(pt68k4_state, keyboard_data_w) +}; + static MACHINE_CONFIG_START( pt68k4, pt68k4_state ) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu",M68000, XTAL_16MHz) + MCFG_CPU_ADD(M68K_TAG, M68000, XTAL_16MHz) MCFG_CPU_PROGRAM_MAP(pt68k4_mem) // add the DUARTS. first one has the console on channel A at 19200. MCFG_DUARTN68681_ADD("duart1", XTAL_16MHz / 4) MCFG_DUARTN68681_IRQ_CALLBACK(WRITELINE(pt68k4_state, duart1_irq)) - MCFG_DUARTN68681_A_TX_CALLBACK(DEVWRITELINE("rs232", serial_port_device, tx)) + MCFG_DUARTN68681_OUTPORT_CALLBACK(WRITE8(pt68k4_state, duart1_out)) MCFG_DUARTN68681_ADD("duart2", XTAL_16MHz / 4) - MCFG_RS232_PORT_ADD("rs232", default_rs232_devices, "serial_terminal") - MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE("duart1", duartn68681_device, rx_a_w)) + MCFG_PC_KBDC_ADD(KBDC_TAG, pc_kbdc_intf) + MCFG_PC_KBDC_SLOT_ADD(KBDC_TAG, "kbd", pc_xt_keyboards, STR_KBD_IBM_PC_XT_83) MCFG_M48T02_ADD(TIMEKEEPER_TAG) - MCFG_PC_FDC_AT_ADD(PCFDC_TAG) - MCFG_FLOPPY_DRIVE_ADD(PCFDC_TAG ":0", pt68k_floppies, "525dd", pt68k4_state::floppy_formats) + MCFG_ISA8_BUS_ADD(ISABUS_TAG, ":"M68K_TAG, pt68k4_isabus_intf) + MCFG_ISA8_BUS_CUSTOM_SPACES() + MCFG_ISA8_SLOT_ADD(ISABUS_TAG, "isa1", pt68k4_isa8_cards, "fdc_at", false) + MCFG_ISA8_SLOT_ADD(ISABUS_TAG, "isa2", pt68k4_isa8_cards, "mda", false) + MCFG_ISA8_SLOT_ADD(ISABUS_TAG, "isa3", pt68k4_isa8_cards, "wdxt_gen", false) + MCFG_ISA8_SLOT_ADD(ISABUS_TAG, "isa4", pt68k4_isa8_cards, NULL, false) + MCFG_ISA8_SLOT_ADD(ISABUS_TAG, "isa5", pt68k4_isa8_cards, NULL, false) + MCFG_ISA8_SLOT_ADD(ISABUS_TAG, "isa6", pt68k4_isa8_cards, NULL, false) + MCFG_ISA8_SLOT_ADD(ISABUS_TAG, "isa7", pt68k4_isa8_cards, NULL, false) + + MCFG_SPEAKER_STANDARD_MONO("mono") + MCFG_SOUND_ADD(SPEAKER_TAG, SPEAKER_SOUND, 0) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) MACHINE_CONFIG_END /* ROM definition */ @@ -201,6 +331,6 @@ ROM_START( pt68k4 ) ROM_END /* Driver */ - /* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS */ COMP( 1990, pt68k4, 0, 0, pt68k4, pt68k4, driver_device, 0, "Peripheral Technology", "PT68K4", GAME_NOT_WORKING | GAME_NO_SOUND) +