From d2637123c4dfbdd3498f51bd73f3b7ce2afafe1b Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 4 Jun 2017 17:55:19 -0400 Subject: [PATCH] Added necessary support to get as far as an empty window when attempting to load a piece of ZX80 software. --- Machines/ZX8081/ZX8081.cpp | 46 ++++++++++ Machines/ZX8081/ZX8081.hpp | 44 +++++++++ .../Clock Signal.xcodeproj/project.pbxproj | 30 +++++- .../Clock Signal/Base.lproj/ZX8081Options.xib | 92 +++++++++++++++++++ .../StaticAnalyser/CSStaticAnalyser.mm | 3 + .../Clock Signal/Machine/Wrappers/CSZX8081.h | 17 ++++ .../Clock Signal/Machine/Wrappers/CSZX8081.mm | 38 ++++++++ Processors/Z80/Z80.hpp | 2 +- StaticAnalyser/ZX8081/StaticAnalyser.cpp | 5 + 9 files changed, 273 insertions(+), 4 deletions(-) create mode 100644 Machines/ZX8081/ZX8081.cpp create mode 100644 Machines/ZX8081/ZX8081.hpp create mode 100644 OSBindings/Mac/Clock Signal/Base.lproj/ZX8081Options.xib create mode 100644 OSBindings/Mac/Clock Signal/Machine/Wrappers/CSZX8081.h create mode 100644 OSBindings/Mac/Clock Signal/Machine/Wrappers/CSZX8081.mm diff --git a/Machines/ZX8081/ZX8081.cpp b/Machines/ZX8081/ZX8081.cpp new file mode 100644 index 000000000..ac9483e16 --- /dev/null +++ b/Machines/ZX8081/ZX8081.cpp @@ -0,0 +1,46 @@ +// +// ZX8081.cpp +// Clock Signal +// +// Created by Thomas Harte on 04/06/2017. +// Copyright © 2017 Thomas Harte. All rights reserved. +// + +#include "ZX8081.hpp" + +using namespace ZX8081; + +Machine::Machine() { + // run at 3.25 Mhz + set_clock_rate(3250000); +} + +int Machine::perform_machine_cycle(const CPU::Z80::MachineCycle &cycle) { + return 0; +} + +void Machine::setup_output(float aspect_ratio) { + crt_.reset(new Outputs::CRT::CRT(207 * 8, 8, Outputs::CRT::DisplayType::PAL50, 1)); + crt_->set_rgb_sampling_function( + "vec3 rgb_sample(usampler2D sampler, vec2 coordinate, vec2 icoordinate)" + "{" + "return vec3(1.0);" + "}"); +} + +void Machine::close_output() { +} + +std::shared_ptr Machine::get_crt() { + return crt_; +} + +std::shared_ptr Machine::get_speaker() { + return nullptr; +} + +void Machine::run_for_cycles(int number_of_cycles) { +} + +void Machine::configure_as_target(const StaticAnalyser::Target &target) { +} diff --git a/Machines/ZX8081/ZX8081.hpp b/Machines/ZX8081/ZX8081.hpp new file mode 100644 index 000000000..c2ccc8df4 --- /dev/null +++ b/Machines/ZX8081/ZX8081.hpp @@ -0,0 +1,44 @@ +// +// ZX8081.hpp +// Clock Signal +// +// Created by Thomas Harte on 04/06/2017. +// Copyright © 2017 Thomas Harte. All rights reserved. +// + +#ifndef ZX8081_hpp +#define ZX8081_hpp + +#include "../ConfigurationTarget.hpp" +#include "../CRTMachine.hpp" + +#include "../../Processors/Z80/Z80.hpp" + +namespace ZX8081 { + +class Machine: + public CPU::Z80::Processor, + public CRTMachine::Machine, + public ConfigurationTarget::Machine { + public: + Machine(); + + int perform_machine_cycle(const CPU::Z80::MachineCycle &cycle); + + void setup_output(float aspect_ratio); + void close_output(); + + std::shared_ptr get_crt(); + std::shared_ptr get_speaker(); + + void run_for_cycles(int number_of_cycles); + + void configure_as_target(const StaticAnalyser::Target &target); + + private: + std::shared_ptr crt_; +}; + +} + +#endif /* ZX8081_hpp */ diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index f7f699843..cdd3bb44f 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -21,6 +21,9 @@ 4B1414621B58888700E04248 /* KlausDormannTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B1414611B58888700E04248 /* KlausDormannTests.swift */; }; 4B1497881EE4A1DA00CE2596 /* ZX80O.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B1497861EE4A1DA00CE2596 /* ZX80O.cpp */; }; 4B14978B1EE4AC5E00CE2596 /* StaticAnalyser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B1497891EE4AC5E00CE2596 /* StaticAnalyser.cpp */; }; + 4B14978F1EE4B4D200CE2596 /* CSZX8081.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B14978E1EE4B4D200CE2596 /* CSZX8081.mm */; }; + 4B1497921EE4B5A800CE2596 /* ZX8081.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B1497901EE4B5A800CE2596 /* ZX8081.cpp */; }; + 4B1497951EE4B7D300CE2596 /* ZX8081Options.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4B1497941EE4B7D300CE2596 /* ZX8081Options.xib */; }; 4B1D08061E0F7A1100763741 /* TimeTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B1D08051E0F7A1100763741 /* TimeTests.mm */; }; 4B1E85751D170228001EF87D /* Typer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B1E85731D170228001EF87D /* Typer.cpp */; }; 4B1E85811D176468001EF87D /* 6532Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B1E85801D176468001EF87D /* 6532Tests.swift */; }; @@ -470,6 +473,11 @@ 4B1497871EE4A1DA00CE2596 /* ZX80O.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ZX80O.hpp; sourceTree = ""; }; 4B1497891EE4AC5E00CE2596 /* StaticAnalyser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StaticAnalyser.cpp; path = ../../StaticAnalyser/ZX8081/StaticAnalyser.cpp; sourceTree = ""; }; 4B14978A1EE4AC5E00CE2596 /* StaticAnalyser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = StaticAnalyser.hpp; path = ../../StaticAnalyser/ZX8081/StaticAnalyser.hpp; sourceTree = ""; }; + 4B14978D1EE4B4D200CE2596 /* CSZX8081.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSZX8081.h; sourceTree = ""; }; + 4B14978E1EE4B4D200CE2596 /* CSZX8081.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CSZX8081.mm; sourceTree = ""; }; + 4B1497901EE4B5A800CE2596 /* ZX8081.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ZX8081.cpp; path = ZX8081/ZX8081.cpp; sourceTree = ""; }; + 4B1497911EE4B5A800CE2596 /* ZX8081.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ZX8081.hpp; path = ZX8081/ZX8081.hpp; sourceTree = ""; }; + 4B1497941EE4B7D300CE2596 /* ZX8081Options.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ZX8081Options.xib; sourceTree = ""; }; 4B1D08051E0F7A1100763741 /* TimeTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TimeTests.mm; sourceTree = ""; }; 4B1E85731D170228001EF87D /* Typer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Typer.cpp; sourceTree = ""; }; 4B1E85741D170228001EF87D /* Typer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Typer.hpp; sourceTree = ""; }; @@ -1079,6 +1087,15 @@ name = ZX80/81; sourceTree = ""; }; + 4B1497931EE4B5AC00CE2596 /* ZX8081 */ = { + isa = PBXGroup; + children = ( + 4B1497901EE4B5A800CE2596 /* ZX8081.cpp */, + 4B1497911EE4B5A800CE2596 /* ZX8081.hpp */, + ); + name = ZX8081; + sourceTree = ""; + }; 4B1E85791D174DEC001EF87D /* 6532 */ = { isa = PBXGroup; children = ( @@ -1144,13 +1161,15 @@ isa = PBXGroup; children = ( 4B2A53991D117D36003C6002 /* CSAtari2600.h */, - 4B2A539A1D117D36003C6002 /* CSAtari2600.mm */, 4B2A539B1D117D36003C6002 /* CSElectron.h */, - 4B2A539C1D117D36003C6002 /* CSElectron.mm */, 4BCF1FA61DADC5250039D2E7 /* CSOric.h */, - 4BCF1FA71DADC5250039D2E7 /* CSOric.mm */, 4B2A539D1D117D36003C6002 /* CSVic20.h */, + 4B14978D1EE4B4D200CE2596 /* CSZX8081.h */, + 4B2A539A1D117D36003C6002 /* CSAtari2600.mm */, + 4B2A539C1D117D36003C6002 /* CSElectron.mm */, + 4BCF1FA71DADC5250039D2E7 /* CSOric.mm */, 4B2A539E1D117D36003C6002 /* CSVic20.mm */, + 4B14978E1EE4B4D200CE2596 /* CSZX8081.mm */, ); path = Wrappers; sourceTree = ""; @@ -1280,6 +1299,7 @@ 4B8FE2211DA19FB20090D3CE /* MachinePanel.swift */, 4B2A332E1DB86869002876E3 /* OricOptionsPanel.swift */, 4B9CCDA01DA279CA0098B625 /* Vic20OptionsPanel.swift */, + 4B1497941EE4B7D300CE2596 /* ZX8081Options.xib */, 4B8FE2131DA19D5F0090D3CE /* Atari2600Options.xib */, 4B8FE2171DA19D5F0090D3CE /* ElectronOptions.xib */, 4B8FE2151DA19D5F0090D3CE /* MachineDocument.xib */, @@ -1851,6 +1871,7 @@ 4B4DC81D1D2C2425003C5BF8 /* Commodore */, 4B2E2D9E1C3A070900138695 /* Electron */, 4BCF1FA51DADC3E10039D2E7 /* Oric */, + 4B1497931EE4B5AC00CE2596 /* ZX8081 */, ); name = Machines; path = ../../Machines; @@ -2221,6 +2242,7 @@ 4B8FE21D1DA19D5F0090D3CE /* ElectronOptions.xib in Resources */, 4B79E4461E3AF38600141F11 /* floppy525.png in Resources */, 4BC9DF451D044FCA00F44158 /* ROMImages in Resources */, + 4B1497951EE4B7D300CE2596 /* ZX8081Options.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2530,6 +2552,7 @@ 4BCF1FA41DADC3DD0039D2E7 /* Oric.cpp in Sources */, 4BEA525E1DF33323007E74F2 /* Tape.cpp in Sources */, 4BC8A62D1DCE60E000DAC693 /* Typer.cpp in Sources */, + 4B1497921EE4B5A800CE2596 /* ZX8081.cpp in Sources */, 4B643F3F1D77B88000D431D6 /* DocumentController.swift in Sources */, 4BA799951D8B656E0045123D /* StaticAnalyser.cpp in Sources */, 4B2BFDB21DAEF5FF001A68B8 /* Video.cpp in Sources */, @@ -2608,6 +2631,7 @@ 4BEE0A701D72496600532C7B /* PRG.cpp in Sources */, 4B8FE2271DA1DE2D0090D3CE /* NSBundle+DataResource.m in Sources */, 4B2A53A01D117D36003C6002 /* CSMachine.mm in Sources */, + 4B14978F1EE4B4D200CE2596 /* CSZX8081.mm in Sources */, 4BC91B831D1F160E00884B76 /* CommodoreTAP.cpp in Sources */, 4BCF1FAB1DADD41B0039D2E7 /* StaticAnalyser.cpp in Sources */, 4B2A539F1D117D36003C6002 /* CSAudioQueue.m in Sources */, diff --git a/OSBindings/Mac/Clock Signal/Base.lproj/ZX8081Options.xib b/OSBindings/Mac/Clock Signal/Base.lproj/ZX8081Options.xib new file mode 100644 index 000000000..c578c2188 --- /dev/null +++ b/OSBindings/Mac/Clock Signal/Base.lproj/ZX8081Options.xib @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm b/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm index f8c07c466..08c354208 100644 --- a/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm +++ b/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm @@ -18,6 +18,7 @@ #import "CSElectron.h" #import "CSOric.h" #import "CSVic20.h" +#import "CSZX8081.h" #import "Clock_Signal-Swift.h" @@ -49,6 +50,7 @@ case StaticAnalyser::Target::Electron: return @"ElectronOptions"; case StaticAnalyser::Target::Oric: return @"OricOptions"; case StaticAnalyser::Target::Vic20: return @"Vic20Options"; + case StaticAnalyser::Target::ZX80: return @"ZX8081Options"; default: return nil; } } @@ -61,6 +63,7 @@ case StaticAnalyser::Target::Electron: return [[CSElectron alloc] init]; case StaticAnalyser::Target::Oric: return [[CSOric alloc] init]; case StaticAnalyser::Target::Vic20: return [[CSVic20 alloc] init]; + case StaticAnalyser::Target::ZX80: return [[CSZX8081 alloc] init]; default: return nil; } } diff --git a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSZX8081.h b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSZX8081.h new file mode 100644 index 000000000..502bf21a8 --- /dev/null +++ b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSZX8081.h @@ -0,0 +1,17 @@ +// +// CSZX8081.h +// Clock Signal +// +// Created by Thomas Harte on 04/06/2017. +// Copyright © 2017 Thomas Harte. All rights reserved. +// + +#import "CSMachine.h" +#import "CSKeyboardMachine.h" +#import "CSFastLoading.h" + +@interface CSZX8081 : CSMachine + +@property (nonatomic, assign) BOOL useFastLoadingHack; + +@end diff --git a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSZX8081.mm b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSZX8081.mm new file mode 100644 index 000000000..32bb5703c --- /dev/null +++ b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSZX8081.mm @@ -0,0 +1,38 @@ +// +// CSZX8081.m +// Clock Signal +// +// Created by Thomas Harte on 04/06/2017. +// Copyright © 2017 Thomas Harte. All rights reserved. +// + +#import "CSZX8081.h" + +#include "ZX8081.hpp" + +@implementation CSZX8081 { + ZX8081::Machine zx8081; +} + +- (CRTMachine::Machine * const)machine { + return &zx8081; +} + +- (instancetype)init { + self = [super init]; + if(self) { + } + return self; +} + +#pragma mark - Keyboard Mapping + +- (void)clearAllKeys { +} + +- (void)setKey:(uint16_t)key isPressed:(BOOL)isPressed { +} + +- (NSString *)userDefaultsPrefix { return @"zx8081"; } + +@end diff --git a/Processors/Z80/Z80.hpp b/Processors/Z80/Z80.hpp index 44bc4ed8e..d901a361a 100644 --- a/Processors/Z80/Z80.hpp +++ b/Processors/Z80/Z80.hpp @@ -345,7 +345,7 @@ template class Processor { // Copy in all programs and set pointers. size_t destination = 0; - for(int c = 0; c < 256; c++) { + for(size_t c = 0; c < 256; c++) { target.instructions[c] = &target.all_operations[destination]; for(int t = 0; t < lengths[c];) { // Skip zero-length bus cycles. diff --git a/StaticAnalyser/ZX8081/StaticAnalyser.cpp b/StaticAnalyser/ZX8081/StaticAnalyser.cpp index 505ea4811..ce8fa0383 100644 --- a/StaticAnalyser/ZX8081/StaticAnalyser.cpp +++ b/StaticAnalyser/ZX8081/StaticAnalyser.cpp @@ -13,4 +13,9 @@ void StaticAnalyser::ZX8081::AddTargets( const std::list> &tapes, const std::list> &cartridges, std::list &destination) { + // Temporary: be entirely trusting. + StaticAnalyser::Target target; + target.machine = Target::ZX80; + target.tapes = tapes; + destination.push_back(target); }