diff --git a/Core/BaseRenderer.cpp b/Core/BaseRenderer.cpp index a50eacc..ceae15b 100644 --- a/Core/BaseRenderer.cpp +++ b/Core/BaseRenderer.cpp @@ -145,10 +145,8 @@ void BaseRenderer::ShowFpsCounter(int lineNumber) void BaseRenderer::ShowGameTimer(int lineNumber) { int yPos = 13 + 24 * lineNumber; - shared_ptr ppu = _console->GetPpu(); uint32_t frameCount = _console->GetFrameCount(); - bool isPal = _console->GetRegion() == ConsoleRegion::Pal; - double frameRate = isPal ? 50.006977968268290848936010226333 : 60.098811862348404716732985230828; + double frameRate = _console->GetFps(); uint32_t seconds = (uint32_t)(frameCount / frameRate) % 60; uint32_t minutes = (uint32_t)(frameCount / frameRate / 60) % 60; uint32_t hours = (uint32_t)(frameCount / frameRate / 3600); diff --git a/Core/Console.cpp b/Core/Console.cpp index 69bb3af..3501cb2 100644 --- a/Core/Console.cpp +++ b/Core/Console.cpp @@ -4,13 +4,14 @@ #include "Ppu.h" #include "Spc.h" #include "NecDsp.h" -#include "Gameboy.h" #include "InternalRegisters.h" #include "ControlManager.h" #include "MemoryManager.h" #include "DmaController.h" #include "BaseCartridge.h" #include "RamHandler.h" +#include "Gameboy.h" +#include "GbPpu.h" #include "Debugger.h" #include "DebugTypes.h" #include "NotificationManager.h" @@ -294,6 +295,8 @@ void Console::Stop(bool sendNotification) _notificationManager->SendNotification(ConsoleNotificationType::BeforeEmulationStop); } + _settings->ClearFlag(EmulationFlags::GameboyMode); + //Make sure we release both pointers to destroy the debugger before everything else _debugger.reset(); debugger.reset(); @@ -876,7 +879,8 @@ uint32_t Console::GetFrameCount() { shared_ptr cart = _cart; if(_settings->CheckFlag(EmulationFlags::GameboyMode) && cart->GetGameboy()) { - return cart->GetGameboy()->GetState().Ppu.FrameCount; + GbPpu* ppu = cart->GetGameboy()->GetPpu(); + return ppu ? ppu->GetFrameCount() : 0; } else { shared_ptr ppu = _ppu; return ppu ? ppu->GetFrameCount() : 0; diff --git a/Core/GbPpu.cpp b/Core/GbPpu.cpp index 9559837..1dcae03 100644 --- a/Core/GbPpu.cpp +++ b/Core/GbPpu.cpp @@ -473,6 +473,11 @@ void GbPpu::GetPalette(uint16_t out[4], uint8_t palCfg) out[3] = bwRgbPalette[(palCfg >> 6) & 0x03]; } +uint32_t GbPpu::GetFrameCount() +{ + return _state.FrameCount; +} + void GbPpu::SendFrame() { _console->ProcessEvent(EventType::EndFrame); diff --git a/Core/GbPpu.h b/Core/GbPpu.h index 1520557..cfe6d9f 100644 --- a/Core/GbPpu.h +++ b/Core/GbPpu.h @@ -70,6 +70,7 @@ public: uint16_t* GetEventViewerBuffer(); uint16_t* GetPreviousEventViewerBuffer(); void GetPalette(uint16_t out[4], uint8_t palCfg); + uint32_t GetFrameCount(); void Exec();