From 180f032a5e372603279593dcb830ebbfd5378de7 Mon Sep 17 00:00:00 2001 From: dinkc64 <12570148+dinkc64@users.noreply.github.com> Date: Fri, 18 Apr 2014 05:28:05 +0000 Subject: [PATCH] Fix for Savestate load crash & sound/music volume in The New Zealand Story new pcb --- src/burn/drv/taito/d_tnzs.cpp | 41 ++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/burn/drv/taito/d_tnzs.cpp b/src/burn/drv/taito/d_tnzs.cpp index 8b10e60a7..25b07054b 100644 --- a/src/burn/drv/taito/d_tnzs.cpp +++ b/src/burn/drv/taito/d_tnzs.cpp @@ -810,11 +810,41 @@ UINT8 __fastcall tnzs_cpu2_in(UINT16 port) return 0; } +static INT32 FROM_SAVESTATE = 0; + static void kabukiz_sound_bankswitch(UINT32, UINT32 data) { if (data != 0xff) { tnzs_banks[2] = data; + if (FROM_SAVESTATE) { + ZetOpen(2); + FROM_SAVESTATE = 0; + } + // I don't like this either - but to avoid a crash on Savestate load, it has to be, as + // YM2203_postload() eventually gets to code that writes to a port that is mapped to + // kabukiz_sound_bankswitch() and at this time, the cpu isn't open + // Stack backtrace from crash: + /*Program received signal SIGSEGV, Segmentation fault. + 0x007ffbf3 in ZetMapArea(int, int, int, unsigned char*) () + (gdb) bt + #0 0x007ffbf3 in ZetMapArea(int, int, int, unsigned char*) () + #1 0x005fe384 in kabukiz_sound_bankswitch(unsigned int, unsigned int) () + #2 0x00441e4b in _AYWriteReg (n=, r=, + v=) at src/burn/snd/ay8910.c:240 + #3 0x00441ec3 in AYWriteReg (v=0, r=14, chip=0) at src/burn/snd/ay8910.c:282 + #4 AY8910Write (chip=0, a=1, data=0) at src/burn/snd/ay8910.c:329 + #5 0x00446285 in YM2203_postload () at src/burn/snd/fm.c:2388 + #6 0x007c80a9 in BurnStateMAMEScan(int, int*) () + #7 0x007c80dd in BurnAreaScan () + #8 0x00a0592e in BurnStateDecompress(unsigned char*, int, int) () + #9 0x00a05064 in BurnStateLoadEmbed(_iobuf*, int, int, int (*)()) () + #10 0x00a0515b in BurnStateLoad(wchar_t*, int, int (*)()) () + #11 0x009f7043 in StatedLoad(int) () + #12 0x009e1c7d in OnCommand(HWND__*, int, HWND__*, unsigned int) () + #13 0x009e577d in ScrnProc () + #14 0x7e418734 in USER32!GetDC () from C:\WINDOWS.0\system32\user32.dll */ + ZetMapArea(0x8000, 0xbfff, 0, DrvZ80ROM2 + 0x0000 + 0x4000 * (data & 0x07)); ZetMapArea(0x8000, 0xbfff, 2, DrvZ80ROM2 + 0x0000 + 0x4000 * (data & 0x07)); } @@ -1444,7 +1474,7 @@ static INT32 Type2Init() BurnTimerAttachZet(6000000); BurnYM2203SetAllRoutes(0, 0.30, BURN_SND_ROUTE_BOTH); - if (strncmp(BurnDrvGetTextA(DRV_NAME), "kabukiz", 7) == 0 || strncmp(BurnDrvGetTextA(DRV_NAME), "tnzsb", 5) == 0) { + if (strncmp(BurnDrvGetTextA(DRV_NAME), "kabukiz", 7) == 0 || strncmp(BurnDrvGetTextA(DRV_NAME), "tnzs", 5) == 0) { BurnYM2203SetRoute(0, BURN_SND_YM2203_YM2203_ROUTE, 2.00, BURN_SND_ROUTE_BOTH); BurnYM2203SetRoute(0, BURN_SND_YM2203_AY8910_ROUTE_1, 1.00, BURN_SND_ROUTE_BOTH); BurnYM2203SetRoute(0, BURN_SND_YM2203_AY8910_ROUTE_2, 1.00, BURN_SND_ROUTE_BOTH); @@ -1856,6 +1886,7 @@ static INT32 DrvScan(INT32 nAction,INT32 *pnMin) } if (nAction & ACB_VOLATILE) { + FROM_SAVESTATE = 1; // see notes @ kabukiz_sound_bankswitch() - dink ba.Data = AllRam; ba.nLen = RamEnd - AllRam; ba.szName = "All Ram"; @@ -1863,8 +1894,12 @@ static INT32 DrvScan(INT32 nAction,INT32 *pnMin) ZetScan(nAction); - BurnYM2203Scan(nAction, pnMin); - BurnYM2151Scan(nAction); + if (tnzs_mcu_type() == MCU_NONE_JPOPNICS) { + BurnYM2151Scan(nAction); + } else { + BurnYM2203Scan(nAction, pnMin); + } + DACScan(nAction, pnMin); tnzs_mcu_scan();