move some of the commands
$d0-$df are now $e0-$ef $e0-$ef are now $f0-$ff $f0-$ff are now $d0-$df
This commit is contained in:
parent
674b5e31c7
commit
f796dbee38
|
@ -94,32 +94,32 @@ hex | description
|
|||
ce | pan slide (c)
|
||||
cf | panning (bb) // left, right
|
||||
----|------------------------------------
|
||||
d0 | speed dial command 0
|
||||
d1 | speed dial command 1
|
||||
.. | ...
|
||||
df | speed dial command 15
|
||||
d0 | UNUSED - placeholder used during optimization passes (3-byte nonce follows)
|
||||
d1 | no operation
|
||||
d2 | UNUSED
|
||||
d3 | loop (negative offset and count follow... both are 8-bit)
|
||||
d4 | UNUSED - call symbol (32-bit index follows; only used internally)
|
||||
d5 | call sub-block (32-bit address follows)
|
||||
d6 | note off + wait one tick
|
||||
d7 | full command (command and data follows)
|
||||
d8 | call sub-block (16-bit address follows)
|
||||
d9 | return from sub-block
|
||||
da | jump (address follows)
|
||||
db | set tick rate (4 bytes)
|
||||
dc | wait (16-bit)
|
||||
dd | wait (8-bit)
|
||||
de | wait one tick
|
||||
df | stop
|
||||
----|------------------------------------
|
||||
e0 | preset delay 0
|
||||
e1 | preset delay 1
|
||||
e0 | speed dial command 0
|
||||
e1 | speed dial command 1
|
||||
.. | ...
|
||||
ef | preset delay 15
|
||||
ef | speed dial command 15
|
||||
----|------------------------------------
|
||||
f0 | UNUSED - placeholder used during optimization passes (3-byte nonce follows)
|
||||
f1 | no operation
|
||||
f2 | UNUSED
|
||||
f3 | loop (negative offset and count follow... both are 8-bit)
|
||||
f4 | UNUSED - call symbol (32-bit index follows; only used internally)
|
||||
f5 | call sub-block (32-bit address follows)
|
||||
f6 | note off + wait one tick
|
||||
f7 | full command (command and data follows)
|
||||
f8 | call sub-block (16-bit address follows)
|
||||
f9 | return from sub-block
|
||||
fa | jump (address follows)
|
||||
fb | set tick rate (4 bytes)
|
||||
fc | wait (16-bit)
|
||||
fd | wait (8-bit)
|
||||
fe | wait one tick
|
||||
ff | stop
|
||||
f0 | preset delay 0
|
||||
f1 | preset delay 1
|
||||
.. | ...
|
||||
ff | preset delay 15
|
||||
```
|
||||
|
||||
## full commands
|
||||
|
|
|
@ -110,10 +110,10 @@ bool DivCSPlayer::tick() {
|
|||
e->dispatchCmd(DivCommand(DIV_CMD_NOTE_ON,i,(int)next-60));
|
||||
chan[i].note=(int)next-60;
|
||||
chan[i].vibratoPos=0;
|
||||
} else if (next>=0xd0 && next<=0xdf) {
|
||||
} else if (next>=0xe0 && next<=0xef) {
|
||||
command=fastCmds[next&15];
|
||||
bAccessTS[fastCmdsOff+(next&15)]=curTick;
|
||||
} else if (next>=0xe0 && next<=0xef) { // preset delay
|
||||
} else if (next>=0xf0) { // preset delay
|
||||
chan[i].waitTicks=fastDelays[next&15];
|
||||
chan[i].lastWaitLen=chan[i].waitTicks;
|
||||
bAccessTS[fastDelaysOff+(next&15)]=curTick;
|
||||
|
@ -203,21 +203,22 @@ bool DivCSPlayer::tick() {
|
|||
e->dispatchCmd(DivCommand(DIV_CMD_PANNING,i,panL,panR));
|
||||
break;
|
||||
}
|
||||
case 0xd0: case 0xd1: case 0xd2: case 0xd3:
|
||||
case 0xd4: case 0xd5: case 0xd6: case 0xd7:
|
||||
case 0xd8: case 0xd9: case 0xda: case 0xdb:
|
||||
case 0xdc: case 0xdd: case 0xde: case 0xdf:
|
||||
command=fastCmds[next-0xd0];
|
||||
case 0xe0: case 0xe1: case 0xe2: case 0xe3:
|
||||
case 0xe4: case 0xe5: case 0xe6: case 0xe7:
|
||||
case 0xe8: case 0xe9: case 0xea: case 0xeb:
|
||||
case 0xec: case 0xed: case 0xee: case 0xef:
|
||||
// TODO: remove as it has no effect
|
||||
command=fastCmds[next&15];
|
||||
|
||||
break;
|
||||
case 0xf0: // placeholder
|
||||
case 0xd0: // placeholder
|
||||
stream.readC();
|
||||
stream.readC();
|
||||
stream.readC();
|
||||
break;
|
||||
case 0xf1: // nop
|
||||
case 0xd1: // nop
|
||||
break;
|
||||
case 0xf3: { // loop
|
||||
case 0xd3: { // loop
|
||||
unsigned char loopOff=stream.readC();
|
||||
if (chan[i].loopCount>0) {
|
||||
stream.readC();
|
||||
|
@ -234,15 +235,15 @@ bool DivCSPlayer::tick() {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 0xf6: // note off + wait 1
|
||||
case 0xd6: // note off + wait 1
|
||||
e->dispatchCmd(DivCommand(DIV_CMD_NOTE_OFF,i));
|
||||
chan[i].waitTicks=1;
|
||||
chan[i].lastWaitLen=chan[i].waitTicks;
|
||||
break;
|
||||
case 0xf7:
|
||||
case 0xd7:
|
||||
command=stream.readC();
|
||||
break;
|
||||
case 0xf8: {
|
||||
case 0xd8: {
|
||||
unsigned int callAddr=bigEndian?((unsigned short)stream.readS_BE()):((unsigned short)stream.readS());
|
||||
chan[i].readPos=stream.tell();
|
||||
if (!chan[i].doCall(callAddr)) {
|
||||
|
@ -252,7 +253,7 @@ bool DivCSPlayer::tick() {
|
|||
mustTell=false;
|
||||
break;
|
||||
}
|
||||
case 0xf5: {
|
||||
case 0xd5: {
|
||||
unsigned int callAddr=bigEndian?stream.readI_BE():stream.readI();
|
||||
chan[i].readPos=stream.tell();
|
||||
if (!chan[i].doCall(callAddr)) {
|
||||
|
@ -262,12 +263,12 @@ bool DivCSPlayer::tick() {
|
|||
mustTell=false;
|
||||
break;
|
||||
}
|
||||
case 0xf4: {
|
||||
case 0xd4: {
|
||||
logE("%d: (callsym) not supported here!",i);
|
||||
chan[i].readPos=0;
|
||||
break;
|
||||
}
|
||||
case 0xf9:
|
||||
case 0xd9:
|
||||
if (!chan[i].callStackPos) {
|
||||
logE("%d: (ret) stack error!",i);
|
||||
chan[i].readPos=0;
|
||||
|
@ -276,27 +277,27 @@ bool DivCSPlayer::tick() {
|
|||
chan[i].readPos=chan[i].callStack[--chan[i].callStackPos];
|
||||
mustTell=false;
|
||||
break;
|
||||
case 0xfa:
|
||||
case 0xda:
|
||||
chan[i].readPos=bigEndian?stream.readI_BE():stream.readI();
|
||||
mustTell=false;
|
||||
break;
|
||||
case 0xfb:
|
||||
case 0xdb:
|
||||
logE("TODO: RATE");
|
||||
stream.readI();
|
||||
break;
|
||||
case 0xfc:
|
||||
case 0xdc:
|
||||
chan[i].waitTicks=(unsigned short)(bigEndian?stream.readS_BE():stream.readS());
|
||||
chan[i].lastWaitLen=chan[i].waitTicks;
|
||||
break;
|
||||
case 0xfd:
|
||||
case 0xdd:
|
||||
chan[i].waitTicks=(unsigned char)stream.readC();
|
||||
chan[i].lastWaitLen=chan[i].waitTicks;
|
||||
break;
|
||||
case 0xfe:
|
||||
case 0xde:
|
||||
chan[i].waitTicks=1;
|
||||
chan[i].lastWaitLen=chan[i].waitTicks;
|
||||
break;
|
||||
case 0xff:
|
||||
case 0xdf:
|
||||
chan[i].readPos=0;
|
||||
mustTell=false;
|
||||
logI("%d: stop",i,chan[i].readPos);
|
||||
|
|
|
@ -243,7 +243,7 @@ int DivCS::getInsLength(unsigned char ins, unsigned char ext, unsigned char* spe
|
|||
case 0xcc: // tremolo
|
||||
case 0xcd: // panbrello
|
||||
case 0xce: // pan slide
|
||||
case 0xfd: // waitc
|
||||
case 0xdd: // waitc
|
||||
return 2;
|
||||
case 0xcf: // pan
|
||||
case 0xc2: // vibrato
|
||||
|
@ -251,25 +251,25 @@ int DivCS::getInsLength(unsigned char ins, unsigned char ext, unsigned char* spe
|
|||
case 0xc9: // porta
|
||||
return 3;
|
||||
// speed dial commands
|
||||
case 0xd0: case 0xd1: case 0xd2: case 0xd3:
|
||||
case 0xd4: case 0xd5: case 0xd6: case 0xd7:
|
||||
case 0xd8: case 0xd9: case 0xda: case 0xdb:
|
||||
case 0xdc: case 0xdd: case 0xde: case 0xdf:
|
||||
case 0xe0: case 0xe1: case 0xe2: case 0xe3:
|
||||
case 0xe4: case 0xe5: case 0xe6: case 0xe7:
|
||||
case 0xe8: case 0xe9: case 0xea: case 0xeb:
|
||||
case 0xec: case 0xed: case 0xee: case 0xef:
|
||||
if (speedDial==NULL) return 0;
|
||||
return 1+getCmdLength(speedDial[ins&15]);
|
||||
case 0xf0: // opt
|
||||
case 0xd0: // opt
|
||||
return 4;
|
||||
case 0xf7: // cmd
|
||||
case 0xd7: // cmd
|
||||
// determine length from secondary
|
||||
if (ext==0) return 0;
|
||||
return 2+getCmdLength(ext);
|
||||
case 0xf8: // call
|
||||
case 0xfc: // waits
|
||||
case 0xd8: // call
|
||||
case 0xdc: // waits
|
||||
return 3;
|
||||
case 0xf4: // callsym
|
||||
case 0xf5: // calli
|
||||
case 0xfa: // jmp
|
||||
case 0xfb: // rate
|
||||
case 0xd4: // callsym
|
||||
case 0xd5: // calli
|
||||
case 0xda: // jmp
|
||||
case 0xdb: // rate
|
||||
case 0xcb: // volporta
|
||||
return 5;
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ void writeCommandValues(SafeWriter* w, const DivCommand& c, bool bigEndian) {
|
|||
w->writeC(0xcf);
|
||||
break;
|
||||
default:
|
||||
w->writeC(0xf7);
|
||||
w->writeC(0xd7);
|
||||
w->writeC(c.cmd);
|
||||
break;
|
||||
}
|
||||
|
@ -650,8 +650,8 @@ void reloc8(unsigned char* buf, size_t len, unsigned int sourceAddr, unsigned in
|
|||
unsigned int delta=destAddr-sourceAddr;
|
||||
for (size_t i=0; i<len; i+=8) {
|
||||
switch (buf[i]) {
|
||||
case 0xf5: // calli
|
||||
case 0xfa: { // jmp
|
||||
case 0xd5: // calli
|
||||
case 0xda: { // jmp
|
||||
unsigned int addr=buf[i+1]|(buf[i+2]<<8)|(buf[i+3]<<16)|(buf[i+4]<<24);
|
||||
addr+=delta;
|
||||
buf[i+1]=addr&0xff;
|
||||
|
@ -660,11 +660,11 @@ void reloc8(unsigned char* buf, size_t len, unsigned int sourceAddr, unsigned in
|
|||
buf[i+4]=(addr>>24)&0xff;
|
||||
break;
|
||||
}
|
||||
case 0xf8: { // call
|
||||
case 0xd8: { // call
|
||||
unsigned int addr=buf[i+1]|(buf[i+2]<<8);
|
||||
addr+=delta;
|
||||
if (addr>0xffff) {
|
||||
buf[i]=0xf5;
|
||||
buf[i]=0xd5;
|
||||
buf[i+1]=addr&0xff;
|
||||
buf[i+2]=(addr>>8)&0xff;
|
||||
buf[i+3]=(addr>>16)&0xff;
|
||||
|
@ -688,8 +688,8 @@ void reloc(unsigned char* buf, size_t len, unsigned int sourceAddr, unsigned int
|
|||
break;
|
||||
}
|
||||
switch (buf[i]) {
|
||||
case 0xf5: // calli
|
||||
case 0xfa: { // jmp
|
||||
case 0xd5: // calli
|
||||
case 0xda: { // jmp
|
||||
unsigned int addr=buf[i+1]|(buf[i+2]<<8)|(buf[i+3]<<16)|(buf[i+4]<<24);
|
||||
addr+=delta;
|
||||
if (bigEndian) {
|
||||
|
@ -705,7 +705,7 @@ void reloc(unsigned char* buf, size_t len, unsigned int sourceAddr, unsigned int
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 0xf8: { // call
|
||||
case 0xd8: { // call
|
||||
unsigned short addr=buf[i+1]|(buf[i+2]<<8);
|
||||
addr+=delta;
|
||||
if (bigEndian) {
|
||||
|
@ -733,21 +733,21 @@ SafeWriter* stripNops(SafeWriter* s) {
|
|||
size_t addr=0;
|
||||
for (size_t i=0; i<oldStream->size(); i+=8) {
|
||||
addrTable[i]=addr;
|
||||
if (buf[i]!=0xf1) addr+=8;
|
||||
if (buf[i]!=0xd1) addr+=8;
|
||||
}
|
||||
|
||||
// translate addresses
|
||||
for (size_t i=0; i<oldStream->size(); i+=8) {
|
||||
switch (buf[i]) {
|
||||
case 0xf5: // calli
|
||||
case 0xfa: { // jmp
|
||||
case 0xd5: // calli
|
||||
case 0xda: { // jmp
|
||||
unsigned int addr=buf[i+1]|(buf[i+2]<<8)|(buf[i+3]<<16)|(buf[i+4]<<24);
|
||||
assert(!(addr&7));
|
||||
if (addr>=oldStream->size()) {
|
||||
logE("OUT OF BOUNDS!");
|
||||
abort();
|
||||
}
|
||||
if (buf[addr]==0xf1) {
|
||||
if (buf[addr]==0xd1) {
|
||||
logE("POINTS TO NOP");
|
||||
abort();
|
||||
}
|
||||
|
@ -763,7 +763,7 @@ SafeWriter* stripNops(SafeWriter* s) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 0xf8: { // call
|
||||
case 0xd8: { // call
|
||||
unsigned int addr=buf[i+1]|(buf[i+2]<<8);
|
||||
try {
|
||||
addr=addrTable[addr];
|
||||
|
@ -775,7 +775,7 @@ SafeWriter* stripNops(SafeWriter* s) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (buf[i]!=0xf1) {
|
||||
if (buf[i]!=0xd1) {
|
||||
s->write(&buf[i],8);
|
||||
}
|
||||
}
|
||||
|
@ -801,7 +801,7 @@ SafeWriter* stripNopsPacked(SafeWriter* s, unsigned char* speedDial) {
|
|||
break;
|
||||
}
|
||||
addrTable[i]=addr;
|
||||
if (buf[i]!=0xf1) addr+=insLen;
|
||||
if (buf[i]!=0xd1) addr+=insLen;
|
||||
i+=insLen;
|
||||
}
|
||||
|
||||
|
@ -813,8 +813,8 @@ SafeWriter* stripNopsPacked(SafeWriter* s, unsigned char* speedDial) {
|
|||
break;
|
||||
}
|
||||
switch (buf[i]) {
|
||||
case 0xf5: // calli
|
||||
case 0xfa: { // jmp
|
||||
case 0xd5: // calli
|
||||
case 0xda: { // jmp
|
||||
unsigned int addr=buf[i+1]|(buf[i+2]<<8)|(buf[i+3]<<8)|(buf[i+4]<<24);
|
||||
try {
|
||||
addr=addrTable[addr];
|
||||
|
@ -827,7 +827,7 @@ SafeWriter* stripNopsPacked(SafeWriter* s, unsigned char* speedDial) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 0xf8: { // call
|
||||
case 0xd8: { // call
|
||||
unsigned int addr=buf[i+1]|(buf[i+2]<<8);
|
||||
try {
|
||||
addr=addrTable[addr];
|
||||
|
@ -842,7 +842,7 @@ SafeWriter* stripNopsPacked(SafeWriter* s, unsigned char* speedDial) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (buf[i]!=0xf1) {
|
||||
if (buf[i]!=0xd1) {
|
||||
s->write(&buf[i],insLen);
|
||||
}
|
||||
i+=insLen;
|
||||
|
@ -1007,7 +1007,7 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector<SafeWriter*>& subBlock
|
|||
// 2. only calls and jmp/ret/stop
|
||||
bool metCriteria=true;
|
||||
for (size_t l=k.orig; l<k.orig+len; l+=8) {
|
||||
if (buf[l]==0xf4 || buf[l]==0xf5) {
|
||||
if (buf[l]==0xd4 || buf[l]==0xd5) {
|
||||
metCriteria=false;
|
||||
break;
|
||||
}
|
||||
|
@ -1016,7 +1016,7 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector<SafeWriter*>& subBlock
|
|||
|
||||
// 3. jmp/ret/stop
|
||||
for (size_t l=k.orig; l<k.orig+len; l+=8) {
|
||||
if (buf[l]==0xf9 || buf[l]==0xfa || buf[l]==0xff) {
|
||||
if (buf[l]==0xd9 || buf[l]==0xda || buf[l]==0xdf) {
|
||||
metCriteria=false;
|
||||
break;
|
||||
}
|
||||
|
@ -1091,7 +1091,7 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector<SafeWriter*>& subBlock
|
|||
SafeWriter* newBlock=new SafeWriter;
|
||||
newBlock->init();
|
||||
newBlock->write(&buf[bestOrig],bestBenefit.len);
|
||||
newBlock->writeC(0xf9); // ret
|
||||
newBlock->writeC(0xd9); // ret
|
||||
// padding
|
||||
newBlock->writeC(0);
|
||||
newBlock->writeC(0);
|
||||
|
@ -1103,7 +1103,7 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector<SafeWriter*>& subBlock
|
|||
subBlocks.push_back(newBlock);
|
||||
|
||||
// insert call on the original block
|
||||
buf[bestOrig]=0xf4;
|
||||
buf[bestOrig]=0xd4;
|
||||
buf[bestOrig+1]=subBlockID&0xff;
|
||||
buf[bestOrig+2]=(subBlockID>>8)&0xff;
|
||||
buf[bestOrig+3]=(subBlockID>>16)&0xff;
|
||||
|
@ -1114,7 +1114,7 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector<SafeWriter*>& subBlock
|
|||
|
||||
// replace the rest with nop
|
||||
for (size_t j=bestOrig+8; j<bestOrig+bestBenefit.len; j++) {
|
||||
buf[j]=0xf1;
|
||||
buf[j]=0xd1;
|
||||
}
|
||||
|
||||
// set matches to this sub-block
|
||||
|
@ -1125,7 +1125,7 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector<SafeWriter*>& subBlock
|
|||
assert(!(i.block&7));
|
||||
|
||||
// set match to this sub-block
|
||||
buf[i.block]=0xf4;
|
||||
buf[i.block]=0xd4;
|
||||
buf[i.block+1]=subBlockID&0xff;
|
||||
buf[i.block+2]=(subBlockID>>8)&0xff;
|
||||
buf[i.block+3]=(subBlockID>>16)&0xff;
|
||||
|
@ -1136,7 +1136,7 @@ SafeWriter* findSubBlocks(SafeWriter* stream, std::vector<SafeWriter*>& subBlock
|
|||
|
||||
// replace the rest with nop
|
||||
for (size_t j=i.block+8; j<i.block+bestBenefit.len; j++) {
|
||||
buf[j]=0xf1;
|
||||
buf[j]=0xd1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1171,19 +1171,19 @@ SafeWriter* packStream(SafeWriter* s, unsigned char* speedDial) {
|
|||
break;
|
||||
}
|
||||
switch (buf[i]) {
|
||||
case 0xf5: { // calli
|
||||
case 0xd5: { // calli
|
||||
unsigned int addr=buf[i+1]|(buf[i+2]<<8)|(buf[i+3]<<16)|(buf[i+4]<<24);
|
||||
try {
|
||||
addr=addrTable[addr];
|
||||
// check whether we have sufficient room to turn this into a 16-bit call
|
||||
if (addr<0xff00) {
|
||||
buf[i]=0xf8;
|
||||
buf[i]=0xd8;
|
||||
buf[i+1]=addr&0xff;
|
||||
buf[i+2]=(addr>>8)&0xff;
|
||||
buf[i+3]=0xf1;
|
||||
buf[i+4]=0xf1;
|
||||
buf[i+3]=0xd1;
|
||||
buf[i+4]=0xd1;
|
||||
} else {
|
||||
buf[i]=0xf5;
|
||||
buf[i]=0xd5;
|
||||
buf[i+1]=addr&0xff;
|
||||
buf[i+2]=(addr>>8)&0xff;
|
||||
buf[i+3]=(addr>>16)&0xff;
|
||||
|
@ -1194,7 +1194,7 @@ SafeWriter* packStream(SafeWriter* s, unsigned char* speedDial) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 0xfa: { // jmp
|
||||
case 0xda: { // jmp
|
||||
unsigned int addr=buf[i+1]|(buf[i+2]<<8)|(buf[i+3]<<16)|(buf[i+4]<<24);
|
||||
try {
|
||||
addr=addrTable[addr];
|
||||
|
@ -1207,7 +1207,7 @@ SafeWriter* packStream(SafeWriter* s, unsigned char* speedDial) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 0xf8: { // call
|
||||
case 0xd8: { // call
|
||||
logW("16-bit call should NEVER be generated. aborting!");
|
||||
abort();
|
||||
break;
|
||||
|
@ -1297,7 +1297,7 @@ SafeWriter* DivEngine::saveCommand(DivCSProgress* progress, DivCSOptions options
|
|||
// PASS 0: play the song and log channel command streams
|
||||
// song beginning marker
|
||||
for (int i=0; i<chans; i++) {
|
||||
chanStream[i]->writeC(0xf0);
|
||||
chanStream[i]->writeC(0xd0);
|
||||
chanStream[i]->writeC(i);
|
||||
chanStream[i]->writeC(0x00);
|
||||
chanStream[i]->writeC(0x00);
|
||||
|
@ -1318,7 +1318,7 @@ SafeWriter* DivEngine::saveCommand(DivCSProgress* progress, DivCSOptions options
|
|||
loopTick=tick;
|
||||
// loop marker
|
||||
for (int i=0; i<chans; i++) {
|
||||
chanStream[i]->writeC(0xf0);
|
||||
chanStream[i]->writeC(0xd0);
|
||||
chanStream[i]->writeC(i);
|
||||
chanStream[i]->writeC(0x00);
|
||||
chanStream[i]->writeC(0x01);
|
||||
|
@ -1338,7 +1338,7 @@ SafeWriter* DivEngine::saveCommand(DivCSProgress* progress, DivCSOptions options
|
|||
// get command stream
|
||||
if (curDivider!=divider) {
|
||||
curDivider=divider;
|
||||
chanStream[0]->writeC(0xfb);
|
||||
chanStream[0]->writeC(0xdb);
|
||||
chanStream[0]->writeI((int)(curDivider*65536));
|
||||
// padding
|
||||
chanStream[0]->writeC(0x00);
|
||||
|
@ -1364,7 +1364,7 @@ SafeWriter* DivEngine::saveCommand(DivCSProgress* progress, DivCSOptions options
|
|||
}
|
||||
cmdStream.clear();
|
||||
for (int i=0; i<chans; i++) {
|
||||
chanStream[i]->writeC(0xfe);
|
||||
chanStream[i]->writeC(0xde);
|
||||
// padding
|
||||
chanStream[i]->writeC(0x00);
|
||||
chanStream[i]->writeC(0x00);
|
||||
|
@ -1378,7 +1378,7 @@ SafeWriter* DivEngine::saveCommand(DivCSProgress* progress, DivCSOptions options
|
|||
}
|
||||
if (!playing || loopTick<0) {
|
||||
for (int i=0; i<chans; i++) {
|
||||
chanStream[i]->writeC(0xff);
|
||||
chanStream[i]->writeC(0xdf);
|
||||
// padding
|
||||
chanStream[i]->writeC(0x00);
|
||||
chanStream[i]->writeC(0x00);
|
||||
|
@ -1391,7 +1391,7 @@ SafeWriter* DivEngine::saveCommand(DivCSProgress* progress, DivCSOptions options
|
|||
} else {
|
||||
for (int i=0; i<chans; i++) {
|
||||
if ((int)tickPos[i].size()>loopTick) {
|
||||
chanStream[i]->writeC(0xfa);
|
||||
chanStream[i]->writeC(0xda);
|
||||
chanStream[i]->writeI(tickPos[i][loopTick]);
|
||||
logD("chan %d loop addr: %x",i,tickPos[i][loopTick]);
|
||||
// padding
|
||||
|
@ -1400,7 +1400,7 @@ SafeWriter* DivEngine::saveCommand(DivCSProgress* progress, DivCSOptions options
|
|||
chanStream[i]->writeC(0x00);
|
||||
} else {
|
||||
logW("chan %d unable to find loop addr!",i);
|
||||
chanStream[i]->writeC(0xff);
|
||||
chanStream[i]->writeC(0xdf);
|
||||
// padding
|
||||
chanStream[i]->writeC(0x00);
|
||||
chanStream[i]->writeC(0x00);
|
||||
|
@ -1449,11 +1449,11 @@ SafeWriter* DivEngine::saveCommand(DivCSProgress* progress, DivCSOptions options
|
|||
for (int h=0; h<chans; h++) {
|
||||
unsigned char* buf=chanStream[h]->getFinalBuf();
|
||||
for (size_t i=0; i<chanStream[h]->size(); i+=8) {
|
||||
if (buf[i]==0xf7) {
|
||||
if (buf[i]==0xd7) {
|
||||
// find whether this command is in speed dial
|
||||
for (int j=0; j<16; j++) {
|
||||
if (buf[i+1]==sortedCmd[j]) {
|
||||
buf[i]=0xd0+j;
|
||||
buf[i]=0xe0+j;
|
||||
// move everything to the left
|
||||
for (int k=i+2; k<(int)i+8; k++) {
|
||||
buf[k-1]=buf[k];
|
||||
|
@ -1473,7 +1473,7 @@ SafeWriter* DivEngine::saveCommand(DivCSProgress* progress, DivCSOptions options
|
|||
unsigned char* buf=chanStream[h]->getFinalBuf();
|
||||
int delayCount=0;
|
||||
for (size_t i=0; i<chanStream[h]->size(); i+=8) {
|
||||
if (buf[i]==0xfe) {
|
||||
if (buf[i]==0xde) {
|
||||
delayCount++;
|
||||
} else {
|
||||
if (delayCount>1 && delayCount<=255) {
|
||||
|
@ -1513,7 +1513,7 @@ SafeWriter* DivEngine::saveCommand(DivCSProgress* progress, DivCSOptions options
|
|||
int delayCount=0;
|
||||
int delayLast=0;
|
||||
for (size_t i=0; i<chanStream[h]->size(); i+=8) {
|
||||
if (buf[i]==0xfe) {
|
||||
if (buf[i]==0xde) {
|
||||
if (delayPos==-1) delayPos=i;
|
||||
delayCount++;
|
||||
delayLast=i;
|
||||
|
@ -1526,20 +1526,20 @@ SafeWriter* DivEngine::saveCommand(DivCSProgress* progress, DivCSOptions options
|
|||
} else {
|
||||
// write condensed delay and fill the rest with nop
|
||||
if (delayCount>255) {
|
||||
buf[delayPos++]=0xfc;
|
||||
buf[delayPos++]=0xdc;
|
||||
buf[delayPos++]=delayCount&0xff;
|
||||
buf[delayPos++]=(delayCount>>8)&0xff;
|
||||
} else {
|
||||
bool foundShort=false;
|
||||
for (int j=0; j<16; j++) {
|
||||
if (sortedDelay[j]==delayCount) {
|
||||
buf[delayPos++]=0xe0+j;
|
||||
buf[delayPos++]=0xf0+j;
|
||||
foundShort=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!foundShort) {
|
||||
buf[delayPos++]=0xfd;
|
||||
buf[delayPos++]=0xdd;
|
||||
buf[delayPos++]=delayCount;
|
||||
}
|
||||
}
|
||||
|
@ -1547,7 +1547,7 @@ SafeWriter* DivEngine::saveCommand(DivCSProgress* progress, DivCSOptions options
|
|||
while (delayPos&7) buf[delayPos++]=0;
|
||||
// fill with nop
|
||||
for (int j=delayPos; j<=delayLast; j++) {
|
||||
buf[j]=0xf1;
|
||||
buf[j]=0xd1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1568,10 +1568,10 @@ SafeWriter* DivEngine::saveCommand(DivCSProgress* progress, DivCSOptions options
|
|||
// find note off
|
||||
if (buf[i]==0xb5) {
|
||||
// check for contiguous wait 1
|
||||
if (buf[i+8]==0xfe) {
|
||||
if (buf[i+8]==0xde) {
|
||||
// turn it into 0xf6 (note off + wait 1) and change the next one to nop
|
||||
buf[i]=0xf6;
|
||||
buf[i+8]=0xf1;
|
||||
buf[i]=0xd6;
|
||||
buf[i+8]=0xd1;
|
||||
|
||||
// skip the next instruction
|
||||
i+=8;
|
||||
|
@ -1636,12 +1636,12 @@ SafeWriter* DivEngine::saveCommand(DivCSProgress* progress, DivCSOptions options
|
|||
// resolve symbols
|
||||
unsigned char* buf=globalStream->getFinalBuf();
|
||||
for (size_t j=0; j<globalStream->size(); j+=8) {
|
||||
if (buf[j]==0xf4) { // callsym
|
||||
if (buf[j]==0xd4) { // callsym
|
||||
unsigned int addr=buf[j+1]|(buf[j+2]<<8)|(buf[j+3]<<16)|(buf[j+4]<<24);
|
||||
if (addr<blockOff.size()) {
|
||||
// turn it into call
|
||||
addr=blockOff[addr];
|
||||
buf[j]=0xf5;
|
||||
buf[j]=0xd5;
|
||||
buf[j+1]=addr&0xff;
|
||||
buf[j+2]=(addr>>8)&0xff;
|
||||
buf[j+3]=(addr>>16)&0xff;
|
||||
|
@ -1675,7 +1675,7 @@ SafeWriter* DivEngine::saveCommand(DivCSProgress* progress, DivCSOptions options
|
|||
break;
|
||||
}
|
||||
|
||||
if (buf[i]==0xf0) {
|
||||
if (buf[i]==0xd0) {
|
||||
if (buf[i+3]==0) {
|
||||
int ch=buf[i+1];
|
||||
if (ch>=0 && ch<chans) {
|
||||
|
|
|
@ -104,10 +104,10 @@ String disasmCmd(unsigned char* buf, size_t bufLen, unsigned int addr, unsigned
|
|||
if (addr+2>=bufLen) return "???";
|
||||
return fmt::sprintf("pan $%x, $%x",(int)buf[addr+1],(int)buf[addr+2]);
|
||||
break;
|
||||
case 0xd0: case 0xd1: case 0xd2: case 0xd3:
|
||||
case 0xd4: case 0xd5: case 0xd6: case 0xd7:
|
||||
case 0xd8: case 0xd9: case 0xda: case 0xdb:
|
||||
case 0xdc: case 0xdd: case 0xde: case 0xdf: {
|
||||
case 0xe0: case 0xe1: case 0xe2: case 0xe3:
|
||||
case 0xe4: case 0xe5: case 0xe6: case 0xe7:
|
||||
case 0xe8: case 0xe9: case 0xea: case 0xeb:
|
||||
case 0xec: case 0xed: case 0xee: case 0xef: {
|
||||
unsigned char cmd=speedDial[buf[addr]&15];
|
||||
int cmdLen=DivCS::getCmdLength(cmd);
|
||||
if ((addr+cmdLen)>=bufLen) return "???";
|
||||
|
@ -118,34 +118,34 @@ String disasmCmd(unsigned char* buf, size_t bufLen, unsigned int addr, unsigned
|
|||
return ret;
|
||||
break;
|
||||
}
|
||||
case 0xe0: case 0xe1: case 0xe2: case 0xe3:
|
||||
case 0xe4: case 0xe5: case 0xe6: case 0xe7:
|
||||
case 0xe8: case 0xe9: case 0xea: case 0xeb:
|
||||
case 0xec: case 0xed: case 0xee: case 0xef:
|
||||
case 0xf0: case 0xf1: case 0xf2: case 0xf3:
|
||||
case 0xf4: case 0xf5: case 0xf6: case 0xf7:
|
||||
case 0xf8: case 0xf9: case 0xfa: case 0xfb:
|
||||
case 0xfc: case 0xfd: case 0xfe: case 0xff:
|
||||
return fmt::sprintf("qwait (%d)",(int)(buf[addr]-0xe0));
|
||||
break;
|
||||
case 0xf0:
|
||||
case 0xd0:
|
||||
if (addr+3>=bufLen) return "???";
|
||||
return fmt::sprintf("opt $%.2x%.2x%.2x",(int)buf[addr+1],(int)buf[addr+2],(int)buf[addr+3]);
|
||||
break;
|
||||
case 0xf1:
|
||||
case 0xd1:
|
||||
return "nop";
|
||||
break;
|
||||
case 0xf3:
|
||||
case 0xd3:
|
||||
return fmt::sprintf("loop (-%d), %d",(int)buf[addr+1],(int)buf[addr+2]);
|
||||
break;
|
||||
case 0xf4:
|
||||
case 0xd4:
|
||||
if (addr+2>=bufLen) return "???";
|
||||
return fmt::sprintf("callsym $%.4x",(int)(buf[addr+1]|(buf[addr+2]<<8)));
|
||||
break;
|
||||
case 0xf5:
|
||||
case 0xd5:
|
||||
if (addr+4>=bufLen) return "???";
|
||||
return fmt::sprintf("call $%.8x",(unsigned int)(buf[addr+1]|(buf[addr+2]<<8)|(buf[addr+3]<<16)|(buf[addr+4]<<24)));
|
||||
break;
|
||||
case 0xf6:
|
||||
case 0xd6:
|
||||
return "offwait";
|
||||
break;
|
||||
case 0xf7: {
|
||||
case 0xd7: {
|
||||
if (addr+1>=bufLen) return "???";
|
||||
int cmdLen=DivCS::getCmdLength(buf[addr+1]);
|
||||
if ((addr+1+cmdLen)>=bufLen) return "???";
|
||||
|
@ -156,31 +156,31 @@ String disasmCmd(unsigned char* buf, size_t bufLen, unsigned int addr, unsigned
|
|||
return ret;
|
||||
break;
|
||||
}
|
||||
case 0xf8:
|
||||
case 0xd8:
|
||||
if (addr+2>=bufLen) return "???";
|
||||
return fmt::sprintf("call $%.4x",(unsigned int)(buf[addr+1]|(buf[addr+2]<<8)));
|
||||
break;
|
||||
case 0xf9:
|
||||
case 0xd9:
|
||||
return "ret";
|
||||
break;
|
||||
case 0xfa:
|
||||
case 0xda:
|
||||
return fmt::sprintf("jmp $%.8x",(unsigned int)(buf[addr+1]|(buf[addr+2]<<8)|(buf[addr+3]<<16)|(buf[addr+4]<<24)));
|
||||
break;
|
||||
case 0xfb:
|
||||
case 0xdb:
|
||||
return fmt::sprintf("rate $%.8x",(unsigned int)(buf[addr+1]|(buf[addr+2]<<8)|(buf[addr+3]<<16)|(buf[addr+4]<<24)));
|
||||
break;
|
||||
case 0xfc:
|
||||
case 0xdc:
|
||||
if (addr+2>=bufLen) return "???";
|
||||
return fmt::sprintf("waits %d",(int)(buf[addr+1]|(buf[addr+2]<<8)));
|
||||
break;
|
||||
case 0xfd:
|
||||
case 0xdd:
|
||||
if (addr+1>=bufLen) return "???";
|
||||
return fmt::sprintf("waitc %d",(int)buf[addr+1]);
|
||||
break;
|
||||
case 0xfe:
|
||||
case 0xde:
|
||||
return "wait 1";
|
||||
break;
|
||||
case 0xff:
|
||||
case 0xdf:
|
||||
return "stop";
|
||||
break;
|
||||
default:
|
||||
|
@ -407,7 +407,7 @@ void FurnaceGUI::drawCSPlayer() {
|
|||
ImGui::Text("%s",dis.c_str());
|
||||
|
||||
// jmp/ret separator
|
||||
if (i.data[0]==0xf9 || i.data[0]==0xfa) {
|
||||
if (i.data[0]==0xd9 || i.data[0]==0xda) {
|
||||
ImGui::TableNextRow(0,oneChar.y);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Separator();
|
||||
|
|
Loading…
Reference in a new issue