From c485c460f7abd9c53a8e4570a4fb48b2c3f055aa Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 4 Jun 2017 18:08:35 -0400 Subject: [PATCH] Imported the ZX80 and 81 system ROMs (though not publicly), added enough code to post their contents into C++ world. --- Machines/ZX8081/ZX8081.cpp | 10 ++++++++++ Machines/ZX8081/ZX8081.hpp | 12 ++++++++++++ .../Mac/Clock Signal/Machine/Wrappers/CSZX8081.mm | 10 ++++++++++ Processors/Z80/Z80.hpp | 7 +++++-- ROMImages/ZX8081/readme.txt | 6 ++++++ 5 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 ROMImages/ZX8081/readme.txt diff --git a/Machines/ZX8081/ZX8081.cpp b/Machines/ZX8081/ZX8081.cpp index ac9483e16..417823a55 100644 --- a/Machines/ZX8081/ZX8081.cpp +++ b/Machines/ZX8081/ZX8081.cpp @@ -28,6 +28,9 @@ void Machine::setup_output(float aspect_ratio) { "}"); } +void Machine::flush() { +} + void Machine::close_output() { } @@ -44,3 +47,10 @@ void Machine::run_for_cycles(int number_of_cycles) { void Machine::configure_as_target(const StaticAnalyser::Target &target) { } + +void Machine::set_rom(ROMType type, std::vector data) { + switch(type) { + case ZX80: zx80_rom_ = data; break; + case ZX81: zx81_rom_ = data; break; + } +} diff --git a/Machines/ZX8081/ZX8081.hpp b/Machines/ZX8081/ZX8081.hpp index c2ccc8df4..41c90ef31 100644 --- a/Machines/ZX8081/ZX8081.hpp +++ b/Machines/ZX8081/ZX8081.hpp @@ -14,8 +14,15 @@ #include "../../Processors/Z80/Z80.hpp" +#include +#include + namespace ZX8081 { +enum ROMType: uint8_t { + ZX80, ZX81 +}; + class Machine: public CPU::Z80::Processor, public CRTMachine::Machine, @@ -24,6 +31,7 @@ class Machine: Machine(); int perform_machine_cycle(const CPU::Z80::MachineCycle &cycle); + void flush(); void setup_output(float aspect_ratio); void close_output(); @@ -35,8 +43,12 @@ class Machine: void configure_as_target(const StaticAnalyser::Target &target); + void set_rom(ROMType type, std::vector data); + private: std::shared_ptr crt_; + std::vector zx81_rom_, zx80_rom_, rom_; + std::vector ram_; }; } diff --git a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSZX8081.mm b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSZX8081.mm index 32bb5703c..c5801d3ce 100644 --- a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSZX8081.mm +++ b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSZX8081.mm @@ -10,6 +10,10 @@ #include "ZX8081.hpp" +#import "CSMachine+Subclassing.h" +#import "NSData+StdVector.h" +#import "NSBundle+DataResource.h" + @implementation CSZX8081 { ZX8081::Machine zx8081; } @@ -21,10 +25,16 @@ - (instancetype)init { self = [super init]; if(self) { + zx8081.set_rom(ZX8081::ROMType::ZX80, [self rom:@"zx80"].stdVector8); + zx8081.set_rom(ZX8081::ROMType::ZX81, [self rom:@"zx81"].stdVector8); } return self; } +- (NSData *)rom:(NSString *)name { + return [[NSBundle mainBundle] dataForResource:name withExtension:@"rom" subdirectory:@"ROMImages/ZX8081"]; +} + #pragma mark - Keyboard Mapping - (void)clearAllKeys { diff --git a/Processors/Z80/Z80.hpp b/Processors/Z80/Z80.hpp index d901a361a..396258122 100644 --- a/Processors/Z80/Z80.hpp +++ b/Processors/Z80/Z80.hpp @@ -775,7 +775,10 @@ template class Processor { while(bus_request_line_) { static MachineCycle bus_acknowledge_cycle = {BusOperation::BusAcknowledge, 1}; number_of_cycles_ -= static_cast(this)->perform_machine_cycle(bus_acknowledge_cycle) + 1; - if(!number_of_cycles_) return; + if(!number_of_cycles_) { + flush(); + return; + } } while(!bus_request_line_) { @@ -790,7 +793,7 @@ template class Processor { switch(operation->type) { case MicroOp::BusOperation: - if(number_of_cycles_ < operation->machine_cycle.length) { scheduled_program_counter_--; return; } + if(number_of_cycles_ < operation->machine_cycle.length) { scheduled_program_counter_--; flush(); return; } number_of_cycles_ -= operation->machine_cycle.length; last_request_status_ = request_status_; number_of_cycles_ -= static_cast(this)->perform_machine_cycle(operation->machine_cycle); diff --git a/ROMImages/ZX8081/readme.txt b/ROMImages/ZX8081/readme.txt new file mode 100644 index 000000000..1813d6efa --- /dev/null +++ b/ROMImages/ZX8081/readme.txt @@ -0,0 +1,6 @@ +ROM files would ordinarily go here; the copyright status of these is uncertain so they have not been included in this repository. + +Expected files: + +zx80.rom +zx81.rom \ No newline at end of file