tabs to spaces
This commit is contained in:
parent
98cebf92f2
commit
5e2a247b77
|
@ -110,14 +110,14 @@ void DivZSM::writeYM(unsigned char a, unsigned char v) {
|
||||||
void DivZSM::writePSG(unsigned char a, unsigned char v) {
|
void DivZSM::writePSG(unsigned char a, unsigned char v) {
|
||||||
// TODO: suppress writes to PSG voice that is not audible (volume=0)
|
// TODO: suppress writes to PSG voice that is not audible (volume=0)
|
||||||
if (a >= 64) {
|
if (a >= 64) {
|
||||||
logD ("ZSM: ignoring VERA PSG write a=%02x v=%02x",a,v);
|
logD ("ZSM: ignoring VERA PSG write a=%02x v=%02x",a,v);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(psgState[psg_PREV][a] == v) {
|
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
|
// NEW value is being reset to the same as PREV value
|
||||||
// so it is no longer a new write.
|
// so it is no longer a new write.
|
||||||
numWrites--;
|
numWrites--;
|
||||||
} else {
|
} 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
|
// if this write changes the NEW cached value to something other
|
||||||
|
@ -143,7 +143,7 @@ void DivZSM::setLoopPoint() {
|
||||||
flushTicks(); // flush ticks incase no writes were pending
|
flushTicks(); // flush ticks incase no writes were pending
|
||||||
logI("ZSM: loop at file offset %d bytes",w->tell());
|
logI("ZSM: loop at file offset %d bytes",w->tell());
|
||||||
loopOffset=w->tell();
|
loopOffset=w->tell();
|
||||||
//update the ZSM header's loop offset value
|
// update the ZSM header's loop offset value
|
||||||
w->seek(0x03,SEEK_SET);
|
w->seek(0x03,SEEK_SET);
|
||||||
w->writeS((short)(loopOffset&0xffff));
|
w->writeS((short)(loopOffset&0xffff));
|
||||||
w->writeC((unsigned char)((loopOffset>>16)&0xff));
|
w->writeC((unsigned char)((loopOffset>>16)&0xff));
|
||||||
|
@ -155,7 +155,7 @@ void DivZSM::setLoopPoint() {
|
||||||
// ... and cache (except for unused channels)
|
// ... and cache (except for unused channels)
|
||||||
memset(&ymState[ym_NEW],-1,0x20);
|
memset(&ymState[ym_NEW],-1,0x20);
|
||||||
for (int chan=0; chan<8 ; chan++) {
|
for (int chan=0; chan<8 ; chan++) {
|
||||||
//do not clear state for as-yet-unused channels
|
// do not clear state for as-yet-unused channels
|
||||||
if (!(ymMask & (1<<chan))) continue;
|
if (!(ymMask & (1<<chan))) continue;
|
||||||
// clear the state for channels in use so they match the unknown state
|
// clear the state for channels in use so they match the unknown state
|
||||||
// of the YM shadow.
|
// of the YM shadow.
|
||||||
|
@ -189,11 +189,11 @@ void DivZSM::flushWrites() {
|
||||||
for (DivRegWrite& write: ymwrites) {
|
for (DivRegWrite& write: ymwrites) {
|
||||||
if (n%ZSM_YM_MAX_WRITES == 0) {
|
if (n%ZSM_YM_MAX_WRITES == 0) {
|
||||||
if(ymwrites.size()-n > ZSM_YM_MAX_WRITES) {
|
if(ymwrites.size()-n > ZSM_YM_MAX_WRITES) {
|
||||||
w->writeC((unsigned char)(ZSM_YM_CMD+ZSM_YM_MAX_WRITES));
|
w->writeC((unsigned char)(ZSM_YM_CMD+ZSM_YM_MAX_WRITES));
|
||||||
logD("ZSM: YM-write: %d (%02x) [max]",ZSM_YM_MAX_WRITES,ZSM_YM_MAX_WRITES+ZSM_YM_CMD);
|
logD("ZSM: YM-write: %d (%02x) [max]",ZSM_YM_MAX_WRITES,ZSM_YM_MAX_WRITES+ZSM_YM_CMD);
|
||||||
} else {
|
} else {
|
||||||
w->writeC((unsigned char)(ZSM_YM_CMD+ymwrites.size()-n));
|
w->writeC((unsigned char)(ZSM_YM_CMD+ymwrites.size()-n));
|
||||||
logD("ZSM: YM-write: %d (%02x)",ymwrites.size()-n,ZSM_YM_CMD+ymwrites.size()-n);
|
logD("ZSM: YM-write: %d (%02x)",ymwrites.size()-n,ZSM_YM_CMD+ymwrites.size()-n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
n++;
|
n++;
|
||||||
|
@ -206,13 +206,13 @@ void DivZSM::flushWrites() {
|
||||||
|
|
||||||
void DivZSM::flushTicks() {
|
void DivZSM::flushTicks() {
|
||||||
while (ticks > ZSM_DELAY_MAX) {
|
while (ticks > ZSM_DELAY_MAX) {
|
||||||
logD("ZSM: write delay %d (max)",ZSM_DELAY_MAX);
|
logD("ZSM: write delay %d (max)",ZSM_DELAY_MAX);
|
||||||
w->writeC((unsigned char)(ZSM_DELAY_CMD+ZSM_DELAY_MAX));
|
w->writeC((unsigned char)(ZSM_DELAY_CMD+ZSM_DELAY_MAX));
|
||||||
ticks -= ZSM_DELAY_MAX;
|
ticks -= ZSM_DELAY_MAX;
|
||||||
}
|
}
|
||||||
if (ticks>0) {
|
if (ticks>0) {
|
||||||
logD("ZSM: write delay %d",ticks);
|
logD("ZSM: write delay %d",ticks);
|
||||||
w->writeC(ZSM_DELAY_CMD+ticks);
|
w->writeC(ZSM_DELAY_CMD+ticks);
|
||||||
}
|
}
|
||||||
ticks=0;
|
ticks=0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,27 +38,27 @@ enum PSG_STATE { psg_PREV, psg_NEW, psg_STATES };
|
||||||
|
|
||||||
class DivZSM {
|
class DivZSM {
|
||||||
private:
|
private:
|
||||||
SafeWriter* w;
|
SafeWriter* w;
|
||||||
int ymState[ym_STATES][256];
|
int ymState[ym_STATES][256];
|
||||||
int psgState[psg_STATES][64];
|
int psgState[psg_STATES][64];
|
||||||
std::vector<DivRegWrite> ymwrites;
|
std::vector<DivRegWrite> ymwrites;
|
||||||
int loopOffset;
|
int loopOffset;
|
||||||
int numWrites;
|
int numWrites;
|
||||||
int ticks;
|
int ticks;
|
||||||
int tickRate;
|
int tickRate;
|
||||||
int ymMask = 0;
|
int ymMask = 0;
|
||||||
int psgMask = 0;
|
int psgMask = 0;
|
||||||
public:
|
public:
|
||||||
DivZSM();
|
DivZSM();
|
||||||
~DivZSM();
|
~DivZSM();
|
||||||
void init(unsigned int rate = 60);
|
void init(unsigned int rate = 60);
|
||||||
int getoffset();
|
int getoffset();
|
||||||
void writeYM(unsigned char a, unsigned char v);
|
void writeYM(unsigned char a, unsigned char v);
|
||||||
void writePSG(unsigned char a, unsigned char v);
|
void writePSG(unsigned char a, unsigned char v);
|
||||||
void writePCM(unsigned char a, unsigned char v);
|
void writePCM(unsigned char a, unsigned char v);
|
||||||
void tick(int numticks = 1);
|
void tick(int numticks = 1);
|
||||||
void setLoopPoint();
|
void setLoopPoint();
|
||||||
SafeWriter* finish();
|
SafeWriter* finish();
|
||||||
private:
|
private:
|
||||||
void flushWrites();
|
void flushWrites();
|
||||||
void flushTicks();
|
void flushTicks();
|
||||||
|
|
|
@ -35,25 +35,25 @@ SafeWriter* DivEngine::saveZSM(unsigned int zsmrate, bool loop) {
|
||||||
//loop = false;
|
//loop = false;
|
||||||
// find indexes for YM and VERA. Ignore other systems.
|
// find indexes for YM and VERA. Ignore other systems.
|
||||||
for (int i=0; i<song.systemLen; i++) {
|
for (int i=0; i<song.systemLen; i++) {
|
||||||
switch (song.system[i]) {
|
switch (song.system[i]) {
|
||||||
case DIV_SYSTEM_VERA:
|
case DIV_SYSTEM_VERA:
|
||||||
if (VERA >= 0) { IGNORED++;break; }
|
if (VERA >= 0) { IGNORED++;break; }
|
||||||
VERA = i;
|
VERA = i;
|
||||||
logD("VERA detected as chip id %d",i);
|
logD("VERA detected as chip id %d",i);
|
||||||
break;
|
break;
|
||||||
case DIV_SYSTEM_YM2151:
|
case DIV_SYSTEM_YM2151:
|
||||||
if (YM >= 0) { IGNORED++;break; }
|
if (YM >= 0) { IGNORED++;break; }
|
||||||
YM = i;
|
YM = i;
|
||||||
logD("YM detected as chip id %d",i);
|
logD("YM detected as chip id %d",i);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
IGNORED++;
|
IGNORED++;
|
||||||
logD("Ignoring chip %d systemID %d",i,song.system[i]);
|
logD("Ignoring chip %d systemID %d",i,song.system[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (VERA < 0 && YM < 0) {
|
if (VERA < 0 && YM < 0) {
|
||||||
logE("No supported systems for ZSM");
|
logE("No supported systems for ZSM");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (IGNORED > 0)
|
if (IGNORED > 0)
|
||||||
logW("ZSM export ignoring %d unsupported system%c",IGNORED,IGNORED>1?'s':' ');
|
logW("ZSM export ignoring %d unsupported system%c",IGNORED,IGNORED>1?'s':' ');
|
||||||
|
@ -121,22 +121,22 @@ SafeWriter* DivEngine::saveZSM(unsigned int zsmrate, bool loop) {
|
||||||
}
|
}
|
||||||
// get register dumps
|
// get register dumps
|
||||||
for (int j=0; j<2; j++) {
|
for (int j=0; j<2; j++) {
|
||||||
int i=0;
|
int i=0;
|
||||||
// dump YM writes first
|
// dump YM writes first
|
||||||
if (j==0) {
|
if (j==0) {
|
||||||
if (YM < 0)
|
if (YM < 0)
|
||||||
continue;
|
continue;
|
||||||
else
|
else
|
||||||
i=YM;
|
i=YM;
|
||||||
}
|
}
|
||||||
// dump VERA writes second
|
// dump VERA writes second
|
||||||
if (j==1) {
|
if (j==1) {
|
||||||
if (VERA < 0)
|
if (VERA < 0)
|
||||||
continue;
|
continue;
|
||||||
else {
|
else {
|
||||||
i=VERA;
|
i=VERA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::vector<DivRegWrite>& writes=disCont[i].dispatch->getRegisterWrites();
|
std::vector<DivRegWrite>& writes=disCont[i].dispatch->getRegisterWrites();
|
||||||
if (writes.size() > 0)
|
if (writes.size() > 0)
|
||||||
logD("zsmOps: Writing %d messages to chip %d",writes.size(), i);
|
logD("zsmOps: Writing %d messages to chip %d",writes.size(), i);
|
||||||
|
|
Loading…
Reference in a new issue