1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +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 {
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/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<uint16_t *>(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<uint16_t *>(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<const Analyser::Static::AtariST::Target *>(target);
if(!atari_target) {
return nullptr;
}
return new ConcreteMachine(*atari_target, rom_fetcher);
}
Machine::~Machine() {}