diff --git a/src/app/emu/cpu/cpu.cc b/src/app/emu/cpu/cpu.cc index 45cb894a..980b5f94 100644 --- a/src/app/emu/cpu/cpu.cc +++ b/src/app/emu/cpu/cpu.cc @@ -10,7 +10,7 @@ namespace yaze { namespace app { namespace emu { -void CPU::Update(UpdateMode mode, int stepCount) { +void Cpu::Update(UpdateMode mode, int stepCount) { int cycles = (mode == UpdateMode::Run) ? clock.GetCycleCount() : stepCount; // Execute the calculated number of cycles @@ -31,7 +31,7 @@ void CPU::Update(UpdateMode mode, int stepCount) { } } -void CPU::ExecuteInstruction(uint8_t opcode) { +void Cpu::ExecuteInstruction(uint8_t opcode) { uint8_t cycles = 0; uint8_t instruction_length = 0; uint32_t operand = 0; @@ -1475,7 +1475,7 @@ void CPU::ExecuteInstruction(uint8_t opcode) { UpdatePC(instruction_length); } -void CPU::LogInstructions(uint16_t PC, uint8_t opcode, uint16_t operand, +void Cpu::LogInstructions(uint16_t PC, uint8_t opcode, uint16_t operand, bool immediate, bool accumulator_mode) { if (flags()->kLogInstructions) { std::ostringstream oss; @@ -1583,7 +1583,7 @@ void CPU::LogInstructions(uint16_t PC, uint8_t opcode, uint16_t operand, } } -uint8_t CPU::GetInstructionLength(uint8_t opcode) { +uint8_t Cpu::GetInstructionLength(uint8_t opcode) { switch (opcode) { case 0x00: // BRK case 0x02: // COP @@ -1928,7 +1928,7 @@ uint8_t CPU::GetInstructionLength(uint8_t opcode) { } // TODO: Implement 65816 interrupts. -void CPU::HandleInterrupts() { +void Cpu::HandleInterrupts() { if (GetInterruptFlag()) { return; } diff --git a/src/app/emu/cpu/cpu.h b/src/app/emu/cpu/cpu.h index cc877fd4..13723888 100644 --- a/src/app/emu/cpu/cpu.h +++ b/src/app/emu/cpu/cpu.h @@ -38,9 +38,9 @@ class InstructionEntry { const int kCpuClockSpeed = 21477272; // 21.477272 MHz -class CPU : public Memory, public Loggable, public core::ExperimentFlags { +class Cpu : public Memory, public Loggable, public core::ExperimentFlags { public: - explicit CPU(Memory& mem, Clock& vclock) : memory(mem), clock(vclock) {} + explicit Cpu(Memory& mem, Clock& vclock) : memory(mem), clock(vclock) {} enum class UpdateMode { Run, Step, Pause }; void Init(bool verbose = false) { clock.SetFrequency(kCpuClockSpeed); } diff --git a/src/app/emu/cpu/internal/addressing.cc b/src/app/emu/cpu/internal/addressing.cc index 685246ed..cbd76493 100644 --- a/src/app/emu/cpu/internal/addressing.cc +++ b/src/app/emu/cpu/internal/addressing.cc @@ -4,92 +4,92 @@ namespace yaze { namespace app { namespace emu { -uint32_t CPU::Absolute(CPU::AccessType access_type) { +uint32_t Cpu::Absolute(Cpu::AccessType access_type) { auto operand = FetchWord(); uint32_t bank = - (access_type == CPU::AccessType::Data) ? (DB << 16) : (PB << 16); + (access_type == Cpu::AccessType::Data) ? (DB << 16) : (PB << 16); return bank | (operand & 0xFFFF); } -uint32_t CPU::AbsoluteIndexedX() { +uint32_t Cpu::AbsoluteIndexedX() { uint16_t address = memory.ReadWord((PB << 16) | (PC + 1)); uint32_t effective_address = (DB << 16) | ((address + X) & 0xFFFF); return effective_address; } -uint32_t CPU::AbsoluteIndexedY() { +uint32_t Cpu::AbsoluteIndexedY() { uint16_t address = memory.ReadWord((PB << 16) | (PC + 1)); uint32_t effective_address = (DB << 16) | address + Y; return effective_address; } -uint16_t CPU::AbsoluteIndexedIndirect() { +uint16_t Cpu::AbsoluteIndexedIndirect() { uint16_t address = FetchWord() + X; return memory.ReadWord((DB << 16) | address & 0xFFFF); } -uint16_t CPU::AbsoluteIndirect() { +uint16_t Cpu::AbsoluteIndirect() { uint16_t address = FetchWord(); return memory.ReadWord((PB << 16) | address); } -uint32_t CPU::AbsoluteIndirectLong() { +uint32_t Cpu::AbsoluteIndirectLong() { uint16_t address = FetchWord(); return memory.ReadWordLong((PB << 16) | address); } -uint32_t CPU::AbsoluteLong() { return FetchLong(); } +uint32_t Cpu::AbsoluteLong() { return FetchLong(); } -uint32_t CPU::AbsoluteLongIndexedX() { return FetchLong() + X; } +uint32_t Cpu::AbsoluteLongIndexedX() { return FetchLong() + X; } -void CPU::BlockMove(uint16_t source, uint16_t dest, uint16_t length) { +void Cpu::BlockMove(uint16_t source, uint16_t dest, uint16_t length) { for (int i = 0; i < length; i++) { memory.WriteByte(dest + i, memory.ReadByte(source + i)); } } -uint16_t CPU::DirectPage() { +uint16_t Cpu::DirectPage() { uint8_t dp = FetchByte(); return D + dp; } -uint16_t CPU::DirectPageIndexedX() { +uint16_t Cpu::DirectPageIndexedX() { uint8_t operand = FetchByte(); uint16_t x_by_mode = GetAccumulatorSize() ? X : X & 0xFF; return D + operand + x_by_mode; } -uint16_t CPU::DirectPageIndexedY() { +uint16_t Cpu::DirectPageIndexedY() { uint8_t operand = FetchByte(); return (operand + Y) & 0xFF; } -uint16_t CPU::DirectPageIndexedIndirectX() { +uint16_t Cpu::DirectPageIndexedIndirectX() { uint8_t operand = FetchByte(); uint16_t indirect_address = D + operand + X; uint16_t effective_address = memory.ReadWord(indirect_address & 0xFFFF); return effective_address; } -uint16_t CPU::DirectPageIndirect() { +uint16_t Cpu::DirectPageIndirect() { uint8_t dp = FetchByte(); uint16_t effective_address = D + dp; return memory.ReadWord(effective_address); } -uint32_t CPU::DirectPageIndirectLong() { +uint32_t Cpu::DirectPageIndirectLong() { uint8_t dp = FetchByte(); uint16_t effective_address = D + dp; return memory.ReadWordLong((0x00 << 0x10) | effective_address); } -uint16_t CPU::DirectPageIndirectIndexedY() { +uint16_t Cpu::DirectPageIndirectIndexedY() { uint8_t operand = FetchByte(); uint16_t indirect_address = D + operand; return memory.ReadWord(indirect_address) + Y; } -uint32_t CPU::DirectPageIndirectLongIndexedY() { +uint32_t Cpu::DirectPageIndirectLongIndexedY() { uint8_t operand = FetchByte(); uint16_t indirect_address = D + operand; uint16_t y_by_mode = GetAccumulatorSize() ? Y : Y & 0xFF; @@ -98,7 +98,7 @@ uint32_t CPU::DirectPageIndirectLongIndexedY() { return effective_address; } -uint16_t CPU::Immediate(bool index_size) { +uint16_t Cpu::Immediate(bool index_size) { bool bit_mode = index_size ? GetIndexSize() : GetAccumulatorSize(); if (bit_mode) { return memory.ReadByte((PB << 16) | PC + 1); @@ -107,13 +107,13 @@ uint16_t CPU::Immediate(bool index_size) { } } -uint16_t CPU::StackRelative() { +uint16_t Cpu::StackRelative() { uint8_t sr = FetchByte(); uint16_t effective_address = SP() + sr; return effective_address; } -uint32_t CPU::StackRelativeIndirectIndexedY() { +uint32_t Cpu::StackRelativeIndirectIndexedY() { uint8_t sr = FetchByte(); return (DB << 0x10) | (memory.ReadWord(SP() + sr) + Y); } diff --git a/src/app/emu/cpu/internal/instructions.cc b/src/app/emu/cpu/internal/instructions.cc index a06ff7bd..2eafcf63 100644 --- a/src/app/emu/cpu/internal/instructions.cc +++ b/src/app/emu/cpu/internal/instructions.cc @@ -14,7 +14,7 @@ namespace emu { * TODO: STP, WDM */ -void CPU::ADC(uint16_t operand) { +void Cpu::ADC(uint16_t operand) { bool C = GetCarryFlag(); if (GetAccumulatorSize()) { // 8-bit mode uint16_t result = static_cast(A & 0xFF) + @@ -47,7 +47,7 @@ void CPU::ADC(uint16_t operand) { } } -void CPU::AND(uint32_t value, bool isImmediate) { +void Cpu::AND(uint32_t value, bool isImmediate) { uint16_t operand; if (GetAccumulatorSize()) { // 8-bit mode operand = isImmediate ? value : memory.ReadByte(value); @@ -63,14 +63,14 @@ void CPU::AND(uint32_t value, bool isImmediate) { } // New function for absolute long addressing mode -void CPU::ANDAbsoluteLong(uint32_t address) { +void Cpu::ANDAbsoluteLong(uint32_t address) { uint32_t operand32 = memory.ReadWordLong(address); A &= operand32; SetZeroFlag(A == 0); SetNegativeFlag(A & 0x8000); } -void CPU::ASL(uint16_t address) { +void Cpu::ASL(uint16_t address) { uint8_t value = memory.ReadByte(address); SetCarryFlag(!(value & 0x80)); // Set carry flag if bit 7 is set value <<= 1; // Shift left @@ -80,53 +80,53 @@ void CPU::ASL(uint16_t address) { SetZeroFlag(value); } -void CPU::BCC(int8_t offset) { +void Cpu::BCC(int8_t offset) { if (!GetCarryFlag()) { // If the carry flag is clear next_pc_ = offset; } } -void CPU::BCS(int8_t offset) { +void Cpu::BCS(int8_t offset) { if (GetCarryFlag()) { // If the carry flag is set next_pc_ = offset; } } -void CPU::BEQ(int8_t offset) { +void Cpu::BEQ(int8_t offset) { if (GetZeroFlag()) { // If the zero flag is set next_pc_ = offset; } } -void CPU::BIT(uint16_t address) { +void Cpu::BIT(uint16_t address) { uint8_t value = memory.ReadByte(address); SetNegativeFlag(value & 0x80); SetOverflowFlag(value & 0x40); SetZeroFlag((A & value) == 0); } -void CPU::BMI(int8_t offset) { +void Cpu::BMI(int8_t offset) { if (GetNegativeFlag()) { // If the negative flag is set next_pc_ = offset; } } -void CPU::BNE(int8_t offset) { +void Cpu::BNE(int8_t offset) { if (!GetZeroFlag()) { // If the zero flag is clear // PC += offset; next_pc_ = offset; } } -void CPU::BPL(int8_t offset) { +void Cpu::BPL(int8_t offset) { if (!GetNegativeFlag()) { // If the negative flag is clear next_pc_ = offset; } } -void CPU::BRA(int8_t offset) { next_pc_ = offset; } +void Cpu::BRA(int8_t offset) { next_pc_ = offset; } -void CPU::BRK() { +void Cpu::BRK() { next_pc_ = PC + 2; // Increment the program counter by 2 memory.PushWord(next_pc_); memory.PushByte(status); @@ -138,32 +138,32 @@ void CPU::BRK() { } } -void CPU::BRL(int16_t offset) { next_pc_ = offset; } +void Cpu::BRL(int16_t offset) { next_pc_ = offset; } -void CPU::BVC(int8_t offset) { +void Cpu::BVC(int8_t offset) { if (!GetOverflowFlag()) { // If the overflow flag is clear next_pc_ = offset; } } -void CPU::BVS(int8_t offset) { +void Cpu::BVS(int8_t offset) { if (GetOverflowFlag()) { // If the overflow flag is set next_pc_ = offset; } } -void CPU::CLC() { status &= ~0x01; } +void Cpu::CLC() { status &= ~0x01; } -void CPU::CLD() { status &= ~0x08; } +void Cpu::CLD() { status &= ~0x08; } -void CPU::CLI() { status &= ~0x04; } +void Cpu::CLI() { status &= ~0x04; } -void CPU::CLV() { status &= ~0x40; } +void Cpu::CLV() { status &= ~0x40; } // n Set if MSB of result is set; else cleared // z Set if result is zero; else cleared // c Set if no borrow; else cleared -void CPU::CMP(uint32_t value, bool isImmediate) { +void Cpu::CMP(uint32_t value, bool isImmediate) { if (GetAccumulatorSize()) { // 8-bit uint8_t result; if (isImmediate) { @@ -189,7 +189,7 @@ void CPU::CMP(uint32_t value, bool isImmediate) { } } -void CPU::COP() { +void Cpu::COP() { next_pc_ += 2; // Increment the program counter by 2 memory.PushWord(next_pc_); memory.PushByte(status); @@ -202,7 +202,7 @@ void CPU::COP() { SetDecimalFlag(false); } -void CPU::CPX(uint32_t value, bool isImmediate) { +void Cpu::CPX(uint32_t value, bool isImmediate) { if (GetIndexSize()) { // 8-bit uint8_t memory_value = isImmediate ? value : memory.ReadByte(value); compare(X, memory_value); @@ -212,7 +212,7 @@ void CPU::CPX(uint32_t value, bool isImmediate) { } } -void CPU::CPY(uint32_t value, bool isImmediate) { +void Cpu::CPY(uint32_t value, bool isImmediate) { if (GetIndexSize()) { // 8-bit uint8_t memory_value = isImmediate ? value : memory.ReadByte(value); compare(Y, memory_value); @@ -222,7 +222,7 @@ void CPU::CPY(uint32_t value, bool isImmediate) { } } -void CPU::DEC(uint32_t address, bool accumulator) { +void Cpu::DEC(uint32_t address, bool accumulator) { if (accumulator) { if (GetAccumulatorSize()) { // 8-bit A = (A - 1) & 0xFF; @@ -251,7 +251,7 @@ void CPU::DEC(uint32_t address, bool accumulator) { } } -void CPU::DEX() { +void Cpu::DEX() { if (GetIndexSize()) { // 8-bit X = static_cast(X - 1); SetZeroFlag(X == 0); @@ -263,7 +263,7 @@ void CPU::DEX() { } } -void CPU::DEY() { +void Cpu::DEY() { if (GetIndexSize()) { // 8-bit Y = static_cast(Y - 1); SetZeroFlag(Y == 0); @@ -275,7 +275,7 @@ void CPU::DEY() { } } -void CPU::EOR(uint32_t address, bool isImmediate) { +void Cpu::EOR(uint32_t address, bool isImmediate) { if (GetAccumulatorSize()) { A ^= isImmediate ? address : memory.ReadByte(address); SetZeroFlag(A == 0); @@ -287,7 +287,7 @@ void CPU::EOR(uint32_t address, bool isImmediate) { } } -void CPU::INC(uint32_t address, bool accumulator) { +void Cpu::INC(uint32_t address, bool accumulator) { if (accumulator) { if (GetAccumulatorSize()) { // 8-bit A = (A + 1) & 0xFF; @@ -316,7 +316,7 @@ void CPU::INC(uint32_t address, bool accumulator) { } } -void CPU::INX() { +void Cpu::INX() { if (GetIndexSize()) { // 8-bit X = static_cast(X + 1); SetZeroFlag(X == 0); @@ -328,7 +328,7 @@ void CPU::INX() { } } -void CPU::INY() { +void Cpu::INY() { if (GetIndexSize()) { // 8-bit Y = static_cast(Y + 1); SetZeroFlag(Y == 0); @@ -340,28 +340,28 @@ void CPU::INY() { } } -void CPU::JMP(uint16_t address) { +void Cpu::JMP(uint16_t address) { next_pc_ = address; // Set program counter to the new address } -void CPU::JML(uint32_t address) { +void Cpu::JML(uint32_t address) { next_pc_ = static_cast(address & 0xFFFF); // Set the PBR to the upper 8 bits of the address PB = static_cast((address >> 16) & 0xFF); } -void CPU::JSR(uint16_t address) { +void Cpu::JSR(uint16_t address) { memory.PushWord(PC); // Push the program counter onto the stack next_pc_ = address; // Set program counter to the new address } -void CPU::JSL(uint32_t address) { +void Cpu::JSL(uint32_t address) { memory.PushLong(PC); // Push the program counter onto the stack as a long // value (24 bits) next_pc_ = address; // Set program counter to the new address } -void CPU::LDA(uint16_t address, bool isImmediate, bool direct_page, bool data_bank) { +void Cpu::LDA(uint16_t address, bool isImmediate, bool direct_page, bool data_bank) { uint8_t bank = PB; if (direct_page) { bank = 0; @@ -377,7 +377,7 @@ void CPU::LDA(uint16_t address, bool isImmediate, bool direct_page, bool data_ba } } -void CPU::LDX(uint16_t address, bool isImmediate) { +void Cpu::LDX(uint16_t address, bool isImmediate) { if (GetIndexSize()) { X = isImmediate ? address : memory.ReadByte(address); SetZeroFlag(X == 0); @@ -389,7 +389,7 @@ void CPU::LDX(uint16_t address, bool isImmediate) { } } -void CPU::LDY(uint16_t address, bool isImmediate) { +void Cpu::LDY(uint16_t address, bool isImmediate) { if (GetIndexSize()) { Y = isImmediate ? address : memory.ReadByte(address); SetZeroFlag(Y == 0); @@ -401,7 +401,7 @@ void CPU::LDY(uint16_t address, bool isImmediate) { } } -void CPU::LSR(uint16_t address, bool accumulator) { +void Cpu::LSR(uint16_t address, bool accumulator) { if (accumulator) { if (GetAccumulatorSize()) { // 8-bit SetCarryFlag(A & 0x01); @@ -424,7 +424,7 @@ void CPU::LSR(uint16_t address, bool accumulator) { SetZeroFlag(value == 0); } -void CPU::MVN(uint16_t source, uint16_t dest, uint16_t length) { +void Cpu::MVN(uint16_t source, uint16_t dest, uint16_t length) { for (uint16_t i = 0; i < length; i++) { memory.WriteByte(dest, memory.ReadByte(source)); source++; @@ -432,7 +432,7 @@ void CPU::MVN(uint16_t source, uint16_t dest, uint16_t length) { } } -void CPU::MVP(uint16_t source, uint16_t dest, uint16_t length) { +void Cpu::MVP(uint16_t source, uint16_t dest, uint16_t length) { for (uint16_t i = 0; i < length; i++) { memory.WriteByte(dest, memory.ReadByte(source)); source--; @@ -440,11 +440,11 @@ void CPU::MVP(uint16_t source, uint16_t dest, uint16_t length) { } } -void CPU::NOP() { +void Cpu::NOP() { // Do nothing } -void CPU::ORA(uint16_t address, bool isImmediate) { +void Cpu::ORA(uint16_t address, bool isImmediate) { if (GetAccumulatorSize()) { A |= isImmediate ? address : memory.ReadByte(address); SetZeroFlag(A == 0); @@ -456,22 +456,22 @@ void CPU::ORA(uint16_t address, bool isImmediate) { } } -void CPU::PEA() { +void Cpu::PEA() { uint16_t address = FetchWord(); memory.PushWord(address); } -void CPU::PEI() { +void Cpu::PEI() { uint16_t address = FetchWord(); memory.PushWord(memory.ReadWord(address)); } -void CPU::PER() { +void Cpu::PER() { uint16_t address = FetchWord(); memory.PushWord(PC + address); } -void CPU::PHA() { +void Cpu::PHA() { if (GetAccumulatorSize()) { memory.PushByte(static_cast(A)); } else { @@ -479,15 +479,15 @@ void CPU::PHA() { } } -void CPU::PHB() { memory.PushByte(DB); } +void Cpu::PHB() { memory.PushByte(DB); } -void CPU::PHD() { memory.PushWord(D); } +void Cpu::PHD() { memory.PushWord(D); } -void CPU::PHK() { memory.PushByte(PB); } +void Cpu::PHK() { memory.PushByte(PB); } -void CPU::PHP() { memory.PushByte(status); } +void Cpu::PHP() { memory.PushByte(status); } -void CPU::PHX() { +void Cpu::PHX() { if (GetIndexSize()) { memory.PushByte(static_cast(X)); } else { @@ -495,7 +495,7 @@ void CPU::PHX() { } } -void CPU::PHY() { +void Cpu::PHY() { if (GetIndexSize()) { memory.PushByte(static_cast(Y)); } else { @@ -503,7 +503,7 @@ void CPU::PHY() { } } -void CPU::PLA() { +void Cpu::PLA() { if (GetAccumulatorSize()) { A = memory.PopByte(); SetNegativeFlag((A & 0x80) != 0); @@ -514,23 +514,23 @@ void CPU::PLA() { SetZeroFlag(A == 0); } -void CPU::PLB() { +void Cpu::PLB() { DB = memory.PopByte(); SetNegativeFlag((DB & 0x80) != 0); SetZeroFlag(DB == 0); } // Pull Direct Page Register from Stack -void CPU::PLD() { +void Cpu::PLD() { D = memory.PopWord(); SetNegativeFlag((D & 0x8000) != 0); SetZeroFlag(D == 0); } // Pull Processor Status Register from Stack -void CPU::PLP() { status = memory.PopByte(); } +void Cpu::PLP() { status = memory.PopByte(); } -void CPU::PLX() { +void Cpu::PLX() { if (GetIndexSize()) { X = memory.PopByte(); SetNegativeFlag((A & 0x80) != 0); @@ -542,7 +542,7 @@ void CPU::PLX() { SetZeroFlag(X == 0); } -void CPU::PLY() { +void Cpu::PLY() { if (GetIndexSize()) { Y = memory.PopByte(); SetNegativeFlag((A & 0x80) != 0); @@ -553,12 +553,12 @@ void CPU::PLY() { SetZeroFlag(Y == 0); } -void CPU::REP() { +void Cpu::REP() { auto byte = FetchByte(); status &= ~byte; } -void CPU::ROL(uint32_t address, bool accumulator) { +void Cpu::ROL(uint32_t address, bool accumulator) { if (accumulator) { if (GetAccumulatorSize()) { // 8-bit uint8_t carry = GetCarryFlag() ? 0x01 : 0x00; @@ -588,7 +588,7 @@ void CPU::ROL(uint32_t address, bool accumulator) { SetZeroFlag(value == 0); } -void CPU::ROR(uint32_t address, bool accumulator) { +void Cpu::ROR(uint32_t address, bool accumulator) { if (accumulator) { if (GetAccumulatorSize()) { // 8-bit uint8_t carry = GetCarryFlag() ? 0x80 : 0x00; @@ -618,21 +618,21 @@ void CPU::ROR(uint32_t address, bool accumulator) { SetZeroFlag(value == 0); } -void CPU::RTI() { +void Cpu::RTI() { status = memory.PopByte(); PC = memory.PopWord(); } -void CPU::RTL() { +void Cpu::RTL() { next_pc_ = memory.PopWord(); PB = memory.PopByte(); } -void CPU::RTS() { +void Cpu::RTS() { last_call_frame_ = memory.PopWord(); } -void CPU::SBC(uint32_t value, bool isImmediate) { +void Cpu::SBC(uint32_t value, bool isImmediate) { uint16_t operand; if (!GetAccumulatorSize()) { // 16-bit mode operand = isImmediate ? value : memory.ReadWord(value); @@ -665,18 +665,18 @@ void CPU::SBC(uint32_t value, bool isImmediate) { } } -void CPU::SEC() { status |= 0x01; } +void Cpu::SEC() { status |= 0x01; } -void CPU::SED() { status |= 0x08; } +void Cpu::SED() { status |= 0x08; } -void CPU::SEI() { status |= 0x04; } +void Cpu::SEI() { status |= 0x04; } -void CPU::SEP() { +void Cpu::SEP() { auto byte = FetchByte(); status |= byte; } -void CPU::STA(uint32_t address) { +void Cpu::STA(uint32_t address) { if (GetAccumulatorSize()) { memory.WriteByte(address, static_cast(A)); } else { @@ -686,12 +686,12 @@ void CPU::STA(uint32_t address) { // TODO: Make this work with the Clock class of the CPU -void CPU::STP() { +void Cpu::STP() { // During the next phase 2 clock cycle, stop the processors oscillator input // The processor is effectively shut down until a reset occurs (RES` pin). } -void CPU::STX(uint16_t address) { +void Cpu::STX(uint16_t address) { if (GetIndexSize()) { memory.WriteByte(address, static_cast(X)); } else { @@ -699,7 +699,7 @@ void CPU::STX(uint16_t address) { } } -void CPU::STY(uint16_t address) { +void Cpu::STY(uint16_t address) { if (GetIndexSize()) { memory.WriteByte(address, static_cast(Y)); } else { @@ -707,7 +707,7 @@ void CPU::STY(uint16_t address) { } } -void CPU::STZ(uint16_t address) { +void Cpu::STZ(uint16_t address) { if (GetAccumulatorSize()) { memory.WriteByte(address, 0x00); } else { @@ -715,79 +715,79 @@ void CPU::STZ(uint16_t address) { } } -void CPU::TAX() { +void Cpu::TAX() { X = A; SetZeroFlag(X == 0); SetNegativeFlag(X & 0x80); } -void CPU::TAY() { +void Cpu::TAY() { Y = A; SetZeroFlag(Y == 0); SetNegativeFlag(Y & 0x80); } -void CPU::TCD() { +void Cpu::TCD() { D = A; SetZeroFlag(D == 0); SetNegativeFlag(D & 0x80); } -void CPU::TCS() { memory.SetSP(A); } +void Cpu::TCS() { memory.SetSP(A); } -void CPU::TDC() { +void Cpu::TDC() { A = D; SetZeroFlag(A == 0); SetNegativeFlag(A & 0x80); } -void CPU::TRB(uint16_t address) { +void Cpu::TRB(uint16_t address) { uint8_t value = memory.ReadByte(address); SetZeroFlag((A & value) == 0); value &= ~A; memory.WriteByte(address, value); } -void CPU::TSB(uint16_t address) { +void Cpu::TSB(uint16_t address) { uint8_t value = memory.ReadByte(address); SetZeroFlag((A & value) == 0); value |= A; memory.WriteByte(address, value); } -void CPU::TSC() { +void Cpu::TSC() { A = SP(); SetZeroFlag(A == 0); SetNegativeFlag(A & 0x80); } -void CPU::TSX() { +void Cpu::TSX() { X = SP(); SetZeroFlag(X == 0); SetNegativeFlag(X & 0x80); } -void CPU::TXA() { +void Cpu::TXA() { A = X; SetZeroFlag(A == 0); SetNegativeFlag(A & 0x80); } -void CPU::TXS() { memory.SetSP(X); } +void Cpu::TXS() { memory.SetSP(X); } -void CPU::TXY() { +void Cpu::TXY() { Y = X; SetZeroFlag(X == 0); SetNegativeFlag(X & 0x80); } -void CPU::TYA() { +void Cpu::TYA() { A = Y; SetZeroFlag(A == 0); SetNegativeFlag(A & 0x80); } -void CPU::TYX() { +void Cpu::TYX() { X = Y; SetZeroFlag(Y == 0); SetNegativeFlag(Y & 0x80); @@ -795,20 +795,20 @@ void CPU::TYX() { // TODO: Make this communicate with the SNES class -void CPU::WAI() { +void Cpu::WAI() { // Pull the RDY pin low // Power consumption is reduced(?) // RDY remains low until an external hardware interupt // (NMI, IRQ, ABORT, or RESET) is received from the SNES class } -void CPU::XBA() { +void Cpu::XBA() { uint8_t lowByte = A & 0xFF; uint8_t highByte = (A >> 8) & 0xFF; A = (lowByte << 8) | highByte; } -void CPU::XCE() { +void Cpu::XCE() { uint8_t carry = status & 0x01; status &= ~0x01; status |= E; diff --git a/src/app/emu/emulator.cc b/src/app/emu/emulator.cc index 11e8a30b..0d898dd9 100644 --- a/src/app/emu/emulator.cc +++ b/src/app/emu/emulator.cc @@ -259,7 +259,7 @@ void Emulator::RenderBreakpointList() { } } -void Emulator::RenderCpuState(CPU& cpu) { +void Emulator::RenderCpuState(Cpu& cpu) { if (ImGui::CollapsingHeader("Register Values", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::Columns(2, "RegistersColumns"); diff --git a/src/app/emu/emulator.h b/src/app/emu/emulator.h index f4467589..688ba6ef 100644 --- a/src/app/emu/emulator.h +++ b/src/app/emu/emulator.h @@ -24,7 +24,7 @@ class Emulator : public SharedROM { void RenderEmulator(); void RenderSnesPpu(); void RenderBreakpointList(); - void RenderCpuState(CPU& cpu); + void RenderCpuState(Cpu& cpu); void RenderMemoryViewer(); struct Bookmark { diff --git a/src/app/emu/memory/mock_memory.h b/src/app/emu/memory/mock_memory.h index e1a43d69..c025ba2d 100644 --- a/src/app/emu/memory/mock_memory.h +++ b/src/app/emu/memory/mock_memory.h @@ -9,7 +9,7 @@ #include "app/emu/memory/memory.h" using yaze::app::emu::Clock; -using yaze::app::emu::CPU; +using yaze::app::emu::Cpu; using yaze::app::emu::Memory; class MockClock : public Clock { diff --git a/src/app/emu/snes.cc b/src/app/emu/snes.cc index 6d736e70..b54bfa07 100644 --- a/src/app/emu/snes.cc +++ b/src/app/emu/snes.cc @@ -257,7 +257,7 @@ void SNES::Run() { void SNES::StepRun() { // Update the CPU cpu_.UpdateClock(0.0); - cpu_.Update(CPU::UpdateMode::Step); + cpu_.Update(Cpu::UpdateMode::Step); // Update the PPU ppu_.UpdateClock(0.0); diff --git a/src/app/emu/snes.h b/src/app/emu/snes.h index 8aa2c31d..1331e1af 100644 --- a/src/app/emu/snes.h +++ b/src/app/emu/snes.h @@ -61,13 +61,13 @@ class SNES : public DMA { bool running() const { return running_; } - auto cpu() -> CPU& { return cpu_; } + auto cpu() -> Cpu& { return cpu_; } auto ppu() -> Ppu& { return ppu_; } auto Memory() -> MemoryImpl* { return &memory_; } void SetCpuMode(int mode) { cpu_mode_ = mode; } - CPU::UpdateMode GetCpuMode() const { - return static_cast(cpu_mode_); + Cpu::UpdateMode GetCpuMode() const { + return static_cast(cpu_mode_); } void SetupMemory(ROM& rom) { @@ -90,7 +90,7 @@ class SNES : public DMA { ClockImpl clock_; audio::AudioRamImpl audio_ram_; - CPU cpu_{memory_, clock_}; + Cpu cpu_{memory_, clock_}; Ppu ppu_{memory_, clock_}; audio::Apu apu_{memory_, audio_ram_, clock_}; diff --git a/src/app/zelda3/dungeon/object_renderer.h b/src/app/zelda3/dungeon/object_renderer.h index fc07b4b2..d349ed79 100644 --- a/src/app/zelda3/dungeon/object_renderer.h +++ b/src/app/zelda3/dungeon/object_renderer.h @@ -48,7 +48,7 @@ class DungeonObjectRenderer : public SharedROM { std::vector rom_data_; emu::MemoryImpl memory_; emu::ClockImpl clock_; - emu::CPU cpu{memory_, clock_}; + emu::Cpu cpu{memory_, clock_}; emu::Ppu ppu{memory_, clock_}; gfx::Bitmap bitmap_; PseudoVram vram_;