Improved the emulation of values read from the TIA based on the results

Eckhard Stolberg obtained from a real 2600 showing that the TIA always
defines bits 6 & 7 and lets bits 0 to 5 float.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@26 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
bwmott 2002-01-13 04:26:42 +00:00
parent efa1675e00
commit eb6636dfbe
1 changed files with 28 additions and 30 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: TIA.cxx,v 1.2 2001-12-30 18:38:54 bwmott Exp $
// $Id: TIA.cxx,v 1.3 2002-01-13 04:26:42 bwmott Exp $
//============================================================================
#include <assert.h>
@ -1560,53 +1560,51 @@ uInt8 TIA::peek(uInt16 addr)
// Update frame to current color clock before we look at anything!
updateFrame(mySystem->cycles() * 3);
uInt8 noise = mySystem->getDataBusState();
uInt8 noise1 = noise & 0x7F;
uInt8 noise2 = noise & 0x3F;
uInt8 noise = mySystem->getDataBusState() & 0x3F;
switch(addr & 0x000f)
{
case 0x00: // CXM0P
return ((myCollision & 0x0001) ? 0x80 : 0x00) |
((myCollision & 0x0002) ? 0x40 : 0x00) | noise2;
((myCollision & 0x0002) ? 0x40 : 0x00) | noise;
case 0x01: // CXM1P
return ((myCollision & 0x0004) ? 0x80 : 0x00) |
((myCollision & 0x0008) ? 0x40 : 0x00) | noise2;
((myCollision & 0x0008) ? 0x40 : 0x00) | noise;
case 0x02: // CXP0FB
return ((myCollision & 0x0010) ? 0x80 : 0x00) |
((myCollision & 0x0020) ? 0x40 : 0x00) | noise2;
((myCollision & 0x0020) ? 0x40 : 0x00) | noise;
case 0x03: // CXP1FB
return ((myCollision & 0x0040) ? 0x80 : 0x00) |
((myCollision & 0x0080) ? 0x40 : 0x00) | noise2;
((myCollision & 0x0080) ? 0x40 : 0x00) | noise;
case 0x04: // CXM0FB
return ((myCollision & 0x0100) ? 0x80 : 0x00) |
((myCollision & 0x0200) ? 0x40 : 0x00) | noise2;
((myCollision & 0x0200) ? 0x40 : 0x00) | noise;
case 0x05: // CXM1FB
return ((myCollision & 0x0400) ? 0x80 : 0x00) |
((myCollision & 0x0800) ? 0x40 : 0x00) | noise2;
((myCollision & 0x0800) ? 0x40 : 0x00) | noise;
case 0x06: // CXBLPF
return ((myCollision & 0x1000) ? 0x80 : 0x00) | noise1;
return ((myCollision & 0x1000) ? 0x80 : 0x00) | noise;
case 0x07: // CXPPMM
return ((myCollision & 0x2000) ? 0x80 : 0x00) |
((myCollision & 0x4000) ? 0x40 : 0x00) | noise2;
((myCollision & 0x4000) ? 0x40 : 0x00) | noise;
case 0x08: // INPT0
{
Int32 r = myConsole.controller(Controller::Left).read(Controller::Nine);
if(r == Controller::minimumResistance)
{
return 0x80 | noise1;
return 0x80 | noise;
}
else if((r == Controller::maximumResistance) || myDumpEnabled)
{
return noise1;
return noise;
}
else
{
@ -1614,11 +1612,11 @@ uInt8 TIA::peek(uInt16 addr)
uInt32 needed = (uInt32)(t * 1.19E6);
if(mySystem->cycles() > (myDumpDisabledCycle + needed))
{
return 0x80 | noise1;
return 0x80 | noise;
}
else
{
return noise1;
return noise;
}
}
}
@ -1628,11 +1626,11 @@ uInt8 TIA::peek(uInt16 addr)
Int32 r = myConsole.controller(Controller::Left).read(Controller::Five);
if(r == Controller::minimumResistance)
{
return 0x80 | noise1;
return 0x80 | noise;
}
else if((r == Controller::maximumResistance) || myDumpEnabled)
{
return noise1;
return noise;
}
else
{
@ -1640,11 +1638,11 @@ uInt8 TIA::peek(uInt16 addr)
uInt32 needed = (uInt32)(t * 1.19E6);
if(mySystem->cycles() > (myDumpDisabledCycle + needed))
{
return 0x80 | noise1;
return 0x80 | noise;
}
else
{
return noise1;
return noise;
}
}
}
@ -1654,11 +1652,11 @@ uInt8 TIA::peek(uInt16 addr)
Int32 r = myConsole.controller(Controller::Right).read(Controller::Nine);
if(r == Controller::minimumResistance)
{
return 0x80 | noise1;
return 0x80 | noise;
}
else if((r == Controller::maximumResistance) || myDumpEnabled)
{
return noise1;
return noise;
}
else
{
@ -1666,11 +1664,11 @@ uInt8 TIA::peek(uInt16 addr)
uInt32 needed = (uInt32)(t * 1.19E6);
if(mySystem->cycles() > (myDumpDisabledCycle + needed))
{
return 0x80 | noise1;
return 0x80 | noise;
}
else
{
return noise1;
return noise;
}
}
}
@ -1680,11 +1678,11 @@ uInt8 TIA::peek(uInt16 addr)
Int32 r = myConsole.controller(Controller::Right).read(Controller::Five);
if(r == Controller::minimumResistance)
{
return 0x80 | noise1;
return 0x80 | noise;
}
else if((r == Controller::maximumResistance) || myDumpEnabled)
{
return noise1;
return noise;
}
else
{
@ -1692,22 +1690,22 @@ uInt8 TIA::peek(uInt16 addr)
uInt32 needed = (uInt32)(t * 1.19E6);
if(mySystem->cycles() > (myDumpDisabledCycle + needed))
{
return 0x80 | noise1;
return 0x80 | noise;
}
else
{
return noise1;
return noise;
}
}
}
case 0x0C: // INPT4
return myConsole.controller(Controller::Left).read(Controller::Six) ?
(0x80 | noise1) : noise1;
(0x80 | noise) : noise;
case 0x0D: // INPT5
return myConsole.controller(Controller::Right).read(Controller::Six) ?
(0x80 | noise1) : noise1;
(0x80 | noise) : noise;
case 0x0e:
return noise;