diff --git a/src/burn/drivers/taito/cchip.cpp b/src/burn/drivers/taito/cchip.cpp index c72457ba7..fe0354888 100644 --- a/src/burn/drivers/taito/cchip.cpp +++ b/src/burn/drivers/taito/cchip.cpp @@ -128,7 +128,7 @@ void MegabCChipReset() void MegabCChipInit() { - MegabCChipRam = (UINT8*)malloc(0x800); + MegabCChipRam = (UINT8*)BurnMalloc(0x800); memset(MegabCChipRam, 0, 0x800); TaitoIC_MegabCChipInUse = 1; @@ -136,10 +136,7 @@ void MegabCChipInit() void MegabCChipExit() { - if (MegabCChipRam) { - free(MegabCChipRam); - MegabCChipRam = NULL; - } + BurnFree(MegabCChipRam); } void MegabCChipScan(INT32 nAction) @@ -891,7 +888,7 @@ void RainbowCChipInit(INT32 Version) ExtraVersion = Version; for (INT32 i = 0; i < 8; i++) { - CRAM[i] = (UINT8*)malloc(0x400); + CRAM[i] = (UINT8*)BurnMalloc(0x400); memset(CRAM[i], 0, 0x400); } @@ -901,10 +898,7 @@ void RainbowCChipInit(INT32 Version) void RainbowCChipExit() { for (INT32 i = 0; i < 8; i++) { - if (CRAM[i]) { - free(CRAM[i]); - CRAM[i] = NULL; - } + BurnFree(CRAM[i]); } ExtraVersion = 0; @@ -1540,7 +1534,7 @@ void OpwolfCChipInit(INT32 Region) { CChipRegion = Region; - CChipRam = (UINT8*)malloc(0x400 * 8); + CChipRam = (UINT8*)BurnMalloc(0x400 * 8); memset(CChipRam, 0, 0x400 * 8); CChipLast_7a = 0; @@ -1558,10 +1552,7 @@ void OpwolfCChipInit(INT32 Region) void OpwolfCChipExit() { - if (CChipRam) { - free(CChipRam); - CChipRam = NULL; - } + BurnFree(CChipRam); CChipRegion = 0; @@ -2564,7 +2555,7 @@ UINT8 VolfiedCChipRamRead(INT32 offset) void VolfiedCChipInit() { - volfied_cchip_ram = (UINT8*)malloc(0x400 * 8); + volfied_cchip_ram = (UINT8*)BurnMalloc(0x400 * 8); TaitoIC_VolfiedCChipInUse = 1; @@ -2585,10 +2576,7 @@ void VolfiedCChipReset() void VolfiedCChipExit() { - if (volfied_cchip_ram) { - free(volfied_cchip_ram); - volfied_cchip_ram = NULL; - } + BurnFree(volfied_cchip_ram); } void VolfiedCChipScan(INT32 nAction) diff --git a/src/burn/drivers/taito/d_asuka.cpp b/src/burn/drivers/taito/d_asuka.cpp index 9d5390583..3f95b9f2d 100644 --- a/src/burn/drivers/taito/d_asuka.cpp +++ b/src/burn/drivers/taito/d_asuka.cpp @@ -1143,7 +1143,24 @@ static INT32 DrvDoReset() { memset (TaitoRamStart, 0, TaitoRamEnd - TaitoRamStart); +#if 0 + // This resets the YM2151 which calls DrvSoundBankSwitch via the port callback TaitoDoReset(); +#else + SekOpen(0); + SekReset(); + SekClose(); + + ZetOpen(0); + ZetReset(); + ZetClose(); + + if (TaitoNumYM2610) BurnYM2610Reset(); + if (TaitoNumMSM5205) MSM5205Reset(); + ZetOpen(0); + if (TaitoNumYM2151) BurnYM2151Reset(); + ZetClose(); +#endif ZetOpen(0); DrvSoundBankSwitch(0, 1); @@ -1333,7 +1350,7 @@ static INT32 CommonInit(void (*Cpu68KSetup)(), void (*CpuZ80Setup)(), void (*Sou TaitoMem = NULL; MemIndex(); INT32 nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -1393,11 +1410,11 @@ static INT32 CadashFrame() TaitoMakeInputsFunction(); - SekOpen(0); - ZetOpen(0); - SekNewFrame(); ZetNewFrame(); + + SekOpen(0); + ZetOpen(0); INT32 nInterleave = 100; INT32 nSoundBufferPos = 0; @@ -1453,11 +1470,11 @@ static INT32 EtoFrame() // Using for asuka too, but needs msm5205 TaitoMakeInputsFunction(); - SekOpen(0); - ZetOpen(0); - SekNewFrame(); ZetNewFrame(); + + SekOpen(0); + ZetOpen(0); INT32 nInterleave = 100; if (TaitoNumMSM5205) nInterleave = MSM5205CalcInterleave(0, 4000000); @@ -1525,11 +1542,11 @@ static INT32 BonzeFrame() } } - SekOpen(0); - ZetOpen(0); - SekNewFrame(); ZetNewFrame(); + + SekOpen(0); + ZetOpen(0); SekRun(8000000 / 60); SekSetIRQLine(4, SEK_IRQSTATUS_AUTO); diff --git a/src/burn/drivers/taito/d_bublbobl.cpp b/src/burn/drivers/taito/d_bublbobl.cpp index abe5d2958..08f16c900 100644 --- a/src/burn/drivers/taito/d_bublbobl.cpp +++ b/src/burn/drivers/taito/d_bublbobl.cpp @@ -1667,7 +1667,7 @@ static INT32 MachineInit() Mem = NULL; MemIndex(); nLen = MemEnd - (UINT8 *)0; - if ((Mem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(Mem, 0, nLen); MemIndex(); @@ -1748,7 +1748,7 @@ static INT32 BublboblCallback() { INT32 nRet = 0; - DrvTempRom = (UINT8 *)malloc(0x80000); + DrvTempRom = (UINT8 *)BurnMalloc(0x80000); // Load Z80 #1 Program Roms nRet = BurnLoadRom(DrvZ80Rom1 + 0x00000, 0, 1); if (nRet != 0) return 1; @@ -1782,10 +1782,7 @@ static INT32 BublboblCallback() // Load the PROM nRet = BurnLoadRom(DrvProm + 0x00000, 17, 1); if (nRet != 0) return 1; - if (DrvTempRom) { - free(DrvTempRom); - DrvTempRom = NULL; - } + BurnFree(DrvTempRom); return 0; } @@ -1803,7 +1800,7 @@ static INT32 BoblboblCallback() { INT32 nRet = 0; - DrvTempRom = (UINT8 *)malloc(0x80000); + DrvTempRom = (UINT8 *)BurnMalloc(0x80000); // Load Z80 #1 Program Roms nRet = BurnLoadRom(DrvZ80Rom1 + 0x00000, 0, 1); if (nRet != 0) return 1; @@ -1835,10 +1832,7 @@ static INT32 BoblboblCallback() // Load the PROM nRet = BurnLoadRom(DrvProm + 0x00000, 17, 1); if (nRet != 0) return 1; - if (DrvTempRom) { - free(DrvTempRom); - DrvTempRom = NULL; - } + BurnFree(DrvTempRom); ZetOpen(0); ZetSetReadHandler(BoblboblRead1); @@ -1863,7 +1857,7 @@ static INT32 Bub68705Callback() { INT32 nRet = 0; - DrvTempRom = (UINT8 *)malloc(0x80000); + DrvTempRom = (UINT8 *)BurnMalloc(0x80000); // Load Z80 #1 Program Roms nRet = BurnLoadRom(DrvZ80Rom1 + 0x00000, 0, 1); if (nRet != 0) return 1; @@ -1901,10 +1895,7 @@ static INT32 Bub68705Callback() // Load the 68705 Rom nRet = BurnLoadRom(DrvMcuRom + 0x00000, 18, 1); if (nRet != 0) return 1; - if (DrvTempRom) { - free(DrvTempRom); - DrvTempRom = NULL; - } + BurnFree(DrvTempRom); return 0; } @@ -1922,7 +1913,7 @@ static INT32 DlandCallback() { INT32 nRet = 0; - DrvTempRom = (UINT8 *)malloc(0x80000); + DrvTempRom = (UINT8 *)BurnMalloc(0x80000); // Load Z80 #1 Program Roms nRet = BurnLoadRom(DrvZ80Rom1 + 0x00000, 0, 1); if (nRet != 0) return 1; @@ -1954,10 +1945,7 @@ static INT32 DlandCallback() // Load the PROM nRet = BurnLoadRom(DrvProm + 0x00000, 11, 1); if (nRet != 0) return 1; - if (DrvTempRom) { - free(DrvTempRom); - DrvTempRom = NULL; - } + BurnFree(DrvTempRom); ZetOpen(0); ZetSetReadHandler(BoblboblRead1); @@ -1986,12 +1974,12 @@ static INT32 TokioInit() Mem = NULL; MemIndex(); nLen = MemEnd - (UINT8 *)0; - if ((Mem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(Mem, 0, nLen); MemIndex(); { - DrvTempRom = (UINT8 *)malloc(0x80000); + DrvTempRom = (UINT8 *)BurnMalloc(0x80000); // Load Z80 #1 Program Roms nRet = BurnLoadRom(DrvZ80Rom1 + 0x00000, 0, 1); if (nRet != 0) return 1; @@ -2032,10 +2020,7 @@ static INT32 TokioInit() // Load MCU Rom //BurnLoadRom(DrvMcuRom + 0x00000, 24, 1); - if (DrvTempRom) { - free(DrvTempRom); - DrvTempRom = NULL; - } + BurnFree(DrvTempRom); } // Setup the Z80 emulation @@ -2083,6 +2068,7 @@ static INT32 TokioInit() ZetClose(); BurnYM2203Init(1, 3000000, &DrvYM2203IRQHandler, DrvSynchroniseStream, DrvGetTime, 0); + BurnYM2203SetVolumeShift(2); BurnTimerAttachZet(3000000); GenericTilesInit(); @@ -2100,14 +2086,13 @@ static INT32 DrvExit() { ZetExit(); BurnYM2203Exit(); - BurnYM3526Exit(); + + if (DrvMCUInUse == 1) M6800Exit(); + if (DrvMCUInUse == 2) m6805Exit(); GenericTilesExit(); - if (Mem) { - free(Mem); - Mem = NULL; - } + BurnFree(Mem); DrvRomBank = 0; DrvSlaveCPUActive = 0; @@ -2131,6 +2116,12 @@ static INT32 DrvExit() return 0; } +static INT32 BublboblExit() +{ + BurnYM3526Exit(); + return DrvExit(); +} + static inline UINT8 pal4bit(UINT8 bits) { bits &= 0x0f; @@ -2258,7 +2249,6 @@ static void DrvDraw() static INT32 DrvFrame() { INT32 nInterleave = 100; - INT32 nSoundBufferPos = 0; if (DrvReset) DrvDoReset(); @@ -2328,18 +2318,6 @@ static INT32 DrvFrame() nCyclesDone[nCurrentCPU] += nCyclesSegment; } } - - if (pBurnSoundOut) { - INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos; - INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); - ZetOpen(2); - BurnYM2203Update(pSoundBuf, nSegmentLength); - ZetClose(); - ZetOpen(0); - BurnYM3526Update(pSoundBuf, nSegmentLength); - ZetClose(); - nSoundBufferPos += nSegmentLength; - } } ZetOpen(0); @@ -2353,16 +2331,12 @@ static INT32 DrvFrame() } if (pBurnSoundOut) { - INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos; - INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); - if (nSegmentLength) { - ZetOpen(2); - BurnYM2203Update(pSoundBuf, nSegmentLength); - ZetClose(); - ZetOpen(0); - BurnYM3526Update(pSoundBuf, nSegmentLength); - ZetClose(); - } + ZetOpen(2); + BurnYM2203Update(pBurnSoundOut, nBurnSoundLen); + ZetClose(); + ZetOpen(0); + BurnYM3526Update(pBurnSoundOut, nBurnSoundLen); + ZetClose(); } if (pBurnDraw) DrvDraw(); @@ -2373,7 +2347,6 @@ static INT32 DrvFrame() static INT32 TokioFrame() { INT32 nInterleave = 100; - INT32 nSoundBufferPos = 0; if (DrvReset) TokioDoReset(); @@ -2422,15 +2395,6 @@ static INT32 TokioFrame() } } ZetClose(); - - if (pBurnSoundOut) { - INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos; - INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); - ZetOpen(2); - BurnYM2203Update(pSoundBuf, nSegmentLength); - ZetClose(); - nSoundBufferPos += nSegmentLength; - } } ZetOpen(2); @@ -2438,13 +2402,9 @@ static INT32 TokioFrame() ZetClose(); if (pBurnSoundOut) { - INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos; - INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); - if (nSegmentLength) { - ZetOpen(2); - BurnYM2203Update(pSoundBuf, nSegmentLength); - ZetClose(); - } + ZetOpen(2); + BurnYM2203Update(pBurnSoundOut, nBurnSoundLen); + ZetClose(); } if (pBurnDraw) DrvDraw(); @@ -2523,7 +2483,7 @@ struct BurnDriver BurnDrvBublbobl = { NULL, NULL, NULL, NULL, BDF_GAME_WORKING, 2, HARDWARE_TAITO_MISC, GBF_PLATFORM, 0, NULL, BublboblRomInfo, BublboblRomName, NULL, NULL, BublboblInputInfo, BublboblDIPInfo, - BublboblInit, DrvExit, DrvFrame, NULL, DrvScan, + BublboblInit, BublboblExit, DrvFrame, NULL, DrvScan, NULL, 0x100, 256, 224, 4, 3 }; @@ -2533,7 +2493,7 @@ struct BurnDriver BurnDrvBublbob1 = { NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_TAITO_MISC, GBF_PLATFORM, 0, NULL, Bublbob1RomInfo, Bublbob1RomName, NULL, NULL, BublboblInputInfo, BublboblDIPInfo, - BublboblInit, DrvExit, DrvFrame, NULL, DrvScan, + BublboblInit, BublboblExit, DrvFrame, NULL, DrvScan, NULL, 0x100, 256, 224, 4, 3 }; @@ -2543,7 +2503,7 @@ struct BurnDriver BurnDrvBublbobr = { NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_TAITO_MISC, GBF_PLATFORM, 0, NULL, BublbobrRomInfo, BublbobrRomName, NULL, NULL, BublboblInputInfo, BublboblDIPInfo, - BublboblInit, DrvExit, DrvFrame, NULL, DrvScan, + BublboblInit, BublboblExit, DrvFrame, NULL, DrvScan, NULL, 0x100, 256, 224, 4, 3 }; @@ -2553,7 +2513,7 @@ struct BurnDriver BurnDrvBubbobr1 = { NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_TAITO_MISC, GBF_PLATFORM, 0, NULL, Bubbobr1RomInfo, Bubbobr1RomName, NULL, NULL, BublboblInputInfo, BublboblDIPInfo, - BublboblInit, DrvExit, DrvFrame, NULL, DrvScan, + BublboblInit, BublboblExit, DrvFrame, NULL, DrvScan, NULL, 0x100, 256, 224, 4, 3 }; @@ -2563,7 +2523,7 @@ struct BurnDriver BurnDrvBoblbobl = { NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_TAITO_MISC, GBF_PLATFORM, 0, NULL, BoblboblRomInfo, BoblboblRomName, NULL, NULL, BoblboblInputInfo, BoblboblDIPInfo, - BoblboblInit, DrvExit, DrvFrame, NULL, DrvScan, + BoblboblInit, BublboblExit, DrvFrame, NULL, DrvScan, NULL, 0x100, 256, 224, 4, 3 }; @@ -2573,7 +2533,7 @@ struct BurnDriver BurnDrvSboblboa = { NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_TAITO_MISC, GBF_PLATFORM, 0, NULL, SboblboaRomInfo, SboblboaRomName, NULL, NULL, BoblboblInputInfo, BoblboblDIPInfo, - BoblboblInit, DrvExit, DrvFrame, NULL, DrvScan, + BoblboblInit, BublboblExit, DrvFrame, NULL, DrvScan, NULL, 0x100, 256, 224, 4, 3 }; @@ -2583,7 +2543,7 @@ struct BurnDriver BurnDrvSboblbob = { NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_TAITO_MISC, GBF_PLATFORM, 0, NULL, SboblbobRomInfo, SboblbobRomName, NULL, NULL, BoblboblInputInfo, SboblbobDIPInfo, - BoblboblInit, DrvExit, DrvFrame, NULL, DrvScan, + BoblboblInit, BublboblExit, DrvFrame, NULL, DrvScan, NULL, 0x100, 256, 224, 4, 3 }; @@ -2593,7 +2553,7 @@ struct BurnDriver BurnDrvBub68705 = { NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_TAITO_MISC, GBF_PLATFORM, 0, NULL, Bub68705RomInfo, Bub68705RomName, NULL, NULL, BublboblInputInfo, BublboblDIPInfo, - Bub68705Init, DrvExit, DrvFrame, NULL, DrvScan, + Bub68705Init, BublboblExit, DrvFrame, NULL, DrvScan, NULL, 0x100, 256, 224, 4, 3 }; @@ -2602,8 +2562,8 @@ struct BurnDriver BurnDrvDland = { "Dream Land / Super Dream Land (bootleg of Bubble Bobble)\0", NULL, "bootleg", "Taito Misc", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_TAITO_MISC, GBF_PLATFORM, 0, - NULL, DlandRomInfo, DlandRomName, NULL, NULL, BublboblInputInfo, DlandDIPInfo, - DlandInit, DrvExit, DrvFrame, NULL, DrvScan, + NULL, DlandRomInfo, DlandRomName, NULL, NULL, BoblboblInputInfo, DlandDIPInfo, + DlandInit, BublboblExit, DrvFrame, NULL, DrvScan, NULL, 0x100, 256, 224, 4, 3 }; diff --git a/src/burn/drivers/taito/d_darius2.cpp b/src/burn/drivers/taito/d_darius2.cpp index 72a137ed7..bc49026be 100644 --- a/src/burn/drivers/taito/d_darius2.cpp +++ b/src/burn/drivers/taito/d_darius2.cpp @@ -1346,7 +1346,7 @@ static INT32 Darius2Init() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -1458,7 +1458,7 @@ static INT32 Darius2dInit() TaitoMem = NULL; Darius2dMemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); Darius2dMemIndex(); @@ -1566,7 +1566,7 @@ static INT32 WarriorbInit() TaitoMem = NULL; WarriorbMemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); WarriorbMemIndex(); @@ -1889,10 +1889,14 @@ static INT32 Darius2Frame() if (i == nInterleave - 1) SekSetIRQLine(TaitoIrqLine, SEK_IRQSTATUS_AUTO); SekClose(); } + + ZetOpen(0); + BurnTimerUpdate(i * (nTaitoCyclesTotal[2] / nInterleave)); + ZetClose(); } ZetOpen(0); - BurnTimerEndFrame(nTaitoCyclesTotal[2] - nTaitoCyclesDone[2]); + BurnTimerEndFrame(nTaitoCyclesTotal[2]); BurnYM2610Update(pBurnSoundOut, nBurnSoundLen); ZetClose(); @@ -1925,10 +1929,14 @@ static INT32 Darius2dFrame() nTaitoCyclesDone[nCurrentCPU] += SekRun(nTaitoCyclesSegment); if (i == nInterleave - 1) SekSetIRQLine(TaitoIrqLine, SEK_IRQSTATUS_AUTO); SekClose(); + + ZetOpen(0); + BurnTimerUpdate(i * (nTaitoCyclesTotal[1] / nInterleave)); + ZetClose(); } ZetOpen(0); - BurnTimerEndFrame(nTaitoCyclesTotal[1] - nTaitoCyclesDone[1]); + BurnTimerEndFrame(nTaitoCyclesTotal[1]); BurnYM2610Update(pBurnSoundOut, nBurnSoundLen); ZetClose(); diff --git a/src/burn/drivers/taito/d_othunder.cpp b/src/burn/drivers/taito/d_othunder.cpp index 8a16e7b69..193b5d044 100644 --- a/src/burn/drivers/taito/d_othunder.cpp +++ b/src/burn/drivers/taito/d_othunder.cpp @@ -769,7 +769,7 @@ static INT32 OthunderInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -837,12 +837,10 @@ static INT32 OthunderInit() static INT32 OthunderExit() { - TaitoExit(); - - BurnGunExit(); - BurnYM2610SetSoundMixMode(0); + TaitoExit(); + // Switch back CPU core if needed if (bUseAsm68KCoreOldValue) { #if 1 && defined FBA_DEBUG @@ -1063,6 +1061,10 @@ static INT32 OthunderFrame() nTaitoCyclesDone[nCurrentCPU] += SekRun(nTaitoCyclesSegment); if (i == (TaitoFrameInterleave - 1)) SekSetIRQLine(TaitoIrqLine, SEK_IRQSTATUS_AUTO); SekClose(); + + ZetOpen(0); + BurnTimerUpdate(i * (nTaitoCyclesTotal[1] / nInterleave)); + ZetClose(); } ZetOpen(0); diff --git a/src/burn/drivers/taito/d_slapshot.cpp b/src/burn/drivers/taito/d_slapshot.cpp index da4b9b82a..0c63af6f1 100644 --- a/src/burn/drivers/taito/d_slapshot.cpp +++ b/src/burn/drivers/taito/d_slapshot.cpp @@ -55,8 +55,8 @@ static struct BurnInputInfo Opwolf3InputList[] = A("P1 Gun X" , BIT_ANALOG_REL, &TaitoAnalogPort0 , "mouse x-axis" ), A("P1 Gun Y" , BIT_ANALOG_REL, &TaitoAnalogPort1 , "mouse y-axis" ), - {"P1 Fire 1" , BIT_DIGITAL , TC0640FIOInputPort2 + 0, "p1 fire 1" }, - {"P1 Fire 2" , BIT_DIGITAL , TC0640FIOInputPort2 + 1, "p1 fire 2" }, + {"P1 Fire 1" , BIT_DIGITAL , TC0640FIOInputPort2 + 0, "mouse button 1" }, + {"P1 Fire 2" , BIT_DIGITAL , TC0640FIOInputPort2 + 1, "mouse button 2" }, A("P2 Gun X" , BIT_ANALOG_REL, &TaitoAnalogPort2 , "p2 x-axis" ), A("P2 Gun Y" , BIT_ANALOG_REL, &TaitoAnalogPort3 , "p2 y-axis" ), @@ -501,7 +501,7 @@ static INT32 MachineInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -594,7 +594,7 @@ static INT32 SlapshotInit() if (MachineInit()) return 1; INT32 nRet; - UINT8 *TempRom = (UINT8*)malloc(0x400000); + UINT8 *TempRom = (UINT8*)BurnMalloc(0x400000); memset(TempRom, 0, 0x400000); nRet = BurnLoadRom(TempRom + 0x000000, 6, 2); if (nRet) return 1; nRet = BurnLoadRom(TempRom + 0x000001, 7, 2); if (nRet) return 1; @@ -617,10 +617,7 @@ static INT32 SlapshotInit() Offset++; } GfxDecode(TaitoNumSpriteA, TaitoSpriteANumPlanes, TaitoSpriteAWidth, TaitoSpriteAHeight, TaitoSpriteAPlaneOffsets, TaitoSpriteAXOffsets, TaitoSpriteAYOffsets, TaitoSpriteAModulo, TempRom, TaitoSpritesA); - if (TempRom) { - free(TempRom); - TempRom = NULL; - } + BurnFree(TempRom); SlapshotDoReset(); @@ -650,7 +647,7 @@ static INT32 Opwolf3Init() if (MachineInit()) return 1; INT32 nRet; - UINT8 *TempRom = (UINT8*)malloc(0x800000); + UINT8 *TempRom = (UINT8*)BurnMalloc(0x800000); memset(TempRom, 0, 0x400000); nRet = BurnLoadRom(TempRom + 0x000000, 8, 2); if (nRet) return 1; nRet = BurnLoadRom(TempRom + 0x000001, 9, 2); if (nRet) return 1; @@ -673,10 +670,7 @@ static INT32 Opwolf3Init() Offset++; } GfxDecode(TaitoNumSpriteA, TaitoSpriteANumPlanes, TaitoSpriteAWidth, TaitoSpriteAHeight, TaitoSpriteAPlaneOffsets, TaitoSpriteAXOffsets, TaitoSpriteAYOffsets, TaitoSpriteAModulo, TempRom, TaitoSpritesA); - if (TempRom) { - free(TempRom); - TempRom = NULL; - } + BurnFree(TempRom); SekOpen(0); SekMapHandler(1, 0xe00000, 0xe00007, SM_RAM); @@ -714,15 +708,6 @@ static INT32 SlapshotExit() return 0; } -static INT32 Opwolf3Exit() -{ - INT32 nRet = SlapshotExit(); - - BurnGunExit(); - - return nRet; -} - inline static INT32 CalcCol(INT32 nColour) { INT32 r, g, b; @@ -915,7 +900,7 @@ struct BurnDriver BurnDrvOpwolf3 = { NULL, NULL, NULL, NULL, BDF_GAME_WORKING, 2, HARDWARE_TAITO_MISC, GBF_SHOOT, 0, NULL, Opwolf3RomInfo, Opwolf3RomName, NULL, NULL, Opwolf3InputInfo, Opwolf3DIPInfo, - Opwolf3Init, Opwolf3Exit, SlapshotFrame, NULL, Opwolf3Scan, + Opwolf3Init, SlapshotExit, SlapshotFrame, NULL, Opwolf3Scan, NULL, 0x2000, 320, 224, 4, 3 }; @@ -925,6 +910,6 @@ struct BurnDriver BurnDrvOpwolf3u = { NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_TAITO_MISC, GBF_SHOOT, 0, NULL, Opwolf3uRomInfo, Opwolf3uRomName, NULL, NULL, Opwolf3InputInfo, Opwolf3DIPInfo, - Opwolf3Init, Opwolf3Exit, SlapshotFrame, NULL, Opwolf3Scan, + Opwolf3Init, SlapshotExit, SlapshotFrame, NULL, Opwolf3Scan, NULL, 0x2000, 320, 224, 4, 3 }; diff --git a/src/burn/drivers/taito/d_superchs.cpp b/src/burn/drivers/taito/d_superchs.cpp index ee9220863..1439817aa 100644 --- a/src/burn/drivers/taito/d_superchs.cpp +++ b/src/burn/drivers/taito/d_superchs.cpp @@ -711,7 +711,7 @@ static INT32 SuperchsInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -720,13 +720,14 @@ static INT32 SuperchsInit() TC0480SCPInit(TaitoNumChar, 0, 0x20, 8, -1, 0, 0); UINT8 *pTemp; - pTemp = (UINT8*)malloc(0xc00000); + pTemp = (UINT8*)BurnMalloc(0xc00000); memcpy(pTemp, TaitoES5505Rom, 0xc00000); memset(TaitoES5505Rom, 0, TaitoES5505RomSize); memcpy(TaitoES5505Rom + 0xc00000, pTemp + 0x000000, 0x400000); memcpy(TaitoES5505Rom + 0x000000, pTemp + 0x400000, 0x400000); memcpy(TaitoES5505Rom + 0x400000, pTemp + 0x400000, 0x400000); memcpy(TaitoES5505Rom + 0x800000, pTemp + 0x800000, 0x400000); + BurnFree(pTemp); SekInit(0, 0x68EC020); SekOpen(0); @@ -785,6 +786,7 @@ static INT32 SuperchsInit() static int SuperchsExit() { TaitoExit(); + ES5506Exit(); SuperchsCoinWord = 0; SuperchsCpuACtrl = 0; diff --git a/src/burn/drivers/taito/d_taitob.cpp b/src/burn/drivers/taito/d_taitob.cpp index f02b1f31b..47ad1c50b 100644 --- a/src/burn/drivers/taito/d_taitob.cpp +++ b/src/burn/drivers/taito/d_taitob.cpp @@ -1661,8 +1661,8 @@ static void DrvMakeInputs() } // for rambo3a's trackball - BurnGunMakeInputs(0, (INT16)TaitoAnalogPort0, (INT16)TaitoAnalogPort1); - BurnGunMakeInputs(1, (INT16)TaitoAnalogPort2, (INT16)TaitoAnalogPort3); + if (nBurnGunNumPlayers) BurnGunMakeInputs(0, (INT16)TaitoAnalogPort0, (INT16)TaitoAnalogPort1); + if (nBurnGunNumPlayers) BurnGunMakeInputs(1, (INT16)TaitoAnalogPort2, (INT16)TaitoAnalogPort3); } static void DrvFMIRQHandler(INT32, INT32 nStatus) @@ -1705,7 +1705,9 @@ static INT32 DrvDoReset(INT32 reset_ram) if (sound_config == 0) { BurnYM2610Reset(); } else { + ZetOpen(0); BurnYM2203Reset(); + ZetClose(); MSM6295Reset(0); } @@ -1767,7 +1769,7 @@ static void DrvGfxDecode(INT32 len, INT32 *tilemask0, INT32 *tilemask1) INT32 XOffs[16] = { 0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007, 0x080, 0x081, 0x082, 0x083, 0x084, 0x085, 0x086, 0x087 }; INT32 YOffs[16] = { 0x000, 0x010, 0x020, 0x030, 0x040, 0x050, 0x060, 0x070, 0x100, 0x110, 0x120, 0x130, 0x140, 0x150, 0x160, 0x170 }; - UINT8 *tmp = (UINT8*)malloc(len); + UINT8 *tmp = (UINT8*)BurnMalloc(len); if (tmp == NULL) { return; } @@ -1780,10 +1782,7 @@ static void DrvGfxDecode(INT32 len, INT32 *tilemask0, INT32 *tilemask1) *tilemask0 = (((len * 8) / 4) / ( 8 * 8)) - 1; *tilemask1 = (((len * 8) / 4) / (16 * 16)) - 1; - if (tmp) { - free (tmp); - tmp = NULL; - } + BurnFree (tmp); } static void common_ym2610_init() @@ -1832,11 +1831,12 @@ static void common_ym2203_init() BurnYM2203Init(1, 3000000, DrvFMIRQHandler, DrvSynchroniseStream, DrvGetTime, 0); BurnYM2203SetPorts(0, NULL, NULL, &bankswitch, NULL); + BurnYM2203SetVolumeShift(2); BurnTimerAttachZet(cpu_speed[1]); MSM6295ROM = TaitoMSM6295Rom; - MSM6295Init(0, 1056000 / 132, 80, 1); + MSM6295Init(0, 1056000 / 132, 40, 1); } static INT32 CommonInit(void (*pInitCallback)(), INT32 sound_type, INT32 color_select, INT32 input_type, INT32 irq0, INT32 irq1) @@ -1852,7 +1852,7 @@ static INT32 CommonInit(void (*pInitCallback)(), INT32 sound_type, INT32 color_s TaitoMem = NULL; MemIndex(); INT32 nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -1899,15 +1899,11 @@ static INT32 DrvExit() { EEPROMExit(); - TaitoICExit(); - GenericTilesExit(); - SekExit(); ZetExit(); - BurnYM2610SetSoundMixMode(0); - if (sound_config == 0) { + BurnYM2610SetSoundMixMode(0); BurnYM2610Exit(); } else { BurnYM2203Exit(); @@ -1915,15 +1911,7 @@ static INT32 DrvExit() MSM6295ROM = NULL; } - if (TaitoMem) { - free (TaitoMem); - TaitoMem = NULL; - } - - if (DrvFramebuffer) { - free (DrvFramebuffer); - DrvFramebuffer = NULL; - } + BurnFree (DrvFramebuffer); memset (nTaitoInputConfig, 0, 5); @@ -2790,7 +2778,7 @@ static void HiticeInitCallback() // SekSetReadWordHandler(0, hitice_read_word); SekClose(); - DrvFramebuffer = (UINT8*)malloc(1024 * 512); + DrvFramebuffer = (UINT8*)BurnMalloc(1024 * 512); } //---------------------------------------------------------------------------------------------------------- @@ -3195,13 +3183,10 @@ STD_ROM_FN(rambo3) static INT32 Rambo3Init() { - INT32 nRet = CommonInit(TetristInitCallback, 0, 0, 0, 1, 6); + nTaitoInputConfig[1] = 0x30; + BurnGunInit(2, false); - if (nRet == 0) { - memmove (Taito68KRom1 + 0x40000, Taito68KRom1 + 0x20000, 0x40000); - } - - return nRet; + return CommonInit(TetristInitCallback, 0, 2, 0, 1, 6); } struct BurnDriver BurnDrvRambo3 = { @@ -3209,7 +3194,7 @@ struct BurnDriver BurnDrvRambo3 = { "Rambo III (Europe)\0", NULL, "Taito Europe Corporation", "Taito B System", NULL, NULL, NULL, NULL, BDF_GAME_WORKING, 2, HARDWARE_TAITO_TAITOB, GBF_MISC, 0, - NULL, rambo3RomInfo, rambo3RomName, NULL, NULL, CommonInputInfo, Rambo3DIPInfo, + NULL, rambo3RomInfo, rambo3RomName, NULL, NULL, Rambo3uInputInfo, Rambo3uDIPInfo, Rambo3Init, DrvExit, DrvFrame, DrvDraw, DrvScan, NULL, 0x1000, 320, 224, 4, 3 }; @@ -3236,20 +3221,13 @@ static struct BurnRomInfo rambo3uRomDesc[] = { STD_ROM_PICK(rambo3u) STD_ROM_FN(rambo3u) -static INT32 Rambo3uInit() -{ - nTaitoInputConfig[1] = 0x30; - - return CommonInit(TetristInitCallback, 0, 2, 0, 1, 6); -} - struct BurnDriver BurnDrvRambo3u = { "rambo3u", "rambo3", NULL, NULL, "1989", "Rambo III (US)\0", NULL, "Taito Europe Corporation", "Taito B System", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_TAITO_TAITOB, GBF_MISC, 0, NULL, rambo3uRomInfo, rambo3uRomName, NULL, NULL, Rambo3uInputInfo, Rambo3uDIPInfo, - Rambo3uInit, DrvExit, DrvFrame, DrvDraw, DrvScan, NULL, 0x1000, + Rambo3Init, DrvExit, DrvFrame, DrvDraw, DrvScan, NULL, 0x1000, 320, 224, 4, 3 }; @@ -3291,13 +3269,24 @@ static struct BurnRomInfo rambo3pRomDesc[] = { STD_ROM_PICK(rambo3p) STD_ROM_FN(rambo3p) +static INT32 Rambo3pInit() +{ + INT32 nRet = CommonInit(TetristInitCallback, 0, 0, 0, 1, 6); + + if (nRet == 0) { + memmove (Taito68KRom1 + 0x40000, Taito68KRom1 + 0x20000, 0x40000); + } + + return nRet; +} + struct BurnDriver BurnDrvRambo3p = { "rambo3p", "rambo3", NULL, NULL, "1989", "Rambo III (Europe, Proti?)\0", NULL, "Taito Europe Corporation", "Taito B System", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_TAITO_TAITOB, GBF_SHOOT, 0, - NULL, rambo3pRomInfo, rambo3pRomName, NULL, NULL, Rambo3uInputInfo, Rambo3uDIPInfo, - Rambo3uInit, DrvExit, DrvFrame, DrvDraw, DrvScan, NULL, 0x1000, + NULL, rambo3pRomInfo, rambo3pRomName, NULL, NULL, CommonInputInfo, Rambo3DIPInfo, + Rambo3pInit, DrvExit, DrvFrame, DrvDraw, DrvScan, NULL, 0x1000, 320, 224, 4, 3 }; diff --git a/src/burn/drivers/taito/d_taitof2.cpp b/src/burn/drivers/taito/d_taitof2.cpp index b27c03be7..f3521a1a0 100644 --- a/src/burn/drivers/taito/d_taitof2.cpp +++ b/src/burn/drivers/taito/d_taitof2.cpp @@ -3527,7 +3527,7 @@ static struct BurnDIPInfo YesnojDIPList[]= { // Default Values {0x09, 0xff, 0xff, 0xff, NULL }, - {0x0a, 0xff, 0xfe, 0xff, NULL }, + {0x0a, 0xff, 0xff, 0xfe, NULL }, // Dip 1 @@ -7504,7 +7504,7 @@ static INT32 CameltryInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -7571,7 +7571,7 @@ static INT32 CamltryaInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -7659,7 +7659,7 @@ static INT32 DeadconxInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -7716,7 +7716,7 @@ static INT32 DinorexInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -7779,7 +7779,7 @@ static INT32 DondokodInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -7842,7 +7842,7 @@ static INT32 DriftoutInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -7909,13 +7909,13 @@ static INT32 DriveoutInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); if (TaitoLoadRoms(1)) return 1; - UINT8 *TempRom = (UINT8*)malloc(0x100000); + UINT8 *TempRom = (UINT8*)BurnMalloc(0x100000); memcpy(TempRom, TaitoMSM6295Rom, 0x100000); memset(TaitoMSM6295Rom, 0, 0x100000); memcpy(TaitoMSM6295Rom + 0x00000, TempRom + 0x00000, 0x20000); @@ -7926,10 +7926,7 @@ static INT32 DriveoutInit() memcpy(TaitoMSM6295Rom + 0xa0000, TempRom + 0x80000, 0x20000); memcpy(TaitoMSM6295Rom + 0xc0000, TempRom + 0x60000, 0x20000); memcpy(TaitoMSM6295Rom + 0xe0000, TempRom + 0x80000, 0x20000); - if (TempRom) { - free(TempRom); - TempRom = NULL; - } + BurnFree(TempRom); TC0100SCNInit(0, TaitoNumChar, 3, 8, 0, NULL); TC0360PRIInit(); @@ -8000,7 +7997,7 @@ static INT32 FinalbInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -8016,7 +8013,7 @@ static INT32 FinalbInit() // Load and decode Sprites INT32 nRet; TaitoNumSpriteA = 0x2000; - UINT8 *TempRom = (UINT8*)malloc(0x200000); + UINT8 *TempRom = (UINT8*)BurnMalloc(0x200000); memset(TempRom, 0, 0x200000); nRet = BurnLoadRom(TempRom + 0x000000 , 5, 2); if (nRet != 0) return 1; nRet = BurnLoadRom(TempRom + 0x000001 , 6, 2); if (nRet != 0) return 1; @@ -8038,10 +8035,7 @@ static INT32 FinalbInit() Offset++; } GfxDecode(TaitoNumSpriteA, TaitoSpriteANumPlanes, TaitoSpriteAWidth, TaitoSpriteAHeight, FinalbSpritePlaneOffsets, FinalbSpriteXOffsets, FinalbSpriteYOffsets, TaitoSpriteAModulo, TempRom, TaitoSpritesA); - if (TempRom) { - free(TempRom); - TempRom = NULL; - } + BurnFree(TempRom); SwitchToMusashi(); @@ -8102,7 +8096,7 @@ static INT32 FootchmpInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -8159,7 +8153,7 @@ static INT32 GrowlInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -8210,7 +8204,7 @@ static INT32 GunfrontInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -8262,7 +8256,7 @@ static INT32 KoshienInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -8315,7 +8309,7 @@ static INT32 LiquidkInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -8367,7 +8361,7 @@ static INT32 MegablstInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -8429,7 +8423,7 @@ static INT32 MetalbInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -8483,7 +8477,7 @@ static INT32 MjnquestInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -8491,7 +8485,7 @@ static INT32 MjnquestInit() // Load and decode Sprites INT32 nRet; - UINT8 *TempRom = (UINT8*)malloc(TaitoSpriteARomSize); + UINT8 *TempRom = (UINT8*)BurnMalloc(TaitoSpriteARomSize); memset(TempRom, 0, TaitoSpriteARomSize); nRet = BurnLoadRom(TempRom + 0x000000 , 6, 1); if (nRet != 0) return 1; for (UINT32 i = 0; i < TaitoSpriteARomSize; i += 2) { @@ -8500,10 +8494,7 @@ static INT32 MjnquestInit() TempRom[i + 1] = (Temp >> 4) | (Temp << 4); } GfxDecode(TaitoNumSpriteA, TaitoSpriteANumPlanes, TaitoSpriteAWidth, TaitoSpriteAHeight, TaitoSpriteAPlaneOffsets, TaitoSpriteAXOffsets, TaitoSpriteAYOffsets, TaitoSpriteAModulo, TempRom, TaitoSpritesA); - if (TempRom) { - free(TempRom); - TempRom = NULL; - } + BurnFree(TempRom); TC0110PCRInit(1, 0x1000); TC0100SCNInit(0, TaitoNumChar, 0, 8, 0, NULL); @@ -8551,7 +8542,7 @@ static INT32 NinjakInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -8608,7 +8599,7 @@ static INT32 PulirulaInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -8665,7 +8656,7 @@ static INT32 QcrayonInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -8720,7 +8711,7 @@ static INT32 Qcrayon2Init() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -8775,7 +8766,7 @@ static INT32 QjinseiInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -8829,7 +8820,7 @@ static INT32 QtorimonInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -8882,7 +8873,7 @@ static INT32 QuizhqInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -8936,7 +8927,7 @@ static INT32 QzchikyuInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -8989,7 +8980,7 @@ static INT32 QzquestInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -9042,7 +9033,7 @@ static INT32 SolfigtrInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -9092,7 +9083,7 @@ static INT32 SsiInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -9155,7 +9146,7 @@ static INT32 ThundfoxInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -9221,7 +9212,7 @@ static INT32 YesnojInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -9280,7 +9271,7 @@ static INT32 YuyugogoInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -10496,7 +10487,6 @@ static void YuyugogoDraw() static INT32 TaitoF2Frame() { INT32 nInterleave = 10; - INT32 nSoundBufferPos = 0; if (TaitoReset) TaitoF2DoReset(); @@ -10535,27 +10525,15 @@ static INT32 TaitoF2Frame() nCurrentCPU = 1; ZetOpen(0); BurnTimerUpdate(i * (nTaitoCyclesTotal[1] / nInterleave)); - if (pBurnSoundOut) { - INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos; - INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); - if (TaitoNumYM2610) BurnYM2610Update(pSoundBuf, nSegmentLength); - if (TaitoNumYM2203) BurnYM2203Update(pSoundBuf, nSegmentLength); - if (TaitoNumMSM6295) MSM6295Render(0, pSoundBuf, nSegmentLength); - nSoundBufferPos += nSegmentLength; - } ZetClose(); } ZetOpen(0); BurnTimerEndFrame(nTaitoCyclesTotal[1]); if (pBurnSoundOut) { - INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos; - INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); - if (nSegmentLength) { - if (TaitoNumYM2610) BurnYM2610Update(pSoundBuf, nSegmentLength); - if (TaitoNumYM2203) BurnYM2203Update(pSoundBuf, nSegmentLength); - if (TaitoNumMSM6295) MSM6295Render(0, pSoundBuf, nSegmentLength); - } + if (TaitoNumYM2610) BurnYM2610Update(pBurnSoundOut, nBurnSoundLen); + if (TaitoNumYM2203) BurnYM2203Update(pBurnSoundOut, nBurnSoundLen); + if (TaitoNumMSM6295) MSM6295Render(0, pBurnSoundOut, nBurnSoundLen); } ZetClose(); @@ -10571,7 +10549,6 @@ static INT32 TaitoF2Frame() static INT32 DriveoutFrame() { INT32 nInterleave = 10; - INT32 nSoundBufferPos = 0; if (TaitoReset) TaitoF2DoReset(); @@ -10615,23 +10592,11 @@ static INT32 DriveoutFrame() nTaitoCyclesSegment = ZetRun(nTaitoCyclesSegment); nTaitoCyclesDone[nCurrentCPU] += nTaitoCyclesSegment; ZetClose(); - - if (pBurnSoundOut) { - INT32 nSegmentLength = nBurnSoundLen / nInterleave; - INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); - MSM6295Render(0, pSoundBuf, nSegmentLength); - nSoundBufferPos += nSegmentLength; - } } // Make sure the buffer is entirely filled. if (pBurnSoundOut) { - INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos; - INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); - - if (nSegmentLength) { - MSM6295Render(0, pSoundBuf, nSegmentLength); - } + MSM6295Render(0, pBurnSoundOut, nBurnSoundLen); } TaitoF2HandleSpriteBuffering(); diff --git a/src/burn/drivers/taito/d_taitomisc.cpp b/src/burn/drivers/taito/d_taitomisc.cpp index e390f2ad1..b857e9178 100644 --- a/src/burn/drivers/taito/d_taitomisc.cpp +++ b/src/burn/drivers/taito/d_taitomisc.cpp @@ -2130,9 +2130,47 @@ static INT32 DariusDoReset() return 0; } +static INT32 RainbowDoReset() +{ +#if 0 + // This resets the YM2151 which calls DrvSoundBankSwitch via the port callback + TaitoDoReset(); +#else + SekOpen(0); + SekReset(); + SekClose(); + + ZetOpen(0); + ZetReset(); + ZetClose(); + + ZetOpen(0); + BurnYM2151Reset(); + ZetClose(); +#endif + + return 0; +} + static INT32 OpwolfDoReset() { +#if 0 + // This resets the YM2151 which calls DrvSoundBankSwitch via the port callback TaitoDoReset(); +#else + SekOpen(0); + SekReset(); + SekClose(); + + ZetOpen(0); + ZetReset(); + ZetClose(); + + ZetOpen(0); + BurnYM2151Reset(); + ZetClose(); + MSM5205Reset(); +#endif memset(OpwolfADPCM_B, 0, 8); memset(OpwolfADPCM_C, 0, 8); @@ -3972,7 +4010,7 @@ static INT32 DariusInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -4044,9 +4082,10 @@ static INT32 DariusInit() ZetClose(); BurnYM2203Init(2, 4000000, TaitoYM2203IRQHandler, TaitoSynchroniseStream, TaitoGetTime, 0); + BurnYM2203SetVolumeShift(2); BurnTimerAttachZet(8000000 / 2); - MSM5205Init(0, TaitoSynchroniseStream, 384000, DariusAdpcmInt, MSM5205_S48_4B, 100, 1); + MSM5205Init(0, TaitoSynchroniseStream, 384000, DariusAdpcmInt, MSM5205_S48_4B, 50, 1); GenericTilesInit(); @@ -4099,7 +4138,7 @@ static INT32 OpwolfInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -4203,7 +4242,7 @@ static INT32 OpwolfbInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -4315,7 +4354,7 @@ static INT32 RainbowInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -4373,7 +4412,7 @@ static INT32 RainbowInit() RainbowCChipInit(CChipVer); // Reset the driver - TaitoResetFunction = TaitoDoReset; + TaitoResetFunction = RainbowDoReset; TaitoResetFunction(); return 0; @@ -4412,7 +4451,7 @@ static INT32 JumpingInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -4504,7 +4543,7 @@ static INT32 RastanInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -4597,7 +4636,7 @@ static INT32 TopspeedInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -4665,7 +4704,7 @@ static INT32 TopspeedInit() nTaitoCyclesTotal[1] = 12000000 / 60; nTaitoCyclesTotal[2] = 4000000 / 60; - pTopspeedTempDraw = (UINT16*)malloc(512 * 512 * sizeof(UINT16)); + pTopspeedTempDraw = (UINT16*)BurnMalloc(512 * 512 * sizeof(UINT16)); // Reset the driver TaitoResetFunction = TopspeedDoReset; @@ -4698,7 +4737,7 @@ static INT32 VolfiedInit() TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -4778,10 +4817,7 @@ static INT32 TaitoMiscExit() VolfiedVidCtrl = 0; VolfiedVidMask = 0; - if (pTopspeedTempDraw) { - free(pTopspeedTempDraw); - pTopspeedTempDraw = NULL; - } + BurnFree(pTopspeedTempDraw); return TaitoExit(); } @@ -5359,10 +5395,12 @@ static INT32 TaitoMiscFrame() } } - if (TaitoNumZ80s >= 1) ZetOpen(0); - if (TaitoNumMSM5205) MSM5205Render(0, pBurnSoundOut, nBurnSoundLen); - if (TaitoNumMSM5205 >= 2) MSM5205Render(1, pBurnSoundOut, nBurnSoundLen); - if (TaitoNumZ80s >= 1) ZetClose(); + if (pBurnSoundOut) { + if (TaitoNumZ80s >= 1) ZetOpen(0); + if (TaitoNumMSM5205) MSM5205Render(0, pBurnSoundOut, nBurnSoundLen); + if (TaitoNumMSM5205 >= 2) MSM5205Render(1, pBurnSoundOut, nBurnSoundLen); + if (TaitoNumZ80s >= 1) ZetClose(); + } if (pBurnDraw) TaitoDrawFunction(); @@ -5421,18 +5459,12 @@ static INT32 DariusFrame() ZetOpen(0); BurnTimerEndFrame(nTaitoCyclesTotal[2]); - BurnYM2203Update(pBurnSoundOut, nBurnSoundLen); + if (pBurnSoundOut) BurnYM2203Update(pBurnSoundOut, nBurnSoundLen); ZetClose(); - // Reduce the YM2203 volume - for (INT32 j = 0; j < nBurnSoundLen * 2; j += 2) { - pBurnSoundOut[j + 0] /= 10; - pBurnSoundOut[j + 1] /= 10; - } - ZetOpen(1); ZetRun(nTaitoCyclesTotal[3] - nTaitoCyclesDone[3]); - MSM5205Render(0, pBurnSoundOut, nBurnSoundLen); + if (pBurnSoundOut) MSM5205Render(0, pBurnSoundOut, nBurnSoundLen); ZetClose(); if (pBurnDraw) TaitoDrawFunction(); @@ -5473,7 +5505,7 @@ static INT32 JumpingFrame() ZetOpen(0); BurnTimerEndFrame(nTaitoCyclesTotal[1]); - BurnYM2203Update(pBurnSoundOut, nBurnSoundLen); + if (pBurnSoundOut) BurnYM2203Update(pBurnSoundOut, nBurnSoundLen); ZetClose(); if (pBurnDraw) TaitoDrawFunction(); @@ -5555,9 +5587,11 @@ static INT32 TopspeedFrame() } } - if (TaitoNumZ80s >= 1) ZetOpen(0); - if (TaitoNumMSM5205) MSM5205Render(0, pBurnSoundOut, nBurnSoundLen); - if (TaitoNumZ80s >= 1) ZetClose(); + if (pBurnSoundOut) { + if (TaitoNumZ80s >= 1) ZetOpen(0); + if (TaitoNumMSM5205) MSM5205Render(0, pBurnSoundOut, nBurnSoundLen); + if (TaitoNumZ80s >= 1) ZetClose(); + } if (pBurnDraw) TaitoDrawFunction(); diff --git a/src/burn/drivers/taito/d_taitox.cpp b/src/burn/drivers/taito/d_taitox.cpp index 6f0d344d6..379c651aa 100644 --- a/src/burn/drivers/taito/d_taitox.cpp +++ b/src/burn/drivers/taito/d_taitox.cpp @@ -1073,7 +1073,7 @@ static INT32 TaitoXInit(INT32 nSoundType) TaitoMem = NULL; MemIndex(); nLen = TaitoMemEnd - (UINT8 *)0; - if ((TaitoMem = (UINT8 *)malloc(nLen)) == NULL) return 1; + if ((TaitoMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1; memset(TaitoMem, 0, nLen); MemIndex(); @@ -1411,7 +1411,6 @@ static void TaitoXDraw() static INT32 TaitoXFrame() { INT32 nInterleave = 10; - INT32 nSoundBufferPos = 0; if (TaitoReset) TaitoDoReset(); @@ -1436,23 +1435,13 @@ static INT32 TaitoXFrame() nCurrentCPU = 1; ZetOpen(0); BurnTimerUpdate(i * (nTaitoCyclesTotal[1] / nInterleave)); - if (pBurnSoundOut) { - INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos; - INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); - BurnYM2610Update(pSoundBuf, nSegmentLength); - nSoundBufferPos += nSegmentLength; - } ZetClose(); } ZetOpen(0); BurnTimerEndFrame(nTaitoCyclesTotal[1]); if (pBurnSoundOut) { - INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos; - INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); - if (nSegmentLength) { - BurnYM2610Update(pSoundBuf, nSegmentLength); - } + BurnYM2610Update(pBurnSoundOut, nBurnSoundLen); } ZetClose(); diff --git a/src/burn/drivers/taito/d_taitoz.cpp b/src/burn/drivers/taito/d_taitoz.cpp index dbb93b021..1660cbc56 100644 --- a/src/burn/drivers/taito/d_taitoz.cpp +++ b/src/burn/drivers/taito/d_taitoz.cpp @@ -4901,6 +4901,8 @@ static INT32 SpacegunInit() static INT32 TaitoZExit() { + BurnYM2610SetSoundMixMode(0); + TaitoExit(); SciSpriteFrame = 0; @@ -4908,8 +4910,6 @@ static INT32 TaitoZExit() Dblaxle = 0; Sci = 0; - BurnYM2610SetSoundMixMode(0); - // Switch back CPU core if needed if (bUseAsm68KCoreOldValue) { #if 1 && defined FBA_DEBUG @@ -5722,17 +5722,23 @@ static INT32 TaitoZFrame() if (i == (TaitoFrameInterleave - 1)) SekSetIRQLine(TaitoIrqLine, SEK_IRQSTATUS_AUTO); SekClose(); } + + if (TaitoNumZ80s) { + ZetOpen(0); + BurnTimerUpdate(i * (nTaitoCyclesTotal[2] / nInterleave)); + ZetClose(); + } } if (TaitoNumZ80s) { ZetOpen(0); BurnTimerEndFrame(nTaitoCyclesTotal[2]); - BurnYM2610Update(pBurnSoundOut, nBurnSoundLen); + if (pBurnSoundOut) BurnYM2610Update(pBurnSoundOut, nBurnSoundLen); ZetClose(); } else { SekOpen(1); if (TaitoCpuACtrl & 0x01) BurnTimerEndFrame(nTaitoCyclesTotal[1]); - BurnYM2610Update(pBurnSoundOut, nBurnSoundLen); + if (pBurnSoundOut) BurnYM2610Update(pBurnSoundOut, nBurnSoundLen); if (TaitoCpuACtrl & 0x01) SekSetIRQLine(TaitoIrqLine, SEK_IRQSTATUS_AUTO); SekClose(); } diff --git a/src/burn/drivers/taito/pc080sn.cpp b/src/burn/drivers/taito/pc080sn.cpp index fd21cb5c5..d4ca48bd0 100644 --- a/src/burn/drivers/taito/pc080sn.cpp +++ b/src/burn/drivers/taito/pc080sn.cpp @@ -415,7 +415,7 @@ void PC080SNReset() void PC080SNInit(INT32 Chip, INT32 nNumTiles, INT32 xOffset, INT32 yOffset, INT32 yInvert, INT32 DblWidth) { - PC080SNRam[Chip] = (UINT8*)malloc(0x10000); + PC080SNRam[Chip] = (UINT8*)BurnMalloc(0x10000); memset(PC080SNRam[Chip], 0, 0x10000); PC080SNNumTiles[Chip] = nNumTiles; @@ -443,10 +443,7 @@ void PC080SNSetFgTransparentPen(INT32 Chip, INT32 Pen) void PC080SNExit() { for (INT32 i = 0; i < PC080SNNum; i++) { - if (PC080SNRam[i]) { - free(PC080SNRam[i]); - PC080SNRam[i] = NULL; - } + BurnFree(PC080SNRam[i]); memset(PC080SNCtrl[i], 0, 8 * sizeof(UINT16)); BgScrollX[i] = 0; diff --git a/src/burn/drivers/taito/pc090oj.cpp b/src/burn/drivers/taito/pc090oj.cpp index a8d77d4d4..5a0e2a5bc 100644 --- a/src/burn/drivers/taito/pc090oj.cpp +++ b/src/burn/drivers/taito/pc090oj.cpp @@ -91,7 +91,7 @@ void PC090OJReset() void PC090OJInit(INT32 nNumTiles, INT32 xOffset, INT32 yOffset, INT32 UseBuffer) { - PC090OJRam = (UINT8*)malloc(0x4000); + PC090OJRam = (UINT8*)BurnMalloc(0x4000); memset(PC090OJRam, 0, 0x4000); PC090OJNumTiles = nNumTiles; @@ -111,10 +111,7 @@ void PC090OJSetPaletteOffset(INT32 Offset) void PC090OJExit() { - if (PC090OJRam) { - free(PC090OJRam); - PC090OJRam = NULL; - } + BurnFree(PC090OJRam); PC090OJNumTiles = 0; PC090OJXOffset = 0; diff --git a/src/burn/drivers/taito/taito.cpp b/src/burn/drivers/taito/taito.cpp index d62f959f5..dd7392f75 100644 --- a/src/burn/drivers/taito/taito.cpp +++ b/src/burn/drivers/taito/taito.cpp @@ -43,7 +43,7 @@ UINT8 *TaitoSpriteRamBuffered = NULL; UINT8 *TaitoSpriteRamDelayed = NULL; UINT8 *TaitoSpriteExtension = NULL; UINT8 *TaitoVideoRam = NULL; -UINT32 *TaitoPalette = NULL; +UINT32 *TaitoPalette = NULL; UINT8 *TaitoPriorityMap = NULL; UINT8 TaitoZ80Bank = 0; @@ -463,7 +463,7 @@ INT32 TaitoLoadRoms(INT32 bLoad) } if (TaitoCharRomSize) { - UINT8 *TempRom = (UINT8*)malloc(TaitoCharRomSize); + UINT8 *TempRom = (UINT8*)BurnMalloc(TaitoCharRomSize); memset(TempRom, 0, TaitoCharRomSize); Offset = 0; @@ -500,14 +500,11 @@ INT32 TaitoLoadRoms(INT32 bLoad) memcpy (TaitoChars, TempRom, Offset); } - if (TempRom) { - free(TempRom); - TempRom = NULL; - } + BurnFree(TempRom); } if (TaitoCharBRomSize) { - UINT8 *TempRom = (UINT8*)malloc(TaitoCharBRomSize); + UINT8 *TempRom = (UINT8*)BurnMalloc(TaitoCharBRomSize); memset(TempRom, 0, TaitoCharBRomSize); Offset = 0; @@ -540,14 +537,11 @@ INT32 TaitoLoadRoms(INT32 bLoad) GfxDecode(TaitoNumCharB, TaitoCharBNumPlanes, TaitoCharBWidth, TaitoCharBHeight, TaitoCharBPlaneOffsets, TaitoCharBXOffsets, TaitoCharBYOffsets, TaitoCharBModulo, TempRom, TaitoCharsB); - if (TempRom) { - free(TempRom); - TempRom = NULL; - } + BurnFree(TempRom); } if (TaitoSpriteARomSize) { - UINT8 *TempRom = (UINT8*)malloc(TaitoSpriteARomSize); + UINT8 *TempRom = (UINT8*)BurnMalloc(TaitoSpriteARomSize); memset(TempRom, 0, TaitoSpriteARomSize); Offset = 0; @@ -629,14 +623,11 @@ INT32 TaitoLoadRoms(INT32 bLoad) memcpy (TaitoSpritesA, TempRom, Offset); } - if (TempRom) { - free(TempRom); - TempRom = NULL; - } + BurnFree(TempRom); } if (TaitoSpriteBRomSize) { - UINT8 *TempRom = (UINT8*)malloc(TaitoSpriteBRomSize); + UINT8 *TempRom = (UINT8*)BurnMalloc(TaitoSpriteBRomSize); memset(TempRom, 0, TaitoSpriteBRomSize); Offset = 0; @@ -687,10 +678,7 @@ INT32 TaitoLoadRoms(INT32 bLoad) GfxDecode(TaitoNumSpriteB, TaitoSpriteBNumPlanes, TaitoSpriteBWidth, TaitoSpriteBHeight, TaitoSpriteBPlaneOffsets, TaitoSpriteBXOffsets, TaitoSpriteBYOffsets, TaitoSpriteBModulo, TempRom, TaitoSpritesB); - if (TempRom) { - free(TempRom); - TempRom = NULL; - } + BurnFree(TempRom); } if (TaitoRoadRomSize) { @@ -764,7 +752,7 @@ INT32 TaitoLoadRoms(INT32 bLoad) } if (TaitoCharPivotRomSize) { - UINT8 *TempRom = (UINT8*)malloc(TaitoCharPivotRomSize); + UINT8 *TempRom = (UINT8*)BurnMalloc(TaitoCharPivotRomSize); memset(TempRom, 0, TaitoCharPivotRomSize); Offset = 0; @@ -785,10 +773,7 @@ INT32 TaitoLoadRoms(INT32 bLoad) GfxDecode(TaitoNumCharPivot, TaitoCharPivotNumPlanes, TaitoCharPivotWidth, TaitoCharPivotHeight, TaitoCharPivotPlaneOffsets, TaitoCharPivotXOffsets, TaitoCharPivotYOffsets, TaitoCharPivotModulo, TempRom, TaitoCharsPivot); - if (TempRom) { - free(TempRom); - TempRom = NULL; - } + BurnFree(TempRom); } if (TaitoMSM6295RomSize) { @@ -876,12 +861,9 @@ INT32 TaitoExit() TaitoICExit(); GenericTilesExit(); - BurnGunExit(); + if (nBurnGunNumPlayers) BurnGunExit(); - if (TaitoMem) { - free(TaitoMem); - TaitoMem = NULL; - } + BurnFree(TaitoMem); Taito68KRom1Num = 0; Taito68KRom2Num = 0; diff --git a/src/burn/drivers/taito/taito_ic.cpp b/src/burn/drivers/taito/taito_ic.cpp index 91018cb2f..3ed2b151d 100644 --- a/src/burn/drivers/taito/taito_ic.cpp +++ b/src/burn/drivers/taito/taito_ic.cpp @@ -52,6 +52,27 @@ void TaitoICReset() void TaitoICExit() { + if (TaitoIC_SupermanCChipInUse) SupermanCChipExit(); + if (TaitoIC_MegabCChipInUse) MegabCChipExit(); + if (TaitoIC_RainbowCChipInUse) RainbowCChipExit(); + if (TaitoIC_OpwolfCChipInUse) OpwolfCChipExit(); + if (TaitoIC_VolfiedCChipInUse) VolfiedCChipExit(); + + if (TaitoIC_PC080SNInUse) PC080SNExit(); + if (TaitoIC_PC090OJInUse) PC090OJExit(); + if (TaitoIC_TC0100SCNInUse) TC0100SCNExit(); + if (TaitoIC_TC0110PCRInUse) TC0110PCRExit(); + if (TaitoIC_TC0140SYTInUse) TC0140SYTExit(); + if (TaitoIC_TC0150RODInUse) TC0150RODExit(); + if (TaitoIC_TC0180VCUInUse) TC0180VCUExit(); + if (TaitoIC_TC0220IOCInUse) TC0220IOCExit(); + if (TaitoIC_TC0280GRDInUse) TC0280GRDExit(); + if (TaitoIC_TC0360PRIInUse) TC0360PRIExit(); + if (TaitoIC_TC0430GRWInUse) TC0430GRWExit(); + if (TaitoIC_TC0480SCPInUse) TC0480SCPExit(); + if (TaitoIC_TC0510NIOInUse) TC0510NIOExit(); + if (TaitoIC_TC0640FIOInUse) TC0640FIOExit(); + TaitoIC_SupermanCChipInUse = 0; TaitoIC_MegabCChipInUse = 0; TaitoIC_RainbowCChipInUse = 0; @@ -74,27 +95,6 @@ void TaitoICExit() TaitoIC_TC0640FIOInUse = 0; TaitoWatchdog = 0; - - SupermanCChipExit(); - MegabCChipExit(); - RainbowCChipExit(); - OpwolfCChipExit(); - VolfiedCChipExit(); - - PC080SNExit(); - PC090OJExit(); - TC0100SCNExit(); - TC0110PCRExit(); - TC0140SYTExit(); - TC0150RODExit(); - TC0180VCUExit(); - TC0220IOCExit(); - TC0280GRDExit(); - TC0360PRIExit(); - TC0430GRWExit(); - TC0480SCPExit(); - TC0510NIOExit(); - TC0640FIOExit(); } void TaitoICScan(INT32 nAction) diff --git a/src/burn/drivers/taito/tc0100scn.cpp b/src/burn/drivers/taito/tc0100scn.cpp index 8a421bbca..acc419580 100644 --- a/src/burn/drivers/taito/tc0100scn.cpp +++ b/src/burn/drivers/taito/tc0100scn.cpp @@ -490,16 +490,16 @@ void TC0100SCNReset() void TC0100SCNInit(INT32 Chip, INT32 nNumTiles, INT32 xOffset, INT32 yOffset, INT32 xFlip, UINT8 *PriorityMap) { - TC0100SCNRam[Chip] = (UINT8*)malloc(0x14000); + TC0100SCNRam[Chip] = (UINT8*)BurnMalloc(0x14000); memset(TC0100SCNRam[Chip], 0, 0x14000); - TC0100SCNChars[Chip] = (UINT8*)malloc(256 * 8 * 8); + TC0100SCNChars[Chip] = (UINT8*)BurnMalloc(256 * 8 * 8); memset(TC0100SCNChars[Chip], 0, 256 * 8 * 8); - pTC0100SCNBgTempDraw[Chip] = (UINT16*)malloc(1024 * 512 * sizeof(UINT16)); + pTC0100SCNBgTempDraw[Chip] = (UINT16*)BurnMalloc(1024 * 512 * sizeof(UINT16)); memset(pTC0100SCNBgTempDraw[Chip], 0, 1024 * 512 * sizeof(UINT16)); - pTC0100SCNFgTempDraw[Chip] = (UINT16*)malloc(1024 * 512 * sizeof(UINT16)); + pTC0100SCNFgTempDraw[Chip] = (UINT16*)BurnMalloc(1024 * 512 * sizeof(UINT16)); memset(pTC0100SCNFgTempDraw[Chip], 0, 1024 * 512 * sizeof(UINT16)); TC0100SCNXOffset[Chip] = xOffset; @@ -552,25 +552,10 @@ void TC0100SCNSetPaletteOffset(INT32 Chip, INT32 PaletteOffset) void TC0100SCNExit() { for (INT32 i = 0; i < TC0100SCNNum; i++) { - if (TC0100SCNRam[i]) { - free(TC0100SCNRam[i]); - TC0100SCNRam[i] = NULL; - } - - if (TC0100SCNChars[i]) { - free(TC0100SCNChars[i]); - TC0100SCNChars[i] = NULL; - } - - if (pTC0100SCNBgTempDraw[i]) { - free(pTC0100SCNBgTempDraw[i]); - pTC0100SCNBgTempDraw[i] = NULL; - } - - if (pTC0100SCNFgTempDraw[i]) { - free(pTC0100SCNFgTempDraw[i]); - pTC0100SCNFgTempDraw[i] = NULL; - } + BurnFree(TC0100SCNRam[i]); + BurnFree(TC0100SCNChars[i]); + BurnFree(pTC0100SCNBgTempDraw[i]); + BurnFree(pTC0100SCNFgTempDraw[i]); memset(TC0100SCNCtrl[i], 0, 8); diff --git a/src/burn/drivers/taito/tc0110pcr.cpp b/src/burn/drivers/taito/tc0110pcr.cpp index 463af5a75..4fd215288 100644 --- a/src/burn/drivers/taito/tc0110pcr.cpp +++ b/src/burn/drivers/taito/tc0110pcr.cpp @@ -140,11 +140,11 @@ void TC0110PCRReset() void TC0110PCRInit(INT32 Num, INT32 nNumColours) { for (INT32 i = 0; i < Num; i++) { - TC0110PCRRam[i] = (UINT8*)malloc(0x4000); + TC0110PCRRam[i] = (UINT8*)BurnMalloc(0x4000); memset(TC0110PCRRam[i], 0, 0x4000); } - TC0110PCRPalette = (UINT32*)malloc(nNumColours * sizeof(UINT32)); + TC0110PCRPalette = (UINT32*)BurnMalloc(nNumColours * sizeof(UINT32)); memset(TC0110PCRPalette, 0, nNumColours); TC0110PCRTotalColours = nNumColours; @@ -155,17 +155,11 @@ void TC0110PCRInit(INT32 Num, INT32 nNumColours) void TC0110PCRExit() { for (INT32 i = 0; i < MAX_TC0110PCR; i++) { - if (TC0110PCRRam[i]) { - free(TC0110PCRRam[i]); - TC0110PCRRam[i] = NULL; - } + BurnFree(TC0110PCRRam[i]); TC0110PCRAddr[i] = 0; } - if (TC0110PCRPalette) { - free(TC0110PCRPalette); - TC0110PCRPalette = NULL; - } + BurnFree(TC0110PCRPalette); TC0110PCRTotalColours = 0; } diff --git a/src/burn/drivers/taito/tc0150rod.cpp b/src/burn/drivers/taito/tc0150rod.cpp index 6caf7af4c..9dcbcb09f 100644 --- a/src/burn/drivers/taito/tc0150rod.cpp +++ b/src/burn/drivers/taito/tc0150rod.cpp @@ -422,9 +422,9 @@ void TC0150RODReset() void TC0150RODInit(INT32 nRomSize, INT32 xFlip) { - TC0150RODRom = (UINT8*)malloc(nRomSize); + TC0150RODRom = (UINT8*)BurnMalloc(nRomSize); memset(TC0150RODRom, 0, nRomSize); - TC0150RODRam = (UINT8*)malloc(0x2000); + TC0150RODRam = (UINT8*)BurnMalloc(0x2000); memset(TC0150RODRam, 0, 0x2000); TC0150RODFlipScreenX = xFlip; @@ -434,15 +434,8 @@ void TC0150RODInit(INT32 nRomSize, INT32 xFlip) void TC0150RODExit() { - if (TC0150RODRom) { - free(TC0150RODRom); - TC0150RODRom = NULL; - } - - if (TC0150RODRam) { - free(TC0150RODRam); - TC0150RODRam = NULL; - } + BurnFree(TC0150RODRom); + BurnFree(TC0150RODRam); TC0150RODFlipScreenX = 0; } diff --git a/src/burn/drivers/taito/tc0180vcu.cpp b/src/burn/drivers/taito/tc0180vcu.cpp index 73c82b3ac..0f7ddcc16 100644 --- a/src/burn/drivers/taito/tc0180vcu.cpp +++ b/src/burn/drivers/taito/tc0180vcu.cpp @@ -101,7 +101,7 @@ static void create_transtile_table(INT32 tile) if (tilemask[tile]) { INT32 len = (tilemask[tile] + 1); - transtiletab[tile] = (UINT8*)malloc(len); + transtiletab[tile] = (UINT8*)BurnMalloc(len); memset (transtiletab[tile], 1, len); @@ -121,14 +121,14 @@ void TC0180VCUInit(UINT8 *gfx0, INT32 mask0, UINT8 *gfx1, INT32 mask1, INT32 glo for (INT32 i = 0; i < 2; i++) { - TC0180VCUFramebuffer[i] = (UINT16*)malloc(512 * 256 * sizeof(UINT16)); - TC0180VCU_scrollx[i] = (INT32*)malloc(257 * sizeof(INT32)); - TC0180VCU_scrolly[i] = (INT32*)malloc(257 * sizeof(INT32)); + TC0180VCUFramebuffer[i] = (UINT16*)BurnMalloc(512 * 256 * sizeof(UINT16)); + TC0180VCU_scrollx[i] = (INT32*)BurnMalloc(257 * sizeof(INT32)); + TC0180VCU_scrolly[i] = (INT32*)BurnMalloc(257 * sizeof(INT32)); } - TC0180VCURAM = (UINT8*)malloc(0x010000); - TC0180VCUScrollRAM = (UINT8*)malloc(0x000800); - TC0180VCUFbRAM = (UINT8*)malloc(0x040000); + TC0180VCURAM = (UINT8*)BurnMalloc(0x010000); + TC0180VCUScrollRAM = (UINT8*)BurnMalloc(0x000800); + TC0180VCUFbRAM = (UINT8*)BurnMalloc(0x040000); tilemask[0] = mask0; tilemask[1] = mask1; @@ -139,8 +139,8 @@ void TC0180VCUInit(UINT8 *gfx0, INT32 mask0, UINT8 *gfx1, INT32 mask1, INT32 glo if (mask1) create_transtile_table(1); if (mask0 == 0) { - dummy_tile = (UINT8*)malloc(0x100); - transtiletab[1] = (UINT8*)malloc(1); + dummy_tile = (UINT8*)BurnMalloc(0x100); + transtiletab[1] = (UINT8*)BurnMalloc(1); tiledata[1] = dummy_tile; } @@ -154,49 +154,20 @@ void TC0180VCUExit() { for (INT32 i = 0; i < 2; i++) { - if (TC0180VCU_scrollx[i]) { - free (TC0180VCU_scrollx[i]); - TC0180VCU_scrollx[i] = NULL; - } - - if (TC0180VCU_scrolly[i]) { - free (TC0180VCU_scrolly[i]); - TC0180VCU_scrolly[i] = NULL; - } + BurnFree (TC0180VCU_scrollx[i]); + BurnFree (TC0180VCU_scrolly[i]); tilemask[i] = ~0; tiledata[i] = NULL; - if (TC0180VCUFramebuffer[i]) { - free (TC0180VCUFramebuffer[i]); - TC0180VCUFramebuffer[i] = NULL; - } - - if (transtiletab[i]) { - free (transtiletab[i]); - transtiletab[i] = NULL; - } + BurnFree (TC0180VCUFramebuffer[i]); + BurnFree (transtiletab[i]); } - if (dummy_tile) { - free (dummy_tile); - dummy_tile = NULL; - } - - if (TC0180VCURAM) { - free (TC0180VCURAM); - TC0180VCURAM = NULL; - } - - if (TC0180VCUScrollRAM) { - free (TC0180VCUScrollRAM); - TC0180VCUScrollRAM = NULL; - } - - if (TC0180VCUFbRAM) { - free (TC0180VCUFbRAM); - TC0180VCUFbRAM = NULL; - } + BurnFree (dummy_tile); + BurnFree (TC0180VCURAM); + BurnFree (TC0180VCUScrollRAM); + BurnFree (TC0180VCUFbRAM); TC0180VCU_y_offset = 0; TC0180VCU_x_offset = 0; diff --git a/src/burn/drivers/taito/tc0280grd.cpp b/src/burn/drivers/taito/tc0280grd.cpp index f3a5dee1e..dc0f4ef7e 100644 --- a/src/burn/drivers/taito/tc0280grd.cpp +++ b/src/burn/drivers/taito/tc0280grd.cpp @@ -154,10 +154,10 @@ void TC0280GRDReset() void TC0280GRDInit(INT32 xOffs, INT32 yOffs, UINT8 *pSrc) { - TC0280GRDRam = (UINT8*)malloc(0x2000); + TC0280GRDRam = (UINT8*)BurnMalloc(0x2000); memset(TC0280GRDRam, 0, 0x2000); - pRozTileMapData = (UINT16*)malloc(512 * 512 * sizeof(UINT16)); + pRozTileMapData = (UINT16*)BurnMalloc(512 * 512 * sizeof(UINT16)); memset(pRozTileMapData, 0, 512 * 512 * sizeof(UINT16)); TC0280GRDXOffset = xOffs; @@ -182,15 +182,8 @@ void TC0430GRWInit(INT32 xOffs, INT32 yOffs, UINT8 *pSrc) void TC0280GRDExit() { - if (TC0280GRDRam) { - free(TC0280GRDRam); - TC0280GRDRam = NULL; - } - - if (pRozTileMapData) { - free(pRozTileMapData); - pRozTileMapData = NULL; - } + BurnFree(TC0280GRDRam); + BurnFree(pRozTileMapData); memset(TC0280GRDCtrl, 0, 8); diff --git a/src/burn/drivers/taito/tc0480scp.cpp b/src/burn/drivers/taito/tc0480scp.cpp index cf61e5c0d..928c900e1 100644 --- a/src/burn/drivers/taito/tc0480scp.cpp +++ b/src/burn/drivers/taito/tc0480scp.cpp @@ -802,9 +802,9 @@ INT32 TC0480SCPGetBgPriority() void TC0480SCPInit(INT32 nNumTiles, INT32 Pixels, INT32 xOffset, INT32 yOffset, INT32 xTextOffset, INT32 yTextOffset, INT32 VisYOffset) { - TC0480SCPRam = (UINT8*)malloc(0x10000); + TC0480SCPRam = (UINT8*)BurnMalloc(0x10000); memset(TC0480SCPRam, 0, 0x10000); - TC0480SCPChars = (UINT8*)malloc(256 * 8 * 8); + TC0480SCPChars = (UINT8*)BurnMalloc(256 * 8 * 8); memset(TC0480SCPChars, 0, 256 * 8 * 8); TC0480SCPTilesNum = nNumTiles; @@ -814,7 +814,7 @@ void TC0480SCPInit(INT32 nNumTiles, INT32 Pixels, INT32 xOffset, INT32 yOffset, TC0480SCPTextXOffset = xTextOffset - TC0480SCPXOffset + 3; TC0480SCPTextYOffset = yTextOffset + TC0480SCPYOffset; - pTC0480SCPTempDraw = (UINT16*)malloc(1024 * 512 * sizeof(UINT16)); + pTC0480SCPTempDraw = (UINT16*)BurnMalloc(1024 * 512 * sizeof(UINT16)); memset(pTC0480SCPTempDraw, 0, 1024 * 512 * sizeof(UINT16)); TC0480SCPColBase = 0; @@ -830,20 +830,9 @@ void TC0480SCPSetColourBase(INT32 Base) void TC0480SCPExit() { - if (TC0480SCPRam) { - free(TC0480SCPRam); - TC0480SCPRam = NULL; - } - - if (TC0480SCPChars) { - free(TC0480SCPChars); - TC0480SCPChars = NULL; - } - - if (pTC0480SCPTempDraw) { - free(pTC0480SCPTempDraw); - pTC0480SCPTempDraw = NULL; - } + BurnFree(TC0480SCPRam); + BurnFree(TC0480SCPChars); + BurnFree(pTC0480SCPTempDraw); memset(TC0480SCPCtrl, 0, 0x18); BgScrollX[0] = BgScrollX[1] = BgScrollX[2] = BgScrollX[3] = 0;