From c72d28ba0c37ad31719c258787114afcda6404f4 Mon Sep 17 00:00:00 2001 From: AJR Date: Fri, 27 Jul 2018 22:03:35 -0400 Subject: osbexec.cpp: Miscellaneous updates (nw) - Even better hookup for modem RS232 port (including transmission clocks) - Use ripple counter device for "RTC" and blink timer - More object finder arrays and devcb3 usage --- src/devices/machine/ripple_counter.h | 2 +- src/mame/drivers/osbexec.cpp | 138 +++++++++++++++-------------------- 2 files changed, 58 insertions(+), 82 deletions(-) diff --git a/src/devices/machine/ripple_counter.h b/src/devices/machine/ripple_counter.h index c322b4fa718..e61c1ec5ef8 100644 --- a/src/devices/machine/ripple_counter.h +++ b/src/devices/machine/ripple_counter.h @@ -34,7 +34,7 @@ class ripple_counter_device : public device_t, public device_rom_interface { public: // construction/destruction - ripple_counter_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + ripple_counter_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0); // configuration void set_stages(u8 stages) { m_count_mask = (1U << stages) - 1; set_rom_addr_width(stages); } diff --git a/src/mame/drivers/osbexec.cpp b/src/mame/drivers/osbexec.cpp index 9b19456acf1..0b608a602e6 100644 --- a/src/mame/drivers/osbexec.cpp +++ b/src/mame/drivers/osbexec.cpp @@ -15,6 +15,7 @@ #include "machine/input_merger.h" #include "machine/pit8253.h" #include "machine/ram.h" +#include "machine/ripple_counter.h" #include "machine/wd_fdc.h" #include "machine/z80sio.h" #include "sound/spkrdev.h" @@ -40,12 +41,12 @@ public: , m_screen(*this, "screen") , m_mb8877(*this, "mb8877") , m_messram( *this, RAM_TAG) - , m_pia_0(*this, "pia_0") - , m_pia_1(*this, "pia_1") + , m_pia(*this, "pia_%u", 0U) + , m_rtc(*this, "rtc") , m_sio(*this, "sio") , m_speaker(*this, "speaker") - , m_floppy0(*this, "mb8877:0:525ssdd") - , m_floppy1(*this, "mb8877:1:525ssdd") + , m_floppy(*this, "mb8877:%u:525ssdd", 0U) + , m_kbd_row(*this, "ROW%u", 0U) { } void osbexec(machine_config &config); @@ -57,12 +58,12 @@ private: required_device m_screen; required_device m_mb8877; required_device m_messram; - required_device m_pia_0; - required_device m_pia_1; + required_device_array m_pia; + required_device m_rtc; required_device m_sio; required_device m_speaker; - required_device m_floppy0; - required_device m_floppy1; + required_device_array m_floppy; + required_ioport_array<8> m_kbd_row; virtual void video_start() override; @@ -86,9 +87,6 @@ private: /* PIA 1 (UD8) */ - /* Vblank counter ("RTC") */ - uint8_t m_rtc; - void set_banks() { uint8_t *ram_ptr = m_messram->pointer(); @@ -181,29 +179,9 @@ READ8_MEMBER(osbexec_state::osbexec_kbd_r) { uint8_t data = 0xFF; - if ( offset & 0x0100 ) - data &= ioport( "ROW0" )->read(); - - if ( offset & 0x0200 ) - data &= ioport( "ROW1" )->read(); - - if ( offset & 0x0400 ) - data &= ioport( "ROW2" )->read(); - - if ( offset & 0x0800 ) - data &= ioport( "ROW3" )->read(); - - if ( offset & 0x1000 ) - data &= ioport( "ROW4" )->read(); - - if ( offset & 0x2000 ) - data &= ioport( "ROW5" )->read(); - - if ( offset & 0x4000 ) - data &= ioport( "ROW6" )->read(); - - if ( offset & 0x8000 ) - data &= ioport( "ROW7" )->read(); + for (int j = 0; j < 8; j++) + if (BIT(offset, j + 8)) + data &= m_kbd_row[j]->read(); return data; } @@ -211,7 +189,8 @@ READ8_MEMBER(osbexec_state::osbexec_kbd_r) READ8_MEMBER(osbexec_state::osbexec_rtc_r) { - return m_rtc; + // 74LS244 buffer @ UF13 + return m_rtc->count(); } @@ -229,11 +208,11 @@ void osbexec_state::osbexec_mem(address_map &map) void osbexec_state::osbexec_io(address_map &map) { map.unmap_value_high(); - map(0x00, 0x03).mirror(0xff00).rw(m_pia_0, FUNC(pia6821_device::read), FUNC(pia6821_device::write)); /* 6821 PIA @ UD12 */ + map(0x00, 0x03).mirror(0xff00).rw(m_pia[0], FUNC(pia6821_device::read), FUNC(pia6821_device::write)); /* 6821 PIA @ UD12 */ map(0x04, 0x07).mirror(0xff00).rw("ctc", FUNC(pit8253_device::read), FUNC(pit8253_device::write)); /* 8253 @UD1 */ map(0x08, 0x0B).mirror(0xff00).rw(m_mb8877, FUNC(wd_fdc_device_base::read), FUNC(wd_fdc_device_base::write)); /* MB8877 @ UB17 input clock = 1MHz */ map(0x0C, 0x0F).mirror(0xff00).rw(m_sio, FUNC(z80sio_device::ba_cd_r), FUNC(z80sio_device::ba_cd_w)); /* SIO @ UD4 */ - map(0x10, 0x13).mirror(0xff00).rw(m_pia_1, FUNC(pia6821_device::read), FUNC(pia6821_device::write)); /* 6821 PIA @ UD8 */ + map(0x10, 0x13).mirror(0xff00).rw(m_pia[1], FUNC(pia6821_device::read), FUNC(pia6821_device::write)); /* 6821 PIA @ UD8 */ map(0x14, 0x17).select(0xff00).r(FUNC(osbexec_state::osbexec_kbd_r)); /* KBD */ map(0x18, 0x1b).mirror(0xff00).r(FUNC(osbexec_state::osbexec_rtc_r)); /* "RTC" @ UE13/UF13 */ /* ?? - vid ? */ @@ -395,12 +374,12 @@ WRITE8_MEMBER(osbexec_state::osbexec_pia0_b_w) switch ( data & 0x06 ) { case 0x02: - m_mb8877->set_floppy(m_floppy1); - m_floppy1->mon_w(0); + m_mb8877->set_floppy(m_floppy[1].target()); + m_floppy[1]->mon_w(0); break; case 0x04: - m_mb8877->set_floppy(m_floppy0); - m_floppy0->mon_w(0); + m_mb8877->set_floppy(m_floppy[0].target()); + m_floppy[0]->mon_w(0); break; default: m_mb8877->set_floppy(nullptr); @@ -426,40 +405,41 @@ WRITE_LINE_MEMBER(osbexec_state::osbexec_pia0_cb2_w) WRITE_LINE_MEMBER(osbexec_state::modem_txclk_w) { if (BIT(m_pia0_portb, 5)) - m_sio->txca_w(!state); + m_sio->txca_w(state); } WRITE_LINE_MEMBER(osbexec_state::modem_rxclk_w) { if (BIT(m_pia0_portb, 4)) - m_sio->rxca_w(!state); + m_sio->rxca_w(state); } WRITE_LINE_MEMBER(osbexec_state::modem_dsr_w) { - m_pia0_portb &= 0xbf; - if (!state) + if (state) m_pia0_portb |= 0x40; + else + m_pia0_portb &= 0xbf; } WRITE_LINE_MEMBER(osbexec_state::modem_ri_w) { - m_pia0_portb &= 0x7f; - if (!state) + if (state) m_pia0_portb |= 0x80; + else + m_pia0_portb &= 0x7f; } WRITE_LINE_MEMBER(osbexec_state::comm_clk_a_w) { - //if (!BIT(m_pia0_portb, 5)) + if (!BIT(m_pia0_portb, 5)) m_sio->txca_w(state); - //if (!BIT(m_pia0_portb, 4)) + if (!BIT(m_pia0_portb, 4)) m_sio->rxca_w(state); - //m_modem->txclk_w(!state); } @@ -483,18 +463,6 @@ TIMER_CALLBACK_MEMBER(osbexec_state::osbexec_video_callback) { int y = m_screen->vpos(); - /* Start of frame */ - if ( y == 0 ) - { - /* Clear CB1 on PIA @ UD12 */ - m_pia_0->cb1_w(0); - } - else if ( y == 240 ) - { - /* Set CB1 on PIA @ UD12 */ - m_pia_0->cb1_w(1); - m_rtc++; - } if ( y < 240 ) { uint16_t row_addr = ( y / 10 ) * 128; @@ -509,15 +477,15 @@ TIMER_CALLBACK_MEMBER(osbexec_state::osbexec_video_callback) uint8_t font_bits = m_fontram[ ( ( attr & 0x10 ) ? 0x800 : 0 ) + ( ch & 0x7f ) * 16 + char_line ]; /* Check for underline */ - if ( ( attr & 0x40 ) && char_line == 9 ) + if (BIT(attr, 6) && char_line == 9) font_bits = 0xFF; /* Check for blink */ - if ( ( attr & 0x20 ) && ( m_rtc & 0x10 ) ) + if (BIT(attr, 5) && BIT(m_rtc->count(), 4)) font_bits = 0; /* Check for inverse video */ - if ( ( ch & 0x80 ) && ! ( attr & 0x10 ) ) + if (BIT(ch, 7) && !BIT(attr, 4)) font_bits ^= 0xFF; for ( int b = 0; b < 8; b++ ) @@ -555,8 +523,6 @@ void osbexec_state::machine_reset() m_video_timer->adjust( m_screen->time_until_pos( 0, 0 ) ); - m_rtc = 0; - // D0 cleared on interrupt acknowledge cycle by TTL gates at UC21 and UA18 m_maincpu->set_input_line_vector(0, 0xfe); } @@ -575,17 +541,21 @@ MACHINE_CONFIG_START(osbexec_state::osbexec) MCFG_DEVICE_IO_MAP(osbexec_io) MCFG_Z80_DAISY_CHAIN(osbexec_daisy_config) - MCFG_SCREEN_ADD_MONOCHROME(m_screen, RASTER, rgb_t::green()) - MCFG_SCREEN_UPDATE_DRIVER(osbexec_state, screen_update) - MCFG_SCREEN_RAW_PARAMS(MAIN_CLOCK/2, 768, 0, 640, 260, 0, 240) /* May not be correct */ - MCFG_SCREEN_PALETTE("palette") + SCREEN(config, m_screen, SCREEN_TYPE_RASTER); + m_screen->set_color(rgb_t::green()); + m_screen->set_screen_update(FUNC(osbexec_state::screen_update)); + m_screen->set_raw(MAIN_CLOCK/2, 768, 0, 640, 260, 0, 240); /* May not be correct */ + m_screen->set_palette("palette"); + m_screen->screen_vblank().set(m_pia[0], FUNC(pia6821_device::cb1_w)); + m_screen->screen_vblank().append(m_rtc, FUNC(ripple_counter_device::clock_w)).invert(); + MCFG_PALETTE_ADD_MONOCHROME_HIGHLIGHT("palette") SPEAKER(config, "mono").front_center(); MCFG_DEVICE_ADD(m_speaker, SPEAKER_SOUND) MCFG_SOUND_ROUTE( ALL_OUTPUTS, "mono", 1.00 ) - MCFG_DEVICE_ADD(m_pia_0, PIA6821, 0) + MCFG_DEVICE_ADD(m_pia[0], PIA6821, 0) MCFG_PIA_READPA_HANDLER(READ8(*this, osbexec_state, osbexec_pia0_a_r)) MCFG_PIA_READPB_HANDLER(READ8(*this, osbexec_state, osbexec_pia0_b_r)) MCFG_PIA_WRITEPA_HANDLER(WRITE8(*this, osbexec_state, osbexec_pia0_a_w)) @@ -595,12 +565,15 @@ MACHINE_CONFIG_START(osbexec_state::osbexec) MCFG_PIA_IRQA_HANDLER(WRITELINE("mainirq", input_merger_device, in_w<0>)) MCFG_PIA_IRQB_HANDLER(WRITELINE("mainirq", input_merger_device, in_w<1>)) - MCFG_DEVICE_ADD(m_pia_1, PIA6821, 0) + MCFG_DEVICE_ADD(m_pia[1], PIA6821, 0) MCFG_PIA_IRQA_HANDLER(WRITELINE("mainirq", input_merger_device, in_w<2>)) MCFG_PIA_IRQB_HANDLER(WRITELINE("mainirq", input_merger_device, in_w<3>)) INPUT_MERGER_ANY_HIGH(config, "mainirq").output_handler().set_inputline(m_maincpu, 0); + RIPPLE_COUNTER(config, m_rtc); // 74LS393 @ UE13 + m_rtc->set_stages(8); // two halves cascaded + Z80SIO(config, m_sio, MAIN_CLOCK/6); m_sio->out_txda_callback().set(MODEM_PORT_TAG, FUNC(rs232_port_device::write_txd)); m_sio->out_dtra_callback().set(MODEM_PORT_TAG, FUNC(rs232_port_device::write_dtr)); @@ -610,13 +583,14 @@ MACHINE_CONFIG_START(osbexec_state::osbexec) m_sio->out_rtsb_callback().set(PRINTER_PORT_TAG, FUNC(rs232_port_device::write_rts)); m_sio->out_int_callback().set("mainirq", FUNC(input_merger_device::in_w<4>)); - MCFG_DEVICE_ADD("ctc", PIT8253, 0) - MCFG_PIT8253_CLK0(MAIN_CLOCK / 13) // divided by 74S161 @ UC25 - MCFG_PIT8253_CLK1(MAIN_CLOCK / 13) // divided by 74S161 @ UC25 - MCFG_PIT8253_CLK2(MAIN_CLOCK / 12) - MCFG_PIT8253_OUT0_HANDLER(WRITELINE(*this, osbexec_state, comm_clk_a_w)) - MCFG_PIT8253_OUT1_HANDLER(WRITELINE(m_sio, z80sio_device, rxtxcb_w)) - //MCFG_PIT8253_OUT2_HANDLER(WRITELINE(*this, osbexec_state, spindle_clk_w)) + pit8253_device &ctc(PIT8253(config, "ctc", 0)); + ctc.set_clk<0>(MAIN_CLOCK / 13); // divided by 74S161 @ UC25 + ctc.set_clk<1>(MAIN_CLOCK / 13); // divided by 74S161 @ UC25 + ctc.set_clk<2>(MAIN_CLOCK / 12); + ctc.out_handler<0>().set(FUNC(osbexec_state::comm_clk_a_w)); + ctc.out_handler<0>().append(MODEM_PORT_TAG, FUNC(rs232_port_device::write_etc)); + ctc.out_handler<1>().set(m_sio, FUNC(z80sio_device::rxtxcb_w)); + //ctc.out_handler<2>().set(FUNC(osbexec_state::spindle_clk_w)); rs232_port_device &modem_port(RS232_PORT(config, MODEM_PORT_TAG, default_rs232_devices, nullptr)); modem_port.rxd_handler().set(m_sio, FUNC(z80sio_device::rxa_w)); @@ -624,6 +598,8 @@ MACHINE_CONFIG_START(osbexec_state::osbexec) modem_port.dsr_handler().set(FUNC(osbexec_state::modem_dsr_w)); modem_port.ri_handler().set(FUNC(osbexec_state::modem_ri_w)); modem_port.cts_handler().set(m_sio, FUNC(z80sio_device::ctsa_w)); + modem_port.txc_handler().set(FUNC(osbexec_state::modem_txclk_w)); + modem_port.rxc_handler().set(FUNC(osbexec_state::modem_rxclk_w)); rs232_port_device &printer_port(RS232_PORT(config, PRINTER_PORT_TAG, default_rs232_devices, nullptr)); printer_port.rxd_handler().set(m_sio, FUNC(z80sio_device::rxb_w)); @@ -631,7 +607,7 @@ MACHINE_CONFIG_START(osbexec_state::osbexec) printer_port.cts_handler().set(m_sio, FUNC(z80sio_device::ctsb_w)); MCFG_DEVICE_ADD("mb8877", MB8877, MAIN_CLOCK/24) - MCFG_WD_FDC_INTRQ_CALLBACK(WRITELINE(m_pia_1, pia6821_device, cb1_w)) + MCFG_WD_FDC_INTRQ_CALLBACK(WRITELINE(m_pia[1], pia6821_device, cb1_w)) MCFG_FLOPPY_DRIVE_ADD("mb8877:0", osborne2_floppies, "525ssdd", floppy_image_device::default_floppy_formats) MCFG_FLOPPY_DRIVE_ADD("mb8877:1", osborne2_floppies, "525ssdd", floppy_image_device::default_floppy_formats) -- cgit v1.2.3