From 2a527275582fb22edd924de82a2880076bbe8604 Mon Sep 17 00:00:00 2001 From: Barry Harris <44396066+barry65536@users.noreply.github.com> Date: Thu, 6 Dec 2012 13:51:06 +0000 Subject: [PATCH] Better emulation of kodb hardware --- src/burn/drv/capcom/cps.h | 1 + src/burn/drv/capcom/cps_draw.cpp | 3 +- src/burn/drv/capcom/cps_obj.cpp | 7 ++- src/burn/drv/capcom/d_cps1.cpp | 90 +++++++++++++++++++++++++++++++- 4 files changed, 97 insertions(+), 4 deletions(-) diff --git a/src/burn/drv/capcom/cps.h b/src/burn/drv/capcom/cps.h index 4211b70f1..67ecd0524 100644 --- a/src/burn/drv/capcom/cps.h +++ b/src/burn/drv/capcom/cps.h @@ -275,6 +275,7 @@ extern INT32 CpsLayer1YOffs; extern INT32 CpsLayer2YOffs; extern INT32 CpsLayer3YOffs; extern INT32 Cps1DisableBgHi; +extern INT32 CpsDisableRowScroll; extern INT32 Cps1OverrideLayers; extern INT32 nCps1Layers[4]; extern INT32 nCps1LayerOffs[3]; diff --git a/src/burn/drv/capcom/cps_draw.cpp b/src/burn/drv/capcom/cps_draw.cpp index cb4148046..d6092fe6b 100644 --- a/src/burn/drv/capcom/cps_draw.cpp +++ b/src/burn/drv/capcom/cps_draw.cpp @@ -19,6 +19,7 @@ INT32 CpsLayer2YOffs = 0; INT32 CpsLayer3YOffs = 0; INT32 Cps1DisableBgHi = 0; +INT32 CpsDisableRowScroll = 0; INT32 Cps1OverrideLayers = 0; INT32 nCps1Layers[4] = { -1, -1, -1, -1 }; @@ -129,7 +130,7 @@ static INT32 DrawScroll2Init(INT32 i) CpsrRows = NULL; - if (n & 1) { + if ((n & 1) && !CpsDisableRowScroll) { INT32 nTab, nStart; // Find row scroll table: diff --git a/src/burn/drv/capcom/cps_obj.cpp b/src/burn/drv/capcom/cps_obj.cpp index c21c9e4df..8142f2673 100644 --- a/src/burn/drv/capcom/cps_obj.cpp +++ b/src/burn/drv/capcom/cps_obj.cpp @@ -469,7 +469,12 @@ INT32 KodbObjGet() pof->nShiftX = -0x40; pof->nShiftY = -0x10; - Get = CpsRam90 + 0x50c8; + // needs to alternate between the two sprite ram areas to achieve flashing + INT32 nOff = BURN_ENDIAN_SWAP_INT16(*((UINT16*)(CpsRamFF + 0x1256))) << 8; + nOff &= 0xffff; + nOff += 0x1140; + + Get = CpsRam90 + nOff; if (Get==NULL) return 1; diff --git a/src/burn/drv/capcom/d_cps1.cpp b/src/burn/drv/capcom/d_cps1.cpp index 507a1a683..80e2105ab 100644 --- a/src/burn/drv/capcom/d_cps1.cpp +++ b/src/burn/drv/capcom/d_cps1.cpp @@ -11417,6 +11417,7 @@ static INT32 DrvExit() PangEEP = 0; Cps1LockSpriteList910000 = 0; Cps1DisableBgHi = 0; + CpsDisableRowScroll = 0; Dinohunt = 0; Sf2thndr = 0; Port6SoundWrite = 0; @@ -12297,9 +12298,85 @@ static INT32 Knightsb2Init() return DrvInit(); } +UINT8 __fastcall KodbInputReadByte(UINT32 a) +{ + switch (a) { + case 0x992000: { + return ~Inp000; + } + + case 0x992001: { + return ~Inp001; + } + + case 0x992008: { + return ~Inp018; + } + + case 0x992009: { + return 0xff; + } + + default: { + bprintf(PRINT_NORMAL, _T("Input Read Byte %x\n"), a); + } + } + + return 0; +} + +void __fastcall Kodb98WriteByte(UINT32 a, UINT8 d) +{ + switch (a) { + case 0x992007: { + PsndSyncZ80((INT64)SekTotalCycles() * nCpsZ80Cycles / nCpsCycles); + PsndCode = d; + return; + } + } + + bprintf(PRINT_IMPORTANT, _T("Unknown byte value written at %x %x\n"), a, d); +} + void __fastcall Kodb98WriteWord(UINT32 a, UINT16 d) { switch (a) { + case 0x980000: { + // scroll1 y + *((UINT16*)(CpsReg + 0x0e)) = BURN_ENDIAN_SWAP_INT16(d); + return; + } + + case 0x980002: { + // scroll1 x + *((UINT16*)(CpsReg + 0x0c)) = BURN_ENDIAN_SWAP_INT16(d - 0x3e); + return; + } + + case 0x980004: { + // scroll2 y + *((UINT16*)(CpsReg + 0x12)) = BURN_ENDIAN_SWAP_INT16(d); + return; + } + + case 0x980006: { + // scroll2 x + *((UINT16*)(CpsReg + 0x10)) = BURN_ENDIAN_SWAP_INT16(d - 0x3c); + return; + } + + case 0x980008: { + // scroll3 y + *((UINT16*)(CpsReg + 0x16)) = BURN_ENDIAN_SWAP_INT16(d); + return; + } + + case 0x98000a: { + // scroll3 x + *((UINT16*)(CpsReg + 0x14)) = BURN_ENDIAN_SWAP_INT16(d - 0x40); + return; + } + case 0x98000c: { *((UINT16*)(CpsReg + nCpsLcReg)) = BURN_ENDIAN_SWAP_INT16(d); return; @@ -12314,6 +12391,11 @@ void __fastcall Kodb98WriteWord(UINT32 a, UINT16 d) *((UINT16*)(CpsReg + MaskAddr[2])) = BURN_ENDIAN_SWAP_INT16(d); return; } + + case 0x994000: { + // ??? + return; + } } bprintf(PRINT_IMPORTANT, _T("Unknown value written at %x %x\n"), a, d); @@ -12324,6 +12406,8 @@ static INT32 KodbInit() INT32 nRet = 0; Kodb = 1; + bCpsUpdatePalEveryFrame = 1; + CpsDisableRowScroll = 1; Cps1GfxLoadCallbackFunction = CpsLoadTilesKodb; Cps1ObjGetCallbackFunction = KodbObjGet; Cps1ObjDrawCallbackFunction = FcrashObjDraw; @@ -12332,11 +12416,13 @@ static INT32 KodbInit() SekOpen(0); SekMapHandler(1, 0x980000, 0x99ffff, SM_WRITE); + SekSetWriteByteHandler(1, Kodb98WriteByte); SekSetWriteWordHandler(1, Kodb98WriteWord); + SekMapHandler(2, 0x992000, 0x992009, SM_READ); + SekSetReadByteHandler(2, KodbInputReadByte); SekClose(); - *((UINT16*)(CpsReg + MaskAddr[0])) = 0x0000; - *((UINT16*)(CpsReg + MaskAddr[3])) = BURN_ENDIAN_SWAP_INT16(0xff00); + Cps1VBlankIRQLine = 4; return nRet; }