diff options
Diffstat (limited to 'src/devices/machine/ie15.cpp')
-rw-r--r-- | src/devices/machine/ie15.cpp | 281 |
1 files changed, 187 insertions, 94 deletions
diff --git a/src/devices/machine/ie15.cpp b/src/devices/machine/ie15.cpp index 65a71ae23c3..29ecfcb581f 100644 --- a/src/devices/machine/ie15.cpp +++ b/src/devices/machine/ie15.cpp @@ -12,24 +12,30 @@ ****************************************************************************/ #include "emu.h" -#include "machine/ie15.h" +#include "ie15.h" #include "emupal.h" #include "ie15.lh" -#define VERBOSE_DBG 1 /* general debug messages */ +#define LOG_RAM (1U << 1) +#define LOG_CPU (1U << 2) +#define LOG_KBD (1U << 3) +#define LOG_SCANLINE (1U << 4) +#define LOG_SERIAL (1U << 5) -#define DBG_LOG(N,M,A) \ - do { \ - if(VERBOSE_DBG>=N) \ - { \ - if( M ) \ - logerror("%11.6f at %s: %-10s",machine().time().as_double(),machine().describe_context(),(char*)M ); \ - logerror A; \ - } \ - } while (0) +#define VERBOSE (LOG_GENERAL|LOG_KBD) +//#define LOG_OUTPUT_FUNC printf +#include "logmacro.h" + +#define LOGM(...) LOGMASKED(LOG_RAM, __VA_ARGS__) +#define LOGCPU(...) LOGMASKED(LOG_CPU, __VA_ARGS__) +#define LOGKBD(...) LOGMASKED(LOG_KBD, __VA_ARGS__) +#define LOGSERIAL(...) LOGMASKED(LOG_SERIAL, __VA_ARGS__) + + +#define _PRINT(ch) (std::isprint(ch & 127)?(ch & 127):' ') ie15_device::ie15_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) @@ -39,10 +45,26 @@ ie15_device::ie15_device(const machine_config &mconfig, device_type type, const , m_p_videoram(*this, "video") , m_p_chargen(*this, "chargen") , m_beeper(*this, "beeper") - , m_rs232(*this, "rs232") , m_screen(*this, "screen") , m_keyboard(*this, "keyboard") , m_io_keyboard(*this, "io_keyboard") + , m_lat_led(*this, "lat_led") + , m_nr_led(*this, "nr_led") + , m_pch_led(*this, "pch_led") + , m_dup_led(*this, "dup_led") + , m_lin_led(*this, "lin_led") + , m_red_led(*this, "red_led") + , m_sdv_led(*this, "sdv_led") + , m_prd_led(*this, "prd_led") + , m_rs232_conn_txd_handler(*this) + , m_rs232_conn_dtr_handler(*this) + , m_rs232_conn_rts_handler(*this) + // Until the UART is implemented + , m_rs232_txbaud(*this, "RS232_TXBAUD") + , m_rs232_rxbaud(*this, "RS232_RXBAUD") + , m_rs232_databits(*this, "RS232_DATABITS") + , m_rs232_parity(*this, "RS232_PARITY") + , m_rs232_stopbits(*this, "RS232_STOPBITS") { } @@ -52,14 +74,14 @@ ie15_device::ie15_device(const machine_config &mconfig, const char *tag, device_ } -READ8_MEMBER(ie15_device::mem_r) +uint8_t ie15_device::mem_r() { uint8_t ret; ret = m_p_videoram[m_video.ptr1]; if ((machine().debug_flags & DEBUG_FLAG_ENABLED) != 0 && m_video.ptr1 >= SCREEN_PAGE) { - DBG_LOG(2, "memory", ("R @ %03x == %02x\n", m_video.ptr1, ret)); + LOGM("memory R @ %03x == %02x\n", m_video.ptr1, ret); } m_video.ptr1++; m_video.ptr1 &= 0xfff; @@ -67,42 +89,42 @@ READ8_MEMBER(ie15_device::mem_r) return ret; } -WRITE8_MEMBER(ie15_device::mem_w) +void ie15_device::mem_w(uint8_t data) { if ((m_latch ^= 1) == 0) { if ((machine().debug_flags & DEBUG_FLAG_ENABLED) != 0 && m_video.ptr1 >= SCREEN_PAGE) { - DBG_LOG(2, "memory", ("W @ %03x <- %02x\n", m_video.ptr1, data)); + LOGM("memory W @ %03x <- %02x\n", m_video.ptr1, data); } m_p_videoram[m_video.ptr1++] = data; m_video.ptr1 &= 0xfff; } } -WRITE8_MEMBER(ie15_device::mem_addr_inc_w) +void ie15_device::mem_addr_inc_w(uint8_t data) { if ((machine().debug_flags & DEBUG_FLAG_ENABLED) != 0) { - DBG_LOG(2, "memory", ("++ %03x\n", m_video.ptr1)); + LOGM("memory addr ++ %03x\n", m_video.ptr1); } m_video.ptr1++; m_video.ptr1 &= 0xfff; if (m_video.enable) m_video.ptr2 = m_video.ptr1; } -WRITE8_MEMBER(ie15_device::mem_addr_dec_w) +void ie15_device::mem_addr_dec_w(uint8_t data) { if ((machine().debug_flags & DEBUG_FLAG_ENABLED) != 0) { - DBG_LOG(2, "memory", ("-- %03x\n", m_video.ptr1)); + LOGM("memory addr -- %03x\n", m_video.ptr1); } m_video.ptr1--; m_video.ptr1 &= 0xfff; if (m_video.enable) m_video.ptr2 = m_video.ptr1; } -WRITE8_MEMBER(ie15_device::mem_addr_lo_w) +void ie15_device::mem_addr_lo_w(uint8_t data) { uint16_t tmp = m_video.ptr1; @@ -110,13 +132,13 @@ WRITE8_MEMBER(ie15_device::mem_addr_lo_w) tmp |= ((data >> 4) & 0xf); if ((machine().debug_flags & DEBUG_FLAG_ENABLED) != 0) { - DBG_LOG(2, "memory", ("lo %03x <- %02x = %03x\n", m_video.ptr1, data, tmp)); + LOGM("memory addr lo %03x <- %02x = %03x\n", m_video.ptr1, data, tmp); } m_video.ptr1 = tmp; if (m_video.enable) m_video.ptr2 = tmp; } -WRITE8_MEMBER(ie15_device::mem_addr_hi_w) +void ie15_device::mem_addr_hi_w(uint8_t data) { uint16_t tmp = m_video.ptr1; @@ -124,7 +146,7 @@ WRITE8_MEMBER(ie15_device::mem_addr_hi_w) tmp |= (data << 4); if ((machine().debug_flags & DEBUG_FLAG_ENABLED) != 0) { - DBG_LOG(2, "memory", ("hi %03x <- %02x = %03x\n", m_video.ptr1, data, tmp)); + LOGM("memory addr hi %03x <- %02x = %03x\n", m_video.ptr1, data, tmp); } m_video.ptr1 = tmp; if (m_video.enable) m_video.ptr2 = tmp; @@ -135,100 +157,95 @@ TIMER_CALLBACK_MEMBER(ie15_device::ie15_beepoff) m_beeper->set_state(0); } -WRITE8_MEMBER(ie15_device::beep_w) +void ie15_device::beep_w(uint8_t data) { uint16_t length = (m_long_beep & IE_TRUE) ? 150 : 400; if ((machine().debug_flags & DEBUG_FLAG_ENABLED) != 0) { - DBG_LOG(1, "beep", ("(%s)\n", m_long_beep ? "short" : "long")); + LOG("beep (%s)\n", m_long_beep ? "short" : "long"); } - machine().scheduler().timer_set(attotime::from_msec(length), timer_expired_delegate(FUNC(ie15_device::ie15_beepoff),this)); + m_beepoff_timer->adjust(attotime::from_msec(length)); m_beeper->set_state(1); } /* keyboard */ // active high -READ8_MEMBER(ie15_device::kb_r) +uint8_t ie15_device::kb_r() { - DBG_LOG(2, "keyboard", ("R %02X '%c'\n", m_kb_data, m_kb_data < 0x20 ? ' ' : m_kb_data)); + LOGKBD("keyboard data R %02X '%c'\n", m_kb_data, _PRINT(m_kb_data)); return m_kb_data; } // active low -READ8_MEMBER(ie15_device::kb_ready_r) +uint8_t ie15_device::kb_ready_r() { m_kb_flag &= IE_TRUE; if (m_kb_flag != m_kb_flag0) { - DBG_LOG(2, "keyboard", ("? %c\n", m_kb_flag ? 'n' : 'y')); + LOGKBD("keyboard ready? %c\n", m_kb_flag ? 'n' : 'y'); m_kb_flag0 = m_kb_flag; } return m_kb_flag; } // active low -WRITE8_MEMBER(ie15_device::kb_ready_w) +void ie15_device::kb_ready_w(uint8_t data) { - DBG_LOG(2, "keyboard", ("clear ready\n")); + LOGKBD("keyboard clear ready\n"); m_kb_flag = IE_TRUE | ie15_keyboard_device::IE_KB_ACK; } // active high; active = interpret controls, inactive = display controls -READ8_MEMBER(ie15_device::kb_s_red_r) +uint8_t ie15_device::kb_s_red_r() { return m_io_keyboard->read() & ie15_keyboard_device::IE_KB_RED ? IE_TRUE : 0; } // active high; active = setup mode -READ8_MEMBER(ie15_device::kb_s_sdv_r) +uint8_t ie15_device::kb_s_sdv_r() { - return m_kb_control & ie15_keyboard_device::IE_KB_SDV ? IE_TRUE : 0; + return m_kbd_sdv ? IE_TRUE : 0; } // active high; active = keypress detected on aux keypad -READ8_MEMBER(ie15_device::kb_s_dk_r) +uint8_t ie15_device::kb_s_dk_r() { return m_kb_control & ie15_keyboard_device::IE_KB_DK ? IE_TRUE : 0; } // active low; active = full duplex, inactive = half duplex -READ8_MEMBER(ie15_device::kb_s_dupl_r) +uint8_t ie15_device::kb_s_dupl_r() { return m_io_keyboard->read() & ie15_keyboard_device::IE_KB_DUP ? IE_TRUE : 0; } // active high; active = on-line, inactive = local editing -READ8_MEMBER(ie15_device::kb_s_lin_r) +uint8_t ie15_device::kb_s_lin_r() { return m_io_keyboard->read() & ie15_keyboard_device::IE_KB_LIN ? IE_TRUE : 0; } -/* serial port */ - -void ie15_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(ie15_device::hblank_onoff_tick) { - switch (id) + if (m_hblank) // Transitioning from in blanking to out of blanking { - case TIMER_HBLANK: - if (m_hblank) // Transitioning from in blanking to out of blanking - { - m_hblank = 0; - m_hblank_timer->adjust(m_screen->time_until_pos((m_vpos + 1) % IE15_TOTAL_VERT, 0)); - scanline_callback(); - } - else // Transitioning from out of blanking to in blanking - { - m_hblank = 1; - m_hblank_timer->adjust(m_screen->time_until_pos(m_vpos, IE15_HORZ_START)); - } - break; + m_hblank = 0; + m_hblank_timer->adjust(m_screen->time_until_pos((m_vpos + 1) % IE15_TOTAL_VERT, 0)); + scanline_callback(); + } + else // Transitioning from out of blanking to in blanking + { + m_hblank = 1; + m_hblank_timer->adjust(m_screen->time_until_pos(m_vpos, IE15_HORZ_START)); } } -WRITE_LINE_MEMBER(ie15_device::serial_rx_callback) +/* serial port */ + +void ie15_device::rs232_conn_rxd_w(int state) { device_serial_interface::rx_w(state); } @@ -243,7 +260,7 @@ void ie15_device::rcv_complete() void ie15_device::tra_callback() { uint8_t bit = transmit_register_get_data_bit(); - m_rs232->write_txd(bit); + m_rs232_conn_txd_handler(bit); } void ie15_device::tra_complete() @@ -252,39 +269,57 @@ void ie15_device::tra_complete() } // active low -READ8_MEMBER(ie15_device::serial_rx_ready_r) +uint8_t ie15_device::serial_rx_ready_r() { return m_serial_rx_ready; } // active high -READ8_MEMBER(ie15_device::serial_tx_ready_r) +uint8_t ie15_device::serial_tx_ready_r() { return m_serial_tx_ready; } // not called unless data are ready -READ8_MEMBER(ie15_device::serial_r) +uint8_t ie15_device::serial_r() { m_serial_rx_ready = IE_TRUE; - DBG_LOG(1,"serial",("R %02X '%c'\n", m_serial_rx_char, m_serial_rx_char < 0x20?' ':m_serial_rx_char&127)); + LOGSERIAL("serial R %02X '%c'\n", m_serial_rx_char, _PRINT(m_serial_rx_char)); return m_serial_rx_char; } -WRITE8_MEMBER(ie15_device::serial_w) +void ie15_device::serial_w(uint8_t data) { - DBG_LOG(1, "serial", ("W %02X '%c'\n", data, data < 0x20 ? ' ' : data & 127)); + LOGSERIAL("serial W %02X '%c'\n", data, _PRINT(data)); m_serial_tx_ready = IE_FALSE; transmit_register_setup(data); } -WRITE8_MEMBER(ie15_device::serial_speed_w) +void ie15_device::serial_speed_w(uint8_t data) { return; } -READ8_MEMBER(ie15_device::flag_r) +void ie15_device::update_serial(int state) +{ + int startbits = 1; + int databits = m_rs232_databits->read(); + parity_t parity_table[] = { PARITY_NONE, PARITY_ODD, PARITY_EVEN, PARITY_MARK, PARITY_SPACE }; + parity_t parity = parity_table[m_rs232_parity->read()]; + stop_bits_t stopbits_table[] = { STOP_BITS_1, STOP_BITS_2 }; + stop_bits_t stopbits = stopbits_table[m_rs232_stopbits->read()]; + + set_data_frame(startbits, databits, parity, stopbits); + + int txbaud = m_rs232_txbaud->read(); + set_tra_rate(txbaud); + + int rxbaud = m_rs232_rxbaud->read(); + set_rcv_rate(rxbaud); +} + +uint8_t ie15_device::flag_r(offs_t offset) { switch (offset) { @@ -301,12 +336,12 @@ READ8_MEMBER(ie15_device::flag_r) } if (machine().debug_flags & DEBUG_FLAG_ENABLED) { - DBG_LOG(2, "flag", ("read %d: ?\n", offset)); + LOGCPU("flag read %d: ?\n", offset); } return 0; } -WRITE8_MEMBER(ie15_device::flag_w) +void ie15_device::flag_w(offs_t offset, uint8_t data) { switch (offset) { @@ -324,13 +359,14 @@ WRITE8_MEMBER(ie15_device::flag_w) break; case 4: m_kb_ruslat = data; + m_keyboard->set_ruslat(!!data); break; default: break; } if ((machine().debug_flags & DEBUG_FLAG_ENABLED) != 0 && !offset) { - DBG_LOG(2, "flag", ("%sset %d\n", data ? "" : "re", offset)); + LOGCPU("flag %sset %d\n", data ? "" : "re", offset); } } @@ -375,12 +411,51 @@ INPUT_PORTS_START( ie15 ) PORT_DIPNAME(ie15_keyboard_device::IE_KB_LIN, ie15_keyboard_device::IE_KB_LIN, "LIN (Online)") PORT_DIPSETTING(0x00, "Off") PORT_DIPSETTING(ie15_keyboard_device::IE_KB_LIN, "On") + + // Until the UART is implemented + PORT_START("RS232_RXBAUD") + PORT_CONFNAME(0xffff, 9600, "RX Baud") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, FUNC(ie15_device::update_serial)) + PORT_CONFSETTING(300, "300") + PORT_CONFSETTING(600, "600") + PORT_CONFSETTING(1200, "1200") + PORT_CONFSETTING(2400, "2400") + PORT_CONFSETTING(4800, "4800") + PORT_CONFSETTING(9600, "9600") + PORT_CONFSETTING(19200, "19200") + + PORT_START("RS232_TXBAUD") + PORT_CONFNAME(0xffff, 9600, "TX Baud") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, FUNC(ie15_device::update_serial)) + PORT_CONFSETTING(300, "300") + PORT_CONFSETTING(600, "600") + PORT_CONFSETTING(1200, "1200") + PORT_CONFSETTING(2400, "2400") + PORT_CONFSETTING(4800, "4800") + PORT_CONFSETTING(9600, "9600") + PORT_CONFSETTING(19200, "19200") + + PORT_START("RS232_DATABITS") + PORT_CONFNAME(0xf, 8, "Data Bits") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, FUNC(ie15_device::update_serial)) + PORT_CONFSETTING(7, "7") + PORT_CONFSETTING(8, "8") + + PORT_START("RS232_PARITY") + PORT_CONFNAME(0x7, 0, "Parity") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, FUNC(ie15_device::update_serial)) + PORT_CONFSETTING(0, "None") + PORT_CONFSETTING(1, "Odd") + PORT_CONFSETTING(2, "Even") + PORT_CONFSETTING(3, "Mark") + PORT_CONFSETTING(4, "Space") + + PORT_START("RS232_STOPBITS") + PORT_CONFNAME(0x3, 1, "Stop Bits") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, FUNC(ie15_device::update_serial)) + PORT_CONFSETTING(1, "1") + PORT_CONFSETTING(2, "2") + INPUT_PORTS_END -WRITE16_MEMBER( ie15_device::kbd_put ) +void ie15_device::kbd_put(uint16_t data) { - DBG_LOG(2,"keyboard",("W %02X<-%02X '%c' %02X (%c)\n", m_kb_data, data, 'x' /* data < 0x20 ? ' ' : (data & 255) */, - m_kb_flag, m_kb_flag ? 'n' : 'y')); + LOGKBD("keyboard data W %02X<-%02X '%c' %02X (%c)\n", m_kb_data, data, _PRINT(data), m_kb_flag, m_kb_flag ? 'n' : 'y'); m_kb_control = (data >> 8) & 255; // send new key only when firmware has processed previous one if (m_kb_flag == IE_TRUE) @@ -390,11 +465,26 @@ WRITE16_MEMBER( ie15_device::kbd_put ) } } +void ie15_device::kbd_sdv(int state) +{ + m_kbd_sdv = state; +} + void ie15_device::device_start() { - m_hblank_timer = timer_alloc(TIMER_HBLANK); + m_lat_led.resolve(); + m_nr_led.resolve(); + m_pch_led.resolve(); + m_dup_led.resolve(); + m_lin_led.resolve(); + m_red_led.resolve(); + m_sdv_led.resolve(); + m_prd_led.resolve(); + + m_hblank_timer = timer_alloc(FUNC(ie15_device::hblank_onoff_tick), this); m_hblank_timer->adjust(attotime::never); + m_beepoff_timer = timer_alloc(FUNC(ie15_device::ie15_beepoff), this); m_video.ptr1 = m_video.ptr2 = m_latch = 0; m_tmpbmp = std::make_unique<uint32_t[]>(IE15_TOTAL_HORZ * IE15_TOTAL_VERT); @@ -402,9 +492,12 @@ void ie15_device::device_start() void ie15_device::device_reset() { - memset(&m_video, 0, sizeof(m_video)); + update_serial(0); + + m_video = decltype(m_video)(); m_kb_ruslat = m_long_beep = m_kb_control = m_kb_data = m_kb_flag0 = 0; m_kb_flag = IE_TRUE; + m_kbd_sdv = false; m_hblank = 1; m_hblank_timer->adjust(m_screen->time_until_pos(0, IE15_HORZ_START)); @@ -499,20 +592,20 @@ void ie15_device::update_leds() { uint8_t data = m_io_keyboard->read(); - machine().output().set_value("lat_led", m_kb_ruslat ^ 1); - machine().output().set_value("nr_led", BIT(m_kb_control, ie15_keyboard_device::IE_KB_NR_BIT) ^ 1); - machine().output().set_value("pch_led", BIT(data, ie15_keyboard_device::IE_KB_PCH_BIT) ^ 1); - machine().output().set_value("dup_led", BIT(data, ie15_keyboard_device::IE_KB_DUP_BIT) ^ 1); - machine().output().set_value("lin_led", BIT(data, ie15_keyboard_device::IE_KB_LIN_BIT) ^ 1); - machine().output().set_value("red_led", BIT(data, ie15_keyboard_device::IE_KB_RED_BIT) ^ 1); - machine().output().set_value("sdv_led", BIT(m_kb_control, ie15_keyboard_device::IE_KB_SDV_BIT) ^ 1); - machine().output().set_value("prd_led", 1); // XXX + m_lat_led = m_kb_ruslat ^ 1; + m_nr_led = BIT(m_kb_control, ie15_keyboard_device::IE_KB_NR_BIT) ^ 1; + m_pch_led = BIT(data, ie15_keyboard_device::IE_KB_PCH_BIT) ^ 1; + m_dup_led = BIT(data, ie15_keyboard_device::IE_KB_DUP_BIT) ^ 1; + m_lin_led = BIT(data, ie15_keyboard_device::IE_KB_LIN_BIT) ^ 1; + m_red_led = BIT(data, ie15_keyboard_device::IE_KB_RED_BIT) ^ 1; + m_sdv_led = m_kbd_sdv ^ 1; + m_prd_led = 1; // XXX } /* - VBlank is active for 3 topmost on-screen rows and 1 at the bottom; however, control flag 3 - overrides VBlank, - allowing status line to be switched on and off. + VBlank is active for 3 topmost on-screen rows and 1 at the bottom. + However, control flag 3 overrides VBlank, allowing status line + to be switched on and off. */ void ie15_device::scanline_callback() { @@ -522,10 +615,10 @@ void ie15_device::scanline_callback() m_vpos %= IE15_TOTAL_VERT; m_marker_scanline = (m_vpos % 11) > 7; - DBG_LOG(3,"scanline_cb", - ("addr %03x frame %d x %.4d y %.3d row %.2d e:c:s %d:%d:%d\n", + LOGMASKED(LOG_SCANLINE, + "addr %03x frame %d x %.4d y %.3d row %.2d e:c:s %d:%d:%d\n", m_video.ptr2, (int)m_screen->frame_number(), m_screen->hpos(), y, - y%11, m_video.enable, m_video.cursor, m_video.line25)); + y%11, m_video.enable, m_video.cursor, m_video.line25); if (y < IE15_VERT_START) return; y -= IE15_VERT_START; @@ -545,7 +638,8 @@ void ie15_device::scanline_callback() uint32_t ie15_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { update_leds(); - memcpy(&bitmap.pix32(0), &m_tmpbmp[0], sizeof(uint32_t) * IE15_TOTAL_HORZ * IE15_TOTAL_VERT); + for (int y = 0; y < IE15_TOTAL_VERT; y++) + std::copy_n(&m_tmpbmp[y * IE15_TOTAL_HORZ], IE15_TOTAL_HORZ, &bitmap.pix(y)); return 0; } @@ -571,17 +665,16 @@ GFXDECODE_END void ie15_device::ie15core(machine_config &config) { /* Basic machine hardware */ - IE15_CPU(config, m_maincpu, XTAL(30'800'000)/10); + IE15_CPU(config, m_maincpu, XTAL(30'800'000) / 10); m_maincpu->set_addrmap(AS_PROGRAM, &ie15_device::ie15_mem); m_maincpu->set_addrmap(AS_IO, &ie15_device::ie15_io); config.set_default_layout(layout_ie15); /* Devices */ - IE15_KEYBOARD(config, m_keyboard, 0).keyboard_cb().set(FUNC(ie15_device::kbd_put)); - - RS232_PORT(config, m_rs232, default_rs232_devices, "null_modem"); - m_rs232->rxd_handler().set(FUNC(ie15_device::serial_rx_callback)); + IE15_KEYBOARD(config, m_keyboard, 0); + m_keyboard->keyboard_cb().set(FUNC(ie15_device::kbd_put)); + m_keyboard->sdv_cb().set(FUNC(ie15_device::kbd_sdv)); SPEAKER(config, "mono").front_center(); BEEP(config, m_beeper, 2400); |