diff --git a/src/devices/machine/mc68681.cpp b/src/devices/machine/mc68681.cpp index f288a76971c..a75d9acbade 100644 --- a/src/devices/machine/mc68681.cpp +++ b/src/devices/machine/mc68681.cpp @@ -26,7 +26,7 @@ #include "emu.h" #include "mc68681.h" -#define VERBOSE 1 +//#define VERBOSE 1 //#define LOG_OUTPUT_FUNC printf #include "logmacro.h" diff --git a/src/mame/drivers/micro3d.cpp b/src/mame/drivers/micro3d.cpp index b3c5ab50313..ff96144a7ed 100644 --- a/src/mame/drivers/micro3d.cpp +++ b/src/mame/drivers/micro3d.cpp @@ -30,11 +30,11 @@ #include "cpu/m68000/m68000.h" #include "cpu/mcs51/mcs51.h" #include "bus/rs232/rs232.h" -#include "machine/z80scc.h" #include "machine/adc0844.h" #include "machine/mc68681.h" #include "machine/mc68901.h" #include "machine/nvram.h" +#include "machine/z80scc.h" #include "sound/ym2151.h" #include "screen.h" @@ -235,8 +235,8 @@ static ADDRESS_MAP_START( vgbmem, AS_PROGRAM, 16, micro3d_state ) AM_RANGE(0x00e00000, 0x00e0000f) AM_WRITE(micro3d_xfer3dk_w) AM_RANGE(0x02000000, 0x0200ffff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") // clut AM_RANGE(0x02600000, 0x0260000f) AM_WRITE(micro3d_creg_w) - AM_RANGE(0x02c00000, 0x02c0003f) AM_READ(micro3d_ti_uart_r) - AM_RANGE(0x02e00000, 0x02e0003f) AM_WRITE(micro3d_ti_uart_w) + AM_RANGE(0x02c00000, 0x02c0003f) AM_READ8(vgb_uart_r, 0x00ff) + AM_RANGE(0x02e00000, 0x02e0003f) AM_WRITE8(vgb_uart_w, 0x00ff) AM_RANGE(0x03800000, 0x03dfffff) AM_ROM AM_REGION("tms_gfx", 0) AM_RANGE(0x03e00000, 0x03ffffff) AM_ROM AM_REGION("tms34010", 0) AM_RANGE(0xc0000000, 0xc00001ff) AM_DEVREADWRITE("vgb", tms34010_device, io_register_r, io_register_w) @@ -354,6 +354,13 @@ static MACHINE_CONFIG_START( micro3d ) MCFG_SCREEN_UPDATE_DEVICE("vgb", tms34010_device, tms340x0_ind16) MCFG_SCREEN_PALETTE("palette") + MCFG_DEVICE_ADD("uart", MC2661, XTAL_40MHz / 8) // actually SCN2651 + MCFG_MC2661_TXD_HANDLER(DEVWRITELINE("monitor_vgb", rs232_port_device, write_txd)) + + MCFG_RS232_PORT_ADD("monitor_vgb", default_rs232_devices, nullptr) + MCFG_RS232_RXD_HANDLER(DEVWRITELINE("uart", mc2661_device, rx_w)) + MCFG_RS232_DSR_HANDLER(DEVWRITELINE("uart", mc2661_device, dsr_w)) //MCFG_DEVCB_XOR(1) + MCFG_RS232_PORT_ADD("monitor_host", default_rs232_devices, nullptr) MCFG_RS232_RXD_HANDLER(DEVWRITELINE("duart", mc68681_device, rx_a_w)) diff --git a/src/mame/includes/micro3d.h b/src/mame/includes/micro3d.h index 25815f0884c..528e4b91218 100644 --- a/src/mame/includes/micro3d.h +++ b/src/mame/includes/micro3d.h @@ -13,6 +13,7 @@ #include "cpu/tms34010/tms34010.h" #include "cpu/mcs51/mcs51.h" #include "sound/upd7759.h" +#include "machine/mc2661.h" #include "machine/mc68681.h" @@ -64,7 +65,9 @@ public: m_joystick_y(*this, "JOYSTICK_Y"), m_shared_ram(*this, "shared_ram"), m_mac_sram(*this, "mac_sram"), - m_sprite_vram(*this, "sprite_vram") { } + m_sprite_vram(*this, "sprite_vram"), + m_vgb_uart(*this, "uart") + { } required_device m_maincpu; required_device m_audiocpu; @@ -88,11 +91,6 @@ public: /* Sound */ uint8_t m_sound_port_latch[4]; - /* TI UART */ - uint8_t m_ti_uart[9]; - int m_ti_uart_mode_cycle; - int m_ti_uart_sync_cycle; - /* Hardware version-check latch for BOTSS 1.1a */ uint8_t m_botss_latch; @@ -132,8 +130,8 @@ public: int m_drawing_buffer; int m_display_buffer; - DECLARE_WRITE16_MEMBER(micro3d_ti_uart_w); - DECLARE_READ16_MEMBER(micro3d_ti_uart_r); + DECLARE_WRITE8_MEMBER(vgb_uart_w); + DECLARE_READ8_MEMBER(vgb_uart_r); DECLARE_WRITE32_MEMBER(micro3d_mac1_w); DECLARE_READ32_MEMBER(micro3d_mac2_r); DECLARE_WRITE32_MEMBER(micro3d_mac2_w); @@ -187,6 +185,9 @@ public: protected: virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; + +private: + required_device m_vgb_uart; }; #endif // MAME_INCLUDES_MICRO3D_H diff --git a/src/mame/machine/micro3d.cpp b/src/mame/machine/micro3d.cpp index 44aafd9400d..dbc18a3018a 100644 --- a/src/mame/machine/micro3d.cpp +++ b/src/mame/machine/micro3d.cpp @@ -84,107 +84,23 @@ WRITE8_MEMBER(micro3d_state::duart_output_w) * *************************************/ -enum +READ8_MEMBER( micro3d_state::vgb_uart_r ) { - RX, TX, STATUS, SYN1, SYN2, DLE, MODE1, MODE2, COMMAND -}; + // the mode and sync registers switched places? + if (offset == 1 || offset == 2) + offset ^= 3; - -WRITE16_MEMBER(micro3d_state::micro3d_ti_uart_w) -{ - switch (offset) - { - case 0x0: - { - m_ti_uart[TX] = data; -#if VGB_MONITOR_DISPLAY - mame_debug_printf("%c",data); -#endif - m_ti_uart[STATUS] |= 1; - break; - } - case 0x1: - { - if (m_ti_uart_mode_cycle == 0) - { - m_ti_uart[MODE1] = data; - m_ti_uart_mode_cycle = 1; - } - else - { - m_ti_uart[MODE2] = data; - m_ti_uart_mode_cycle = 0; - } - break; - } - case 0x2: - { - if (m_ti_uart_sync_cycle == 0) - { - m_ti_uart[SYN1] = data; - m_ti_uart_mode_cycle = 1; - } - else if (m_ti_uart_sync_cycle == 1) - { - m_ti_uart[SYN2] = data; - m_ti_uart_mode_cycle = 2; - } - else - { - m_ti_uart[DLE] = data; - m_ti_uart_mode_cycle = 0; - } - break; - } - case 0x3: - { - m_ti_uart[COMMAND] = data; - m_ti_uart_mode_cycle = 0; - m_ti_uart_sync_cycle = 0; - break; - } - } + return m_vgb_uart->read(space, offset); } -READ16_MEMBER(micro3d_state::micro3d_ti_uart_r) +WRITE8_MEMBER( micro3d_state::vgb_uart_w ) { - switch (offset) - { - case 0x0: - { - m_ti_uart[STATUS] ^= 2; - return m_ti_uart[RX]; - } - case 0x1: - { - if (m_ti_uart_mode_cycle == 0) - { - m_ti_uart_mode_cycle = 1; - return m_ti_uart[MODE1]; - } - else - { - m_ti_uart_mode_cycle = 0; - return m_ti_uart[MODE2]; - } - } - case 0x2: - { - return m_ti_uart[STATUS]; - } - case 0x3: - { - m_ti_uart_mode_cycle = m_ti_uart_sync_cycle = 0; - return m_ti_uart[COMMAND]; - } - default: - { - logerror("Unknown TI UART access.\n"); - return 0; - } - } -} + // the mode and sync registers switched places? + if (offset == 1 || offset == 2) + offset ^= 3; + m_vgb_uart->write(space, offset, data); +} /************************************* @@ -629,8 +545,6 @@ DRIVER_INIT_MEMBER(micro3d_state,botss) void micro3d_state::machine_reset() { - m_ti_uart[STATUS] = 1; - m_vgb->set_input_line(INPUT_LINE_RESET, ASSERT_LINE); m_drmath->set_input_line(INPUT_LINE_RESET, ASSERT_LINE); m_audiocpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);