1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-04-20 10:17:05 +00:00

Take a swing at reset.

This commit is contained in:
Thomas Harte
2025-11-03 20:50:47 -05:00
parent fba2d37714
commit d4aa0799a9
4 changed files with 34 additions and 15 deletions
+3 -2
View File
@@ -925,10 +925,11 @@ public:
if constexpr (is_read(operation)) {
const uint8_t result = tube_ula_.host_read(address);
value = result;
// Logger::info().append("Read tube %04x: %02x", +address, result);
Logger::info().append("Read tube %04x: %02x", +address, result);
} else {
// Logger::info().append("Write tube %04x: %02x", +address, value);
Logger::info().append("Write tube %04x: %02x", +address, value);
tube_ula_.host_write(address, value);
tube6502_.set_reset(tube_ula_.parasite_reset());
}
}
} else if(address >= 0xfe08 && address < 0xfe10) {
+5 -3
View File
@@ -17,12 +17,14 @@ template <size_t length, typename ULAT>
struct FIFO {
FIFO(ULAT &ula, const uint8_t mask = 0x00) : ula_(ula), mask_(mask) {}
/// @returns b7 set exactly if this FIFO is not empty.
uint8_t data_available() const {
return (read_ != write_) ? 0x80 : 0x00;
return (read_ != write_) ? 0x80 : 0x00;
}
uint8_t full() const {
return (size_t(write_ - read_) < length) ? 0x40 : 0x00;
/// @returns b6 set exactly if this FIFO is not full.
uint8_t not_full() const {
return (size_t(write_ - read_) < length) ? 0x40 : 0x00;
}
void write(const uint8_t value) {
+14 -2
View File
@@ -50,12 +50,19 @@ public:
void set_rom(const std::vector<uint8_t> &source) {
// TODO: verify the ROM is 2kb.
// TODO: determine whethe rthis really is ROM, or is ROM that should have copied itself to RAM, or is something else.
std::copy(source.begin(), source.end(), &ram_[65536 - 2048]);
// TODO: determine whether this really is ROM, or is ROM that should have copied itself to RAM, or is something else.
std::copy(source.begin(), source.end(), rom_);
reinstall_rom();
}
void set_irq() { m6502_.template set<CPU::MOS6502Mk2::Line::IRQ>(true); }
void set_nmi() { m6502_.template set<CPU::MOS6502Mk2::Line::NMI>(true); }
void set_reset(const bool reset) {
m6502_.template set<CPU::MOS6502Mk2::Line::Reset>(reset);
if(reset) {
reinstall_rom();
}
}
private:
void update_interrupts() {
@@ -63,6 +70,11 @@ private:
m6502_.template set<CPU::MOS6502Mk2::Line::NMI>(ula_.has_parasite_nmi());
}
void reinstall_rom() {
std::copy(std::begin(rom_), std::end(rom_), &ram_[65536 - 2048]);
}
uint8_t rom_[2048];
uint8_t ram_[65536];
Cycles cycles_modulo_;
+12 -8
View File
@@ -42,6 +42,10 @@ struct ULA {
}
}
bool parasite_reset() const {
return !(flags_ & 0x20);
}
void fifo_has_data(const uint8_t mask) {
if(!(flags_ & mask)) return;
@@ -86,13 +90,13 @@ struct ULA {
uint8_t parasite_read(const uint16_t address) {
switch(address & 7) {
case 0: return to_parasite1_.data_available() | to_host1_.full() | status();
case 0: return to_parasite1_.data_available() | to_host1_.not_full() | status();
case 1: return to_parasite1_.read();
case 2: return to_parasite2_.data_available() | to_host2_.full();
case 2: return to_parasite2_.data_available() | to_host2_.not_full();
case 3: return to_parasite2_.read();
case 4: return to_parasite3_.data_available() | to_host3_.full();
case 4: return to_parasite3_.data_available() | to_host3_.not_full();
case 5: return to_parasite3_.read();
case 6: return to_parasite4_.data_available() | to_host4_.full();
case 6: return to_parasite4_.data_available() | to_host4_.not_full();
case 7: return to_parasite4_.read();
default: __builtin_unreachable();
@@ -112,13 +116,13 @@ struct ULA {
uint8_t host_read(const uint16_t address) {
switch(address & 7) {
case 0: return to_host1_.data_available() | to_parasite1_.full() | status();
case 0: return to_host1_.data_available() | to_parasite1_.not_full() | status();
case 1: return to_host1_.read();
case 2: return to_host2_.data_available() | to_parasite2_.full();
case 2: return to_host2_.data_available() | to_parasite2_.not_full();
case 3: return to_host2_.read();
case 4: return to_host3_.data_available() | to_parasite3_.full();
case 4: return to_host3_.data_available() | to_parasite3_.not_full();
case 5: return to_host3_.read();
case 6: return to_host4_.data_available() | to_parasite4_.full();
case 6: return to_host4_.data_available() | to_parasite4_.not_full();
case 7: return to_host4_.read();
default: __builtin_unreachable();