diff --git a/Machines/Apple/Macintosh/Macintosh.cpp b/Machines/Apple/Macintosh/Macintosh.cpp index 22972e929..039b23109 100644 --- a/Machines/Apple/Macintosh/Macintosh.cpp +++ b/Machines/Apple/Macintosh/Macintosh.cpp @@ -10,6 +10,7 @@ #include "../../../Processors/68000/68000.hpp" #include "../../../Components/6522/6522.hpp" +#include "../../Utility/MemoryPacker.hpp" namespace Apple { namespace Macintosh { @@ -21,19 +22,19 @@ class ConcreteMachine: ConcreteMachine(const ROMMachine::ROMFetcher &rom_fetcher) : mc68000_(*this) { + // Grab a copy of the ROM and convert it into big-endian data. const auto roms = rom_fetcher("Macintosh", { "mac128k.rom" }); if(!roms[0]) { throw ROMMachine::Error::MissingROMs; } - roms[0]->resize(64*1024); - memcpy(rom_, roms[0]->data(), roms[0]->size()); + Memory::PackBigEndian16(*roms[0], rom_); } private: CPU::MC68000::Processor<ConcreteMachine, true> mc68000_; - uint8_t rom_[64*1024]; - uint8_t ram_[128*1024]; + uint16_t rom_[32*1024]; + uint16_t ram_[64*1024]; }; } diff --git a/Machines/Utility/MemoryFuzzer.hpp b/Machines/Utility/MemoryFuzzer.hpp index dd922e077..bd097aeed 100644 --- a/Machines/Utility/MemoryFuzzer.hpp +++ b/Machines/Utility/MemoryFuzzer.hpp @@ -18,7 +18,7 @@ namespace Memory { /// Stores @c size random bytes from @c buffer onwards. void Fuzz(uint8_t *buffer, std::size_t size); -// Replaces all existing vector contents with random bytes. +/// Replaces all existing vector contents with random bytes. void Fuzz(std::vector<uint8_t> &buffer); } diff --git a/Machines/Utility/MemoryPacker.cpp b/Machines/Utility/MemoryPacker.cpp new file mode 100644 index 000000000..9630af259 --- /dev/null +++ b/Machines/Utility/MemoryPacker.cpp @@ -0,0 +1,15 @@ +// +// MemoryPacker.cpp +// Clock Signal +// +// Created by Thomas Harte on 03/05/2019. +// Copyright © 2019 Thomas Harte. All rights reserved. +// + +#include "MemoryPacker.hpp" + +void Memory::PackBigEndian16(const std::vector<uint8_t> &source, uint16_t *target) { + for(std::size_t c = 0; c < source.size(); c += 2) { + target[c >> 1] = uint16_t(source[c] << 8) | uint16_t(source[c+1]); + } +} diff --git a/Machines/Utility/MemoryPacker.hpp b/Machines/Utility/MemoryPacker.hpp new file mode 100644 index 000000000..145191829 --- /dev/null +++ b/Machines/Utility/MemoryPacker.hpp @@ -0,0 +1,24 @@ +// +// MemoryPacker.hpp +// Clock Signal +// +// Created by Thomas Harte on 03/05/2019. +// Copyright © 2019 Thomas Harte. All rights reserved. +// + +#ifndef MemoryPacker_hpp +#define MemoryPacker_hpp + +#include <cstdint> +#include <vector> + +namespace Memory { + +/*! + Copies the bytes from @c source into @c target, interpreting them + as big-endian 16-bit data. +*/ +void PackBigEndian16(const std::vector<uint8_t> &source, uint16_t *target); + +} +#endif /* MemoryPacker_hpp */ diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index f8bf87bff..e4d1cf0b2 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -616,6 +616,7 @@ 4BCE0052227CE8CA000CA200 /* DiskIICard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BCE004E227CE8CA000CA200 /* DiskIICard.cpp */; }; 4BCE0053227CE8CA000CA200 /* AppleII.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BCE0050227CE8CA000CA200 /* AppleII.cpp */; }; 4BCE005A227CFFCA000CA200 /* Macintosh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BCE0058227CFFCA000CA200 /* Macintosh.cpp */; }; + 4BCE005D227D30CC000CA200 /* MemoryPacker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BCE005B227D30CC000CA200 /* MemoryPacker.cpp */; }; 4BCF1FA41DADC3DD0039D2E7 /* Oric.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BCF1FA21DADC3DD0039D2E7 /* Oric.cpp */; }; 4BD191F42191180E0042E144 /* ScanTarget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD191F22191180E0042E144 /* ScanTarget.cpp */; }; 4BD191F52191180E0042E144 /* ScanTarget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD191F22191180E0042E144 /* ScanTarget.cpp */; }; @@ -1380,6 +1381,8 @@ 4BCE0050227CE8CA000CA200 /* AppleII.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppleII.cpp; sourceTree = "<group>"; }; 4BCE0058227CFFCA000CA200 /* Macintosh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Macintosh.cpp; sourceTree = "<group>"; }; 4BCE0059227CFFCA000CA200 /* Macintosh.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Macintosh.hpp; sourceTree = "<group>"; }; + 4BCE005B227D30CC000CA200 /* MemoryPacker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryPacker.cpp; sourceTree = "<group>"; }; + 4BCE005C227D30CC000CA200 /* MemoryPacker.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = MemoryPacker.hpp; sourceTree = "<group>"; }; 4BCF1FA21DADC3DD0039D2E7 /* Oric.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Oric.cpp; path = Oric/Oric.cpp; sourceTree = "<group>"; }; 4BCF1FA31DADC3DD0039D2E7 /* Oric.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Oric.hpp; path = Oric/Oric.hpp; sourceTree = "<group>"; }; 4BD060A51FE49D3C006E14BE /* Speaker.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Speaker.hpp; sourceTree = "<group>"; }; @@ -1697,13 +1700,15 @@ children = ( 4B055ABE1FAE98000060FFFF /* MachineForTarget.cpp */, 4B2B3A481F9B8FA70062DABF /* MemoryFuzzer.cpp */, + 4BCE005B227D30CC000CA200 /* MemoryPacker.cpp */, + 4B17B58920A8A9D9007CCA8F /* StringSerialiser.cpp */, 4B2B3A471F9B8FA70062DABF /* Typer.cpp */, 4B055ABF1FAE98000060FFFF /* MachineForTarget.hpp */, 4B2B3A491F9B8FA70062DABF /* MemoryFuzzer.hpp */, - 4B2B3A4A1F9B8FA70062DABF /* Typer.hpp */, - 4B79A4FE1FC9082300EEDAD5 /* TypedDynamicMachine.hpp */, - 4B17B58920A8A9D9007CCA8F /* StringSerialiser.cpp */, + 4BCE005C227D30CC000CA200 /* MemoryPacker.hpp */, 4B17B58A20A8A9D9007CCA8F /* StringSerialiser.hpp */, + 4B79A4FE1FC9082300EEDAD5 /* TypedDynamicMachine.hpp */, + 4B2B3A4A1F9B8FA70062DABF /* Typer.hpp */, ); path = Utility; sourceTree = "<group>"; @@ -4017,6 +4022,7 @@ 4B8805F01DCFC99C003085B1 /* Acorn.cpp in Sources */, 4B3051301D98ACC600B4FED8 /* Plus3.cpp in Sources */, 4B30512D1D989E2200B4FED8 /* Drive.cpp in Sources */, + 4BCE005D227D30CC000CA200 /* MemoryPacker.cpp in Sources */, 4B83348C1F5DB99C0097E338 /* 6522Base.cpp in Sources */, 4BCE0051227CE8CA000CA200 /* Video.cpp in Sources */, 4B894536201967B4007DE474 /* Z80.cpp in Sources */, diff --git a/OSBindings/Mac/Clock Signal/MachinePicker/Base.lproj/MachinePicker.xib b/OSBindings/Mac/Clock Signal/MachinePicker/Base.lproj/MachinePicker.xib index 39373b44b..b51807442 100644 --- a/OSBindings/Mac/Clock Signal/MachinePicker/Base.lproj/MachinePicker.xib +++ b/OSBindings/Mac/Clock Signal/MachinePicker/Base.lproj/MachinePicker.xib @@ -17,14 +17,14 @@ <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" titleVisibility="hidden" id="QvC-M9-y7g"> <windowStyleMask key="styleMask" titled="YES" documentModal="YES"/> <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> - <rect key="contentRect" x="196" y="240" width="700" height="205"/> + <rect key="contentRect" x="196" y="240" width="650" height="205"/> <rect key="screenRect" x="0.0" y="0.0" width="1440" height="900"/> <view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ"> - <rect key="frame" x="0.0" y="0.0" width="700" height="205"/> + <rect key="frame" x="0.0" y="0.0" width="650" height="205"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="hKn-1l-OSN"> - <rect key="frame" x="599" y="13" width="87" height="32"/> + <rect key="frame" x="549" y="13" width="87" height="32"/> <buttonCell key="cell" type="push" title="Choose" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="MnM-xo-4Qa"> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <font key="font" metaFont="system"/> @@ -37,7 +37,7 @@ DQ </connections> </button> <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="JQy-Cj-AOK"> - <rect key="frame" x="518" y="13" width="82" height="32"/> + <rect key="frame" x="468" y="13" width="82" height="32"/> <buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="sub-rB-Req"> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <font key="font" metaFont="system"/> @@ -59,7 +59,7 @@ Gw </textFieldCell> </textField> <tabView translatesAutoresizingMaskIntoConstraints="NO" id="VUb-QG-x7c"> - <rect key="frame" x="13" y="51" width="674" height="140"/> + <rect key="frame" x="13" y="51" width="624" height="140"/> <font key="font" metaFont="system"/> <tabViewItems> <tabViewItem label="Apple II" identifier="appleii" id="P59-QG-LOa"> @@ -130,7 +130,7 @@ Gw </tabViewItem> <tabViewItem label="Amstrad CPC" identifier="cpc" id="JmB-OF-xcM"> <view key="view" id="5zS-Nj-Ynx"> - <rect key="frame" x="10" y="33" width="654" height="94"/> + <rect key="frame" x="10" y="33" width="604" height="94"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="00d-sg-Krh"> diff --git a/ROMImages/Macintosh/readme.txt b/ROMImages/Macintosh/readme.txt new file mode 100644 index 000000000..da6516e77 --- /dev/null +++ b/ROMImages/Macintosh/readme.txt @@ -0,0 +1,7 @@ +ROMs for the Apple Macintosh go here; these are the property of Apple and so are not included in the distribution. + +Please supply one or more of: + +mac128k.rom +mac512k.rom +macplus.rom \ No newline at end of file