diff options
Diffstat (limited to 'src/mame/drivers/selz80.cpp')
-rw-r--r-- | src/mame/drivers/selz80.cpp | 93 |
1 files changed, 77 insertions, 16 deletions
diff --git a/src/mame/drivers/selz80.cpp b/src/mame/drivers/selz80.cpp index ffff71824d8..2016a75db8e 100644 --- a/src/mame/drivers/selz80.cpp +++ b/src/mame/drivers/selz80.cpp @@ -14,23 +14,27 @@ Test sequence: Press -, enter an address, press = to show contents, press ToDo: - Artwork -- Various missing LEDs and switches - Keys are a guess, need to be confirmed. - Needs to be tested by a subject-matter expert. +- i8255 to be added (address is unknown) +- "Tape-Interface" to be added (has its own LED) +- "Binary" area to be added - has 8 slide switches and a LED for each +- Halt LED +- "User Display" to be added - has 6 digits and a 74C917 chip +- 3 large sockets labelled "E C B - BUS" - Unknown I/O: 'maincpu' (00F2): unmapped i/o memory write to 000C = 00 & FF 'maincpu' (00F8): unmapped i/o memory write to 0010 = FF & FF -'maincpu' (0122): unmapped i/o memory write to 0019 = 91 & FF -'maincpu' (0122): unmapped i/o memory write to 0019 = 40 & FF -'maincpu' (0122): unmapped i/o memory write to 0019 = CE & FF -'maincpu' (0122): unmapped i/o memory write to 0019 = 17 & FF ****************************************************************************/ #include "emu.h" #include "cpu/z80/z80.h" +#include "machine/i8251.h" #include "machine/i8279.h" +#include "bus/rs232/rs232.h" +#include "machine/clock.h" #include "selz80.lh" @@ -38,18 +42,26 @@ class selz80_state : public driver_device { public: selz80_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu"), - m_p_ram(*this, "ram") + : driver_device(mconfig, type, tag) + , m_maincpu(*this, "maincpu") + , m_p_ram(*this, "ram") + , m_keyboard(*this, "X%u", 0) + , m_clock(*this, "uart_clock") { } DECLARE_WRITE8_MEMBER(scanlines_w); DECLARE_WRITE8_MEMBER(digit_w); DECLARE_READ8_MEMBER(kbd_r); DECLARE_MACHINE_RESET(dagz80); + DECLARE_MACHINE_RESET(selz80); + +private: uint8_t m_digit; + void setup_baud(); required_device<cpu_device> m_maincpu; optional_shared_ptr<uint8_t> m_p_ram; + required_ioport_array<4> m_keyboard; + required_device<clock_device> m_clock; }; static ADDRESS_MAP_START(dagz80_mem, AS_PROGRAM, 8, selz80_state) @@ -61,7 +73,8 @@ ADDRESS_MAP_END static ADDRESS_MAP_START(selz80_mem, AS_PROGRAM, 8, selz80_state) ADDRESS_MAP_UNMAP_HIGH AM_RANGE(0x0000, 0x0fff) AM_ROM - AM_RANGE(0x1000, 0x1fff) AM_RAM + AM_RANGE(0x1000, 0x27ff) AM_RAM // all 3 RAM sockets filled + // AM_RANGE(0x3000, 0x37ff) AM_ROM // empty socket for ROM AM_RANGE(0xa000, 0xffff) AM_ROM ADDRESS_MAP_END @@ -69,6 +82,8 @@ static ADDRESS_MAP_START(selz80_io, AS_IO, 8, selz80_state) ADDRESS_MAP_UNMAP_HIGH ADDRESS_MAP_GLOBAL_MASK(0xff) AM_RANGE(0x00, 0x01) AM_DEVREADWRITE("i8279", i8279_device, read, write) + AM_RANGE(0x18, 0x18) AM_DEVREADWRITE("uart", i8251_device, data_r, data_w) + AM_RANGE(0x19, 0x19) AM_DEVREADWRITE("uart", i8251_device, status_r, control_w) ADDRESS_MAP_END /* Input ports */ @@ -118,11 +133,45 @@ RG EN SA SD 0(AF) 1(BC) 2(DE) 3(HL) PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SA") PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("EN") PORT_CODE(KEYCODE_K) PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("RG") PORT_CODE(KEYCODE_L) + + PORT_START("BJ") // baud jumper + /* not connected to cpu, each pair of pins is connected directly to the output + of a 4020 counter dividing the ???? clock to feed the 8251. You use a jumper + (like the kind on the back of a IDE hard drive) to choose the speed. */ + PORT_DIPNAME( 0x0F, 0x00, "Baud Rate" ) + PORT_DIPSETTING( 0x00, "9600" ) + PORT_DIPSETTING( 0x01, "4800" ) + PORT_DIPSETTING( 0x02, "2400" ) + PORT_DIPSETTING( 0x03, "1200" ) + PORT_DIPSETTING( 0x04, "600" ) + PORT_DIPSETTING( 0x05, "300" ) + PORT_DIPSETTING( 0x06, "150" ) + PORT_DIPSETTING( 0x07, "75" ) + PORT_DIPSETTING( 0x08, "38" ) // 37.5 + PORT_DIPSETTING( 0x09, "18" ) // 17.75 + PORT_DIPSETTING( 0x0A, "9" ) // 8.875 INPUT_PORTS_END +void selz80_state::setup_baud() +{ + // setup baud rate for uart + u8 baudsw = ioport("BJ")->read() & 15; + if (baudsw) + { + u32 speed = (9600*16) >> baudsw; + m_clock->set_unscaled_clock(speed); + } +} + +MACHINE_RESET_MEMBER(selz80_state, selz80) +{ + setup_baud(); +} + MACHINE_RESET_MEMBER(selz80_state, dagz80) { + setup_baud(); uint8_t* rom = memregion("user1")->base(); uint16_t size = memregion("user1")->bytes(); memcpy(m_p_ram, rom, size); @@ -144,25 +193,37 @@ READ8_MEMBER( selz80_state::kbd_r ) uint8_t data = 0xff; if (m_digit < 4) - { - char kbdrow[6]; - sprintf(kbdrow,"X%X",m_digit); - data = ioport(kbdrow)->read(); - } + data = m_keyboard[m_digit]->read(); + return data; } static MACHINE_CONFIG_START( selz80 ) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu",Z80, XTAL_4MHz) + MCFG_CPU_ADD("maincpu",Z80, XTAL_4MHz) // it's actually a 5MHz XTAL with a NEC uPD780C-1 cpu MCFG_CPU_PROGRAM_MAP(selz80_mem) MCFG_CPU_IO_MAP(selz80_io) + MCFG_MACHINE_RESET_OVERRIDE(selz80_state, selz80 ) /* video hardware */ MCFG_DEFAULT_LAYOUT(layout_selz80) /* Devices */ - MCFG_DEVICE_ADD("i8279", I8279, 2500000) // based on divider + MCFG_DEVICE_ADD("uart_clock", CLOCK, 153600) + MCFG_CLOCK_SIGNAL_HANDLER(DEVWRITELINE("uart", i8251_device, write_txc)) + MCFG_DEVCB_CHAIN_OUTPUT(DEVWRITELINE("uart", i8251_device, write_rxc)) + + MCFG_DEVICE_ADD("uart", I8251, 0) + MCFG_I8251_TXD_HANDLER(DEVWRITELINE("rs232", rs232_port_device, write_txd)) + MCFG_I8251_DTR_HANDLER(DEVWRITELINE("rs232", rs232_port_device, write_dtr)) + MCFG_I8251_RTS_HANDLER(DEVWRITELINE("rs232", rs232_port_device, write_rts)) + + MCFG_RS232_PORT_ADD("rs232", default_rs232_devices, nullptr) + MCFG_RS232_RXD_HANDLER(DEVWRITELINE("uart", i8251_device, write_rxd)) + MCFG_RS232_DSR_HANDLER(DEVWRITELINE("uart", i8251_device, write_dsr)) + MCFG_RS232_CTS_HANDLER(DEVWRITELINE("uart", i8251_device, write_cts)) + + MCFG_DEVICE_ADD("i8279", I8279, 5000000 / 2) // based on divider MCFG_I8279_OUT_SL_CB(WRITE8(selz80_state, scanlines_w)) // scan SL lines MCFG_I8279_OUT_DISP_CB(WRITE8(selz80_state, digit_w)) // display A&B MCFG_I8279_IN_RL_CB(READ8(selz80_state, kbd_r)) // kbd RL lines |