summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Curt Coder <curtcoder@mail.com>2015-05-25 21:32:55 +0300
committer Curt Coder <curtcoder@mail.com>2015-05-25 21:33:03 +0300
commit1963cf696766dafc768979db3876aba1476a92ea (patch)
tree4eb8a26b067a0b99a8ccd4789b44ee93d0612dbf
parent4d5b72800f13013a89cfd990eb688b5538441f31 (diff)
mos6530n: Fixed timer last count. (nw)
-rw-r--r--src/emu/machine/mos6530n.c63
-rw-r--r--src/emu/machine/mos6530n.h5
-rw-r--r--src/mess/drivers/a2600.c28
-rw-r--r--src/mess/drivers/a7800.c22
4 files changed, 56 insertions, 62 deletions
diff --git a/src/emu/machine/mos6530n.c b/src/emu/machine/mos6530n.c
index 76e1b9de263..a1a9d196548 100644
--- a/src/emu/machine/mos6530n.c
+++ b/src/emu/machine/mos6530n.c
@@ -216,7 +216,7 @@ void mos6530_base_t::device_start()
save_item(NAME(m_irq_timer));
save_item(NAME(m_ie_edge));
save_item(NAME(m_irq_edge));
- save_item(NAME(m_shift));
+ save_item(NAME(m_prescale));
save_item(NAME(m_timer));
}
@@ -259,7 +259,7 @@ void mos6530_base_t::device_reset()
update_irq();
edge_detect();
- m_shift = 1024;
+ m_prescale = 1024;
if (cur_live.state != IDLE) {
live_abort();
@@ -619,7 +619,9 @@ UINT8 mos6530_base_t::timer_r(bool ie)
live_sync();
m_ie_timer = ie;
- m_irq_timer = false;
+ if (cur_live.tm_irq != machine().time()) {
+ m_irq_timer = false;
+ }
update_irq();
data = cur_live.value;
@@ -673,17 +675,19 @@ void mos6530_base_t::timer_w(offs_t offset, UINT8 data, bool ie)
m_timer = data;
switch (offset & 0x03) {
- case 0: m_shift = 1; break;
- case 1: m_shift = 8; break;
- case 2: m_shift = 64; break;
- case 3: m_shift = 1024; break;
+ case 0: m_prescale = 1; break;
+ case 1: m_prescale = 8; break;
+ case 2: m_prescale = 64; break;
+ case 3: m_prescale = 1024; break;
}
m_ie_timer = ie;
- m_irq_timer = false;
+ if (cur_live.tm_irq != machine().time()) {
+ m_irq_timer = false;
+ }
update_irq();
- if (LOG_TIMER) logerror("%s %s %s '%s' Timer value %02x shift %u IE %u\n", machine().time().as_string(), machine().describe_context(), name(), tag(), data, m_shift, m_ie_timer ? 1 : 0);
+ if (LOG_TIMER) logerror("%s %s %s '%s' Timer value %02x prescale %u IE %u\n", machine().time().as_string(), machine().describe_context(), name(), tag(), data, m_prescale, m_ie_timer ? 1 : 0);
checkpoint();
@@ -715,14 +719,14 @@ WRITE8_MEMBER( mos6530_base_t::edge_w )
void mos6530_base_t::live_start()
{
- cur_live.period = attotime::from_hz(clock() / m_shift);
+ cur_live.period = attotime::from_ticks(m_prescale, clock());
cur_live.tm = machine().time() + attotime::from_hz(clock());
cur_live.state = RUNNING;
cur_live.next_state = -1;
cur_live.value = m_timer;
- checkpoint_live = cur_live;
+ checkpoint();
live_run();
}
@@ -776,6 +780,7 @@ void mos6530_base_t::live_abort()
cur_live.tm = attotime::never;
cur_live.state = IDLE;
cur_live.next_state = -1;
+ cur_live.tm_irq = attotime::never;
}
void mos6530_base_t::live_run(const attotime &limit)
@@ -791,39 +796,29 @@ void mos6530_base_t::live_run(const attotime &limit)
cur_live.value--;
- if (LOG_TIMER) logerror("%s %s '%s' timer %02x IRQ 1\n", cur_live.tm.as_string(), name(), tag(), cur_live.value);
+ if (cur_live.value == 0xff) {
+ live_delay(RUNNING_SYNCPOINT);
+ return;
+ } else {
+ if (LOG_TIMER) logerror("%s %s '%s' timer %02x\n", cur_live.tm.as_string(), name(), tag(), cur_live.value);
- if (!cur_live.value) {
- cur_live.period = attotime::from_hz(clock());
- cur_live.state = RUNNING_INTERRUPT;
+ cur_live.tm += cur_live.period;
}
-
- cur_live.tm += cur_live.period;
break;
}
- case RUNNING_INTERRUPT: {
- if (cur_live.tm > limit)
- return;
-
- cur_live.value--;
-
- if (LOG_TIMER) logerror("%s %s '%s' timer %02x IRQ 0\n", cur_live.tm.as_string(), name(), tag(), cur_live.value);
-
- live_delay(RUNNING_SYNCPOINT);
-
- cur_live.tm += cur_live.period;
- return;
- }
-
case RUNNING_SYNCPOINT: {
- if (LOG_TIMER) logerror("%s %s '%s' timer IRQ\n", machine().time().as_string(), name(), tag());
+ if (LOG_TIMER) logerror("%s %s '%s' timer %02x interrupt\n", cur_live.tm.as_string(), name(), tag(), cur_live.value);
+ cur_live.tm_irq = cur_live.tm;
m_irq_timer = true;
update_irq();
- cur_live.state = RUNNING_AFTER_INTERRUPT;
checkpoint();
+
+ cur_live.state = RUNNING_AFTER_INTERRUPT;
+ cur_live.period = attotime::from_hz(clock());
+ cur_live.tm += cur_live.period;
break;
}
@@ -833,7 +828,7 @@ void mos6530_base_t::live_run(const attotime &limit)
cur_live.value--;
- if (LOG_TIMER) logerror("%s %s '%s' timer %02x IRQ 0\n", cur_live.tm.as_string(), name(), tag(), cur_live.value);
+ if (LOG_TIMER) logerror("%s %s '%s' timer %02x\n", cur_live.tm.as_string(), name(), tag(), cur_live.value);
if (!cur_live.value) {
cur_live.state = IDLE;
diff --git a/src/emu/machine/mos6530n.h b/src/emu/machine/mos6530n.h
index 2fe851ace12..01044ac7c7b 100644
--- a/src/emu/machine/mos6530n.h
+++ b/src/emu/machine/mos6530n.h
@@ -341,19 +341,18 @@ protected:
bool m_ie_edge;
bool m_irq_edge;
- int m_shift;
+ int m_prescale;
UINT8 m_timer;
enum {
IDLE,
RUNNING,
- RUNNING_INTERRUPT,
RUNNING_SYNCPOINT,
RUNNING_AFTER_INTERRUPT
};
struct live_info {
- attotime tm;
+ attotime tm, tm_irq;
attotime period;
int state, next_state;
UINT8 value;
diff --git a/src/mess/drivers/a2600.c b/src/mess/drivers/a2600.c
index 7a0197bf083..35c9dacf0c5 100644
--- a/src/mess/drivers/a2600.c
+++ b/src/mess/drivers/a2600.c
@@ -11,7 +11,7 @@ TODO:
***************************************************************************/
#include "emu.h"
-#include "machine/6532riot.h"
+#include "machine/mos6530n.h"
#include "cpu/m6502/m6502.h"
#include "sound/tiaintf.h"
#include "video/tia.h"
@@ -81,7 +81,7 @@ static ADDRESS_MAP_START(a2600_mem, AS_PROGRAM, 8, a2600_state )
ADDRESS_MAP_GLOBAL_MASK(0x1fff)
AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x0f00) AM_DEVREADWRITE("tia_video", tia_video_device, read, write)
AM_RANGE(0x0080, 0x00ff) AM_MIRROR(0x0d00) AM_RAM AM_SHARE("riot_ram")
- AM_RANGE(0x0280, 0x029f) AM_MIRROR(0x0d00) AM_DEVREADWRITE("riot", riot6532_device, read, write)
+ AM_RANGE(0x0280, 0x029f) AM_MIRROR(0x0d00) AM_DEVICE("riot", mos6532_t, io_map)
// AM_RANGE(0x1000, 0x1fff) is cart data and it is configured at reset time, depending on the mounted cart!
ADDRESS_MAP_END
@@ -482,12 +482,12 @@ static MACHINE_CONFIG_START( a2600, a2600_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.90)
/* devices */
- MCFG_DEVICE_ADD("riot", RIOT6532, MASTER_CLOCK_NTSC / 3)
- MCFG_RIOT6532_IN_PA_CB(READ8(a2600_state, switch_A_r))
- MCFG_RIOT6532_OUT_PA_CB(WRITE8(a2600_state, switch_A_w))
- MCFG_RIOT6532_IN_PB_CB(READ8(a2600_state, riot_input_port_8_r))
- MCFG_RIOT6532_OUT_PB_CB(WRITE8(a2600_state, switch_B_w))
- MCFG_RIOT6532_IRQ_CB(WRITELINE(a2600_state, irq_callback))
+ MCFG_DEVICE_ADD("riot", MOS6532n, MASTER_CLOCK_NTSC / 3)
+ MCFG_MOS6530n_IN_PA_CB(READ8(a2600_state, switch_A_r))
+ MCFG_MOS6530n_OUT_PA_CB(WRITE8(a2600_state, switch_A_w))
+ MCFG_MOS6530n_IN_PB_CB(READ8(a2600_state, riot_input_port_8_r))
+ MCFG_MOS6530n_OUT_PB_CB(WRITE8(a2600_state, switch_B_w))
+ MCFG_MOS6530n_IRQ_CB(WRITELINE(a2600_state, irq_callback))
MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, "joy")
MCFG_VCS_CONTROL_PORT_ADD(CONTROL2_TAG, vcs_control_port_devices, NULL)
@@ -523,12 +523,12 @@ static MACHINE_CONFIG_START( a2600p, a2600_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.90)
/* devices */
- MCFG_DEVICE_ADD("riot", RIOT6532, MASTER_CLOCK_PAL / 3)
- MCFG_RIOT6532_IN_PA_CB(READ8(a2600_state, switch_A_r))
- MCFG_RIOT6532_OUT_PA_CB(WRITE8(a2600_state, switch_A_w))
- MCFG_RIOT6532_IN_PB_CB(READ8(a2600_state, riot_input_port_8_r))
- MCFG_RIOT6532_OUT_PB_CB(WRITE8(a2600_state, switch_B_w))
- MCFG_RIOT6532_IRQ_CB(WRITELINE(a2600_state, irq_callback))
+ MCFG_DEVICE_ADD("riot", MOS6532n, MASTER_CLOCK_PAL / 3)
+ MCFG_MOS6530n_IN_PA_CB(READ8(a2600_state, switch_A_r))
+ MCFG_MOS6530n_OUT_PA_CB(WRITE8(a2600_state, switch_A_w))
+ MCFG_MOS6530n_IN_PB_CB(READ8(a2600_state, riot_input_port_8_r))
+ MCFG_MOS6530n_OUT_PB_CB(WRITE8(a2600_state, switch_B_w))
+ MCFG_MOS6530n_IRQ_CB(WRITELINE(a2600_state, irq_callback))
MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, "joy")
MCFG_VCS_CONTROL_PORT_ADD(CONTROL2_TAG, vcs_control_port_devices, NULL)
diff --git a/src/mess/drivers/a7800.c b/src/mess/drivers/a7800.c
index d4b52f97204..1db3f4aba25 100644
--- a/src/mess/drivers/a7800.c
+++ b/src/mess/drivers/a7800.c
@@ -100,7 +100,7 @@
#include "cpu/m6502/m6502.h"
#include "sound/tiaintf.h"
#include "sound/tiasound.h"
-#include "machine/6532riot.h"
+#include "machine/mos6530n.h"
#include "video/maria.h"
#include "bus/a7800/a78_carts.h"
@@ -284,8 +284,8 @@ static ADDRESS_MAP_START( a7800_mem, AS_PROGRAM, 8, a7800_state )
AM_RANGE(0x0020, 0x003f) AM_MIRROR(0x300) AM_DEVREADWRITE("maria", atari_maria_device, read, write)
AM_RANGE(0x0040, 0x00ff) AM_RAMBANK("zpmirror") // mirror of 0x2040-0x20ff, for zero page
AM_RANGE(0x0140, 0x01ff) AM_RAMBANK("spmirror") // mirror of 0x2140-0x21ff, for stack page
- AM_RANGE(0x0280, 0x02ff) AM_DEVREADWRITE("riot", riot6532_device, read, write)
- AM_RANGE(0x0480, 0x04ff) AM_RAM AM_SHARE("riot_ram") AM_MIRROR(0x100)
+ AM_RANGE(0x0280, 0x029f) AM_MIRROR(0x60) AM_DEVICE("riot", mos6532_t, io_map)
+ AM_RANGE(0x0480, 0x04ff) AM_MIRROR(0x100) AM_DEVICE("riot", mos6532_t, ram_map)
AM_RANGE(0x1800, 0x1fff) AM_RAM AM_SHARE("6116_1")
AM_RANGE(0x2000, 0x27ff) AM_RAM AM_SHARE("6116_2") AM_MIRROR(0x0800)
// According to the official Software Guide, the RAM at 0x2000 is
@@ -1375,10 +1375,10 @@ static MACHINE_CONFIG_START( a7800_ntsc, a7800_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
/* devices */
- MCFG_DEVICE_ADD("riot", RIOT6532, A7800_NTSC_Y1/8)
- MCFG_RIOT6532_IN_PA_CB(READ8(a7800_state, riot_joystick_r))
- MCFG_RIOT6532_IN_PB_CB(READ8(a7800_state, riot_console_button_r))
- MCFG_RIOT6532_OUT_PB_CB(WRITE8(a7800_state, riot_button_pullup_w))
+ MCFG_DEVICE_ADD("riot", MOS6532n, A7800_NTSC_Y1/8)
+ MCFG_MOS6530n_IN_PA_CB(READ8(a7800_state, riot_joystick_r))
+ MCFG_MOS6530n_IN_PB_CB(READ8(a7800_state, riot_console_button_r))
+ MCFG_MOS6530n_OUT_PB_CB(WRITE8(a7800_state, riot_button_pullup_w))
MCFG_A78_CARTRIDGE_ADD("cartslot", a7800_cart, NULL)
@@ -1402,10 +1402,10 @@ static MACHINE_CONFIG_DERIVED( a7800_pal, a7800_ntsc )
/* devices */
MCFG_DEVICE_REMOVE("riot")
- MCFG_DEVICE_ADD("riot", RIOT6532, CLK_PAL)
- MCFG_RIOT6532_IN_PA_CB(READ8(a7800_state, riot_joystick_r))
- MCFG_RIOT6532_IN_PB_CB(READ8(a7800_state, riot_console_button_r))
- MCFG_RIOT6532_OUT_PB_CB(WRITE8(a7800_state, riot_button_pullup_w))
+ MCFG_DEVICE_ADD("riot", MOS6532n, CLK_PAL)
+ MCFG_MOS6530n_IN_PA_CB(READ8(a7800_state, riot_joystick_r))
+ MCFG_MOS6530n_IN_PB_CB(READ8(a7800_state, riot_console_button_r))
+ MCFG_MOS6530n_OUT_PB_CB(WRITE8(a7800_state, riot_button_pullup_w))
/* software lists */
MCFG_DEVICE_REMOVE("cart_list")