From f6acee18ccbdf151e28eaab8669fec7790bf4861 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 10 May 2023 18:53:38 -0500 Subject: [PATCH] Eliminate type-in-function-name from 6502-world. --- Machines/Apple/AppleIIgs/AppleIIgs.cpp | 32 +++++++------- Machines/Commodore/Vic-20/Vic20.cpp | 8 ++-- Machines/Electron/Electron.cpp | 6 +-- Machines/Oric/Oric.cpp | 4 +- .../65816ComparativeTests.mm | 44 +++++++++---------- .../Bridges/TestMachine6502.mm | 4 +- Processors/6502/6502.hpp | 8 ++-- Processors/6502/AllRAM/6502AllRAM.cpp | 18 ++++---- Processors/6502/AllRAM/6502AllRAM.hpp | 4 +- .../Implementation/6502Implementation.hpp | 4 +- Processors/6502Esque/6502Esque.hpp | 4 +- Processors/65816/65816.hpp | 4 +- Processors/65816/Implementation/65816Base.cpp | 4 +- Processors/Z80/Z80.hpp | 2 +- 14 files changed, 73 insertions(+), 73 deletions(-) diff --git a/Machines/Apple/AppleIIgs/AppleIIgs.cpp b/Machines/Apple/AppleIIgs/AppleIIgs.cpp index 5bc2a1afe..a2af523aa 100644 --- a/Machines/Apple/AppleIIgs/AppleIIgs.cpp +++ b/Machines/Apple/AppleIIgs/AppleIIgs.cpp @@ -395,13 +395,13 @@ class ConcreteMachine: // // printf("%06x a:%04x x:%04x y:%04x s:%04x d:%04x b:%04x\n", // address, -// m65816_.get_value_of_register(CPU::WDC65816::Register::A), -// m65816_.get_value_of_register(CPU::WDC65816::Register::X), -// m65816_.get_value_of_register(CPU::WDC65816::Register::Y), -//// m65816_.get_value_of_register(CPU::WDC65816::Register::Flags), -// m65816_.get_value_of_register(CPU::WDC65816::Register::StackPointer), -// m65816_.get_value_of_register(CPU::WDC65816::Register::Direct), -// m65816_.get_value_of_register(CPU::WDC65816::Register::DataBank) +// m65816_.value_of(CPU::WDC65816::Register::A), +// m65816_.value_of(CPU::WDC65816::Register::X), +// m65816_.value_of(CPU::WDC65816::Register::Y), +//// m65816_.value_of(CPU::WDC65816::Register::Flags), +// m65816_.value_of(CPU::WDC65816::Register::StackPointer), +// m65816_.value_of(CPU::WDC65816::Register::Direct), +// m65816_.value_of(CPU::WDC65816::Register::DataBank) // ); // } @@ -1009,15 +1009,15 @@ class ConcreteMachine: printf("%06x %s %02x [%s]", address, isReadOperation(operation) ? "->" : "<-", *value, (is_1Mhz || (speed_register_ & motor_flags_)) ? "1.0" : "2.8"); if(operation == CPU::WDC65816::BusOperation::ReadOpcode) { printf(" a:%04x x:%04x y:%04x s:%04x e:%d p:%02x db:%02x pb:%02x d:%04x [tot:%llu]\n", - m65816_.get_value_of_register(CPU::WDC65816::Register::A), - m65816_.get_value_of_register(CPU::WDC65816::Register::X), - m65816_.get_value_of_register(CPU::WDC65816::Register::Y), - m65816_.get_value_of_register(CPU::WDC65816::Register::StackPointer), - m65816_.get_value_of_register(CPU::WDC65816::Register::EmulationFlag), - m65816_.get_value_of_register(CPU::WDC65816::Register::Flags), - m65816_.get_value_of_register(CPU::WDC65816::Register::DataBank), - m65816_.get_value_of_register(CPU::WDC65816::Register::ProgramBank), - m65816_.get_value_of_register(CPU::WDC65816::Register::Direct), + m65816_.value_of(CPU::WDC65816::Register::A), + m65816_.value_of(CPU::WDC65816::Register::X), + m65816_.value_of(CPU::WDC65816::Register::Y), + m65816_.value_of(CPU::WDC65816::Register::StackPointer), + m65816_.value_of(CPU::WDC65816::Register::EmulationFlag), + m65816_.value_of(CPU::WDC65816::Register::Flags), + m65816_.value_of(CPU::WDC65816::Register::DataBank), + m65816_.value_of(CPU::WDC65816::Register::ProgramBank), + m65816_.value_of(CPU::WDC65816::Register::Direct), static_cast(total) ); } else printf("\n"); diff --git a/Machines/Commodore/Vic-20/Vic20.cpp b/Machines/Commodore/Vic-20/Vic20.cpp index 02d7b2d10..56967236e 100644 --- a/Machines/Commodore/Vic-20/Vic20.cpp +++ b/Machines/Commodore/Vic-20/Vic20.cpp @@ -544,7 +544,7 @@ class ConcreteMachine: *value = 0x0c; // i.e. NOP abs, to swallow the entire JSR } else if(address == 0xf90b) { - uint8_t x = uint8_t(m6502_.get_value_of_register(CPU::MOS6502::Register::X)); + uint8_t x = uint8_t(m6502_.value_of(CPU::MOS6502::Register::X)); if(x == 0xe) { Storage::Tape::Commodore::Parser parser; const uint64_t tape_position = tape_->get_tape()->get_offset(); @@ -567,13 +567,13 @@ class ConcreteMachine: // set tape status, carry and flag ram_[0x90] |= 0x40; - uint8_t flags = uint8_t(m6502_.get_value_of_register(CPU::MOS6502::Register::Flags)); + uint8_t flags = uint8_t(m6502_.value_of(CPU::MOS6502::Register::Flags)); flags &= ~uint8_t((CPU::MOS6502::Flag::Carry | CPU::MOS6502::Flag::Interrupt)); - m6502_.set_value_of_register(CPU::MOS6502::Register::Flags, flags); + m6502_.set_value_of(CPU::MOS6502::Register::Flags, flags); // to ensure that execution proceeds to 0xfccf, pretend a NOP was here and // ensure that the PC leaps to 0xfccf - m6502_.set_value_of_register(CPU::MOS6502::Register::ProgramCounter, 0xfccf); + m6502_.set_value_of(CPU::MOS6502::Register::ProgramCounter, 0xfccf); *value = 0xea; // i.e. NOP implied hold_tape_ = true; LOG("Vic-20: Found data"); diff --git a/Machines/Electron/Electron.cpp b/Machines/Electron/Electron.cpp index 9d71d24ba..14669f1db 100644 --- a/Machines/Electron/Electron.cpp +++ b/Machines/Electron/Electron.cpp @@ -421,7 +421,7 @@ template class ConcreteMachine: // allow the PC read to return an RTS. ) ) { - const auto service_call = uint8_t(m6502_.get_value_of_register(CPU::MOS6502::Register::X)); + const auto service_call = uint8_t(m6502_.value_of(CPU::MOS6502::Register::X)); if(address == 0xf0a8) { if(!ram_[0x247] && service_call == 14) { tape_.set_delegate(nullptr); @@ -441,8 +441,8 @@ template class ConcreteMachine: interrupt_status_ |= tape_.get_interrupt_status(); fast_load_is_in_data_ = true; - m6502_.set_value_of_register(CPU::MOS6502::Register::A, 0); - m6502_.set_value_of_register(CPU::MOS6502::Register::Y, tape_.get_data_register()); + m6502_.set_value_of(CPU::MOS6502::Register::A, 0); + m6502_.set_value_of(CPU::MOS6502::Register::Y, tape_.get_data_register()); *value = 0x60; // 0x60 is RTS } else *value = os_[address & 16383]; diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index d6d522b1d..6633c600e 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -469,8 +469,8 @@ template is_at_end()) { uint8_t next_byte = tape_player_.get_next_byte(!ram_[tape_speed_address_]); - m6502_.set_value_of_register(CPU::MOS6502Esque::A, next_byte); - m6502_.set_value_of_register(CPU::MOS6502Esque::Flags, next_byte ? 0 : CPU::MOS6502::Flag::Zero); + m6502_.set_value_of(CPU::MOS6502Esque::A, next_byte); + m6502_.set_value_of(CPU::MOS6502Esque::Flags, next_byte ? 0 : CPU::MOS6502::Flag::Zero); *value = 0x60; // i.e. RTS } } else { diff --git a/OSBindings/Mac/Clock SignalTests/65816ComparativeTests.mm b/OSBindings/Mac/Clock SignalTests/65816ComparativeTests.mm index 8f1d49be4..e47d84d0e 100644 --- a/OSBindings/Mac/Clock SignalTests/65816ComparativeTests.mm +++ b/OSBindings/Mac/Clock SignalTests/65816ComparativeTests.mm @@ -93,8 +93,8 @@ struct BusHandler: public CPU::MOS6502Esque::BusHandler { using Register = CPU::MOS6502Esque::Register; const uint32_t pc = - processor.get_value_of_register(Register::ProgramCounter) | - (processor.get_value_of_register(Register::ProgramBank) << 16); + processor.value_of(Register::ProgramCounter) | + (processor.value_of(Register::ProgramBank) << 16); inventions[pc] = ram[pc] = opcode; } @@ -120,16 +120,16 @@ struct BusHandler: public CPU::MOS6502Esque::BusHandler { template void print_registers(FILE *file, const Processor &processor, int pc_offset) { using Register = CPU::MOS6502Esque::Register; - fprintf(file, "\"pc\": %d, ", (processor.get_value_of_register(Register::ProgramCounter) + pc_offset) & 65535); - fprintf(file, "\"s\": %d, ", processor.get_value_of_register(Register::StackPointer)); - fprintf(file, "\"p\": %d, ", processor.get_value_of_register(Register::Flags)); - fprintf(file, "\"a\": %d, ", processor.get_value_of_register(Register::A)); - fprintf(file, "\"x\": %d, ", processor.get_value_of_register(Register::X)); - fprintf(file, "\"y\": %d, ", processor.get_value_of_register(Register::Y)); - fprintf(file, "\"dbr\": %d, ", processor.get_value_of_register(Register::DataBank)); - fprintf(file, "\"d\": %d, ", processor.get_value_of_register(Register::Direct)); - fprintf(file, "\"pbr\": %d, ", processor.get_value_of_register(Register::ProgramBank)); - fprintf(file, "\"e\": %d, ", processor.get_value_of_register(Register::EmulationFlag)); + fprintf(file, "\"pc\": %d, ", (processor.value_of(Register::ProgramCounter) + pc_offset) & 65535); + fprintf(file, "\"s\": %d, ", processor.value_of(Register::StackPointer)); + fprintf(file, "\"p\": %d, ", processor.value_of(Register::Flags)); + fprintf(file, "\"a\": %d, ", processor.value_of(Register::A)); + fprintf(file, "\"x\": %d, ", processor.value_of(Register::X)); + fprintf(file, "\"y\": %d, ", processor.value_of(Register::Y)); + fprintf(file, "\"dbr\": %d, ", processor.value_of(Register::DataBank)); + fprintf(file, "\"d\": %d, ", processor.value_of(Register::Direct)); + fprintf(file, "\"pbr\": %d, ", processor.value_of(Register::ProgramBank)); + fprintf(file, "\"e\": %d, ", processor.value_of(Register::EmulationFlag)); } void print_ram(FILE *file, const std::unordered_map &data) { @@ -180,19 +180,19 @@ void print_ram(FILE *file, const std::unordered_map &data) { // Randomise most of the processor state... using Register = CPU::MOS6502Esque::Register; - handler.processor.set_value_of_register(Register::A, rand() >> 8); - handler.processor.set_value_of_register(Register::Flags, rand() >> 8); - handler.processor.set_value_of_register(Register::X, rand() >> 8); - handler.processor.set_value_of_register(Register::Y, rand() >> 8); - handler.processor.set_value_of_register(Register::ProgramCounter, rand() >> 8); - handler.processor.set_value_of_register(Register::StackPointer, rand() >> 8); - handler.processor.set_value_of_register(Register::DataBank, rand() >> 8); - handler.processor.set_value_of_register(Register::ProgramBank, rand() >> 8); - handler.processor.set_value_of_register(Register::Direct, rand() >> 8); + handler.processor.set_value_of(Register::A, rand() >> 8); + handler.processor.set_value_of(Register::Flags, rand() >> 8); + handler.processor.set_value_of(Register::X, rand() >> 8); + handler.processor.set_value_of(Register::Y, rand() >> 8); + handler.processor.set_value_of(Register::ProgramCounter, rand() >> 8); + handler.processor.set_value_of(Register::StackPointer, rand() >> 8); + handler.processor.set_value_of(Register::DataBank, rand() >> 8); + handler.processor.set_value_of(Register::ProgramBank, rand() >> 8); + handler.processor.set_value_of(Register::Direct, rand() >> 8); // ... except for emulation mode, which is a given. // And is set last to ensure proper internal state is applied. - handler.processor.set_value_of_register(Register::EmulationFlag, is_emulated); + handler.processor.set_value_of(Register::EmulationFlag, is_emulated); // Establish the opcode. handler.setup(opcode); diff --git a/OSBindings/Mac/Clock SignalTests/Bridges/TestMachine6502.mm b/OSBindings/Mac/Clock SignalTests/Bridges/TestMachine6502.mm index 5ced2a41b..cfcabd737 100644 --- a/OSBindings/Mac/Clock SignalTests/Bridges/TestMachine6502.mm +++ b/OSBindings/Mac/Clock SignalTests/Bridges/TestMachine6502.mm @@ -79,11 +79,11 @@ static CPU::MOS6502::Register registerForRegister(CSTestMachine6502Register reg) } - (void)setValue:(uint16_t)value forRegister:(CSTestMachine6502Register)reg { - _processor->set_value_of_register(registerForRegister(reg), value); + _processor->set_value_of(registerForRegister(reg), value); } - (uint16_t)valueForRegister:(CSTestMachine6502Register)reg { - return _processor->get_value_of_register(registerForRegister(reg)); + return _processor->value_of(registerForRegister(reg)); } - (void)setData:(NSData *)data atAddress:(uint32_t)startAddress { diff --git a/Processors/6502/6502.hpp b/Processors/6502/6502.hpp index cc0d5b87d..8ed3ff0f9 100644 --- a/Processors/6502/6502.hpp +++ b/Processors/6502/6502.hpp @@ -59,22 +59,22 @@ class ProcessorBase: public ProcessorStorage { /*! Gets the value of a register. - @see set_value_of_register + @see set_value_of @param r The register to set. @returns The value of the register. 8-bit registers will be returned as unsigned. */ - inline uint16_t get_value_of_register(Register r) const; + inline uint16_t value_of(Register r) const; /*! Sets the value of a register. - @see get_value_of_register + @see value_of @param r The register to set. @param value The value to set. If the register is only 8 bit, the value will be truncated. */ - inline void set_value_of_register(Register r, uint16_t value); + inline void set_value_of(Register r, uint16_t value); /*! Sets the current level of the RST line. diff --git a/Processors/6502/AllRAM/6502AllRAM.cpp b/Processors/6502/AllRAM/6502AllRAM.cpp index 5cb724104..ca7963432 100644 --- a/Processors/6502/AllRAM/6502AllRAM.cpp +++ b/Processors/6502/AllRAM/6502AllRAM.cpp @@ -51,11 +51,11 @@ template class ConcreteAllRAMProcessor: if(operation == BusOperation::ReadOpcode) { if constexpr (LogProgramCounter) { printf("[%04x] %02x a:%04x x:%04x y:%04x p:%02x s:%02x\n", address, memory_[address], - mos6502_.get_value_of_register(Register::A), - mos6502_.get_value_of_register(Register::X), - mos6502_.get_value_of_register(Register::Y), - mos6502_.get_value_of_register(Register::Flags) & 0xff, - mos6502_.get_value_of_register(Register::StackPointer) & 0xff); + mos6502_.value_of(Register::A), + mos6502_.value_of(Register::X), + mos6502_.value_of(Register::Y), + mos6502_.value_of(Register::Flags) & 0xff, + mos6502_.value_of(Register::StackPointer) & 0xff); } check_address_for_trap(address); --instructions_; @@ -137,12 +137,12 @@ template class ConcreteAllRAMProcessor: mos6502_.set_nmi_line(value); } - uint16_t get_value_of_register(Register r) { - return mos6502_.get_value_of_register(r); + uint16_t value_of(Register r) { + return mos6502_.value_of(r); } - void set_value_of_register(Register r, uint16_t value) { - mos6502_.set_value_of_register(r, value); + void set_value_of(Register r, uint16_t value) { + mos6502_.set_value_of(r, value); } private: diff --git a/Processors/6502/AllRAM/6502AllRAM.hpp b/Processors/6502/AllRAM/6502AllRAM.hpp index 94d8eda1f..fbf40daca 100644 --- a/Processors/6502/AllRAM/6502AllRAM.hpp +++ b/Processors/6502/AllRAM/6502AllRAM.hpp @@ -25,8 +25,8 @@ class AllRAMProcessor: virtual bool is_jammed() = 0; virtual void set_irq_line(bool value) = 0; virtual void set_nmi_line(bool value) = 0; - virtual uint16_t get_value_of_register(Register r) = 0; - virtual void set_value_of_register(Register r, uint16_t value) = 0; + virtual uint16_t value_of(Register r) = 0; + virtual void set_value_of(Register r, uint16_t value) = 0; diff --git a/Processors/6502/Implementation/6502Implementation.hpp b/Processors/6502/Implementation/6502Implementation.hpp index c0cbbe0ac..b7e1f4707 100644 --- a/Processors/6502/Implementation/6502Implementation.hpp +++ b/Processors/6502/Implementation/6502Implementation.hpp @@ -704,7 +704,7 @@ bool ProcessorBase::is_jammed() const { return is_jammed_; } -uint16_t ProcessorBase::get_value_of_register(Register r) const { +uint16_t ProcessorBase::value_of(Register r) const { switch (r) { case Register::ProgramCounter: return pc_.full; case Register::LastOperationAddress: return last_operation_pc_.full; @@ -717,7 +717,7 @@ uint16_t ProcessorBase::get_value_of_register(Register r) const { } } -void ProcessorBase::set_value_of_register(Register r, uint16_t value) { +void ProcessorBase::set_value_of(Register r, uint16_t value) { switch (r) { case Register::ProgramCounter: pc_.full = value; break; case Register::StackPointer: s_ = uint8_t(value); break; diff --git a/Processors/6502Esque/6502Esque.hpp b/Processors/6502Esque/6502Esque.hpp index 836c9747b..9c32d2148 100644 --- a/Processors/6502Esque/6502Esque.hpp +++ b/Processors/6502Esque/6502Esque.hpp @@ -24,7 +24,7 @@ namespace CPU::MOS6502Esque { /* - The list of registers that can be accessed via @c set_value_of_register and @c set_value_of_register. + The list of registers that can be accessed via @c value_of(Register) and @c set_value_of(Register, value). */ enum Register { LastOperationAddress, @@ -43,7 +43,7 @@ enum Register { }; /* - Flags as defined on the 6502; can be used to decode the result of @c get_value_of_register(Flags) or to form a value for + Flags as defined on the 6502; can be used to decode the result of @c value_of(Flags) or to form a value for the corresponding set. */ enum Flag: uint8_t { diff --git a/Processors/65816/65816.hpp b/Processors/65816/65816.hpp index 20e680943..a968b73a1 100644 --- a/Processors/65816/65816.hpp +++ b/Processors/65816/65816.hpp @@ -60,8 +60,8 @@ class ProcessorBase: protected ProcessorStorage { */ inline void restart_operation_fetch(); - void set_value_of_register(Register r, uint16_t value); - uint16_t get_value_of_register(Register r) const; + void set_value_of(Register r, uint16_t value); + uint16_t value_of(Register r) const; }; template class Processor: public ProcessorBase { diff --git a/Processors/65816/Implementation/65816Base.cpp b/Processors/65816/Implementation/65816Base.cpp index 5dff89928..83bb01701 100644 --- a/Processors/65816/Implementation/65816Base.cpp +++ b/Processors/65816/Implementation/65816Base.cpp @@ -10,7 +10,7 @@ using namespace CPU::WDC65816; -uint16_t ProcessorBase::get_value_of_register(Register r) const { +uint16_t ProcessorBase::value_of(Register r) const { switch (r) { case Register::ProgramCounter: return registers_.pc; case Register::LastOperationAddress: return last_operation_pc_; @@ -30,7 +30,7 @@ uint16_t ProcessorBase::get_value_of_register(Register r) const { } } -void ProcessorBase::set_value_of_register(Register r, uint16_t value) { +void ProcessorBase::set_value_of(Register r, uint16_t value) { switch (r) { case Register::ProgramCounter: registers_.pc = value; break; case Register::StackPointer: registers_.s.full = value; break; diff --git a/Processors/Z80/Z80.hpp b/Processors/Z80/Z80.hpp index 3dc140689..b5a453640 100644 --- a/Processors/Z80/Z80.hpp +++ b/Processors/Z80/Z80.hpp @@ -20,7 +20,7 @@ namespace CPU::Z80 { /* - The list of registers that can be accessed via @c set_value_of_register and @c set_value_of_register. + The list of registers that can be accessed via @c value_of(Register) and @c set_value_of(Register). */ enum class Register { ProgramCounter,