From 410c09cb35cd05f100989c497f86a37e9cdab785 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 16 Aug 2015 15:39:40 -0400 Subject: [PATCH] Made attempt not to touch the _collisions registers (which are instance variables) unless the local variables imply it's potentially necessary. So that's a broad phase on collisions, I guess. --- Machines/Atari2600.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Machines/Atari2600.cpp b/Machines/Atari2600.cpp index 51955cfd9..030b87209 100644 --- a/Machines/Atari2600.cpp +++ b/Machines/Atari2600.cpp @@ -124,18 +124,27 @@ void Machine::get_output_pixel(uint8_t *pixel, int offset) } // accumulate collisions - _collisions[0] |= ((missilePixels[0] & playerPixels[1]) << 7) | ((missilePixels[0] & playerPixels[0]) << 6); - _collisions[1] |= ((missilePixels[1] & playerPixels[0]) << 7) | ((missilePixels[1] & playerPixels[1]) << 6); + if(playerPixels[0] | playerPixels[1]) + { + _collisions[0] |= ((missilePixels[0] & playerPixels[1]) << 7) | ((missilePixels[0] & playerPixels[0]) << 6); + _collisions[1] |= ((missilePixels[1] & playerPixels[0]) << 7) | ((missilePixels[1] & playerPixels[1]) << 6); - _collisions[2] |= ((playfieldPixel & playerPixels[0]) << 7) | ((ballPixel & playerPixels[0]) << 6); - _collisions[3] |= ((playfieldPixel & playerPixels[1]) << 7) | ((ballPixel & playerPixels[1]) << 6); + _collisions[2] |= ((playfieldPixel & playerPixels[0]) << 7) | ((ballPixel & playerPixels[0]) << 6); + _collisions[3] |= ((playfieldPixel & playerPixels[1]) << 7) | ((ballPixel & playerPixels[1]) << 6); - _collisions[4] |= ((playfieldPixel & missilePixels[0]) << 7) | ((ballPixel & missilePixels[0]) << 6); - _collisions[5] |= ((playfieldPixel & missilePixels[1]) << 7) | ((ballPixel & missilePixels[1]) << 6); + _collisions[7] |= ((playerPixels[0] & playerPixels[1]) << 7); + } - _collisions[6] |= ((playfieldPixel & ballPixel) << 7); + if(playfieldPixel | ballPixel) + { + _collisions[4] |= ((playfieldPixel & missilePixels[0]) << 7) | ((ballPixel & missilePixels[0]) << 6); + _collisions[5] |= ((playfieldPixel & missilePixels[1]) << 7) | ((ballPixel & missilePixels[1]) << 6); - _collisions[7] |= ((playerPixels[0] & playerPixels[1]) << 7) | ((missilePixels[0] & missilePixels[1]) << 6); + _collisions[6] |= ((playfieldPixel & ballPixel) << 7); + } + + if(missilePixels[0] & missilePixels[1]) + _collisions[7] |= (1 << 6); // apply appropriate priority to pick a colour playfieldPixel |= ballPixel;