Merge pull request #596 from Kagamiin/feature/vrc-irq-cycle-mode
Implementing cycle IRQ mode for Konami VRC mappers
This commit is contained in:
commit
552be94c1a
|
@ -23,7 +23,7 @@
|
|||
static bool isPirate;
|
||||
static uint8 is22, reg1mask, reg2mask;
|
||||
static uint16 IRQCount;
|
||||
static uint8 IRQLatch, IRQa;
|
||||
static uint8 IRQLatch, IRQa, IRQMode;
|
||||
static uint8 prgreg[2], chrreg[8];
|
||||
static uint16 chrhi[8];
|
||||
static uint8 regcmd, irqcmd, mirr, big_bank;
|
||||
|
@ -45,6 +45,7 @@ static SFORMAT StateRegs[] =
|
|||
{ &IRQCount, 2, "IRQC" },
|
||||
{ &IRQLatch, 1, "IRQL" },
|
||||
{ &IRQa, 1, "IRQA" },
|
||||
{ &IRQMode, 1, "IRQM" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
|
@ -115,7 +116,7 @@ static DECLFW(VRC24Write) {
|
|||
case 0x9003: regcmd = V; Sync(); break;
|
||||
case 0xF000: X6502_IRQEnd(FCEU_IQEXT); IRQLatch &= 0xF0; IRQLatch |= V & 0xF; break;
|
||||
case 0xF001: X6502_IRQEnd(FCEU_IQEXT); IRQLatch &= 0x0F; IRQLatch |= V << 4; break;
|
||||
case 0xF002: X6502_IRQEnd(FCEU_IQEXT); acount = 0; IRQCount = IRQLatch; IRQa = V & 2; irqcmd = V & 1; break;
|
||||
case 0xF002: X6502_IRQEnd(FCEU_IQEXT); acount = 0; IRQCount = IRQLatch; IRQMode = V & 4; IRQa = V & 2; irqcmd = V & 1; break;
|
||||
case 0xF003: X6502_IRQEnd(FCEU_IQEXT); IRQa = irqcmd; break;
|
||||
}
|
||||
}
|
||||
|
@ -136,6 +137,17 @@ static void VRC24Power(void) {
|
|||
void VRC24IRQHook(int a) {
|
||||
#define LCYCS 341
|
||||
if (IRQa) {
|
||||
if (IRQMode) {
|
||||
acount += a;
|
||||
while (acount > 0) {
|
||||
acount--;
|
||||
IRQCount++;
|
||||
if (IRQCount & 0x100) {
|
||||
X6502_IRQBegin(FCEU_IQEXT);
|
||||
IRQCount = IRQLatch;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
acount += a * 3;
|
||||
if (acount >= LCYCS) {
|
||||
while (acount >= LCYCS) {
|
||||
|
@ -148,6 +160,7 @@ void VRC24IRQHook(int a) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void StateRestore(int version) {
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
static uint8 is26;
|
||||
static uint8 prg[2], chr[8], mirr;
|
||||
static uint8 IRQLatch, IRQa, IRQd;
|
||||
static uint8 IRQLatch, IRQa, IRQd, IRQMode;
|
||||
static int32 IRQCount, CycleCount;
|
||||
static uint8 *WRAM = NULL;
|
||||
static uint32 WRAMSIZE;
|
||||
|
@ -40,6 +40,7 @@ static SFORMAT StateRegs[] =
|
|||
{ &IRQLatch, 1, "IRQL" },
|
||||
{ &IRQCount, 4, "IRQC" },
|
||||
{ &CycleCount, 4, "CYCC" },
|
||||
{ &IRQMode, 1, "IRQM" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
|
@ -109,6 +110,7 @@ static DECLFW(VRC6Write) {
|
|||
case 0xE003: chr[7] = V; Sync(); break;
|
||||
case 0xF000: IRQLatch = V; X6502_IRQEnd(FCEU_IQEXT); break;
|
||||
case 0xF001:
|
||||
IRQMode = V & 4;
|
||||
IRQa = V & 2;
|
||||
IRQd = V & 1;
|
||||
if (V & 2)
|
||||
|
@ -132,6 +134,17 @@ static void VRC6Power(void) {
|
|||
|
||||
static void VRC6IRQHook(int a) {
|
||||
if (IRQa) {
|
||||
if (IRQMode) {
|
||||
CycleCount += a;
|
||||
while (CycleCount > 0) {
|
||||
CycleCount--;
|
||||
IRQCount++;
|
||||
if (IRQCount & 0x100) {
|
||||
X6502_IRQBegin(FCEU_IQEXT);
|
||||
IRQCount = IRQLatch;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
CycleCount += a * 3;
|
||||
while(CycleCount >= 341) {
|
||||
CycleCount -= 341;
|
||||
|
@ -142,6 +155,7 @@ static void VRC6IRQHook(int a) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void VRC6Close(void)
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "mapinc.h"
|
||||
|
||||
static uint8 vrc7idx, preg[3], creg[8], mirr;
|
||||
static uint8 IRQLatch, IRQa, IRQd;
|
||||
static uint8 IRQLatch, IRQa, IRQd, IRQMode;
|
||||
static int32 IRQCount, CycleCount;
|
||||
static uint8 *WRAM = NULL;
|
||||
static uint32 WRAMSIZE;
|
||||
|
@ -44,6 +44,7 @@ static SFORMAT StateRegs[] =
|
|||
{ &IRQCount, 4, "IRQC" },
|
||||
{ &CycleCount, 4, "CYCC" },
|
||||
{ (void**)VRC7Sound_saveptr, sizeof(*VRC7Sound) | FCEUSTATE_INDIRECT, "VRC7" },
|
||||
{ &IRQMode, 1, "IRQM" },
|
||||
{0}
|
||||
};
|
||||
|
||||
|
@ -134,6 +135,7 @@ static DECLFW(VRC7Write) {
|
|||
case 0xE000: mirr = V & 3; Sync(); break;
|
||||
case 0xE010: IRQLatch = V; X6502_IRQEnd(FCEU_IQEXT); break;
|
||||
case 0xF000:
|
||||
IRQMode = V & 4;
|
||||
IRQa = V & 2;
|
||||
IRQd = V & 1;
|
||||
if (V & 2)
|
||||
|
@ -165,6 +167,17 @@ static void VRC7Close(void)
|
|||
|
||||
static void VRC7IRQHook(int a) {
|
||||
if (IRQa) {
|
||||
if (IRQMode) {
|
||||
CycleCount += a;
|
||||
while (CycleCount > 0) {
|
||||
CycleCount--;
|
||||
IRQCount++;
|
||||
if (IRQCount & 0x100) {
|
||||
X6502_IRQBegin(FCEU_IQEXT);
|
||||
IRQCount = IRQLatch;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
CycleCount += a * 3;
|
||||
while(CycleCount >= 341) {
|
||||
CycleCount -= 341;
|
||||
|
@ -175,6 +188,7 @@ static void VRC7IRQHook(int a) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void StateRestore(int version) {
|
||||
|
|
Loading…
Reference in New Issue