From 26e13c42416d22384930a7864f5bbb33c59ed6f9 Mon Sep 17 00:00:00 2001 From: smf- Date: Sat, 25 Jan 2014 18:38:22 +0000 Subject: [PATCH] 6522 CA1 is input only, so I have removed the output callback. The lisa via hookup has been changed as it had functions named as CA2/CB2 hooked up to CA1/CB1 and CA1 output no longer exists, it appears to have been wrong since before the code was merged with MAME. Changed CB1 to be active low as CA2 & CB2 already are & it sort of was before, but when the chip is reset then the handlers are called setting the lines to 1. This seems to stop it thinking that you've pressed a key at startup as I believe it got out of sync before because the lines weren't consistent. Merged some duplicate code for handling outputs and removed some obvious comments. [smf] --- src/emu/machine/6522via.c | 111 ++++++++++---------------------------- src/emu/machine/6522via.h | 6 --- src/mess/drivers/cat.c | 14 ----- src/mess/drivers/clcd.c | 16 +++--- src/mess/drivers/lisa.c | 4 +- src/mess/drivers/pet.c | 2 - 6 files changed, 38 insertions(+), 115 deletions(-) diff --git a/src/emu/machine/6522via.c b/src/emu/machine/6522via.c index 83c60a6b69f..b787baac7f0 100644 --- a/src/emu/machine/6522via.c +++ b/src/emu/machine/6522via.c @@ -152,7 +152,6 @@ via6522_device::via6522_device(const machine_config &mconfig, const char *tag, d m_in_b_handler(*this), m_out_a_handler(*this), m_out_b_handler(*this), - m_ca1_handler(*this), m_ca2_handler(*this), m_cb1_handler(*this), m_cb2_handler(*this), @@ -178,7 +177,6 @@ void via6522_device::device_start() m_in_b_handler.resolve(); m_out_a_handler.resolve_safe(); m_out_b_handler.resolve_safe(); - m_ca1_handler.resolve(); m_cb1_handler.resolve_safe(); m_ca2_handler.resolve_safe(); m_cb2_handler.resolve_safe(); @@ -242,11 +240,11 @@ void via6522_device::device_start() void via6522_device::device_reset() { m_out_a = 0; - m_out_ca2 = 0; + m_out_ca2 = 1; m_ddr_a = 0; m_out_b = 0; - m_out_cb1 = 0; - m_out_cb2 = 0; + m_out_cb1 = 1; + m_out_cb2 = 1; m_ddr_b = 0; m_t1cl = 0; @@ -262,6 +260,10 @@ void via6522_device::device_reset() m_t1_active = 0; m_t2_active = 0; m_shift_counter = 0; + + m_ca2_handler(m_out_ca2); + m_cb1_handler(m_out_cb1); + m_cb2_handler(m_out_cb2); } @@ -354,11 +356,10 @@ void via6522_device::device_timer(emu_timer &timer, device_timer_id id, int para { switch (id) { - // shift timer case TIMER_SHIFT: m_out_cb1 = !m_out_cb1; - if (m_out_cb1) + if (!m_out_cb1) { if (SO_T2_RATE(m_acr) || SO_T2_CONTROL(m_acr) || SO_O2_CONTROL(m_acr)) { @@ -377,7 +378,7 @@ void via6522_device::device_timer(emu_timer &timer, device_timer_id id, int para m_cb1_handler(m_out_cb1); } - if (SO_T2_RATE(m_acr) || m_shift_counter || m_out_cb1) + if (SO_T2_RATE(m_acr) || m_shift_counter || !m_out_cb1) { if (SI_O2_CONTROL(m_acr) || SO_O2_CONTROL(m_acr)) { @@ -390,7 +391,6 @@ void via6522_device::device_timer(emu_timer &timer, device_timer_id id, int para } break; - // t1 timeout case TIMER_T1: if (T1_CONTINUOUS (m_acr)) { @@ -421,7 +421,6 @@ void via6522_device::device_timer(emu_timer &timer, device_timer_id id, int para } break; - // t2 timeout case TIMER_T2: m_t2_active = 0; m_time2 = machine().time(); @@ -433,8 +432,8 @@ void via6522_device::device_timer(emu_timer &timer, device_timer_id id, int para break; case TIMER_CA2: - m_ca2_handler(1); m_out_ca2 = 1; + m_ca2_handler(m_out_ca2); break; } } @@ -507,29 +506,14 @@ READ8_MEMBER( via6522_device::read ) CLR_PA_INT(); - /* If CA2 is configured as output and in pulse or handshake mode, - CA2 is set now */ - if (CA2_PULSE_OUTPUT(m_pcr)) + if (m_out_ca2 && (CA2_PULSE_OUTPUT(m_pcr) || CA2_AUTO_HS(m_pcr))) { - /* call the CA2 output function */ - m_ca2_handler(0); m_out_ca2 = 0; + m_ca2_handler(m_out_ca2); + } + if (CA2_PULSE_OUTPUT(m_pcr)) m_ca2_timer->adjust(clocks_to_attotime(1)); - } - /* If CA2 is configured as output and in pulse or handshake mode, - CA2 is set now */ - else if (CA2_AUTO_HS(m_pcr)) - { - if (m_out_ca2) - { - /* set CA2 */ - m_out_ca2 = 0; - - /* call the CA2 output function */ - m_ca2_handler(0); - } - } break; @@ -671,18 +655,10 @@ WRITE8_MEMBER( via6522_device::write ) CLR_PB_INT(); - /* If CB2 is configured as output and in pulse or handshake mode, - CB2 is set now */ - if (CB2_AUTO_HS(m_pcr)) + if (m_out_cb2 && CB2_AUTO_HS(m_pcr)) { - if (m_out_cb2) - { - /* set CB2 */ - m_out_cb2 = 0; - - /* call the CB2 output function */ - m_cb2_handler(0); - } + m_out_cb2 = 0; + m_cb2_handler(m_out_cb2); } break; @@ -697,27 +673,14 @@ WRITE8_MEMBER( via6522_device::write ) CLR_PA_INT(); - /* If CA2 is configured as output and in pulse or handshake mode, - CA2 is set now */ - if (CA2_PULSE_OUTPUT(m_pcr)) + if (m_out_ca2 && (CA2_PULSE_OUTPUT(m_pcr) || CA2_AUTO_HS(m_pcr))) { - /* call the CA2 output function */ - m_ca2_handler(0); m_out_ca2 = 0; + m_ca2_handler(m_out_ca2); + } + if (CA2_PULSE_OUTPUT(m_pcr)) m_ca2_timer->adjust(clocks_to_attotime(1)); - } - else if (CA2_AUTO_HS(m_pcr)) - { - if (m_out_ca2) - { - /* set CA2 */ - m_out_ca2 = 0; - - /* call the CA2 output function */ - m_ca2_handler(0); - } - } break; @@ -835,13 +798,13 @@ WRITE8_MEMBER( via6522_device::write ) logerror("%s:6522VIA chip %s: PCR = %02X\n", machine().describe_context(), tag(), data); } - if (CA2_FIX_OUTPUT(data) && CA2_OUTPUT_LEVEL(data) ^ m_out_ca2) + if (CA2_FIX_OUTPUT(data) && m_out_ca2 != CA2_OUTPUT_LEVEL(data)) { m_out_ca2 = CA2_OUTPUT_LEVEL(data); m_ca2_handler(m_out_ca2); } - if (CB2_FIX_OUTPUT(data) && CB2_OUTPUT_LEVEL(data) ^ m_out_cb2) + if (CB2_FIX_OUTPUT(data) && m_out_cb2 != CB2_OUTPUT_LEVEL(data)) { m_out_cb2 = CB2_OUTPUT_LEVEL(data); m_cb2_handler(m_out_cb2); @@ -952,18 +915,10 @@ WRITE_LINE_MEMBER( via6522_device::write_ca1 ) set_int(INT_CA1); - /* CA2 is configured as output and in pulse or handshake mode, - CA2 is cleared now */ - if (CA2_AUTO_HS(m_pcr)) + if (!m_out_ca2 && CA2_AUTO_HS(m_pcr)) { - if (!m_out_ca2) - { - /* clear CA2 */ - m_out_ca2 = 1; - - /* call the CA2 output function */ - m_ca2_handler(1); - } + m_out_ca2 = 1; + m_ca2_handler(m_out_ca2); } } } @@ -1037,18 +992,10 @@ WRITE_LINE_MEMBER( via6522_device::write_cb1 ) set_int(INT_CB1); - /* CB2 is configured as output and in pulse or handshake mode, - CB2 is cleared now */ - if (CB2_AUTO_HS(m_pcr)) + if (!m_out_cb2 && CB2_AUTO_HS(m_pcr)) { - if (!m_out_cb2) - { - /* clear CB2 */ - m_out_cb2 = 1; - - /* call the CB2 output function */ - m_cb2_handler(1); - } + m_out_cb2 = 1; + m_cb2_handler(1); } } } diff --git a/src/emu/machine/6522via.h b/src/emu/machine/6522via.h index 104bb0014e7..04038f705d9 100644 --- a/src/emu/machine/6522via.h +++ b/src/emu/machine/6522via.h @@ -38,10 +38,6 @@ #define MCFG_VIA6522_WRITEPB_HANDLER(_devcb) \ devcb = &via6522_device::set_writepb_handler(*device, DEVCB2_##_devcb); -// NOT USED -#define MCFG_VIA6522_CA1_HANDLER(_devcb) \ - devcb = &via6522_device::set_ca1_handler(*device, DEVCB2_##_devcb); - #define MCFG_VIA6522_CA2_HANDLER(_devcb) \ devcb = &via6522_device::set_ca2_handler(*device, DEVCB2_##_devcb); @@ -76,7 +72,6 @@ public: template static devcb2_base &set_writepa_handler(device_t &device, _Object object) { return downcast(device).m_out_a_handler.set_callback(object); } template static devcb2_base &set_writepb_handler(device_t &device, _Object object) { return downcast(device).m_out_b_handler.set_callback(object); } - template static devcb2_base &set_ca1_handler(device_t &device, _Object object) { return downcast(device).m_ca1_handler.set_callback(object); } template static devcb2_base &set_ca2_handler(device_t &device, _Object object) { return downcast(device).m_ca2_handler.set_callback(object); } template static devcb2_base &set_cb1_handler(device_t &device, _Object object) { return downcast(device).m_cb1_handler.set_callback(object); } template static devcb2_base &set_cb2_handler(device_t &device, _Object object) { return downcast(device).m_cb2_handler.set_callback(object); } @@ -157,7 +152,6 @@ private: devcb2_write8 m_out_a_handler; devcb2_write8 m_out_b_handler; - devcb2_write_line m_ca1_handler; devcb2_write_line m_ca2_handler; devcb2_write_line m_cb1_handler; devcb2_write_line m_cb2_handler; diff --git a/src/mess/drivers/cat.c b/src/mess/drivers/cat.c index 09ec81ade59..6057345f9c4 100644 --- a/src/mess/drivers/cat.c +++ b/src/mess/drivers/cat.c @@ -460,7 +460,6 @@ public: DECLARE_WRITE8_MEMBER(swyft_via0_w); DECLARE_READ8_MEMBER(via0_pa_r); DECLARE_WRITE8_MEMBER(via0_pa_w); - DECLARE_WRITE_LINE_MEMBER(via0_ca1_w); DECLARE_WRITE_LINE_MEMBER(via0_ca2_w); DECLARE_READ8_MEMBER(via0_pb_r); DECLARE_WRITE8_MEMBER(via0_pb_w); @@ -472,7 +471,6 @@ public: DECLARE_WRITE8_MEMBER(swyft_via1_w); DECLARE_READ8_MEMBER(via1_pa_r); DECLARE_WRITE8_MEMBER(via1_pa_w); - DECLARE_WRITE_LINE_MEMBER(via1_ca1_w); DECLARE_WRITE_LINE_MEMBER(via1_ca2_w); DECLARE_READ8_MEMBER(via1_pb_r); DECLARE_WRITE8_MEMBER(via1_pb_w); @@ -1375,11 +1373,6 @@ WRITE8_MEMBER( cat_state::via0_pa_w ) logerror("VIA0: Port A written with data of 0x%02x!\n", data); } -WRITE_LINE_MEMBER ( cat_state::via0_ca1_w ) -{ - logerror("VIA0: CA1 written with %d!\n", state); -} - WRITE_LINE_MEMBER ( cat_state::via0_ca2_w ) { logerror("VIA0: CA2 written with %d!\n", state); @@ -1423,11 +1416,6 @@ WRITE8_MEMBER( cat_state::via1_pa_w ) logerror(" VIA1: Port A written with data of 0x%02x!\n", data); } -WRITE_LINE_MEMBER ( cat_state::via1_ca1_w ) -{ - logerror(" VIA1: CA1 written with %d!\n", state); -} - WRITE_LINE_MEMBER ( cat_state::via1_ca2_w ) { logerror(" VIA1: CA2 written with %d!\n", state); @@ -1487,7 +1475,6 @@ static MACHINE_CONFIG_START( swyft, cat_state ) MCFG_VIA6522_READPB_HANDLER(READ8(cat_state, via0_pb_r)) MCFG_VIA6522_WRITEPA_HANDLER(WRITE8(cat_state, via0_pa_w)) MCFG_VIA6522_WRITEPB_HANDLER(WRITE8(cat_state, via0_pb_w)) - MCFG_VIA6522_CA1_HANDLER(WRITELINE(cat_state, via0_ca1_w)) MCFG_VIA6522_CB1_HANDLER(WRITELINE(cat_state, via0_cb1_w)) MCFG_VIA6522_CA2_HANDLER(WRITELINE(cat_state, via0_ca2_w)) MCFG_VIA6522_CB2_HANDLER(WRITELINE(cat_state, via0_cb2_w)) @@ -1498,7 +1485,6 @@ static MACHINE_CONFIG_START( swyft, cat_state ) MCFG_VIA6522_READPB_HANDLER(READ8(cat_state, via1_pb_r)) MCFG_VIA6522_WRITEPA_HANDLER(WRITE8(cat_state, via1_pa_w)) MCFG_VIA6522_WRITEPB_HANDLER(WRITE8(cat_state, via1_pb_w)) - MCFG_VIA6522_CA1_HANDLER(WRITELINE(cat_state, via1_ca1_w)) MCFG_VIA6522_CB1_HANDLER(WRITELINE(cat_state, via1_cb1_w)) MCFG_VIA6522_CA2_HANDLER(WRITELINE(cat_state, via1_ca2_w)) MCFG_VIA6522_CB2_HANDLER(WRITELINE(cat_state, via1_cb2_w)) diff --git a/src/mess/drivers/clcd.c b/src/mess/drivers/clcd.c index 755658cb0b8..ef07cb2436e 100644 --- a/src/mess/drivers/clcd.c +++ b/src/mess/drivers/clcd.c @@ -82,6 +82,12 @@ public: save_item(NAME(m_key_shift)); } + void palette_init() + { + palette_set_color(machine(), 0, MAKE_RGB(36,72,36)); + palette_set_color(machine(), 1, MAKE_RGB(2,4,2)); + } + UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { if (m_lcd_mode & LCD_MODE_GRAPH) @@ -449,7 +455,7 @@ public: { m_key_clk = newm_key_clk; - if (m_key_clk) + if (!m_key_clk) { m_via0->write_cb2((m_key_shift & 0x8000) != 0); m_key_shift <<= 1; @@ -471,7 +477,6 @@ private: required_device m_bank3; required_device m_bank4; required_memory_region m_lcd_char_rom; - virtual void palette_init(); int m_lcd_scrollx; int m_lcd_scrolly; int m_lcd_mode; @@ -654,13 +659,6 @@ static INPUT_PORTS_START( clcd ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // clears screen and goes into infinite loop INPUT_PORTS_END - -void clcd_state::palette_init() -{ - palette_set_color(machine(), 0, MAKE_RGB(32,64,32)); - palette_set_color(machine(), 1, MAKE_RGB(2,4,2)); -} - static MACHINE_CONFIG_START(clcd, clcd_state) /* basic machine hardware */ MCFG_CPU_ADD("maincpu",M65C02, 2000000) diff --git a/src/mess/drivers/lisa.c b/src/mess/drivers/lisa.c index b4ba4c7bdd4..3f08c546c6b 100644 --- a/src/mess/drivers/lisa.c +++ b/src/mess/drivers/lisa.c @@ -175,8 +175,8 @@ static MACHINE_CONFIG_START( lisa, lisa_state ) MCFG_DEVICE_ADD("via6522_0", VIA6522, 500000) MCFG_VIA6522_WRITEPA_HANDLER(WRITE8(lisa_state, COPS_via_out_a)) MCFG_VIA6522_WRITEPB_HANDLER(WRITE8(lisa_state, COPS_via_out_b)) - MCFG_VIA6522_CA1_HANDLER(WRITELINE(lisa_state, COPS_via_out_ca2)) - MCFG_VIA6522_CB1_HANDLER(WRITELINE(lisa_state, COPS_via_out_cb2)) + MCFG_VIA6522_CA2_HANDLER(WRITELINE(lisa_state, COPS_via_out_ca2)) + MCFG_VIA6522_CB2_HANDLER(WRITELINE(lisa_state, COPS_via_out_cb2)) MCFG_VIA6522_IRQ_HANDLER(WRITELINE(lisa_state, COPS_via_irq_func)) MCFG_DEVICE_ADD("via6522_1", VIA6522, 500000) diff --git a/src/mess/drivers/pet.c b/src/mess/drivers/pet.c index 40ce5028bcc..36443a4bd82 100644 --- a/src/mess/drivers/pet.c +++ b/src/mess/drivers/pet.c @@ -1389,7 +1389,6 @@ static MACHINE_CONFIG_START( pet, pet_state ) MCFG_VIA6522_READPB_HANDLER(READ8(pet_state, via_pb_r)) MCFG_VIA6522_WRITEPA_HANDLER(WRITE8(pet_state, via_pa_w)) MCFG_VIA6522_WRITEPB_HANDLER(WRITE8(pet_state, via_pb_w)) - MCFG_VIA6522_CA1_HANDLER(DEVWRITELINE(PET_USER_PORT_TAG, pet_user_port_device, write_b)) MCFG_VIA6522_CA2_HANDLER(WRITELINE(pet_state, via_ca2_w)) MCFG_VIA6522_CB2_HANDLER(WRITELINE(pet_state, via_cb2_w)) MCFG_VIA6522_IRQ_HANDLER(WRITELINE(pet_state, via_irq_w)) @@ -1706,7 +1705,6 @@ static MACHINE_CONFIG_START( pet80, pet80_state ) MCFG_VIA6522_READPB_HANDLER(READ8(pet_state, via_pb_r)) MCFG_VIA6522_WRITEPA_HANDLER(WRITE8(pet_state, via_pa_w)) MCFG_VIA6522_WRITEPB_HANDLER(WRITE8(pet_state, via_pb_w)) - MCFG_VIA6522_CA1_HANDLER(DEVWRITELINE(PET_USER_PORT_TAG, pet_user_port_device, write_b)) MCFG_VIA6522_CA2_HANDLER(WRITELINE(pet_state, via_ca2_w)) MCFG_VIA6522_CB2_HANDLER(WRITELINE(pet_state, via_cb2_w)) MCFG_VIA6522_IRQ_HANDLER(WRITELINE(pet_state, via_irq_w))