Skip to content

Commit c545ac9

Browse files
committed
h8_timer: compare match event was off by 1
1 parent 3b79698 commit c545ac9

File tree

4 files changed

+64
-61
lines changed

4 files changed

+64
-61
lines changed

Diff for: src/devices/cpu/h8/h8_timer16.cpp

+14-12
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,14 @@ void h8_timer16_channel_device::update_counter(u64 cur_time)
275275
m_tcnt = tt % m_counter_cycle;
276276

277277
for(int i = 0; i < m_tgr_count; i++) {
278-
bool match = m_tcnt == m_tgr[i] || (tt == m_tgr[i] && tt == m_counter_cycle);
278+
u16 cmp = m_tgr[i] + 1;
279+
bool match = m_tcnt == cmp || (tt == cmp && tt == m_counter_cycle);
279280
if(!match) {
280281
// Need to do additional checks here for software that polls the flags with interrupts disabled, since recalc_event only schedules IRQ events.
281282
if(prev >= m_counter_cycle)
282-
match = (m_tgr[i] > prev && tt >= m_tgr[i]) || (m_tgr[i] <= m_counter_cycle && m_tcnt < m_counter_cycle && (delta - (0x10000 - prev)) >= m_tgr[i]);
283-
else if(m_tgr[i] <= m_counter_cycle)
284-
match = delta >= m_counter_cycle || (prev < m_tgr[i] && tt >= m_tgr[i]) || (m_tcnt <= prev && m_tcnt >= m_tgr[i]);
283+
match = (cmp > prev && tt >= cmp) || (cmp <= m_counter_cycle && m_tcnt < m_counter_cycle && (delta - (0x10000 - prev)) >= cmp);
284+
else if(cmp <= m_counter_cycle)
285+
match = delta >= m_counter_cycle || (prev < cmp && tt >= cmp) || (m_tcnt <= prev && m_tcnt >= cmp);
285286

286287
if(match && BIT(m_ier, i) && m_interrupt[i] != -1)
287288
logerror("update_counter unexpected TGR %d IRQ\n, i");
@@ -327,8 +328,8 @@ void h8_timer16_channel_device::recalc_event(u64 cur_time)
327328

328329
if(m_counter_incrementing) {
329330
u32 event_delay = 0xffffffff;
330-
if(m_tgr_clearing >= 0 && m_tgr[m_tgr_clearing])
331-
m_counter_cycle = m_tgr[m_tgr_clearing];
331+
if(m_tgr_clearing >= 0)
332+
m_counter_cycle = m_tgr[m_tgr_clearing] + 1;
332333
else
333334
m_counter_cycle = 0x10000;
334335
if((m_ier & IRQ_V && m_interrupt[4] != -1) && (m_counter_cycle == 0x10000 || m_tcnt >= m_counter_cycle))
@@ -337,14 +338,15 @@ void h8_timer16_channel_device::recalc_event(u64 cur_time)
337338
for(int i = 0; i < m_tgr_count; i++)
338339
if(BIT(m_ier, i) && m_interrupt[i] != -1) {
339340
u32 new_delay = 0xffffffff;
340-
if(m_tgr[i] > m_tcnt) {
341-
if(m_tcnt >= m_counter_cycle || m_tgr[i] <= m_counter_cycle)
342-
new_delay = m_tgr[i] - m_tcnt;
343-
} else if(m_tgr[i] <= m_counter_cycle) {
341+
u16 cmp = m_tgr[i] + 1;
342+
if(cmp > m_tcnt) {
343+
if(m_tcnt >= m_counter_cycle || cmp <= m_counter_cycle)
344+
new_delay = cmp - m_tcnt;
345+
} else if(cmp <= m_counter_cycle) {
344346
if(m_tcnt < m_counter_cycle)
345-
new_delay = (m_counter_cycle - m_tcnt) + m_tgr[i];
347+
new_delay = (m_counter_cycle - m_tcnt) + cmp;
346348
else
347-
new_delay = (0x10000 - m_tcnt) + m_tgr[i];
349+
new_delay = (0x10000 - m_tcnt) + cmp;
348350
}
349351

350352
if(event_delay > new_delay)

Diff for: src/devices/cpu/h8/h8_timer8.cpp

+17-15
Original file line numberDiff line numberDiff line change
@@ -265,21 +265,22 @@ void h8_timer8_channel_device::update_counter(u64 cur_time, u64 delta)
265265
} else
266266
m_tcnt = tt % m_counter_cycle;
267267

268-
if(m_tcnt == m_tcor[0] || (tt == m_tcor[0] && tt == m_counter_cycle)) {
268+
if(u8 cmp = m_tcor[0] + 1; m_tcnt == cmp || (tt == cmp && tt == m_counter_cycle)) {
269269
if(m_chained_timer)
270270
m_chained_timer->chained_timer_tcora();
271-
272271
if(!(m_tcsr & TCSR_CMFA)) {
273272
m_tcsr |= TCSR_CMFA;
274273
if(m_tcr & TCR_CMIEA)
275274
m_intc->internal_interrupt(m_irq_ca);
276275
}
277276
}
278277

279-
if(!(m_tcsr & TCSR_CMFB) && (tt == m_tcor[1] || m_tcnt == m_tcor[1])) {
280-
m_tcsr |= TCSR_CMFB;
281-
if(m_tcr & TCR_CMIEB)
282-
m_intc->internal_interrupt(m_irq_cb);
278+
if(u8 cmp = m_tcor[1] + 1; m_tcnt == cmp || (tt == cmp && tt == m_counter_cycle)) {
279+
if(!(m_tcsr & TCSR_CMFB)) {
280+
m_tcsr |= TCSR_CMFB;
281+
if(m_tcr & TCR_CMIEB)
282+
m_intc->internal_interrupt(m_irq_cb);
283+
}
283284
}
284285

285286
if(tt >= 0x100 && (m_counter_cycle == 0x100 || prev >= m_counter_cycle)) {
@@ -309,23 +310,24 @@ void h8_timer8_channel_device::recalc_event(u64 cur_time)
309310
cur_time = m_cpu->total_cycles();
310311

311312
u32 event_delay = 0xffffffff;
312-
if((m_clear_type == CLEAR_A || m_clear_type == CLEAR_B) && m_tcor[m_clear_type - CLEAR_A])
313-
m_counter_cycle = m_tcor[m_clear_type - CLEAR_A];
313+
if(m_clear_type == CLEAR_A || m_clear_type == CLEAR_B)
314+
m_counter_cycle = m_tcor[m_clear_type - CLEAR_A] + 1;
314315
else
315316
m_counter_cycle = 0x100;
316317
if(m_counter_cycle == 0x100 || m_tcnt >= m_counter_cycle)
317318
event_delay = 0x100 - m_tcnt;
318319

319-
for(auto &elem : m_tcor) {
320+
for(auto &tcor : m_tcor) {
320321
u32 new_delay = 0xffffffff;
321-
if(elem > m_tcnt) {
322-
if(m_tcnt >= m_counter_cycle || elem <= m_counter_cycle)
323-
new_delay = elem - m_tcnt;
324-
} else if(elem <= m_counter_cycle) {
322+
u8 cmp = tcor + 1;
323+
if(cmp > m_tcnt) {
324+
if(m_tcnt >= m_counter_cycle || cmp <= m_counter_cycle)
325+
new_delay = cmp - m_tcnt;
326+
} else if(cmp <= m_counter_cycle) {
325327
if(m_tcnt < m_counter_cycle)
326-
new_delay = (m_counter_cycle - m_tcnt) + elem;
328+
new_delay = (m_counter_cycle - m_tcnt) + cmp;
327329
else
328-
new_delay = (0x100 - m_tcnt) + elem;
330+
new_delay = (0x100 - m_tcnt) + cmp;
329331
}
330332
if(event_delay > new_delay)
331333
event_delay = new_delay;

Diff for: src/mame/chess/excal_ivant.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Hardware notes:
1616
1717
The MCU used here is a HD6433256A33P from Excalibur Mirage, the internal ROM
1818
is disabled. There's also a newer version on a H8/3216. The first version was
19-
manufactured by CXG.
19+
produced in a CXG factory.
2020
2121
TODO:
2222
- it does a cold boot at every reset, so nvram won't work properly unless MAME
@@ -238,7 +238,6 @@ u8 ivant_state::p6_r()
238238
void ivant_state::main_map(address_map &map)
239239
{
240240
map(0x0000, 0x0007).mirror(0xfff8).w(FUNC(ivant_state::latch_w));
241-
map(0x0000, 0xffff).w(FUNC(ivant_state::latch_w));
242241
map(0x0000, 0x7fff).rom();
243242
map(0x8000, 0xbfff).bankr(m_rombank);
244243
}

Diff for: src/mame/namco/namcos23.cpp

+32-32
Original file line numberDiff line numberDiff line change
@@ -5597,37 +5597,37 @@ ROM_END
55975597

55985598

55995599
/* Games */
5600-
#define GAME_FLAGS (MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION | MACHINE_IMPERFECT_GRAPHICS )
5601-
// YEAR, NAME, PARENT, MACHINE, INPUT, CLASS, INIT, MNTR, COMPANY, FULLNAME, FLAGS
5602-
GAME( 1997, rapidrvr, 0, gorgon, rapidrvr, namcos23_state, init_s23, ROT0, "Namco", "Rapid River (US, RD3 Ver. C)", GAME_FLAGS ) // 97/11/27, USA
5603-
GAME( 1997, rapidrvrv2c, rapidrvr, gorgon, rapidrvr, namcos23_state, init_s23, ROT0, "Namco", "Rapid River (World, RD2 Ver. C)", GAME_FLAGS ) // 97/11/27, Europe
5604-
GAME( 1997, rapidrvrp, rapidrvr, gorgon, rapidrvrp, namcos23_state, init_s23, ROT0, "Namco", "Rapid River (prototype)", GAME_FLAGS ) // 97/11/10, USA
5605-
GAME( 1997, finfurl, 0, gorgon, finfurl, namcos23_state, init_s23, ROT0, "Namco", "Final Furlong (World, FF2 Ver. A)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5606-
GAME( 1997, downhill, 0, s23, downhill, namcos23_state, init_s23, ROT0, "Namco", "Downhill Bikers (World, DH2 Ver. A)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5607-
GAME( 1997, downhillu, downhill, s23, downhill, namcos23_state, init_s23, ROT0, "Namco", "Downhill Bikers (US, DH3 Ver. A)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5608-
GAME( 1997, motoxgo, 0, motoxgo, s23, namcos23_state, init_s23, ROT0, "Namco", "Motocross Go! (US, MG3 Ver. A)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5609-
GAME( 1997, motoxgov2a, motoxgo, motoxgo, s23, namcos23_state, init_s23, ROT0, "Namco", "Motocross Go! (World, MG2 Ver. A, set 1)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5610-
GAME( 1997, motoxgov2a2, motoxgo, motoxgo, s23, namcos23_state, init_s23, ROT0, "Namco", "Motocross Go! (World, MG2 Ver. A, set 2)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5600+
#define GAME_FLAGS (MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION | MACHINE_IMPERFECT_GRAPHICS)
5601+
// YEAR, NAME, PARENT, MACHINE, INPUT, CLASS, INIT, MNTR, COMPANY, FULLNAME, FLAGS
5602+
GAME( 1997, rapidrvr, 0, gorgon, rapidrvr, namcos23_state, init_s23, ROT0, "Namco", "Rapid River (US, RD3 Ver. C)", GAME_FLAGS ) // 97/11/27, USA
5603+
GAME( 1997, rapidrvrv2c, rapidrvr, gorgon, rapidrvr, namcos23_state, init_s23, ROT0, "Namco", "Rapid River (World, RD2 Ver. C)", GAME_FLAGS ) // 97/11/27, Europe
5604+
GAME( 1997, rapidrvrp, rapidrvr, gorgon, rapidrvrp, namcos23_state, init_s23, ROT0, "Namco", "Rapid River (prototype)", GAME_FLAGS ) // 97/11/10, USA
5605+
GAME( 1997, finfurl, 0, gorgon, finfurl, namcos23_state, init_s23, ROT0, "Namco", "Final Furlong (World, FF2 Ver. A)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5606+
GAME( 1997, downhill, 0, s23, downhill, namcos23_state, init_s23, ROT0, "Namco", "Downhill Bikers (World, DH2 Ver. A)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5607+
GAME( 1997, downhillu, downhill, s23, downhill, namcos23_state, init_s23, ROT0, "Namco", "Downhill Bikers (US, DH3 Ver. A)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5608+
GAME( 1997, motoxgo, 0, motoxgo, s23, namcos23_state, init_s23, ROT0, "Namco", "Motocross Go! (US, MG3 Ver. A)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5609+
GAME( 1997, motoxgov2a, motoxgo, motoxgo, s23, namcos23_state, init_s23, ROT0, "Namco", "Motocross Go! (World, MG2 Ver. A, set 1)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5610+
GAME( 1997, motoxgov2a2, motoxgo, motoxgo, s23, namcos23_state, init_s23, ROT0, "Namco", "Motocross Go! (World, MG2 Ver. A, set 2)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
56115611
GAME( 1997, motoxgov1a, motoxgo, motoxgo, s23, namcos23_state, init_s23, ROT0, "Namco", "Motocross Go! (Japan, MG1 Ver. A, set 1)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
56125612
GAME( 1997, motoxgov1a2, motoxgo, motoxgo, s23, namcos23_state, init_s23, ROT0, "Namco", "Motocross Go! (Japan, MG1 Ver. A, set 2)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5613-
GAME( 1997, timecrs2, 0, timecrs2, timecrs2, namcos23_state, init_s23, ROT0, "Namco", "Time Crisis II (US, TSS3 Ver. B)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5614-
GAME( 1997, timecrs2v2b, timecrs2, timecrs2, timecrs2, namcos23_state, init_s23, ROT0, "Namco", "Time Crisis II (World, TSS2 Ver. B)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5615-
GAME( 1997, timecrs2v1b, timecrs2, timecrs2, timecrs2, namcos23_state, init_s23, ROT0, "Namco", "Time Crisis II (Japan, TSS1 Ver. B)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5616-
GAME( 1997, timecrs2v4a, timecrs2, timecrs2v4a, timecrs2, namcos23_state, init_s23, ROT0, "Namco", "Time Crisis II (World, TSS4 Ver. A)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5617-
GAME( 1997, timecrs2v5a, timecrs2, timecrs2v4a, timecrs2, namcos23_state, init_s23, ROT0, "Namco", "Time Crisis II (US, TSS5 Ver. A)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5618-
GAME( 1997, panicprk, 0, s23, s23, namcos23_state, init_s23, ROT0, "Namco", "Panic Park (World, PNP2 Ver. A)", GAME_FLAGS )
5619-
GAME( 1997, panicprkj, panicprk, s23, s23, namcos23_state, init_s23, ROT0, "Namco", "Panic Park (Japan, PNP1 Ver. B, set 1)", GAME_FLAGS )
5620-
GAME( 1997, panicprkj2, panicprk, s23, s23, namcos23_state, init_s23, ROT0, "Namco", "Panic Park (Japan, PNP1 Ver. B, set 2)", GAME_FLAGS )
5621-
GAME( 1998, gunwars, 0, gmen, s23, namcos23_state, init_s23, ROT0, "Namco", "Gunmen Wars (Japan, GM1 Ver. B)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5622-
GAME( 1998, gunwarsa, gunwars, gmen, s23, namcos23_state, init_s23, ROT0, "Namco", "Gunmen Wars (Japan, GM1 Ver. A)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5623-
GAME( 1998, raceon, 0, gmen, s23, namcos23_state, init_s23, ROT0, "Namco", "Race On! (World, RO2 Ver. A)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5624-
GAME( 1998, 500gp, 0, ss23, 500gp, namcos23_state, init_s23, ROT0, "Namco", "500 GP (US, 5GP3 Ver. C)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5625-
GAME( 1998, aking, 0, ss23, s23, namcos23_state, init_s23, ROT0, "Namco", "Angler King (Japan, AG1 Ver. A)", GAME_FLAGS )
5626-
GAME( 1998, finfurl2, 0, gmen, s23, namcos23_state, init_s23, ROT0, "Namco", "Final Furlong 2 (World)", GAME_FLAGS | MACHINE_NODEVICE_LAN ) // 99/02/26 15:08:47 Overseas
5627-
GAME( 1998, finfurl2j, finfurl2, gmen, s23, namcos23_state, init_s23, ROT0, "Namco", "Final Furlong 2 (Japan, FFS1 Ver.A)", GAME_FLAGS | MACHINE_NODEVICE_LAN ) // 99/02/26 15:03:14 Japanese
5628-
GAME( 1999, crszone, 0, ss23e2, s23, namcos23_state, init_s23, ROT0, "Namco", "Crisis Zone (World, CSZO4 Ver. B)", GAME_FLAGS )
5629-
GAME( 1999, crszonev4a, crszone, ss23e2, s23, namcos23_state, init_s23, ROT0, "Namco", "Crisis Zone (World, CSZO4 Ver. A)", GAME_FLAGS )
5630-
GAME( 1999, crszonev3b, crszone, ss23e2, s23, namcos23_state, init_s23, ROT0, "Namco", "Crisis Zone (US, CSZO3 Ver. B, set 1)", GAME_FLAGS )
5631-
GAME( 1999, crszonev3b2, crszone, ss23e2, s23, namcos23_state, init_s23, ROT0, "Namco", "Crisis Zone (US, CSZO3 Ver. B, set 2)", GAME_FLAGS )
5632-
GAME( 1999, crszonev3a, crszone, ss23e2, s23, namcos23_state, init_s23, ROT0, "Namco", "Crisis Zone (US, CSZO3 Ver. A)", GAME_FLAGS )
5633-
GAME( 1999, crszonev2a, crszone, ss23e2, s23, namcos23_state, init_s23, ROT0, "Namco", "Crisis Zone (World, CSZO2 Ver. A)", GAME_FLAGS )
5613+
GAME( 1997, timecrs2, 0, timecrs2, timecrs2, namcos23_state, init_s23, ROT0, "Namco", "Time Crisis II (US, TSS3 Ver. B)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5614+
GAME( 1997, timecrs2v2b, timecrs2, timecrs2, timecrs2, namcos23_state, init_s23, ROT0, "Namco", "Time Crisis II (World, TSS2 Ver. B)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5615+
GAME( 1997, timecrs2v1b, timecrs2, timecrs2, timecrs2, namcos23_state, init_s23, ROT0, "Namco", "Time Crisis II (Japan, TSS1 Ver. B)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5616+
GAME( 1997, timecrs2v4a, timecrs2, timecrs2v4a, timecrs2, namcos23_state, init_s23, ROT0, "Namco", "Time Crisis II (World, TSS4 Ver. A)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5617+
GAME( 1997, timecrs2v5a, timecrs2, timecrs2v4a, timecrs2, namcos23_state, init_s23, ROT0, "Namco", "Time Crisis II (US, TSS5 Ver. A)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5618+
GAME( 1997, panicprk, 0, s23, s23, namcos23_state, init_s23, ROT0, "Namco", "Panic Park (World, PNP2 Ver. A)", GAME_FLAGS )
5619+
GAME( 1997, panicprkj, panicprk, s23, s23, namcos23_state, init_s23, ROT0, "Namco", "Panic Park (Japan, PNP1 Ver. B, set 1)", GAME_FLAGS )
5620+
GAME( 1997, panicprkj2, panicprk, s23, s23, namcos23_state, init_s23, ROT0, "Namco", "Panic Park (Japan, PNP1 Ver. B, set 2)", GAME_FLAGS )
5621+
GAME( 1998, gunwars, 0, gmen, s23, namcos23_state, init_s23, ROT0, "Namco", "Gunmen Wars (Japan, GM1 Ver. B)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5622+
GAME( 1998, gunwarsa, gunwars, gmen, s23, namcos23_state, init_s23, ROT0, "Namco", "Gunmen Wars (Japan, GM1 Ver. A)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5623+
GAME( 1998, raceon, 0, gmen, s23, namcos23_state, init_s23, ROT0, "Namco", "Race On! (World, RO2 Ver. A)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5624+
GAME( 1998, 500gp, 0, ss23, 500gp, namcos23_state, init_s23, ROT0, "Namco", "500 GP (US, 5GP3 Ver. C)", GAME_FLAGS | MACHINE_NODEVICE_LAN )
5625+
GAME( 1998, aking, 0, ss23, s23, namcos23_state, init_s23, ROT0, "Namco", "Angler King (Japan, AG1 Ver. A)", GAME_FLAGS )
5626+
GAME( 1998, finfurl2, 0, gmen, s23, namcos23_state, init_s23, ROT0, "Namco", "Final Furlong 2 (World)", GAME_FLAGS | MACHINE_NODEVICE_LAN ) // 99/02/26 15:08:47 Overseas
5627+
GAME( 1998, finfurl2j, finfurl2, gmen, s23, namcos23_state, init_s23, ROT0, "Namco", "Final Furlong 2 (Japan, FFS1 Ver.A)", GAME_FLAGS | MACHINE_NODEVICE_LAN ) // 99/02/26 15:03:14 Japanese
5628+
GAME( 1999, crszone, 0, ss23e2, s23, namcos23_state, init_s23, ROT0, "Namco", "Crisis Zone (World, CSZO4 Ver. B)", GAME_FLAGS )
5629+
GAME( 1999, crszonev4a, crszone, ss23e2, s23, namcos23_state, init_s23, ROT0, "Namco", "Crisis Zone (World, CSZO4 Ver. A)", GAME_FLAGS )
5630+
GAME( 1999, crszonev3b, crszone, ss23e2, s23, namcos23_state, init_s23, ROT0, "Namco", "Crisis Zone (US, CSZO3 Ver. B, set 1)", GAME_FLAGS )
5631+
GAME( 1999, crszonev3b2, crszone, ss23e2, s23, namcos23_state, init_s23, ROT0, "Namco", "Crisis Zone (US, CSZO3 Ver. B, set 2)", GAME_FLAGS )
5632+
GAME( 1999, crszonev3a, crszone, ss23e2, s23, namcos23_state, init_s23, ROT0, "Namco", "Crisis Zone (US, CSZO3 Ver. A)", GAME_FLAGS )
5633+
GAME( 1999, crszonev2a, crszone, ss23e2, s23, namcos23_state, init_s23, ROT0, "Namco", "Crisis Zone (World, CSZO2 Ver. A)", GAME_FLAGS )

0 commit comments

Comments
 (0)