Added files via upload

correct star pattern
This commit is contained in:
alyosha-tas 2016-04-05 18:03:23 -04:00
parent 03b236b0cf
commit 8e852622a1
1 changed files with 284 additions and 278 deletions

View File

@ -409,167 +409,171 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// Assume we're on the left side of the screen for now // Assume we're on the left side of the screen for now
var rightSide = false; var rightSide = false;
// ---- Things that happen only in the drawing section ---- // ---- Things that happen only in the drawing section ----
// TODO: Remove this magic number (17). It depends on the HMOVE // TODO: Remove this magic number (17). It depends on the HMOVE
if ((_hsyncCnt / 4) >= (_hmove.LateHBlankReset ? 19 : 17)) if ((_hsyncCnt / 4) >= (_hmove.LateHBlankReset ? 19 : 17))
{ {
// TODO: Remove this magic number // TODO: Remove this magic number
if ((_hsyncCnt / 4) >= 37) if ((_hsyncCnt / 4) >= 37)
{ {
rightSide = true; rightSide = true;
} }
// The bit number of the PF data which we want // The bit number of the PF data which we want
int pfBit = ((_hsyncCnt / 4) - 17) % 20; int pfBit = ((_hsyncCnt / 4) - 17) % 20;
// Create the mask for the bit we want // Create the mask for the bit we want
// Note that bits are arranged 0 1 2 3 4 .. 19 // Note that bits are arranged 0 1 2 3 4 .. 19
int pfMask = 1 << (20 - 1 - pfBit); int pfMask = 1 << (20 - 1 - pfBit);
// Reverse the mask if on the right and playfield is reflected // Reverse the mask if on the right and playfield is reflected
if (rightSide && _playField.Reflect) if (rightSide && _playField.Reflect)
{ {
pfMask = ReverseBits(pfMask, 20); pfMask = ReverseBits(pfMask, 20);
} }
// Calculate collisions // Calculate collisions
byte collisions = 0x00; byte collisions = 0x00;
if ((_playField.Grp & pfMask) != 0) if ((_playField.Grp & pfMask) != 0)
{ {
collisions |= CXPF; collisions |= CXPF;
} }
// ---- Player 0 ---- // ---- Player 0 ----
collisions |= _player0.Tick() ? CXP0 : (byte)0x00; collisions |= _player0.Tick() ? CXP0 : (byte)0x00;
// ---- Missile 0 ---- // ---- Missile 0 ----
collisions |= _player0.Missile.Tick() ? CXM0 : (byte)0x00; collisions |= _player0.Missile.Tick() ? CXM0 : (byte)0x00;
// ---- Player 1 ---- // ---- Player 1 ----
collisions |= _player1.Tick() ? CXP1 : (byte)0x00; collisions |= _player1.Tick() ? CXP1 : (byte)0x00;
// ---- Missile 0 ---- // ---- Missile 0 ----
collisions |= _player1.Missile.Tick() ? CXM1 : (byte)0x00; collisions |= _player1.Missile.Tick() ? CXM1 : (byte)0x00;
// ---- Ball ---- // ---- Ball ----
collisions |= _ball.Tick() ? CXBL : (byte)0x00; collisions |= _ball.Tick() ? CXBL : (byte)0x00;
// Pick the pixel color from collisions // Pick the pixel color from collisions
int pixelColor = BackColor; int pixelColor = BackColor;
if (_core.Settings.ShowBG) if (_core.Settings.ShowBG)
{ {
pixelColor = _palette[_playField.BkColor]; pixelColor = _palette[_playField.BkColor];
} }
if ((collisions & CXPF) != 0 && _core.Settings.ShowPlayfield) if ((collisions & CXPF) != 0 && _core.Settings.ShowPlayfield)
{ {
if (_playField.Score) if (_playField.Score)
{ {
if (!rightSide) if (!rightSide)
{ {
pixelColor = _palette[_player0.Color]; pixelColor = _palette[_player0.Color];
} }
else else
{ {
pixelColor = _palette[_player1.Color]; pixelColor = _palette[_player1.Color];
} }
} }
else else
{ {
pixelColor = _palette[_playField.PfColor]; pixelColor = _palette[_playField.PfColor];
} }
} }
if ((collisions & CXBL) != 0) if ((collisions & CXBL) != 0)
{ {
_ball.Collisions |= collisions; _ball.Collisions |= collisions;
if (_core.Settings.ShowBall) if (_core.Settings.ShowBall)
{ {
pixelColor = _palette[_playField.PfColor]; pixelColor = _palette[_playField.PfColor];
} }
} }
if ((collisions & CXM1) != 0) if ((collisions & CXM1) != 0)
{ {
_player1.Missile.Collisions |= collisions; _player1.Missile.Collisions |= collisions;
if (_core.Settings.ShowMissle2) if (_core.Settings.ShowMissle2)
{ {
pixelColor = _palette[_player1.Color]; pixelColor = _palette[_player1.Color];
} }
} }
if ((collisions & CXP1) != 0) if ((collisions & CXP1) != 0)
{ {
_player1.Collisions |= collisions; _player1.Collisions |= collisions;
if (_core.Settings.ShowPlayer2) if (_core.Settings.ShowPlayer2)
{ {
pixelColor = _palette[_player1.Color]; pixelColor = _palette[_player1.Color];
} }
} }
if ((collisions & CXM0) != 0) if ((collisions & CXM0) != 0)
{ {
_player0.Missile.Collisions |= collisions; _player0.Missile.Collisions |= collisions;
if (_core.Settings.ShowMissle1) if (_core.Settings.ShowMissle1)
{ {
pixelColor = _palette[_player0.Color]; pixelColor = _palette[_player0.Color];
} }
} }
if ((collisions & CXP0) != 0) if ((collisions & CXP0) != 0)
{ {
_player0.Collisions |= collisions; _player0.Collisions |= collisions;
if (_core.Settings.ShowPlayer1) if (_core.Settings.ShowPlayer1)
{ {
pixelColor = _palette[_player0.Color]; pixelColor = _palette[_player0.Color];
} }
} }
if (_playField.Priority && (collisions & CXPF) != 0 && _core.Settings.ShowPlayfield) if (_playField.Priority && (collisions & CXPF) != 0 && _core.Settings.ShowPlayfield)
{ {
if (_playField.Score) if (_playField.Score)
{ {
pixelColor = !rightSide ? _palette[_player0.Color] : _palette[_player1.Color]; pixelColor = !rightSide ? _palette[_player0.Color] : _palette[_player1.Color];
} }
else else
{ {
pixelColor = _palette[_playField.PfColor]; pixelColor = _palette[_playField.PfColor];
} }
} }
// Handle vblank // Handle vblank
if (_vblankEnabled) if (_vblankEnabled)
{ {
pixelColor = BackColor; pixelColor = BackColor;
} }
// Add the pixel to the scanline // Add the pixel to the scanline
// TODO: Remove this magic number (68) // TODO: Remove this magic number (68)
int y = _CurrentScanLine; int y = _CurrentScanLine;
// y >= max screen height means lag frame or game crashed, but is a legal situation. // y >= max screen height means lag frame or game crashed, but is a legal situation.
// either way, there's nothing to display // either way, there's nothing to display
if (y < MaxScreenHeight) if (y < MaxScreenHeight)
{ {
int x = _hsyncCnt - 68; int x = _hsyncCnt - 68;
if (x < 0 || x > 159) // this can't happen, right? if (x < 0 || x > 159) // this can't happen, right?
throw new Exception(); // TODO throw new Exception(); // TODO
_scanlinebuffer[_CurrentScanLine * ScreenWidth + x] = pixelColor; _scanlinebuffer[_CurrentScanLine * ScreenWidth + x] = pixelColor;
} }
} }
else
{
// ---- Things that happen every time ----
// Handle HMOVE
if (_hmove.HMoveEnabled) // ---- Things that happen every time ----
{
// On the first time, set the latches and counters // Handle HMOVE
if (_hmove.HMoveJustStarted) if (_hmove.HMoveEnabled)
{ {
// On the first time, set the latches and counters
if (_hmove.HMoveJustStarted)
{
_hmove.Player0Latch = true; _hmove.Player0Latch = true;
_hmove.Player0Cnt = 0; _hmove.Player0Cnt = 0;
@ -597,180 +601,182 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_hmove.HMoveJustStarted = false; _hmove.HMoveJustStarted = false;
_hmove.LateHBlankReset = true; _hmove.LateHBlankReset = true;
_hmove.DecCntEnabled = false; _hmove.DecCntEnabled = false;
}
if (_hmove.DecCntEnabled) }
{
// clock
// Actually do stuff only evey 4 pulses
if (_hmove.HMoveCnt == 0)
{
// If the latch is still set
if (_hmove.Player0Latch)
{
// If the move counter still has a bit in common with the HM register
if (((15 - _hmove.Player0Cnt) ^ ((_player0.HM & 0x07) | ((~(_player0.HM & 0x08)) & 0x08))) != 0x0F)
{
// "Clock-Stuffing"
_player0.Tick();
// Increase by 1, max of 15 if (_hmove.DecCntEnabled)
{
test_count_p0++;
if (test_count_p0<16) // clock
// Actually do stuff only evey 4 pulses
if (_hmove.HMoveCnt == 0)
{
// If the latch is still set
if (_hmove.Player0Latch)
{
// If the move counter still has a bit in common with the HM register
if (((15 - _hmove.Player0Cnt) ^ ((_player0.HM & 0x07) | ((~(_player0.HM & 0x08)) & 0x08))) != 0x0F)
{ {
_hmove.Player0Cnt++; // "Clock-Stuffing"
} else _player0.Tick();
{
_hmove.Player0Cnt = 0;
}
//_hmove.Player0Cnt %= 16;
}
else
{
_hmove.Player0Latch = false;
}
}
if (_hmove.Missile0Latch) // Increase by 1, max of 15
{
if (_hmove.Missile0Cnt == 15)
{ }
// If the move counter still has a bit in common with the HM register test_count_p0++;
if (((15 - _hmove.Missile0Cnt) ^ ((_player0.Missile.Hm & 0x07) | ((~(_player0.Missile.Hm & 0x08)) & 0x08))) != 0x0F) if (test_count_p0 < 16)
{ {
// "Clock-Stuffing" _hmove.Player0Cnt++;
_player0.Missile.Tick(); }
else
{
_hmove.Player0Cnt = 0;
}
// Increase by 1, max of 15 //_hmove.Player0Cnt %= 16;
test_count_m0++;
if (test_count_m0 < 16)
{
_hmove.Missile0Cnt++;
} }
else else
{ {
_hmove.Missile0Cnt=0; _hmove.Player0Latch = false;
} }
//_hmove.Missile0Cnt %= 16; }
}
else
{
_hmove.Missile0Latch = false;
_hmove.Missile0Cnt = 0;
}
}
if (_hmove.Player1Latch) if (_hmove.Missile0Latch)
{ {
// If the move counter still has a bit in common with the HM register if (_hmove.Missile0Cnt == 15)
if (((15 - _hmove.Player1Cnt) ^ ((_player1.HM & 0x07) | ((~(_player1.HM & 0x08)) & 0x08))) != 0x0F) { }
{
// "Clock-Stuffing"
_player1.Tick();
// Increase by 1, max of 15 // If the move counter still has a bit in common with the HM register
test_count_p1++; if (((15 - _hmove.Missile0Cnt) ^ ((_player0.Missile.Hm & 0x07) | ((~(_player0.Missile.Hm & 0x08)) & 0x08))) != 0x0F)
if (test_count_p1 < 16)
{ {
_hmove.Player1Cnt++; // "Clock-Stuffing"
_player0.Missile.Tick();
// Increase by 1, max of 15
test_count_m0++;
if (test_count_m0 < 16)
{
_hmove.Missile0Cnt++;
}
else
{
_hmove.Missile0Cnt = 0;
}
//_hmove.Missile0Cnt %= 16;
} }
else else
{ {
_hmove.Player1Cnt = 0; _hmove.Missile0Latch = false;
_hmove.Missile0Cnt = 0;
} }
//_hmove.Player1Cnt %= 16; }
}
else
{
_hmove.Player1Latch = false;
}
}
if (_hmove.Missile1Latch) if (_hmove.Player1Latch)
{ {
// If the move counter still has a bit in common with the HM register // If the move counter still has a bit in common with the HM register
if (((15 - _hmove.Missile1Cnt) ^ ((_player1.Missile.Hm & 0x07) | ((~(_player1.Missile.Hm & 0x08)) & 0x08))) != 0x0F) if (((15 - _hmove.Player1Cnt) ^ ((_player1.HM & 0x07) | ((~(_player1.HM & 0x08)) & 0x08))) != 0x0F)
{
// "Clock-Stuffing"
_player1.Missile.Tick();
// Increase by 1, max of 15
test_count_m1++;
if (test_count_m1 < 16)
{ {
_hmove.Missile1Cnt++; // "Clock-Stuffing"
_player1.Tick();
// Increase by 1, max of 15
test_count_p1++;
if (test_count_p1 < 16)
{
_hmove.Player1Cnt++;
}
else
{
_hmove.Player1Cnt = 0;
}
//_hmove.Player1Cnt %= 16;
} }
else else
{ {
_hmove.Missile1Cnt = 0; _hmove.Player1Latch = false;
} }
// _hmove.Missile1Cnt %= 16; }
}
else
{
_hmove.Missile1Latch = false;
}
}
if (_hmove.BallLatch) if (_hmove.Missile1Latch)
{ {
// If the move counter still has a bit in common with the HM register // If the move counter still has a bit in common with the HM register
if (((15 - _hmove.BallCnt) ^ ((_ball.HM & 0x07) | ((~(_ball.HM & 0x08)) & 0x08))) != 0x0F) if (((15 - _hmove.Missile1Cnt) ^ ((_player1.Missile.Hm & 0x07) | ((~(_player1.Missile.Hm & 0x08)) & 0x08))) != 0x0F)
{
// "Clock-Stuffing"
_ball.Tick();
// Increase by 1, max of 15
test_count_b++;
if (test_count_b < 16)
{ {
_hmove.BallCnt++; // "Clock-Stuffing"
_player1.Missile.Tick();
// Increase by 1, max of 15
test_count_m1++;
if (test_count_m1 < 16)
{
_hmove.Missile1Cnt++;
}
else
{
_hmove.Missile1Cnt = 0;
}
// _hmove.Missile1Cnt %= 16;
} }
else else
{ {
_hmove.BallCnt = 0; _hmove.Missile1Latch = false;
} }
//_hmove.BallCnt %= 16; }
}
else
{
_hmove.BallLatch = false;
}
}
if (!_hmove.Player0Latch && !_hmove.Player1Latch && !_hmove.BallLatch && !_hmove.Missile0Latch && !_hmove.Missile1Latch) if (_hmove.BallLatch)
{ {
_hmove.HMoveEnabled = false; // If the move counter still has a bit in common with the HM register
_hmove.DecCntEnabled = false; if (((15 - _hmove.BallCnt) ^ ((_ball.HM & 0x07) | ((~(_ball.HM & 0x08)) & 0x08))) != 0x0F)
_hmove.HMoveDelayCnt = 0; {
} // "Clock-Stuffing"
} _ball.Tick();
_hmove.HMoveCnt++; // Increase by 1, max of 15
_hmove.HMoveCnt %= 4; test_count_b++;
} if (test_count_b < 16)
{
_hmove.BallCnt++;
}
else
{
_hmove.BallCnt = 0;
}
//_hmove.BallCnt %= 16;
}
else
{
_hmove.BallLatch = false;
}
}
if (_hmove.HMoveDelayCnt < 5) if (!_hmove.Player0Latch && !_hmove.Player1Latch && !_hmove.BallLatch && !_hmove.Missile0Latch && !_hmove.Missile1Latch)
{ {
_hmove.HMoveDelayCnt++; _hmove.HMoveEnabled = false;
} _hmove.DecCntEnabled = false;
_hmove.HMoveDelayCnt = 0;
}
}
if (_hmove.HMoveDelayCnt == 5) _hmove.HMoveCnt++;
{ _hmove.HMoveCnt %= 4;
_hmove.HMoveDelayCnt++; }
_hmove.HMoveCnt = 0;
_hmove.DecCntEnabled = true; if (_hmove.HMoveDelayCnt < 5)
} {
} _hmove.HMoveDelayCnt++;
}
if (_hmove.HMoveDelayCnt == 5)
{
_hmove.HMoveDelayCnt++;
_hmove.HMoveCnt = 0;
_hmove.DecCntEnabled = true;
}
}
}
// Increment the hsync counter // Increment the hsync counter
_hsyncCnt++; _hsyncCnt++;
@ -1032,7 +1038,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
else if (maskedAddr == 0x12) // RESM0 else if (maskedAddr == 0x12) // RESM0
{ {
_player0.Missile.HPosCnt = (byte)(_hsyncCnt < 68 ? 160 - 2 : 160 - 4); _player0.Missile.HPosCnt = (byte)(_hsyncCnt < 68 ? 160 - 2 : 160 - 4);
} }
else if (maskedAddr == 0x13) // RESM1 else if (maskedAddr == 0x13) // RESM1
{ {
_player1.Missile.HPosCnt = (byte)(_hsyncCnt < 68 ? 160 - 2 : 160 - 4); _player1.Missile.HPosCnt = (byte)(_hsyncCnt < 68 ? 160 - 2 : 160 - 4);