1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-29 12:50:28 +00:00

Avoid infinite loops for completely undefined addresses.

This commit is contained in:
Thomas Harte 2021-12-18 17:48:45 -05:00
parent f118891970
commit 54aa211f56
2 changed files with 8 additions and 8 deletions

View File

@ -810,13 +810,13 @@ void Chipset::perform(const CPU::MC68000::Microcycle &cycle) {
const uint32_t register_address = *cycle.address & 0x1fe;
if(cycle.operation & Microcycle::Read) {
cycle.set_value16(read(register_address));
cycle.set_value16(read<true>(register_address));
} else {
write(register_address, cycle.value16());
write<true>(register_address, cycle.value16());
}
}
void Chipset::write(uint32_t address, uint16_t value) {
template <bool allow_conversion> void Chipset::write(uint32_t address, uint16_t value) {
#define ApplySetClear(target, mask) { \
if(value & 0x8000) { \
target |= (value & mask); \
@ -828,7 +828,7 @@ void Chipset::write(uint32_t address, uint16_t value) {
switch(address) {
default:
// If there was nothing to write, perform a throwaway read.
read(address);
if constexpr (allow_conversion) read<false>(address);
break;
// Raster position.
@ -1083,12 +1083,12 @@ void Chipset::write(uint32_t address, uint16_t value) {
#undef ApplySetClear
}
uint16_t Chipset::read(uint32_t address) {
template <bool allow_conversion> uint16_t Chipset::read(uint32_t address) {
switch(address) {
default:
// If there was nothing to read, perform a write.
// TODO: Rather than 0xffff, should be whatever is left on the bus, vapour-lock style.
write(address, 0xffff);
if constexpr (allow_conversion) write<false>(address, 0xffff);
return 0xffff;
// Raster position.

View File

@ -108,8 +108,8 @@ class Chipset: private ClockingHint::Observer {
friend class DMADeviceBase;
// MARK: - Register read/write functions.
uint16_t read(uint32_t address);
void write(uint32_t address, uint16_t value);
template <bool allow_conversion> uint16_t read(uint32_t address);
template <bool allow_conversion> void write(uint32_t address, uint16_t value);
// MARK: - E Clock and keyboard dividers.