From ce2f5515c0417c7d04cc75316ee484e0dd3d954c Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 19 Jun 2016 18:11:37 -0400 Subject: [PATCH] Made some minor documentation improvements, killed 6522.cpp as the 6522 is going to be a template only, attempting to promote good inlining behaviour. --- Components/6522/6522.cpp | 12 -------- Components/6522/6522.hpp | 28 +++++++++++++++++++ Components/6532/6532.cpp | 9 ++++++ Components/6532/6532.hpp | 14 ++++++++++ Components/6560/6560.hpp | 4 +-- .../Clock Signal.xcodeproj/project.pbxproj | 18 +++++++++--- 6 files changed, 67 insertions(+), 18 deletions(-) delete mode 100644 Components/6522/6522.cpp create mode 100644 Components/6532/6532.cpp create mode 100644 Components/6532/6532.hpp diff --git a/Components/6522/6522.cpp b/Components/6522/6522.cpp deleted file mode 100644 index 412cf4791..000000000 --- a/Components/6522/6522.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// -// 6522.cpp -// Clock Signal -// -// Created by Thomas Harte on 06/06/2016. -// Copyright © 2016 Thomas Harte. All rights reserved. -// - -#include "6522.hpp" - -using namespace MOS; - diff --git a/Components/6522/6522.hpp b/Components/6522/6522.hpp index 4cd616fde..58180edcf 100644 --- a/Components/6522/6522.hpp +++ b/Components/6522/6522.hpp @@ -14,6 +14,17 @@ namespace MOS { +/*! + Implements the template for an emulation of the MOS 6522 Versatile Interface Adaptor ('VIA'). + + The VIA provides: + * two timers, each of which may trigger interrupts and one of which may repeat; + * two digial input/output ports; and + * a serial-to-parallel shifter. + + Consumers should derive their own curiously-recurring-template-pattern subclass of MOS6522, + implementing bus communications as required for the specific machine. +*/ template class MOS6522 { private: enum InterruptFlag: uint8_t { @@ -27,6 +38,7 @@ template class MOS6522 { }; public: + /*! Sets a register value. */ void set_register(int address, uint8_t value) { address &= 0xf; @@ -98,6 +110,7 @@ template class MOS6522 { } } + /*! Gets a register value. */ uint8_t get_register(int address) { address &= 0xf; @@ -143,6 +156,16 @@ template class MOS6522 { { } + /*! + Runs for a specified number of half cycles. + + Although the original chip accepts only a phase-2 input, timer reloads are specified as occuring + 1.5 cycles after the timer hits zero. It is therefore necessary to emulate at half-cycle precision. + + The first emulated half-cycle will be the period between the trailing edge of a phase-2 input and the + next rising edge. So it should align with a full system's phase-1. The next emulated half-cycle will be + that which occurs during phase-2. + */ void run_for_half_cycles(unsigned int number_of_cycles) { while(number_of_cycles--) @@ -188,6 +211,7 @@ template class MOS6522 { } } + /*! @returns @c true if the IRQ line is currently active; @c false otherwise. */ bool get_interrupt_line() { uint8_t interrupt_status = _registers.interrupt_flags & _registers.interrupt_enable & 0x7f; @@ -249,6 +273,10 @@ template class MOS6522 { bool _timer_is_running[2]; }; +/*! + Provided for optional composition with @c MOS6522, @c MOS6522IRQDelegate provides for a delegate + that will receive IRQ line change notifications. +*/ class MOS6522IRQDelegate { public: class Delegate { diff --git a/Components/6532/6532.cpp b/Components/6532/6532.cpp new file mode 100644 index 000000000..ce466a685 --- /dev/null +++ b/Components/6532/6532.cpp @@ -0,0 +1,9 @@ +// +// 6532.cpp +// Clock Signal +// +// Created by Thomas Harte on 19/06/2016. +// Copyright © 2016 Thomas Harte. All rights reserved. +// + +#include "6532.hpp" diff --git a/Components/6532/6532.hpp b/Components/6532/6532.hpp new file mode 100644 index 000000000..2fd8a1989 --- /dev/null +++ b/Components/6532/6532.hpp @@ -0,0 +1,14 @@ +// +// 6532.hpp +// Clock Signal +// +// Created by Thomas Harte on 19/06/2016. +// Copyright © 2016 Thomas Harte. All rights reserved. +// + +#ifndef _532_hpp +#define _532_hpp + +#include + +#endif /* _532_hpp */ diff --git a/Components/6560/6560.hpp b/Components/6560/6560.hpp index bad97523e..4c041a962 100644 --- a/Components/6560/6560.hpp +++ b/Components/6560/6560.hpp @@ -15,9 +15,9 @@ namespace MOS { /*! - The 6560 is a video and audio output chip; it therefore vends both a @c CRT and a @c Speaker. + The 6560 Video Interface Chip ('VIC') is a video and audio output chip; it therefore vends both a @c CRT and a @c Speaker. - To run the 6560 for a cycle, the caller should call @c get_address, make the requested bus access + To run the VIC for a cycle, the caller should call @c get_address, make the requested bus access and call @c set_graphics_value with the result. @c set_register and @c get_register provide register access. diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index d7c054aac..06a18303e 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 4B1414601B58885000E04248 /* WolfgangLorenzTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B14145F1B58885000E04248 /* WolfgangLorenzTests.swift */; }; 4B1414621B58888700E04248 /* KlausDormannTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B1414611B58888700E04248 /* KlausDormannTests.swift */; }; 4B1E85751D170228001EF87D /* Typer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B1E85731D170228001EF87D /* Typer.cpp */; }; + 4B1E857C1D174DEC001EF87D /* 6532.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B1E857A1D174DEC001EF87D /* 6532.cpp */; }; 4B2409551C45AB05004DA684 /* Speaker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B2409531C45AB05004DA684 /* Speaker.cpp */; }; 4B2A539F1D117D36003C6002 /* CSAudioQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B2A53911D117D36003C6002 /* CSAudioQueue.m */; }; 4B2A53A01D117D36003C6002 /* CSMachine.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B2A53961D117D36003C6002 /* CSMachine.mm */; }; @@ -320,7 +321,6 @@ 4BC76E6B1C98F43700E6EF73 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC76E6A1C98F43700E6EF73 /* Accelerate.framework */; }; 4BC9DF451D044FCA00F44158 /* ROMImages in Resources */ = {isa = PBXBuildFile; fileRef = 4BC9DF441D044FCA00F44158 /* ROMImages */; }; 4BC9DF4F1D04691600F44158 /* 6560.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC9DF4D1D04691600F44158 /* 6560.cpp */; }; - 4BCA98C31D065CA20062F44C /* 6522.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BCA98C11D065CA20062F44C /* 6522.cpp */; }; 4BD5F1951D13528900631CD1 /* CSBestEffortUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD5F1941D13528900631CD1 /* CSBestEffortUpdater.m */; }; /* End PBXBuildFile section */ @@ -355,6 +355,8 @@ 4B1414611B58888700E04248 /* KlausDormannTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KlausDormannTests.swift; 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 = ""; }; + 4B1E857A1D174DEC001EF87D /* 6532.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = 6532.cpp; sourceTree = ""; }; + 4B1E857B1D174DEC001EF87D /* 6532.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = 6532.hpp; sourceTree = ""; }; 4B2409531C45AB05004DA684 /* Speaker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Speaker.cpp; path = ../../Outputs/Speaker.cpp; sourceTree = ""; }; 4B2409541C45AB05004DA684 /* Speaker.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Speaker.hpp; path = ../../Outputs/Speaker.hpp; sourceTree = ""; }; 4B24095A1C45DF85004DA684 /* Stepper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Stepper.hpp; sourceTree = ""; }; @@ -699,7 +701,6 @@ 4BC9DF441D044FCA00F44158 /* ROMImages */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ROMImages; path = ../../../../ROMImages; sourceTree = ""; }; 4BC9DF4D1D04691600F44158 /* 6560.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = 6560.cpp; sourceTree = ""; }; 4BC9DF4E1D04691600F44158 /* 6560.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = 6560.hpp; sourceTree = ""; }; - 4BCA98C11D065CA20062F44C /* 6522.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = 6522.cpp; sourceTree = ""; }; 4BCA98C21D065CA20062F44C /* 6522.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = 6522.hpp; sourceTree = ""; }; 4BD5F1931D13528900631CD1 /* CSBestEffortUpdater.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSBestEffortUpdater.h; path = Updater/CSBestEffortUpdater.h; sourceTree = ""; }; 4BD5F1941D13528900631CD1 /* CSBestEffortUpdater.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CSBestEffortUpdater.m; path = Updater/CSBestEffortUpdater.m; sourceTree = ""; }; @@ -765,6 +766,15 @@ name = "Test Binaries"; sourceTree = ""; }; + 4B1E85791D174DEC001EF87D /* 6532 */ = { + isa = PBXGroup; + children = ( + 4B1E857A1D174DEC001EF87D /* 6532.cpp */, + 4B1E857B1D174DEC001EF87D /* 6532.hpp */, + ); + path = 6532; + sourceTree = ""; + }; 4B2409591C45DF85004DA684 /* SignalProcessing */ = { isa = PBXGroup; children = ( @@ -1304,6 +1314,7 @@ isa = PBXGroup; children = ( 4BC9DF4B1D04691600F44158 /* 6522 */, + 4B1E85791D174DEC001EF87D /* 6532 */, 4BC9DF4C1D04691600F44158 /* 6560 */, ); name = Components; @@ -1313,7 +1324,6 @@ 4BC9DF4B1D04691600F44158 /* 6522 */ = { isa = PBXGroup; children = ( - 4BCA98C11D065CA20062F44C /* 6522.cpp */, 4BCA98C21D065CA20062F44C /* 6522.hpp */, ); path = 6522; @@ -1764,8 +1774,8 @@ 4BBF99181C8FBA6F0075DAFB /* TextureTarget.cpp in Sources */, 4BC76E691C98E31700E6EF73 /* FIRFilter.cpp in Sources */, 4B55CE5F1C3B7D960093A61B /* MachineDocument.swift in Sources */, - 4BCA98C31D065CA20062F44C /* 6522.cpp in Sources */, 4B2A53A11D117D36003C6002 /* CSAtari2600.mm in Sources */, + 4B1E857C1D174DEC001EF87D /* 6532.cpp in Sources */, 4B69FB441C4D941400B5F0AA /* TapeUEF.cpp in Sources */, 4BBF99141C8FBA6F0075DAFB /* CRTInputBufferBuilder.cpp in Sources */, 4B2409551C45AB05004DA684 /* Speaker.cpp in Sources */,