ZSM: code style
This commit is contained in:
parent
982678eff3
commit
6b89dec812
|
|
@ -72,8 +72,7 @@ void DivZSM::writeYM(unsigned char a, unsigned char v) {
|
|||
if (a==0x08) {
|
||||
// write keyUPDN messages if channel is active.
|
||||
writeit=(ymMask&(1<<(v&0x07)))>0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// do not suppress global registers
|
||||
writeit=true;
|
||||
}
|
||||
|
|
@ -99,7 +98,7 @@ void DivZSM::writeYM(unsigned char a, unsigned char v) {
|
|||
// Handle the current write if channel is active
|
||||
if (writeit && ((ymState[ym_NEW][a]!=ymState[ym_PREV][a]) || a==0x08)) {
|
||||
// update YM shadow if not the KeyUPDN register.
|
||||
if (a!=0x008) ymState[ym_PREV][a] = ymState[ym_NEW][a];
|
||||
if (a!=8) ymState[ym_PREV][a]=ymState[ym_NEW][a];
|
||||
// if reg=PMD, then change back to real register 0x19
|
||||
if (a==0x1a) a=0x19;
|
||||
ymwrites.push_back(DivRegWrite(a,v));
|
||||
|
|
@ -114,16 +113,18 @@ void DivZSM::writePSG(unsigned char a, unsigned char v) {
|
|||
return;
|
||||
}
|
||||
if (psgState[psg_PREV][a]==v) {
|
||||
if (psgState[psg_NEW][a] != v)
|
||||
if (psgState[psg_NEW][a]!=v) {
|
||||
// NEW value is being reset to the same as PREV value
|
||||
// so it is no longer a new write.
|
||||
numWrites--;
|
||||
}
|
||||
} else {
|
||||
if (psgState[psg_PREV][a] == psgState[psg_NEW][a])
|
||||
if (psgState[psg_PREV][a]==psgState[psg_NEW][a]) {
|
||||
// if this write changes the NEW cached value to something other
|
||||
// than the PREV value, then this is a new write.
|
||||
numWrites++;
|
||||
}
|
||||
}
|
||||
psgState[psg_NEW][a]=v;
|
||||
// mark channel as used in the psgMask if volume is set>0.
|
||||
if ((a%4==2) && (v&0x3f)) psgMask|=(1<<(a>>2));
|
||||
|
|
@ -159,7 +160,9 @@ void DivZSM::setLoopPoint() {
|
|||
if (!(ymMask&(1<<chan))) continue;
|
||||
// clear the state for channels in use so they match the unknown state
|
||||
// of the YM shadow.
|
||||
for (int i=0x20+chan; i<=0xff; i+= 8) ymState[ym_NEW][i] = -1;
|
||||
for (int i=0x20+chan; i<=0xff; i+=8) {
|
||||
ymState[ym_NEW][i]=-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,36 +27,42 @@ constexpr int MASTER_CLOCK_PREC=(sizeof(void*)==8)?8:0;
|
|||
constexpr int MASTER_CLOCK_MASK=(sizeof(void*)==8)?0xff:0;
|
||||
|
||||
SafeWriter* DivEngine::saveZSM(unsigned int zsmrate, bool loop) {
|
||||
|
||||
int VERA=-1;
|
||||
int YM=-1;
|
||||
int IGNORED=0;
|
||||
|
||||
//loop = false;
|
||||
// find indexes for YM and VERA. Ignore other systems.
|
||||
for (int i=0; i<song.systemLen; i++) {
|
||||
switch (song.system[i]) {
|
||||
case DIV_SYSTEM_VERA:
|
||||
if (VERA >= 0) { IGNORED++;break; }
|
||||
if (VERA>=0) {
|
||||
IGNORED++;
|
||||
break;
|
||||
}
|
||||
VERA=i;
|
||||
logD("VERA detected as chip id %d",i);
|
||||
break;
|
||||
case DIV_SYSTEM_YM2151:
|
||||
if (YM >= 0) { IGNORED++;break; }
|
||||
if (YM>=0) {
|
||||
IGNORED++;
|
||||
break;
|
||||
}
|
||||
YM=i;
|
||||
logD("YM detected as chip id %d",i);
|
||||
break;
|
||||
default:
|
||||
IGNORED++;
|
||||
logD("Ignoring chip %d systemID %d",i,song.system[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (VERA<0 && YM<0) {
|
||||
logE("No supported systems for ZSM");
|
||||
return NULL;
|
||||
}
|
||||
if (IGNORED > 0)
|
||||
if (IGNORED>0) {
|
||||
logW("ZSM export ignoring %d unsupported system%c",IGNORED,IGNORED>1?'s':' ');
|
||||
}
|
||||
|
||||
stop();
|
||||
repeatPattern=false;
|
||||
|
|
@ -126,16 +132,17 @@ SafeWriter* DivEngine::saveZSM(unsigned int zsmrate, bool loop) {
|
|||
int i=0;
|
||||
// dump YM writes first
|
||||
if (j==0) {
|
||||
if (YM < 0)
|
||||
if (YM<0) {
|
||||
continue;
|
||||
else
|
||||
} else {
|
||||
i=YM;
|
||||
}
|
||||
}
|
||||
// dump VERA writes second
|
||||
if (j==1) {
|
||||
if (VERA < 0)
|
||||
if (VERA<0) {
|
||||
continue;
|
||||
else {
|
||||
} else {
|
||||
i=VERA;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue