1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-25 18:30:07 +00:00

Eliminates the generalised special case selectors and ROM suppliers from the CPC, Vic-20, Electron and ZX80/81.

This commit is contained in:
Thomas Harte 2017-11-24 17:55:28 -05:00
parent a8ac51da73
commit c83b3cefbc
11 changed files with 54 additions and 55 deletions

View File

@ -24,8 +24,18 @@
#include "../../ClockReceiver/ForceInline.hpp"
#include <cstdint>
#include <vector>
namespace AmstradCPC {
enum ROMType: int {
OS464 = 0, BASIC464,
OS664, BASIC664,
OS6128, BASIC6128,
AMSDOS
};
/*!
Models the CPC's interrupt timer. Inputs are vsync, hsync, interrupt acknowledge and reset, and its output
is simply yes or no on whether an interupt is currently requested. Internally it uses a counter with a period
@ -920,7 +930,7 @@ class ConcreteMachine:
}
// See header; provides the system ROMs.
void set_rom(ROMType type, const std::vector<uint8_t> &data) override final {
void set_rom(ROMType type, const std::vector<uint8_t> &data) {
roms_[static_cast<int>(type)] = data;
}

View File

@ -13,18 +13,8 @@
#include "../CRTMachine.hpp"
#include "../KeyboardMachine.hpp"
#include <cstdint>
#include <vector>
namespace AmstradCPC {
enum ROMType: int {
OS464 = 0, BASIC464,
OS664, BASIC664,
OS6128, BASIC6128,
AMSDOS
};
/*!
Models an Amstrad CPC.
*/
@ -37,9 +27,6 @@ class Machine:
/// Creates and returns an Amstrad CPC.
static Machine *AmstradCPC();
/// Sets the contents of rom @c type to @c data. Assumed to be a setup step; has no effect once a machine is running.
virtual void set_rom(ROMType type, const std::vector<uint8_t> &data) = 0;
};
}

View File

@ -27,10 +27,18 @@
#include "../../../Configurable/StandardOptions.hpp"
#include <algorithm>
#include <cstdint>
namespace Commodore {
namespace Vic20 {
enum ROMSlot {
Kernel = 0,
BASIC,
Characters,
Drive
};
std::vector<std::unique_ptr<Configurable::Option>> get_options() {
return Configurable::standard_options(Configurable::QuickLoadTape);
}
@ -304,7 +312,7 @@ class ConcreteMachine:
delete[] rom_;
}
void set_rom(ROMSlot slot, const std::vector<uint8_t> &data) override final {
void set_rom(ROMSlot slot, const std::vector<uint8_t> &data) {
}
// Obtains the system ROMs.
@ -502,7 +510,7 @@ class ConcreteMachine:
}
}
void set_use_fast_tape_hack(bool activate) override final {
void set_use_fast_tape_hack(bool activate) {
use_fast_tape_hack_ = activate;
}

View File

@ -15,18 +15,9 @@
#include "../../KeyboardMachine.hpp"
#include "../../JoystickMachine.hpp"
#include <cstdint>
namespace Commodore {
namespace Vic20 {
enum ROMSlot {
Kernel = 0,
BASIC,
Characters,
Drive
};
enum MemorySize {
Default,
ThreeKB,
@ -56,17 +47,11 @@ class Machine:
/// Creates and returns a Vic-20.
static Machine *Vic20();
/// Sets the contents of the rom in @c slot to the buffer @c data of length @c length.
virtual void set_rom(ROMSlot slot, const std::vector<uint8_t> &data) = 0;
/// 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;
/// Enables or disables turbo-speed tape loading.
virtual void set_use_fast_tape_hack(bool activate) = 0;
};
}

View File

@ -103,7 +103,7 @@ class ConcreteMachine:
if(is_holding_shift_) set_key_state(KeyShift, true);
}
void set_use_fast_tape_hack(bool activate) override final {
void set_use_fast_tape_hack(bool activate) {
use_fast_tape_hack_ = activate;
}

View File

@ -58,9 +58,6 @@ class Machine:
is enabled it acts as if it were sideways RAM. Otherwise the slot is modelled as containing ROM.
*/
virtual void set_rom(ROMSlot slot, const std::vector<uint8_t> &data, bool is_writeable) = 0;
/// Enables or disables turbo-speed tape loading.
virtual void set_use_fast_tape_hack(bool activate) = 0;
};
}

View File

@ -21,7 +21,9 @@
#include "Keyboard.hpp"
#include "Video.hpp"
#include <cstdint>
#include <memory>
#include <vector>
namespace {
// The clock rate is 3.25Mhz.
@ -30,6 +32,10 @@ namespace {
namespace ZX8081 {
enum ROMType: uint8_t {
ZX80 = 0, ZX81
};
std::vector<std::unique_ptr<Configurable::Option>> get_options() {
return Configurable::standard_options(
static_cast<Configurable::StandardOptions>(Configurable::AutomaticTapeMotorControl | Configurable::QuickLoadTape)
@ -291,7 +297,7 @@ template<bool is_zx81> class ConcreteMachine:
Utility::TypeRecipient::set_typer_for_string(string, std::move(mapper));
}
void set_rom(ROMType type, const std::vector<uint8_t> &data) override final {
void set_rom(ROMType type, const std::vector<uint8_t> &data) {
switch(type) {
case ZX80: zx80_rom_ = data; break;
case ZX81: zx81_rom_ = data; break;
@ -328,11 +334,11 @@ template<bool is_zx81> class ConcreteMachine:
}
// MARK: - Tape control
void set_use_fast_tape_hack(bool activate) override final {
void set_use_fast_tape_hack(bool activate) {
use_fast_tape_hack_ = activate;
}
void set_use_automatic_tape_motor_control(bool enabled) override final {
void set_use_automatic_tape_motor_control(bool enabled) {
use_automatic_tape_motor_control_ = enabled;
if(!enabled) {
tape_player_.set_motor_control(false);

View File

@ -14,15 +14,8 @@
#include "../CRTMachine.hpp"
#include "../KeyboardMachine.hpp"
#include <cstdint>
#include <vector>
namespace ZX8081 {
enum ROMType: uint8_t {
ZX80 = 0, ZX81
};
/// @returns The options available for a ZX80 or ZX81.
std::vector<std::unique_ptr<Configurable::Option>> get_options();
@ -32,14 +25,11 @@ class Machine:
public KeyboardMachine::Machine,
public Configurable::Device {
public:
static Machine *ZX8081(const StaticAnalyser::Target &target_hint);
virtual ~Machine();
virtual void set_rom(ROMType type, const std::vector<uint8_t> &data) = 0;
static Machine *ZX8081(const StaticAnalyser::Target &target_hint);
virtual void set_use_fast_tape_hack(bool activate) = 0;
virtual void set_tape_is_playing(bool is_playing) = 0;
virtual void set_use_automatic_tape_motor_control(bool enabled) = 0;
};
}

View File

@ -9,7 +9,7 @@
#import "CSElectron.h"
#include "Electron.hpp"
#include "StandardOptions.hpp"
@implementation CSElectron {
std::unique_ptr<Electron::Machine> _electron;
@ -34,14 +34,20 @@
- (void)setUseFastLoadingHack:(BOOL)useFastLoadingHack {
@synchronized(self) {
_useFastLoadingHack = useFastLoadingHack;
_electron->set_use_fast_tape_hack(useFastLoadingHack ? true : false);
Configurable::SelectionSet selection_set;
append_quick_load_tape_selection(selection_set, useFastLoadingHack ? true : false);
_electron->set_selections(selection_set);
}
}
- (void)setUseTelevisionOutput:(BOOL)useTelevisionOutput {
@synchronized(self) {
_useTelevisionOutput = useTelevisionOutput;
_electron->get_crt()->set_output_device(useTelevisionOutput ? Outputs::CRT::OutputDevice::Television : Outputs::CRT::OutputDevice::Monitor);
Configurable::SelectionSet selection_set;
append_display_selection(selection_set, useTelevisionOutput ? Configurable::Display::Composite : Configurable::Display::RGB);
_electron->set_selections(selection_set);
}
}
@end

View File

@ -9,6 +9,7 @@
#import "CSVic20.h"
#include "Vic20.hpp"
#include "StandardOptions.hpp"
using namespace Commodore::Vic20;
@ -47,7 +48,9 @@ using namespace Commodore::Vic20;
- (void)setUseFastLoadingHack:(BOOL)useFastLoadingHack {
_useFastLoadingHack = useFastLoadingHack;
@synchronized(self) {
_vic20->set_use_fast_tape_hack(useFastLoadingHack ? true : false);
Configurable::SelectionSet selection_set;
append_quick_load_tape_selection(selection_set, useFastLoadingHack ? true : false);
_vic20->set_selections(selection_set);
}
}

View File

@ -9,6 +9,7 @@
#import "CSZX8081.h"
#include "ZX8081.hpp"
#include "StandardOptions.hpp"
@implementation CSZX8081 {
std::unique_ptr<ZX8081::Machine> _zx8081;
@ -31,7 +32,10 @@
- (void)setUseFastLoadingHack:(BOOL)useFastLoadingHack {
@synchronized(self) {
_useFastLoadingHack = useFastLoadingHack;
_zx8081->set_use_fast_tape_hack(useFastLoadingHack ? true : false);
Configurable::SelectionSet selection_set;
append_quick_load_tape_selection(selection_set, useFastLoadingHack ? true : false);
_zx8081->set_selections(selection_set);
}
}
@ -45,7 +49,10 @@
- (void)setUseAutomaticTapeMotorControl:(BOOL)useAutomaticTapeMotorControl {
@synchronized(self) {
_useAutomaticTapeMotorControl = useAutomaticTapeMotorControl;
_zx8081->set_use_automatic_tape_motor_control(useAutomaticTapeMotorControl ? true : false);
Configurable::SelectionSet selection_set;
append_automatic_tape_motor_control_selection(selection_set, useAutomaticTapeMotorControl ? true : false);
_zx8081->set_selections(selection_set);
}
}