Address calculations are a little easier, if they're always 16-bit

This commit is contained in:
Adrian Conlon 2024-03-04 17:07:22 +00:00
parent 92d677f9d0
commit 8369e0d976
2 changed files with 9 additions and 9 deletions

View File

@ -94,11 +94,11 @@ namespace EightBit {
[[nodiscard]] auto Address_Immediate() noexcept { return PC()++; }
[[nodiscard]] auto Address_Absolute() noexcept { return fetchWord(); }
[[nodiscard]] auto Address_ZeroPage() noexcept { return fetchByte(); }
[[nodiscard]] auto Address_ZeroPage() noexcept { return register16_t(fetchByte(), 0); }
[[nodiscard]] register16_t Address_ZeroPageIndirect() noexcept;
[[nodiscard]] register16_t Address_Indirect() noexcept;
[[nodiscard]] uint8_t Address_ZeroPageX() noexcept;
[[nodiscard]] uint8_t Address_ZeroPageY() noexcept;
[[nodiscard]] register16_t Address_ZeroPageX() noexcept;
[[nodiscard]] register16_t Address_ZeroPageY() noexcept;
[[nodiscard]] std::pair<register16_t, uint8_t> Address_AbsoluteX() noexcept;
[[nodiscard]] std::pair<register16_t, uint8_t> Address_AbsoluteY() noexcept;
[[nodiscard]] register16_t Address_IndexedIndirectX() noexcept;

View File

@ -425,7 +425,7 @@ void EightBit::MOS6502::dummyPush(const uint8_t value) noexcept {
////
EightBit::register16_t EightBit::MOS6502::Address_ZeroPageIndirect() noexcept {
BUS().ADDRESS() = { Address_ZeroPage(), 0 };
BUS().ADDRESS() = Address_ZeroPage();
return getWordPaged();
}
@ -434,16 +434,16 @@ EightBit::register16_t EightBit::MOS6502::Address_Indirect() noexcept {
return getWordPaged();
}
uint8_t EightBit::MOS6502::Address_ZeroPageX() noexcept {
EightBit::register16_t EightBit::MOS6502::Address_ZeroPageX() noexcept {
const auto address = Address_ZeroPage();
memoryRead(address);
return address + X();
return register16_t(address.low + X(), 0);
}
uint8_t EightBit::MOS6502::Address_ZeroPageY() noexcept {
EightBit::register16_t EightBit::MOS6502::Address_ZeroPageY() noexcept {
const auto address = Address_ZeroPage();
memoryRead(address);
return address + Y();
return register16_t(address.low + Y(), 0);
}
std::pair<EightBit::register16_t, uint8_t> EightBit::MOS6502::Address_AbsoluteX() noexcept {
@ -459,7 +459,7 @@ std::pair<EightBit::register16_t, uint8_t> EightBit::MOS6502::Address_AbsoluteY(
}
EightBit::register16_t EightBit::MOS6502::Address_IndexedIndirectX() noexcept {
BUS().ADDRESS() = { Address_ZeroPageX(), 0 };
BUS().ADDRESS() = Address_ZeroPageX();
return getWordPaged();
}