UINT16 __fastcall korokoroReadWord(UINT32 sekAddress) { switch (sekAddress) { case 0x1c0000: case 0x300000: return (nUnknownIRQ << 1) | nVideoIRQ | (bVBlank ? 4 : 0); case 0x1c0002: case 0x300002: return (nUnknownIRQ << 1) | nVideoIRQ; case 0x1c0004: case 0x300004: nVideoIRQ = 1; UpdateIRQStatus(); return (nUnknownIRQ << 1) | nVideoIRQ; case 0x1c0006: case 0x300006: nUnknownIRQ = 1; UpdateIRQStatus(); return (nUnknownIRQ << 1) | nVideoIRQ; case 0x280000: return (DrvInput[0] & 0x5FFF) | (korokoro_hopper ? 0x0000 : 0x8000) | ((DrvDip[0] & 0x20) << 8); case 0x280002: return (DrvInput[1] & 0xEFFF) | ((EEPROMRead() & 1) ? 0x1000 : 0x0000); // default: // bprintf(PRINT_NORMAL, "Attempt to read word value of location %x\n", sekAddress); } return 0; }
UINT8 __fastcall korokoroReadByte(UINT32 sekAddress) { switch (sekAddress) { case 0x1c0000: case 0x1c0001: case 0x300000: case 0x300001: return (nUnknownIRQ << 1) | nVideoIRQ | (bVBlank ? 0 : 4); case 0x1c0002: case 0x1c0003: case 0x300002: case 0x300003: return (nUnknownIRQ << 1) | nVideoIRQ; case 0x1c0004: case 0x1c0005: case 0x300004: case 0x300005: nVideoIRQ = 1; UpdateIRQStatus(); return (nUnknownIRQ << 1) | nVideoIRQ; case 0x1c0006: case 0x1c0007: case 0x300006: case 0x300007: nUnknownIRQ = 1; UpdateIRQStatus(); return (nUnknownIRQ << 1) | nVideoIRQ; case 0x280000: return ((DrvInput[0] >> 8) & 0x5F) | (korokoro_hopper ? 0x00 : 0x80) | (DrvDip[0] & 0x20); case 0x280001: return DrvInput[0] & 0xFF; case 0x280002: return ((DrvInput[1] >> 8) & 0xEF) | (EEPROMRead() ? 0x10 : 0x00); case 0x280003: return DrvInput[1] & 0xFF; // default: // bprintf(PRINT_NORMAL, "Attempt to read byte value of location %x\n", sekAddress); } return 0; }
UINT16 __fastcall ddonpachReadWord(UINT32 sekAddress) { switch (sekAddress) { case 0x300002: { return YMZ280BReadStatus(); } case 0x800000: { UINT16 nRet = 6 | nVideoIRQ; nVideoIRQ = 1; UpdateIRQStatus(); return nRet; } case 0x800002: case 0x800004: case 0x800006: { UINT16 nRet = 6 | nVideoIRQ; return nRet; } case 0xD00000: return DrvInput[0] ^ 0xFFFF; case 0xD00002: return (DrvInput[1] ^ 0xF7FF) | (EEPROMRead() << 11); default: { // bprintf(PRINT_NORMAL, "Attempt to read word value of location %x\n", sekAddress); } } return 0; }
unsigned char __fastcall donpachiReadByte(unsigned int sekAddress) { switch (sekAddress) { case 0x900000: case 0x900001: case 0x900002: case 0x900003: { unsigned char nRet = (nUnknownIRQ << 1) | nVideoIRQ; return nRet; } case 0x900004: case 0x900005: { unsigned char nRet = (nUnknownIRQ << 1) | nVideoIRQ; nVideoIRQ = 1; UpdateIRQStatus(); return nRet; } case 0x900006: case 0x900007: { unsigned char nRet = (nUnknownIRQ << 1) | nVideoIRQ; nUnknownIRQ = 1; UpdateIRQStatus(); return nRet; } case 0xB00001: return MSM6295ReadStatus(0); case 0xB00011: return MSM6295ReadStatus(1); case 0xC00000: return (DrvInput[0] >> 8) ^ 0xFF; case 0xC00001: return (DrvInput[0] & 0xFF) ^ 0xFF; case 0xC00002: return (DrvInput[1] >> 8) ^ 0xF7 | (EEPROMRead() << 3); case 0xC00003: return (DrvInput[1] & 0xFF) ^ 0xFF; default: { // bprintf(PRINT_NORMAL, "Attempt to read byte value of location %x\n", sekAddress); } } return 0; }
UINT16 __fastcall metmqstrReadWord(UINT32 sekAddress) { switch (sekAddress) { case 0xa80000: case 0xa80002: { UINT8 nRet = (nUnknownIRQ << 1) | nVideoIRQ; return nRet; } case 0xa80004: { UINT8 nRet = (nUnknownIRQ << 1) | nVideoIRQ; nVideoIRQ = 1; UpdateIRQStatus(); return nRet; } case 0xa80006: { UINT8 nRet = (nUnknownIRQ << 1) | nVideoIRQ; nUnknownIRQ = 1; UpdateIRQStatus(); return nRet; } case 0xa8006C: if (SoundLatchReplyIndex > SoundLatchReplyMax) { return 2; } return 0; case 0xa8006E: if (SoundLatchReplyIndex > SoundLatchReplyMax) { SoundLatchReplyIndex = 0; SoundLatchReplyMax = -1; return 0; } return SoundLatchReply[SoundLatchReplyIndex++]; case 0xc80000: return DrvInput[0] ^ 0xFFFF; case 0xc80002: return (DrvInput[1] ^ 0xF7FF) | (EEPROMRead() << 11); default: { bprintf(PRINT_NORMAL, _T("Attempt to read word value of location %x\n"), sekAddress); } } return 0; }
static void TriggerSoundIRQ(INT32 nStatus) { nSoundIRQ = nStatus ^ 1; UpdateIRQStatus(); if (nIRQPending && nCurrentCPU != 0) { nCyclesDone[0] += SekRun(0x0400); } }
unsigned short __fastcall donpachiReadWord(unsigned int sekAddress) { switch (sekAddress) { case 0x900000: case 0x900002: { unsigned short nRet = (nUnknownIRQ << 1) | nVideoIRQ; return nRet; } case 0x900004: { unsigned short nRet = (nUnknownIRQ << 1) | nVideoIRQ; nVideoIRQ = 1; UpdateIRQStatus(); return nRet; } case 0x900006: { unsigned short nRet = (nUnknownIRQ << 1) | nVideoIRQ; nUnknownIRQ = 1; UpdateIRQStatus(); return nRet; } case 0xB00000: return MSM6295ReadStatus(0); case 0xB00010: return MSM6295ReadStatus(1); case 0xC00000: return DrvInput[0] ^ 0xFFFF; case 0xC00002: return DrvInput[1] ^ 0xF7FF | (EEPROMRead() << 11); default: { // bprintf(PRINT_NORMAL, "Attempt to read word value of location %x\n", sekAddress); } } return 0; }
UINT16 __fastcall hotdogstReadWord(UINT32 sekAddress) { switch (sekAddress) { case 0xa80000: case 0xa80002: { UINT8 nRet = (nUnknownIRQ << 1) | nVideoIRQ; return nRet; } case 0xa80004: { UINT8 nRet = (nUnknownIRQ << 1) | nVideoIRQ; nVideoIRQ = 1; UpdateIRQStatus(); return nRet; } case 0xa80006: { UINT8 nRet = (nUnknownIRQ << 1) | nVideoIRQ; nUnknownIRQ = 1; UpdateIRQStatus(); return nRet; } // case 0xa8006e: { // return 0xff; // } case 0xc80000: return DrvInput[0] ^ 0xFFFF; case 0xC80002: return (DrvInput[1] ^ 0xF7FF) | (EEPROMRead() << 11); default: { bprintf(PRINT_NORMAL, _T("Attempt to read word value of location %x\n"), sekAddress); } } return 0; }
UINT8 __fastcall ddonpachReadByte(UINT32 sekAddress) { switch (sekAddress) { case 0x300002: case 0x300003: { return YMZ280BReadStatus(); } case 0x800000: case 0x800001: { UINT8 nRet = 6 | nVideoIRQ; nVideoIRQ = 1; UpdateIRQStatus(); return nRet; } case 0x800002: case 0x800003: case 0x800004: case 0x800005: case 0x800006: case 0x800007: { UINT8 nRet = 6 | nVideoIRQ; return nRet; } case 0xD00000: return (DrvInput[0] >> 8) ^ 0xFF; case 0xD00001: return (DrvInput[0] & 0xFF) ^ 0xFF; case 0xD00002: return ((DrvInput[1] >> 8) ^ 0xF7) | (EEPROMRead() << 3); case 0xD00003: return (DrvInput[1] & 0xFF) ^ 0xFF; default: { // bprintf(PRINT_NORMAL, "Attempt to read byte value of location %x\n", sekAddress); } } return 0; }
static int DrvFrame() { int nCyclesVBlank; int nInterleave = 8; int nCyclesTotal[2]; int nCyclesDone[2]; int nCyclesSegment; if (DrvReset) { // Reset machine DrvDoReset(); } // Compile digital inputs DrvInput[0] = 0x0000; // Player 1 DrvInput[1] = 0x0000; // Player 2 for (int i = 0; i < 10; i++) { DrvInput[0] |= (DrvJoy1[i] & 1) << i; DrvInput[1] |= (DrvJoy2[i] & 1) << i; } CaveClearOpposites(&DrvInput[0]); CaveClearOpposites(&DrvInput[1]); SekNewFrame(); nCyclesTotal[0] = (int)((long long)16000000 * nBurnCPUSpeedAdjust / (0x0100 * CAVE_REFRESHRATE)); nCyclesDone[0] = 0; nCyclesVBlank = nCyclesTotal[0] - (int)((nCyclesTotal[0] * CAVE_VBLANK_LINES) / 271.5); bVBlank = false; int nSoundBufferPos = 0; SekOpen(0); for (int i = 1; i <= nInterleave; i++) { int nCurrentCPU = 0; int nNext = i * nCyclesTotal[nCurrentCPU] / nInterleave; // Run 68000 // See if we need to trigger the VBlank interrupt if (!bVBlank && nNext > nCyclesVBlank) { if (nCyclesDone[nCurrentCPU] < nCyclesVBlank) { nCyclesSegment = nCyclesVBlank - nCyclesDone[nCurrentCPU]; if (!CheckSleep(nCurrentCPU)) { // See if this CPU is busywaiting nCyclesDone[nCurrentCPU] += SekRun(nCyclesSegment); } else { nCyclesDone[nCurrentCPU] += SekIdle(nCyclesSegment); } } if (pBurnDraw != NULL) { DrvDraw(); // Draw screen if needed } bVBlank = true; nVideoIRQ = 0; UpdateIRQStatus(); } nCyclesSegment = nNext - nCyclesDone[nCurrentCPU]; if (!CheckSleep(nCurrentCPU)) { // See if this CPU is busywaiting nCyclesDone[nCurrentCPU] += SekRun(nCyclesSegment); } else { nCyclesDone[nCurrentCPU] += SekIdle(nCyclesSegment); } } // Make sure the buffer is entirely filled. { if (pBurnSoundOut) { int nSegmentLength = nBurnSoundLen - nSoundBufferPos; short* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); if (nSegmentLength) { MSM6295Render(0, pSoundBuf, nSegmentLength); MSM6295Render(1, pSoundBuf, nSegmentLength); } } } SekClose(); return 0; }
static INT32 DrvFrame() { INT32 nCyclesVBlank; INT32 nInterleave = 8; if (DrvReset) { // Reset machine DrvDoReset(); } // Compile digital inputs DrvInput[0] = 0; // Player 1 DrvInput[1] = 0; // Player 2 for (INT32 i = 0; i < 16; i++) { DrvInput[0] |= (DrvJoy1[i] & 1) << i; DrvInput[1] |= (DrvJoy2[i] & 1) << i; } CaveClearOpposites(&DrvInput[0]); CaveClearOpposites(&DrvInput[1]); DrvInput[0] ^= 0xffff; DrvInput[1] ^= 0xffff; SekNewFrame(); nCyclesTotal[0] = (INT32)((INT64)16000000 * nBurnCPUSpeedAdjust / (0x0100 * CAVE_REFRESHRATE)); nCyclesDone[0] = 0; nCyclesVBlank = nCyclesTotal[0] - (INT32)((nCyclesTotal[0] * CAVE_VBLANK_LINES) / 271.5); bVBlank = false; INT32 nSoundBufferPos = 0; SekOpen(0); for (INT32 i = 1; i <= nInterleave; i++) { INT32 nNext; // Render sound segment if ((i & 1) == 0) { if (pBurnSoundOut) { INT32 nSegmentEnd = nBurnSoundLen * i / nInterleave; INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); YMZ280BRender(pSoundBuf, nSegmentEnd - nSoundBufferPos); nSoundBufferPos = nSegmentEnd; } } // Run 68000 nCurrentCPU = 0; nNext = i * nCyclesTotal[nCurrentCPU] / nInterleave; // See if we need to trigger the VBlank interrupt if (!bVBlank && nNext > nCyclesVBlank) { if (nCyclesDone[nCurrentCPU] < nCyclesVBlank) { nCyclesSegment = nCyclesVBlank - nCyclesDone[nCurrentCPU]; if (!CheckSleep(nCurrentCPU)) { // See if this CPU is busywaiting nCyclesDone[nCurrentCPU] += SekRun(nCyclesSegment); } else { nCyclesDone[nCurrentCPU] += SekIdle(nCyclesSegment); } } if (pBurnDraw != NULL) { DrvDraw(); // Draw screen if needed } bVBlank = true; nVideoIRQ = 0; UpdateIRQStatus(); } nCyclesSegment = nNext - nCyclesDone[nCurrentCPU]; if (!CheckSleep(nCurrentCPU)) { // See if this CPU is busywaiting nCyclesDone[nCurrentCPU] += SekRun(nCyclesSegment); } else { nCyclesDone[nCurrentCPU] += SekIdle(nCyclesSegment); } nCurrentCPU = -1; } { // Make sure the buffer is entirely filled. if (pBurnSoundOut) { INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos; INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); if (nSegmentLength) { YMZ280BRender(pSoundBuf, nSegmentLength); } } } SekClose(); return 0; }