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 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 &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 &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 +#include + +namespace Memory { + +/*! + Copies the bytes from @c source into @c target, interpreting them + as big-endian 16-bit data. +*/ +void PackBigEndian16(const std::vector &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 = ""; }; 4BCE0058227CFFCA000CA200 /* Macintosh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Macintosh.cpp; sourceTree = ""; }; 4BCE0059227CFFCA000CA200 /* Macintosh.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Macintosh.hpp; sourceTree = ""; }; + 4BCE005B227D30CC000CA200 /* MemoryPacker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryPacker.cpp; sourceTree = ""; }; + 4BCE005C227D30CC000CA200 /* MemoryPacker.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = MemoryPacker.hpp; sourceTree = ""; }; 4BCF1FA21DADC3DD0039D2E7 /* Oric.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Oric.cpp; path = Oric/Oric.cpp; sourceTree = ""; }; 4BCF1FA31DADC3DD0039D2E7 /* Oric.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Oric.hpp; path = Oric/Oric.hpp; sourceTree = ""; }; 4BD060A51FE49D3C006E14BE /* Speaker.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Speaker.hpp; sourceTree = ""; }; @@ -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 = ""; @@ -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 @@ - + - +