From 68392ce6f52fc8d5eaaaffa76bb4a8f53f644cb7 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 3 May 2019 23:25:42 -0400 Subject: [PATCH] Adds enough of a concept of Mac video to get a properly initialised display. Completely empty at present, naturally. Also this is the very first time I've run my 68000 at live speed. From just one data point, it's not terrible. Phew! --- Machines/Apple/Macintosh/Macintosh.cpp | 25 +++++++++++++++- Machines/Apple/Macintosh/Video.cpp | 30 +++++++++++++++++++ Machines/Apple/Macintosh/Video.hpp | 29 ++++++++++++++++++ .../Clock Signal.xcodeproj/project.pbxproj | 6 ++++ .../xcschemes/Clock Signal.xcscheme | 2 +- 5 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 Machines/Apple/Macintosh/Video.cpp create mode 100644 Machines/Apple/Macintosh/Video.hpp diff --git a/Machines/Apple/Macintosh/Macintosh.cpp b/Machines/Apple/Macintosh/Macintosh.cpp index 039b23109..eaa11ee8d 100644 --- a/Machines/Apple/Macintosh/Macintosh.cpp +++ b/Machines/Apple/Macintosh/Macintosh.cpp @@ -8,8 +8,13 @@ #include "Macintosh.hpp" +#include "Video.hpp" + +#include "../../CRTMachine.hpp" + #include "../../../Processors/68000/68000.hpp" #include "../../../Components/6522/6522.hpp" + #include "../../Utility/MemoryPacker.hpp" namespace Apple { @@ -17,10 +22,12 @@ namespace Macintosh { class ConcreteMachine: public Machine, + public CRTMachine::Machine, public CPU::MC68000::BusHandler { public: ConcreteMachine(const ROMMachine::ROMFetcher &rom_fetcher) : - mc68000_(*this) { + mc68000_(*this), + video_(ram_) { // Grab a copy of the ROM and convert it into big-endian data. const auto roms = rom_fetcher("Macintosh", { "mac128k.rom" }); @@ -29,10 +36,26 @@ class ConcreteMachine: } roms[0]->resize(64*1024); Memory::PackBigEndian16(*roms[0], rom_); + + // The Mac runs at 7.8336mHz. + set_clock_rate(7833600.0); + } + + void set_scan_target(Outputs::Display::ScanTarget *scan_target) override { + video_.set_scan_target(scan_target); + } + + Outputs::Speaker::Speaker *get_speaker() override { + return nullptr; + } + + void run_for(const Cycles cycles) override { + mc68000_.run_for(cycles); } private: CPU::MC68000::Processor mc68000_; + Video video_; uint16_t rom_[32*1024]; uint16_t ram_[64*1024]; }; diff --git a/Machines/Apple/Macintosh/Video.cpp b/Machines/Apple/Macintosh/Video.cpp new file mode 100644 index 000000000..aa39de5ea --- /dev/null +++ b/Machines/Apple/Macintosh/Video.cpp @@ -0,0 +1,30 @@ +// +// Video.cpp +// Clock Signal +// +// Created by Thomas Harte on 03/05/2019. +// Copyright © 2019 Thomas Harte. All rights reserved. +// + +#include "Video.hpp" + +using namespace Apple::Macintosh; + +// Re: CRT timings, see the Apple Guide to the Macintosh Hardware Family, +// bottom of page 400: +// +// "For each scan line, 512 pixels are drawn on the screen ... +// The horizontal blanking interval takes the time of an additional 192 pixels" +// +// And, at the top of 401: +// +// "The visible portion of a full-screen display consists of 342 horizontal scan lines... +// During the vertical blanking interval, the turned-off beam ... traces out an additional 28 scan lines," +// +Video::Video(uint16_t *ram) : + crt_(704, 1, 370, Outputs::Display::ColourSpace::YIQ, 1, 1, 6, false, Outputs::Display::InputDataType::Luminance1) { +} + +void Video::set_scan_target(Outputs::Display::ScanTarget *scan_target) { + crt_.set_scan_target(scan_target); +} diff --git a/Machines/Apple/Macintosh/Video.hpp b/Machines/Apple/Macintosh/Video.hpp new file mode 100644 index 000000000..35e60a89c --- /dev/null +++ b/Machines/Apple/Macintosh/Video.hpp @@ -0,0 +1,29 @@ +// +// Video.hpp +// Clock Signal +// +// Created by Thomas Harte on 03/05/2019. +// Copyright © 2019 Thomas Harte. All rights reserved. +// + +#ifndef Video_hpp +#define Video_hpp + +#include "../../../Outputs/CRT/CRT.hpp" + +namespace Apple { +namespace Macintosh { + +class Video { + public: + Video(uint16_t *ram); + void set_scan_target(Outputs::Display::ScanTarget *scan_target); + + private: + Outputs::CRT::CRT crt_; +}; + +} +} + +#endif /* Video_hpp */ diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index e4d1cf0b2..9fa15aeab 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -617,6 +617,7 @@ 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 */; }; + 4BCE0060227D39AB000CA200 /* Video.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BCE005E227D39AB000CA200 /* Video.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 */; }; @@ -1383,6 +1384,8 @@ 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 = ""; }; + 4BCE005E227D39AB000CA200 /* Video.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Video.cpp; sourceTree = ""; }; + 4BCE005F227D39AB000CA200 /* Video.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Video.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 = ""; }; @@ -3060,7 +3063,9 @@ isa = PBXGroup; children = ( 4BCE0058227CFFCA000CA200 /* Macintosh.cpp */, + 4BCE005E227D39AB000CA200 /* Video.cpp */, 4BCE0059227CFFCA000CA200 /* Macintosh.hpp */, + 4BCE005F227D39AB000CA200 /* Video.hpp */, ); path = Macintosh; sourceTree = ""; @@ -3953,6 +3958,7 @@ 4B8805F71DCFF6C9003085B1 /* Commodore.cpp in Sources */, 4BC76E691C98E31700E6EF73 /* FIRFilter.cpp in Sources */, 4B3BF5B01F146265005B6C36 /* CSW.cpp in Sources */, + 4BCE0060227D39AB000CA200 /* Video.cpp in Sources */, 4B4518A51F75FD1C00926311 /* SSD.cpp in Sources */, 4B55CE5F1C3B7D960093A61B /* MachineDocument.swift in Sources */, 4B2B3A4C1F9B8FA70062DABF /* MemoryFuzzer.cpp in Sources */, diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme index 9c2dca9ce..cdac581d4 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme +++ b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme @@ -69,7 +69,7 @@