mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Commutes Vic-20 machine configuration options to its Target.
This commit is contained in:
parent
8067bf548a
commit
a2da51c30b
@ -22,7 +22,16 @@ struct Target: public ::Analyser::Static::Target {
|
||||
ThirtyTwoKB
|
||||
};
|
||||
|
||||
enum class Region {
|
||||
American,
|
||||
Danish,
|
||||
Japanese,
|
||||
European,
|
||||
Swedish
|
||||
};
|
||||
|
||||
MemoryModel memory_model = MemoryModel::Unexpanded;
|
||||
Region region = Region::European;
|
||||
bool has_c1540 = false;
|
||||
};
|
||||
|
||||
|
@ -368,24 +368,12 @@ class ConcreteMachine:
|
||||
}
|
||||
|
||||
void configure_as_target(const Analyser::Static::Target *target) override final {
|
||||
auto *const commodore_target = dynamic_cast<const Analyser::Static::Commodore::Target *>(target);
|
||||
commodore_target_ = *dynamic_cast<const Analyser::Static::Commodore::Target *>(target);
|
||||
|
||||
if(target->loading_command.length()) {
|
||||
type_string(target->loading_command);
|
||||
}
|
||||
|
||||
switch(commodore_target->memory_model) {
|
||||
case Analyser::Static::Commodore::Target::MemoryModel::Unexpanded:
|
||||
set_memory_size(Default);
|
||||
break;
|
||||
case Analyser::Static::Commodore::Target::MemoryModel::EightKB:
|
||||
set_memory_size(ThreeKB);
|
||||
break;
|
||||
case Analyser::Static::Commodore::Target::MemoryModel::ThirtyTwoKB:
|
||||
set_memory_size(ThirtyTwoKB);
|
||||
break;
|
||||
}
|
||||
|
||||
if(target->media.disks.size()) {
|
||||
// construct the 1540
|
||||
c1540_.reset(new ::Commodore::C1540::Machine(Commodore::C1540::Machine::C1540));
|
||||
@ -439,16 +427,6 @@ class ConcreteMachine:
|
||||
return joysticks_;
|
||||
}
|
||||
|
||||
void set_memory_size(MemorySize size) override final {
|
||||
memory_size_ = size;
|
||||
needs_configuration_ = true;
|
||||
}
|
||||
|
||||
void set_region(Region region) override final {
|
||||
region_ = region;
|
||||
needs_configuration_ = true;
|
||||
}
|
||||
|
||||
void set_ntsc_6560() {
|
||||
set_clock_rate(1022727);
|
||||
if(mos6560_) {
|
||||
@ -465,9 +443,9 @@ class ConcreteMachine:
|
||||
}
|
||||
}
|
||||
|
||||
void configure_memory() {
|
||||
void set_memory_map(Analyser::Static::Commodore::Target::MemoryModel memory_model, Analyser::Static::Commodore::Target::Region region) {
|
||||
// Determine PAL/NTSC
|
||||
if(region_ == American || region_ == Japanese) {
|
||||
if(region == Analyser::Static::Commodore::Target::Region::American || region == Analyser::Static::Commodore::Target::Region::Japanese) {
|
||||
// NTSC
|
||||
set_ntsc_6560();
|
||||
} else {
|
||||
@ -479,13 +457,14 @@ class ConcreteMachine:
|
||||
memset(processor_write_memory_map_, 0, sizeof(processor_write_memory_map_));
|
||||
memset(mos6560_->video_memory_map, 0, sizeof(mos6560_->video_memory_map));
|
||||
|
||||
switch(memory_size_) {
|
||||
switch(memory_model) {
|
||||
default: break;
|
||||
case ThreeKB:
|
||||
case Analyser::Static::Commodore::Target::MemoryModel::EightKB:
|
||||
// TODO: is this 3kb or 8kb?
|
||||
write_to_map(processor_read_memory_map_, expansion_ram_, 0x0000, 0x1000);
|
||||
write_to_map(processor_write_memory_map_, expansion_ram_, 0x0000, 0x1000);
|
||||
break;
|
||||
case ThirtyTwoKB:
|
||||
case Analyser::Static::Commodore::Target::MemoryModel::ThirtyTwoKB:
|
||||
write_to_map(processor_read_memory_map_, expansion_ram_, 0x0000, 0x8000);
|
||||
write_to_map(processor_write_memory_map_, expansion_ram_, 0x0000, 0x8000);
|
||||
break;
|
||||
@ -508,24 +487,24 @@ class ConcreteMachine:
|
||||
|
||||
ROM character_rom;
|
||||
ROM kernel_rom;
|
||||
switch(region_) {
|
||||
switch(region) {
|
||||
default:
|
||||
character_rom = CharactersEnglish;
|
||||
kernel_rom = KernelPAL;
|
||||
break;
|
||||
case American:
|
||||
case Analyser::Static::Commodore::Target::Region::American:
|
||||
character_rom = CharactersEnglish;
|
||||
kernel_rom = KernelNTSC;
|
||||
break;
|
||||
case Danish:
|
||||
case Analyser::Static::Commodore::Target::Region::Danish:
|
||||
character_rom = CharactersDanish;
|
||||
kernel_rom = KernelDanish;
|
||||
break;
|
||||
case Japanese:
|
||||
case Analyser::Static::Commodore::Target::Region::Japanese:
|
||||
character_rom = CharactersJapanese;
|
||||
kernel_rom = KernelJapanese;
|
||||
break;
|
||||
case Swedish:
|
||||
case Analyser::Static::Commodore::Target::Region::Swedish:
|
||||
character_rom = CharactersSwedish;
|
||||
kernel_rom = KernelSwedish;
|
||||
break;
|
||||
@ -648,10 +627,6 @@ class ConcreteMachine:
|
||||
}
|
||||
|
||||
void run_for(const Cycles cycles) override final {
|
||||
if(needs_configuration_) {
|
||||
needs_configuration_ = false;
|
||||
configure_memory();
|
||||
}
|
||||
m6502_.run_for(cycles);
|
||||
}
|
||||
|
||||
@ -659,7 +634,7 @@ class ConcreteMachine:
|
||||
mos6560_.reset(new Vic6560());
|
||||
mos6560_->set_high_frequency_cutoff(1600); // There is a 1.6Khz low-pass filter in the Vic-20.
|
||||
// Make a guess: PAL. Without setting a clock rate the 6560 isn't fully set up so contractually something must be set.
|
||||
set_pal_6560();
|
||||
set_memory_map(commodore_target_.memory_model, commodore_target_.region);
|
||||
}
|
||||
|
||||
void close_output() override final {
|
||||
@ -718,6 +693,8 @@ class ConcreteMachine:
|
||||
}
|
||||
|
||||
private:
|
||||
Analyser::Static::Commodore::Target commodore_target_;
|
||||
|
||||
CPU::MOS6502::Processor<ConcreteMachine, false> m6502_;
|
||||
|
||||
std::vector<uint8_t> roms_[9];
|
||||
@ -748,10 +725,6 @@ class ConcreteMachine:
|
||||
}
|
||||
}
|
||||
|
||||
Region region_ = European;
|
||||
MemorySize memory_size_ = MemorySize::Default;
|
||||
bool needs_configuration_ = true;
|
||||
|
||||
Commodore::Vic20::KeyboardMapper keyboard_mapper_;
|
||||
std::vector<std::unique_ptr<Inputs::Joystick>> joysticks_;
|
||||
|
||||
|
@ -14,20 +14,6 @@
|
||||
namespace Commodore {
|
||||
namespace Vic20 {
|
||||
|
||||
enum MemorySize {
|
||||
Default,
|
||||
ThreeKB,
|
||||
ThirtyTwoKB
|
||||
};
|
||||
|
||||
enum Region {
|
||||
American,
|
||||
Danish,
|
||||
Japanese,
|
||||
European,
|
||||
Swedish
|
||||
};
|
||||
|
||||
/// @returns The options available for a Vic-20.
|
||||
std::vector<std::unique_ptr<Configurable::Option>> get_options();
|
||||
|
||||
@ -37,12 +23,6 @@ class Machine {
|
||||
|
||||
/// Creates and returns a Vic-20.
|
||||
static Machine *Vic20();
|
||||
|
||||
/// Sets the memory size of this Vic-20.
|
||||
virtual void set_memory_size(MemorySize size) = 0;
|
||||
|
||||
/// Sets the region of this Vic-20.
|
||||
virtual void set_region(Region region) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user