From cd5939501f6e1013d614d2eaa199a29870ab7ea4 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 20 Sep 2016 07:36:57 -0400 Subject: [PATCH] =?UTF-8?q?Treading=20water=20some=20more,=20ensured=20the?= =?UTF-8?q?=20DFS=20and=20ADFS=20ROMs=20get=20to=20the=20Electron.=20It=20?= =?UTF-8?q?now=20even=20inserts=20the=20DFS=20ROM=20if=20it=20has=20a=20DF?= =?UTF-8?q?S=20disk=20image.=20Might=20need=20to=20make=20it=20a=20sideway?= =?UTF-8?q?s=20RAM=20though=3F=20Regardless,=20the=20next=20job=20surely?= =?UTF-8?q?=20=E2=80=94=20surely!=20=E2=80=94=20has=20to=20be=20to=20stop?= =?UTF-8?q?=20avoiding=20the=201770=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Machines/Electron/Electron.cpp | 19 +++++++++++++++++-- Machines/Electron/Electron.hpp | 6 ++++-- .../Clock Signal.xcodeproj/project.pbxproj | 6 ++++++ .../Documents/ElectronDocument.swift | 16 ++++++++++++++-- .../Clock Signal/Machine/NSData+StdVector.h | 18 ++++++++++++++++++ .../Clock Signal/Machine/NSData+StdVector.mm | 19 +++++++++++++++++++ .../Machine/Wrappers/CSElectron.h | 3 ++- .../Machine/Wrappers/CSElectron.mm | 18 ++++++------------ ROMImages/Electron/readme.txt | 6 +++--- 9 files changed, 89 insertions(+), 22 deletions(-) create mode 100644 OSBindings/Mac/Clock Signal/Machine/NSData+StdVector.h create mode 100644 OSBindings/Mac/Clock Signal/Machine/NSData+StdVector.mm diff --git a/Machines/Electron/Electron.cpp b/Machines/Electron/Electron.cpp index ec44dd248..dbf2ab008 100644 --- a/Machines/Electron/Electron.cpp +++ b/Machines/Electron/Electron.cpp @@ -485,22 +485,37 @@ void Machine::configure_as_target(const StaticAnalyser::Target &target) _tape.set_tape(target.tapes.front()); } + if(target.disks.size()) + { + _wd1770.reset(new WD::WD1770); + + if(target.acorn.has_dfs) + { + set_rom(ROMSlot0, _dfs); + } + + // TODO: actually insert the disk, why not? + } + if(target.loadingCommand.length()) // TODO: and automatic loading option enabled { set_typer_for_string(target.loadingCommand.c_str()); } } -void Machine::set_rom(ROMSlot slot, size_t length, const uint8_t *data) +void Machine::set_rom(ROMSlot slot, std::vector data) { uint8_t *target = nullptr; switch(slot) { + case ROMSlotDFS: _dfs = data; return; + case ROMSlotADFS: _adfs = data; return; + case ROMSlotOS: target = _os; break; default: target = _roms[slot]; break; } - memcpy(target, data, std::min((size_t)16384, length)); + memcpy(target, &data[0], std::min((size_t)16384, data.size())); } inline void Machine::signal_interrupt(Electron::Interrupt interrupt) diff --git a/Machines/Electron/Electron.hpp b/Machines/Electron/Electron.hpp index 57c2e6a60..2b3b85f14 100644 --- a/Machines/Electron/Electron.hpp +++ b/Machines/Electron/Electron.hpp @@ -18,6 +18,7 @@ #include "../Typer.hpp" #include +#include namespace Electron { @@ -31,7 +32,7 @@ enum ROMSlot: uint8_t { ROMSlot12, ROMSlot13, ROMSlot14, ROMSlot15, - ROMSlotOS + ROMSlotOS, ROMSlotDFS, ROMSlotADFS }; enum Interrupt: uint8_t { @@ -147,7 +148,7 @@ class Machine: public: Machine(); - void set_rom(ROMSlot slot, size_t length, const uint8_t *data); + void set_rom(ROMSlot slot, std::vector data); void configure_as_target(const StaticAnalyser::Target &target); void set_key_state(Key key, bool isPressed); @@ -189,6 +190,7 @@ class Machine: // Things that directly constitute the memory map. uint8_t _roms[16][16384]; uint8_t _os[16384], _ram[32768]; + std::vector _dfs, _adfs; // Things affected by registers, explicitly or otherwise. uint8_t _interrupt_status, _interrupt_control; diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index adfd9fa15..f9b4aa0f6 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -51,6 +51,7 @@ 4B92EACA1B7C112B00246143 /* 6502TimingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B92EAC91B7C112B00246143 /* 6502TimingTests.swift */; }; 4B96F7221D75119A0058BB2D /* Tape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B96F7201D75119A0058BB2D /* Tape.cpp */; }; 4BA22B071D8817CE0008C640 /* Disk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BA22B051D8817CE0008C640 /* Disk.cpp */; }; + 4BA61EB01D91515900B3C876 /* NSData+StdVector.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BA61EAF1D91515900B3C876 /* NSData+StdVector.mm */; }; 4BA799951D8B656E0045123D /* StaticAnalyser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BA799931D8B656E0045123D /* StaticAnalyser.cpp */; }; 4BAB62AD1D3272D200DF5BA0 /* Disk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BAB62AB1D3272D200DF5BA0 /* Disk.cpp */; }; 4BAB62B51D327F7E00DF5BA0 /* G64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BAB62B31D327F7E00DF5BA0 /* G64.cpp */; }; @@ -464,6 +465,8 @@ 4B96F7211D75119A0058BB2D /* Tape.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Tape.hpp; path = ../../StaticAnalyser/Acorn/Tape.hpp; sourceTree = ""; }; 4BA22B051D8817CE0008C640 /* Disk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Disk.cpp; path = ../../StaticAnalyser/Commodore/Disk.cpp; sourceTree = ""; }; 4BA22B061D8817CE0008C640 /* Disk.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Disk.hpp; path = ../../StaticAnalyser/Commodore/Disk.hpp; sourceTree = ""; }; + 4BA61EAE1D91515900B3C876 /* NSData+StdVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+StdVector.h"; sourceTree = ""; }; + 4BA61EAF1D91515900B3C876 /* NSData+StdVector.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSData+StdVector.mm"; sourceTree = ""; }; 4BA799931D8B656E0045123D /* StaticAnalyser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StaticAnalyser.cpp; path = ../../StaticAnalyser/Atari/StaticAnalyser.cpp; sourceTree = ""; }; 4BA799941D8B656E0045123D /* StaticAnalyser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = StaticAnalyser.hpp; path = ../../StaticAnalyser/Atari/StaticAnalyser.hpp; sourceTree = ""; }; 4BA9C3CF1D8164A9002DDB61 /* ConfigurationTarget.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ConfigurationTarget.hpp; sourceTree = ""; }; @@ -922,6 +925,8 @@ 4B2A53961D117D36003C6002 /* CSMachine.mm */, 4B643F3B1D77AD6D00D431D6 /* StaticAnalyser */, 4B2A53981D117D36003C6002 /* Wrappers */, + 4BA61EAE1D91515900B3C876 /* NSData+StdVector.h */, + 4BA61EAF1D91515900B3C876 /* NSData+StdVector.mm */, ); path = Machine; sourceTree = ""; @@ -2118,6 +2123,7 @@ 4BC830D11D6E7C690000A26F /* Tape.cpp in Sources */, 4B69FB441C4D941400B5F0AA /* TapeUEF.cpp in Sources */, 4BF829691D8F7361001BAE39 /* File.cpp in Sources */, + 4BA61EB01D91515900B3C876 /* NSData+StdVector.mm in Sources */, 4B4DC8211D2C2425003C5BF8 /* Vic20.cpp in Sources */, 4BF8295D1D8F048B001BAE39 /* MFM.cpp in Sources */, 4BE77A2E1D84ADFB00BC3827 /* File.cpp in Sources */, diff --git a/OSBindings/Mac/Clock Signal/Documents/ElectronDocument.swift b/OSBindings/Mac/Clock Signal/Documents/ElectronDocument.swift index 73aab5fee..a577b2b77 100644 --- a/OSBindings/Mac/Clock Signal/Documents/ElectronDocument.swift +++ b/OSBindings/Mac/Clock Signal/Documents/ElectronDocument.swift @@ -31,15 +31,27 @@ class ElectronDocument: MachineDocument { return dataForResource(name, ofType: "rom", inDirectory: "ROMImages/Electron") } - override func windowControllerDidLoadNib(_ aController: NSWindowController) { - super.windowControllerDidLoadNib(aController) + override init() { + super.init(); if let os = rom("os"), let basic = rom("basic") { self.electron.setOSROM(os) self.electron.setBASICROM(basic) } + if let dfs = rom("DFS-1770-2.20") { + self.electron.setDFSROM(dfs) + } + if let adfs1 = rom("ADFS-E00_1"), let adfs2 = rom("ADFS-E00_2") { + var fullADFS = adfs1 + fullADFS.append(adfs2) + self.electron.setADFSROM(fullADFS as Data) + } } +// override func windowControllerDidLoadNib(_ aController: NSWindowController) { +// super.windowControllerDidLoadNib(aController) +// } + override var windowNibName: String? { return "ElectronDocument" } diff --git a/OSBindings/Mac/Clock Signal/Machine/NSData+StdVector.h b/OSBindings/Mac/Clock Signal/Machine/NSData+StdVector.h new file mode 100644 index 000000000..3e1749ef9 --- /dev/null +++ b/OSBindings/Mac/Clock Signal/Machine/NSData+StdVector.h @@ -0,0 +1,18 @@ +// +// NSData+StdVector.h +// Clock Signal +// +// Created by Thomas Harte on 20/09/2016. +// Copyright © 2016 Thomas Harte. All rights reserved. +// + +#import + +#include +#include + +@interface NSData (StdVector) + +- (std::vector)stdVector8; + +@end diff --git a/OSBindings/Mac/Clock Signal/Machine/NSData+StdVector.mm b/OSBindings/Mac/Clock Signal/Machine/NSData+StdVector.mm new file mode 100644 index 000000000..88a32c457 --- /dev/null +++ b/OSBindings/Mac/Clock Signal/Machine/NSData+StdVector.mm @@ -0,0 +1,19 @@ +// +// NSData+StdVector.m +// Clock Signal +// +// Created by Thomas Harte on 20/09/2016. +// Copyright © 2016 Thomas Harte. All rights reserved. +// + +#import "NSData+StdVector.h" + +@implementation NSData (StdVector) + +- (std::vector)stdVector8 +{ + uint8_t *bytes8 = (uint8_t *)self.bytes; + return std::vector(bytes8, bytes8 + self.length); +} + +@end diff --git a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.h b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.h index 13e44e4f8..d96647745 100644 --- a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.h +++ b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.h @@ -16,7 +16,8 @@ - (void)setOSROM:(nonnull NSData *)rom; - (void)setBASICROM:(nonnull NSData *)rom; -- (void)setROM:(nonnull NSData *)rom slot:(int)slot; +- (void)setDFSROM:(nonnull NSData *)rom; +- (void)setADFSROM:(nonnull NSData *)rom; @property (nonatomic, assign) BOOL useFastLoadingHack; @property (nonatomic, assign) BOOL useTelevisionOutput; diff --git a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.mm b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.mm index d3635d2a5..ad3481dd3 100644 --- a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.mm +++ b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.mm @@ -10,6 +10,7 @@ #include "Electron.hpp" #import "CSMachine+Subclassing.h" +#import "NSData+StdVector.h" #include "StaticAnalyser.hpp" #include "TapeUEF.hpp" @@ -25,21 +26,14 @@ StaticAnalyser::GetTargets([url fileSystemRepresentation]); } -- (void)setOSROM:(nonnull NSData *)rom { - @synchronized(self) { - _electron.set_rom(Electron::ROMSlotOS, rom.length, (const uint8_t *)rom.bytes); - } -} - -- (void)setBASICROM:(nonnull NSData *)rom { - @synchronized(self) { - _electron.set_rom(Electron::ROMSlotBASIC, rom.length, (const uint8_t *)rom.bytes); - } -} +- (void)setOSROM:(nonnull NSData *)rom { [self setROM:rom slot:Electron::ROMSlotOS]; } +- (void)setBASICROM:(nonnull NSData *)rom { [self setROM:rom slot:Electron::ROMSlotBASIC]; } +- (void)setADFSROM:(nonnull NSData *)rom { [self setROM:rom slot:Electron::ROMSlotADFS]; } +- (void)setDFSROM:(nonnull NSData *)rom { [self setROM:rom slot:Electron::ROMSlotDFS]; } - (void)setROM:(nonnull NSData *)rom slot:(int)slot { @synchronized(self) { - _electron.set_rom((Electron::ROMSlot)slot, rom.length, (const uint8_t *)rom.bytes); + _electron.set_rom((Electron::ROMSlot)slot, rom.stdVector8); } } diff --git a/ROMImages/Electron/readme.txt b/ROMImages/Electron/readme.txt index 8e81ed5e6..accfc031e 100644 --- a/ROMImages/Electron/readme.txt +++ b/ROMImages/Electron/readme.txt @@ -5,12 +5,12 @@ Expected files: basic.rom os.rom plus1.rom +DFS-1770-2.20.rom +ADFS-E00_1.rom +ADFS-E00_2.rom Likely to be desired in the future: adfs.rom -ADFS-E00_1.rom -ADFS-E00_2.rom -DFSE00r3.rom ElectronExpansionRomPresAP2-v1.23.rom os300.rom