a better command stream debugger

This commit is contained in:
tildearrow 2024-03-08 17:53:37 -05:00
parent d3f0f1d1d0
commit 2290f3d873
14 changed files with 265 additions and 6 deletions

View file

@ -35,8 +35,30 @@ bool DivCSChannelState::doCall(unsigned int addr) {
return true;
}
unsigned char* DivCSPlayer::getData() {
return b;
}
size_t DivCSPlayer::getDataLen() {
return bLen;
}
DivCSChannelState* DivCSPlayer::getChanState(int ch) {
return &chan[ch];
}
unsigned char* DivCSPlayer::getFastDelays() {
return fastDelays;
}
unsigned char* DivCSPlayer::getFastCmds() {
return fastCmds;
}
void DivCSPlayer::cleanup() {
delete b;
b=NULL;
bLen=0;
}
bool DivCSPlayer::tick() {
@ -383,7 +405,8 @@ bool DivCSPlayer::init() {
stream.readI();
continue;
}
chan[i].readPos=stream.readI();
chan[i].startPos=stream.readI();
chan[i].readPos=chan[i].startPos;
}
stream.read(fastDelays,16);
@ -427,3 +450,17 @@ bool DivEngine::playStream(unsigned char* f, size_t length) {
BUSY_END;
return true;
}
DivCSPlayer* DivEngine::getStreamPlayer() {
return cmdStreamInt;
}
bool DivEngine::killStream() {
if (!cmdStreamInt) return false;
BUSY_BEGIN;
cmdStreamInt->cleanup();
delete cmdStreamInt;
cmdStreamInt=NULL;
BUSY_END;
return true;
}

View file

@ -26,6 +26,7 @@
class DivEngine;
struct DivCSChannelState {
unsigned int startPos;
unsigned int readPos;
int waitTicks;
@ -69,6 +70,7 @@ struct DivCSChannelState {
class DivCSPlayer {
DivEngine* e;
unsigned char* b;
size_t bLen;
SafeReader stream;
DivCSChannelState chan[DIV_MAX_CHANS];
unsigned char fastDelays[16];
@ -77,12 +79,18 @@ class DivCSPlayer {
short vibTable[64];
public:
unsigned char* getData();
size_t getDataLen();
DivCSChannelState* getChanState(int ch);
unsigned char* getFastDelays();
unsigned char* getFastCmds();
void cleanup();
bool tick();
bool init();
DivCSPlayer(DivEngine* en, unsigned char* buf, size_t len):
e(en),
b(buf),
bLen(len),
stream(buf,len) {}
};

View file

@ -633,6 +633,10 @@ class DivEngine {
bool load(unsigned char* f, size_t length);
// play a binary command stream.
bool playStream(unsigned char* f, size_t length);
// get the playing stream.
DivCSPlayer* getStreamPlayer();
// destroy command stream player.
bool killStream();
// save as .dmf.
SafeWriter* saveDMF(unsigned char version);
// save as .fur.

View file

@ -1595,9 +1595,7 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
if (subticks==tickMult && cmdStreamInt) {
if (!cmdStreamInt->tick()) {
cmdStreamInt->cleanup();
delete cmdStreamInt;
cmdStreamInt=NULL;
// !!!
}
}

View file

@ -227,3 +227,9 @@ void SafeWriter::finish() {
buf=NULL;
operative=false;
}
void SafeWriter::disown() {
if (!operative) return;
buf=NULL;
operative=false;
}

View file

@ -62,6 +62,7 @@ class SafeWriter {
void init();
SafeReader* toReader();
void finish();
void disown();
SafeWriter():
operative(false),