Fixed SH-2 DMAC irqs, fixes at least hard-locking on Baroque [Angelo Salese]

This commit is contained in:
Angelo Salese 2013-02-18 21:18:30 +00:00
parent d9cdaf1649
commit f0c5d94a16
3 changed files with 12 additions and 4 deletions

View file

@ -418,6 +418,7 @@ void sh2_do_dma(sh2_state *sh2, int dma)
LOG(("SH2.%s: DMA %d complete\n", sh2->device->tag(), dma));
sh2->m[0x63+4*dma] |= 2;
sh2->dma_timer_active[dma] = 0;
sh2->dma_irq[dma] |= 1;
sh2_recalc_irq(sh2);
}
@ -860,19 +861,21 @@ void sh2_recalc_irq(sh2_state *sh2)
}
// DMA irqs
if((sh2->m[0x63] & 6) == 6) {
if((sh2->m[0x63] & 6) == 6 && sh2->dma_irq[0]) {
level = (sh2->m[0x38] >> 8) & 15;
if(level > irq) {
irq = level;
vector = (sh2->m[0x68] >> 24) & 0x7f;
sh2->dma_irq[0] &= ~1;
vector = (sh2->m[0x68]) & 0x7f;
}
}
if((sh2->m[0x67] & 6) == 6) {
if((sh2->m[0x67] & 6) == 6 && sh2->dma_irq[1]) {
level = (sh2->m[0x38] >> 8) & 15;
if(level > irq) {
irq = level;
vector = (sh2->m[0x6a] >> 24) & 0x7f;
sh2->dma_irq[1] &= ~1;
vector = (sh2->m[0x6a]) & 0x7f;
}
}
@ -894,6 +897,8 @@ void sh2_exception(sh2_state *sh2, const char *message, int irqline)
if (sh2->internal_irq_level == irqline)
{
vector = sh2->internal_irq_vector;
/* avoid spurious irqs with this (TODO: needs a better fix) */
sh2->internal_irq_level = -1;
LOG(("SH-2 '%s' exception #%d (internal vector: $%x) after [%s]\n", sh2->device->tag(), irqline, vector, message));
}
else
@ -1024,4 +1029,5 @@ void sh2_common_init(sh2_state *sh2, legacy_cpu_device *device, device_irq_ackno
device->save_item(NAME(sh2->internal_irq_level));
device->save_item(NAME(sh2->internal_irq_vector));
device->save_item(NAME(sh2->dma_timer_active));
device->save_item(NAME(sh2->dma_irq));
}

View file

@ -137,6 +137,7 @@ struct sh2_state
emu_timer *timer;
emu_timer *dma_current_active_timer[2];
int dma_timer_active[2];
UINT8 dma_irq[2];
int active_dma_incs[2];
int active_dma_incd[2];

View file

@ -805,6 +805,7 @@ static CPU_RESET( sh2 )
sh2->frc_base = 0;
sh2->frt_input = sh2->internal_irq_level = sh2->internal_irq_vector = 0;
sh2->dma_timer_active[0] = sh2->dma_timer_active[1] = 0;
sh2->dma_irq[0] = sh2->dma_irq[1] = 0;
sh2->ftcsr_read_callback = f;
sh2->irq_callback = save_irqcallback;