prepare to diagnose TIunA hang
This commit is contained in:
parent
dcf904c99f
commit
69f95722f6
|
@ -26,53 +26,107 @@
|
||||||
#include "../ta-log.h"
|
#include "../ta-log.h"
|
||||||
|
|
||||||
struct TiunaNew {
|
struct TiunaNew {
|
||||||
short pitch=-1;
|
short pitch;
|
||||||
signed char ins=-1;
|
signed char ins;
|
||||||
signed char vol=-1;
|
signed char vol;
|
||||||
short sync=-1;
|
short sync;
|
||||||
|
TiunaNew():
|
||||||
|
pitch(-1),
|
||||||
|
ins(-1),
|
||||||
|
vol(-1),
|
||||||
|
sync(-1) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TiunaLast {
|
struct TiunaLast {
|
||||||
short pitch=0;
|
short pitch;
|
||||||
signed char ins=0;
|
signed char ins;
|
||||||
signed char vol=0;
|
signed char vol;
|
||||||
int tick=1;
|
int tick;
|
||||||
bool forcePitch=true;
|
bool forcePitch;
|
||||||
|
TiunaLast():
|
||||||
|
pitch(0),
|
||||||
|
ins(0),
|
||||||
|
vol(0),
|
||||||
|
tick(1),
|
||||||
|
forcePitch(true) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TiunaCmd {
|
struct TiunaCmd {
|
||||||
signed char pitchChange=-1;
|
signed char pitchChange;
|
||||||
short pitchSet=-1;
|
short pitchSet;
|
||||||
signed char ins=-1;
|
signed char ins;
|
||||||
signed char vol=-1;
|
signed char vol;
|
||||||
short sync=-1;
|
short sync;
|
||||||
short wait=-1;
|
short wait;
|
||||||
|
TiunaCmd():
|
||||||
|
pitchChange(-1),
|
||||||
|
pitchSet(-1),
|
||||||
|
ins(-1),
|
||||||
|
vol(-1),
|
||||||
|
sync(-1),
|
||||||
|
wait(-1) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TiunaBytes {
|
struct TiunaBytes {
|
||||||
unsigned char ch=0;
|
unsigned char ch;
|
||||||
int ticks=0;
|
int ticks;
|
||||||
unsigned char size=0;
|
unsigned char size;
|
||||||
unsigned char buf[16];
|
unsigned char buf[16];
|
||||||
friend bool operator==(const TiunaBytes& l, const TiunaBytes& r) {
|
friend bool operator==(const TiunaBytes& l, const TiunaBytes& r) {
|
||||||
if (l.size!=r.size) return false;
|
if (l.size!=r.size) return false;
|
||||||
if (l.ticks!=r.ticks) return false;
|
if (l.ticks!=r.ticks) return false;
|
||||||
return memcmp(l.buf,r.buf,l.size)==0;
|
return memcmp(l.buf,r.buf,l.size)==0;
|
||||||
}
|
}
|
||||||
|
TiunaBytes(unsigned char c, int t, unsigned char s, std::initializer_list<unsigned char> b):
|
||||||
|
ch(c),
|
||||||
|
ticks(t),
|
||||||
|
size(s) {
|
||||||
|
// because C++14 does not support data() on initializer_list
|
||||||
|
unsigned char p=0;
|
||||||
|
for (unsigned char i: b) {
|
||||||
|
buf[p++]=i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TiunaBytes():
|
||||||
|
ch(0),
|
||||||
|
ticks(0),
|
||||||
|
size(0) {
|
||||||
|
memset(buf,0,16);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TiunaMatch {
|
struct TiunaMatch {
|
||||||
int pos;
|
int pos;
|
||||||
int endPos;
|
int endPos;
|
||||||
int size;
|
int size;
|
||||||
int id;
|
int id;
|
||||||
|
TiunaMatch(int p, int ep, int s, int _i):
|
||||||
|
pos(p),
|
||||||
|
endPos(ep),
|
||||||
|
size(s),
|
||||||
|
id(_i) {}
|
||||||
|
TiunaMatch():
|
||||||
|
pos(0),
|
||||||
|
endPos(0),
|
||||||
|
size(0),
|
||||||
|
id(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TiunaMatches {
|
struct TiunaMatches {
|
||||||
int bytesSaved=INT32_MIN;
|
int bytesSaved;
|
||||||
int length=0;
|
int length;
|
||||||
int ticks=0;
|
int ticks;
|
||||||
std::vector<int> pos;
|
std::vector<int> pos;
|
||||||
|
TiunaMatches():
|
||||||
|
bytesSaved(INT32_MIN),
|
||||||
|
length(0),
|
||||||
|
ticks(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void writeCmd(std::vector<TiunaBytes>& cmds, TiunaCmd& cmd, unsigned char ch, int& lastWait, int fromTick, int toTick) {
|
static void writeCmd(std::vector<TiunaBytes>& cmds, TiunaCmd& cmd, unsigned char ch, int& lastWait, int fromTick, int toTick) {
|
||||||
while (fromTick<toTick) {
|
while (fromTick<toTick) {
|
||||||
int val=MIN(toTick-fromTick,256);
|
int val=MIN(toTick-fromTick,256);
|
||||||
|
assert(val>0);
|
||||||
if (lastWait!=val) {
|
if (lastWait!=val) {
|
||||||
cmd.wait=val;
|
cmd.wait=val;
|
||||||
lastWait=val;
|
lastWait=val;
|
||||||
|
@ -322,7 +376,7 @@ SafeWriter* DivEngine::saveTiuna(const bool* sysToExport, const char* baseLabel,
|
||||||
size+=renderedCmds[i+k].size;
|
size+=renderedCmds[i+k].size;
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
if (size>2) match.push_back({j,j+k,size,0});
|
if (size>2) match.push_back(TiunaMatch(j,j+k,size,0));
|
||||||
if (k==0) k++;
|
if (k==0) k++;
|
||||||
j+=k;
|
j+=k;
|
||||||
}
|
}
|
||||||
|
@ -462,7 +516,7 @@ SafeWriter* DivEngine::saveTiuna(const bool* sysToExport, const char* baseLabel,
|
||||||
if (callVisited[cmIter->id]) {
|
if (callVisited[cmIter->id]) {
|
||||||
unsigned char idLo=cmIter->id&0xff;
|
unsigned char idLo=cmIter->id&0xff;
|
||||||
unsigned char idHi=cmIter->id>>8;
|
unsigned char idHi=cmIter->id>>8;
|
||||||
cmd={cmd.ch,0,2,{idHi,idLo}};
|
cmd=TiunaBytes(cmd.ch,0,2,{idHi,idLo});
|
||||||
i=cmIter->endPos-1;
|
i=cmIter->endPos-1;
|
||||||
} else {
|
} else {
|
||||||
writeCall=cmIter->id;
|
writeCall=cmIter->id;
|
||||||
|
@ -508,11 +562,11 @@ SafeWriter* DivEngine::saveTiuna(const bool* sysToExport, const char* baseLabel,
|
||||||
totalSize++;
|
totalSize++;
|
||||||
logI("total size: %d bytes (%d banks)",totalSize,curBank+1);
|
logI("total size: %d bytes (%d banks)",totalSize,curBank+1);
|
||||||
|
|
||||||
FILE* f=ps_fopen("confirmedMatches.txt","wb");
|
//FILE* f=ps_fopen("confirmedMatches.txt","wb");
|
||||||
if (f!=NULL) {
|
//if (f!=NULL) {
|
||||||
fwrite(dbg.getFinalBuf(),1,dbg.size(),f);
|
// fwrite(dbg.getFinalBuf(),1,dbg.size(),f);
|
||||||
fclose(f);
|
// fclose(f);
|
||||||
}
|
//}
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue