Merge branch 'master' into c64-refactor

This commit is contained in:
SaxxonPike 2019-07-23 04:52:35 -05:00
commit 47880fabb7
17 changed files with 279 additions and 294 deletions

View File

@ -2700,3 +2700,4 @@ sha1:650DA2339D41D1D2F180A6CAFE8DC311AC588ACD Boulder Dash Intro Tune (2005) (E
sha1:F28E52921646A18467577370808454F494C15EFE 0840 EconoBanking A26 m=0840;NTSC=true sha1:F28E52921646A18467577370808454F494C15EFE 0840 EconoBanking A26 m=0840;NTSC=true
sha1:2A9647E27AB27E6CF82B3BF122EDF212FA34AE86 Halo2600 Final A26 m=m4K sha1:2A9647E27AB27E6CF82B3BF122EDF212FA34AE86 Halo2600 Final A26 m=m4K
sha1:341BB93E67C21063F3910845D1AF59FEA129FF21 Bang! A26 m=F4SC sha1:341BB93E67C21063F3910845D1AF59FEA129FF21 Bang! A26 m=F4SC
sha1:62E7A3CE40BE1C29870D892639FBD394977281F5 DHmoveValues(rev2) A26 m=F6SC

View File

@ -69,85 +69,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
throw new NotImplementedException(); throw new NotImplementedException();
} }
public long TotalExecutedCycles => Cpu.TotalExecutedCycles; public long TotalExecutedCycles => Cpu.TotalExecutedCycles;
private int JSRCount = 0;
private const byte JSR = 0x20;
private const byte RTS = 0x60;
// the opsize table is used to quickly grab the instruction sizes (in bytes)
private readonly byte[] opsize =
{
/*0x00*/ 1,2,0,0,0,2,2,0,1,2,1,0,0,3,3,0,
/*0x10*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,
/*0x20*/ 3,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0,
/*0x30*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,
/*0x40*/ 1,2,0,0,0,2,2,0,1,2,1,0,3,3,3,0,
/*0x50*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,
/*0x60*/ 1,2,0,0,0,2,2,0,1,2,1,0,3,3,3,0,
/*0x70*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,
/*0x80*/ 0,2,0,0,2,2,2,0,1,0,1,0,3,3,3,0,
/*0x90*/ 2,2,0,0,2,2,2,0,1,3,1,0,0,3,0,0,
/*0xA0*/ 2,2,2,0,2,2,2,0,1,2,1,0,3,3,3,0,
/*0xB0*/ 2,2,0,0,2,2,2,0,1,3,1,0,3,3,3,0,
/*0xC0*/ 2,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0,
/*0xD0*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,
/*0xE0*/ 2,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0,
/*0xF0*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0
};
/*the optype table is a quick way to grab the addressing mode for any 6502 opcode
//
// 0 = Implied\Accumulator\Immediate\Branch\NULL
// 1 = (Indirect,X)
// 2 = Zero Page
// 3 = Absolute
// 4 = (Indirect),Y
// 5 = Zero Page,X
// 6 = Absolute,Y
// 7 = Absolute,X
// 8 = Zero Page,Y
*/
private readonly byte[] optype =
{
/*0x00*/ 0,1,0,0,0,2,2,0,0,0,0,0,0,3,3,0,
/*0x10*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0,
/*0x20*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0,
/*0x30*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0,
/*0x40*/ 0,1,0,0,0,2,2,0,0,0,0,0,0,3,3,0,
/*0x50*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0,
/*0x60*/ 0,1,0,0,0,2,2,0,0,0,0,0,3,3,3,0,
/*0x70*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0,
/*0x80*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0,
/*0x90*/ 0,4,0,0,5,5,8,0,0,6,0,0,0,7,0,0,
/*0xA0*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0,
/*0xB0*/ 0,4,0,0,5,5,8,0,0,6,0,0,7,7,6,0,
/*0xC0*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0,
/*0xD0*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0,
/*0xE0*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0,
/*0xF0*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0
};
#region Currently Unused Debug hooks
private int CurrentScanLine
{
get { return _tia.LineCount; }
}
private bool IsVsync
{
get { return _tia.IsVSync; }
}
private bool IsVBlank
{
get { return _tia.IsVBlank; }
}
#endregion
} }
} }

View File

@ -1,4 +1,5 @@
using BizHawk.Common; using BizHawk.Common;
using System;
namespace BizHawk.Emulation.Cores.Atari.Atari2600 namespace BizHawk.Emulation.Cores.Atari.Atari2600
{ {
@ -75,6 +76,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
Timer.InterruptFlag = false; Timer.InterruptFlag = false;
} }
if (Timer.Overflowed)
{
Timer.Overflowed = false;
}
return Timer.Value; return Timer.Value;
} }
@ -105,6 +111,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// If bit 0x0010 is set, and bit 0x0004 is set, this is a timer write // If bit 0x0010 is set, and bit 0x0004 is set, this is a timer write
if ((addr & 0x0014) == 0x0014) if ((addr & 0x0014) == 0x0014)
{ {
Timer.Overflowed = false;
var registerAddr = (ushort)(addr & 0x0007); var registerAddr = (ushort)(addr & 0x0007);
// Bit 0x0080 contains interrupt enable/disable // Bit 0x0080 contains interrupt enable/disable
@ -117,7 +125,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// Write to Timer/1 // Write to Timer/1
Timer.PrescalerShift = 0; Timer.PrescalerShift = 0;
Timer.Value = value; Timer.Value = value;
Timer.PrescalerCount = 0; // 1 << Timer.PrescalerShift; Timer.PrescalerCount = 1;// << Timer.PrescalerShift;
Timer.InterruptFlag = false; Timer.InterruptFlag = false;
} }
else if (registerAddr == 0x05) else if (registerAddr == 0x05)
@ -125,7 +133,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// Write to Timer/8 // Write to Timer/8
Timer.PrescalerShift = 3; Timer.PrescalerShift = 3;
Timer.Value = value; Timer.Value = value;
Timer.PrescalerCount = 0; // 1 << Timer.PrescalerShift; Timer.PrescalerCount = 1;// << Timer.PrescalerShift;
Timer.InterruptFlag = false; Timer.InterruptFlag = false;
} }
else if (registerAddr == 0x06) else if (registerAddr == 0x06)
@ -133,7 +141,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// Write to Timer/64 // Write to Timer/64
Timer.PrescalerShift = 6; Timer.PrescalerShift = 6;
Timer.Value = value; Timer.Value = value;
Timer.PrescalerCount = 0; // 1 << Timer.PrescalerShift; Timer.PrescalerCount = 1;// << Timer.PrescalerShift;
Timer.InterruptFlag = false; Timer.InterruptFlag = false;
} }
else if (registerAddr == 0x07) else if (registerAddr == 0x07)
@ -141,7 +149,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
// Write to Timer/1024 // Write to Timer/1024
Timer.PrescalerShift = 10; Timer.PrescalerShift = 10;
Timer.Value = value; Timer.Value = value;
Timer.PrescalerCount = 0; // 1 << Timer.PrescalerShift; Timer.PrescalerCount = 1;// << Timer.PrescalerShift;
Timer.InterruptFlag = false; Timer.InterruptFlag = false;
} }
} }
@ -195,22 +203,25 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
public bool InterruptEnabled; public bool InterruptEnabled;
public bool InterruptFlag; public bool InterruptFlag;
public bool Overflowed;
public void Tick() public void Tick()
{ {
if (PrescalerCount == 0) PrescalerCount--;
if ((PrescalerCount == 0) || Overflowed)
{ {
Value--; Value--;
PrescalerCount = 1 << PrescalerShift;
if (Value == 0xFF)
{
Overflowed = true;
InterruptFlag = true;
} }
PrescalerCount--;
if (PrescalerCount == 0) if (PrescalerCount == 0)
{ {
if (Value == 0) PrescalerCount = 1 << PrescalerShift;
{
InterruptFlag = true;
PrescalerShift = 0;
} }
} }
} }
@ -222,6 +233,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
ser.Sync("value", ref Value); ser.Sync("value", ref Value);
ser.Sync("interruptEnabled", ref InterruptEnabled); ser.Sync("interruptEnabled", ref InterruptEnabled);
ser.Sync("interruptFlag", ref InterruptFlag); ser.Sync("interruptFlag", ref InterruptFlag);
ser.Sync("Overflowed", ref Overflowed);
} }
} }
} }

View File

@ -104,6 +104,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
private int _hmbDelay; private int _hmbDelay;
private byte _hmbVal; private byte _hmbVal;
private int _nusiz0Delay;
private byte _nusiz0Val;
private int _nusiz1Delay;
private byte _nusiz1Val;
private int _hmClrDelay; private int _hmClrDelay;
private int _prg0Delay; private int _prg0Delay;
@ -223,6 +228,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_hmbDelay = 0; _hmbDelay = 0;
_hmbVal = 0; _hmbVal = 0;
_nusiz0Delay = 0;
_nusiz0Val = 0;
_nusiz1Delay = 0;
_nusiz1Val = 0;
_prg0Delay = 0; _prg0Delay = 0;
_prg1Delay = 0; _prg1Delay = 0;
_prg0Val = 0; _prg0Val = 0;
@ -404,6 +414,32 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
} }
} }
if (_nusiz0Delay > 0)
{
_nusiz0Delay++;
if (_nusiz0Delay == 4)
{
_nusiz0Delay = 0;
_player0.Nusiz = (byte)(_nusiz0Val & 0x37);
_player0.Missile.Size = (byte)((_nusiz0Val & 0x30) >> 4);
_player0.Missile.Number = (byte)(_nusiz0Val & 0x07);
}
}
if (_nusiz1Delay > 0)
{
_nusiz1Delay++;
if (_nusiz1Delay == 4)
{
_nusiz1Delay = 0;
_player1.Nusiz = (byte)(_nusiz1Val & 0x37);
_player1.Missile.Size = (byte)((_nusiz1Val & 0x30) >> 4);
_player1.Missile.Number = (byte)(_nusiz1Val & 0x07);
}
}
// Reset the RDY flag when we reach hblank // Reset the RDY flag when we reach hblank
if (_hsyncCnt <= 0) if (_hsyncCnt <= 0)
{ {
@ -566,7 +602,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
} }
// if extended HBLank is active, the screen area still needs a color // if extended HBLank is active, the screen area still needs a color
if (_hsyncCnt >= 68 && _hsyncCnt < 76 && _hmove.LateHBlankReset) if (_hmove.LateHBlankReset && _hsyncCnt >= 68 && _hsyncCnt < 76)
{ {
int pixelColor = 0; int pixelColor = 0;
@ -1054,15 +1090,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
} }
else if (maskedAddr == 0x04) // NUSIZ0 else if (maskedAddr == 0x04) // NUSIZ0
{ {
_player0.Nusiz = (byte)(value & 0x37); _nusiz0Delay = 1;
_player0.Missile.Size = (byte)((value & 0x30) >> 4); _nusiz0Val = value;
_player0.Missile.Number = (byte)(value & 0x07);
} }
else if (maskedAddr == 0x05) // NUSIZ1 else if (maskedAddr == 0x05) // NUSIZ1
{ {
_player1.Nusiz = (byte)(value & 0x37); _nusiz1Delay = 1;
_player1.Missile.Size = (byte)((value & 0x30) >> 4); _nusiz1Val = value;
_player1.Missile.Number = (byte)(value & 0x07);
} }
else if (maskedAddr == 0x06) // COLUP0 else if (maskedAddr == 0x06) // COLUP0
{ {
@ -1120,8 +1154,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{ {
_pf0MaxDelay = 3; _pf0MaxDelay = 3;
} }
////_playField.Grp = (uint)((_playField.Grp & 0x0FFFF) + ((ReverseBits(value, 8) & 0x0F) << 16));
} }
else if (maskedAddr == 0x0E) // PF1 else if (maskedAddr == 0x0E) // PF1
{ {
@ -1147,7 +1179,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{ {
_pf1MaxDelay = 3; _pf1MaxDelay = 3;
} }
////_playField.Grp = (uint)((_playField.Grp & 0xF00FF) + (value << 8));
} }
else if (maskedAddr == 0x0F) // PF2 else if (maskedAddr == 0x0F) // PF2
{ {
@ -1173,15 +1204,17 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{ {
_pf2MaxDelay = 3; _pf2MaxDelay = 3;
} }
////_playField.Grp = (uint)((_playField.Grp & 0xFFF00) + ReverseBits(value, 8));
} }
else if (maskedAddr == 0x10) // RESP0 else if (maskedAddr == 0x10) // RESP0
{ {
// RESP delays draw signal clocking
_player0.Resp_check();
// Resp depends on HMOVE // Resp depends on HMOVE
if (!_hmove.LateHBlankReset) if (!_hmove.LateHBlankReset)
{ {
_player0.HPosCnt = (byte)(_hsyncCnt < 68 ? 160 - 2 : 160 - 4); _player0.HPosCnt = (byte)(_hsyncCnt < 68 ? 160 - 2 : 160 - 4);
if (_hsyncCnt == 67 || _hsyncCnt==0) if (_hsyncCnt == 67)
{ {
_player0.HPosCnt = 160 - 3; _player0.HPosCnt = 160 - 3;
} }
@ -1189,7 +1222,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
else else
{ {
_player0.HPosCnt = (byte)(_hsyncCnt < 76 ? 160 - 2 : 160 - 4); _player0.HPosCnt = (byte)(_hsyncCnt < 76 ? 160 - 2 : 160 - 4);
if (_hsyncCnt == 75 || _hsyncCnt == 0) if (_hsyncCnt == 75)
{ {
_player0.HPosCnt = 160 - 3; _player0.HPosCnt = 160 - 3;
} }
@ -1197,11 +1230,14 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
} }
else if (maskedAddr == 0x11) // RESP1 else if (maskedAddr == 0x11) // RESP1
{ {
// RESP delays draw signal clocking
_player1.Resp_check();
// RESP depends on HMOVE // RESP depends on HMOVE
if (!_hmove.LateHBlankReset) if (!_hmove.LateHBlankReset)
{ {
_player1.HPosCnt = (byte)(_hsyncCnt < 68 ? 160 - 2 : 160 - 4); _player1.HPosCnt = (byte)(_hsyncCnt < 68 ? 160 - 2 : 160 - 4);
if (_hsyncCnt == 67 || _hsyncCnt == 0) if (_hsyncCnt == 67)
{ {
_player1.HPosCnt = 160 - 3; _player1.HPosCnt = 160 - 3;
} }
@ -1209,7 +1245,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
else else
{ {
_player1.HPosCnt = (byte)(_hsyncCnt < 76 ? 160 - 2 : 160 - 4); _player1.HPosCnt = (byte)(_hsyncCnt < 76 ? 160 - 2 : 160 - 4);
if (_hsyncCnt == 75 || _hsyncCnt == 0) if (_hsyncCnt == 75)
{ {
_player1.HPosCnt = 160 - 3; _player1.HPosCnt = 160 - 3;
} }
@ -1217,10 +1253,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
} }
else if (maskedAddr == 0x12) // RESM0 else if (maskedAddr == 0x12) // RESM0
{ {
// RESP delays draw signal clocking
_player0.Missile.Resp_check();
if (!_hmove.LateHBlankReset) if (!_hmove.LateHBlankReset)
{ {
_player0.Missile.HPosCnt = (byte)(_hsyncCnt < 68 ? 160 - 2 : 160 - 4); _player0.Missile.HPosCnt = (byte)(_hsyncCnt < 68 ? 160 - 2 : 160 - 4);
if (_hsyncCnt == 67 || _hsyncCnt == 0) if (_hsyncCnt == 67)
{ {
_player0.Missile.HPosCnt = 160 - 3; _player0.Missile.HPosCnt = 160 - 3;
} }
@ -1228,7 +1267,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
else else
{ {
_player0.Missile.HPosCnt = (byte)(_hsyncCnt < 76 ? 160 - 2 : 160 - 4); _player0.Missile.HPosCnt = (byte)(_hsyncCnt < 76 ? 160 - 2 : 160 - 4);
if (_hsyncCnt == 75 || _hsyncCnt == 0) if (_hsyncCnt == 75)
{ {
_player0.Missile.HPosCnt = 160 - 3; _player0.Missile.HPosCnt = 160 - 3;
} }
@ -1236,10 +1275,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
} }
else if (maskedAddr == 0x13) // RESM1 else if (maskedAddr == 0x13) // RESM1
{ {
// RESP delays draw signal clocking
_player1.Missile.Resp_check();
if (!_hmove.LateHBlankReset) if (!_hmove.LateHBlankReset)
{ {
_player1.Missile.HPosCnt = (byte)(_hsyncCnt < 68 ? 160 - 2 : 160 - 4); _player1.Missile.HPosCnt = (byte)(_hsyncCnt < 68 ? 160 - 2 : 160 - 4);
if (_hsyncCnt == 67 || _hsyncCnt == 0) if (_hsyncCnt == 67)
{ {
_player1.Missile.HPosCnt = 160 - 3; _player1.Missile.HPosCnt = 160 - 3;
} }
@ -1247,7 +1289,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
else else
{ {
_player1.Missile.HPosCnt = (byte)(_hsyncCnt < 76 ? 160 - 2 : 160 - 4); _player1.Missile.HPosCnt = (byte)(_hsyncCnt < 76 ? 160 - 2 : 160 - 4);
if (_hsyncCnt == 75 || _hsyncCnt == 0) if (_hsyncCnt == 75)
{ {
_player1.Missile.HPosCnt = 160 - 3; _player1.Missile.HPosCnt = 160 - 3;
} }
@ -1258,7 +1300,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
if (!_hmove.LateHBlankReset) if (!_hmove.LateHBlankReset)
{ {
_ball.HPosCnt = (byte)(_hsyncCnt < 68 ? 160 - 2 : 160 - 4); _ball.HPosCnt = (byte)(_hsyncCnt < 68 ? 160 - 2 : 160 - 4);
if (_hsyncCnt == 67 || _hsyncCnt == 0) if (_hsyncCnt == 67)
{ {
_ball.HPosCnt = 160 - 3; _ball.HPosCnt = 160 - 3;
} }
@ -1266,7 +1308,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
else else
{ {
_ball.HPosCnt = (byte)(_hsyncCnt < 76 ? 160 - 2 : 160 - 4); _ball.HPosCnt = (byte)(_hsyncCnt < 76 ? 160 - 2 : 160 - 4);
if (_hsyncCnt == 75 || _hsyncCnt == 0) if (_hsyncCnt == 75)
{ {
_ball.HPosCnt = 160 - 3; _ball.HPosCnt = 160 - 3;
} }
@ -1375,8 +1417,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
else if (maskedAddr == 0x2B) // HMCLR else if (maskedAddr == 0x2B) // HMCLR
{ {
_hmClrDelay = 1; _hmClrDelay = 1;
} }
else if (maskedAddr == 0x2C) // CXCLR else if (maskedAddr == 0x2C) // CXCLR
{ {

View File

@ -20,6 +20,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
private bool _scanCntInit; private bool _scanCntInit;
private int _startSignal; private int _startSignal;
private int _signalReached; private int _signalReached;
public bool _draw_signaled;
public bool Tick() public bool Tick()
{ {
@ -38,53 +39,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
} }
} }
/*
// At hPosCnt == 0, start drawing the missile, if enabled
if (HPosCnt < (1 << Size))
{
if (Enabled && !ResetToPlayer)
{
// Draw the missile
result = true;
}
}
if ((Number & 0x07) == 0x01 || ((Number & 0x07) == 0x03))
{
if (HPosCnt >= 16 && HPosCnt <= (16 + (1 << Size) - 1))
{
if (Enabled && !ResetToPlayer)
{
// Draw the missile
result = true;
}
}
}
if ((Number & 0x07) == 0x02 || ((Number & 0x07) == 0x03) || ((Number & 0x07) == 0x06))
{
if (HPosCnt >= 32 && HPosCnt <= (32 + (1 << Size) - 1))
{
if (Enabled && !ResetToPlayer)
{
// Draw the missile
result = true;
}
}
}
if ((Number & 0x07) == 0x04 || (Number & 0x07) == 0x06)
{
if (HPosCnt >= 64 && HPosCnt <= (64 + (1 << Size) - 1))
{
if (Enabled && !ResetToPlayer)
{
// Draw the missile
result = true;
}
}
}*/
if (_startSignal == 160) if (_startSignal == 160)
{ {
_scanCnt = 0; _scanCnt = 0;
@ -97,6 +51,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_scanCnt = 0; _scanCnt = 0;
_startSignal++; _startSignal++;
_scanCntInit = true; _scanCntInit = true;
_draw_signaled = false;
} }
if (_startSignal == 32 && ((Number & 0x07) == 0x02 || ((Number & 0x07) == 0x03) || ((Number & 0x07) == 0x06))) if (_startSignal == 32 && ((Number & 0x07) == 0x02 || ((Number & 0x07) == 0x03) || ((Number & 0x07) == 0x06)))
@ -104,6 +59,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_scanCnt = 0; _scanCnt = 0;
_startSignal++; _startSignal++;
_scanCntInit = true; _scanCntInit = true;
_draw_signaled = false;
} }
if (_startSignal == 64 && ((Number & 0x07) == 0x04 || ((Number & 0x07) == 0x06))) if (_startSignal == 64 && ((Number & 0x07) == 0x04 || ((Number & 0x07) == 0x06)))
@ -111,6 +67,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_scanCnt = 0; _scanCnt = 0;
_startSignal++; _startSignal++;
_scanCntInit = true; _scanCntInit = true;
_draw_signaled = false;
} }
// Increment the counter // Increment the counter
@ -125,6 +82,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{ {
_startSignal = HPosCnt; _startSignal = HPosCnt;
_signalReached = HPosCnt + 5; _signalReached = HPosCnt + 5;
_draw_signaled = true;
} }
if (_startSignal < _signalReached) if (_startSignal < _signalReached)
@ -135,6 +93,31 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
return result; return result;
} }
public void Resp_check()
{
if (_draw_signaled)
{
if (_startSignal < 17)
{
_startSignal -= _startSignal - 12;
}
else if (_startSignal < 33)
{
_startSignal -= _startSignal - 28;
}
else if (_startSignal < 65)
{
_startSignal -= _startSignal - 60;
}
else if (_startSignal < 161)
{
_startSignal -= _startSignal - 156;
}
}
}
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
ser.BeginSection("Missile"); ser.BeginSection("Missile");
@ -150,6 +133,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
ser.Sync("draw_to", ref _drawTo); ser.Sync("draw_to", ref _drawTo);
ser.Sync("scanCnt", ref _scanCnt); ser.Sync("scanCnt", ref _scanCnt);
ser.Sync("scanCntInit", ref _scanCntInit); ser.Sync("scanCntInit", ref _scanCntInit);
ser.Sync("_draw_signaled", ref _draw_signaled);
ser.EndSection(); ser.EndSection();
} }
} }

View File

@ -1,5 +1,9 @@
using BizHawk.Common; using BizHawk.Common;
// TODO: Some of the values that are being latched (like Nusiz) are being latched based on the internal player ticks, not the external hsync ticks.
// This can be seen for example in the player32_hblank test ROM.
// Which values these are exactly needs to be more carefully studied.
namespace BizHawk.Emulation.Cores.Atari.Atari2600 namespace BizHawk.Emulation.Cores.Atari.Atari2600
{ {
public partial class TIA public partial class TIA
@ -21,8 +25,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
public byte Collisions; public byte Collisions;
// Resp commands do not trigger start signals for main copies. We need to model this // Resp commands do not trigger start signals for main copies. We need to model this
private int _startSignal; public int _startSignal;
private int _signalReached; private int _signalReached;
public bool _draw_signaled;
public bool Tick() public bool Tick()
{ {
@ -103,9 +108,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
} }
} }
} }
else else if (ScanCntInit)
{ {
ScanCntInit = false; ScanCntInit = false;
//ScanCnt++;
}
else
{
ScanCnt++; ScanCnt++;
} }
} }
@ -134,18 +143,21 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{ {
ScanCnt = 0; ScanCnt = 0;
_startSignal++; _startSignal++;
_draw_signaled = false;
} }
if (_startSignal == 32 && ((Nusiz & 0x07) == 0x02 || ((Nusiz & 0x07) == 0x03) || ((Nusiz & 0x07) == 0x06))) if (_startSignal == 32 && ((Nusiz & 0x07) == 0x02 || ((Nusiz & 0x07) == 0x03) || ((Nusiz & 0x07) == 0x06)))
{ {
ScanCnt = 0; ScanCnt = 0;
_startSignal++; _startSignal++;
_draw_signaled = false;
} }
if (_startSignal == 64 && ((Nusiz & 0x07) == 0x04 || ((Nusiz & 0x07) == 0x06))) if (_startSignal == 64 && ((Nusiz & 0x07) == 0x04 || ((Nusiz & 0x07) == 0x06)))
{ {
ScanCnt = 0; ScanCnt = 0;
_startSignal++; _startSignal++;
_draw_signaled = false;
} }
// Increment the counter // Increment the counter
@ -160,6 +172,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{ {
_startSignal = HPosCnt - 1; _startSignal = HPosCnt - 1;
_signalReached = HPosCnt + 5; _signalReached = HPosCnt + 5;
_draw_signaled = true;
} }
if (_startSignal < _signalReached) if (_startSignal < _signalReached)
@ -170,6 +183,32 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
return result; return result;
} }
public void Resp_check()
{
if (_draw_signaled)
{
if (_startSignal < 17)
{
_startSignal -= _startSignal - 12;
}
else if (_startSignal < 33)
{
_startSignal -= _startSignal - 28;
}
else if (_startSignal < 65)
{
_startSignal -= _startSignal - 60;
}
else if (_startSignal < 161)
{
_startSignal -= _startSignal - 156;
}
}
}
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
Missile.SyncState(ser); Missile.SyncState(ser);
@ -186,6 +225,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
ser.Sync("collisions", ref Collisions); ser.Sync("collisions", ref Collisions);
ser.Sync("start_signal", ref _startSignal); ser.Sync("start_signal", ref _startSignal);
ser.Sync("signal_reached", ref _signalReached); ser.Sync("signal_reached", ref _signalReached);
ser.Sync("_draw_signaled", ref _draw_signaled);
} }
} }
} }

View File

@ -51,6 +51,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
ser.Sync("hmb_delay", ref _hmbDelay); ser.Sync("hmb_delay", ref _hmbDelay);
ser.Sync("hmb_val", ref _hmbVal); ser.Sync("hmb_val", ref _hmbVal);
ser.Sync("_nusiz0Delay", ref _nusiz0Delay);
ser.Sync("_nusiz0Val", ref _nusiz0Val);
ser.Sync("_nusiz1Delay", ref _nusiz1Delay);
ser.Sync("_nusiz1Val", ref _nusiz1Val);
ser.Sync("_hmClrDelay", ref _hmClrDelay); ser.Sync("_hmClrDelay", ref _hmClrDelay);
ser.Sync("PRG0_delay", ref _prg0Delay); ser.Sync("PRG0_delay", ref _prg0Delay);

View File

@ -196,11 +196,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
if (sel1) if (sel1)
{ {
ppu.bright = (byte)((portA_ret & 0x7F) << 1); ppu.bright = (byte)((portA_ret & 0x7F) << 1);
ppu.bright_int_1 = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); ppu.bright_int_1 = (0xFF000000 | (uint)(ppu.bright << 16) | (uint)(ppu.bright << 8) | ppu.bright);
ppu.bright = (byte)(portA_ret & 0x7F); ppu.bright = (byte)(portA_ret & 0x7F);
ppu.bright_int_2 = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); ppu.bright_int_2 = (0xFF000000 | (uint)(ppu.bright << 16) | (uint)(ppu.bright << 8) | ppu.bright);
ppu.bright = (byte)(portA_ret & 0x3F); ppu.bright = (byte)(portA_ret & 0x3F);
ppu.bright_int_3 = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); ppu.bright_int_3 = (0xFF000000 | (uint)(ppu.bright << 16) | (uint)(ppu.bright << 8) | ppu.bright);
} }
else else
{ {
@ -273,11 +273,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
if (sel1) if (sel1)
{ {
ppu.bright = (byte)((portA_ret & 0x7F) << 1); ppu.bright = (byte)((portA_ret & 0x7F) << 1);
ppu.bright_int_1 = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); ppu.bright_int_1 = (0xFF000000 | (uint)(ppu.bright << 16) | (uint)(ppu.bright << 8) | ppu.bright);
ppu.bright = (byte)(portA_ret & 0x7F); ppu.bright = (byte)(portA_ret & 0x7F);
ppu.bright_int_2 = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); ppu.bright_int_2 = (0xFF000000 | (uint)(ppu.bright << 16) | (uint)(ppu.bright << 8) | ppu.bright);
ppu.bright = (byte)(portA_ret & 0x3F); ppu.bright = (byte)(portA_ret & 0x3F);
ppu.bright_int_3 = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); ppu.bright_int_3 = (0xFF000000 | (uint)(ppu.bright << 16) | (uint)(ppu.bright << 8) | ppu.bright);
} }
else else
{ {

View File

@ -1,6 +1,5 @@
using System; using System;
using BizHawk.Emulation.Common;
using BizHawk.Common.NumberExtensions;
using BizHawk.Common; using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Consoles.Vectrex namespace BizHawk.Emulation.Cores.Consoles.Vectrex

View File

@ -1,6 +1,5 @@
using System; using System;
using System.IO; using System.IO;
using System.Collections.Generic;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;

View File

@ -1,5 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;

View File

@ -1,10 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy; using BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Nintendo.Gameboy namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
{ {

View File

@ -1,10 +1,6 @@
using BizHawk.Common; using BizHawk.Common;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy
{ {

View File

@ -1,11 +1,8 @@
using BizHawk.Common.BizInvoke; using BizHawk.Common.BizInvoke;
using BizHawk.Emulation.Cores.Waterbox; using BizHawk.Emulation.Cores.Waterbox;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy
{ {

View File

@ -3,12 +3,10 @@ using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Properties; using BizHawk.Emulation.Cores.Properties;
using BizHawk.Emulation.Cores.Waterbox; using BizHawk.Emulation.Cores.Waterbox;
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy
{ {

View File

@ -1,11 +1,8 @@
using System; using System;
using BizHawk.Common.BufferExtensions;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Components.Z80A;
using BizHawk.Emulation.Cores.Sega.MasterSystem; using BizHawk.Emulation.Cores.Sega.MasterSystem;
using System.Runtime.InteropServices;
namespace BizHawk.Emulation.Cores.Sega.GGHawkLink namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
{ {