Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate macros from 6502 bus operation actions. #1448

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Machines/Acorn/Electron/Electron.cpp
Original file line number Diff line number Diff line change
@@ -250,15 +250,15 @@ template <bool has_scsi_bus> class ConcreteMachine:
}

if(address < 0x8000) {
if(isReadOperation(operation)) {
if(is_read(operation)) {
*value = ram_[address];
} else {
ram_[address] = *value;
}
} else {
switch(address & 0xff0f) {
case 0xfe00:
if(isReadOperation(operation)) {
if(is_read(operation)) {
*value = interrupt_status_;
interrupt_status_ &= ~PowerOnReset;
} else {
@@ -267,7 +267,7 @@ template <bool has_scsi_bus> class ConcreteMachine:
}
break;
case 0xfe07:
if(!isReadOperation(operation)) {
if(!is_read(operation)) {
// update speaker mode
bool new_speaker_is_enabled = (*value & 6) == 2;
if(new_speaker_is_enabled != speaker_is_enabled_) {
@@ -291,12 +291,12 @@ template <bool has_scsi_bus> class ConcreteMachine:
case 0xfe02: case 0xfe03:
case 0xfe08: case 0xfe09: case 0xfe0a: case 0xfe0b:
case 0xfe0c: case 0xfe0d: case 0xfe0e: case 0xfe0f:
if(!isReadOperation(operation)) {
if(!is_read(operation)) {
video_.write(address, *value);
}
break;
case 0xfe04:
if(isReadOperation(operation)) {
if(is_read(operation)) {
*value = tape_.get_data_register();
tape_.clear_interrupts(Interrupt::ReceiveDataFull);
} else {
@@ -305,7 +305,7 @@ template <bool has_scsi_bus> class ConcreteMachine:
}
break;
case 0xfe05:
if(!isReadOperation(operation)) {
if(!is_read(operation)) {
const uint8_t interruptDisable = (*value)&0xf0;
if( interruptDisable ) {
if( interruptDisable&0x10 ) interrupt_status_ &= ~Interrupt::DisplayEnd;
@@ -332,7 +332,7 @@ template <bool has_scsi_bus> class ConcreteMachine:
}
break;
case 0xfe06:
if(!isReadOperation(operation)) {
if(!is_read(operation)) {
update_audio();
sound_generator_.set_divider(*value);
tape_.set_counter(*value);
@@ -345,22 +345,22 @@ template <bool has_scsi_bus> class ConcreteMachine:
is_holding_shift_ = false;
set_key_state(KeyShift, false);
}
if(isReadOperation(operation))
if(is_read(operation))
*value = plus3_->read(address);
else
plus3_->write(address, *value);
}
break;
case 0xfc00:
if(plus3_ && (address&0x00f0) == 0x00c0) {
if(!isReadOperation(operation)) {
if(!is_read(operation)) {
plus3_->set_control_register(*value);
} else *value = 1;
}

if(has_scsi_bus && (address&0x00f0) == 0x0040) {
scsi_acknowledge_ = true;
if(!isReadOperation(operation)) {
if(!is_read(operation)) {
scsi_data_ = *value;
push_scsi_output();
} else {
@@ -377,7 +377,7 @@ template <bool has_scsi_bus> class ConcreteMachine:
}
break;
case 0xfc01:
if(has_scsi_bus && (address&0x00f0) == 0x0040 && isReadOperation(operation)) {
if(has_scsi_bus && (address&0x00f0) == 0x0040 && is_read(operation)) {
// Status byte is:
//
// b7: SCSI C/D
@@ -427,7 +427,7 @@ template <bool has_scsi_bus> class ConcreteMachine:

default:
if(address >= 0xc000) {
if(isReadOperation(operation)) {
if(is_read(operation)) {
if(
use_fast_tape_hack_ &&
(operation == CPU::MOS6502::BusOperation::ReadOpcode) &&
@@ -479,7 +479,7 @@ template <bool has_scsi_bus> class ConcreteMachine:
}
}
} else {
if(isReadOperation(operation)) {
if(is_read(operation)) {
*value = roms_[active_rom_][address & 16383];
if(keyboard_is_active_) {
*value &= 0xf0;
20 changes: 10 additions & 10 deletions Machines/Apple/AppleII/AppleII.cpp
Original file line number Diff line number Diff line change
@@ -722,14 +722,14 @@ template <Analyser::Static::AppleII::Target::Model model, bool has_mockingboard>

bool has_updated_cards = false;
if(read_pages_[address >> 8]) {
if(isReadOperation(operation)) *value = read_pages_[address >> 8][address & 0xff];
if(is_read(operation)) *value = read_pages_[address >> 8][address & 0xff];
else {
if(address >= 0x200 && address < 0x6000) update_video();
if(write_pages_[address >> 8]) write_pages_[address >> 8][address & 0xff] = *value;
}

if(is_iie(model)) {
auxiliary_switches_.access(address, isReadOperation(operation));
auxiliary_switches_.access(address, is_read(operation));
}
} else {
// Assume a vapour read unless it turns out otherwise; this is a little
@@ -745,7 +745,7 @@ template <Analyser::Static::AppleII::Target::Model model, bool has_mockingboard>
// doesn't. The call into the video isn't free because it's a just-in-time
// actor, but this will actually be the result most of the time so it's not
// too terrible.
if(isReadOperation(operation) && address != 0xc000) {
if(is_read(operation) && address != 0xc000) {
// Ensure any enqueued video changes are applied before grabbing the
// vapour value.
if(video_.has_deferred_actions()) {
@@ -756,7 +756,7 @@ template <Analyser::Static::AppleII::Target::Model model, bool has_mockingboard>

switch(address) {
default:
if(isReadOperation(operation)) {
if(is_read(operation)) {
// Read-only switches.
switch(address) {
default: break;
@@ -868,13 +868,13 @@ template <Analyser::Static::AppleII::Target::Model model, bool has_mockingboard>
case 0xc055:
update_video();
video_.set_page2(address&1);
auxiliary_switches_.access(address, isReadOperation(operation));
auxiliary_switches_.access(address, is_read(operation));
break;
case 0xc056:
case 0xc057:
update_video();
video_.set_high_resolution(address&1);
auxiliary_switches_.access(address, isReadOperation(operation));
auxiliary_switches_.access(address, is_read(operation));
break;

case 0xc05e:
@@ -889,7 +889,7 @@ template <Analyser::Static::AppleII::Target::Model model, bool has_mockingboard>
keyboard_.clear_keyboard_input();

// On the IIe, reading C010 returns additional key info.
if(is_iie(model) && isReadOperation(operation)) {
if(is_iie(model) && is_read(operation)) {
*value = (keyboard_.get_key_is_down() ? 0x80 : 0x00) | (keyboard_.get_keyboard_input() & 0x7f);
}
break;
@@ -904,7 +904,7 @@ template <Analyser::Static::AppleII::Target::Model model, bool has_mockingboard>
case 0xc081: case 0xc085: case 0xc089: case 0xc08d:
case 0xc082: case 0xc086: case 0xc08a: case 0xc08e:
case 0xc083: case 0xc087: case 0xc08b: case 0xc08f:
language_card_.access(address, isReadOperation(operation));
language_card_.access(address, is_read(operation));
break;
}

@@ -950,7 +950,7 @@ template <Analyser::Static::AppleII::Target::Model model, bool has_mockingboard>

// If the selected card is a just-in-time card, update the just-in-time cards,
// and then message it specifically.
const bool is_read = isReadOperation(operation);
const bool is_read = CPU::MOS6502Esque::is_read(operation);
Apple::II::Card *const target = cards_[size_t(card_number)].get();
if(target && !is_every_cycle_card(target)) {
update_just_in_time_cards();
@@ -971,7 +971,7 @@ template <Analyser::Static::AppleII::Target::Model model, bool has_mockingboard>

if(!has_updated_cards && !every_cycle_cards_.empty()) {
// Update all every-cycle cards and give them the cycle.
const bool is_read = isReadOperation(operation);
const bool is_read = CPU::MOS6502Esque::is_read(operation);
for(const auto &card: every_cycle_cards_) {
card->run_for(Cycles(1), is_stretched_cycle);
card->perform_bus_operation(Apple::II::Card::None, is_read, address, value);
4 changes: 2 additions & 2 deletions Machines/Apple/AppleIIgs/AppleIIgs.cpp
Original file line number Diff line number Diff line change
@@ -284,7 +284,7 @@ class ConcreteMachine:
*value = rom_[rom_.size() - 65536 + address];
} else if(region.flags & MemoryMap::Region::IsIO) {
// Ensure classic auxiliary and language card accesses have effect.
const bool is_read = isReadOperation(operation);
const bool is_read = CPU::MOS6502Esque::is_read(operation);
memory_.access(uint16_t(address), is_read);

const auto address_suffix = address & 0xffff;
@@ -818,7 +818,7 @@ class ConcreteMachine:
assert(operation != CPU::WDC65816::BusOperation::ReadOpcode || region.read);
is_1Mhz = region.flags & MemoryMap::Region::Is1Mhz;

if(isReadOperation(operation)) {
if(is_read(operation)) {
*value = memory_.read(region, address);
} else {
// Shadowed writes also occur "at 1Mhz".
2 changes: 1 addition & 1 deletion Machines/Atari/2600/Cartridges/ActivisionStack.hpp
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ class ActivisionStack: public BusExtender {
}
}

if(isReadOperation(operation)) {
if(is_read(operation)) {
*value = rom_ptr_[address & 4095];
}

6 changes: 3 additions & 3 deletions Machines/Atari/2600/Cartridges/Atari16k.hpp
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ class Atari16k: public BusExtender {

if(address >= 0x1ff6 && address <= 0x1ff9) rom_ptr_ = rom_base_ + (address - 0x1ff6) * 4096;

if(isReadOperation(operation)) {
if(is_read(operation)) {
*value = rom_ptr_[address & 4095];
}
}
@@ -53,12 +53,12 @@ class Atari16kSuperChip: public BusExtender {

if(address >= 0x1ff6 && address <= 0x1ff9) rom_ptr_ = rom_base_ + (address - 0x1ff6) * 4096;

if(isReadOperation(operation)) {
if(is_read(operation)) {
*value = rom_ptr_[address & 4095];
}

if(address < 0x1080) ram_[address & 0x7f] = *value;
else if(address < 0x1100 && isReadOperation(operation)) *value = ram_[address & 0x7f];
else if(address < 0x1100 && is_read(operation)) *value = ram_[address & 0x7f];
}

private:
6 changes: 3 additions & 3 deletions Machines/Atari/2600/Cartridges/Atari32k.hpp
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ class Atari32k: public BusExtender {

if(address >= 0x1ff4 && address <= 0x1ffb) rom_ptr_ = rom_base_ + (address - 0x1ff4) * 4096;

if(isReadOperation(operation)) {
if(is_read(operation)) {
*value = rom_ptr_[address & 4095];
}
}
@@ -51,12 +51,12 @@ class Atari32kSuperChip: public BusExtender {

if(address >= 0x1ff4 && address <= 0x1ffb) rom_ptr_ = rom_base_ + (address - 0x1ff4) * 4096;

if(isReadOperation(operation)) {
if(is_read(operation)) {
*value = rom_ptr_[address & 4095];
}

if(address < 0x1080) ram_[address & 0x7f] = *value;
else if(address < 0x1100 && isReadOperation(operation)) *value = ram_[address & 0x7f];
else if(address < 0x1100 && is_read(operation)) *value = ram_[address & 0x7f];
}

private:
6 changes: 3 additions & 3 deletions Machines/Atari/2600/Cartridges/Atari8k.hpp
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ class Atari8k: public BusExtender {
if(address == 0x1ff8) rom_ptr_ = rom_base_;
else if(address == 0x1ff9) rom_ptr_ = rom_base_ + 4096;

if(isReadOperation(operation)) {
if(is_read(operation)) {
*value = rom_ptr_[address & 4095];
}
}
@@ -53,12 +53,12 @@ class Atari8kSuperChip: public BusExtender {
if(address == 0x1ff8) rom_ptr_ = rom_base_;
if(address == 0x1ff9) rom_ptr_ = rom_base_ + 4096;

if(isReadOperation(operation)) {
if(is_read(operation)) {
*value = rom_ptr_[address & 4095];
}

if(address < 0x1080) ram_[address & 0x7f] = *value;
else if(address < 0x1100 && isReadOperation(operation)) *value = ram_[address & 0x7f];
else if(address < 0x1100 && is_read(operation)) *value = ram_[address & 0x7f];
}

private:
4 changes: 2 additions & 2 deletions Machines/Atari/2600/Cartridges/CBSRAMPlus.hpp
Original file line number Diff line number Diff line change
@@ -27,12 +27,12 @@ class CBSRAMPlus: public BusExtender {

if(address >= 0x1ff8 && address <= 0x1ffa) rom_ptr_ = rom_base_ + (address - 0x1ff8) * 4096;

if(isReadOperation(operation)) {
if(is_read(operation)) {
*value = rom_ptr_[address & 4095];
}

if(address < 0x1100) ram_[address & 0xff] = *value;
else if(address < 0x1200 && isReadOperation(operation)) *value = ram_[address & 0xff];
else if(address < 0x1200 && is_read(operation)) *value = ram_[address & 0xff];
}

private:
10 changes: 5 additions & 5 deletions Machines/Atari/2600/Cartridges/Cartridge.hpp
Original file line number Diff line number Diff line change
@@ -78,13 +78,13 @@ template<class T> class Cartridge:
cycles_since_6532_update_ += Cycles(cycles_run_for / 3);
bus_extender_.advance_cycles(cycles_run_for / 3);

if(isAccessOperation(operation)) {
if(is_access(operation)) {
// give the cartridge a chance to respond to the bus access
bus_extender_.perform_bus_operation(operation, address, value);

// check for a RIOT RAM access
if((address&0x1280) == 0x80) {
if(isReadOperation(operation)) {
if(is_read(operation)) {
returnValue &= mos6532_.get_ram(address);
} else {
mos6532_.set_ram(address, *value);
@@ -93,7 +93,7 @@ template<class T> class Cartridge:

// check for a TIA access
if(!(address&0x1080)) {
if(isReadOperation(operation)) {
if(is_read(operation)) {
const uint16_t decodedAddress = address & 0xf;
switch(decodedAddress) {
case 0x00: // missile 0 / player collisions
@@ -183,14 +183,14 @@ template<class T> class Cartridge:
// check for a PIA access
if((address&0x1280) == 0x280) {
update_6532();
if(isReadOperation(operation)) {
if(is_read(operation)) {
returnValue &= mos6532_.read(address);
} else {
mos6532_.write(address, *value);
}
}

if(isReadOperation(operation)) {
if(is_read(operation)) {
*value &= returnValue;
}
}
4 changes: 2 additions & 2 deletions Machines/Atari/2600/Cartridges/CommaVid.hpp
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ class CommaVid: public BusExtender {
address &= 0x1fff;

if(address < 0x1400) {
if(isReadOperation(operation)) *value = ram_[address & 1023];
if(is_read(operation)) *value = ram_[address & 1023];
return;
}

@@ -34,7 +34,7 @@ class CommaVid: public BusExtender {
return;
}

if(isReadOperation(operation)) *value = rom_base_[address & 2047];
if(is_read(operation)) *value = rom_base_[address & 2047];
}

private:
8 changes: 4 additions & 4 deletions Machines/Atari/2600/Cartridges/MNetwork.hpp
Original file line number Diff line number Diff line change
@@ -41,18 +41,18 @@ class MNetwork: public BusExtender {
if(address < 0x1900) {
high_ram_ptr_[address & 255] = *value;
} else if(address < 0x1a00) {
if(isReadOperation(operation)) *value = high_ram_ptr_[address & 255];
if(is_read(operation)) *value = high_ram_ptr_[address & 255];
} else {
if(isReadOperation(operation)) *value = rom_ptr_[1][address & 2047];
if(is_read(operation)) *value = rom_ptr_[1][address & 2047];
}
} else {
if(rom_ptr_[0]) {
if(isReadOperation(operation)) *value = rom_ptr_[0][address & 2047];
if(is_read(operation)) *value = rom_ptr_[0][address & 2047];
} else {
if(address < 0x1400) {
low_ram_[address & 1023] = *value;
} else {
if(isReadOperation(operation)) *value = low_ram_[address & 1023];
if(is_read(operation)) *value = low_ram_[address & 1023];
}
}
}
Loading