Renamed some of the TIA tables to shorter names.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1673 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2009-02-08 21:07:06 +00:00
parent 378549a715
commit ada27762f5
3 changed files with 435 additions and 433 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: TIA.cxx,v 1.103 2009-01-24 18:17:34 stephena Exp $ // $Id: TIA.cxx,v 1.104 2009-02-08 21:07:06 stephena Exp $
//============================================================================ //============================================================================
//#define DEBUG_HMOVE //#define DEBUG_HMOVE
@ -143,12 +143,12 @@ void TIA::reset()
// Some default values for the "current" variables // Some default values for the "current" variables
myCurrentGRP0 = 0; myCurrentGRP0 = 0;
myCurrentGRP1 = 0; myCurrentGRP1 = 0;
myCurrentBLMask = TIATables::BallMaskTable[0][0]; myCurrentBLMask = TIATables::BLMask[0][0];
myCurrentM0Mask = TIATables::MissleMaskTable[0][0][0]; myCurrentM0Mask = TIATables::MxMask[0][0][0];
myCurrentM1Mask = TIATables::MissleMaskTable[0][0][0]; myCurrentM1Mask = TIATables::MxMask[0][0][0];
myCurrentP0Mask = TIATables::PlayerMaskTable[0][0][0]; myCurrentP0Mask = TIATables::PxMask[0][0][0];
myCurrentP1Mask = TIATables::PlayerMaskTable[0][0][0]; myCurrentP1Mask = TIATables::PxMask[0][0][0];
myCurrentPFMask = TIATables::PlayfieldTable[0]; myCurrentPFMask = TIATables::PFMask[0];
myMotionClockP0 = 0; myMotionClockP0 = 0;
myMotionClockP1 = 0; myMotionClockP1 = 0;
@ -341,12 +341,12 @@ bool TIA::save(Serializer& out) const
out.putByte((char)myCurrentGRP1); out.putByte((char)myCurrentGRP1);
// pointers // pointers
// myCurrentBLMask = TIATables::BallMaskTable[0][0]; // myCurrentBLMask = TIATables::BLMask[0][0];
// myCurrentM0Mask = TIATables::MissleMaskTable[0][0][0]; // myCurrentM0Mask = TIATables::MxMask[0][0][0];
// myCurrentM1Mask = TIATables::MissleMaskTable[0][0][0]; // myCurrentM1Mask = TIATables::MxMask[0][0][0];
// myCurrentP0Mask = TIATables::PlayerMaskTable[0][0][0]; // myCurrentP0Mask = TIATables::PxMask[0][0][0];
// myCurrentP1Mask = TIATables::PlayerMaskTable[0][0][0]; // myCurrentP1Mask = TIATables::PxMask[0][0][0];
// myCurrentPFMask = TIATables::PlayfieldTable[0]; // myCurrentPFMask = TIATables::PFMask[0];
out.putInt(myLastHMOVEClock); out.putInt(myLastHMOVEClock);
out.putBool(myHMOVEBlankEnabled); out.putBool(myHMOVEBlankEnabled);
@ -438,12 +438,12 @@ bool TIA::load(Deserializer& in)
myCurrentGRP1 = (uInt8) in.getByte(); myCurrentGRP1 = (uInt8) in.getByte();
// pointers // pointers
// myCurrentBLMask = TIATables::BallMaskTable[0][0]; // myCurrentBLMask = TIATables::BLMask[0][0];
// myCurrentM0Mask = TIATables::MissleMaskTable[0][0][0]; // myCurrentM0Mask = TIATables::MxMask[0][0][0];
// myCurrentM1Mask = TIATables::MissleMaskTable[0][0][0]; // myCurrentM1Mask = TIATables::MxMask[0][0][0];
// myCurrentP0Mask = TIATables::PlayerMaskTable[0][0][0]; // myCurrentP0Mask = TIATables::PxMask[0][0][0];
// myCurrentP1Mask = TIATables::PlayerMaskTable[0][0][0]; // myCurrentP1Mask = TIATables::PxMask[0][0][0];
// myCurrentPFMask = TIATables::PlayfieldTable[0]; // myCurrentPFMask = TIATables::PFMask[0];
myLastHMOVEClock = (Int32) in.getInt(); myLastHMOVEClock = (Int32) in.getInt();
myHMOVEBlankEnabled = in.getBool(); myHMOVEBlankEnabled = in.getBool();
@ -812,7 +812,7 @@ inline void TIA::updateFrameScanline(uInt32 clocksToUpdate, uInt32 hpos)
myCOLUP0 : ((myCurrentGRP1 & *mP1) ? myCOLUP1 : myCOLUBK); myCOLUP0 : ((myCurrentGRP1 & *mP1) ? myCOLUP1 : myCOLUBK);
if((myCurrentGRP0 & *mP0) && (myCurrentGRP1 & *mP1)) if((myCurrentGRP0 & *mP0) && (myCurrentGRP1 & *mP1))
myCollision |= TIATables::CollisionTable[P0Bit | P1Bit]; myCollision |= TIATables::CollisionMask[P0Bit | P1Bit];
++mP0; ++mP1; ++myFramePointer; ++mP0; ++mP1; ++myFramePointer;
} }
@ -913,7 +913,7 @@ inline void TIA::updateFrameScanline(uInt32 clocksToUpdate, uInt32 hpos)
*myFramePointer = *mM0 ? myCOLUP0 : (*mM1 ? myCOLUP1 : myCOLUBK); *myFramePointer = *mM0 ? myCOLUP0 : (*mM1 ? myCOLUP1 : myCOLUBK);
if(*mM0 && *mM1) if(*mM0 && *mM1)
myCollision |= TIATables::CollisionTable[M0Bit | M1Bit]; myCollision |= TIATables::CollisionMask[M0Bit | M1Bit];
++mM0; ++mM1; ++myFramePointer; ++mM0; ++mM1; ++myFramePointer;
} }
@ -940,7 +940,7 @@ inline void TIA::updateFrameScanline(uInt32 clocksToUpdate, uInt32 hpos)
*myFramePointer = (*mM0 ? myCOLUP0 : (*mBL ? myCOLUPF : myCOLUBK)); *myFramePointer = (*mM0 ? myCOLUP0 : (*mBL ? myCOLUPF : myCOLUBK));
if(*mBL && *mM0) if(*mBL && *mM0)
myCollision |= TIATables::CollisionTable[BLBit | M0Bit]; myCollision |= TIATables::CollisionMask[BLBit | M0Bit];
++mBL; ++mM0; ++myFramePointer; ++mBL; ++mM0; ++myFramePointer;
} }
@ -967,7 +967,7 @@ inline void TIA::updateFrameScanline(uInt32 clocksToUpdate, uInt32 hpos)
*myFramePointer = (*mBL ? myCOLUPF : (*mM0 ? myCOLUP0 : myCOLUBK)); *myFramePointer = (*mBL ? myCOLUPF : (*mM0 ? myCOLUP0 : myCOLUBK));
if(*mBL && *mM0) if(*mBL && *mM0)
myCollision |= TIATables::CollisionTable[BLBit | M0Bit]; myCollision |= TIATables::CollisionMask[BLBit | M0Bit];
++mBL; ++mM0; ++myFramePointer; ++mBL; ++mM0; ++myFramePointer;
} }
@ -995,7 +995,7 @@ inline void TIA::updateFrameScanline(uInt32 clocksToUpdate, uInt32 hpos)
*myFramePointer = (*mM1 ? myCOLUP1 : (*mBL ? myCOLUPF : myCOLUBK)); *myFramePointer = (*mM1 ? myCOLUP1 : (*mBL ? myCOLUPF : myCOLUBK));
if(*mBL && *mM1) if(*mBL && *mM1)
myCollision |= TIATables::CollisionTable[BLBit | M1Bit]; myCollision |= TIATables::CollisionMask[BLBit | M1Bit];
++mBL; ++mM1; ++myFramePointer; ++mBL; ++mM1; ++myFramePointer;
} }
@ -1023,7 +1023,7 @@ inline void TIA::updateFrameScanline(uInt32 clocksToUpdate, uInt32 hpos)
*myFramePointer = (*mBL ? myCOLUPF : (*mM1 ? myCOLUP1 : myCOLUBK)); *myFramePointer = (*mBL ? myCOLUPF : (*mM1 ? myCOLUP1 : myCOLUBK));
if(*mBL && *mM1) if(*mBL && *mM1)
myCollision |= TIATables::CollisionTable[BLBit | M1Bit]; myCollision |= TIATables::CollisionMask[BLBit | M1Bit];
++mBL; ++mM1; ++myFramePointer; ++mBL; ++mM1; ++myFramePointer;
} }
@ -1051,7 +1051,7 @@ inline void TIA::updateFrameScanline(uInt32 clocksToUpdate, uInt32 hpos)
(*mBL ? myCOLUPF : myCOLUBK); (*mBL ? myCOLUPF : myCOLUBK);
if(*mBL && (myCurrentGRP1 & *mP1)) if(*mBL && (myCurrentGRP1 & *mP1))
myCollision |= TIATables::CollisionTable[BLBit | P1Bit]; myCollision |= TIATables::CollisionMask[BLBit | P1Bit];
++mBL; ++mP1; ++myFramePointer; ++mBL; ++mP1; ++myFramePointer;
} }
@ -1079,7 +1079,7 @@ inline void TIA::updateFrameScanline(uInt32 clocksToUpdate, uInt32 hpos)
((myCurrentGRP1 & *mP1) ? myCOLUP1 : myCOLUBK); ((myCurrentGRP1 & *mP1) ? myCOLUP1 : myCOLUBK);
if(*mBL && (myCurrentGRP1 & *mP1)) if(*mBL && (myCurrentGRP1 & *mP1))
myCollision |= TIATables::CollisionTable[BLBit | P1Bit]; myCollision |= TIATables::CollisionMask[BLBit | P1Bit];
++mBL; ++mP1; ++myFramePointer; ++mBL; ++mP1; ++myFramePointer;
} }
@ -1106,7 +1106,7 @@ inline void TIA::updateFrameScanline(uInt32 clocksToUpdate, uInt32 hpos)
myCOLUP0 : ((myPF & *mPF) ? myCOLUPF : myCOLUBK); myCOLUP0 : ((myPF & *mPF) ? myCOLUPF : myCOLUBK);
if((myPF & *mPF) && (myCurrentGRP0 & *mP0)) if((myPF & *mPF) && (myCurrentGRP0 & *mP0))
myCollision |= TIATables::CollisionTable[PFBit | P0Bit]; myCollision |= TIATables::CollisionMask[PFBit | P0Bit];
++mPF; ++mP0; ++myFramePointer; ++mPF; ++mP0; ++myFramePointer;
} }
@ -1134,7 +1134,7 @@ inline void TIA::updateFrameScanline(uInt32 clocksToUpdate, uInt32 hpos)
((myCurrentGRP0 & *mP0) ? myCOLUP0 : myCOLUBK); ((myCurrentGRP0 & *mP0) ? myCOLUP0 : myCOLUBK);
if((myPF & *mPF) && (myCurrentGRP0 & *mP0)) if((myPF & *mPF) && (myCurrentGRP0 & *mP0))
myCollision |= TIATables::CollisionTable[PFBit | P0Bit]; myCollision |= TIATables::CollisionMask[PFBit | P0Bit];
++mPF; ++mP0; ++myFramePointer; ++mPF; ++mP0; ++myFramePointer;
} }
@ -1162,7 +1162,7 @@ inline void TIA::updateFrameScanline(uInt32 clocksToUpdate, uInt32 hpos)
myCOLUP1 : ((myPF & *mPF) ? myCOLUPF : myCOLUBK); myCOLUP1 : ((myPF & *mPF) ? myCOLUPF : myCOLUBK);
if((myPF & *mPF) && (myCurrentGRP1 & *mP1)) if((myPF & *mPF) && (myCurrentGRP1 & *mP1))
myCollision |= TIATables::CollisionTable[PFBit | P1Bit]; myCollision |= TIATables::CollisionMask[PFBit | P1Bit];
++mPF; ++mP1; ++myFramePointer; ++mPF; ++mP1; ++myFramePointer;
} }
@ -1190,7 +1190,7 @@ inline void TIA::updateFrameScanline(uInt32 clocksToUpdate, uInt32 hpos)
((myCurrentGRP1 & *mP1) ? myCOLUP1 : myCOLUBK); ((myCurrentGRP1 & *mP1) ? myCOLUP1 : myCOLUBK);
if((myPF & *mPF) && (myCurrentGRP1 & *mP1)) if((myPF & *mPF) && (myCurrentGRP1 & *mP1))
myCollision |= TIATables::CollisionTable[PFBit | P1Bit]; myCollision |= TIATables::CollisionMask[PFBit | P1Bit];
++mPF; ++mP1; ++myFramePointer; ++mPF; ++mP1; ++myFramePointer;
} }
@ -1218,7 +1218,7 @@ inline void TIA::updateFrameScanline(uInt32 clocksToUpdate, uInt32 hpos)
*myFramePointer = ((myPF & *mPF) || *mBL) ? myCOLUPF : myCOLUBK; *myFramePointer = ((myPF & *mPF) || *mBL) ? myCOLUPF : myCOLUBK;
if((myPF & *mPF) && *mBL) if((myPF & *mPF) && *mBL)
myCollision |= TIATables::CollisionTable[PFBit | BLBit]; myCollision |= TIATables::CollisionMask[PFBit | BLBit];
++mPF; ++mBL; ++myFramePointer; ++mPF; ++mBL; ++myFramePointer;
} }
@ -1248,7 +1248,7 @@ inline void TIA::updateFrameScanline(uInt32 clocksToUpdate, uInt32 hpos)
if((myEnabledObjects & M0Bit) && myCurrentM0Mask[hpos]) if((myEnabledObjects & M0Bit) && myCurrentM0Mask[hpos])
enabled |= M0Bit; enabled |= M0Bit;
myCollision |= TIATables::CollisionTable[enabled]; myCollision |= TIATables::CollisionMask[enabled];
*myFramePointer = myColor[myPriorityEncoder[hpos < 80 ? 0 : 1] *myFramePointer = myColor[myPriorityEncoder[hpos < 80 ? 0 : 1]
[enabled | myPlayfieldPriorityAndScore]]; [enabled | myPlayfieldPriorityAndScore]];
} }
@ -1344,14 +1344,14 @@ void TIA::updateFrame(Int32 clock)
if(myClocksToEndOfScanLine == 228) if(myClocksToEndOfScanLine == 228)
{ {
// Yes, so set PF mask based on current CTRLPF reflection state // Yes, so set PF mask based on current CTRLPF reflection state
myCurrentPFMask = TIATables::PlayfieldTable[myCTRLPF & 0x01]; myCurrentPFMask = TIATables::PFMask[myCTRLPF & 0x01];
// TODO: These should be reset right after the first copy of the player // TODO: These should be reset right after the first copy of the player
// has passed. However, for now we'll just reset at the end of the // has passed. However, for now we'll just reset at the end of the
// scanline since the other way would be to slow (01/21/99). // scanline since the other way would be to slow (01/21/99).
myCurrentP0Mask = &TIATables::PlayerMaskTable[myPOSP0 & 0x03] myCurrentP0Mask = &TIATables::PxMask[myPOSP0 & 0x03]
[0][myNUSIZ0 & 0x07][160 - (myPOSP0 & 0xFC)]; [0][myNUSIZ0 & 0x07][160 - (myPOSP0 & 0xFC)];
myCurrentP1Mask = &TIATables::PlayerMaskTable[myPOSP1 & 0x03] myCurrentP1Mask = &TIATables::PxMask[myPOSP1 & 0x03]
[0][myNUSIZ1 & 0x07][160 - (myPOSP1 & 0xFC)]; [0][myNUSIZ1 & 0x07][160 - (myPOSP1 & 0xFC)];
#ifndef NO_HMOVE_FIXES #ifndef NO_HMOVE_FIXES
@ -1372,18 +1372,18 @@ void TIA::updateFrame(Int32 clock)
if(myM0CosmicArkCounter == 1) if(myM0CosmicArkCounter == 1)
{ {
// Stretch this missle so it's at least 2 pixels wide // Stretch this missle so it's at least 2 pixels wide
myCurrentM0Mask = &TIATables::MissleMaskTable[myPOSM0 & 0x03] myCurrentM0Mask = &TIATables::MxMask[myPOSM0 & 0x03]
[myNUSIZ0 & 0x07][((myNUSIZ0 & 0x30) >> 4) | 0x01] [myNUSIZ0 & 0x07][((myNUSIZ0 & 0x30) >> 4) | 0x01]
[160 - (myPOSM0 & 0xFC)]; [160 - (myPOSM0 & 0xFC)];
} }
else if(myM0CosmicArkCounter == 2) else if(myM0CosmicArkCounter == 2)
{ {
// Missle is disabled on this line // Missle is disabled on this line
myCurrentM0Mask = &TIATables::DisabledMaskTable[0]; myCurrentM0Mask = &TIATables::DisabledMask[0];
} }
else else
{ {
myCurrentM0Mask = &TIATables::MissleMaskTable[myPOSM0 & 0x03] myCurrentM0Mask = &TIATables::MxMask[myPOSM0 & 0x03]
[myNUSIZ0 & 0x07][(myNUSIZ0 & 0x30) >> 4][160 - (myPOSM0 & 0xFC)]; [myNUSIZ0 & 0x07][(myNUSIZ0 & 0x30) >> 4][160 - (myPOSM0 & 0xFC)];
} }
} }
@ -1547,7 +1547,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
addr = addr & 0x003f; addr = addr & 0x003f;
Int32 clock = mySystem->cycles() * 3; Int32 clock = mySystem->cycles() * 3;
Int16 delay = TIATables::PokeDelayTable[addr]; Int16 delay = TIATables::PokeDelay[addr];
// See if this is a poke to a PF register // See if this is a poke to a PF register
if(delay == -1) if(delay == -1)
@ -1641,10 +1641,10 @@ void TIA::poke(uInt16 addr, uInt8 value)
// TODO: Technically the "enable" part, [0], should depend on the current // TODO: Technically the "enable" part, [0], should depend on the current
// enabled or disabled state. This mean we probably need a data member // enabled or disabled state. This mean we probably need a data member
// to maintain that state (01/21/99). // to maintain that state (01/21/99).
myCurrentP0Mask = &TIATables::PlayerMaskTable[myPOSP0 & 0x03] myCurrentP0Mask = &TIATables::PxMask[myPOSP0 & 0x03]
[0][myNUSIZ0 & 0x07][160 - (myPOSP0 & 0xFC)]; [0][myNUSIZ0 & 0x07][160 - (myPOSP0 & 0xFC)];
myCurrentM0Mask = &TIATables::MissleMaskTable[myPOSM0 & 0x03] myCurrentM0Mask = &TIATables::MxMask[myPOSM0 & 0x03]
[myNUSIZ0 & 0x07][(myNUSIZ0 & 0x30) >> 4][160 - (myPOSM0 & 0xFC)]; [myNUSIZ0 & 0x07][(myNUSIZ0 & 0x30) >> 4][160 - (myPOSM0 & 0xFC)];
break; break;
@ -1657,10 +1657,10 @@ void TIA::poke(uInt16 addr, uInt8 value)
// TODO: Technically the "enable" part, [0], should depend on the current // TODO: Technically the "enable" part, [0], should depend on the current
// enabled or disabled state. This mean we probably need a data member // enabled or disabled state. This mean we probably need a data member
// to maintain that state (01/21/99). // to maintain that state (01/21/99).
myCurrentP1Mask = &TIATables::PlayerMaskTable[myPOSP1 & 0x03] myCurrentP1Mask = &TIATables::PxMask[myPOSP1 & 0x03]
[0][myNUSIZ1 & 0x07][160 - (myPOSP1 & 0xFC)]; [0][myNUSIZ1 & 0x07][160 - (myPOSP1 & 0xFC)];
myCurrentM1Mask = &TIATables::MissleMaskTable[myPOSM1 & 0x03] myCurrentM1Mask = &TIATables::MxMask[myPOSM1 & 0x03]
[myNUSIZ1 & 0x07][(myNUSIZ1 & 0x30) >> 4][160 - (myPOSM1 & 0xFC)]; [myNUSIZ1 & 0x07][(myNUSIZ1 & 0x30) >> 4][160 - (myPOSM1 & 0xFC)];
break; break;
@ -1723,10 +1723,10 @@ void TIA::poke(uInt16 addr, uInt8 value)
// we're still on the left hand side of the playfield // we're still on the left hand side of the playfield
if(((clock - myClockWhenFrameStarted) % 228) < (68 + 79)) if(((clock - myClockWhenFrameStarted) % 228) < (68 + 79))
{ {
myCurrentPFMask = TIATables::PlayfieldTable[myCTRLPF & 0x01]; myCurrentPFMask = TIATables::PFMask[myCTRLPF & 0x01];
} }
myCurrentBLMask = &TIATables::BallMaskTable[myPOSBL & 0x03] myCurrentBLMask = &TIATables::BLMask[myPOSBL & 0x03]
[(myCTRLPF & 0x30) >> 4][160 - (myPOSBL & 0xFC)]; [(myCTRLPF & 0x30) >> 4][160 - (myPOSBL & 0xFC)];
break; break;
@ -1738,7 +1738,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
if(((value & 0x08) && !myREFP0) || (!(value & 0x08) && myREFP0)) if(((value & 0x08) && !myREFP0) || (!(value & 0x08) && myREFP0))
{ {
myREFP0 = (value & 0x08); myREFP0 = (value & 0x08);
myCurrentGRP0 = TIATables::PlayerReflectTable[myCurrentGRP0]; myCurrentGRP0 = TIATables::GRPReflect[myCurrentGRP0];
} }
break; break;
} }
@ -1749,7 +1749,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
if(((value & 0x08) && !myREFP1) || (!(value & 0x08) && myREFP1)) if(((value & 0x08) && !myREFP1) || (!(value & 0x08) && myREFP1))
{ {
myREFP1 = (value & 0x08); myREFP1 = (value & 0x08);
myCurrentGRP1 = TIATables::PlayerReflectTable[myCurrentGRP1]; myCurrentGRP1 = TIATables::GRPReflect[myCurrentGRP1];
} }
break; break;
} }
@ -1796,7 +1796,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
Int32 newx = hpos < HBLANK ? 3 : (((hpos - HBLANK) + 5) % 160); Int32 newx = hpos < HBLANK ? 3 : (((hpos - HBLANK) + 5) % 160);
// Find out under what condition the player is being reset // Find out under what condition the player is being reset
Int8 when = TIATables::PlayerPositionResetWhenTable[myNUSIZ0 & 7][myPOSP0][newx]; Int8 when = TIATables::PxPosResetWhen[myNUSIZ0 & 7][myPOSP0][newx];
#ifdef DEBUG_HMOVE #ifdef DEBUG_HMOVE
if((clock - myLastHMOVEClock) < (24 * 3)) if((clock - myLastHMOVEClock) < (24 * 3))
@ -1817,7 +1817,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
myPOSP0 = newx; myPOSP0 = newx;
// Setup the mask to skip the first copy of the player // Setup the mask to skip the first copy of the player
myCurrentP0Mask = &TIATables::PlayerMaskTable[myPOSP0 & 0x03] myCurrentP0Mask = &TIATables::PxMask[myPOSP0 & 0x03]
[1][myNUSIZ0 & 0x07][160 - (myPOSP0 & 0xFC)]; [1][myNUSIZ0 & 0x07][160 - (myPOSP0 & 0xFC)];
} }
// Player is being reset in neither the delay nor display section // Player is being reset in neither the delay nor display section
@ -1826,7 +1826,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
myPOSP0 = newx; myPOSP0 = newx;
// So we setup the mask to skip the first copy of the player // So we setup the mask to skip the first copy of the player
myCurrentP0Mask = &TIATables::PlayerMaskTable[myPOSP0 & 0x03] myCurrentP0Mask = &TIATables::PxMask[myPOSP0 & 0x03]
[1][myNUSIZ0 & 0x07][160 - (myPOSP0 & 0xFC)]; [1][myNUSIZ0 & 0x07][160 - (myPOSP0 & 0xFC)];
} }
// Player is being reset during the delay section of one of its copies // Player is being reset during the delay section of one of its copies
@ -1835,7 +1835,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
myPOSP0 = newx; myPOSP0 = newx;
// So we setup the mask to display all copies of the player // So we setup the mask to display all copies of the player
myCurrentP0Mask = &TIATables::PlayerMaskTable[myPOSP0 & 0x03] myCurrentP0Mask = &TIATables::PxMask[myPOSP0 & 0x03]
[0][myNUSIZ0 & 0x07][160 - (myPOSP0 & 0xFC)]; [0][myNUSIZ0 & 0x07][160 - (myPOSP0 & 0xFC)];
} }
break; break;
@ -1847,7 +1847,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
Int32 newx = hpos < HBLANK ? 3 : (((hpos - HBLANK) + 5) % 160); Int32 newx = hpos < HBLANK ? 3 : (((hpos - HBLANK) + 5) % 160);
// Find out under what condition the player is being reset // Find out under what condition the player is being reset
Int8 when = TIATables::PlayerPositionResetWhenTable[myNUSIZ1 & 7][myPOSP1][newx]; Int8 when = TIATables::PxPosResetWhen[myNUSIZ1 & 7][myPOSP1][newx];
#ifdef DEBUG_HMOVE #ifdef DEBUG_HMOVE
if((clock - myLastHMOVEClock) < (24 * 3)) if((clock - myLastHMOVEClock) < (24 * 3))
@ -1868,7 +1868,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
myPOSP1 = newx; myPOSP1 = newx;
// Setup the mask to skip the first copy of the player // Setup the mask to skip the first copy of the player
myCurrentP1Mask = &TIATables::PlayerMaskTable[myPOSP1 & 0x03] myCurrentP1Mask = &TIATables::PxMask[myPOSP1 & 0x03]
[1][myNUSIZ1 & 0x07][160 - (myPOSP1 & 0xFC)]; [1][myNUSIZ1 & 0x07][160 - (myPOSP1 & 0xFC)];
} }
// Player is being reset in neither the delay nor display section // Player is being reset in neither the delay nor display section
@ -1877,7 +1877,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
myPOSP1 = newx; myPOSP1 = newx;
// So we setup the mask to skip the first copy of the player // So we setup the mask to skip the first copy of the player
myCurrentP1Mask = &TIATables::PlayerMaskTable[myPOSP1 & 0x03] myCurrentP1Mask = &TIATables::PxMask[myPOSP1 & 0x03]
[1][myNUSIZ1 & 0x07][160 - (myPOSP1 & 0xFC)]; [1][myNUSIZ1 & 0x07][160 - (myPOSP1 & 0xFC)];
} }
// Player is being reset during the delay section of one of its copies // Player is being reset during the delay section of one of its copies
@ -1886,7 +1886,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
myPOSP1 = newx; myPOSP1 = newx;
// So we setup the mask to display all copies of the player // So we setup the mask to display all copies of the player
myCurrentP1Mask = &TIATables::PlayerMaskTable[myPOSP1 & 0x03] myCurrentP1Mask = &TIATables::PxMask[myPOSP1 & 0x03]
[0][myNUSIZ1 & 0x07][160 - (myPOSP1 & 0xFC)]; [0][myNUSIZ1 & 0x07][160 - (myPOSP1 & 0xFC)];
} }
break; break;
@ -1920,7 +1920,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
myPOSM0 = 8; myPOSM0 = 8;
} }
#endif #endif
myCurrentM0Mask = &TIATables::MissleMaskTable[myPOSM0 & 0x03] myCurrentM0Mask = &TIATables::MxMask[myPOSM0 & 0x03]
[myNUSIZ0 & 0x07][(myNUSIZ0 & 0x30) >> 4][160 - (myPOSM0 & 0xFC)]; [myNUSIZ0 & 0x07][(myNUSIZ0 & 0x30) >> 4][160 - (myPOSM0 & 0xFC)];
break; break;
} }
@ -1946,7 +1946,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
myPOSM1 = 3; myPOSM1 = 3;
} }
#endif #endif
myCurrentM1Mask = &TIATables::MissleMaskTable[myPOSM1 & 0x03] myCurrentM1Mask = &TIATables::MxMask[myPOSM1 & 0x03]
[myNUSIZ1 & 0x07][(myNUSIZ1 & 0x30) >> 4][160 - (myPOSM1 & 0xFC)]; [myNUSIZ1 & 0x07][(myNUSIZ1 & 0x30) >> 4][160 - (myPOSM1 & 0xFC)];
break; break;
} }
@ -2018,7 +2018,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
myPOSBL = 8; myPOSBL = 8;
} }
#endif #endif
myCurrentBLMask = &TIATables::BallMaskTable[myPOSBL & 0x03] myCurrentBLMask = &TIATables::BLMask[myPOSBL & 0x03]
[(myCTRLPF & 0x30) >> 4][160 - (myPOSBL & 0xFC)]; [(myCTRLPF & 0x30) >> 4][160 - (myPOSBL & 0xFC)];
break; break;
} }
@ -2075,11 +2075,11 @@ void TIA::poke(uInt16 addr, uInt8 value)
// Get the "current" data for GRP0 base on delay register and reflect // Get the "current" data for GRP0 base on delay register and reflect
uInt8 grp0 = myVDELP0 ? myDGRP0 : myGRP0; uInt8 grp0 = myVDELP0 ? myDGRP0 : myGRP0;
myCurrentGRP0 = myREFP0 ? TIATables::PlayerReflectTable[grp0] : grp0; myCurrentGRP0 = myREFP0 ? TIATables::GRPReflect[grp0] : grp0;
// Get the "current" data for GRP1 base on delay register and reflect // Get the "current" data for GRP1 base on delay register and reflect
uInt8 grp1 = myVDELP1 ? myDGRP1 : myGRP1; uInt8 grp1 = myVDELP1 ? myDGRP1 : myGRP1;
myCurrentGRP1 = myREFP1 ? TIATables::PlayerReflectTable[grp1] : grp1; myCurrentGRP1 = myREFP1 ? TIATables::GRPReflect[grp1] : grp1;
// Set enabled object bits // Set enabled object bits
if(myCurrentGRP0 != 0) if(myCurrentGRP0 != 0)
@ -2108,11 +2108,11 @@ void TIA::poke(uInt16 addr, uInt8 value)
// Get the "current" data for GRP0 base on delay register // Get the "current" data for GRP0 base on delay register
uInt8 grp0 = myVDELP0 ? myDGRP0 : myGRP0; uInt8 grp0 = myVDELP0 ? myDGRP0 : myGRP0;
myCurrentGRP0 = myREFP0 ? TIATables::PlayerReflectTable[grp0] : grp0; myCurrentGRP0 = myREFP0 ? TIATables::GRPReflect[grp0] : grp0;
// Get the "current" data for GRP1 base on delay register // Get the "current" data for GRP1 base on delay register
uInt8 grp1 = myVDELP1 ? myDGRP1 : myGRP1; uInt8 grp1 = myVDELP1 ? myDGRP1 : myGRP1;
myCurrentGRP1 = myREFP1 ? TIATables::PlayerReflectTable[grp1] : grp1; myCurrentGRP1 = myREFP1 ? TIATables::GRPReflect[grp1] : grp1;
// Set enabled object bits // Set enabled object bits
if(myCurrentGRP0 != 0) if(myCurrentGRP0 != 0)
@ -2212,7 +2212,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
myVDELP0 = value & 0x01; myVDELP0 = value & 0x01;
uInt8 grp0 = myVDELP0 ? myDGRP0 : myGRP0; uInt8 grp0 = myVDELP0 ? myDGRP0 : myGRP0;
myCurrentGRP0 = myREFP0 ? TIATables::PlayerReflectTable[grp0] : grp0; myCurrentGRP0 = myREFP0 ? TIATables::GRPReflect[grp0] : grp0;
if(myCurrentGRP0 != 0) if(myCurrentGRP0 != 0)
myEnabledObjects |= P0Bit; myEnabledObjects |= P0Bit;
@ -2226,7 +2226,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
myVDELP1 = value & 0x01; myVDELP1 = value & 0x01;
uInt8 grp1 = myVDELP1 ? myDGRP1 : myGRP1; uInt8 grp1 = myVDELP1 ? myDGRP1 : myGRP1;
myCurrentGRP1 = myREFP1 ? TIATables::PlayerReflectTable[grp1] : grp1; myCurrentGRP1 = myREFP1 ? TIATables::GRPReflect[grp1] : grp1;
if(myCurrentGRP1 != 0) if(myCurrentGRP1 != 0)
myEnabledObjects |= P1Bit; myEnabledObjects |= P1Bit;
@ -2260,7 +2260,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
middle = 4; middle = 4;
myPOSM0 = (myPOSP0 + middle) % 160; myPOSM0 = (myPOSP0 + middle) % 160;
myCurrentM0Mask = &TIATables::MissleMaskTable[myPOSM0 & 0x03] myCurrentM0Mask = &TIATables::MxMask[myPOSM0 & 0x03]
[myNUSIZ0 & 0x07][(myNUSIZ0 & 0x30) >> 4][160 - (myPOSM0 & 0xFC)]; [myNUSIZ0 & 0x07][(myNUSIZ0 & 0x30) >> 4][160 - (myPOSM0 & 0xFC)];
} }
@ -2288,7 +2288,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
middle = 4; middle = 4;
myPOSM1 = (myPOSP1 + middle) % 160; myPOSM1 = (myPOSP1 + middle) % 160;
myCurrentM1Mask = &TIATables::MissleMaskTable[myPOSM1 & 0x03] myCurrentM1Mask = &TIATables::MxMask[myPOSM1 & 0x03]
[myNUSIZ1 & 0x07][(myNUSIZ1 & 0x30) >> 4][160 - (myPOSM1 & 0xFC)]; [myNUSIZ1 & 0x07][(myNUSIZ1 & 0x30) >> 4][160 - (myPOSM1 & 0xFC)];
} }
@ -2313,11 +2313,11 @@ void TIA::poke(uInt16 addr, uInt8 value)
myHMOVEBlankEnabled = true; myHMOVEBlankEnabled = true;
} }
myPOSP0 += TIATables::CompleteMotionTable[x][myHMP0]; myPOSP0 += TIATables::CompleteMotion[x][myHMP0];
myPOSP1 += TIATables::CompleteMotionTable[x][myHMP1]; myPOSP1 += TIATables::CompleteMotion[x][myHMP1];
myPOSM0 += TIATables::CompleteMotionTable[x][myHMM0]; myPOSM0 += TIATables::CompleteMotion[x][myHMM0];
myPOSM1 += TIATables::CompleteMotionTable[x][myHMM1]; myPOSM1 += TIATables::CompleteMotion[x][myHMM1];
myPOSBL += TIATables::CompleteMotionTable[x][myHMBL]; myPOSBL += TIATables::CompleteMotion[x][myHMBL];
if(myPOSP0 >= 160) if(myPOSP0 >= 160)
myPOSP0 -= 160; myPOSP0 -= 160;
@ -2344,17 +2344,17 @@ void TIA::poke(uInt16 addr, uInt8 value)
else if(myPOSBL < 0) else if(myPOSBL < 0)
myPOSBL += 160; myPOSBL += 160;
myCurrentBLMask = &TIATables::BallMaskTable[myPOSBL & 0x03] myCurrentBLMask = &TIATables::BLMask[myPOSBL & 0x03]
[(myCTRLPF & 0x30) >> 4][160 - (myPOSBL & 0xFC)]; [(myCTRLPF & 0x30) >> 4][160 - (myPOSBL & 0xFC)];
myCurrentP0Mask = &TIATables::PlayerMaskTable[myPOSP0 & 0x03] myCurrentP0Mask = &TIATables::PxMask[myPOSP0 & 0x03]
[0][myNUSIZ0 & 0x07][160 - (myPOSP0 & 0xFC)]; [0][myNUSIZ0 & 0x07][160 - (myPOSP0 & 0xFC)];
myCurrentP1Mask = &TIATables::PlayerMaskTable[myPOSP1 & 0x03] myCurrentP1Mask = &TIATables::PxMask[myPOSP1 & 0x03]
[0][myNUSIZ1 & 0x07][160 - (myPOSP1 & 0xFC)]; [0][myNUSIZ1 & 0x07][160 - (myPOSP1 & 0xFC)];
myCurrentM0Mask = &TIATables::MissleMaskTable[myPOSM0 & 0x03] myCurrentM0Mask = &TIATables::MxMask[myPOSM0 & 0x03]
[myNUSIZ0 & 0x07][(myNUSIZ0 & 0x30) >> 4][160 - (myPOSM0 & 0xFC)]; [myNUSIZ0 & 0x07][(myNUSIZ0 & 0x30) >> 4][160 - (myPOSM0 & 0xFC)];
myCurrentM1Mask = &TIATables::MissleMaskTable[myPOSM1 & 0x03] myCurrentM1Mask = &TIATables::MxMask[myPOSM1 & 0x03]
[myNUSIZ1 & 0x07][(myNUSIZ1 & 0x30) >> 4][160 - (myPOSM1 & 0xFC)]; [myNUSIZ1 & 0x07][(myNUSIZ1 & 0x30) >> 4][160 - (myPOSM1 & 0xFC)];
// Remember what clock HMOVE occured at // Remember what clock HMOVE occured at

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: TIATables.cxx,v 1.2 2009-02-07 21:50:05 stephena Exp $ // $Id: TIATables.cxx,v 1.3 2009-02-08 21:07:06 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
@ -25,210 +25,73 @@
void TIATables::computeAllTables() void TIATables::computeAllTables()
{ {
for(uInt32 i = 0; i < 640; ++i) for(uInt32 i = 0; i < 640; ++i)
DisabledMaskTable[i] = 0; DisabledMask[i] = 0;
computeBallMaskTable(); buildCollisionMaskTable();
computeCollisionTable(); buildPxMaskTable();
computeMissleMaskTable(); buildMxMaskTable();
computePlayerMaskTable(); buildBLMaskTable();
computePlayerPositionResetWhenTable(); buildPFMaskTable();
computePlayerReflectTable(); buildGRPReflectTable();
computePlayfieldMaskTable(); buildPxPosResetWhenTable();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIATables::computeBallMaskTable() void TIATables::buildCollisionMaskTable()
{
// First, calculate masks for alignment 0
for(Int32 size = 0; size < 4; ++size)
{
Int32 x;
// Set all of the masks to false to start with
for(x = 0; x < 160; ++x)
{
BallMaskTable[0][size][x] = false;
}
// Set the necessary fields true
for(x = 0; x < 160 + 8; ++x)
{
if((x >= 0) && (x < (1 << size)))
{
BallMaskTable[0][size][x % 160] = true;
}
}
// Copy fields into the wrap-around area of the mask
for(x = 0; x < 160; ++x)
{
BallMaskTable[0][size][x + 160] = BallMaskTable[0][size][x];
}
}
// Now, copy data for alignments of 1, 2 and 3
for(uInt32 align = 1; align < 4; ++align)
{
for(uInt32 size = 0; size < 4; ++size)
{
for(uInt32 x = 0; x < 320; ++x)
{
BallMaskTable[align][size][x] = BallMaskTable[0][size][(x + 320 - align) % 320];
}
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIATables::computeCollisionTable()
{ {
for(uInt8 i = 0; i < 64; ++i) for(uInt8 i = 0; i < 64; ++i)
{ {
CollisionTable[i] = 0; CollisionMask[i] = 0;
if((i & M0Bit) && (i & P1Bit)) // M0-P1 if((i & M0Bit) && (i & P1Bit)) // M0-P1
CollisionTable[i] |= 0x0001; CollisionMask[i] |= 0x0001;
if((i & M0Bit) && (i & P0Bit)) // M0-P0 if((i & M0Bit) && (i & P0Bit)) // M0-P0
CollisionTable[i] |= 0x0002; CollisionMask[i] |= 0x0002;
if((i & M1Bit) && (i & P0Bit)) // M1-P0 if((i & M1Bit) && (i & P0Bit)) // M1-P0
CollisionTable[i] |= 0x0004; CollisionMask[i] |= 0x0004;
if((i & M1Bit) && (i & P1Bit)) // M1-P1 if((i & M1Bit) && (i & P1Bit)) // M1-P1
CollisionTable[i] |= 0x0008; CollisionMask[i] |= 0x0008;
if((i & P0Bit) && (i & PFBit)) // P0-PF if((i & P0Bit) && (i & PFBit)) // P0-PF
CollisionTable[i] |= 0x0010; CollisionMask[i] |= 0x0010;
if((i & P0Bit) && (i & BLBit)) // P0-BL if((i & P0Bit) && (i & BLBit)) // P0-BL
CollisionTable[i] |= 0x0020; CollisionMask[i] |= 0x0020;
if((i & P1Bit) && (i & PFBit)) // P1-PF if((i & P1Bit) && (i & PFBit)) // P1-PF
CollisionTable[i] |= 0x0040; CollisionMask[i] |= 0x0040;
if((i & P1Bit) && (i & BLBit)) // P1-BL if((i & P1Bit) && (i & BLBit)) // P1-BL
CollisionTable[i] |= 0x0080; CollisionMask[i] |= 0x0080;
if((i & M0Bit) && (i & PFBit)) // M0-PF if((i & M0Bit) && (i & PFBit)) // M0-PF
CollisionTable[i] |= 0x0100; CollisionMask[i] |= 0x0100;
if((i & M0Bit) && (i & BLBit)) // M0-BL if((i & M0Bit) && (i & BLBit)) // M0-BL
CollisionTable[i] |= 0x0200; CollisionMask[i] |= 0x0200;
if((i & M1Bit) && (i & PFBit)) // M1-PF if((i & M1Bit) && (i & PFBit)) // M1-PF
CollisionTable[i] |= 0x0400; CollisionMask[i] |= 0x0400;
if((i & M1Bit) && (i & BLBit)) // M1-BL if((i & M1Bit) && (i & BLBit)) // M1-BL
CollisionTable[i] |= 0x0800; CollisionMask[i] |= 0x0800;
if((i & BLBit) && (i & PFBit)) // BL-PF if((i & BLBit) && (i & PFBit)) // BL-PF
CollisionTable[i] |= 0x1000; CollisionMask[i] |= 0x1000;
if((i & P0Bit) && (i & P1Bit)) // P0-P1 if((i & P0Bit) && (i & P1Bit)) // P0-P1
CollisionTable[i] |= 0x2000; CollisionMask[i] |= 0x2000;
if((i & M0Bit) && (i & M1Bit)) // M0-M1 if((i & M0Bit) && (i & M1Bit)) // M0-M1
CollisionTable[i] |= 0x4000; CollisionMask[i] |= 0x4000;
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIATables::computeMissleMaskTable() void TIATables::buildPxMaskTable() // [4][2][8][320]
{
// First, calculate masks for alignment 0
Int32 x, size, number;
// Clear the missle table to start with
for(number = 0; number < 8; ++number)
for(size = 0; size < 4; ++size)
for(x = 0; x < 160; ++x)
MissleMaskTable[0][number][size][x] = false;
for(number = 0; number < 8; ++number)
{
for(size = 0; size < 4; ++size)
{
for(x = 0; x < 160 + 72; ++x)
{
// Only one copy of the missle
if((number == 0x00) || (number == 0x05) || (number == 0x07))
{
if((x >= 0) && (x < (1 << size)))
MissleMaskTable[0][number][size][x % 160] = true;
}
// Two copies - close
else if(number == 0x01)
{
if((x >= 0) && (x < (1 << size)))
MissleMaskTable[0][number][size][x % 160] = true;
else if(((x - 16) >= 0) && ((x - 16) < (1 << size)))
MissleMaskTable[0][number][size][x % 160] = true;
}
// Two copies - medium
else if(number == 0x02)
{
if((x >= 0) && (x < (1 << size)))
MissleMaskTable[0][number][size][x % 160] = true;
else if(((x - 32) >= 0) && ((x - 32) < (1 << size)))
MissleMaskTable[0][number][size][x % 160] = true;
}
// Three copies - close
else if(number == 0x03)
{
if((x >= 0) && (x < (1 << size)))
MissleMaskTable[0][number][size][x % 160] = true;
else if(((x - 16) >= 0) && ((x - 16) < (1 << size)))
MissleMaskTable[0][number][size][x % 160] = true;
else if(((x - 32) >= 0) && ((x - 32) < (1 << size)))
MissleMaskTable[0][number][size][x % 160] = true;
}
// Two copies - wide
else if(number == 0x04)
{
if((x >= 0) && (x < (1 << size)))
MissleMaskTable[0][number][size][x % 160] = true;
else if(((x - 64) >= 0) && ((x - 64) < (1 << size)))
MissleMaskTable[0][number][size][x % 160] = true;
}
// Three copies - medium
else if(number == 0x06)
{
if((x >= 0) && (x < (1 << size)))
MissleMaskTable[0][number][size][x % 160] = true;
else if(((x - 32) >= 0) && ((x - 32) < (1 << size)))
MissleMaskTable[0][number][size][x % 160] = true;
else if(((x - 64) >= 0) && ((x - 64) < (1 << size)))
MissleMaskTable[0][number][size][x % 160] = true;
}
}
// Copy data into wrap-around area
for(x = 0; x < 160; ++x)
MissleMaskTable[0][number][size][x + 160] =
MissleMaskTable[0][number][size][x];
}
}
// Now, copy data for alignments of 1, 2 and 3
for(uInt32 align = 1; align < 4; ++align)
{
for(number = 0; number < 8; ++number)
{
for(size = 0; size < 4; ++size)
{
for(x = 0; x < 320; ++x)
{
MissleMaskTable[align][number][size][x] =
MissleMaskTable[0][number][size][(x + 320 - align) % 320];
}
}
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIATables::computePlayerMaskTable()
{ {
// First, calculate masks for alignment 0 // First, calculate masks for alignment 0
Int32 x, enable, mode; Int32 x, enable, mode;
@ -237,7 +100,7 @@ void TIATables::computePlayerMaskTable()
for(enable = 0; enable < 2; ++enable) for(enable = 0; enable < 2; ++enable)
for(mode = 0; mode < 8; ++mode) for(mode = 0; mode < 8; ++mode)
for(x = 0; x < 160; ++x) for(x = 0; x < 160; ++x)
PlayerMaskTable[0][enable][mode][x] = 0x00; PxMask[0][enable][mode][x] = 0x00;
// Now, compute the player mask table // Now, compute the player mask table
for(enable = 0; enable < 2; ++enable) for(enable = 0; enable < 2; ++enable)
@ -246,71 +109,73 @@ void TIATables::computePlayerMaskTable()
{ {
for(x = 0; x < 160 + 72; ++x) for(x = 0; x < 160 + 72; ++x)
{ {
if(mode == 0x00) switch(mode)
{ {
if((enable == 0) && (x >= 0) && (x < 8)) case 0x00:
PlayerMaskTable[0][enable][mode][x % 160] = 0x80 >> x; if((enable == 0) && (x >= 0) && (x < 8))
} PxMask[0][enable][mode][x % 160] = 0x80 >> x;
else if(mode == 0x01) break;
{
if((enable == 0) && (x >= 0) && (x < 8)) case 0x01:
PlayerMaskTable[0][enable][mode][x % 160] = 0x80 >> x; if((enable == 0) && (x >= 0) && (x < 8))
else if(((x - 16) >= 0) && ((x - 16) < 8)) PxMask[0][enable][mode][x % 160] = 0x80 >> x;
PlayerMaskTable[0][enable][mode][x % 160] = 0x80 >> (x - 16); else if(((x - 16) >= 0) && ((x - 16) < 8))
} PxMask[0][enable][mode][x % 160] = 0x80 >> (x - 16);
else if(mode == 0x02) break;
{
if((enable == 0) && (x >= 0) && (x < 8)) case 0x02:
PlayerMaskTable[0][enable][mode][x % 160] = 0x80 >> x; if((enable == 0) && (x >= 0) && (x < 8))
else if(((x - 32) >= 0) && ((x - 32) < 8)) PxMask[0][enable][mode][x % 160] = 0x80 >> x;
PlayerMaskTable[0][enable][mode][x % 160] = 0x80 >> (x - 32); else if(((x - 32) >= 0) && ((x - 32) < 8))
} PxMask[0][enable][mode][x % 160] = 0x80 >> (x - 32);
else if(mode == 0x03) break;
{
if((enable == 0) && (x >= 0) && (x < 8)) case 0x03:
PlayerMaskTable[0][enable][mode][x % 160] = 0x80 >> x; if((enable == 0) && (x >= 0) && (x < 8))
else if(((x - 16) >= 0) && ((x - 16) < 8)) PxMask[0][enable][mode][x % 160] = 0x80 >> x;
PlayerMaskTable[0][enable][mode][x % 160] = 0x80 >> (x - 16); else if(((x - 16) >= 0) && ((x - 16) < 8))
else if(((x - 32) >= 0) && ((x - 32) < 8)) PxMask[0][enable][mode][x % 160] = 0x80 >> (x - 16);
PlayerMaskTable[0][enable][mode][x % 160] = 0x80 >> (x - 32); else if(((x - 32) >= 0) && ((x - 32) < 8))
} PxMask[0][enable][mode][x % 160] = 0x80 >> (x - 32);
else if(mode == 0x04) break;
{
if((enable == 0) && (x >= 0) && (x < 8)) case 0x04:
PlayerMaskTable[0][enable][mode][x % 160] = 0x80 >> x; if((enable == 0) && (x >= 0) && (x < 8))
else if(((x - 64) >= 0) && ((x - 64) < 8)) PxMask[0][enable][mode][x % 160] = 0x80 >> x;
PlayerMaskTable[0][enable][mode][x % 160] = 0x80 >> (x - 64); else if(((x - 64) >= 0) && ((x - 64) < 8))
} PxMask[0][enable][mode][x % 160] = 0x80 >> (x - 64);
else if(mode == 0x05) break;
{
// For some reason in double size mode the player's output case 0x05:
// is delayed by one pixel thus we use > instead of >= // For some reason in double size mode the player's output
if((enable == 0) && (x > 0) && (x <= 16)) // is delayed by one pixel thus we use > instead of >=
PlayerMaskTable[0][enable][mode][x % 160] = 0x80 >> ((x - 1)/2); if((enable == 0) && (x > 0) && (x <= 16))
} PxMask[0][enable][mode][x % 160] = 0x80 >> ((x - 1)/2);
else if(mode == 0x06) break;
{
if((enable == 0) && (x >= 0) && (x < 8)) case 0x06:
PlayerMaskTable[0][enable][mode][x % 160] = 0x80 >> x; if((enable == 0) && (x >= 0) && (x < 8))
else if(((x - 32) >= 0) && ((x - 32) < 8)) PxMask[0][enable][mode][x % 160] = 0x80 >> x;
PlayerMaskTable[0][enable][mode][x % 160] = 0x80 >> (x - 32); else if(((x - 32) >= 0) && ((x - 32) < 8))
else if(((x - 64) >= 0) && ((x - 64) < 8)) PxMask[0][enable][mode][x % 160] = 0x80 >> (x - 32);
PlayerMaskTable[0][enable][mode][x % 160] = 0x80 >> (x - 64); else if(((x - 64) >= 0) && ((x - 64) < 8))
} PxMask[0][enable][mode][x % 160] = 0x80 >> (x - 64);
else if(mode == 0x07) break;
{
// For some reason in quad size mode the player's output case 0x07:
// is delayed by one pixel thus we use > instead of >= // For some reason in quad size mode the player's output
if((enable == 0) && (x > 0) && (x <= 32)) // is delayed by one pixel thus we use > instead of >=
PlayerMaskTable[0][enable][mode][x % 160] = 0x80 >> ((x - 1)/4); if((enable == 0) && (x > 0) && (x <= 32))
PxMask[0][enable][mode][x % 160] = 0x80 >> ((x - 1)/4);
break;
} }
} }
// Copy data into wrap-around area // Copy data into wrap-around area
for(x = 0; x < 160; ++x) for(x = 0; x < 160; ++x)
{ {
PlayerMaskTable[0][enable][mode][x + 160] = PxMask[0][enable][mode][x + 160] =
PlayerMaskTable[0][enable][mode][x]; PxMask[0][enable][mode][x];
} }
} }
} }
@ -324,8 +189,8 @@ void TIATables::computePlayerMaskTable()
{ {
for(x = 0; x < 320; ++x) for(x = 0; x < 320; ++x)
{ {
PlayerMaskTable[align][enable][mode][x] = PxMask[align][enable][mode][x] =
PlayerMaskTable[0][enable][mode][(x + 320 - align) % 320]; PxMask[0][enable][mode][(x + 320 - align) % 320];
} }
} }
} }
@ -333,7 +198,200 @@ void TIATables::computePlayerMaskTable()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIATables::computePlayerPositionResetWhenTable() void TIATables::buildMxMaskTable() // [4][8][4][320]
{
// First, calculate masks for alignment 0
Int32 x, size, number;
// Clear the missle table to start with
for(number = 0; number < 8; ++number)
for(size = 0; size < 4; ++size)
for(x = 0; x < 160; ++x)
MxMask[0][number][size][x] = false;
for(number = 0; number < 8; ++number)
{
for(size = 0; size < 4; ++size)
{
for(x = 0; x < 160 + 72; ++x)
{
// Only one copy of the missle
if((number == 0x00) || (number == 0x05) || (number == 0x07))
{
if((x >= 0) && (x < (1 << size)))
MxMask[0][number][size][x % 160] = true;
}
// Two copies - close
else if(number == 0x01)
{
if((x >= 0) && (x < (1 << size)))
MxMask[0][number][size][x % 160] = true;
else if(((x - 16) >= 0) && ((x - 16) < (1 << size)))
MxMask[0][number][size][x % 160] = true;
}
// Two copies - medium
else if(number == 0x02)
{
if((x >= 0) && (x < (1 << size)))
MxMask[0][number][size][x % 160] = true;
else if(((x - 32) >= 0) && ((x - 32) < (1 << size)))
MxMask[0][number][size][x % 160] = true;
}
// Three copies - close
else if(number == 0x03)
{
if((x >= 0) && (x < (1 << size)))
MxMask[0][number][size][x % 160] = true;
else if(((x - 16) >= 0) && ((x - 16) < (1 << size)))
MxMask[0][number][size][x % 160] = true;
else if(((x - 32) >= 0) && ((x - 32) < (1 << size)))
MxMask[0][number][size][x % 160] = true;
}
// Two copies - wide
else if(number == 0x04)
{
if((x >= 0) && (x < (1 << size)))
MxMask[0][number][size][x % 160] = true;
else if(((x - 64) >= 0) && ((x - 64) < (1 << size)))
MxMask[0][number][size][x % 160] = true;
}
// Three copies - medium
else if(number == 0x06)
{
if((x >= 0) && (x < (1 << size)))
MxMask[0][number][size][x % 160] = true;
else if(((x - 32) >= 0) && ((x - 32) < (1 << size)))
MxMask[0][number][size][x % 160] = true;
else if(((x - 64) >= 0) && ((x - 64) < (1 << size)))
MxMask[0][number][size][x % 160] = true;
}
}
// Copy data into wrap-around area
for(x = 0; x < 160; ++x)
MxMask[0][number][size][x + 160] =
MxMask[0][number][size][x];
}
}
// Now, copy data for alignments of 1, 2 and 3
for(uInt32 align = 1; align < 4; ++align)
{
for(number = 0; number < 8; ++number)
{
for(size = 0; size < 4; ++size)
{
for(x = 0; x < 320; ++x)
{
MxMask[align][number][size][x] =
MxMask[0][number][size][(x + 320 - align) % 320];
}
}
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIATables::buildBLMaskTable() // [4][4][320]
{
// First, calculate masks for alignment 0
for(Int32 size = 0; size < 4; ++size)
{
Int32 x;
// Set all of the masks to false to start with
for(x = 0; x < 160; ++x)
{
BLMask[0][size][x] = false;
}
// Set the necessary fields true
for(x = 0; x < 160 + 8; ++x)
{
if((x >= 0) && (x < (1 << size)))
{
BLMask[0][size][x % 160] = true;
}
}
// Copy fields into the wrap-around area of the mask
for(x = 0; x < 160; ++x)
{
BLMask[0][size][x + 160] = BLMask[0][size][x];
}
}
// Now, copy data for alignments of 1, 2 and 3
for(uInt32 align = 1; align < 4; ++align)
{
for(uInt32 size = 0; size < 4; ++size)
{
for(uInt32 x = 0; x < 320; ++x)
{
BLMask[align][size][x] = BLMask[0][size][(x + 320 - align) % 320];
}
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIATables::buildPFMaskTable() // [2][160]
{
Int32 x;
// Compute playfield mask table for non-reflected mode
for(x = 0; x < 160; ++x)
{
if(x < 16)
PFMask[0][x] = 0x00001 << (x / 4);
else if(x < 48)
PFMask[0][x] = 0x00800 >> ((x - 16) / 4);
else if(x < 80)
PFMask[0][x] = 0x01000 << ((x - 48) / 4);
else if(x < 96)
PFMask[0][x] = 0x00001 << ((x - 80) / 4);
else if(x < 128)
PFMask[0][x] = 0x00800 >> ((x - 96) / 4);
else if(x < 160)
PFMask[0][x] = 0x01000 << ((x - 128) / 4);
}
// Compute playfield mask table for reflected mode
for(x = 0; x < 160; ++x)
{
if(x < 16)
PFMask[1][x] = 0x00001 << (x / 4);
else if(x < 48)
PFMask[1][x] = 0x00800 >> ((x - 16) / 4);
else if(x < 80)
PFMask[1][x] = 0x01000 << ((x - 48) / 4);
else if(x < 112)
PFMask[1][x] = 0x80000 >> ((x - 80) / 4);
else if(x < 144)
PFMask[1][x] = 0x00010 << ((x - 112) / 4);
else if(x < 160)
PFMask[1][x] = 0x00008 >> ((x - 144) / 4);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIATables::buildGRPReflectTable()
{
for(uInt16 i = 0; i < 256; ++i)
{
uInt8 r = 0;
for(uInt16 t = 1; t <= 128; t *= 2)
{
r = (r << 1) | ((i & t) ? 0x01 : 0x00);
}
GRPReflect[i] = r;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIATables::buildPxPosResetWhenTable()
{ {
uInt32 mode, oldx, newx; uInt32 mode, oldx, newx;
@ -349,7 +407,7 @@ void TIATables::computePlayerPositionResetWhenTable()
// Set everything to 0 for non-delay/non-display section // Set everything to 0 for non-delay/non-display section
for(newx = 0; newx < 160; ++newx) for(newx = 0; newx < 160; ++newx)
{ {
PlayerPositionResetWhenTable[mode][oldx][newx] = 0; PxPosResetWhen[mode][oldx][newx] = 0;
} }
// Now, we'll set the entries for non-delay/non-display section // Now, we'll set the entries for non-delay/non-display section
@ -358,94 +416,94 @@ void TIATables::computePlayerPositionResetWhenTable()
if(mode == 0x00) if(mode == 0x00)
{ {
if((newx >= oldx) && (newx < (oldx + 4))) if((newx >= oldx) && (newx < (oldx + 4)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = -1; PxPosResetWhen[mode][oldx][newx % 160] = -1;
if((newx >= oldx + 4) && (newx < (oldx + 4 + 8))) if((newx >= oldx + 4) && (newx < (oldx + 4 + 8)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = 1; PxPosResetWhen[mode][oldx][newx % 160] = 1;
} }
else if(mode == 0x01) else if(mode == 0x01)
{ {
if((newx >= oldx) && (newx < (oldx + 4))) if((newx >= oldx) && (newx < (oldx + 4)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = -1; PxPosResetWhen[mode][oldx][newx % 160] = -1;
else if((newx >= (oldx + 16)) && (newx < (oldx + 16 + 4))) else if((newx >= (oldx + 16)) && (newx < (oldx + 16 + 4)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = -1; PxPosResetWhen[mode][oldx][newx % 160] = -1;
if((newx >= oldx + 4) && (newx < (oldx + 4 + 8))) if((newx >= oldx + 4) && (newx < (oldx + 4 + 8)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = 1; PxPosResetWhen[mode][oldx][newx % 160] = 1;
else if((newx >= oldx + 16 + 4) && (newx < (oldx + 16 + 4 + 8))) else if((newx >= oldx + 16 + 4) && (newx < (oldx + 16 + 4 + 8)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = 1; PxPosResetWhen[mode][oldx][newx % 160] = 1;
} }
else if(mode == 0x02) else if(mode == 0x02)
{ {
if((newx >= oldx) && (newx < (oldx + 4))) if((newx >= oldx) && (newx < (oldx + 4)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = -1; PxPosResetWhen[mode][oldx][newx % 160] = -1;
else if((newx >= (oldx + 32)) && (newx < (oldx + 32 + 4))) else if((newx >= (oldx + 32)) && (newx < (oldx + 32 + 4)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = -1; PxPosResetWhen[mode][oldx][newx % 160] = -1;
if((newx >= oldx + 4) && (newx < (oldx + 4 + 8))) if((newx >= oldx + 4) && (newx < (oldx + 4 + 8)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = 1; PxPosResetWhen[mode][oldx][newx % 160] = 1;
else if((newx >= oldx + 32 + 4) && (newx < (oldx + 32 + 4 + 8))) else if((newx >= oldx + 32 + 4) && (newx < (oldx + 32 + 4 + 8)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = 1; PxPosResetWhen[mode][oldx][newx % 160] = 1;
} }
else if(mode == 0x03) else if(mode == 0x03)
{ {
if((newx >= oldx) && (newx < (oldx + 4))) if((newx >= oldx) && (newx < (oldx + 4)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = -1; PxPosResetWhen[mode][oldx][newx % 160] = -1;
else if((newx >= (oldx + 16)) && (newx < (oldx + 16 + 4))) else if((newx >= (oldx + 16)) && (newx < (oldx + 16 + 4)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = -1; PxPosResetWhen[mode][oldx][newx % 160] = -1;
else if((newx >= (oldx + 32)) && (newx < (oldx + 32 + 4))) else if((newx >= (oldx + 32)) && (newx < (oldx + 32 + 4)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = -1; PxPosResetWhen[mode][oldx][newx % 160] = -1;
if((newx >= oldx + 4) && (newx < (oldx + 4 + 8))) if((newx >= oldx + 4) && (newx < (oldx + 4 + 8)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = 1; PxPosResetWhen[mode][oldx][newx % 160] = 1;
else if((newx >= oldx + 16 + 4) && (newx < (oldx + 16 + 4 + 8))) else if((newx >= oldx + 16 + 4) && (newx < (oldx + 16 + 4 + 8)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = 1; PxPosResetWhen[mode][oldx][newx % 160] = 1;
else if((newx >= oldx + 32 + 4) && (newx < (oldx + 32 + 4 + 8))) else if((newx >= oldx + 32 + 4) && (newx < (oldx + 32 + 4 + 8)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = 1; PxPosResetWhen[mode][oldx][newx % 160] = 1;
} }
else if(mode == 0x04) else if(mode == 0x04)
{ {
if((newx >= oldx) && (newx < (oldx + 4))) if((newx >= oldx) && (newx < (oldx + 4)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = -1; PxPosResetWhen[mode][oldx][newx % 160] = -1;
else if((newx >= (oldx + 64)) && (newx < (oldx + 64 + 4))) else if((newx >= (oldx + 64)) && (newx < (oldx + 64 + 4)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = -1; PxPosResetWhen[mode][oldx][newx % 160] = -1;
if((newx >= oldx + 4) && (newx < (oldx + 4 + 8))) if((newx >= oldx + 4) && (newx < (oldx + 4 + 8)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = 1; PxPosResetWhen[mode][oldx][newx % 160] = 1;
else if((newx >= oldx + 64 + 4) && (newx < (oldx + 64 + 4 + 8))) else if((newx >= oldx + 64 + 4) && (newx < (oldx + 64 + 4 + 8)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = 1; PxPosResetWhen[mode][oldx][newx % 160] = 1;
} }
else if(mode == 0x05) else if(mode == 0x05)
{ {
if((newx >= oldx) && (newx < (oldx + 4))) if((newx >= oldx) && (newx < (oldx + 4)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = -1; PxPosResetWhen[mode][oldx][newx % 160] = -1;
if((newx >= oldx + 4) && (newx < (oldx + 4 + 16))) if((newx >= oldx + 4) && (newx < (oldx + 4 + 16)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = 1; PxPosResetWhen[mode][oldx][newx % 160] = 1;
} }
else if(mode == 0x06) else if(mode == 0x06)
{ {
if((newx >= oldx) && (newx < (oldx + 4))) if((newx >= oldx) && (newx < (oldx + 4)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = -1; PxPosResetWhen[mode][oldx][newx % 160] = -1;
else if((newx >= (oldx + 32)) && (newx < (oldx + 32 + 4))) else if((newx >= (oldx + 32)) && (newx < (oldx + 32 + 4)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = -1; PxPosResetWhen[mode][oldx][newx % 160] = -1;
else if((newx >= (oldx + 64)) && (newx < (oldx + 64 + 4))) else if((newx >= (oldx + 64)) && (newx < (oldx + 64 + 4)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = -1; PxPosResetWhen[mode][oldx][newx % 160] = -1;
if((newx >= oldx + 4) && (newx < (oldx + 4 + 8))) if((newx >= oldx + 4) && (newx < (oldx + 4 + 8)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = 1; PxPosResetWhen[mode][oldx][newx % 160] = 1;
else if((newx >= oldx + 32 + 4) && (newx < (oldx + 32 + 4 + 8))) else if((newx >= oldx + 32 + 4) && (newx < (oldx + 32 + 4 + 8)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = 1; PxPosResetWhen[mode][oldx][newx % 160] = 1;
else if((newx >= oldx + 64 + 4) && (newx < (oldx + 64 + 4 + 8))) else if((newx >= oldx + 64 + 4) && (newx < (oldx + 64 + 4 + 8)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = 1; PxPosResetWhen[mode][oldx][newx % 160] = 1;
} }
else if(mode == 0x07) else if(mode == 0x07)
{ {
if((newx >= oldx) && (newx < (oldx + 4))) if((newx >= oldx) && (newx < (oldx + 4)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = -1; PxPosResetWhen[mode][oldx][newx % 160] = -1;
if((newx >= oldx + 4) && (newx < (oldx + 4 + 32))) if((newx >= oldx + 4) && (newx < (oldx + 4 + 32)))
PlayerPositionResetWhenTable[mode][oldx][newx % 160] = 1; PxPosResetWhen[mode][oldx][newx % 160] = 1;
} }
} }
@ -453,9 +511,9 @@ void TIATables::computePlayerPositionResetWhenTable()
uInt32 s1 = 0, s2 = 0; uInt32 s1 = 0, s2 = 0;
for(newx = 0; newx < 160; ++newx) for(newx = 0; newx < 160; ++newx)
{ {
if(PlayerPositionResetWhenTable[mode][oldx][newx] == -1) if(PxPosResetWhen[mode][oldx][newx] == -1)
++s1; ++s1;
if(PlayerPositionResetWhenTable[mode][oldx][newx] == 1) if(PxPosResetWhen[mode][oldx][newx] == 1)
++s2; ++s2;
} }
assert((s1 % 4 == 0) && (s2 % 8 == 0)); assert((s1 % 4 == 0) && (s2 % 8 == 0));
@ -464,72 +522,16 @@ void TIATables::computePlayerPositionResetWhenTable()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIATables::computePlayerReflectTable() uInt8 TIATables::BLMask[4][4][320];
{
for(uInt16 i = 0; i < 256; ++i)
{
uInt8 r = 0;
for(uInt16 t = 1; t <= 128; t *= 2)
{
r = (r << 1) | ((i & t) ? 0x01 : 0x00);
}
PlayerReflectTable[i] = r;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIATables::computePlayfieldMaskTable() uInt16 TIATables::CollisionMask[64];
{
Int32 x;
// Compute playfield mask table for non-reflected mode
for(x = 0; x < 160; ++x)
{
if(x < 16)
PlayfieldTable[0][x] = 0x00001 << (x / 4);
else if(x < 48)
PlayfieldTable[0][x] = 0x00800 >> ((x - 16) / 4);
else if(x < 80)
PlayfieldTable[0][x] = 0x01000 << ((x - 48) / 4);
else if(x < 96)
PlayfieldTable[0][x] = 0x00001 << ((x - 80) / 4);
else if(x < 128)
PlayfieldTable[0][x] = 0x00800 >> ((x - 96) / 4);
else if(x < 160)
PlayfieldTable[0][x] = 0x01000 << ((x - 128) / 4);
}
// Compute playfield mask table for reflected mode
for(x = 0; x < 160; ++x)
{
if(x < 16)
PlayfieldTable[1][x] = 0x00001 << (x / 4);
else if(x < 48)
PlayfieldTable[1][x] = 0x00800 >> ((x - 16) / 4);
else if(x < 80)
PlayfieldTable[1][x] = 0x01000 << ((x - 48) / 4);
else if(x < 112)
PlayfieldTable[1][x] = 0x80000 >> ((x - 80) / 4);
else if(x < 144)
PlayfieldTable[1][x] = 0x00010 << ((x - 112) / 4);
else if(x < 160)
PlayfieldTable[1][x] = 0x00008 >> ((x - 144) / 4);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 TIATables::BallMaskTable[4][4][320]; uInt8 TIATables::DisabledMask[640];
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 TIATables::CollisionTable[64]; const Int16 TIATables::PokeDelay[64] = {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 TIATables::DisabledMaskTable[640];
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Int16 TIATables::PokeDelayTable[64] = {
0, 1, 0, 0, 8, 8, 0, 0, 0, 0, 0, 1, 1, -1, -1, -1, 0, 1, 0, 0, 8, 8, 0, 0, 0, 0, 0, 1, 1, -1, -1, -1,
0, 0, 8, 8, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -537,7 +539,7 @@ const Int16 TIATables::PokeDelayTable[64] = {
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 TIATables::MissleMaskTable[4][8][4][320]; uInt8 TIATables::MxMask[4][8][4][320];
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const bool TIATables::HMOVEBlankEnableCycles[76] = { const bool TIATables::HMOVEBlankEnableCycles[76] = {
@ -552,7 +554,7 @@ const bool TIATables::HMOVEBlankEnableCycles[76] = {
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Int32 TIATables::CompleteMotionTable[76][16] = { const Int32 TIATables::CompleteMotion[76][16] = {
{ 0, -1, -2, -3, -4, -5, -6, -7, 8, 7, 6, 5, 4, 3, 2, 1}, // HBLANK { 0, -1, -2, -3, -4, -5, -6, -7, 8, 7, 6, 5, 4, 3, 2, 1}, // HBLANK
{ 0, -1, -2, -3, -4, -5, -6, -7, 8, 7, 6, 5, 4, 3, 2, 1}, // HBLANK { 0, -1, -2, -3, -4, -5, -6, -7, 8, 7, 6, 5, 4, 3, 2, 1}, // HBLANK
{ 0, -1, -2, -3, -4, -5, -6, -7, 8, 7, 6, 5, 4, 3, 2, 1}, // HBLANK { 0, -1, -2, -3, -4, -5, -6, -7, 8, 7, 6, 5, 4, 3, 2, 1}, // HBLANK
@ -632,13 +634,13 @@ const Int32 TIATables::CompleteMotionTable[76][16] = {
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 TIATables::PlayerMaskTable[4][2][8][320]; uInt8 TIATables::PxMask[4][2][8][320];
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Int8 TIATables::PlayerPositionResetWhenTable[8][160][160]; Int8 TIATables::PxPosResetWhen[8][160][160];
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 TIATables::PlayerReflectTable[256]; uInt8 TIATables::GRPReflect[256];
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 TIATables::PlayfieldTable[2][160]; uInt32 TIATables::PFMask[2][160];

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: TIATables.hxx,v 1.1 2009-01-19 16:52:32 stephena Exp $ // $Id: TIATables.hxx,v 1.2 2009-02-08 21:07:06 stephena Exp $
//============================================================================ //============================================================================
#ifndef TIA_TABLES_HXX #ifndef TIA_TABLES_HXX
@ -102,7 +102,7 @@ enum {
here. here.
@author Stephen Anthony @author Stephen Anthony
@version $Id: TIATables.hxx,v 1.1 2009-01-19 16:52:32 stephena Exp $ @version $Id: TIATables.hxx,v 1.2 2009-02-08 21:07:06 stephena Exp $
*/ */
class TIATables class TIATables
{ {
@ -112,61 +112,61 @@ class TIATables
*/ */
static void computeAllTables(); static void computeAllTables();
// Ball mask table (entries are true or false)
static uInt8 BallMaskTable[4][4][320];
// Used to set the collision register to the correct value // Used to set the collision register to the correct value
static uInt16 CollisionTable[64]; static uInt16 CollisionMask[64];
// A mask table which can be used when an object is disabled // A mask table which can be used when an object is disabled
static uInt8 DisabledMaskTable[640]; static uInt8 DisabledMask[640];
// Indicates the update delay associated with poking at a TIA address // Indicates the update delay associated with poking at a TIA address
static const Int16 PokeDelayTable[64]; static const Int16 PokeDelay[64];
// Missle mask table (entries are true or false)
static uInt8 MissleMaskTable[4][8][4][320];
// Used to convert value written in a motion register into // Used to convert value written in a motion register into
// its internal representation // its internal representation
static const Int32 CompleteMotionTable[76][16]; static const Int32 CompleteMotion[76][16];
// Indicates if HMOVE blanks should occur for the corresponding cycle // Indicates if HMOVE blanks should occur for the corresponding cycle
static const bool HMOVEBlankEnableCycles[76]; static const bool HMOVEBlankEnableCycles[76];
// Player mask table // Player mask table
static uInt8 PlayerMaskTable[4][2][8][320]; static uInt8 PxMask[4][2][8][320];
// Indicates if player is being reset during delay, display or other times // Missle mask table (entries are true or false)
static Int8 PlayerPositionResetWhenTable[8][160][160]; static uInt8 MxMask[4][8][4][320];
// Used to reflect a players graphics // Ball mask table (entries are true or false)
static uInt8 PlayerReflectTable[256]; static uInt8 BLMask[4][4][320];
// Playfield mask table for reflected and non-reflected playfields // Playfield mask table for reflected and non-reflected playfields
static uInt32 PlayfieldTable[2][160]; static uInt32 PFMask[2][160];
// Used to reflect a players graphics
static uInt8 GRPReflect[256];
// Indicates if player is being reset during delay, display or other times
static Int8 PxPosResetWhen[8][160][160];
private: private:
// Compute the ball mask table
static void computeBallMaskTable();
// Compute the collision decode table // Compute the collision decode table
static void computeCollisionTable(); static void buildCollisionMaskTable();
// Compute the missle mask table
static void computeMissleMaskTable();
// Compute the player mask table // Compute the player mask table
static void computePlayerMaskTable(); static void buildPxMaskTable();
// Compute the player position reset when table // Compute the missle mask table
static void computePlayerPositionResetWhenTable(); static void buildMxMaskTable();
// Compute the player reflect table // Compute the ball mask table
static void computePlayerReflectTable(); static void buildBLMaskTable();
// Compute playfield mask table // Compute playfield mask table
static void computePlayfieldMaskTable(); static void buildPFMaskTable();
// Compute the player reflect table
static void buildGRPReflectTable();
// Compute the player position reset when table
static void buildPxPosResetWhenTable();
}; };
#endif #endif