GUI: add status bar

This commit is contained in:
tildearrow 2021-12-21 02:30:09 -05:00
parent 5523a43804
commit 6ee4e33b89
5 changed files with 64 additions and 14 deletions

View file

@ -1432,12 +1432,13 @@ void DivEngine::playSub(bool preserveDrift) {
endOfSong=false; endOfSong=false;
} else { } else {
ticks=1; ticks=1;
totalTicks=0;
} }
speedAB=false; speedAB=false;
playing=true; playing=true;
dispatch->setSkipRegisterWrites(true); dispatch->setSkipRegisterWrites(true);
while (curOrder<goal) { while (curOrder<goal) {
if (nextTick()) break; if (nextTick(preserveDrift)) break;
} }
dispatch->setSkipRegisterWrites(false); dispatch->setSkipRegisterWrites(false);
dispatch->forceIns(); dispatch->forceIns();
@ -1473,6 +1474,8 @@ void DivEngine::reset() {
} }
extValue=0; extValue=0;
extValuePresent=0; extValuePresent=0;
speed1=song.speed1;
speed2=song.speed2;
dispatch->reset(); dispatch->reset();
} }
@ -1498,6 +1501,29 @@ int DivEngine::getRow() {
return curRow; return curRow;
} }
unsigned char DivEngine::getSpeed1() {
return speed1;
}
unsigned char DivEngine::getSpeed2() {
return speed2;
}
int DivEngine::getHz() {
if (song.customTempo) {
return song.hz;
} else if (song.pal) {
return 60;
} else {
return 50;
}
return 60;
}
int DivEngine::getTotalTicks() {
return totalTicks;
}
bool DivEngine::hasExtValue() { bool DivEngine::hasExtValue() {
return extValuePresent; return extValuePresent;
} }

View file

@ -81,6 +81,7 @@ class DivEngine {
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;
unsigned char extValue; unsigned char extValue;
unsigned char speed1, speed2;
DivStatusView view; DivStatusView view;
DivChannelState chan[17]; DivChannelState chan[17];
DivAudioEngines audioEngine; DivAudioEngines audioEngine;
@ -108,7 +109,7 @@ class DivEngine {
void nextOrder(); void nextOrder();
void nextRow(); void nextRow();
// returns true if end of song. // returns true if end of song.
bool nextTick(); bool nextTick(bool noAccum=false);
bool perSystemEffect(int ch, unsigned char effect, unsigned char effectVal); bool perSystemEffect(int ch, unsigned char effect, unsigned char effectVal);
bool perSystemPostEffect(int ch, unsigned char effect, unsigned char effectVal); bool perSystemPostEffect(int ch, unsigned char effect, unsigned char effectVal);
void renderSamples(); void renderSamples();
@ -208,6 +209,18 @@ class DivEngine {
// get current row // get current row
int getRow(); int getRow();
// get speed 1
unsigned char getSpeed1();
// get speed 2
unsigned char getSpeed2();
// get Hz
int getHz();
// get time
int getTotalTicks();
// has ext value // has ext value
bool hasExtValue(); bool hasExtValue();
@ -301,6 +314,8 @@ class DivEngine {
lastCmds(0), lastCmds(0),
cmdsPerSecond(0), cmdsPerSecond(0),
extValue(0), extValue(0),
speed1(3),
speed2(3),
view(DIV_STATUS_NOTHING), view(DIV_STATUS_NOTHING),
audioEngine(DIV_AUDIO_SDL), audioEngine(DIV_AUDIO_SDL),
bbInLen(0), bbInLen(0),

View file

@ -379,10 +379,10 @@ void DivEngine::processRow(int i, bool afterDelay) {
// per-system effect // per-system effect
if (!perSystemEffect(i,effect,effectVal)) switch (effect) { if (!perSystemEffect(i,effect,effectVal)) switch (effect) {
case 0x09: // speed 1 case 0x09: // speed 1
song.speed1=effectVal; speed1=effectVal;
break; break;
case 0x0f: // speed 2 case 0x0f: // speed 2
song.speed2=effectVal; speed2=effectVal;
break; break;
case 0x0b: // change order case 0x0b: // change order
if (changeOrd==-1) { if (changeOrd==-1) {
@ -623,19 +623,19 @@ void DivEngine::nextRow() {
if (song.system==DIV_SYSTEM_YMU759) { if (song.system==DIV_SYSTEM_YMU759) {
if (speedAB) { if (speedAB) {
ticks=song.speed2; ticks=speed2;
nextSpeed=song.speed1; nextSpeed=speed1;
} else { } else {
ticks=song.speed1; ticks=speed1;
nextSpeed=song.speed2; nextSpeed=speed2;
} }
} else { } else {
if (speedAB) { if (speedAB) {
ticks=song.speed2*(song.timeBase+1); ticks=speed2*(song.timeBase+1);
nextSpeed=song.speed1; nextSpeed=speed1;
} else { } else {
ticks=song.speed1*(song.timeBase+1); ticks=speed1*(song.timeBase+1);
nextSpeed=song.speed2; nextSpeed=speed2;
} }
} }
speedAB=!speedAB; speedAB=!speedAB;
@ -651,7 +651,7 @@ void DivEngine::nextRow() {
} }
} }
bool DivEngine::nextTick() { bool DivEngine::nextTick(bool noAccum) {
bool ret=false; bool ret=false;
int divider=60; int divider=60;
if (song.customTempo) { if (song.customTempo) {
@ -781,7 +781,7 @@ bool DivEngine::nextTick() {
// system tick // system tick
dispatch->tick(); dispatch->tick();
totalTicks++; if (!noAccum) totalTicks++;
int hz; int hz;
if (song.customTempo) { if (song.customTempo) {

View file

@ -2076,6 +2076,13 @@ bool FurnaceGUI::loop() {
} }
ImGui::EndMenu(); ImGui::EndMenu();
} }
if (e->isPlaying()) {
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PLAYBACK_STAT]);
int totalTicks=e->getTotalTicks();
int hz=e->getHz();
ImGui::Text("| Speed %d:%d | Order %d/%d | Row %d/%d | %d:%.2d:%.2d.%.2d",e->getSpeed1(),e->getSpeed2(),e->getOrder(),e->song.ordersLen,e->getRow(),e->song.patLen,totalTicks/(hz*3600),(totalTicks/(hz*60))%60,(totalTicks/hz)%60,(totalTicks%hz)*100/hz);
ImGui::PopStyleColor();
}
ImGui::EndMainMenuBar(); ImGui::EndMainMenuBar();
ImGui::DockSpaceOverViewport(); ImGui::DockSpaceOverViewport();
@ -2328,6 +2335,7 @@ FurnaceGUI::FurnaceGUI():
uiColors[GUI_COLOR_PATTERN_EFFECT_SYS_SECONDARY]=ImVec4(0.0f,1.0f,0.5f,1.0f); uiColors[GUI_COLOR_PATTERN_EFFECT_SYS_SECONDARY]=ImVec4(0.0f,1.0f,0.5f,1.0f);
uiColors[GUI_COLOR_PATTERN_EFFECT_MISC]=ImVec4(0.3f,0.3f,1.0f,1.0f); uiColors[GUI_COLOR_PATTERN_EFFECT_MISC]=ImVec4(0.3f,0.3f,1.0f,1.0f);
uiColors[GUI_COLOR_EE_VALUE]=ImVec4(0.0f,1.0f,1.0f,1.0f); uiColors[GUI_COLOR_EE_VALUE]=ImVec4(0.0f,1.0f,1.0f,1.0f);
uiColors[GUI_COLOR_PLAYBACK_STAT]=ImVec4(0.6f,0.6f,0.6f,1.0f);
for (int i=0; i<64; i++) { for (int i=0; i<64; i++) {
ImVec4 col1=uiColors[GUI_COLOR_PATTERN_VOLUME_MIN]; ImVec4 col1=uiColors[GUI_COLOR_PATTERN_VOLUME_MIN];

View file

@ -31,6 +31,7 @@ enum FurnaceGUIColors {
GUI_COLOR_PATTERN_EFFECT_SYS_SECONDARY, GUI_COLOR_PATTERN_EFFECT_SYS_SECONDARY,
GUI_COLOR_PATTERN_EFFECT_MISC, GUI_COLOR_PATTERN_EFFECT_MISC,
GUI_COLOR_EE_VALUE, GUI_COLOR_EE_VALUE,
GUI_COLOR_PLAYBACK_STAT,
GUI_COLOR_MAX GUI_COLOR_MAX
}; };