1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-26 15:32:04 +00:00

Added memory fuzzing as a way to verify state being written by the Z80. Eventually discovered the HALT problem as fixed in the last commit, so have stripped away the caveman stuff again.

This commit is contained in:
Thomas Harte 2017-06-05 10:36:07 -04:00
parent 3df6eba237
commit 23ca00fd9a
3 changed files with 12 additions and 13 deletions

View File

@ -22,3 +22,7 @@ void Memory::Fuzz(uint8_t *buffer, size_t size) {
buffer[c] = (uint8_t)(std::rand() >> shift);
}
}
void Memory::Fuzz(std::vector<uint8_t> &buffer) {
Fuzz(buffer.data(), buffer.size());
}

View File

@ -11,10 +11,12 @@
#include <cstdint>
#include <cstddef>
#include <vector>
namespace Memory {
void Fuzz(uint8_t *buffer, size_t size);
void Fuzz(std::vector<uint8_t> &buffer);
}

View File

@ -8,33 +8,33 @@
#include "ZX8081.hpp"
//static int logging_delay = 3250000 * 10;
#include "../MemoryFuzzer.hpp"
using namespace ZX8081;
Machine::Machine() :
vsync_(false),
hsync_(false),
ram_(65536) {
ram_(1024) {
// run at 3.25 Mhz
set_clock_rate(3250000);
Memory::Fuzz(ram_);
}
int Machine::perform_machine_cycle(const CPU::Z80::MachineCycle &cycle) {
cycles_since_display_update_ += cycle.length;
// logging_delay -= cycle.length;
uint8_t r;
uint16_t address = cycle.address ? *cycle.address : 0;
switch(cycle.operation) {
case CPU::Z80::BusOperation::Output:
if((*cycle.address&0xff) == 0xff) {
if((address&7) == 7) {
set_vsync(false);
}
break;
case CPU::Z80::BusOperation::Input:
if((*cycle.address&0xff) == 0xfe) {
if((address&7) == 6) {
set_vsync(true);
}
*cycle.value = 0xff;
@ -55,13 +55,9 @@ int Machine::perform_machine_cycle(const CPU::Z80::MachineCycle &cycle) {
uint8_t value = ram_[address & 1023];
if(address&0x8000 && !(value & 0x40) && cycle.operation == CPU::Z80::BusOperation::ReadOpcode && !get_halt_line()) {
// TODO: character lookup.
// if(logging_delay < 0) printf("%02x ", value);
if(value) printf("!");
output_byte(value);
*cycle.value = 0;
}
else
*cycle.value = value;
} else *cycle.value = value;
}
break;
@ -124,16 +120,13 @@ void Machine::update_display() {
void Machine::set_vsync(bool sync) {
if(sync == vsync_) return;
// if(logging_delay < 0) if(!sync) printf("\n---\n");
vsync_ = sync;
}
void Machine::set_hsync(bool sync) {
if(sync == hsync_) return;
// if(logging_delay < 0) if(sync) printf("\n");
hsync_ = sync;
}
void Machine::output_byte(uint8_t byte) {
// printf("%02x ", byte);
}