From 173999b05e42950f15ee83d0a8856e1948ba93ff Mon Sep 17 00:00:00 2001 From: Curt Coder Date: Tue, 20 Mar 2012 15:49:47 +0000 Subject: [PATCH] 6526cia.c: The PC output will now go low for 1 cycle following a read/write of port B. (instead of being toggled immediately) [Curt Coder] --- src/emu/machine/6526cia.c | 53 +++++++++++++++++++++++++++++++-------- src/emu/machine/6526cia.h | 5 ++++ 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/src/emu/machine/6526cia.c b/src/emu/machine/6526cia.c index e1bf6c5477f..3d4b63842b6 100644 --- a/src/emu/machine/6526cia.c +++ b/src/emu/machine/6526cia.c @@ -10,9 +10,11 @@ #include "emu.h" #include "6526cia.h" -/*************************************************************************** - CONSTANTS -***************************************************************************/ + + +//************************************************************************** +// MACROS / CONSTANTS +//************************************************************************** /* CIA registers */ #define CIA_PRA 0 @@ -41,20 +43,34 @@ #define CIA_CRA_SPMODE 0x40 #define CIA_CRA_TODIN 0x80 + + //************************************************************************** // DEVICE CONFIGURATION //************************************************************************** - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - // device type definition const device_type MOS6526R1 = &device_creator; const device_type MOS6526R2 = &device_creator; const device_type MOS8520 = &device_creator; + + +//************************************************************************** +// INLINE HELPERS +//************************************************************************** + +inline attotime mos6526_device::cycles_to_time(int c) +{ + return attotime::from_hz(clock()) * c; +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + //------------------------------------------------- // mos6526_device - constructor //------------------------------------------------- @@ -174,6 +190,8 @@ void mos6526_device::device_start() } /* setup timers */ + m_pc_timer = timer_alloc(TIMER_PC); + for (int t = 0; t < (sizeof(m_timer) / sizeof(m_timer[0])); t++) { cia_timer *timer = &m_timer[t]; @@ -225,6 +243,21 @@ void mos6526_device::device_start() } +//------------------------------------------------- +// device_timer - handler timer events +//------------------------------------------------- + +void mos6526_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +{ + switch (id) + { + case TIMER_PC: + m_out_pc_func(1); + break; + } +} + + /*------------------------------------------------- set_port_mask_value -------------------------------------------------*/ @@ -240,9 +273,9 @@ void mos6526_device::set_port_mask_value(int port, int data) void mos6526_device::update_pc() { - /* this should really be one cycle long */ m_out_pc_func(0); - m_out_pc_func(1); + + m_pc_timer->adjust(cycles_to_time(1)); } /*------------------------------------------------- diff --git a/src/emu/machine/6526cia.h b/src/emu/machine/6526cia.h index ab17474524c..3aee04adcd4 100644 --- a/src/emu/machine/6526cia.h +++ b/src/emu/machine/6526cia.h @@ -132,12 +132,15 @@ protected: virtual void device_reset(); virtual void device_post_load() { } virtual void device_clock_changed() { } + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); static TIMER_CALLBACK( timer_proc ); static TIMER_CALLBACK( clock_tod_callback ); private: + static const device_timer_id TIMER_PC = 0; + inline attotime cycles_to_time(int c); void update_pc(); void update_interrupts(); void timer_bump(int timer); @@ -201,6 +204,8 @@ private: UINT8 m_cnt; UINT8 m_shift; UINT8 m_serial; + + emu_timer *m_pc_timer; }; class mos6526r1_device : public mos6526_device