Skip to content

Commit

Permalink
fix clock overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tildearrow committed Oct 12, 2023
1 parent 6118e75 commit 40da2ec
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/engine/playback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
}
if (totalTicks>=1000000) {
totalTicks-=1000000;
totalSeconds++;
if (totalSeconds<0x7fffffff) totalSeconds++;
cmdsPerSecond=totalCmds-lastCmds;
lastCmds=totalCmds;
}
Expand Down
38 changes: 37 additions & 1 deletion src/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4412,7 +4412,43 @@ bool FurnaceGUI::loop() {
info+=fmt::sprintf("| Row %d/%d ",oldRow,e->curSubSong->patLen);
}

info+=fmt::sprintf("| %d:%.2d:%.2d.%.2d",totalSeconds/3600,(totalSeconds/60)%60,totalSeconds%60,totalTicks/10000);
info+="| ";

if (totalSeconds==0x7fffffff) {
info+="Don't you have anything better to do?";
} else {
if (totalSeconds>=86400) {
int totalDays=totalSeconds/86400;
int totalYears=totalDays/365;
totalDays%=365;
int totalMonths=totalDays/30;
totalDays%=30;

if (totalYears>1) {
info+=fmt::sprintf("%d years ",totalYears);
} else if (totalYears) {
info+=fmt::sprintf("%d year ",totalYears);
}

if (totalMonths>1) {
info+=fmt::sprintf("%d months ",totalMonths);
} else if (totalMonths) {
info+=fmt::sprintf("%d month ",totalMonths);
}

if (totalDays>1) {
info+=fmt::sprintf("%d days ",totalDays);
} else {
info+=fmt::sprintf("%d day ",totalDays);
}
}

if (totalSeconds>=3600) {
info+=fmt::sprintf("%.2d:",(totalSeconds/3600)%24);
}

info+=fmt::sprintf("%.2d:%.2d.%.2d",(totalSeconds/60)%60,totalSeconds%60,totalTicks/10000);
}

ImGui::TextUnformatted(info.c_str());
} else {
Expand Down

0 comments on commit 40da2ec

Please sign in to comment.