mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-11 15:49:38 +00:00
Add const
s widely.
This commit is contained in:
parent
8e71180cd2
commit
c14a4515ce
@ -46,7 +46,7 @@ enum ROMSlot {
|
||||
Kernel = 0,
|
||||
BASIC,
|
||||
Characters,
|
||||
Drive
|
||||
Drive,
|
||||
};
|
||||
|
||||
enum JoystickInput {
|
||||
@ -54,7 +54,7 @@ enum JoystickInput {
|
||||
Down = 0x08,
|
||||
Left = 0x10,
|
||||
Right = 0x80,
|
||||
Fire = 0x20
|
||||
Fire = 0x20,
|
||||
};
|
||||
|
||||
/*!
|
||||
@ -67,7 +67,7 @@ public:
|
||||
UserPortVIA() : port_a_(0xbf) {}
|
||||
|
||||
/// Reports the current input to the 6522 port @c port.
|
||||
uint8_t get_port_input(MOS::MOS6522::Port port) {
|
||||
uint8_t get_port_input(const MOS::MOS6522::Port port) {
|
||||
// Port A provides information about the presence or absence of a tape, and parts of
|
||||
// the joystick and serial port state, both of which have been statefully collected
|
||||
// into port_a_.
|
||||
@ -78,7 +78,7 @@ public:
|
||||
}
|
||||
|
||||
/// Receives announcements of control line output change from the 6522.
|
||||
void set_control_line_output(MOS::MOS6522::Port port, MOS::MOS6522::Line line, bool value) {
|
||||
void set_control_line_output(const MOS::MOS6522::Port port, const MOS::MOS6522::Line line, const bool value) {
|
||||
// The CA2 output is used to control the tape motor.
|
||||
if(port == MOS::MOS6522::Port::A && line == MOS::MOS6522::Line::Two) {
|
||||
tape_->set_motor_control(!value);
|
||||
@ -86,7 +86,7 @@ public:
|
||||
}
|
||||
|
||||
/// Receives announcements of changes in the serial bus connected to the serial port and propagates them into Port A.
|
||||
void set_serial_line_state(::Commodore::Serial::Line line, bool value) {
|
||||
void set_serial_line_state(const ::Commodore::Serial::Line line, const bool value) {
|
||||
switch(line) {
|
||||
default: break;
|
||||
case ::Commodore::Serial::Line::Data: port_a_ = (port_a_ & ~0x02) | (value ? 0x02 : 0x00); break;
|
||||
@ -95,14 +95,14 @@ public:
|
||||
}
|
||||
|
||||
/// Allows the current joystick input to be set.
|
||||
void set_joystick_state(JoystickInput input, bool value) {
|
||||
void set_joystick_state(const JoystickInput input, const bool value) {
|
||||
if(input != JoystickInput::Right) {
|
||||
port_a_ = (port_a_ & ~input) | (value ? 0 : input);
|
||||
}
|
||||
}
|
||||
|
||||
/// Receives announcements from the 6522 of user-port output, which might affect what's currently being presented onto the serial bus.
|
||||
void set_port_output(MOS::MOS6522::Port port, uint8_t value, uint8_t) {
|
||||
void set_port_output(const MOS::MOS6522::Port port, const uint8_t value, uint8_t) {
|
||||
// Line 7 of port A is inverted and output as serial ATN.
|
||||
if(!port) {
|
||||
std::shared_ptr<::Commodore::Serial::Port> serialPort = serial_port_.lock();
|
||||
@ -137,7 +137,7 @@ public:
|
||||
}
|
||||
|
||||
/// Sets whether @c key @c is_pressed.
|
||||
void set_key_state(uint16_t key, bool is_pressed) {
|
||||
void set_key_state(const uint16_t key, const bool is_pressed) {
|
||||
if(is_pressed)
|
||||
columns_[key & 7] &= ~(key >> 3);
|
||||
else
|
||||
@ -150,7 +150,7 @@ public:
|
||||
}
|
||||
|
||||
/// Called by the 6522 to get input. Reads the keyboard on Port A, returns a small amount of joystick state on Port B.
|
||||
uint8_t get_port_input(MOS::MOS6522::Port port) {
|
||||
uint8_t get_port_input(const MOS::MOS6522::Port port) {
|
||||
if(!port) {
|
||||
uint8_t result = 0xff;
|
||||
for(int c = 0; c < 8; c++) {
|
||||
@ -164,12 +164,12 @@ public:
|
||||
}
|
||||
|
||||
/// Called by the 6522 to set output. The value of Port B selects which part of the keyboard to read.
|
||||
void set_port_output(MOS::MOS6522::Port port, uint8_t value, uint8_t mask) {
|
||||
void set_port_output(const MOS::MOS6522::Port port, const uint8_t value, const uint8_t mask) {
|
||||
if(port) activation_mask_ = (value & mask) | (~mask);
|
||||
}
|
||||
|
||||
/// Called by the 6522 to set control line output. Which affects the serial port.
|
||||
void set_control_line_output(MOS::MOS6522::Port port, MOS::MOS6522::Line line, bool value) {
|
||||
void set_control_line_output(const MOS::MOS6522::Port port, const MOS::MOS6522::Line line, const bool value) {
|
||||
if(line == MOS::MOS6522::Line::Two) {
|
||||
std::shared_ptr<::Commodore::Serial::Port> serialPort = serial_port_.lock();
|
||||
if(serialPort) {
|
||||
@ -183,7 +183,7 @@ public:
|
||||
}
|
||||
|
||||
/// Sets whether the joystick input @c input is pressed.
|
||||
void set_joystick_state(JoystickInput input, bool value) {
|
||||
void set_joystick_state(const JoystickInput input, const bool value) {
|
||||
if(input == JoystickInput::Right) {
|
||||
port_b_ = (port_b_ & ~input) | (value ? 0 : input);
|
||||
}
|
||||
@ -207,13 +207,13 @@ private:
|
||||
class SerialPort : public ::Commodore::Serial::Port {
|
||||
public:
|
||||
/// Receives an input change from the base serial port class, and communicates it to the user-port VIA.
|
||||
void set_input(::Commodore::Serial::Line line, ::Commodore::Serial::LineLevel level) {
|
||||
void set_input(const ::Commodore::Serial::Line line, const ::Commodore::Serial::LineLevel level) {
|
||||
std::shared_ptr<UserPortVIA> userPortVIA = user_port_via_.lock();
|
||||
if(userPortVIA) userPortVIA->set_serial_line_state(line, bool(level));
|
||||
}
|
||||
|
||||
/// Sets the user-port VIA with which this serial port communicates.
|
||||
void set_user_port_via(std::shared_ptr<UserPortVIA> userPortVIA) {
|
||||
void set_user_port_via(const std::shared_ptr<UserPortVIA> userPortVIA) {
|
||||
user_port_via_ = userPortVIA;
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ private:
|
||||
*/
|
||||
struct Vic6560BusHandler {
|
||||
/// Performs a read on behalf of the 6560; in practice uses @c video_memory_map and @c colour_memory to find data.
|
||||
forceinline void perform_read(uint16_t address, uint8_t *pixel_data, uint8_t *colour_data) {
|
||||
forceinline void perform_read(const uint16_t address, uint8_t *const pixel_data, uint8_t *const colour_data) {
|
||||
*pixel_data = video_memory_map[address >> 10] ? video_memory_map[address >> 10][address & 0x3ff] : 0xff; // TODO
|
||||
*colour_data = colour_memory[address & 0x03ff];
|
||||
}
|
||||
@ -234,6 +234,8 @@ struct Vic6560BusHandler {
|
||||
// It is assumed that these pointers have been filled in by the machine.
|
||||
uint8_t *video_memory_map[16]{}; // Segments video memory into 1kb portions.
|
||||
uint8_t *colour_memory{}; // Colour memory must be contiguous.
|
||||
|
||||
// TODO: make the above const.
|
||||
};
|
||||
|
||||
/*!
|
||||
@ -252,7 +254,7 @@ public:
|
||||
user_port_via_port_handler_(user_port_via_port_handler),
|
||||
keyboard_via_port_handler_(keyboard_via_port_handler) {}
|
||||
|
||||
void did_set_input(const Input &digital_input, bool is_active) final {
|
||||
void did_set_input(const Input &digital_input, const bool is_active) final {
|
||||
JoystickInput mapped_input;
|
||||
switch(digital_input.type) {
|
||||
default: return;
|
||||
@ -468,7 +470,7 @@ public:
|
||||
return !media.tapes.empty() || (!media.disks.empty() && c1540_ != nullptr) || !media.cartridges.empty();
|
||||
}
|
||||
|
||||
void set_key_state(uint16_t key, bool is_pressed) final {
|
||||
void set_key_state(const uint16_t key, const bool is_pressed) final {
|
||||
if(key < 0xfff0) {
|
||||
keyboard_via_port_handler_->set_key_state(key, is_pressed);
|
||||
} else {
|
||||
@ -502,7 +504,11 @@ public:
|
||||
}
|
||||
|
||||
// to satisfy CPU::MOS6502::Processor
|
||||
forceinline Cycles perform_bus_operation(CPU::MOS6502::BusOperation operation, uint16_t address, uint8_t *value) {
|
||||
forceinline Cycles perform_bus_operation(
|
||||
const CPU::MOS6502::BusOperation operation,
|
||||
const uint16_t address,
|
||||
uint8_t *const value
|
||||
) {
|
||||
// run the phase-1 part of this cycle, in which the VIC accesses memory
|
||||
cycles_since_mos6560_update_++;
|
||||
|
||||
@ -622,7 +628,7 @@ public:
|
||||
return Cycles(1);
|
||||
}
|
||||
|
||||
void flush_output(int outputs) final {
|
||||
void flush_output(const int outputs) final {
|
||||
if(outputs & Output::Video) {
|
||||
update_video();
|
||||
}
|
||||
@ -635,7 +641,7 @@ public:
|
||||
m6502_.run_for(cycles);
|
||||
}
|
||||
|
||||
void set_scan_target(Outputs::Display::ScanTarget *scan_target) final {
|
||||
void set_scan_target(Outputs::Display::ScanTarget *const scan_target) final {
|
||||
mos6560_.set_scan_target(scan_target);
|
||||
}
|
||||
|
||||
@ -643,7 +649,7 @@ public:
|
||||
return mos6560_.get_scaled_scan_status();
|
||||
}
|
||||
|
||||
void set_display_type(Outputs::Display::DisplayType display_type) final {
|
||||
void set_display_type(const Outputs::Display::DisplayType display_type) final {
|
||||
mos6560_.set_display_type(display_type);
|
||||
}
|
||||
|
||||
@ -664,11 +670,11 @@ public:
|
||||
Utility::TypeRecipient<CharacterMapper>::add_typer(string);
|
||||
}
|
||||
|
||||
bool can_type(char c) const final {
|
||||
bool can_type(const char c) const final {
|
||||
return Utility::TypeRecipient<CharacterMapper>::can_type(c);
|
||||
}
|
||||
|
||||
void tape_did_change_input(Storage::Tape::BinaryTapePlayer *tape) final {
|
||||
void tape_did_change_input(Storage::Tape::BinaryTapePlayer *const tape) final {
|
||||
keyboard_via_.set_control_line_input(MOS::MOS6522::Port::A, MOS::MOS6522::Line::One, !tape->input());
|
||||
}
|
||||
|
||||
@ -692,13 +698,13 @@ public:
|
||||
set_use_fast_tape();
|
||||
}
|
||||
|
||||
void set_component_prefers_clocking(ClockingHint::Source *, ClockingHint::Preference clocking) final {
|
||||
void set_component_prefers_clocking(ClockingHint::Source *, const ClockingHint::Preference clocking) final {
|
||||
tape_is_sleeping_ = clocking == ClockingHint::Preference::None;
|
||||
set_use_fast_tape();
|
||||
}
|
||||
|
||||
// MARK: - Activity Source
|
||||
void set_activity_observer(Activity::Observer *observer) final {
|
||||
void set_activity_observer(Activity::Observer *const observer) final {
|
||||
if(c1540_) c1540_->set_activity_observer(observer);
|
||||
}
|
||||
|
||||
@ -762,7 +768,7 @@ private:
|
||||
using namespace Commodore::Vic20;
|
||||
|
||||
std::unique_ptr<Machine> Machine::Vic20(
|
||||
const Analyser::Static::Target *target,
|
||||
const Analyser::Static::Target *const target,
|
||||
const ROMMachine::ROMFetcher &rom_fetcher
|
||||
) {
|
||||
using Target = Analyser::Static::Commodore::Target;
|
||||
|
Loading…
Reference in New Issue
Block a user