From 7e3a46c33efe0a2781bf4a8756ce49a41a46d84e Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 4 Jun 2017 21:54:55 -0400 Subject: [PATCH] [Re]discovered that sync may also be a product of the interrupt cycle. So started looking into that. --- Machines/ZX8081/ZX8081.cpp | 27 +++++++++++++++++++-------- Machines/ZX8081/ZX8081.hpp | 5 +++-- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Machines/ZX8081/ZX8081.cpp b/Machines/ZX8081/ZX8081.cpp index a5fd50498..ab6cd09cf 100644 --- a/Machines/ZX8081/ZX8081.cpp +++ b/Machines/ZX8081/ZX8081.cpp @@ -11,7 +11,8 @@ using namespace ZX8081; Machine::Machine() : - vertical_sync_(false), + vsync_(false), + hsync_(false), ram_(65536) { // run at 3.25 Mhz set_clock_rate(3250000); @@ -23,24 +24,26 @@ int Machine::perform_machine_cycle(const CPU::Z80::MachineCycle &cycle) { uint8_t r; switch(cycle.operation) { case CPU::Z80::BusOperation::Output: - if(*cycle.address == 0xff) { - update_display(); - set_sync(false); + if((*cycle.address&0xff) == 0xff) { + set_vsync(false); } break; case CPU::Z80::BusOperation::Input: - if(*cycle.address == 0xfe) { - update_display(); - set_sync(true); + if((*cycle.address&0xff) == 0xfe) { + set_vsync(true); } + *cycle.value = 0xff; break; case CPU::Z80::BusOperation::Interrupt: + set_hsync(true); *cycle.value = 0xff; break; case CPU::Z80::BusOperation::ReadOpcode: + set_hsync(false); +// printf("%04x\n", *cycle.address); r = (uint8_t)get_value_of_register(CPU::Z80::Register::R); set_interrupt_line(!(r & 0x40)); case CPU::Z80::BusOperation::Read: @@ -113,8 +116,16 @@ void Machine::update_display() { cycles_since_display_update_ = 0; } -void Machine::set_sync(bool sync) { +void Machine::set_vsync(bool sync) { + if(sync && !vsync_) printf("\n---\n"); + vsync_ = sync; +} + +void Machine::set_hsync(bool sync) { + if(sync && !hsync_) printf("\n"); + hsync_ = sync; } void Machine::output_byte(uint8_t byte) { + printf("%02x ", byte); } diff --git a/Machines/ZX8081/ZX8081.hpp b/Machines/ZX8081/ZX8081.hpp index 3edd4791c..2cb3da838 100644 --- a/Machines/ZX8081/ZX8081.hpp +++ b/Machines/ZX8081/ZX8081.hpp @@ -50,11 +50,12 @@ class Machine: std::vector zx81_rom_, zx80_rom_, rom_; std::vector ram_; - bool vertical_sync_; + bool vsync_, hsync_; int cycles_since_display_update_; void update_display(); - void set_sync(bool sync); + void set_vsync(bool sync); + void set_hsync(bool sync); void output_byte(uint8_t byte); };