diff options
author | 2020-01-30 11:12:34 +0100 | |
---|---|---|
committer | 2020-01-30 11:12:34 +0100 | |
commit | 8f9e9c9e84f863527f1502f0a8b0ee46a659d227 (patch) | |
tree | 4b169f9032a82c8a5da20bde764ac4e46c1164cd | |
parent | d2ad10d5888e67b1fcf1585403d46a9bc3964dd5 (diff) |
alfaskop4110: WIP added keyboard
-rw-r--r-- | scripts/target/mame/mess.lua | 3 | ||||
-rw-r--r-- | src/mame/drivers/alfaskop41xx.cpp | 204 | ||||
-rw-r--r-- | src/mame/machine/alfaskop_s41_kb.cpp | 397 | ||||
-rw-r--r-- | src/mame/machine/alfaskop_s41_kb.h | 48 |
4 files changed, 586 insertions, 66 deletions
diff --git a/scripts/target/mame/mess.lua b/scripts/target/mame/mess.lua index 2d4427ddbd2..b448b883d7a 100644 --- a/scripts/target/mame/mess.lua +++ b/scripts/target/mame/mess.lua @@ -2217,6 +2217,9 @@ files { MAME_DIR .. "src/mame/drivers/eispc.cpp", MAME_DIR .. "src/mame/machine/eispc_kb.cpp", MAME_DIR .. "src/mame/machine/eispc_kb.h", + MAME_DIR .. "src/mame/drivers/alfaskop41xx.cpp", + MAME_DIR .. "src/mame/machine/alfaskop_s41_kb.cpp", + MAME_DIR .. "src/mame/machine/alfaskop_s41_kb.h", } createMESSProjects(_target, _subtarget, "exidy") diff --git a/src/mame/drivers/alfaskop41xx.cpp b/src/mame/drivers/alfaskop41xx.cpp index eeadb8bbd1b..63d461631f8 100644 --- a/src/mame/drivers/alfaskop41xx.cpp +++ b/src/mame/drivers/alfaskop41xx.cpp @@ -32,9 +32,10 @@ Dansk Datahistorisk Forening - http://datamuseum.dk/ #include "screen.h" #include "machine/input_merger.h" #include "machine/output_latch.h" +#include "machine/alfaskop_s41_kb.h" //#include "bus/rs232/rs232.h" -//#include "machine/clock.h" +#include "machine/clock.h" #define LOG_IO (1U << 1) #define LOG_NVRAM (1U << 2) @@ -43,8 +44,12 @@ Dansk Datahistorisk Forening - http://datamuseum.dk/ #define LOG_DMA (1U << 5) #define LOG_IRQ (1U << 6) #define LOG_ADLC (1U << 7) +#define LOG_KBD (1U << 8) +#define LOG_AM (1U << 9) +#define LOG_LEDS (1U << 10) +#define LOG_BITS (1U << 11) -//#define VERBOSE (LOG_MIC|LOG_ADLC|LOG_IRQ|LOG_DMA|LOG_IO) +//#define VERBOSE (LOG_MIC) //#define LOG_OUTPUT_STREAM std::cout #include "logmacro.h" @@ -56,6 +61,10 @@ Dansk Datahistorisk Forening - http://datamuseum.dk/ #define LOGDMA(...) LOGMASKED(LOG_DMA, __VA_ARGS__) #define LOGIRQ(...) LOGMASKED(LOG_IRQ, __VA_ARGS__) #define LOGADLC(...) LOGMASKED(LOG_ADLC, __VA_ARGS__) +#define LOGKBD(...) LOGMASKED(LOG_KBD, __VA_ARGS__) +#define LOGAM(...) LOGMASKED(LOG_AM, __VA_ARGS__) +#define LOGLEDS(...) LOGMASKED(LOG_LEDS, __VA_ARGS__) +#define LOGBITS(...) LOGMASKED(LOG_BITS, __VA_ARGS__) #define PLA1_TAG "ic50" @@ -72,6 +81,7 @@ public: , m_screen(*this, "screen") , m_vram(*this, "vram") , m_pla(*this, PLA1_TAG) + , m_kbd(*this, "keyboard") , m_chargen(*this, "chargen") , m_tia_adlc(*this, "tia_adlc") , m_tia_dma(*this, "tia_dma") @@ -94,6 +104,7 @@ private: required_device<screen_device> m_screen; required_shared_ptr<uint8_t> m_vram; required_device<pls100_device> m_pla; + required_device<alfaskop_s41_keyboard_device> m_kbd; /* Video controller */ required_region_ptr<uint8_t> m_chargen; @@ -108,6 +119,9 @@ private: uint8_t m_irq; uint8_t m_imsk; + /* Kbd communications */ + uint8_t m_txd; + /* Debug stuff */ /* Timer */ enum @@ -118,6 +132,7 @@ private: void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; // DEBUG stuff, will be removed when hooked up towards remote peer +#if 1 /* zero extended SDLC poll message frame to feed into receiver as a test 0 1 1 1 1 1 1 0 ; opening flag 0x7e 0 0 0 0 0 0 0 0 ; 0x00 @@ -129,6 +144,22 @@ private: 0 1 1 1 1 1 1 0 ; closing flag 0x7e */ uint8_t txBuf[10] = {0x7e, 0x00, 0xff, 0xc0, 0xa0, 0x8d, 0x55, 0x7e}; + +#else // Alternative poll message body wih faulty CRC, CRC isn't checked yet by the ADLC + + /* zero extended SDLC poll message frame to feed into receiver as a test + 0 1 1 1 1 1 1 0 ; opening flag 0x7e + 0 0 0 0 0 0 0 0 ; 0x00 + 0 0 0 0 0 0 0 0 ; 0x00 + 1 1 1 1 1 0 1 1 0 ; 0xfe <- a zero needs to be inserted, done by test code + 1 1 1 0 1 0 0 1 ; 0xe9 + 1 0 1 1 0 0 0 1 ; CRC 0x8d - wrong + 1 0 1 0 1 0 1 0 ; CRC 0x55 - wrong + 0 1 1 1 1 1 1 0 ; closing flag 0x7e + */ + uint8_t txBuf[10] = {0x7e, 0x00, 0x00, 0xfe, 0xe9, 0x8d, 0x55, 0x7e}; +#endif + int index = 0; int pos = 0; int ones = 0; @@ -179,24 +210,30 @@ void alfaskop4110_state::mem_map(address_map &map) map(0x8000, 0xefff).ram(); // NVRAM - map(0xf600, 0xf6ff).lrw8(NAME([this](offs_t offset) -> uint8_t { LOGNVRAM("nvram_r %04x: %02x\n", offset, 0); return (uint8_t) 0; }), - NAME( [this](offs_t offset, uint8_t data) { LOGNVRAM("nvram_w %04x: %02x\n", offset, data); })); + map(0xf600, 0xf6ff).lrw8(NAME([this](offs_t offset) -> uint8_t + { + LOGNVRAM("nvram_r %04x: %02x\n", offset, 0); return (uint8_t) 0; + }), + NAME([this](offs_t offset, uint8_t data) + { + LOGNVRAM("nvram_w %04x: %02x\n", offset, data); + })); // TIA board map(0xf700, 0xf71f).mirror(0x00).lrw8(NAME([this](offs_t offset) -> uint8_t { LOGDMA("TIA DMA_r %04x: %02x\n", offset, 0); return m_tia_dma->read(offset); }), - NAME([this](offs_t offset, uint8_t data) { LOGDMA("TIA DMA_w %04x: %02x\n", offset, data); m_tia_dma->write(offset, data); })); + NAME([this](offs_t offset, uint8_t data) { LOGDMA("TIA DMA_w %04x: %02x\n", offset, data); m_tia_dma->write(offset, data); })); map(0xf720, 0xf723).mirror(0x04).lrw8(NAME([this](offs_t offset) -> uint8_t { LOGADLC("TIA ADLC_r %04x: %02x\n", offset, 0); return m_tia_adlc->read(offset); }), - NAME([this](offs_t offset, uint8_t data) { LOGADLC("TIA ADLC_w %04x: %02x\n", offset, data); m_tia_adlc->write(offset, data); })); + NAME([this](offs_t offset, uint8_t data) { LOGADLC("TIA ADLC_w %04x: %02x\n", offset, data); m_tia_adlc->write(offset, data); })); // Main PCB map(0xf7d9, 0xf7d9).mirror(0x06).lrw8(NAME([this](offs_t offset) -> uint8_t { LOGIO("CRTC reg r %04x: %02x\n", offset, 0); return m_crtc->register_r(); }), - NAME([this](offs_t offset, uint8_t data) { LOGIO("CRTC reg w %04x: %02x\n", offset, data); m_crtc->register_w(data);})); + NAME([this](offs_t offset, uint8_t data) { LOGIO("CRTC reg w %04x: %02x\n", offset, data); m_crtc->register_w(data);})); map(0xf7d8, 0xf7d8).mirror(0x06).lw8(NAME([this](offs_t offset, uint8_t data) { LOGIO("CRTC adr w %04x: %02x\n", offset, data); m_crtc->address_w(data); })); map(0xf7d0, 0xf7d3).mirror(0x04).lrw8(NAME([this](offs_t offset) -> uint8_t { LOGDIA("DIA pia_r %04x: %02x\n", offset, 0); return m_dia_pia->read(offset & 3); }), - NAME([this](offs_t offset, uint8_t data) { LOGDIA("DIA pia_w %04x: %02x\n", offset, data); m_dia_pia->write(offset & 3, data); })); + NAME([this](offs_t offset, uint8_t data) { LOGDIA("DIA pia_w %04x: %02x\n", offset, data); m_dia_pia->write(offset & 3, data); })); map(0xf7c4, 0xf7c7).mirror(0x00).lrw8(NAME([this](offs_t offset) -> uint8_t { uint8_t tmp = m_mic_pia->read(offset & 3); LOGMIC("\nMIC pia_r %04x: %02x\n", offset, tmp); return tmp; }), - NAME([this](offs_t offset, uint8_t data) { LOGMIC("\nMIC pia_w %04x: %02x\n", offset, data); m_mic_pia->write(offset & 3, data); })); - map(0xf7c0, 0xf7c1).mirror(0x02).lrw8(NAME([this](offs_t offset) -> uint8_t { LOGIO("KBD acia_r %04x: %02x\n", offset, 0); return m_kbd_acia->read(offset & 1); }), - NAME([this](offs_t offset, uint8_t data) { LOGIO("KBD acia_w %04x: %02x\n", offset, data); m_kbd_acia->write(offset & 1, data); })); + NAME([this](offs_t offset, uint8_t data) { LOGMIC("\nMIC pia_w %04x: %02x\n", offset, data); m_mic_pia->write(offset & 3, data); })); + map(0xf7c0, 0xf7c1).mirror(0x02).lrw8(NAME([this](offs_t offset) -> uint8_t { LOGKBD("KBD acia_r %04x: %02x\n", offset, 0); return m_kbd_acia->read(offset & 1); }), + NAME([this](offs_t offset, uint8_t data) { LOGKBD("KBD acia_w %04x: %02x\n", offset, data); m_kbd_acia->write(offset & 1, data); })); map(0xf7fc, 0xf7fc).mirror(0x00).lr8(NAME([this](offs_t offset) -> uint8_t { LOGIO("Address Switch 0-7\n"); return 0; })); @@ -204,32 +241,33 @@ void alfaskop4110_state::mem_map(address_map &map) // IRQ mask setting map(0xffe8, 0xfff7).rom().lrw8( NAME([this](offs_t offset) -> uint8_t - { - if (!machine().side_effects_disabled()) LOGIO("AMSK read set %04x\n", offset >> 1); - m_imsk = (offset >> 1) & 7; - return ((uint8_t *) memregion("roms")->base() + 0x7e8)[offset]; - }), + { + if (!machine().side_effects_disabled()) LOGAM("AMSK read set %04x\n", offset >> 1); + m_imsk = (offset >> 1) & 7; + return ((uint8_t *) memregion("roms")->base() + 0x7e8)[offset]; + }), NAME([this](offs_t offset, uint8_t data) - { - if (!machine().side_effects_disabled()) LOGIO("AMSK write set %04x\n", offset); - m_imsk = (offset >> 1) & 7; - })); + { + if (!machine().side_effects_disabled()) LOGAM("AMSK write set %04x\n", offset); + m_imsk = (offset >> 1) & 7; + })); // Address modification map(0xfff8, 0xfff9).rom().lrw8( NAME([this](offs_t offset) -> uint8_t - { - uint16_t ploffs = (~m_irq & 0xff) | ((m_imsk & 0x07) << 8) | 0x000 | (0x18 << 11); - uint8_t tmp = ((uint8_t *) memregion("roms")->base())[0x7e0 | offset | ((m_pla->read(ploffs) & 0xf0) >> 3)]; - if (!machine().side_effects_disabled()) - { - LOGIO("AMOD read %04x: %02x\n", offset, tmp); - LOGIO("AMOD pla read %04x: %02x ==> %04x\n", ploffs, m_pla->read(ploffs), (0xffe0 | offset | ((m_pla->read(ploffs) & 0xf0) >> 3))); - } - return tmp; }), + { + uint16_t ploffs = (~m_irq & 0xff) | ((m_imsk & 0x07) << 8) | 0x000 | (0x18 << 11); + uint8_t tmp = ((uint8_t *) memregion("roms")->base())[0x7e0 | offset | ((m_pla->read(ploffs) & 0xf0) >> 3)]; + if (!machine().side_effects_disabled()) + { + LOGAM("AMOD read %04x: %02x\n", offset, tmp); + LOGAM("AMOD pla read %04x: %02x ==> %04x\n", ploffs, m_pla->read(ploffs), (0xffe0 | offset | ((m_pla->read(ploffs) & 0xf0) >> 3))); + } + return tmp; + }), NAME([this](offs_t offset, uint8_t data) // TODO: Check what a write does if anything - { - if (!machine().side_effects_disabled()) LOGIO("AMOD write %04x\n", offset); - })); + { + if (!machine().side_effects_disabled()) LOGAM("AMOD write %04x\n", offset); + })); map(0xfffa, 0xffff).rom().region("roms", 0x7fa); } @@ -241,9 +279,9 @@ void alfaskop4120_state::mem_map(address_map &map) map(0xf600, 0xf6ff).lrw8(NAME([this](offs_t offset) -> uint8_t { LOGNVRAM("nvram_r %04x: %02x\n", offset, 0); return (uint8_t) 0; }), // TODO: Move to MRO board NAME([this](offs_t offset, uint8_t data) { LOGNVRAM("nvram_w %04x: %02x\n", offset, data); })); map(0xf740, 0xf743).mirror(0x0c).lrw8(NAME([this](offs_t offset) -> uint8_t { LOGIO("FDA pia_r %04x: %02x\n", offset, 0); return m_fdapia->read(offset & 3); }), - NAME([this](offs_t offset, uint8_t data) { LOGIO("FDA pia_w %04x: %02x\n", offset, data); m_fdapia->write(offset & 3, data); })); + NAME([this](offs_t offset, uint8_t data) { LOGIO("FDA pia_w %04x: %02x\n", offset, data); m_fdapia->write(offset & 3, data); })); map(0xf7c4, 0xf7c7).mirror(0x00).lrw8(NAME([this](offs_t offset) -> uint8_t { LOGMIC("MIC pia_r %04x: %02x\n", offset, 0); return m_mic_pia->read(offset & 3); }), - NAME([this](offs_t offset, uint8_t data) { LOGMIC("MIC pia_w %04x: %02x\n", offset, data); m_mic_pia->write(offset & 3, data); })); + NAME([this](offs_t offset, uint8_t data) { LOGMIC("MIC pia_w %04x: %02x\n", offset, data); m_mic_pia->write(offset & 3, data); })); map(0xf800, 0xffff).rom().region("roms", 0); } @@ -254,7 +292,7 @@ void alfaskop4101_state::mem_map(address_map &map) map(0xf600, 0xf6ff).lrw8(NAME([this](offs_t offset) -> uint8_t { LOGNVRAM("nvram_r %04x: %02x\n", offset, 0); return (uint8_t) 0; }), NAME([this](offs_t offset, uint8_t data) { LOGNVRAM("nvram_w %04x: %02x\n", offset, data); })); map(0xf7c4, 0xf7c7).mirror(0x00).lrw8(NAME([this](offs_t offset) -> uint8_t { LOGMIC("MIC pia_r %04x: %02x\n", offset, 0); return m_mic_pia->read(offset & 3); }), - NAME([this](offs_t offset, uint8_t data) { LOGMIC("MIC pia_w %04x: %02x\n", offset, data); m_mic_pia->write(offset & 3, data); })); + NAME([this](offs_t offset, uint8_t data) { LOGMIC("MIC pia_w %04x: %02x\n", offset, data); m_mic_pia->write(offset & 3, data); })); map(0xf800, 0xffff).rom().region("roms", 0); } @@ -301,6 +339,19 @@ void alfaskop4110_state::alfaskop4110(machine_config &config) M6800(config, m_maincpu, XTAL(19'170'000) / 18); // Verified from service manual m_maincpu->set_addrmap(AS_PROGRAM, &alfaskop4110_state::mem_map); + // TTL-level serial keyboard callback + ALFASKOP_S41_KB(config, m_kbd); + m_kbd->txd_cb().set([this](bool state) + { + LOGBITS("KBD->4110: %d\n", state); + m_kbd_acia->write_rxd(state); + }); + m_kbd->leds_cb().set([this] (uint8_t data) + { + LOGLEDS("LEDS: write %02x to LEDs\n", data); + }); + + /* Interrupt controller and address modifier PLA */ /* * 82S100 data sheet @@ -400,7 +451,8 @@ void alfaskop4110_state::alfaskop4110(machine_config &config) m_mic_pia->writepa_handler().set([this](offs_t offset, uint8_t data) { LOGMIC("->MIC PIA: Port A write %02x\n", data); - LOGMIC(" PA1 - KBD reset %s\n", BIT(data, 1) ? "active" : "inactive"); + LOGKBD(" PA1 - KBD reset %s\n", BIT(data, 1) ? "active" : "inactive"); + m_kbd->rst_line_w(BIT(data, 1) ? ASSERT_LINE : CLEAR_LINE); LOGMIC(" PA5 - Int out %s\n", BIT(data, 5) ? "enabled": "disabled"); LOGMIC(" PA6 - I4 latch %s\n", BIT(data, 6) ? "enabled": "disabled"); }); @@ -438,13 +490,24 @@ void alfaskop4110_state::alfaskop4110(machine_config &config) m_dia_pia->readca1_handler().set([this](offs_t offset) -> uint8_t { LOGDIA("DIA PIA: CA1_r\n"); return 0;}); m_dia_pia->readca2_handler().set([this](offs_t offset) -> uint8_t { LOGDIA("DIA PIA: CA2_r\n"); return 0;}); - ACIA6850(config, m_kbd_acia, 0); - //CLOCK(config, "acia_clock", ACIA_CLOCK).signal_handler().set(FUNC(alfaskop4110_state::write_acia_clock)); + /* The ACIA RxC and TxC are fed from the systemclock divided through a by 14 dividing 74163, from the tech manual: + "A clock of 76 kHz is provided for the ACIA by the timing logic. ACIA divides this clock by 64 (Bit transfer rate 1188 Hz) and + synchronizes internally to received data. Furthermore ACIA may provide interrupt (at level 3) when transmit register is empty, + receive register is full or an error has occured. */ + ACIA6850(config, m_kbd_acia, XTAL(19'170'000) / 18); + CLOCK(config, "acia_clock", (XTAL(19'170'000) / 18) / 14 ).signal_handler().set([this](int state) { m_kbd_acia->write_txc(state); m_kbd_acia->write_rxc(state); }); m_kbd_acia->irq_handler().set("irq3", FUNC(input_merger_device::in_w<3>)); + m_kbd_acia->txd_handler().set([this](bool state) + { + if (m_txd != state) + { + LOGBITS("4110->KBD: %d\n", state); + m_txd = state; + m_kbd->rxd_w(m_txd); + } + }); - MC6854(config, m_tia_adlc, XTAL(19'170'000) / 18); // TODO: attach IRQ by IRQ 7 through descrete interrupt prioritization instead - //m_tia_adlc->out_irq_cb().set([this](bool state){ LOGDMA("TIA ADLC IRQ: %s\n", state == ASSERT_LINE ? "asserted" : "cleared"); m_maincpu->set_input_line(M6800_IRQ_LINE, state); }); - //m_tia_adlc->out_irq_cb().set([this](bool state){ LOGDMA("TIA ADLC IRQ: %s\n", state == ASSERT_LINE ? "asserted" : "cleared"); m_maincpu->set_input_line(M6800_IRQ_LINE, state); }); + MC6854(config, m_tia_adlc, XTAL(19'170'000) / 18); m_tia_adlc->out_irq_cb().set("irq7", FUNC(input_merger_device::in_w<7>)); m_tia_adlc->out_rdsr_cb().set([this](bool state){ LOGDMA("TIA ADLC RDSR: %d\n", state); m_tia_dma->dreq_w<1>(state); }); m_tia_adlc->out_tdsr_cb().set([this](bool state){ LOGDMA("TIA ADLC TDSR: %d\n", state); m_tia_dma->dreq_w<0>(state); }); @@ -472,11 +535,15 @@ void alfaskop4110_state::machine_start() save_item(NAME(m_irq)); save_item(NAME(m_imsk)); timer_set(attotime::from_msec(5000), TIMER_POLL_START); + + // Hard wired inputs + m_kbd_acia->write_cts(0); + m_kbd_acia->write_dcd(0); } void alfaskop4110_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { - // Debug, inserts a poll SDLC frame through the ADLC, it ends up at address 0x140 in RAM through DMA + // Debug feature, inserts a poll SDLC frame through the ADLC, it ends up at address 0x140 in RAM through DMA switch (id) { case TIMER_POLL_START: @@ -486,37 +553,42 @@ void alfaskop4110_state::device_timer(emu_timer &timer, device_timer_id id, int timer_set(attotime::from_hz(300000), TIMER_POLL_BIT); break; case TIMER_POLL_BIT: - if (flank) - { - if (index != 0 && index != 7 && BIT(txBuf[index], (pos % 8)) && ones == 5) + if (flank) { - LOGADLC("%d%c", 2, (pos % 8) == 7 ? '\n' : ' '); - m_tia_adlc->set_rx(0); - ones = 0; - } - else - { - LOGADLC("%d%c", BIT(txBuf[index], (pos % 8)), (pos % 8) == 7 ? '\n' : ' '); - m_tia_adlc->set_rx(BIT(txBuf[index], (pos % 8))); - if (index != 0 && index != 7 && BIT(txBuf[index], (pos % 8))) - ones++; - else + if (index != 0 && index != 7 && BIT(txBuf[index], (pos % 8)) && ones == 5) + { + LOGADLC("%d%c", 2, (pos % 8) == 7 ? '\n' : ' '); + m_tia_adlc->set_rx(0); ones = 0; - pos++; - index = pos / 8; + } + else + { + LOGADLC("%d%c", BIT(txBuf[index], (pos % 8)), (pos % 8) == 7 ? '\n' : ' '); + m_tia_adlc->set_rx(BIT(txBuf[index], (pos % 8))); + if (index != 0 && index != 7 && BIT(txBuf[index], (pos % 8))) + ones++; + else + ones = 0; + pos++; + index = pos / 8; + } } - } - m_tia_adlc->rxc_w(flank ? 1 : 0); - if (index < 8) - timer_set(attotime::from_hz(300000) / 2, TIMER_POLL_BIT); - flank = !flank; - break; + m_tia_adlc->rxc_w(flank ? 1 : 0); + if (index < 8) + timer_set(attotime::from_hz(300000) / 2, TIMER_POLL_BIT); + flank = !flank; + break; } } void alfaskop4110_state::machine_reset() { m_irq = 0x00; + m_kbd->rst_line_w(ASSERT_LINE); + + // Hard wired inputs + m_kbd_acia->write_cts(0); + m_kbd_acia->write_dcd(0); } void alfaskop4120_state::alfaskop4120(machine_config &config) @@ -545,7 +617,7 @@ ROM_START( alfaskop4110 ) // Display Unit ROM_REGION( 0x800, "chargen", ROMREGION_ERASEFF ) ROM_LOAD( "e3405972067500.bin", 0x0000, 0x0400, CRC(fb12b549) SHA1(53783f62c5e51320a53e053fbcf8b3701d8a805f)) ROM_LOAD( "e3405972067600.bin", 0x0400, 0x0400, CRC(c7069d65) SHA1(587efcbee036d4c0c5b936cc5d7b1f97b6fe6dba)) - ROM_REGION( 0xff, PLA1_TAG, 0 ) + ROM_REGION( 0xff, PLA1_TAG, 0 ) //ROM_LOAD( "dtc_a_e34062_0100_ic50_e3405970303601_ml.bin", 0x00, 0xf5, CRC(b37395f2) SHA1(a00dc77d4bef084c0ddceef618986d83c69b1d65) ) // Signetics_N82S100N.bin MAXLOADER format ROM_LOAD( "dtc_a_e34062_0100_ic50_e3405970303601.bin", 0x00, 0xfa, CRC(16339b7a) SHA1(9b313a7526460dc9bcedfda25bece91c924f0ddc) ) // Signetics_N82S100N.bin DATAIO format ROM_END @@ -562,7 +634,7 @@ ROM_END /* Driver(S) */ -// Only 4101 may exist as a driver in the end making the 4110 and 4120 as slots devices on the SS3 bus, time will tell +// Only 4101 should exist as a driver in the end, making the 4110 and 4120 as slots devices on the SS3 bus, time will tell // YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS COMP( 1984, alfaskop4110, 0, 0, alfaskop4110, alfaskop4110, alfaskop4110_state, empty_init, "Ericsson", "Alfaskop Display Unit 4110", MACHINE_IS_SKELETON) diff --git a/src/mame/machine/alfaskop_s41_kb.cpp b/src/mame/machine/alfaskop_s41_kb.cpp new file mode 100644 index 00000000000..733914d636e --- /dev/null +++ b/src/mame/machine/alfaskop_s41_kb.cpp @@ -0,0 +1,397 @@ +// license:BSD-3-Clause +// copyright-holders: Joakim Larsson Edström +/********************************************************************** + + Alfaskop 4110 keyboard, emulation of the KeyBoard Unit KBU 4140. which often + was attached to the numerical Keyboard eXpansion Unit KXE 4141 which is not + emulated yet. There is also an optional Magnetic Identification Device MID 4131 + + TTL-level bi-directional serial matrix keyboard + + The KBU 4140 keyboard is controlled by a MC6802@3'579'000Hz in combo with a MC6846. + The key matrix is scanned with the help of two 74LS164 which is also extended to the + KXE 4141. The columns are read through a 74LS240. There are 8 LEDs which are + latched by a 74LS374. The I/O port on the MC6846 is connected to a magnet strip + reader through a MIA interface + + The keyboard serial interface line is interpreted and generated by the timer in + the MC6846 where both TX and Rx shares the same line on the keyboard side. The + keyboard remains silent until spoken to by the host computer to avoid collisions. + + Credits + ------- + The MC6846 ROM and address decoder ROM were dumped by Dalby Datormuseum whom + also provided documentation and schematics of the keyboard + + https://sites.google.com/site/dalbydatormuseum/home + + **********************************************************************/ + +#include "emu.h" +#include "alfaskop_s41_kb.h" +#include "cpu/m6800/m6800.h" + +//************************************************************************** +// CONFIGURABLE LOGGING +//************************************************************************** +#define LOG_IRQ (1U << 1) +#define LOG_RESET (1U << 2) +#define LOG_BITS (1U << 3) +#define LOG_UI (1U << 4) +#define LOG_LEDS (1U << 5) +#define LOG_ROM (1U << 6) +#define LOG_ADEC (1U << 7) +#define LOG_IO (1U << 8) + +//#define VERBOSE (LOG_GENERAL|LOG_IO|LOG_IRQ|LOG_LEDS|LOG_BITS|LOG_RESET) +//#define LOG_OUTPUT_STREAM std::cout + +#include "logmacro.h" + +#define LOGIRQ(...) LOGMASKED(LOG_IRQ, __VA_ARGS__) +#define LOGRST(...) LOGMASKED(LOG_RESET, __VA_ARGS__) +#define LOGBITS(...) LOGMASKED(LOG_BITS, __VA_ARGS__) +#define LOGUI(...) LOGMASKED(LOG_UI, __VA_ARGS__) +#define LOGLEDS(...) if (!machine().side_effects_disabled()) LOGMASKED(LOG_LEDS, __VA_ARGS__) +#define LOGROM(...) if (!machine().side_effects_disabled()) LOGMASKED(LOG_ROM, __VA_ARGS__) +#define LOGADEC(...) if (!machine().side_effects_disabled()) LOGMASKED(LOG_ADEC, __VA_ARGS__) +#define LOGIO(...) if (!machine().side_effects_disabled()) LOGMASKED(LOG_IO, __VA_ARGS__) + +//************************************************************************** +// MACROS / CONSTANTS +//************************************************************************** + +#define M6800_TAG "mcu" + +namespace { + +INPUT_PORTS_START(alfaskop_s41_kb) + PORT_START("P15") + PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("KP 6") PORT_CODE(KEYCODE_6_PAD) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR('6') PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) // 77 + PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("KP +") PORT_CODE(KEYCODE_PLUS_PAD) PORT_CHAR('+') // 78 + PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("KP 5") PORT_CODE(KEYCODE_5_PAD) PORT_CHAR('5') // 76 + PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("* PRINT") PORT_CODE(KEYCODE_TILDE) PORT_CHAR('*') PORT_CHAR(UCHAR_MAMEKEY(PRTSCR)) // 55 + PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("R Shift") PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) // 54 + PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('_') // 53 + PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME(". :") PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR(':') // 52 + PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("F5") PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5)) // 63 + PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("F6") PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6)) // 64 + PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_UNUSED ) // no scancode is sent + PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("CTRL") PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_MAMEKEY(LCONTROL)) // 29 + PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME(", ;") PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR(';') // 51 + PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D') PORT_CHAR('d') // 32 + PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('X') PORT_CHAR('x') // 45 + PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C') PORT_CHAR('c') // 46 + PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('J') PORT_CHAR('j') // 36 + + PORT_START("P14") + PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_UNUSED ) // 00 - keyboard error + PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("BREAK") PORT_CODE(KEYCODE_PAUSE) PORT_CHAR(UCHAR_MAMEKEY(PAUSE)) // 70 + PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("KP 7") PORT_CODE(KEYCODE_7_PAD) PORT_CHAR('7') PORT_CHAR(UCHAR_MAMEKEY(HOME)) // 71 + PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNUSED ) // ff - keyboard error + PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('^') PORT_CHAR('~') PORT_CHAR(']') // 27 + PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR(0x00e5) PORT_CHAR(0x00c5) PORT_CHAR('[') // 26 å Å + PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('P') PORT_CHAR('p') // 25 + PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("F1") PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1)) // 59 + PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("F2") PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2)) // 60 + PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W') // 17 + PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E') // 18 + PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O') // 24 + PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R') // 19 + PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T') // 20 + PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y') // 21 + PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I') // 23 + + PORT_START("P13") + PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_NUMLOCK) PORT_CHAR(UCHAR_MAMEKEY(NUMLOCK)) // 69 + PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_UNUSED ) // ff - keyboard error + PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("BS DEL") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) PORT_CHAR(UCHAR_MAMEKEY(DEL)) // 14 + PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_CHAR('+') // 13 + PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('_') // 12 + PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR(')') // 11 + PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR('(') // 10 + PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') // 02 + PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("ESC") PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC)) // 01 + PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('@') // 03 + PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') // 04 + PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('*') // 09 + PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') // 05 + PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') // 06 + PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('^') // 07 + PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('&') // 08 + + PORT_START("P12") + PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("KP 9") PORT_CODE(KEYCODE_9_PAD) PORT_CHAR('9') PORT_CHAR(UCHAR_MAMEKEY(PGUP)) // 73 + PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("KP -") PORT_CODE(KEYCODE_MINUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(MINUS_PAD)) // 74 + PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("KP 8") PORT_CODE(KEYCODE_8_PAD) PORT_CODE(KEYCODE_UP) PORT_CHAR('8') PORT_CHAR(UCHAR_MAMEKEY(UP)) // 72 + PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`') PORT_CHAR('~') // 41 + PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') PORT_CHAR('"') // 40 + PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR(':') // 39 + PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L') // 38 + PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("F3") PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3)) // 61 + PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("F4") PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4)) // 62 + PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q') // 16 + PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("TAB") PORT_CODE(KEYCODE_TAB) PORT_CHAR(9) // 15 + PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K') // 37 + PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F') // 33 + PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G') // 34 + PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H') // 35 + PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U') // 22 + + PORT_START("P11") + PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DEL_PAD) PORT_CHAR(UCHAR_MAMEKEY(COMMA_PAD)) // 83 + PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("RETURN") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) // 28 + PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("KP 0") PORT_CODE(KEYCODE_0_PAD) PORT_CHAR('0') PORT_CHAR(UCHAR_MAMEKEY(INSERT)) // 82 + PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNUSED ) // 89 - no key + PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNUSED ) // 86 - no key + PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNUSED ) // 87 - no key + PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNUSED ) // 88 - no key + PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("F9") PORT_CODE(KEYCODE_F9) PORT_CHAR(UCHAR_MAMEKEY(F9)) // 67 + PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("F10") PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10)) // 68 + PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_UNUSED ) // scan code ff - keyboard error + PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') // 43 + PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("CAPS LOCK") PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) // 58 + PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("SHIFT LOCK") PORT_CODE(KEYCODE_LALT) // 56 + PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNUSED ) // 85 - no key + PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V') // 47 + PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') // 57 + + PORT_START("P10") + PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("KP 3") PORT_CODE(KEYCODE_3_PAD) PORT_CODE(KEYCODE_PGDN) // 81 + PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_UNUSED ) // ff - keyboard error + PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("KP 2") PORT_CODE(KEYCODE_2_PAD) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(2_PAD)) // 80 + PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("NEW LINE") PORT_CODE(KEYCODE_ENTER_PAD) PORT_CHAR(UCHAR_MAMEKEY(ENTER_PAD)) // 84 (programmable, default is 28) + PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("KP 1") PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD)) // 79 + PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("KP 4") PORT_CODE(KEYCODE_4_PAD) PORT_CODE(KEYCODE_LEFT) PORT_CHAR('4') PORT_CHAR(UCHAR_MAMEKEY(LEFT)) // 75 + PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNUSED ) // ff - keyboard error + PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("F7") PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7)) // 65 + PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("F8") PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8)) // 66 + PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1) // 42 + PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z') // 44 + PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M') // 50 + PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A') // 30 + PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S') // 31 + PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B') // 48 + PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N') // 49 +INPUT_PORTS_END + + +//------------------------------------------------- +// ROM( alfaskop_s41_kb ) +//------------------------------------------------- + +ROM_START( alfaskop_s41_kb ) + ROM_REGION( 0x800, M6800_TAG, 0 ) + ROM_LOAD( "kbc_e34066_0000_ic3.bin", 0x000, 0x800, CRC(a1232241) SHA1(45d1b038bfbd04e1b7e3718a27202280c5257989) ) + ROM_REGION( 0x20, "ad_rom", 0 ) // Address decoder + ROM_LOAD( "kbc_e34066_0000_ic4_e3405970280400.bin", 0x00, 0x20, CRC(f26acca3) SHA1(ac8c607d50bb588c1da4ad1602665c785ebd29b3) ) +ROM_END + +} // anonymous namespace + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +DEFINE_DEVICE_TYPE(ALFASKOP_S41_KB, alfaskop_s41_keyboard_device, "alfaskop_s41_kb", "Alfaskop 4110 keyboard") + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// alfaskop_s41_keyboard_device - constructor +//------------------------------------------------- + +alfaskop_s41_keyboard_device::alfaskop_s41_keyboard_device( + machine_config const &mconfig, + char const *tag, + device_t *owner, + uint32_t clock) + : device_t(mconfig, ALFASKOP_S41_KB, tag, owner, clock) + , m_mcu(*this, M6800_TAG) + , m_mc6846(*this, "mc6846") + , m_rows(*this, "P1%u", 0) + , m_txd_cb(*this) + , m_leds_cb(*this) + , m_rxd_high(true) + , m_txd_high(true) + , m_hold(true) + , m_col_select(0) + , m_p1(0) + , m_leds(0) +{ +} + +WRITE_LINE_MEMBER(alfaskop_s41_keyboard_device::rxd_w) +{ + LOGBITS("KBD bit presented: %d\n", state); + //m_rxd_high = CLEAR_LINE != state; +} + +// WRITE_LINE_MEMBER(alfaskop_s41_keyboard_device::hold_w) +// { +// m_hold = CLEAR_LINE == state; +// } + +WRITE_LINE_MEMBER(alfaskop_s41_keyboard_device::rst_line_w) +{ + if (state == CLEAR_LINE) + { + m_mcu->set_input_line(INPUT_LINE_RESET, CLEAR_LINE); + LOGRST("KBD: Keyboard mcu reset line is cleared\n"); + } + else + { + m_mcu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE); + LOGRST("KBD: Keyboard mcu reset line is asserted\n"); + } +} + +//------------------------------------------------- +// device_start - device specific startup +//------------------------------------------------- + +void alfaskop_s41_keyboard_device::device_start() +{ + m_txd_cb.resolve_safe(); + m_leds_cb.resolve_safe(); + + save_item(NAME(m_rxd_high)); + save_item(NAME(m_txd_high)); + save_item(NAME(m_col_select)); + + m_rxd_high = true; + m_txd_high = true; + m_col_select = 0; +} + + + +//------------------------------------------------- +// device_add_mconfig - add device configuration +//------------------------------------------------- + +void alfaskop_s41_keyboard_device::device_add_mconfig(machine_config &config) +{ + M6802(config, m_mcu, XTAL(3'579'545)); // Crystal verified from schematics + m_mcu->set_addrmap(AS_PROGRAM, &alfaskop_s41_keyboard_device::alfaskop_s41_kb_mem); + + MC6846(config, m_mc6846, XTAL(3'579'545) / 4); // Driven by E from 6802 == XTAL / 4 + m_mc6846->irq().set([this](bool state) + { + LOGIRQ(" [timer IRQ: %s] ", state == ASSERT_LINE ? "asserted" : "cleared"); + m_mcu->set_input_line(M6802_IRQ_LINE, state); + }); + m_mc6846->cp2().set([this](bool state){ LOG("CP2:%d\n", state); }); + // MIA ID interrupt: m_mc6846->set_input_cp1(1); + m_mc6846->cto().set([this](bool state){ LOG("CTO:%d\n", state); }); // Not connected to anything +} + +//------------------------------------------------- +// input_ports - device-specific input ports +//------------------------------------------------- + +ioport_constructor alfaskop_s41_keyboard_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( alfaskop_s41_kb ); +} + +//------------------------------------------------- +// ADDRESS_MAP( alfaskop_s41_kb_mem ) +//------------------------------------------------- + +void alfaskop_s41_keyboard_device::alfaskop_s41_kb_mem(address_map &map) +{ + map(0x0000, 0x007f).ram(); // Internal RAM + /* A 32 byte decoder ROM connects A0-A4 to A11, A12, A13, A15 and to an external port pin, A14 is not decoded! + * c3 c3 c3 c3 c3 c3 c3 c3 c3 c3 c3 c3 c3 c3 c3 c3 - if external port pin is low + * c3 c3 c3 c3 c5 c6 cb c3 d3 c3 c3 c3 c3 c3 43 f3 - if external port pin is high - normal operation + * + * Decoder rom byte bits as follows + * 0 - 0x01 Start scanning + * 1 - 0x02 read col + * 2 - 0x04 shift col clock + * 3 - 0x08 set lamp data + * 4 - 0x10 CS1 mc6846 I/O access - active low + * 5 - 0x20 CS0 mc6846 ROM access - active high + * 6 - 0x40 n/c? + * 7 - 0x80 to KBX + * + * F3 <- 0x0f <- 1-11 1 == b800-bfff, f800-ffff // 1111 0011 MC6846 Internal ROM access (CS0 - active high) + * 43 <- 0x0e <- 1-11 0 == b000-b7ff, f000-f7ff // 0100 0011 + * c3 <- 0x0d <- 1-10 1 == a800-afff, e800-efff // 1100 0011 + * c3 <- 0x0c <- 1-10 0 == a000-a7ff, e000-e7ff // 1100 0011 + * c3 <- 0x0b <- 1-01 1 == 9800-9fff, d800-dfff // 1100 0011 + * c3 <- 0x0a <- 1-01 0 == 9000-97ff, d000-d7ff // 1100 0011 + * c3 <- 0x09 <- 1-00 1 == 8800-8fff, c800-cfff // 1100 0011 + * d3 <- 0x08 <- 1-00 0 == 8000-87ff, c000-c7ff // 1101 0011 MC6846 Internal I/O access (CS1 - active high) + + * c3 <- 0x07 <- 0-11 1 == 3800-3fff, 7800-7fff // 1100 0011 + * cb <- 0x06 <- 0-11 0 == 3000-37ff, 7000-77ff // 1100 1011 Set lamp data + * c6 <- 0x05 <- 0-10 1 == 2800-2fff, 6800-6fff // 1100 0110 start scan + * c5 <- 0x04 <- 0-10 0 == 2000-27ff, 6000-67ff // 1100 0101 read col + * c3 <- 0x03 <- 0-01 1 == 1800-1fff, 5800-5fff // 1100 0011 + * c3 <- 0x02 <- 0-01 0 == 1000-17ff, 5000-57ff // 1100 0011 + * c3 <- 0x01 <- 0-00 1 == 0800-0fff, 4800-4fff // 1100 0011 + * c3 <- 0x00 <- 0-00 0 == 0000-07ff, 4000-47ff // 1100 0011 + */ + map(0x0080, 0xffff).lrw8(NAME([this](address_space &space, offs_t offset) -> uint8_t + { + uint16_t addr = offset + 0x80; + uint8_t index = 0x10 | ((((addr & 0x8000) | ((addr & 0x3800) << 1)) >> 12) & 0x000f); // 0x10 | (((A15 | A13 | A12 | A11) >> 12) + uint8_t ret = 0; + LOGADEC("address_r %04x -> index %02x: %02x\n", offset + 0x80, index, memregion("ad_rom")->base ()[index]); + switch (memregion("ad_rom")->base ()[index]) + { + case 0xf3: + ret = memregion(M6800_TAG)->base ()[addr & 0x07ff]; + LOGROM(" - ROM %04x: %02x\n", addr & 0x7ff, ret); + break; + case 0xd3: + LOGIO(" - I/O read mc6846 %04x", addr & 0x07); + ret = m_mc6846->read(space, (offs_t)(addr & 0x07)); + LOGIO(": %02x\n", ret); + break; + case 0xc3: + break; // Idle + default: + logerror(" - unmapped read access at %04x through %02x\n", addr, memregion("ad_rom")->base ()[index]); + } + return ret; + }), + NAME( [this](address_space &space, offs_t offset, uint8_t data) + { + uint16_t addr = offset + 0x80; + uint8_t index = 0x10 | ((((addr & 0x8000) | ((addr & 0x3800) << 1)) >> 12) & 0x000f); // 0x10 | (((A15 | A13 | A12 | A11) >> 12) + LOGADEC("address_w %04x -> index %02x: %02x\n", offset + 0x80, index, memregion("ad_rom")->base ()[index]); + switch (memregion("ad_rom")->base ()[index]) + { + case 0xd3: + LOGIO(" - I/O write mc6846 %04x, %02x\n", addr & 0x07, data); + m_mc6846->write(space, (offs_t)(addr & 0x07), data); + break; + case 0xcb: // Leds + if (m_leds != data) + { + m_leds_cb(data); m_leds = data; + LOGLEDS(" - I/O write LEDs %04x, %02x\n", addr, data); + } + break; + case 0xc3: + break; // Idle + default: + logerror(" - unmapped write access at %04x, %02x through %02x\n", addr, data, memregion("ad_rom")->base ()[index]); + } + })); + // map(0xf800, 0xffff).rom().region(M6800_TAG,0); +} + +//------------------------------------------------- +// rom_region - device-specific ROM region +//------------------------------------------------- + +const tiny_rom_entry *alfaskop_s41_keyboard_device::device_rom_region() const +{ + return ROM_NAME( alfaskop_s41_kb ); +} diff --git a/src/mame/machine/alfaskop_s41_kb.h b/src/mame/machine/alfaskop_s41_kb.h new file mode 100644 index 00000000000..8ac29df5f40 --- /dev/null +++ b/src/mame/machine/alfaskop_s41_kb.h @@ -0,0 +1,48 @@ +// license:BSD-3-Clause +// copyright-holders:Joakim Larsson Edström +#ifndef MAME_MACHINE_ALFASKOP_S41_KB_H +#define MAME_MACHINE_ALFASKOP_S41_KB_H + +#pragma once + +#include "cpu/m6800/m6800.h" +#include "machine/mc6846.h" + +DECLARE_DEVICE_TYPE(ALFASKOP_S41_KB, alfaskop_s41_keyboard_device) + +class alfaskop_s41_keyboard_device : public device_t +{ +public: + auto txd_cb() { return m_txd_cb.bind(); } + auto leds_cb() { return m_leds_cb.bind(); } + + alfaskop_s41_keyboard_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock = 0); + + DECLARE_INPUT_CHANGED_MEMBER(key); + DECLARE_WRITE_LINE_MEMBER(rxd_w); + //DECLARE_WRITE_LINE_MEMBER(hold_w); + DECLARE_WRITE_LINE_MEMBER(rst_line_w); + +protected: + virtual void device_start() override; + virtual void device_add_mconfig(machine_config &config) override; + virtual ioport_constructor device_input_ports() const override; + virtual tiny_rom_entry const *device_rom_region() const override; + + required_device<m6802_cpu_device> m_mcu; + required_device<mc6846_device> m_mc6846; + required_ioport_array<6> m_rows; + devcb_write_line m_txd_cb; // Callback for KBD-> S41 + devcb_write8 m_leds_cb; // Callback for all 8 leds -> layout + + bool m_rxd_high; // state of Rx input line + bool m_txd_high; // state of Tx output line + bool m_hold; + uint16_t m_col_select; + uint8_t m_p1; + uint8_t m_leds; + + void alfaskop_s41_kb_mem(address_map &map); +}; + +#endif // MAME_MACHINE_ALFASKOP_S41_KB_H |