diff options
author | Dirk Best <mail@dirk-best.de> | 2024-03-19 13:34:55 +0100 |
---|---|---|
committer | Dirk Best <mail@dirk-best.de> | 2024-03-19 13:55:16 +0100 |
commit | c4b4da6755e7edd72120e0445333111c648b8666 (patch) | |
tree | 5239d12066f102380279b270c9fa526a5be8a196 | |
parent | b79289eff789a4be60cc47d7423a665b4e8700fe (diff) |
- Added dump of character generator ROM and Revision 0.08 firmware [Bitsavers]
- Initial screen rendering, but missing most attributes
- Implement keyboard [Dirk Best, Bitsavers]
- Start documenting PPI connections
Systems promoted to working
---------------------------
Visual 50
-rw-r--r-- | src/mame/visual/v50.cpp | 144 | ||||
-rw-r--r-- | src/mame/visual/v50_kbd.cpp | 262 | ||||
-rw-r--r-- | src/mame/visual/v50_kbd.h | 62 |
3 files changed, 447 insertions, 21 deletions
diff --git a/src/mame/visual/v50.cpp b/src/mame/visual/v50.cpp index 9dc73242e03..b238900af26 100644 --- a/src/mame/visual/v50.cpp +++ b/src/mame/visual/v50.cpp @@ -10,31 +10,34 @@ - D780C (Z80) - 2764 and 2732 EPROM - 2x TMM314APL-1 (1k RAM) - - X2210D NOVRAM (64x4) + - X2210D NOVRAM (64x4) (X2210 for REV A) - Intel P8253-5 PIT - D8255AC-5 PPI - 2x D8251AC USART - - SCN2672A + - SCN2672A (SCN2672 N for REV A) - 2673 - TMM2016P-2 (2k VRAM) - C68100 IC240-001R00 (character generator?) - 17.320 MHz XTAL TODO: - - Character generator ROM is undumped - - Keyboard (also not dumped) - - Screen rendering + - Screen attributes (reverse sometimes works) + - Smooth scroll - Screen brightness control - - PPI connections are unknown + - Most PPI connections are unknown - AUX port Notes: - - PCB marked "PA015 REV B 1183" + - PCB marked "PA015-A REV A" for R08 firmware + - PCB marked "PA015 REV B 1183" for R11 firmware + - Use TERM=vi50 and disable AUTO LF/CR in setup mode ***************************************************************************/ #include "emu.h" +#include "v50_kbd.h" + #include "bus/rs232/rs232.h" #include "cpu/z80/z80.h" #include "machine/i8251.h" @@ -44,6 +47,7 @@ #include "machine/x2212.h" #include "video/scn2674.h" +#include "emupal.h" #include "screen.h" @@ -63,8 +67,11 @@ public: m_novram(*this, "novram"), m_pit(*this, "pit"), m_screen(*this, "screen"), + m_palette(*this, "palette"), m_pvtc(*this, "pvtc"), - m_usart(*this, "usart%u", 0U) + m_usart(*this, "usart%u", 0U), + m_vram(*this, "vram"), + m_chargen(*this, "chargen") { } void visual50(machine_config &config); @@ -78,8 +85,11 @@ private: required_device<x2210_device> m_novram; required_device<pit8253_device> m_pit; required_device<screen_device> m_screen; + required_device<palette_device> m_palette; required_device<scn2672_device> m_pvtc; required_device_array<i8251_device, 2> m_usart; + required_shared_ptr<uint8_t> m_vram; + required_region_ptr<uint8_t> m_chargen; void mem_map(address_map &map); void io_map(address_map &map); @@ -87,6 +97,10 @@ private: SCN2672_DRAW_CHARACTER_MEMBER(draw_character); + void ppi_porta_w(uint8_t data); + void ppi_portb_w(uint8_t data); + void ppi_portc_w(uint8_t data); + uint8_t recall_r(); void recall_w(uint8_t data); uint8_t store_r(); @@ -121,7 +135,7 @@ void visual50_state::io_map(address_map &map) void visual50_state::char_map(address_map &map) { - map(0x000, 0x7ff).ram(); + map(0x000, 0x7ff).ram().share("vram"); } @@ -139,13 +153,82 @@ INPUT_PORTS_END SCN2672_DRAW_CHARACTER_MEMBER( visual50_state::draw_character ) { + uint16_t data = m_chargen[(charcode & 0x7f) << 4 | linecount]; + const pen_t *const pen = m_palette->pens(); + + if (BIT(charcode, 7)) + data = ~data; // wrong + + if (cursor) + data = ~data; + + // foreground/background colors + rgb_t fg = pen[2]; + rgb_t bg = pen[0]; + + // draw 9 pixels of the character + for (int i = 0; i < 9; i++) + bitmap.pix(y, x + i) = BIT(data, 8 - i) ? fg : bg; } +static const gfx_layout char_layout = +{ + 8, 12, + RGN_FRAC(1,1), + 1, + { 0 }, + { STEP8(0, 1) }, + { STEP16(0, 8) }, + 8 * 16 +}; + +static GFXDECODE_START( chars ) + GFXDECODE_ENTRY("chargen", 0, char_layout, 0, 1) +GFXDECODE_END + //************************************************************************** // MACHINE EMULATION //************************************************************************** +void visual50_state::ppi_porta_w(uint8_t data) +{ + // 7------- unknown + // -6------ unknown + // --5----- unknown + // ---43210 brightness (0x00 = brightest, 0x1f = darkest) + + logerror("porta_w: %02x\n", data); +} + +void visual50_state::ppi_portb_w(uint8_t data) +{ + // 7------- unknown + // -6------ monitor mode + // --5----- unknown + // ---4---- reverse video + // ----3--- unknown + // -----2-- local echo + // ------1- unknown + // -------0 unknown + + logerror("portb_w: %02x\n", data); +} + +void visual50_state::ppi_portc_w(uint8_t data) +{ + // 7------- unknown + // -6------ rs232/current loop + // --5----- unknown + // ---4---- unknown, toggles + // ----3--- reverse video + // -----2-- unknown + // ------1- unknown + // -------0 unknown + + logerror("portc_w: %02x\n", data); +} + uint8_t visual50_state::recall_r() { if (!machine().side_effects_disabled()) @@ -190,7 +273,7 @@ void visual50_state::machine_reset() //************************************************************************** -// MACHINE DEFINTIONS +// MACHINE DEFINITIONS //************************************************************************** void visual50_state::visual50(machine_config &config) @@ -212,13 +295,19 @@ void visual50_state::visual50(machine_config &config) m_pit->out_handler<1>().append(m_usart[1], FUNC(i8251_device::write_txc)); m_pit->out_handler<2>().set(m_usart[0], FUNC(i8251_device::write_txc)); // or rxc? - I8255(config, "ppi"); + i8255_device &ppi(I8255(config, "ppi")); + ppi.out_pa_callback().set(FUNC(visual50_state::ppi_porta_w)); + ppi.out_pb_callback().set(FUNC(visual50_state::ppi_portb_w)); + ppi.out_pc_callback().set(FUNC(visual50_state::ppi_portc_w)); SCREEN(config, m_screen, SCREEN_TYPE_RASTER); - m_screen->set_color(rgb_t::amber()); // unknown color m_screen->set_raw(17.320_MHz_XTAL, 900, 0, 720, 321, 0, 300); m_screen->set_screen_update(m_pvtc, FUNC(scn2672_device::screen_update)); + PALETTE(config, m_palette, palette_device::MONOCHROME_HIGHLIGHT); + + GFXDECODE(config, "gfxdecode", m_palette, chars); + SCN2672(config, m_pvtc, 17.320_MHz_XTAL / 9); m_pvtc->intr_callback().set_inputline(m_maincpu, INPUT_LINE_NMI); m_pvtc->set_screen("screen"); @@ -226,19 +315,24 @@ void visual50_state::visual50(machine_config &config) m_pvtc->set_display_callback(FUNC(visual50_state::draw_character)); m_pvtc->set_addrmap(0, &visual50_state::char_map); - // mainport + // modem port I8251(config, m_usart[0], 17.320_MHz_XTAL / 8); // divider not verified m_usart[0]->rxrdy_handler().set("mainirq", FUNC(input_merger_device::in_w<0>)); - m_usart[0]->txd_handler().set("mainport", FUNC(rs232_port_device::write_txd)); - m_usart[0]->rts_handler().set("mainport", FUNC(rs232_port_device::write_rts)); + m_usart[0]->txd_handler().set("modem", FUNC(rs232_port_device::write_txd)); + m_usart[0]->rts_handler().set("modem", FUNC(rs232_port_device::write_rts)); - rs232_port_device &mainport(RS232_PORT(config, "mainport", default_rs232_devices, nullptr)); - mainport.rxd_handler().set(m_usart[0], FUNC(i8251_device::write_rxd)); - mainport.cts_handler().set(m_usart[0], FUNC(i8251_device::write_cts)); + rs232_port_device &modem(RS232_PORT(config, "modem", default_rs232_devices, nullptr)); + modem.rxd_handler().set(m_usart[0], FUNC(i8251_device::write_rxd)); + modem.cts_handler().set(m_usart[0], FUNC(i8251_device::write_cts)); // keyboard I8251(config, m_usart[1], 17.320_MHz_XTAL / 8); // divider not verified m_usart[1]->rxrdy_handler().set("mainirq", FUNC(input_merger_device::in_w<1>)); + m_usart[1]->txd_handler().set("kbd", FUNC(v50_kbd_device::rxd_w)); + + v50_kbd_device &kbd(V50_KBD(config, "kbd")); + kbd.txd_cb().set(m_usart[1], FUNC(i8251_device::write_rxd)); + kbd.cts_cb().set(m_usart[1], FUNC(i8251_device::write_cts)); } @@ -248,8 +342,16 @@ void visual50_state::visual50(machine_config &config) ROM_START( visual50 ) ROM_REGION(0x3000, "maincpu", 0) - ROM_LOAD("e244-012.bin", 0x0000, 0x2000, CRC(755f0722) SHA1(80b90882c52c9ddcc1cf455c9195d4e1ccda8ce8)) - ROM_LOAD("e262-055.bin", 0x2000, 0x1000, CRC(90a142e8) SHA1(5f4c403b7ab09dcb3cfdc8f57f65e0a52992feed)) + ROM_DEFAULT_BIOS("r11") + ROM_SYSTEM_BIOS(0, "r08", "Revision 0.08") + ROMX_LOAD("e244-012_r08.u2", 0x0000, 0x2000, CRC(3931796d) SHA1(1f71b977e021a2f5eb5437c4056991cc7601768b), ROM_BIOS(0)) + ROMX_LOAD("e262-055_r08.u3", 0x2000, 0x1000, CRC(20067dc0) SHA1(bf8051117876246b3c3ba88c1c750e146800ca0b), ROM_BIOS(0)) + ROM_SYSTEM_BIOS(1, "r11", "Revision 0.11") + ROMX_LOAD("e244-012_r11.u2", 0x0000, 0x2000, CRC(755f0722) SHA1(80b90882c52c9ddcc1cf455c9195d4e1ccda8ce8), ROM_BIOS(1)) + ROMX_LOAD("e262-055_r11.u3", 0x2000, 0x1000, CRC(90a142e8) SHA1(5f4c403b7ab09dcb3cfdc8f57f65e0a52992feed), ROM_BIOS(1)) + + ROM_REGION(0x800, "chargen", 0) + ROM_LOAD("ic240-001r00.u32", 0x000, 0x800, CRC(5041acd0) SHA1(ef3d952140c33c6cf2712463b53e8fca4a5400f4)) ROM_END @@ -261,4 +363,4 @@ ROM_END //************************************************************************** // YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS -COMP( 1983, visual50, 0, 0, visual50, visual50, visual50_state, empty_init, "Visual Technology", "Visual 50", MACHINE_NOT_WORKING | MACHINE_NO_SOUND ) +COMP( 1983, visual50, 0, 0, visual50, visual50, visual50_state, empty_init, "Visual Technology", "Visual 50", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/visual/v50_kbd.cpp b/src/mame/visual/v50_kbd.cpp new file mode 100644 index 00000000000..9aa52e80c13 --- /dev/null +++ b/src/mame/visual/v50_kbd.cpp @@ -0,0 +1,262 @@ +// license: BSD-3-Clause +// copyright-holders: Dirk Best +/*************************************************************************** + + Visual 50 Keyboard + + Hardware: + - B125 20-08048-131 SMA3051 (hard to read) + - 48-300-007 XTAL (apparently that's 4.608 MHz) + - D2758 EPROM labeled "241" + - Buzzer + + Notes: + - Key Tronic A65-02428-001 PCB-201A + - There is an alternate version using an 8048 with embedded ROM, + part number 20-08048-161 + +***************************************************************************/ + +#include "emu.h" +#include "v50_kbd.h" +#include "speaker.h" + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +DEFINE_DEVICE_TYPE(V50_KBD, v50_kbd_device, "v50_kbd", "Visual 50 Keyboard") + +v50_kbd_device::v50_kbd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, V50_KBD, tag, owner, 0U), + m_mcu(*this, "mcu"), + m_buzzer(*this, "buzzer"), + m_keys(*this, "row_%x", 0U), + m_txd_cb(*this), + m_cts_cb(*this) +{ +} + + +//************************************************************************** +// ROM DEFINITIONS +//************************************************************************** + +ROM_START( firmware ) + ROM_REGION(0x400, "mcu", 0) + ROM_LOAD("241.bin", 0x000, 0x400, CRC(244ee196) SHA1(5224887097004894ab9f4876f3217f3da08801da)) +ROM_END + +const tiny_rom_entry *v50_kbd_device::device_rom_region() const +{ + return ROM_NAME( firmware ); +} + + +//************************************************************************** +// MACHINE DEFINITIONS +//************************************************************************** + +void v50_kbd_device::device_add_mconfig(machine_config &config) +{ + I8048(config, m_mcu, 4.608_MHz_XTAL); // needed for the correct baud rate + m_mcu->p1_in_cb().set(FUNC(v50_kbd_device::p1_r)); + m_mcu->p2_out_cb().set(FUNC(v50_kbd_device::p2_w)); + m_mcu->prog_out_cb().set(FUNC(v50_kbd_device::prog_w)); + + SPEAKER(config, "mono").front_center(); + + BEEP(config, m_buzzer, 786); // unknown frequency + m_buzzer->add_route(ALL_OUTPUTS, "mono", 0.5); +} + + +//************************************************************************** +// INPUT PORT DEFINITIONS +//************************************************************************** + +static INPUT_PORTS_START( keyboard ) + PORT_START("row_0") + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_RCONTROL) PORT_NAME("FUNCTION") + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1) // or RSHIFT? + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) // or LSHIFT? + PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_SHIFT_2) + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) + PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA_PAD) PORT_CHAR(UCHAR_MAMEKEY(COMMA_PAD)) + PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED) // 94 + PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) PORT_NAME(u8"\u2193 AUX") + + PORT_START("row_1") + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD)) + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(MINUS_PAD)) + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_PLUS_PAD) PORT_NAME("Keypad .") + PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER_PAD) PORT_CHAR(UCHAR_MAMEKEY(ENTER_PAD)) + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(2_PAD)) PORT_NAME("Keypad 2 CP") + PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD)) PORT_NAME("Keypad 5 EL") + PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) PORT_NAME(u8"\u2191 F3") + PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) PORT_NAME(u8"\u2192 F2") + + PORT_START("row_2") + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_CANCEL) PORT_NAME("BREAK") + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD)) + PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(6_PAD)) PORT_NAME("Keypad 6 EP") + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD)) PORT_NAME("Keypad 3 DL") + PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_DEL) PORT_CHAR(UCHAR_MAMEKEY(DEL)) + PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) PORT_NAME(u8"\u2190 F1") + PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED) // f0 + + PORT_START("row_3") + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(7_PAD)) + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_8_PAD) PORT_CHAR(UCHAR_MAMEKEY(8_PAD)) PORT_NAME("Keypad 8 HM") + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CHAR(10) PORT_NAME("LINE FEED") + PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_4_PAD) PORT_CHAR(UCHAR_MAMEKEY(4_PAD)) PORT_NAME("Keypad 4 EF") + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD)) PORT_NAME("Keypad 1 IL") + PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O') + PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED) // ec + PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED) // e8 + + PORT_START("row_4") + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNUSED) // 98 + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNUSED) // 9c + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L') + PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) + PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U') + PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED) // e4 + PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED) // e0 + + PORT_START("row_5") + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNUSED) // 00 + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N') + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J') + PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P') + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K') + PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T') + PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED) // dc + PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED) // d8 + + PORT_START("row_6") + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B') + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V') + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G') + PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I') + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H') + PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E') + PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED) // d4 + PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED) // d0 + + PORT_START("row_7") + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C') + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X') + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D') + PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R') + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F') + PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_TAB) PORT_CHAR(9) + PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED) // cc + PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED) // c8 + + PORT_START("row_8") + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('&') + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('*') + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') + PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NO SCROLL") + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S') + PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC)) + PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED) // c4 + PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LALT) PORT_NAME("SET-UP") + + PORT_START("row_9") + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('^') + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') + PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`') PORT_CHAR('~') + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') PORT_CHAR('|') + PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') PORT_CHAR('"') + PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_CHAR('+') + PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y') + + PORT_START("row_a") + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') + PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('_') + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W') + PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR(':') + PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR(')') + PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}') + + PORT_START("row_b") + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('@') + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M') + PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR('(') + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q') + PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A') + PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z') + PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{') + + PORT_START("row_c") + PORT_BIT(0xff, 0xff, IPT_UNUSED) + + PORT_START("row_d") + PORT_BIT(0xff, 0xff, IPT_UNUSED) + + PORT_START("row_e") + PORT_BIT(0xff, 0xff, IPT_UNUSED) + + PORT_START("row_f") + PORT_BIT(0xff, 0xff, IPT_UNUSED) +INPUT_PORTS_END + +ioport_constructor v50_kbd_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( keyboard ); +} + + +//************************************************************************** +// MACHINE EMULATION +//************************************************************************** + +void v50_kbd_device::device_start() +{ + // register for save states + save_item(NAME(m_prog)); + save_item(NAME(m_key_row)); +} + +void v50_kbd_device::device_reset() +{ + // always use external rom + m_mcu->set_input_line(MCS48_INPUT_EA, CLEAR_LINE); + + // signal we are connected to the host + m_cts_cb(0); +} + +void v50_kbd_device::rxd_w(int state) +{ + m_mcu->set_input_line(MCS48_INPUT_IRQ, state ? CLEAR_LINE : ASSERT_LINE); +} + +uint8_t v50_kbd_device::p1_r() +{ + return m_keys[m_key_row]->read(); +} + +void v50_kbd_device::p2_w(uint8_t data) +{ + m_buzzer->set_state(BIT(~data, 6)); + m_txd_cb(BIT(data, 7)); +} + +void v50_kbd_device::prog_w(int state) +{ + // set new keyboard row from p2 on transition 0->1 + if (!m_prog && bool(state)) + m_key_row = m_mcu->p2_r() & 0x0f; + + m_prog = bool(state); +} diff --git a/src/mame/visual/v50_kbd.h b/src/mame/visual/v50_kbd.h new file mode 100644 index 00000000000..9d2a3584c33 --- /dev/null +++ b/src/mame/visual/v50_kbd.h @@ -0,0 +1,62 @@ +// license: BSD-3-Clause +// copyright-holders: Dirk Best +/*************************************************************************** + + Visual 50 Keyboard + +***************************************************************************/ + +#ifndef MAME_VISUAL_V50_KBD_H +#define MAME_VISUAL_V50_KBD_H + +#pragma once + +#include "cpu/mcs48/mcs48.h" +#include "sound/beep.h" + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +class v50_kbd_device : public device_t +{ +public: + // construction/destruction + v50_kbd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + + // callbacks + auto txd_cb() { return m_txd_cb.bind(); } + auto cts_cb() { return m_cts_cb.bind(); } + + // from host + void rxd_w(int state); + +protected: + // device_t overrides + virtual const tiny_rom_entry *device_rom_region() const override; + virtual void device_add_mconfig(machine_config &config) override; + virtual ioport_constructor device_input_ports() const override; + virtual void device_start() override; + virtual void device_reset() override; + +private: + required_device<i8048_device> m_mcu; + required_device<beep_device> m_buzzer; + required_ioport_array<16> m_keys; + + devcb_write_line m_txd_cb; + devcb_write_line m_cts_cb; + + bool m_prog = true; + uint8_t m_key_row = 0x0f; + + uint8_t p1_r(); + void p2_w(uint8_t data); + void prog_w(int state); +}; + +// device type definition +DECLARE_DEVICE_TYPE(V50_KBD, v50_kbd_device) + +#endif // MAME_VISUAL_V50_KBD_H |