From 6d1c9546232645af9a3708aad433cc453c0caf36 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 10 Aug 2022 12:00:06 -0400 Subject: [PATCH] Make ST RAM size selectable, default to 1MB. --- Analyser/Static/AtariST/Target.hpp | 13 ++++++++++++- Machines/Atari/ST/AtariST.cpp | 27 +++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/Analyser/Static/AtariST/Target.hpp b/Analyser/Static/AtariST/Target.hpp index fd025baf8..b4d01279f 100644 --- a/Analyser/Static/AtariST/Target.hpp +++ b/Analyser/Static/AtariST/Target.hpp @@ -17,7 +17,18 @@ namespace Static { namespace AtariST { struct Target: public Analyser::Static::Target, public Reflection::StructImpl { - 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); + } + } }; } diff --git a/Machines/Atari/ST/AtariST.cpp b/Machines/Atari/ST/AtariST.cpp index f72647ef4..5a350f03d 100644 --- a/Machines/Atari/ST/AtariST.cpp +++ b/Machines/Atari/ST/AtariST.cpp @@ -35,12 +35,14 @@ #include "../../Utility/MemoryPacker.hpp" #include "../../Utility/MemoryFuzzer.hpp" +#include "../../../Analyser/Static/AtariST/Target.hpp" + namespace Atari { namespace ST { constexpr int CLOCK_RATE = 8021247; -using Target = Analyser::Static::Target; +using Target = Analyser::Static::AtariST::Target; class ConcreteMachine: public Atari::ST::Machine, public CPU::MC68000Mk2::BusHandler, @@ -70,10 +72,22 @@ class ConcreteMachine: set_clock_rate(CLOCK_RATE); speaker_.set_input_rate(float(CLOCK_RATE) / 4.0f); - ram_.resize(512 * 1024); // i.e. 512kb - video_->set_ram(reinterpret_cast(ram_.data()), ram_.size()); + switch(target.memory_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_); + video_->set_ram(reinterpret_cast(ram_.data()), ram_.size()); + constexpr ROM::Name rom_name = ROM::Name::AtariSTTOS100; ROM::Request request(rom_name); auto roms = rom_fetcher(request); @@ -685,7 +699,12 @@ class ConcreteMachine: using namespace Atari::ST; 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(target); + if(!atari_target) { + return nullptr; + } + + return new ConcreteMachine(*atari_target, rom_fetcher); } Machine::~Machine() {}