Microoptimization: pre-invert collision bitmasks.

This commit is contained in:
Christian Speckner 2016-12-02 09:05:35 +01:00
parent a1eb8fd9ab
commit a717890c29
5 changed files with 20 additions and 20 deletions

View File

@ -27,7 +27,7 @@ namespace TIA6502tsCore {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ball::Ball(uInt32 collisionMask) Ball::Ball(uInt32 collisionMask)
: myCollisionMaskDisabled(collisionMask), : myCollisionMaskDisabled(collisionMask),
myCollisionMaskEnabled(0x8000), myCollisionMaskEnabled(0xFFFF),
mySupressed(false) mySupressed(false)
{ {
reset(); reset();
@ -92,7 +92,7 @@ void Ball::vdelbl(uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Ball::toggleCollisions(bool enabled) void Ball::toggleCollisions(bool enabled)
{ {
myCollisionMaskEnabled = enabled ? 0x8000 : (0x8000 | myCollisionMaskDisabled); myCollisionMaskEnabled = enabled ? 0xFFFF : (0x8000 | myCollisionMaskDisabled);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -29,7 +29,7 @@ namespace TIA6502tsCore {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Missile::Missile(uInt32 collisionMask) Missile::Missile(uInt32 collisionMask)
: myCollisionMaskDisabled(collisionMask), : myCollisionMaskDisabled(collisionMask),
myCollisionMaskEnabled(0x8000), myCollisionMaskEnabled(0xFFFF),
mySupressed(false) mySupressed(false)
{ {
reset(); reset();
@ -90,7 +90,7 @@ void Missile::resmp(uInt8 value, const Player& player)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Missile::toggleCollisions(bool enabled) void Missile::toggleCollisions(bool enabled)
{ {
myCollisionMaskEnabled = enabled ? 0x8000 : (0x8000 | myCollisionMaskDisabled); myCollisionMaskEnabled = enabled ? 0xFFFF : (0x8000 | myCollisionMaskDisabled);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -29,7 +29,7 @@ namespace TIA6502tsCore {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Player::Player(uInt32 collisionMask) Player::Player(uInt32 collisionMask)
: myCollisionMaskDisabled(collisionMask), : myCollisionMaskDisabled(collisionMask),
myCollisionMaskEnabled(0x8000), myCollisionMaskEnabled(0xFFFF),
mySupressed(false) mySupressed(false)
{ {
reset(); reset();
@ -126,7 +126,7 @@ void Player::toggleEnabled(bool enabled)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Player::toggleCollisions(bool enabled) void Player::toggleCollisions(bool enabled)
{ {
myCollisionMaskEnabled = enabled ? 0x8000 : (0x8000 | myCollisionMaskDisabled); myCollisionMaskEnabled = enabled ? 0xFFFF : (0x8000 | myCollisionMaskDisabled);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -24,7 +24,7 @@ namespace TIA6502tsCore {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Playfield::Playfield(uInt32 collisionMask) Playfield::Playfield(uInt32 collisionMask)
: myCollisionMaskDisabled(collisionMask), : myCollisionMaskDisabled(collisionMask),
myCollisionMaskEnabled(0x8000), myCollisionMaskEnabled(0xFFFF),
mySupressed(false) mySupressed(false)
{ {
reset(); reset();
@ -103,7 +103,7 @@ void Playfield::toggleEnabled(bool enabled)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Playfield::toggleCollisions(bool enabled) void Playfield::toggleCollisions(bool enabled)
{ {
myCollisionMaskEnabled = enabled ? 0x8000 : (0x8000 | myCollisionMaskDisabled); myCollisionMaskEnabled = enabled ? 0xFFFF : (0x8000 | myCollisionMaskDisabled);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -58,12 +58,12 @@ TIA::TIA(Console& console, Sound& sound, Settings& settings)
myDelayQueue(10, 20), myDelayQueue(10, 20),
mySpriteEnabledBits(0xFF), mySpriteEnabledBits(0xFF),
myCollisionsEnabledBits(0xFF), myCollisionsEnabledBits(0xFF),
myPlayfield(CollisionMask::playfield), myPlayfield(~CollisionMask::playfield & 0x7FFF),
myMissile0(CollisionMask::missile0), myMissile0(~CollisionMask::missile0 & 0x7FFF),
myMissile1(CollisionMask::missile1), myMissile1(~CollisionMask::missile1 & 0x7FFF),
myPlayer0(CollisionMask::player0), myPlayer0(~CollisionMask::player0 & 0x7FFF),
myPlayer1(CollisionMask::player1), myPlayer1(~CollisionMask::player1 & 0x7FFF),
myBall(CollisionMask::ball) myBall(~CollisionMask::ball & 0x7FFF)
{ {
myFrameManager.setHandlers( myFrameManager.setHandlers(
[this] () { [this] () {
@ -900,12 +900,12 @@ void TIA::nextLine()
void TIA::updateCollision() void TIA::updateCollision()
{ {
myCollisionMask |= ( myCollisionMask |= (
~myPlayer0.collision & myPlayer0.collision &
~myPlayer1.collision & myPlayer1.collision &
~myMissile0.collision & myMissile0.collision &
~myMissile1.collision & myMissile1.collision &
~myBall.collision & myBall.collision &
~myPlayfield.collision myPlayfield.collision
); );
} }