MinMod: Fix CPU usage warning

This commit is contained in:
Natt Akuma 2024-03-18 12:22:38 +07:00
parent 21eed3e512
commit 01db0f7e54
2 changed files with 4 additions and 3 deletions

View file

@ -219,10 +219,10 @@ void DivPlatformGBAMinMod::acquire(short** buf, size_t len) {
void DivPlatformGBAMinMod::tick(bool sysTick) {
// collect stats for display in chip config
// logV("rendered=%d,updTot=%d",sampsRendered,updCyclesTotal);
if (sysTick && sampsRendered>0) {
if (sysTick && updCyclesTotal>0) {
// assuming new sample, L!=R and lowest ROM access wait in all channels
// this gives 39.5 cycles/sample, rounded up to 40 for loops
maxCPU=(float)sampsRendered*chanMax*40/updCyclesTotal;
maxCPU=(float)sampsRendered*chanMax*40/(float)updCyclesTotal;
}
sampsRendered=0;
updCyclesTotal=0;

View file

@ -448,8 +448,9 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl
DivPlatformGBAMinMod* dispatch=(DivPlatformGBAMinMod*)e->getDispatch(chan);
float maxCPU=dispatch->maxCPU*100;
ImGui::Text("Actual sample rate: %d Hz", dispatch->chipClock);
FurnaceGUI::pushWarningColor(maxCPU>90);
if (maxCPU>90) ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_WARNING]);
ImGui::Text("Max mixer CPU usage: %.0f%%", maxCPU);
if (maxCPU>90) ImGui::PopStyleColor();
FurnaceGUI::popWarningColor();
if (altered) {
e->lockSave([&]() {