From ef4a814ee235f6c84b17e5338f5ba9e3c2d9916a Mon Sep 17 00:00:00 2001 From: iq_132 <1191709+iq132@users.noreply.github.com> Date: Tue, 16 Sep 2014 18:01:18 +0000 Subject: [PATCH] HD6309 - Change so that each cpu is initialized separately. All hd6309 games ahve been tested. --- src/burn/drv/dataeast/d_dec8.cpp | 7 ++-- src/burn/drv/konami/d_mainevt.cpp | 2 +- src/burn/drv/pre90s/d_ddragon.cpp | 12 +++---- src/cpu/hd6309_intf.cpp | 55 ++++++++++++++++--------------- src/cpu/hd6309_intf.h | 2 +- 5 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/burn/drv/dataeast/d_dec8.cpp b/src/burn/drv/dataeast/d_dec8.cpp index 03e2bb8a8..01039386d 100644 --- a/src/burn/drv/dataeast/d_dec8.cpp +++ b/src/burn/drv/dataeast/d_dec8.cpp @@ -1317,7 +1317,7 @@ static INT32 DrvInit() DrvGfxDecode(); } - HD6309Init(1); + HD6309Init(0); HD6309Open(0); HD6309MapMemory(DrvMainRAM, 0x0000, 0x17ff, HD6309_RAM); HD6309MapMemory(DrvVidRAM, 0x1800, 0x1fff, HD6309_RAM); @@ -3398,7 +3398,7 @@ static INT32 GondoInit() GondoGfxDecode(); } - HD6309Init(1); + HD6309Init(0); HD6309Open(0); HD6309MapMemory(DrvMainRAM, 0x0000, 0x17ff, HD6309_RAM); HD6309MapMemory(DrvVidRAM, 0x1800, 0x1fff, HD6309_RAM); @@ -4002,7 +4002,7 @@ static INT32 OscarInit() OscarGfxDecode(); } - HD6309Init(2); + HD6309Init(0); HD6309Open(0); HD6309MapMemory(DrvMainRAM, 0x0000, 0x1fff, HD6309_RAM); // all shared? HD6309MapMemory(DrvVidRAM, 0x2000, 0x28ff, HD6309_RAM); @@ -4015,6 +4015,7 @@ static INT32 OscarInit() HD6309SetReadHandler(oscar_main_read); HD6309Close(); + HD6309Init(1); HD6309Open(1); HD6309MapMemory(DrvMainRAM, 0x0000, 0x0eff, HD6309_RAM); // all shared? AM_RANGE(0x0f00, 0x0fff) AM_RAM not? HD6309MapMemory(DrvPalRAM + 0x400, 0x0f00, 0x0fff, HD6309_RAM); // not really pal... diff --git a/src/burn/drv/konami/d_mainevt.cpp b/src/burn/drv/konami/d_mainevt.cpp index ace2f5663..440ccd28d 100644 --- a/src/burn/drv/konami/d_mainevt.cpp +++ b/src/burn/drv/konami/d_mainevt.cpp @@ -726,7 +726,7 @@ static INT32 DrvInit(INT32 type) DrvGfxDecode(gfx0_offset * 2); } - HD6309Init(1); + HD6309Init(0); HD6309Open(0); HD6309MapMemory(DrvHD6309RAM, 0x4000, 0x5fff, HD6309_RAM); HD6309MapMemory(DrvHD6309ROM + 0x10000, 0x6000, 0x7fff, HD6309_ROM); diff --git a/src/burn/drv/pre90s/d_ddragon.cpp b/src/burn/drv/pre90s/d_ddragon.cpp index 1ea0c7535..94505ca47 100644 --- a/src/burn/drv/pre90s/d_ddragon.cpp +++ b/src/burn/drv/pre90s/d_ddragon.cpp @@ -1894,13 +1894,8 @@ static INT32 DarktowrLoadRoms() static INT32 DrvMachineInit() { BurnSetRefreshRate(57.444853); - - // Setup the HD6309 emulation - if (DrvSubCPUType == DD_CPU_TYPE_HD6309) { - HD6309Init(2); - } else { - HD6309Init(1); - } + + HD6309Init(0); HD6309Open(0); HD6309MapMemory(DrvHD6309Ram , 0x0000, 0x0fff, M6809_RAM); HD6309MapMemory(DrvPaletteRam1 , 0x1000, 0x11ff, M6809_RAM); @@ -1922,6 +1917,7 @@ static INT32 DrvMachineInit() } if (DrvSubCPUType == DD_CPU_TYPE_HD6309) { + HD6309Init(1); HD6309Open(1); HD6309MapMemory(DrvSubCPURom , 0xc000, 0xffff, HD6309_ROM); HD6309SetReadHandler(DrvDdragonbSubHD6309ReadByte); @@ -1979,7 +1975,7 @@ static INT32 DrvMachineInit() static INT32 Drv2MachineInit() { // Setup the HD6309 emulation - HD6309Init(1); + HD6309Init(0); HD6309Open(0); HD6309MapMemory(DrvHD6309Ram , 0x0000, 0x17ff, M6809_RAM); HD6309MapMemory(DrvFgVideoRam , 0x1800, 0x1fff, M6809_RAM); diff --git a/src/cpu/hd6309_intf.cpp b/src/cpu/hd6309_intf.cpp index 465d8bd02..51722b233 100644 --- a/src/cpu/hd6309_intf.cpp +++ b/src/cpu/hd6309_intf.cpp @@ -78,39 +78,42 @@ static cpu_core_config HD6309CheatCpuConfig = 0 }; -INT32 HD6309Init(INT32 num) +INT32 HD6309Init(INT32 nCPU) { DebugCPU_HD6309Initted = 1; nActiveCPU = -1; - nHD6309Count = num % MAX_CPU; - - HD6309CPUContext = (HD6309Ext*)malloc(num * sizeof(HD6309Ext)); + if ((nCPU+1) > nHD6309Count) nHD6309Count = nCPU+1; + +#if defined FBA_DEBUG + if (nCPU >= MAX_CPU) bprintf(PRINT_ERROR, _T("HD6309Init called too many CPUs! %d, %d is MAX\n"), nCPU, MAX_CPU); +#endif + if (HD6309CPUContext == NULL) { - return 1; - } - - memset(HD6309CPUContext, 0, num * sizeof(HD6309Ext)); - - for (INT32 i = 0; i < num; i++) { - HD6309CPUContext[i].ReadByte = HD6309ReadByteDummyHandler; - HD6309CPUContext[i].WriteByte = HD6309WriteByteDummyHandler; - HD6309CPUContext[i].ReadOp = HD6309ReadOpDummyHandler; - HD6309CPUContext[i].ReadOpArg = HD6309ReadOpArgDummyHandler; - - nHD6309CyclesDone[i] = 0; - - for (INT32 j = 0; j < (0x0100 * 3); j++) { - HD6309CPUContext[i].pMemMap[j] = NULL; + HD6309CPUContext = (HD6309Ext*)malloc(MAX_CPU * sizeof(HD6309Ext)); + if (HD6309CPUContext == NULL) { + return 1; } - } - - nHD6309CyclesTotal = 0; - - hd6309_init(); - for (INT32 i = 0; i < num; i++) - CpuCheatRegister(i, &HD6309CheatCpuConfig); + memset(HD6309CPUContext, 0, MAX_CPU * sizeof(HD6309Ext)); + } + + HD6309CPUContext[nCPU].ReadByte = HD6309ReadByteDummyHandler; + HD6309CPUContext[nCPU].WriteByte = HD6309WriteByteDummyHandler; + HD6309CPUContext[nCPU].ReadOp = HD6309ReadOpDummyHandler; + HD6309CPUContext[nCPU].ReadOpArg = HD6309ReadOpArgDummyHandler; + + nHD6309CyclesDone[nCPU] = 0; + + for (INT32 j = 0; j < (0x0100 * 3); j++) { + HD6309CPUContext[nCPU].pMemMap[j] = NULL; + } + + nHD6309CyclesTotal = 0; + + //hd6309_init(); // does nothing. + + CpuCheatRegister(nCPU, &HD6309CheatCpuConfig); return 0; } diff --git a/src/cpu/hd6309_intf.h b/src/cpu/hd6309_intf.h index 5bfc4b255..f7e1de6a3 100644 --- a/src/cpu/hd6309_intf.h +++ b/src/cpu/hd6309_intf.h @@ -38,7 +38,7 @@ extern INT32 nHD6309CyclesTotal; void HD6309Reset(); void HD6309NewFrame(); -INT32 HD6309Init(INT32 num); +INT32 HD6309Init(INT32 nCPU); void HD6309Exit(); void HD6309Open(INT32 num); void HD6309Close();