From d170bb14e636c3c1061350b241710c5ae95337aa Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 17 May 2016 18:21:49 -0400 Subject: [PATCH] Extended scheduling plans, inserted initial events for hmove, albeit not yet implemented. --- Machines/Atari2600/Atari2600.cpp | 17 +++++++++++++++-- Machines/Atari2600/Atari2600.hpp | 17 ++++++++++++----- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Machines/Atari2600/Atari2600.cpp b/Machines/Atari2600/Atari2600.cpp index 420da42df..4480bff03 100644 --- a/Machines/Atari2600/Atari2600.cpp +++ b/Machines/Atari2600/Atari2600.cpp @@ -21,7 +21,6 @@ Machine::Machine() : _lastOutputState(OutputState::Sync), _piaTimerStatus(0xff), _rom(nullptr), - _hMoveWillCount(false), _piaDataValue{0xff, 0xff}, _tiaInputValue{0xff, 0xff}, _upcomingEventsPointer(0) @@ -555,7 +554,21 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin case 0x2a: _vBlankExtend = true; - _hMoveWillCount = true; + + // clear any ongoing moves + if(_hMoveFlags) + { + for(int c = 0; c < number_of_upcoming_events; c++) + { + _upcomingEvents[c].updates &= ~(Event::Action::HMoveCompare | Event::Action::HMoveDecrement); + } + } + + // schedule new moves + _hMoveFlags = 0x1f; + _hMoveCounter = 15; + _upcomingEvents[(_upcomingEventsPointer + 15)%number_of_upcoming_events].updates |= Event::Action::HMoveCompare; + _upcomingEvents[(_upcomingEventsPointer + 17)%number_of_upcoming_events].updates |= Event::Action::HMoveDecrement; break; case 0x2b: _objectMotion[0] = diff --git a/Machines/Atari2600/Atari2600.hpp b/Machines/Atari2600/Atari2600.hpp index bc69e5799..a553fb70b 100644 --- a/Machines/Atari2600/Atari2600.hpp +++ b/Machines/Atari2600/Atari2600.hpp @@ -16,7 +16,7 @@ namespace Atari2600 { -const unsigned int number_of_upcoming_events = 8; +const unsigned int number_of_upcoming_events = 18; class Machine: public CPU6502::Processor { @@ -61,11 +61,14 @@ class Machine: public CPU6502::Processor { struct Event { enum Action { Playfield = 1 << 0, - Ball = 1 << 1 + Ball = 1 << 1, + HMoveCompare = 1 << 2, + HMoveDecrement = 1 << 3 }; - unsigned int updates; + int updates; uint8_t playfieldOutput; OutputState state; + Event() : updates(0) {} } _upcomingEvents[number_of_upcoming_events]; unsigned int _upcomingEventsPointer; @@ -95,10 +98,14 @@ class Machine: public CPU6502::Processor { unsigned int _horizontalTimer; bool _vSyncEnabled, _vBlankEnabled; bool _vBlankExtend; + + // horizontal motion control uint8_t _hMoveCounter; - bool _hMoveIsCounting, _hMoveWillCount; - uint8_t _objectCounter[5], _objectMotion[5]; uint8_t _hMoveFlags; + uint8_t _objectMotion[5]; + + // object counters + uint8_t _objectCounter[5]; // joystick state uint8_t _piaDataDirection[2];