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/InstructionSets/PowerPC/Decoder.cpp b/InstructionSets/PowerPC/Decoder.cpp index 2c740a54a..bcb619866 100644 --- a/InstructionSets/PowerPC/Decoder.cpp +++ b/InstructionSets/PowerPC/Decoder.cpp @@ -595,10 +595,10 @@ Instruction Decoder::decode(uint32_t opcode) { return Instruction(opcode); } -template class InstructionSet::PowerPC::Decoder; -template class InstructionSet::PowerPC::Decoder; -template class InstructionSet::PowerPC::Decoder; +template struct InstructionSet::PowerPC::Decoder; +template struct InstructionSet::PowerPC::Decoder; +template struct InstructionSet::PowerPC::Decoder; -template class InstructionSet::PowerPC::Decoder; -template class InstructionSet::PowerPC::Decoder; -template class InstructionSet::PowerPC::Decoder; +template struct InstructionSet::PowerPC::Decoder; +template struct InstructionSet::PowerPC::Decoder; +template struct InstructionSet::PowerPC::Decoder; diff --git a/Machines/Atari/ST/AtariST.cpp b/Machines/Atari/ST/AtariST.cpp index f72647ef4..6925ad85a 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,25 @@ 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() >> 1 + ); + constexpr ROM::Name rom_name = ROM::Name::AtariSTTOS100; ROM::Request request(rom_name); auto roms = rom_fetcher(request); @@ -685,7 +702,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() {} diff --git a/Machines/Atari/ST/Video.cpp b/Machines/Atari/ST/Video.cpp index a0a841e82..7549c857c 100644 --- a/Machines/Atari/ST/Video.cpp +++ b/Machines/Atari/ST/Video.cpp @@ -130,8 +130,9 @@ Video::Video() : crt_.set_visible_area(crt_.get_rect_for_area(33, 260, 440, 1700, 4.0f / 3.0f)); } -void Video::set_ram(uint16_t *ram, size_t) { +void Video::set_ram(uint16_t *ram, size_t size) { ram_ = ram; + ram_mask_ = int(size - 1); } void Video::set_scan_target(Outputs::Display::ScanTarget *scan_target) { @@ -202,7 +203,7 @@ void Video::run_for(HalfCycles duration) { const int end_column = (since_load + run_length - 1) >> 3; while(start_column != end_column) { - data_latch_[data_latch_position_] = ram_[current_address_ & 262143]; + data_latch_[data_latch_position_] = ram_[current_address_ & ram_mask_]; data_latch_position_ = (data_latch_position_ + 1) & 127; ++current_address_; ++start_column; diff --git a/Machines/Atari/ST/Video.hpp b/Machines/Atari/ST/Video.hpp index 867d6c632..a467c33cc 100644 --- a/Machines/Atari/ST/Video.hpp +++ b/Machines/Atari/ST/Video.hpp @@ -37,7 +37,7 @@ class Video { Video(); /*! - Sets the memory pool that provides video, and its size. + Sets the memory pool that provides video, and its size in words. */ void set_ram(uint16_t *, size_t size); @@ -138,6 +138,7 @@ class Video { int current_address_ = 0; uint16_t *ram_ = nullptr; + int ram_mask_ = 0; int x_ = 0, y_ = 0, next_y_ = 0; bool load_ = false; diff --git a/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.h b/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.h index 970dbf641..4f96141f6 100644 --- a/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.h +++ b/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.h @@ -128,7 +128,7 @@ typedef int Kilobytes; - (instancetype)initWithAmstradCPCModel:(CSMachineCPCModel)model; - (instancetype)initWithAppleIIModel:(CSMachineAppleIIModel)model diskController:(CSMachineAppleIIDiskController)diskController; - (instancetype)initWithAppleIIgsModel:(CSMachineAppleIIgsModel)model memorySize:(Kilobytes)memorySize; -- (instancetype)initWithAtariSTModel:(CSMachineAtariSTModel)model; +- (instancetype)initWithAtariSTModel:(CSMachineAtariSTModel)model memorySize:(Kilobytes)memorySize; - (instancetype)initWithElectronDFS:(BOOL)dfs adfs:(BOOL)adfs ap6:(BOOL)ap6 sidewaysRAM:(BOOL)sidewaysRAM; - (instancetype)initWithEnterpriseModel:(CSMachineEnterpriseModel)model speed:(CSMachineEnterpriseSpeed)speed exosVersion:(CSMachineEnterpriseEXOS)exosVersion basicVersion:(CSMachineEnterpriseBASIC)basicVersion dos:(CSMachineEnterpriseDOS)dos; - (instancetype)initWithMacintoshModel:(CSMachineMacintoshModel)model; diff --git a/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm b/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm index 5da15a508..964dd8612 100644 --- a/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm +++ b/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm @@ -135,11 +135,16 @@ } -- (instancetype)initWithAtariSTModel:(CSMachineAtariSTModel)model { +- (instancetype)initWithAtariSTModel:(CSMachineAtariSTModel)model memorySize:(Kilobytes)memorySize { self = [super init]; if(self) { using Target = Analyser::Static::AtariST::Target; auto target = std::make_unique(); + switch(memorySize) { + default: target->memory_size = Target::MemorySize::FiveHundredAndTwelveKilobytes; break; + case 1024: target->memory_size = Target::MemorySize::OneMegabyte; break; + case 4096: target->memory_size = Target::MemorySize::FourMegabytes; break; + } _targets.push_back(std::move(target)); } return self; diff --git a/OSBindings/Mac/Clock Signal/MachinePicker/Base.lproj/MachinePicker.xib b/OSBindings/Mac/Clock Signal/MachinePicker/Base.lproj/MachinePicker.xib index 51d26aa1c..a1a5ebc4e 100644 --- a/OSBindings/Mac/Clock Signal/MachinePicker/Base.lproj/MachinePicker.xib +++ b/OSBindings/Mac/Clock Signal/MachinePicker/Base.lproj/MachinePicker.xib @@ -1,8 +1,8 @@ - + - + @@ -300,22 +300,39 @@ Gw - + - - - - + + + + - + + + + + + + + + + + + + + + - - - + + + + + + @@ -959,6 +976,7 @@ Gw + diff --git a/OSBindings/Mac/Clock Signal/MachinePicker/MachinePicker.swift b/OSBindings/Mac/Clock Signal/MachinePicker/MachinePicker.swift index d6749071a..b70d4c3df 100644 --- a/OSBindings/Mac/Clock Signal/MachinePicker/MachinePicker.swift +++ b/OSBindings/Mac/Clock Signal/MachinePicker/MachinePicker.swift @@ -31,6 +31,9 @@ class MachinePicker: NSObject, NSTableViewDataSource, NSTableViewDelegate { @IBOutlet var appleIIgsModelButton: NSPopUpButton! @IBOutlet var appleIIgsMemorySizeButton: NSPopUpButton! + // MARK: - Atari ST properties + @IBOutlet var atariSTMemorySizeButton: NSPopUpButton! + // MARK: - CPC properties @IBOutlet var cpcModelTypeButton: NSPopUpButton! @@ -108,6 +111,9 @@ class MachinePicker: NSObject, NSTableViewDataSource, NSTableViewDelegate { appleIIgsModelButton.selectItem(withTag: standardUserDefaults.integer(forKey: "new.appleIIgsModel")) appleIIgsMemorySizeButton.selectItem(withTag: standardUserDefaults.integer(forKey: "new.appleIIgsMemorySize")) + // Atari ST settings + atariSTMemorySizeButton.selectItem(withTag: standardUserDefaults.integer(forKey: "new.atariSTMemorySize")) + // CPC settings cpcModelTypeButton.selectItem(withTag: standardUserDefaults.integer(forKey: "new.cpcModel")) @@ -169,6 +175,9 @@ class MachinePicker: NSObject, NSTableViewDataSource, NSTableViewDelegate { standardUserDefaults.set(appleIIgsModelButton.selectedTag(), forKey: "new.appleIIgsModel") standardUserDefaults.set(appleIIgsMemorySizeButton.selectedTag(), forKey: "new.appleIIgsMemorySize") + // Atari ST settings + standardUserDefaults.set(atariSTMemorySizeButton.selectedTag(), forKey: "new.atariSTMemorySize") + // CPC settings standardUserDefaults.set(cpcModelTypeButton.selectedTag(), forKey: "new.cpcModel") @@ -275,7 +284,8 @@ class MachinePicker: NSObject, NSTableViewDataSource, NSTableViewDelegate { return CSStaticAnalyser(appleIIgsModel: model, memorySize: memorySize) case "atarist": - return CSStaticAnalyser(atariSTModel: .model512k) + let memorySize = Kilobytes(atariSTMemorySizeButton.selectedTag()) + return CSStaticAnalyser(atariSTModel: .model512k, memorySize: memorySize) case "cpc": switch cpcModelTypeButton.selectedTag() { diff --git a/OSBindings/Qt/mainwindow.cpp b/OSBindings/Qt/mainwindow.cpp index 39a1b646a..6eae7d315 100644 --- a/OSBindings/Qt/mainwindow.cpp +++ b/OSBindings/Qt/mainwindow.cpp @@ -1069,7 +1069,11 @@ void MainWindow::start_atariST() { using Target = Analyser::Static::AtariST::Target; auto target = std::make_unique(); - /* There are no options yet for an Atari ST. */ + switch(ui->atariSTRAMComboBox->currentIndex()) { + default: target->memory_size = Target::MemorySize::FiveHundredAndTwelveKilobytes; break; + case 1: target->memory_size = Target::MemorySize::OneMegabyte; break; + case 2: target->memory_size = Target::MemorySize::FourMegabytes; break; + } launchTarget(std::move(target)); } @@ -1274,7 +1278,8 @@ void MainWindow::launchTarget(std::unique_ptr &&target /* Amstrad CPC. */ \ ComboBox(amstradCPCModelComboBox, "amstradcpc.model"); \ \ - /* Atari ST: nothing */ \ + /* Atari ST. */ \ + ComboBox(atariSTRAMComboBox, "atarist.memorySize"); \ \ /* Electron. */ \ CheckBox(electronDFSCheckBox, "electron.hasDFS"); \ diff --git a/OSBindings/Qt/mainwindow.ui b/OSBindings/Qt/mainwindow.ui index 3d05cc783..511df37ea 100644 --- a/OSBindings/Qt/mainwindow.ui +++ b/OSBindings/Qt/mainwindow.ui @@ -343,12 +343,39 @@ Atari ST - - - - At present only a 512k Atari ST is supported. - - + + + + + + + + RAM: + + + + + + + + 512 kb + + + + + 1 mb + + + + + 4 mb + + + + + + +