From 0b99649b0fad69ae5c3e97150783da49236c439e Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 18 May 2016 07:31:05 -0400 Subject: [PATCH] Had a first shot at triggering player and missile resets. --- Machines/Atari2600/Atari2600.cpp | 41 +++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/Machines/Atari2600/Atari2600.cpp b/Machines/Atari2600/Atari2600.cpp index 3ea6d2703..8a6a53ecf 100644 --- a/Machines/Atari2600/Atari2600.cpp +++ b/Machines/Atari2600/Atari2600.cpp @@ -95,14 +95,38 @@ void Machine::update_upcoming_event() { _upcomingEvents[upcomingEventsPointerPlus4].updates |= Event::Action::ResetPixelCounter; _upcomingEvents[upcomingEventsPointerPlus4].pixelCounterMask |= (1 << 4); -// _upcomingEvents[_upcomingEventsPointer].updates |= Event::Action::ResetPixelCounter; -// _upcomingEvents[_upcomingEventsPointer].pixelCounterMask |= (1 << 4); } _objectCounter[4] = (_objectCounter[4] + 1)%160; -// printf("-%d- ", _objectCounter[4]); - // the players and missles become visible only upon overflow to zero, so schedule for - // 5/6 clocks ahead from 159 + unsigned int upcomingEventsPointerPlus5 = (_upcomingEventsPointer + 5)%number_of_upcoming_events; + unsigned int upcomingEventsPointerPlus6 = (_upcomingEventsPointer + 6)%number_of_upcoming_events; + + // check for player and missle triggers + for(int c = 0; c < 4; c++) + { + // the players and missles become visible only upon overflow to zero, so schedule for + // 5/6 clocks ahead from 159 + if(_objectCounter[c] == 159) + { + unsigned int actionSlot = (c < 2) ? upcomingEventsPointerPlus6 : upcomingEventsPointerPlus5; + _upcomingEvents[actionSlot].updates |= Event::Action::ResetPixelCounter; + _upcomingEvents[actionSlot].pixelCounterMask |= (1 << c); + } + else + { + uint8_t repeatMask = _playerAndMissileSize[c] & 7; + if( + ( _objectCounter[c] == 12 && ((repeatMask == 1) || (repeatMask == 3)) ) || + ( _objectCounter[c] == 28 && ((repeatMask == 2) || (repeatMask == 3) || (repeatMask == 6)) ) || + ( _objectCounter[c] == 60 && ((repeatMask == 4) || (repeatMask == 6)) ) + ) + { + unsigned int actionSlot = (c < 2) ? upcomingEventsPointerPlus5 : upcomingEventsPointerPlus4; + _upcomingEvents[actionSlot].updates |= Event::Action::ResetPixelCounter; + _upcomingEvents[actionSlot].pixelCounterMask |= (1 << c); + } + } + } } uint8_t Machine::get_output_pixel() @@ -120,6 +144,9 @@ uint8_t Machine::get_output_pixel() } _pixelCounter[4] ++; + // deal with the sprites + + // get player and missile proposed pixels /* uint8_t playerPixels[2] = {0, 0}, missilePixels[2] = {0, 0}; for(int c = 0; c < 2; c++) @@ -507,7 +534,9 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin break; case 0x10: case 0x11: case 0x12: case 0x13: - case 0x14: _objectCounter[decodedAddress - 0x10] = 0; break; + case 0x14: + _objectCounter[decodedAddress - 0x10] = 0; + break; case 0x1c: _ballGraphicsEnable = _ballGraphicsEnableLatch;