Merge branch 'master' of https://github.com/tildearrow/furnace into es5506_alt

This commit is contained in:
cam900 2023-01-16 10:07:13 +09:00
commit 46865b3adb
29 changed files with 301 additions and 105 deletions

View file

@ -24,7 +24,7 @@
constexpr int MASTER_CLOCK_PREC=(sizeof(void*)==8)?8:0;
void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write, int streamOff, double* loopTimer, double* loopFreq, int* loopSample, bool* sampleDir, bool isSecond, bool directStream) {
void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write, int streamOff, double* loopTimer, double* loopFreq, int* loopSample, bool* sampleDir, bool isSecond, int* pendingFreq, int* playingSample, bool directStream) {
unsigned char baseAddr1=isSecond?0xa0:0x50;
unsigned char baseAddr2=isSecond?0x80:0;
unsigned short baseAddr2S=isSecond?0x8000:0;
@ -575,14 +575,19 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
switch (write.addr&0xff) {
case 0: // play sample
if (write.val<song.sampleLen) {
DivSample* sample=song.sample[write.val];
w->writeC(0x95);
w->writeC(streamID);
w->writeS(write.val); // sample number
w->writeC((sample->getLoopStartPosition(DIV_SAMPLE_DEPTH_8BIT)==0)|(sampleDir[streamID]?0x10:0)); // flags
if (sample->isLoopable() && !sampleDir[streamID]) {
loopTimer[streamID]=sample->length8;
loopSample[streamID]=write.val;
if (playingSample[streamID]!=write.val) {
pendingFreq[streamID]=write.val;
} else {
DivSample* sample=song.sample[write.val];
w->writeC(0x95);
w->writeC(streamID);
w->writeS(write.val); // sample number
w->writeC((sample->getLoopStartPosition(DIV_SAMPLE_DEPTH_8BIT)==0)|(sampleDir[streamID]?0x10:0)); // flags
if (sample->isLoopable() && !sampleDir[streamID]) {
loopTimer[streamID]=sample->length8;
loopSample[streamID]=write.val;
}
playingSample[streamID]=write.val;
}
}
break;
@ -591,11 +596,26 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
w->writeC(streamID);
w->writeI(write.val);
loopFreq[streamID]=write.val;
if (pendingFreq[streamID]!=-1) {
DivSample* sample=song.sample[pendingFreq[streamID]];
w->writeC(0x95);
w->writeC(streamID);
w->writeS(pendingFreq[streamID]); // sample number
w->writeC((sample->getLoopStartPosition(DIV_SAMPLE_DEPTH_8BIT)==0)|(sampleDir[streamID]?0x10:0)); // flags
if (sample->isLoopable() && !sampleDir[streamID]) {
loopTimer[streamID]=sample->length8;
loopSample[streamID]=pendingFreq[streamID];
}
playingSample[streamID]=pendingFreq[streamID];
pendingFreq[streamID]=-1;
}
break;
case 2: // stop sample
w->writeC(0x94);
w->writeC(streamID);
loopSample[streamID]=-1;
playingSample[streamID]=-1;
pendingFreq[streamID]=-1;
break;
case 3: // set sample direction
sampleDir[streamID]=write.val;
@ -902,16 +922,20 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
}
#define CHIP_VOL(_id,_mult) { \
double _vol=fabs((float)song.systemVol[i])*4.0*_mult; \
double _vol=fabs((float)song.systemVol[i])*256.0*_mult; \
if (_vol<0.0) _vol=0.0; \
if (_vol>32767.0) _vol=32767.0; \
chipVolSum+=(unsigned int)(_vol/_mult); \
chipAccounting++; \
chipVol.push_back((_id)|(0x80000000)|(((unsigned int)_vol)<<16)); \
}
#define CHIP_VOL_SECOND(_id,_mult) { \
double _vol=fabs((float)song.systemVol[i])*4.0*_mult; \
double _vol=fabs((float)song.systemVol[i])*256.0*_mult; \
if (_vol<0.0) _vol=0.0; \
if (_vol>32767.0) _vol=32767.0; \
chipVolSum+=(unsigned int)(_vol/_mult); \
chipAccounting++; \
chipVol.push_back((_id)|(0x80000100)|(((unsigned int)_vol)<<16)); \
}
@ -996,6 +1020,8 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
int hasLynx=0;
int howManyChips=0;
int chipVolSum=0;
int chipAccounting=0;
int loopPos=-1;
int loopTick=-1;
@ -1018,7 +1044,9 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
double loopFreq[DIV_MAX_CHANS];
int loopSample[DIV_MAX_CHANS];
bool sampleDir[DIV_MAX_CHANS];
std::vector<unsigned int> chipVol;
int pendingFreq[DIV_MAX_CHANS];
int playingSample[DIV_MAX_CHANS];
std::vector<unsigned int> chipVol;
std::vector<DivDelayedWrite> delayedWrites[DIV_MAX_CHIPS];
std::vector<std::pair<int,DivDelayedWrite>> sortedWrites;
@ -1026,6 +1054,8 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
loopTimer[i]=0;
loopFreq[i]=0;
loopSample[i]=-1;
pendingFreq[i]=-1;
playingSample[i]=-1;
sampleDir[i]=false;
}
@ -1056,7 +1086,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_SMS:
if (!hasSN) {
hasSN=disCont[i].dispatch->chipClock;
CHIP_VOL(0,1.0);
CHIP_VOL(0,2.0);
willExport[i]=true;
switch (song.systemFlags[i].getInt("chipType",0)) {
case 1: // real SN
@ -1075,7 +1105,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
} else if (!(hasSN&0x40000000)) {
isSecond[i]=true;
willExport[i]=true;
CHIP_VOL_SECOND(0,1.0);
CHIP_VOL_SECOND(0,2.0);
hasSN|=0x40000000;
howManyChips++;
}
@ -1083,9 +1113,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_GB:
if (!hasGB) {
hasGB=disCont[i].dispatch->chipClock;
CHIP_VOL(19,0.75);
willExport[i]=true;
} else if (!(hasGB&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(19,0.75);
willExport[i]=true;
hasGB|=0x40000000;
howManyChips++;
@ -1094,10 +1126,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_PCE:
if (!hasPCE) {
hasPCE=disCont[i].dispatch->chipClock;
CHIP_VOL(27,0.98);
willExport[i]=true;
writePCESamples=true;
} else if (!(hasPCE&0x40000000)) {
isSecond[i]=true;
CHIP_VOL(27,0.98);
willExport[i]=true;
hasPCE|=0x40000000;
howManyChips++;
@ -1106,10 +1140,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_NES:
if (!hasNES) {
hasNES=disCont[i].dispatch->chipClock;
CHIP_VOL(20,1.7);
willExport[i]=true;
writeNESSamples=true;
} else if (!(hasNES&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(20,1.7);
willExport[i]=true;
hasNES|=0x40000000;
howManyChips++;
@ -1119,10 +1155,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_SEGAPCM_COMPAT:
if (!hasSegaPCM) {
hasSegaPCM=4000000;
CHIP_VOL(4,0.67);
willExport[i]=true;
writeSegaPCM=1;
} else if (!(hasSegaPCM&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(4,0.67);
willExport[i]=true;
writeSegaPCM=2;
hasSegaPCM|=0x40000000;
@ -1132,10 +1170,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_X1_010:
if (!hasX1) {
hasX1=disCont[i].dispatch->chipClock;
CHIP_VOL(38,0.5);
willExport[i]=true;
writeX1010[0]=disCont[i].dispatch;
} else if (!(hasX1&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(38,0.5);
willExport[i]=true;
writeX1010[1]=disCont[i].dispatch;
hasX1|=0x40000000;
@ -1150,10 +1190,14 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_YM2610B_EXT:
if (!hasOPNB) {
hasOPNB=disCont[i].dispatch->chipClock;
CHIP_VOL(8,1.0);
CHIP_VOL(0x88,1.25);
willExport[i]=true;
writeADPCM_OPNB[0]=disCont[i].dispatch;
} else if (!(hasOPNB&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(8,1.0);
CHIP_VOL_SECOND(0x88,1.25);
willExport[i]=true;
writeADPCM_OPNB[1]=disCont[i].dispatch;
hasOPNB|=0x40000000;
@ -1198,9 +1242,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
if (hasStereo && song.systemFlags[i].getBool("stereo",false)) {
ayFlags|=0x80;
}
CHIP_VOL(18,1.0);
willExport[i]=true;
} else if (!(hasAY&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(18,1.0);
willExport[i]=true;
hasAY|=0x40000000;
howManyChips++;
@ -1210,9 +1256,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_SAA1099:
if (!hasSAA) {
hasSAA=disCont[i].dispatch->chipClock;
CHIP_VOL(35,1.0);
willExport[i]=true;
} else if (!(hasSAA&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(35,1.0);
willExport[i]=true;
hasSAA|=0x40000000;
howManyChips++;
@ -1224,10 +1272,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_YM2612_DUALPCM_EXT:
if (!hasOPN2) {
hasOPN2=disCont[i].dispatch->chipClock;
CHIP_VOL(2,0.8);
willExport[i]=true;
writeDACSamples=true;
} else if (!(hasOPN2&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(2,0.8);
willExport[i]=true;
hasOPN2|=0x40000000;
howManyChips++;
@ -1236,9 +1286,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_YM2151:
if (!hasOPM) {
hasOPM=disCont[i].dispatch->chipClock;
CHIP_VOL(3,1.0);
willExport[i]=true;
} else if (!(hasOPM&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(3,1.0);
willExport[i]=true;
hasOPM|=0x40000000;
howManyChips++;
@ -1249,10 +1301,14 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
if (!hasOPN) {
hasOPN=disCont[i].dispatch->chipClock;
willExport[i]=true;
CHIP_VOL(6,1.0);
CHIP_VOL(0x86,1.7);
writeDACSamples=true;
} else if (!(hasOPN&0x40000000)) {
isSecond[i]=true;
willExport[i]=true;
CHIP_VOL_SECOND(6,1.0);
CHIP_VOL_SECOND(0x86,1.7);
hasOPN|=0x40000000;
howManyChips++;
}
@ -1261,10 +1317,14 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_YM2608_EXT:
if (!hasOPNA) {
hasOPNA=disCont[i].dispatch->chipClock;
CHIP_VOL(7,1.0);
CHIP_VOL(0x87,1.3);
willExport[i]=true;
writeADPCM_OPNA[0]=disCont[i].dispatch;
} else if (!(hasOPNA&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(7,1.0);
CHIP_VOL_SECOND(0x87,1.3);
willExport[i]=true;
writeADPCM_OPNA[1]=disCont[i].dispatch;
hasOPNA|=0x40000000;
@ -1276,9 +1336,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_VRC7:
if (!hasOPLL) {
hasOPLL=disCont[i].dispatch->chipClock;
CHIP_VOL(1,1.6);
willExport[i]=true;
} else if (!(hasOPLL&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(1,1.6);
willExport[i]=true;
hasOPLL|=0x40000000;
howManyChips++;
@ -1301,9 +1363,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_POKEY:
if (!hasPOKEY) {
hasPOKEY=disCont[i].dispatch->chipClock;
CHIP_VOL(30,0.8);
willExport[i]=true;
} else if (!(hasPOKEY&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(30,0.8);
willExport[i]=true;
hasPOKEY|=0x40000000;
howManyChips++;
@ -1326,10 +1390,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
// However I think it it not necessary because old VGM players will still
// not be able to handle the 64kb sample bank trick
hasQSound=disCont[i].dispatch->chipClock;
CHIP_VOL(31,1.0);
willExport[i]=true;
writeQSound[0]=disCont[i].dispatch;
} else if (!(hasQSound&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(31,1.0);
willExport[i]=false;
writeQSound[1]=disCont[i].dispatch;
addWarning("dual QSound is not supported by the VGM format");
@ -1338,6 +1404,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_SWAN:
if (!hasSwan) {
hasSwan=disCont[i].dispatch->chipClock;
CHIP_VOL(33,1.0);
willExport[i]=true;
// funny enough, VGM doesn't have support for WSC's sound DMA by design
// so DAC stream it goes
@ -1345,6 +1412,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
writeDACSamples=true;
} else if (!(hasSwan&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(33,1.0);
willExport[i]=true;
hasSwan|=0x40000000;
howManyChips++;
@ -1367,9 +1435,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_VBOY:
if (!hasVSU) {
hasVSU=disCont[i].dispatch->chipClock;
CHIP_VOL(34,0.72);
willExport[i]=true;
} else if (!(hasVSU&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(34,0.72);
willExport[i]=true;
hasVSU|=0x40000000;
howManyChips++;
@ -1379,9 +1449,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_OPL_DRUMS:
if (!hasOPL) {
hasOPL=disCont[i].dispatch->chipClock;
CHIP_VOL(9,1.0);
willExport[i]=true;
} else if (!(hasOPL&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(9,1.0);
willExport[i]=true;
hasOPL|=0x40000000;
howManyChips++;
@ -1391,10 +1463,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_Y8950_DRUMS:
if (!hasY8950) {
hasY8950=disCont[i].dispatch->chipClock;
CHIP_VOL(11,1.0);
willExport[i]=true;
writeADPCM_Y8950[0]=disCont[i].dispatch;
} else if (!(hasY8950&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(11,1.0);
willExport[i]=true;
writeADPCM_Y8950[1]=disCont[i].dispatch;
hasY8950|=0x40000000;
@ -1405,9 +1479,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_OPL2_DRUMS:
if (!hasOPL2) {
hasOPL2=disCont[i].dispatch->chipClock;
CHIP_VOL(10,1.0);
willExport[i]=true;
} else if (!(hasOPL2&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(10,1.0);
willExport[i]=true;
hasOPL2|=0x40000000;
howManyChips++;
@ -1417,9 +1493,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_OPL3_DRUMS:
if (!hasOPL3) {
hasOPL3=disCont[i].dispatch->chipClock;
CHIP_VOL(12,1.0);
willExport[i]=true;
} else if (!(hasOPL3&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(12,1.0);
willExport[i]=true;
hasOPL3|=0x40000000;
howManyChips++;
@ -1432,9 +1510,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
if (song.system[i]==DIV_SYSTEM_SCC_PLUS) {
hasK051649|=0x80000000;
}
CHIP_VOL(25,1.0);
willExport[i]=true;
} else if (!(hasK051649&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(25,1.0);
willExport[i]=true;
hasK051649|=0x40000000;
if (song.system[i]==DIV_SYSTEM_SCC_PLUS) {
@ -1446,10 +1526,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_YMZ280B:
if (!hasZ280) {
hasZ280=disCont[i].dispatch->chipClock;
CHIP_VOL(15,0.72);
willExport[i]=true;
writeZ280[0]=disCont[i].dispatch;
} else if (!(hasZ280&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(15,0.72);
willExport[i]=true;
writeZ280[1]=disCont[i].dispatch;
hasZ280|=0x40000000;
@ -1465,11 +1547,13 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
if (!hasRFC1) {
hasRFC1=disCont[i].dispatch->chipClock;
isSecond[i]=true;
CHIP_VOL(16,1.6);
willExport[i]=true;
writeRF5C68[1]=disCont[i].dispatch;
}
} else if (!hasRFC) {
hasRFC=disCont[i].dispatch->chipClock;
CHIP_VOL(5,1.6);
willExport[i]=true;
writeRF5C68[0]=disCont[i].dispatch;
}
@ -1477,10 +1561,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_MSM6295:
if (!hasOKIM6295) {
hasOKIM6295=disCont[i].dispatch->chipClock;
CHIP_VOL(24,1.0);
willExport[i]=true;
writeMSM6295[0]=disCont[i].dispatch;
} else if (!(hasOKIM6295&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(24,1.0);
willExport[i]=true;
writeMSM6295[1]=disCont[i].dispatch;
hasOKIM6295|=0x40000000;
@ -1490,10 +1576,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_GA20:
if (!hasGA20) {
hasGA20=disCont[i].dispatch->chipClock;
CHIP_VOL(40,0.4);
willExport[i]=true;
writeGA20[0]=disCont[i].dispatch;
} else if (!(hasGA20&0x40000000)) {
isSecond[i]=true;
CHIP_VOL_SECOND(40,0.4);
willExport[i]=true;
writeGA20[1]=disCont[i].dispatch;
hasGA20|=0x40000000;
@ -1503,7 +1591,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
case DIV_SYSTEM_T6W28:
if (!hasSN) {
hasSN=0xc0000000|disCont[i].dispatch->chipClock;
CHIP_VOL(0,1.0);
CHIP_VOL(0,2.0);
snNoiseConfig=3;
snNoiseSize=15;
willExport[i]=true;
@ -1578,8 +1666,9 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
w->writeC(0); // OPN
w->writeC(0); // OPNA
}
if (version>=0x160) {
int calcVolume=32.0*(log(song.masterVol)/log(2.0));
if (version>=0x160) { // global volume
double abnormalVol=song.masterVol*(double)chipVolSum/(256.0*MAX(1,chipAccounting));
int calcVolume=32.0*(log(abnormalVol)/log(2.0));
if (calcVolume<-63) calcVolume=-63;
if (calcVolume>192) calcVolume=192;
w->writeC(calcVolume&0xff); // volume
@ -2058,7 +2147,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
for (int i=0; i<song.systemLen; i++) {
std::vector<DivRegWrite>& writes=disCont[i].dispatch->getRegisterWrites();
for (DivRegWrite& j: writes) {
performVGMWrite(w,song.system[i],j,streamIDs[i],loopTimer,loopFreq,loopSample,sampleDir,isSecond[i],directStream);
performVGMWrite(w,song.system[i],j,streamIDs[i],loopTimer,loopFreq,loopSample,sampleDir,isSecond[i],pendingFreq,playingSample,directStream);
writeCount++;
}
writes.clear();
@ -2098,7 +2187,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
lastOne=i.second.time;
}
// write write
performVGMWrite(w,song.system[i.first],i.second.write,streamIDs[i.first],loopTimer,loopFreq,loopSample,sampleDir,isSecond[i.first],directStream);
performVGMWrite(w,song.system[i.first],i.second.write,streamIDs[i.first],loopTimer,loopFreq,loopSample,sampleDir,isSecond[i.first],pendingFreq,playingSample,directStream);
writeCount++;
}
sortedWrites.clear();
@ -2231,7 +2320,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
w->writeI(0);
} else {
w->writeI(loopPos-0x1c);
w->writeI(tickCount-loopTick-1);
w->writeI(tickCount-loopTick);
}
} else {
w->writeI(0);