only output playback status in console mode

This commit is contained in:
tildearrow 2021-12-18 04:26:17 -05:00
parent d4046de2e1
commit beceefd34b
5 changed files with 45 additions and 15 deletions

View file

@ -1484,6 +1484,10 @@ void DivEngine::setView(DivStatusView which) {
view=which; view=which;
} }
void DivEngine::setConsoleMode(bool enable) {
consoleMode=enable;
}
void DivEngine::initDispatch() { void DivEngine::initDispatch() {
if (dispatch!=NULL) return; if (dispatch!=NULL) return;
isBusy.lock(); isBusy.lock();

View file

@ -72,6 +72,7 @@ class DivEngine {
bool playing; bool playing;
bool speedAB; bool speedAB;
bool endOfSong; bool endOfSong;
bool consoleMode;
int ticks, cycles, curRow, curOrder, remainingLoops, nextSpeed, clockDrift; int ticks, cycles, curRow, curOrder, remainingLoops, nextSpeed, clockDrift;
int changeOrd, changePos, totalTicks, totalCmds, lastCmds, cmdsPerSecond; int changeOrd, changePos, totalTicks, totalCmds, lastCmds, cmdsPerSecond;
DivStatusView view; DivStatusView view;
@ -208,6 +209,9 @@ class DivEngine {
// set the view mode. // set the view mode.
void setView(DivStatusView which); void setView(DivStatusView which);
// set the console mode.
void setConsoleMode(bool enable);
// public render samples // public render samples
void renderSamplesP(); void renderSamplesP();
@ -233,6 +237,7 @@ class DivEngine {
playing(false), playing(false),
speedAB(false), speedAB(false),
endOfSong(false), endOfSong(false),
consoleMode(false),
ticks(0), ticks(0),
cycles(0), cycles(0),
curRow(0), curRow(0),

View file

@ -505,7 +505,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
} }
break; break;
case 0xee: // external command case 0xee: // external command
printf("\x1b[1;36m%d: extern command %d\x1b[m\n",i,effectVal); //printf("\x1b[1;36m%d: extern command %d\x1b[m\n",i,effectVal);
break; break;
} }
} }
@ -772,7 +772,7 @@ bool DivEngine::nextTick() {
} else { } else {
hz=50; hz=50;
} }
fprintf(stderr,"\x1b[2K> %d:%.2d:%.2d.%.2d %.2x/%.2x:%.3d/%.3d %4dcmd/s\x1b[G",totalTicks/(hz*3600),(totalTicks/(hz*60))%60,(totalTicks/hz)%60,totalTicks%hz,curOrder,song.ordersLen,curRow,song.patLen,cmdsPerSecond); if (consoleMode) fprintf(stderr,"\x1b[2K> %d:%.2d:%.2d.%.2d %.2x/%.2x:%.3d/%.3d %4dcmd/s\x1b[G",totalTicks/(hz*3600),(totalTicks/(hz*60))%60,(totalTicks/hz)%60,totalTicks%hz,curOrder,song.ordersLen,curRow,song.patLen,cmdsPerSecond);
if ((totalTicks%hz)==0) { if ((totalTicks%hz)==0) {
cmdsPerSecond=totalCmds-lastCmds; cmdsPerSecond=totalCmds-lastCmds;

View file

@ -6,7 +6,11 @@ int logD(const char* format, ...) {
va_list va; va_list va;
int ret; int ret;
if (logLevel<LOGLEVEL_DEBUG) return 0; if (logLevel<LOGLEVEL_DEBUG) return 0;
#ifdef _WIN32
printf("[debug] ");
#else
printf("\x1b[1;34m[debug]\x1b[m "); printf("\x1b[1;34m[debug]\x1b[m ");
#endif
va_start(va,format); va_start(va,format);
ret=vprintf(format,va); ret=vprintf(format,va);
va_end(va); va_end(va);
@ -18,7 +22,11 @@ int logI(const char* format, ...) {
va_list va; va_list va;
int ret; int ret;
if (logLevel<LOGLEVEL_INFO) return 0; if (logLevel<LOGLEVEL_INFO) return 0;
#ifdef _WIN32
printf("[info] ");
#else
printf("\x1b[1;32m[info]\x1b[m "); printf("\x1b[1;32m[info]\x1b[m ");
#endif
va_start(va,format); va_start(va,format);
ret=vprintf(format,va); ret=vprintf(format,va);
va_end(va); va_end(va);
@ -29,7 +37,11 @@ int logW(const char* format, ...) {
va_list va; va_list va;
int ret; int ret;
if (logLevel<LOGLEVEL_WARN) return 0; if (logLevel<LOGLEVEL_WARN) return 0;
#ifdef _WIN32
printf("[warning] ");
#else
printf("\x1b[1;33m[warning]\x1b[m "); printf("\x1b[1;33m[warning]\x1b[m ");
#endif
va_start(va,format); va_start(va,format);
ret=vprintf(format,va); ret=vprintf(format,va);
va_end(va); va_end(va);
@ -40,7 +52,11 @@ int logE(const char* format, ...) {
va_list va; va_list va;
int ret; int ret;
if (logLevel<LOGLEVEL_ERROR) return 0; if (logLevel<LOGLEVEL_ERROR) return 0;
printf("\x1b[1;31m[ERROR]\x1b[m "); #ifdef _WIN32
printf("[ERROR] ");
#else
printf("\x0b[1;31m[ERROR]\x1b[m ");
#endif
va_start(va,format); va_start(va,format);
ret=vprintf(format,va); ret=vprintf(format,va);
va_end(va); va_end(va);

View file

@ -180,18 +180,6 @@ void initParams() {
int main(int argc, char** argv) { int main(int argc, char** argv) {
outName=""; outName="";
#ifdef _WIN32
HANDLE winin=GetStdHandle(STD_INPUT_HANDLE);
HANDLE winout=GetStdHandle(STD_OUTPUT_HANDLE);
int termprop=0;
int termpropi=0;
GetConsoleMode(winout,(LPDWORD)&termprop);
GetConsoleMode(winin,(LPDWORD)&termpropi);
termprop|=ENABLE_VIRTUAL_TERMINAL_PROCESSING;
termpropi&=~ENABLE_LINE_INPUT;
SetConsoleMode(winout,termprop);
SetConsoleMode(winin,termpropi);
#endif
initParams(); initParams();
@ -233,6 +221,23 @@ int main(int argc, char** argv) {
} }
} }
e.setConsoleMode(consoleMode);
#ifdef _WIN32
if (consoleMode) {
HANDLE winin=GetStdHandle(STD_INPUT_HANDLE);
HANDLE winout=GetStdHandle(STD_OUTPUT_HANDLE);
int termprop=0;
int termpropi=0;
GetConsoleMode(winout,(LPDWORD)&termprop);
GetConsoleMode(winin,(LPDWORD)&termpropi);
termprop|=ENABLE_VIRTUAL_TERMINAL_PROCESSING;
termpropi&=~ENABLE_LINE_INPUT;
SetConsoleMode(winout,termprop);
SetConsoleMode(winin,termpropi);
}
#endif
if (fileName.empty() && consoleMode) { if (fileName.empty() && consoleMode) {
logI("usage: %s file\n",argv[0]); logI("usage: %s file\n",argv[0]);
return 1; return 1;