Fixed bug in handling illegal TIA reads; the value returned should always

'clipped' to the unused TIA bits.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2099 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2010-08-16 19:49:32 +00:00
parent d007c3502f
commit 0a7726cb9f
2 changed files with 23 additions and 23 deletions

View File

@ -47,6 +47,9 @@
extra storage. Special thanks to Omegamatrix of AtariAge for advice extra storage. Special thanks to Omegamatrix of AtariAge for advice
and test ROMs in this area. and test ROMs in this area.
* Fixed bug when reading from illegal TIA addresses; a Space Invaders
hack was showing pink enemies instead of white ones.
* Fixed bug in handling INPT4/INPT5 latches from VBLANK; a least one * Fixed bug in handling INPT4/INPT5 latches from VBLANK; a least one
ROM was working in Stella when it didn't on real hardware. ROM was working in Stella when it didn't on real hardware.

View File

@ -1169,46 +1169,42 @@ uInt8 TIA::peek(uInt16 addr)
// If pins are undriven, we start with the last databus value // If pins are undriven, we start with the last databus value
// Otherwise, there is some randomness injected into the mix // Otherwise, there is some randomness injected into the mix
uInt8 value = myTIAPinsDriven ? mySystem->getDataBusState(0xFF) : // In either case, we start out with D7 and D6 disabled (the only
mySystem->getDataBusState(); // valid bits in a TIA read), and selectively enable them
uInt8 value = 0x3F & (!myTIAPinsDriven ? mySystem->getDataBusState() :
mySystem->getDataBusState(0xFF));
uInt16 collision = myCollision & (uInt16)myCollisionEnabledMask; uInt16 collision = myCollision & (uInt16)myCollisionEnabledMask;
switch(addr & 0x000f) switch(addr & 0x000f)
{ {
case CXM0P: case CXM0P:
value = (value & 0x3F) | value |= ((collision & Cx_M0P1) ? 0x80 : 0x00) |
((collision & Cx_M0P1) ? 0x80 : 0x00) | ((collision & Cx_M0P0) ? 0x40 : 0x00);
((collision & Cx_M0P0) ? 0x40 : 0x00);
break; break;
case CXM1P: case CXM1P:
value = (value & 0x3F) | value |= ((collision & Cx_M1P0) ? 0x80 : 0x00) |
((collision & Cx_M1P0) ? 0x80 : 0x00) | ((collision & Cx_M1P1) ? 0x40 : 0x00);
((collision & Cx_M1P1) ? 0x40 : 0x00);
break; break;
case CXP0FB: case CXP0FB:
value = (value & 0x3F) | value |= ((collision & Cx_P0PF) ? 0x80 : 0x00) |
((collision & Cx_P0PF) ? 0x80 : 0x00) | ((collision & Cx_P0BL) ? 0x40 : 0x00);
((collision & Cx_P0BL) ? 0x40 : 0x00);
break; break;
case CXP1FB: case CXP1FB:
value = (value & 0x3F) | value |= ((collision & Cx_P1PF) ? 0x80 : 0x00) |
((collision & Cx_P1PF) ? 0x80 : 0x00) | ((collision & Cx_P1BL) ? 0x40 : 0x00);
((collision & Cx_P1BL) ? 0x40 : 0x00);
break; break;
case CXM0FB: case CXM0FB:
value = (value & 0x3F) | value |= ((collision & Cx_M0PF) ? 0x80 : 0x00) |
((collision & Cx_M0PF) ? 0x80 : 0x00) | ((collision & Cx_M0BL) ? 0x40 : 0x00);
((collision & Cx_M0BL) ? 0x40 : 0x00);
break; break;
case CXM1FB: case CXM1FB:
value = (value & 0x3F) | value |= ((collision & Cx_M1PF) ? 0x80 : 0x00) |
((collision & Cx_M1PF) ? 0x80 : 0x00) | ((collision & Cx_M1BL) ? 0x40 : 0x00);
((collision & Cx_M1BL) ? 0x40 : 0x00);
break; break;
case CXBLPF: case CXBLPF:
@ -1216,9 +1212,8 @@ uInt8 TIA::peek(uInt16 addr)
break; break;
case CXPPMM: case CXPPMM:
value = (value & 0x3F) | value |= ((collision & Cx_P0P1) ? 0x80 : 0x00) |
((collision & Cx_P0P1) ? 0x80 : 0x00) | ((collision & Cx_M0M1) ? 0x40 : 0x00);
((collision & Cx_M0M1) ? 0x40 : 0x00);
break; break;
case INPT0: case INPT0:
@ -1260,6 +1255,8 @@ uInt8 TIA::peek(uInt16 addr)
} }
default: default:
// This shouldn't happen, but if it does, we essentially just
// return the last databus value with bits D6 and D7 zeroed out
break; break;
} }
return value; return value;