From 285d81c716d5e157f1e4f82403797ba7b358552c Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 16 Oct 2022 01:27:39 -0500 Subject: [PATCH] T6W28: VGM export --- src/engine/sysDef.cpp | 2 +- src/engine/vgmOps.cpp | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/engine/sysDef.cpp b/src/engine/sysDef.cpp index 404f64057..63ff23eea 100644 --- a/src/engine/sysDef.cpp +++ b/src/engine/sysDef.cpp @@ -1657,7 +1657,7 @@ void DivEngine::registerSystems() { sysDefs[DIV_SYSTEM_T6W28]=new DivSysDef( // 0x0a = wild guess. it may as well be 0x83 - "T6W28", NULL, 0xbf, 0x0a, 4, false, true, 0, false, 0, + "T6W28", NULL, 0xbf, 0x0a, 4, false, true, 0x160, false, 0, "an SN76489 derivative used in Neo Geo Pocket, has independent stereo volume and noise channel frequency.", {"Square 1", "Square 2", "Square 3", "Noise"}, {"S1", "S2", "S3", "NO"}, diff --git a/src/engine/vgmOps.cpp b/src/engine/vgmOps.cpp index 815436fd6..c7d376a05 100644 --- a/src/engine/vgmOps.cpp +++ b/src/engine/vgmOps.cpp @@ -79,6 +79,14 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write w->writeC(0x90|(i<<5)|15); } break; + case DIV_SYSTEM_T6W28: + for (int i=0; i<4; i++) { + w->writeC(0x30); + w->writeC(0x90|(i<<5)|15); + w->writeC(0x50); + w->writeC(0x90|(i<<5)|15); + } + break; case DIV_SYSTEM_GB: // square 1 w->writeC(0xb3); @@ -497,6 +505,12 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write w->writeC(baseAddr2|12); w->writeC(1); break; + case DIV_SYSTEM_VBOY: + // isn't it amazing when a chip has a built-in reset command? + w->writeC(0xc7); + w->writeS_BE(baseAddr2S|(0x580>>2)); + w->writeC(0xff); + break; default: break; } @@ -559,6 +573,14 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write w->writeC(smsAddr); w->writeC(write.val); break; + case DIV_SYSTEM_T6W28: + if (write.addr) { + w->writeC(0x30); + } else { + w->writeC(0x50); + } + w->writeC(write.val); + break; case DIV_SYSTEM_GB: w->writeC(0xb3); w->writeC(baseAddr2|((write.addr-16)&0xff)); @@ -808,14 +830,14 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write } #define CHIP_VOL(_id,_mult) { \ - double _vol=fabs(song.systemVol[i])*4.0*_mult; \ + double _vol=fabs((float)song.systemVol[i])*4.0*_mult; \ if (_vol<0.0) _vol=0.0; \ if (_vol>32767.0) _vol=32767.0; \ chipVol.push_back((_id)|(0x80000000)|(((unsigned int)_vol)<<16)); \ } #define CHIP_VOL_SECOND(_id,_mult) { \ - double _vol=fabs(song.systemVol[i])*4.0*_mult; \ + double _vol=fabs((float)song.systemVol[i])*4.0*_mult; \ if (_vol<0.0) _vol=0.0; \ if (_vol>32767.0) _vol=32767.0; \ chipVol.push_back((_id)|(0x80000100)|(((unsigned int)_vol)<<16)); \ @@ -1362,6 +1384,13 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p howManyChips++; } break; + case DIV_SYSTEM_T6W28: + if (!hasSN) { + hasSN=0xc0000000|disCont[i].dispatch->chipClock; + CHIP_VOL(0,1.0); + willExport[i]=true; + } + break; default: break; }