1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-21 21:33:54 +00:00

Permit granular specification of what to flush.

This commit is contained in:
Thomas Harte 2022-07-08 15:38:29 -04:00
parent 5c3084c37c
commit b03d91d5dd
4 changed files with 18 additions and 9 deletions

View File

@ -219,7 +219,7 @@ class ConcreteMachine:
mc68000_.run_for(cycles);
}
void flush_output() final {
void flush_output(Output) final {
flush();
}

View File

@ -210,10 +210,14 @@ class ConcreteMachine:
z80_.run_for(cycles);
}
void flush_output() final {
vdp_.flush();
update_audio();
audio_queue_.perform();
void flush_output(Output output) final {
if(int(output) & int(Output::Video)) {
vdp_.flush();
}
if(int(output) & int(Output::Audio)) {
update_audio();
audio_queue_.perform();
}
}
forceinline HalfCycles perform_machine_cycle(const CPU::Z80::PartialMachineCycle &cycle) {

View File

@ -61,8 +61,13 @@ class TimedMachine {
virtual float get_confidence() { return 0.5f; }
virtual std::string debug_type() { return ""; }
/// Ensures all locally-buffered output is posted onward.
virtual void flush_output() {}
enum class Output {
Video = 1 << 0,
Audio = 1 << 1
};
/// Ensures all locally-buffered output is posted onward for the types of output indicated
/// by the bitfield argument.
virtual void flush_output(Output) {}
protected:
/// Runs the machine for @c cycles.

View File

@ -678,13 +678,13 @@ struct ActivityObserver: public Activity::Observer {
- (void)audioQueueIsRunningDry:(nonnull CSAudioQueue *)audioQueue {
updater.update([self] {
updater.performer.machine->flush_output();
updater.performer.machine->flush_output(MachineTypes::TimedMachine::Output::Audio);
});
}
- (void)scanTargetViewDisplayLinkDidFire:(CSScanTargetView *)view now:(const CVTimeStamp *)now outputTime:(const CVTimeStamp *)outputTime {
updater.update([self] {
updater.performer.machine->flush_output();
updater.performer.machine->flush_output(MachineTypes::TimedMachine::Output::Video);
dispatch_async(dispatch_get_main_queue(), ^{
[self.view updateBacking];
[self.view draw];