Fix and hook up speed setting.

This commit is contained in:
Christian Speckner 2024-08-11 15:21:47 +02:00
parent 22af25e77c
commit 91044b3b4f
4 changed files with 30 additions and 24 deletions

View File

@ -125,6 +125,7 @@ void DevSettingsHandler::saveSettings(SettingsSet set)
#endif
// Thumb ARM emulation exception
settings.setValue("dev.thumb.trapfatal", myThumbException[set]);
settings.setValue("dev.arm.mips", myArmSpeed[set]);
}
// AtariVox/SaveKey/PlusROM access

View File

@ -203,7 +203,21 @@ namespace {
default:
throw runtime_error("invalid system type");
}
}
}
uInt32 get6502SpeedHz(ConsoleTiming timing) {
switch (timing) {
case ConsoleTiming::ntsc:
return 262 * 76 * 60;
case ConsoleTiming::pal:
case ConsoleTiming::secam:
return 312 * 76 * 50;
default:
throw runtime_error("invalid console timing");
}
}
} // namespace
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -232,11 +246,15 @@ void CartridgeELF::reset()
{
const bool devMode = mySettings.getBool("dev.settings");
const bool strictMode = devMode && mySettings.getBool("dev.thumb.trapfatal");
const uInt32 mips = devMode ? mySettings.getInt("dev.arm.mips") : MIPS_MAX;
std::fill_n(myLastPeekResult.get(), 0x1000, 0);
myIsBusDriven = false;
myDriveBusValue = 0;
myArmCyclesOffset = 0;
myArmCyclesPer6502Cycle = (mips * 1000000) / get6502SpeedHz(myConsoleTiming);
cout << myArmCyclesPer6502Cycle << std::endl;
mySystemType = determineSystemType(myProperties);
myLinker->relink(externalSymbols(mySystemType));
@ -530,22 +548,6 @@ void CartridgeELF::setupMemoryMap(bool strictMode)
myFallbackDelegate.setErrorsAreFatal(strictMode);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeELF::getCoreClock() const
{
switch (myConsoleTiming) {
case ConsoleTiming::ntsc:
return myArmCyclesPer6502Cycle * 262 * 76 * 60;
case ConsoleTiming::pal:
case ConsoleTiming::secam:
return myArmCyclesPer6502Cycle * 312 * 76 * 50;
default:
throw runtime_error("invalid console timing");
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeELF::switchExecutionStage()
{
@ -603,7 +605,7 @@ void CartridgeELF::callMain()
err |= myCortexEmu.write32(sp, 0);
sp -= 4;
err |= myCortexEmu.write32(sp, getCoreClock());
err |= myCortexEmu.write32(sp, myArmCyclesPer6502Cycle * get6502SpeedHz(myConsoleTiming));
sp -= 4;
err |= myCortexEmu.write32(sp, getSystemTypeParam(mySystemType));

View File

@ -29,6 +29,10 @@
class ElfLinker;
class CartridgeELF: public Cartridge {
public:
static constexpr uInt32 MIPS_MAX = 300;
static constexpr uInt32 MIPS_MIN = 50;
public:
CartridgeELF(const ByteBuffer& image, size_t size, string_view md5,
const Settings& settings);
@ -102,8 +106,6 @@ class CartridgeELF: public Cartridge {
void allocationSections();
void setupMemoryMap(bool strictMode);
uInt32 getCoreClock() const;
void switchExecutionStage();
void callFn(uInt32 ptr, uInt32 sp);
void callMain();
@ -138,7 +140,7 @@ class CartridgeELF: public Cartridge {
BusFallbackDelegate myFallbackDelegate;
ConsoleTiming myConsoleTiming{ConsoleTiming::ntsc};
uInt32 myArmCyclesPer6502Cycle{160};
uInt32 myArmCyclesPer6502Cycle{100};
Int64 myArmCyclesOffset{0};

View File

@ -35,6 +35,7 @@
#include "StateManager.hxx"
#include "RewindManager.hxx"
#include "M6502.hxx"
#include "CartELF.hxx"
#ifdef DEBUGGER_SUPPORT
#include "Debugger.hxx"
#include "DebuggerDialog.hxx"
@ -226,8 +227,8 @@ void DeveloperDialog::addEmulationTab(const GUI::Font& font)
myArmSpeedWidget = new SliderWidget(myTab, font, HBORDER + INDENT * 1, ypos - 1,
fontWidth * 10, lineHeight, "Limit ARM speed ",
0, kArmSpeedChanged, fontWidth * 9, " MIPS");
myArmSpeedWidget->setMinValue(50); // TODO: use constant
myArmSpeedWidget->setMaxValue(250); // TODO: use constant
myArmSpeedWidget->setMinValue(CartridgeELF::MIPS_MIN); // TODO: use constant
myArmSpeedWidget->setMaxValue(CartridgeELF::MIPS_MAX); // TODO: use constant
myArmSpeedWidget->setTickmarkIntervals(4);
myArmSpeedWidget->setStepValue(2);
myArmSpeedWidget->setToolTip("Limit emulation speed to simulate ARM CPU used.");