1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-19 08:31:11 +00:00

Make ST RAM size selectable, default to 1MB.

This commit is contained in:
Thomas Harte 2022-08-10 12:00:06 -04:00
parent af7c56d313
commit 6d1c954623
2 changed files with 35 additions and 5 deletions

View File

@ -17,7 +17,18 @@ namespace Static {
namespace AtariST { namespace AtariST {
struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Target> { struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Target> {
Target() : Analyser::Static::Target(Machine::AtariST) {} ReflectableEnum(MemorySize,
FiveHundredAndTwelveKilobytes,
OneMegabyte,
FourMegabytes);
MemorySize memory_size = MemorySize::OneMegabyte;
Target() : Analyser::Static::Target(Machine::AtariST) {
if(needs_declare()) {
DeclareField(memory_size);
AnnounceEnum(MemorySize);
}
}
}; };
} }

View File

@ -35,12 +35,14 @@
#include "../../Utility/MemoryPacker.hpp" #include "../../Utility/MemoryPacker.hpp"
#include "../../Utility/MemoryFuzzer.hpp" #include "../../Utility/MemoryFuzzer.hpp"
#include "../../../Analyser/Static/AtariST/Target.hpp"
namespace Atari { namespace Atari {
namespace ST { namespace ST {
constexpr int CLOCK_RATE = 8021247; constexpr int CLOCK_RATE = 8021247;
using Target = Analyser::Static::Target; using Target = Analyser::Static::AtariST::Target;
class ConcreteMachine: class ConcreteMachine:
public Atari::ST::Machine, public Atari::ST::Machine,
public CPU::MC68000Mk2::BusHandler, public CPU::MC68000Mk2::BusHandler,
@ -70,10 +72,22 @@ class ConcreteMachine:
set_clock_rate(CLOCK_RATE); set_clock_rate(CLOCK_RATE);
speaker_.set_input_rate(float(CLOCK_RATE) / 4.0f); speaker_.set_input_rate(float(CLOCK_RATE) / 4.0f);
ram_.resize(512 * 1024); // i.e. 512kb switch(target.memory_size) {
video_->set_ram(reinterpret_cast<uint16_t *>(ram_.data()), ram_.size()); default:
case Target::MemorySize::FiveHundredAndTwelveKilobytes:
ram_.resize(512 * 1024);
break;
case Target::MemorySize::OneMegabyte:
ram_.resize(1024 * 1024);
break;
case Target::MemorySize::FourMegabytes:
ram_.resize(4 * 1024 * 1024);
break;
}
Memory::Fuzz(ram_); Memory::Fuzz(ram_);
video_->set_ram(reinterpret_cast<uint16_t *>(ram_.data()), ram_.size());
constexpr ROM::Name rom_name = ROM::Name::AtariSTTOS100; constexpr ROM::Name rom_name = ROM::Name::AtariSTTOS100;
ROM::Request request(rom_name); ROM::Request request(rom_name);
auto roms = rom_fetcher(request); auto roms = rom_fetcher(request);
@ -685,7 +699,12 @@ class ConcreteMachine:
using namespace Atari::ST; using namespace Atari::ST;
Machine *Machine::AtariST(const Analyser::Static::Target *target, const ROMMachine::ROMFetcher &rom_fetcher) { Machine *Machine::AtariST(const Analyser::Static::Target *target, const ROMMachine::ROMFetcher &rom_fetcher) {
return new ConcreteMachine(*target, rom_fetcher); auto *const atari_target = dynamic_cast<const Analyser::Static::AtariST::Target *>(target);
if(!atari_target) {
return nullptr;
}
return new ConcreteMachine(*atari_target, rom_fetcher);
} }
Machine::~Machine() {} Machine::~Machine() {}