From 837cccdf835ac926cbd3e3b4ce977c13e76b8a8f Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 4 Mar 2017 14:58:28 -0500 Subject: [PATCH] Switched to deferred updates for the 6532. --- Machines/Atari2600/Atari2600.cpp | 10 +++++++++- Machines/Atari2600/Atari2600.hpp | 8 ++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Machines/Atari2600/Atari2600.cpp b/Machines/Atari2600/Atari2600.cpp index e7454d630..aa6e3fdd7 100644 --- a/Machines/Atari2600/Atari2600.cpp +++ b/Machines/Atari2600/Atari2600.cpp @@ -22,6 +22,7 @@ Machine::Machine() : tia_input_value_{0xff, 0xff}, cycles_since_speaker_update_(0), cycles_since_video_update_(0), + cycles_since_6532_update_(0), frame_record_pointer_(0), is_ntsc_(true) { @@ -203,6 +204,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin // check for a PIA access if((address&0x1280) == 0x280) { + update_6532(); if(isReadOperation(operation)) { returnValue &= mos6532_.get_register(address); } else { @@ -216,7 +218,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin } if(!tia_->get_cycles_until_horizontal_blank(cycles_since_video_update_)) set_ready_line(false); - mos6532_.run_for_cycles(cycles_run_for / 3); + cycles_since_6532_update_ += (cycles_run_for / 3); return cycles_run_for / 3; } @@ -321,6 +323,12 @@ void Machine::update_video() cycles_since_video_update_ = 0; } +void Machine::update_6532() +{ + mos6532_.run_for_cycles(cycles_since_6532_update_); + cycles_since_6532_update_ = 0; +} + void Machine::synchronise() { update_audio(); diff --git a/Machines/Atari2600/Atari2600.hpp b/Machines/Atari2600/Atari2600.hpp index 68c45e97b..ad1a076aa 100644 --- a/Machines/Atari2600/Atari2600.hpp +++ b/Machines/Atari2600/Atari2600.hpp @@ -77,11 +77,15 @@ class Machine: // speaker backlog accumlation counter unsigned int cycles_since_speaker_update_; - void update_audio(); + inline void update_audio(); // video backlog accumulation counter unsigned int cycles_since_video_update_; - void update_video(); + inline void update_video(); + + // RIOT backlog accumulation counter + unsigned int cycles_since_6532_update_; + inline void update_6532(); // output frame rate tracker struct FrameRecord