mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Started sketching out an interface for sound generation. Which made me realise that the CRT in CRTDelegate was redundant, since C++ has namespaces.
This commit is contained in:
parent
6112f4ef6b
commit
3437781abd
@ -12,6 +12,7 @@
|
|||||||
4B14145E1B5887AA00E04248 /* CPU6502AllRAM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B1414591B58879D00E04248 /* CPU6502AllRAM.cpp */; };
|
4B14145E1B5887AA00E04248 /* CPU6502AllRAM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B1414591B58879D00E04248 /* CPU6502AllRAM.cpp */; };
|
||||||
4B1414601B58885000E04248 /* WolfgangLorenzTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B14145F1B58885000E04248 /* WolfgangLorenzTests.swift */; };
|
4B1414601B58885000E04248 /* WolfgangLorenzTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B14145F1B58885000E04248 /* WolfgangLorenzTests.swift */; };
|
||||||
4B1414621B58888700E04248 /* KlausDormannTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B1414611B58888700E04248 /* KlausDormannTests.swift */; };
|
4B1414621B58888700E04248 /* KlausDormannTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B1414611B58888700E04248 /* KlausDormannTests.swift */; };
|
||||||
|
4B2409551C45AB05004DA684 /* Speaker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B2409531C45AB05004DA684 /* Speaker.cpp */; };
|
||||||
4B2E2D951C399D1200138695 /* ElectronDocument.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4B2E2D931C399D1200138695 /* ElectronDocument.xib */; };
|
4B2E2D951C399D1200138695 /* ElectronDocument.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4B2E2D931C399D1200138695 /* ElectronDocument.xib */; };
|
||||||
4B2E2D9A1C3A06EC00138695 /* Atari2600.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B2E2D971C3A06EC00138695 /* Atari2600.cpp */; };
|
4B2E2D9A1C3A06EC00138695 /* Atari2600.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B2E2D971C3A06EC00138695 /* Atari2600.cpp */; };
|
||||||
4B2E2D9D1C3A070400138695 /* Electron.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B2E2D9B1C3A070400138695 /* Electron.cpp */; };
|
4B2E2D9D1C3A070400138695 /* Electron.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B2E2D9B1C3A070400138695 /* Electron.cpp */; };
|
||||||
@ -327,6 +328,8 @@
|
|||||||
4B14145A1B58879D00E04248 /* CPU6502AllRAM.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CPU6502AllRAM.hpp; sourceTree = "<group>"; };
|
4B14145A1B58879D00E04248 /* CPU6502AllRAM.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CPU6502AllRAM.hpp; sourceTree = "<group>"; };
|
||||||
4B14145F1B58885000E04248 /* WolfgangLorenzTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WolfgangLorenzTests.swift; sourceTree = "<group>"; };
|
4B14145F1B58885000E04248 /* WolfgangLorenzTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WolfgangLorenzTests.swift; sourceTree = "<group>"; };
|
||||||
4B1414611B58888700E04248 /* KlausDormannTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KlausDormannTests.swift; sourceTree = "<group>"; };
|
4B1414611B58888700E04248 /* KlausDormannTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KlausDormannTests.swift; sourceTree = "<group>"; };
|
||||||
|
4B2409531C45AB05004DA684 /* Speaker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Speaker.cpp; path = ../../Outputs/Speaker.cpp; sourceTree = "<group>"; };
|
||||||
|
4B2409541C45AB05004DA684 /* Speaker.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Speaker.hpp; path = ../../Outputs/Speaker.hpp; sourceTree = "<group>"; };
|
||||||
4B2632551B631A510082A461 /* CRTFrame.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CRTFrame.h; path = ../../Outputs/CRTFrame.h; sourceTree = "<group>"; };
|
4B2632551B631A510082A461 /* CRTFrame.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CRTFrame.h; path = ../../Outputs/CRTFrame.h; sourceTree = "<group>"; };
|
||||||
4B2E2D941C399D1200138695 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/ElectronDocument.xib; sourceTree = "<group>"; };
|
4B2E2D941C399D1200138695 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/ElectronDocument.xib; sourceTree = "<group>"; };
|
||||||
4B2E2D971C3A06EC00138695 /* Atari2600.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Atari2600.cpp; sourceTree = "<group>"; };
|
4B2E2D971C3A06EC00138695 /* Atari2600.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Atari2600.cpp; sourceTree = "<group>"; };
|
||||||
@ -708,6 +711,8 @@
|
|||||||
4B366DFA1B5C165A0026627B /* CRT.cpp */,
|
4B366DFA1B5C165A0026627B /* CRT.cpp */,
|
||||||
4B366DFB1B5C165A0026627B /* CRT.hpp */,
|
4B366DFB1B5C165A0026627B /* CRT.hpp */,
|
||||||
4B2632551B631A510082A461 /* CRTFrame.h */,
|
4B2632551B631A510082A461 /* CRTFrame.h */,
|
||||||
|
4B2409531C45AB05004DA684 /* Speaker.cpp */,
|
||||||
|
4B2409541C45AB05004DA684 /* Speaker.hpp */,
|
||||||
);
|
);
|
||||||
name = Outputs;
|
name = Outputs;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -1532,6 +1537,7 @@
|
|||||||
4B55CE4B1C3B3B0C0093A61B /* CSAtari2600.mm in Sources */,
|
4B55CE4B1C3B3B0C0093A61B /* CSAtari2600.mm in Sources */,
|
||||||
4B55CE581C3B7D360093A61B /* Atari2600Document.swift in Sources */,
|
4B55CE581C3B7D360093A61B /* Atari2600Document.swift in Sources */,
|
||||||
4B55CE5F1C3B7D960093A61B /* MachineDocument.swift in Sources */,
|
4B55CE5F1C3B7D960093A61B /* MachineDocument.swift in Sources */,
|
||||||
|
4B2409551C45AB05004DA684 /* Speaker.cpp in Sources */,
|
||||||
4B55CE4E1C3B3BDA0093A61B /* CSMachine.mm in Sources */,
|
4B55CE4E1C3B3BDA0093A61B /* CSMachine.mm in Sources */,
|
||||||
4B2E2D9D1C3A070400138695 /* Electron.cpp in Sources */,
|
4B2E2D9D1C3A070400138695 /* Electron.cpp in Sources */,
|
||||||
4B55CE5D1C3B7D6F0093A61B /* CSCathodeRayView.m in Sources */,
|
4B55CE5D1C3B7D6F0093A61B /* CSCathodeRayView.m in Sources */,
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
[view setSignalDecoder:[NSString stringWithUTF8String:_atari2600.get_signal_decoder()] type:CSCathodeRayViewSignalTypeNTSC];
|
[view setSignalDecoder:[NSString stringWithUTF8String:_atari2600.get_signal_decoder()] type:CSCathodeRayViewSignalTypeNTSC];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setCRTDelegate:(Outputs::CRT::CRTDelegate *)delegate{
|
- (void)setCRTDelegate:(Outputs::CRT::Delegate *)delegate{
|
||||||
_atari2600.get_crt()->set_delegate(delegate);
|
_atari2600.get_crt()->set_delegate(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
_electron.set_rom(Electron::ROMSlotBASIC, rom.length, (const uint8_t *)rom.bytes);
|
_electron.set_rom(Electron::ROMSlotBASIC, rom.length, (const uint8_t *)rom.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setCRTDelegate:(Outputs::CRT::CRTDelegate *)delegate{
|
- (void)setCRTDelegate:(Outputs::CRT::Delegate *)delegate{
|
||||||
_electron.get_crt()->set_delegate(delegate);
|
_electron.get_crt()->set_delegate(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
@interface CSMachine (Subclassing)
|
@interface CSMachine (Subclassing)
|
||||||
|
|
||||||
- (void)setCRTDelegate:(Outputs::CRT::CRTDelegate *)delegate;
|
- (void)setCRTDelegate:(Outputs::CRT::Delegate *)delegate;
|
||||||
- (void)doRunForNumberOfCycles:(int)numberOfCycles;
|
- (void)doRunForNumberOfCycles:(int)numberOfCycles;
|
||||||
- (void)crt:(Outputs::CRT *)crt didEndFrame:(CRTFrame *)frame didDetectVSync:(BOOL)didDetectVSync;
|
- (void)crt:(Outputs::CRT *)crt didEndFrame:(CRTFrame *)frame didDetectVSync:(BOOL)didDetectVSync;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#import "CSMachine.h"
|
#import "CSMachine.h"
|
||||||
#import "CSMachine+Subclassing.h"
|
#import "CSMachine+Subclassing.h"
|
||||||
|
|
||||||
struct CRTDelegate: public Outputs::CRT::CRTDelegate {
|
struct CRTDelegate: public Outputs::CRT::Delegate {
|
||||||
__weak CSMachine *machine;
|
__weak CSMachine *machine;
|
||||||
void crt_did_end_frame(Outputs::CRT *crt, CRTFrame *frame, bool did_detect_vsync) {
|
void crt_did_end_frame(Outputs::CRT *crt, CRTFrame *frame, bool did_detect_vsync) {
|
||||||
[machine crt:crt didEndFrame:frame didDetectVSync:did_detect_vsync];
|
[machine crt:crt didEndFrame:frame didDetectVSync:did_detect_vsync];
|
||||||
@ -60,7 +60,7 @@ typedef NS_ENUM(NSInteger, CSAtari2600RunningState) {
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setCRTDelegate:(Outputs::CRT::CRTDelegate *)delegate {}
|
- (void)setCRTDelegate:(Outputs::CRT::Delegate *)delegate {}
|
||||||
- (void)doRunForNumberOfCycles:(int)numberOfCycles {}
|
- (void)doRunForNumberOfCycles:(int)numberOfCycles {}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -335,7 +335,7 @@ void CRT::return_frame()
|
|||||||
|
|
||||||
#pragma mark - delegate
|
#pragma mark - delegate
|
||||||
|
|
||||||
void CRT::set_delegate(CRTDelegate *delegate)
|
void CRT::set_delegate(Delegate *delegate)
|
||||||
{
|
{
|
||||||
_delegate = delegate;
|
_delegate = delegate;
|
||||||
}
|
}
|
||||||
|
@ -58,11 +58,11 @@ class CRT {
|
|||||||
void output_level(unsigned int number_of_cycles);
|
void output_level(unsigned int number_of_cycles);
|
||||||
void output_data(unsigned int number_of_cycles);
|
void output_data(unsigned int number_of_cycles);
|
||||||
|
|
||||||
class CRTDelegate {
|
class Delegate {
|
||||||
public:
|
public:
|
||||||
virtual void crt_did_end_frame(CRT *crt, CRTFrame *frame, bool did_detect_vsync) = 0;
|
virtual void crt_did_end_frame(CRT *crt, CRTFrame *frame, bool did_detect_vsync) = 0;
|
||||||
};
|
};
|
||||||
void set_delegate(CRTDelegate *delegate);
|
void set_delegate(Delegate *delegate);
|
||||||
void return_frame();
|
void return_frame();
|
||||||
|
|
||||||
void allocate_write_area(int required_length);
|
void allocate_write_area(int required_length);
|
||||||
@ -90,7 +90,7 @@ class CRT {
|
|||||||
CRTFrameBuilder *_current_frame_builder;
|
CRTFrameBuilder *_current_frame_builder;
|
||||||
int _frames_with_delegate;
|
int _frames_with_delegate;
|
||||||
int _frame_read_pointer;
|
int _frame_read_pointer;
|
||||||
CRTDelegate *_delegate;
|
Delegate *_delegate;
|
||||||
|
|
||||||
// outer elements of sync separation
|
// outer elements of sync separation
|
||||||
bool _is_receiving_sync; // true if the CRT is currently receiving sync (i.e. this is for edge triggering of horizontal sync)
|
bool _is_receiving_sync; // true if the CRT is currently receiving sync (i.e. this is for edge triggering of horizontal sync)
|
||||||
|
9
Outputs/Speaker.cpp
Normal file
9
Outputs/Speaker.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
//
|
||||||
|
// Speaker.cpp
|
||||||
|
// Clock Signal
|
||||||
|
//
|
||||||
|
// Created by Thomas Harte on 12/01/2016.
|
||||||
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "Speaker.hpp"
|
32
Outputs/Speaker.hpp
Normal file
32
Outputs/Speaker.hpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
//
|
||||||
|
// Speaker.hpp
|
||||||
|
// Clock Signal
|
||||||
|
//
|
||||||
|
// Created by Thomas Harte on 12/01/2016.
|
||||||
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef Speaker_hpp
|
||||||
|
#define Speaker_hpp
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
namespace Speaker {
|
||||||
|
|
||||||
|
class Delegate {
|
||||||
|
public:
|
||||||
|
virtual void speaker_did_complete_samples(uint8_t *buffer);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T> class Filter {
|
||||||
|
public:
|
||||||
|
void set_output_rate(int cycles_per_second);
|
||||||
|
void set_delegate(Delegate *delegate);
|
||||||
|
|
||||||
|
void set_input_rate(int cycles_per_second);
|
||||||
|
void run_for_cycles(int input_cycles);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* Speaker_hpp */
|
Loading…
Reference in New Issue
Block a user