diff --git a/Assets/gamedb/gamedb_a2600.txt b/Assets/gamedb/gamedb_a2600.txt index cac5fb3048..95587d31ee 100644 --- a/Assets/gamedb/gamedb_a2600.txt +++ b/Assets/gamedb/gamedb_a2600.txt @@ -2699,4 +2699,5 @@ sha1:00CCF622E7BA4D0A39DCBABAB771CE815B0FB8FE Boulder Dash (2005) (Andrew Davie sha1:650DA2339D41D1D2F180A6CAFE8DC311AC588ACD Boulder Dash Intro Tune (2005) (Erik Ehrling) A26 m=4K;NTSC=true sha1:F28E52921646A18467577370808454F494C15EFE 0840 EconoBanking A26 m=0840;NTSC=true sha1:2A9647E27AB27E6CF82B3BF122EDF212FA34AE86 Halo2600 Final A26 m=m4K -sha1:341BB93E67C21063F3910845D1AF59FEA129FF21 Bang! A26 m=F4SC \ No newline at end of file +sha1:341BB93E67C21063F3910845D1AF59FEA129FF21 Bang! A26 m=F4SC +sha1:62E7A3CE40BE1C29870D892639FBD394977281F5 DHmoveValues(rev2) A26 m=F6SC diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IDebuggable.cs index 1a5068cb10..a69b9be7ea 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IDebuggable.cs @@ -69,85 +69,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 throw new NotImplementedException(); } - 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 } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/M6532.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/M6532.cs index f4b2856b94..5c4486818f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/M6532.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/M6532.cs @@ -1,4 +1,5 @@ using BizHawk.Common; +using System; namespace BizHawk.Emulation.Cores.Atari.Atari2600 { @@ -75,6 +76,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 Timer.InterruptFlag = false; } + if (Timer.Overflowed) + { + Timer.Overflowed = false; + } + 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 ((addr & 0x0014) == 0x0014) { + Timer.Overflowed = false; + var registerAddr = (ushort)(addr & 0x0007); // Bit 0x0080 contains interrupt enable/disable @@ -117,7 +125,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 // Write to Timer/1 Timer.PrescalerShift = 0; Timer.Value = value; - Timer.PrescalerCount = 0; // 1 << Timer.PrescalerShift; + Timer.PrescalerCount = 1;// << Timer.PrescalerShift; Timer.InterruptFlag = false; } else if (registerAddr == 0x05) @@ -125,7 +133,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 // Write to Timer/8 Timer.PrescalerShift = 3; Timer.Value = value; - Timer.PrescalerCount = 0; // 1 << Timer.PrescalerShift; + Timer.PrescalerCount = 1;// << Timer.PrescalerShift; Timer.InterruptFlag = false; } else if (registerAddr == 0x06) @@ -133,7 +141,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 // Write to Timer/64 Timer.PrescalerShift = 6; Timer.Value = value; - Timer.PrescalerCount = 0; // 1 << Timer.PrescalerShift; + Timer.PrescalerCount = 1;// << Timer.PrescalerShift; Timer.InterruptFlag = false; } else if (registerAddr == 0x07) @@ -141,7 +149,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 // Write to Timer/1024 Timer.PrescalerShift = 10; Timer.Value = value; - Timer.PrescalerCount = 0; // 1 << Timer.PrescalerShift; + Timer.PrescalerCount = 1;// << Timer.PrescalerShift; Timer.InterruptFlag = false; } } @@ -195,22 +203,25 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public bool InterruptEnabled; public bool InterruptFlag; + public bool Overflowed; public void Tick() { - if (PrescalerCount == 0) + PrescalerCount--; + + if ((PrescalerCount == 0) || Overflowed) { Value--; - PrescalerCount = 1 << PrescalerShift; - } - PrescalerCount--; - if (PrescalerCount == 0) - { - if (Value == 0) + if (Value == 0xFF) { + Overflowed = true; InterruptFlag = true; - PrescalerShift = 0; + } + + if (PrescalerCount == 0) + { + PrescalerCount = 1 << PrescalerShift; } } } @@ -222,6 +233,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 ser.Sync("value", ref Value); ser.Sync("interruptEnabled", ref InterruptEnabled); ser.Sync("interruptFlag", ref InterruptFlag); + ser.Sync("Overflowed", ref Overflowed); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/TIA.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/TIA.cs index 225139911a..20af03a20e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/TIA.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/TIA.cs @@ -104,6 +104,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 private int _hmbDelay; private byte _hmbVal; + private int _nusiz0Delay; + private byte _nusiz0Val; + private int _nusiz1Delay; + private byte _nusiz1Val; + private int _hmClrDelay; private int _prg0Delay; @@ -223,6 +228,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 _hmbDelay = 0; _hmbVal = 0; + _nusiz0Delay = 0; + _nusiz0Val = 0; + _nusiz1Delay = 0; + _nusiz1Val = 0; + _prg0Delay = 0; _prg1Delay = 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 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 (_hsyncCnt >= 68 && _hsyncCnt < 76 && _hmove.LateHBlankReset) + if (_hmove.LateHBlankReset && _hsyncCnt >= 68 && _hsyncCnt < 76) { int pixelColor = 0; @@ -1054,15 +1090,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } else if (maskedAddr == 0x04) // NUSIZ0 { - _player0.Nusiz = (byte)(value & 0x37); - _player0.Missile.Size = (byte)((value & 0x30) >> 4); - _player0.Missile.Number = (byte)(value & 0x07); + _nusiz0Delay = 1; + _nusiz0Val = value; } else if (maskedAddr == 0x05) // NUSIZ1 { - _player1.Nusiz = (byte)(value & 0x37); - _player1.Missile.Size = (byte)((value & 0x30) >> 4); - _player1.Missile.Number = (byte)(value & 0x07); + _nusiz1Delay = 1; + _nusiz1Val = value; } else if (maskedAddr == 0x06) // COLUP0 { @@ -1120,8 +1154,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 { _pf0MaxDelay = 3; } - - ////_playField.Grp = (uint)((_playField.Grp & 0x0FFFF) + ((ReverseBits(value, 8) & 0x0F) << 16)); } else if (maskedAddr == 0x0E) // PF1 { @@ -1147,7 +1179,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 { _pf1MaxDelay = 3; } - ////_playField.Grp = (uint)((_playField.Grp & 0xF00FF) + (value << 8)); } else if (maskedAddr == 0x0F) // PF2 { @@ -1173,15 +1204,17 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 { _pf2MaxDelay = 3; } - ////_playField.Grp = (uint)((_playField.Grp & 0xFFF00) + ReverseBits(value, 8)); } else if (maskedAddr == 0x10) // RESP0 { + // RESP delays draw signal clocking + _player0.Resp_check(); + // Resp depends on HMOVE if (!_hmove.LateHBlankReset) { _player0.HPosCnt = (byte)(_hsyncCnt < 68 ? 160 - 2 : 160 - 4); - if (_hsyncCnt == 67 || _hsyncCnt==0) + if (_hsyncCnt == 67) { _player0.HPosCnt = 160 - 3; } @@ -1189,7 +1222,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 else { _player0.HPosCnt = (byte)(_hsyncCnt < 76 ? 160 - 2 : 160 - 4); - if (_hsyncCnt == 75 || _hsyncCnt == 0) + if (_hsyncCnt == 75) { _player0.HPosCnt = 160 - 3; } @@ -1197,11 +1230,14 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } else if (maskedAddr == 0x11) // RESP1 { + // RESP delays draw signal clocking + _player1.Resp_check(); + // RESP depends on HMOVE if (!_hmove.LateHBlankReset) { _player1.HPosCnt = (byte)(_hsyncCnt < 68 ? 160 - 2 : 160 - 4); - if (_hsyncCnt == 67 || _hsyncCnt == 0) + if (_hsyncCnt == 67) { _player1.HPosCnt = 160 - 3; } @@ -1209,7 +1245,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 else { _player1.HPosCnt = (byte)(_hsyncCnt < 76 ? 160 - 2 : 160 - 4); - if (_hsyncCnt == 75 || _hsyncCnt == 0) + if (_hsyncCnt == 75) { _player1.HPosCnt = 160 - 3; } @@ -1217,10 +1253,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } else if (maskedAddr == 0x12) // RESM0 { + // RESP delays draw signal clocking + _player0.Missile.Resp_check(); + if (!_hmove.LateHBlankReset) { _player0.Missile.HPosCnt = (byte)(_hsyncCnt < 68 ? 160 - 2 : 160 - 4); - if (_hsyncCnt == 67 || _hsyncCnt == 0) + if (_hsyncCnt == 67) { _player0.Missile.HPosCnt = 160 - 3; } @@ -1228,7 +1267,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 else { _player0.Missile.HPosCnt = (byte)(_hsyncCnt < 76 ? 160 - 2 : 160 - 4); - if (_hsyncCnt == 75 || _hsyncCnt == 0) + if (_hsyncCnt == 75) { _player0.Missile.HPosCnt = 160 - 3; } @@ -1236,10 +1275,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } else if (maskedAddr == 0x13) // RESM1 { + // RESP delays draw signal clocking + _player1.Missile.Resp_check(); + if (!_hmove.LateHBlankReset) { _player1.Missile.HPosCnt = (byte)(_hsyncCnt < 68 ? 160 - 2 : 160 - 4); - if (_hsyncCnt == 67 || _hsyncCnt == 0) + if (_hsyncCnt == 67) { _player1.Missile.HPosCnt = 160 - 3; } @@ -1247,7 +1289,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 else { _player1.Missile.HPosCnt = (byte)(_hsyncCnt < 76 ? 160 - 2 : 160 - 4); - if (_hsyncCnt == 75 || _hsyncCnt == 0) + if (_hsyncCnt == 75) { _player1.Missile.HPosCnt = 160 - 3; } @@ -1258,7 +1300,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 if (!_hmove.LateHBlankReset) { _ball.HPosCnt = (byte)(_hsyncCnt < 68 ? 160 - 2 : 160 - 4); - if (_hsyncCnt == 67 || _hsyncCnt == 0) + if (_hsyncCnt == 67) { _ball.HPosCnt = 160 - 3; } @@ -1266,7 +1308,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 else { _ball.HPosCnt = (byte)(_hsyncCnt < 76 ? 160 - 2 : 160 - 4); - if (_hsyncCnt == 75 || _hsyncCnt == 0) + if (_hsyncCnt == 75) { _ball.HPosCnt = 160 - 3; } @@ -1374,9 +1416,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } else if (maskedAddr == 0x2B) // HMCLR { - _hmClrDelay = 1; - - + _hmClrDelay = 1; } else if (maskedAddr == 0x2C) // CXCLR { diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.MissleData.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.MissleData.cs index b2feca019e..38c579712b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.MissleData.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.MissleData.cs @@ -20,6 +20,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 private bool _scanCntInit; private int _startSignal; private int _signalReached; + public bool _draw_signaled; 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) { _scanCnt = 0; @@ -97,6 +51,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 _scanCnt = 0; _startSignal++; _scanCntInit = true; + _draw_signaled = false; } if (_startSignal == 32 && ((Number & 0x07) == 0x02 || ((Number & 0x07) == 0x03) || ((Number & 0x07) == 0x06))) @@ -104,6 +59,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 _scanCnt = 0; _startSignal++; _scanCntInit = true; + _draw_signaled = false; } if (_startSignal == 64 && ((Number & 0x07) == 0x04 || ((Number & 0x07) == 0x06))) @@ -111,6 +67,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 _scanCnt = 0; _startSignal++; _scanCntInit = true; + _draw_signaled = false; } // Increment the counter @@ -125,6 +82,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 { _startSignal = HPosCnt; _signalReached = HPosCnt + 5; + _draw_signaled = true; } if (_startSignal < _signalReached) @@ -135,6 +93,31 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 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) { ser.BeginSection("Missile"); @@ -150,6 +133,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 ser.Sync("draw_to", ref _drawTo); ser.Sync("scanCnt", ref _scanCnt); ser.Sync("scanCntInit", ref _scanCntInit); + ser.Sync("_draw_signaled", ref _draw_signaled); ser.EndSection(); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.PlayerData.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.PlayerData.cs index d57bc7d735..3d33f1426e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.PlayerData.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.PlayerData.cs @@ -1,5 +1,9 @@ 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 { public partial class TIA @@ -21,8 +25,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public byte Collisions; // Resp commands do not trigger start signals for main copies. We need to model this - private int _startSignal; + public int _startSignal; private int _signalReached; + public bool _draw_signaled; public bool Tick() { @@ -103,9 +108,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } } } - else + else if (ScanCntInit) { ScanCntInit = false; + //ScanCnt++; + } + else + { ScanCnt++; } } @@ -134,18 +143,21 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 { ScanCnt = 0; _startSignal++; + _draw_signaled = false; } if (_startSignal == 32 && ((Nusiz & 0x07) == 0x02 || ((Nusiz & 0x07) == 0x03) || ((Nusiz & 0x07) == 0x06))) { ScanCnt = 0; _startSignal++; + _draw_signaled = false; } if (_startSignal == 64 && ((Nusiz & 0x07) == 0x04 || ((Nusiz & 0x07) == 0x06))) { ScanCnt = 0; _startSignal++; + _draw_signaled = false; } // Increment the counter @@ -160,6 +172,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 { _startSignal = HPosCnt - 1; _signalReached = HPosCnt + 5; + _draw_signaled = true; } if (_startSignal < _signalReached) @@ -170,6 +183,32 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 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) { Missile.SyncState(ser); @@ -186,6 +225,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 ser.Sync("collisions", ref Collisions); ser.Sync("start_signal", ref _startSignal); ser.Sync("signal_reached", ref _signalReached); + ser.Sync("_draw_signaled", ref _draw_signaled); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.SyncState.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.SyncState.cs index 8881944917..deb62d3a7b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.SyncState.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.SyncState.cs @@ -51,6 +51,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 ser.Sync("hmb_delay", ref _hmbDelay); 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("PRG0_delay", ref _prg0Delay); diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/HW_Registers.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/HW_Registers.cs index 9c93cbb159..b938128f15 100644 --- a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/HW_Registers.cs +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/HW_Registers.cs @@ -196,11 +196,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex if (sel1) { 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_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_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 { @@ -273,11 +273,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex if (sel1) { 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_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_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 { diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/SerialPort.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/SerialPort.cs index 1212ce8a24..cb10b8e578 100644 --- a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/SerialPort.cs +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/SerialPort.cs @@ -1,6 +1,5 @@ using System; -using BizHawk.Emulation.Common; -using BizHawk.Common.NumberExtensions; + using BizHawk.Common; namespace BizHawk.Emulation.Cores.Consoles.Vectrex diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ICodeDataLog.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ICodeDataLog.cs index 99b478f570..0c4c2d0421 100644 --- a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ICodeDataLog.cs +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ICodeDataLog.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using System.Collections.Generic; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllers.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllers.cs index 155ac7c314..c7ccd88f0b 100644 --- a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllers.cs +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllers.cs @@ -1,5 +1,5 @@ using System; -using System.Collections.Generic; + using System.ComponentModel; using System.Linq; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs index 4192c9bece..a8f84d1131 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs @@ -1,101 +1,101 @@ -using System; - -using BizHawk.Emulation.Common; - -using BizHawk.Emulation.Cores.Nintendo.GBHawk; - -namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink -{ - [Core( - "GBHawkLink", - "", - isPorted: false, - isReleased: true)] - [ServiceNotApplicable(typeof(IDriveLight))] - public partial class GBHawkLink : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable, ILinkable, - ISettable - { - // we want to create two GBHawk instances that we will run concurrently - // maybe up to 4 eventually? - public GBHawk.GBHawk L; - public GBHawk.GBHawk R; - - // if true, the link cable is currently connected - private bool _cableconnected = true; - - // if true, the link cable toggle signal is currently asserted - private bool _cablediscosignal = false; - - private bool do_r_next = false; - - //[CoreConstructor("GB", "GBC")] - public GBHawkLink(CoreComm comm, GameInfo game_L, byte[] rom_L, GameInfo game_R, byte[] rom_R, /*string gameDbFn,*/ object settings, object syncSettings) - { - var ser = new BasicServiceProvider(this); - - linkSettings = (GBLinkSettings)settings ?? new GBLinkSettings(); - linkSyncSettings = (GBLinkSyncSettings)syncSettings ?? new GBLinkSyncSettings(); - _controllerDeck = new GBHawkLinkControllerDeck(GBHawkLinkControllerDeck.DefaultControllerName, GBHawkLinkControllerDeck.DefaultControllerName); - - CoreComm = comm; - - var temp_set_L = new GBHawk.GBHawk.GBSettings(); - var temp_set_R = new GBHawk.GBHawk.GBSettings(); - - var temp_sync_L = new GBHawk.GBHawk.GBSyncSettings(); - var temp_sync_R = new GBHawk.GBHawk.GBSyncSettings(); - - temp_sync_L.ConsoleMode = linkSyncSettings.ConsoleMode_L; - temp_sync_R.ConsoleMode = linkSyncSettings.ConsoleMode_R; - - temp_sync_L.DivInitialTime = linkSyncSettings.DivInitialTime_L; - temp_sync_R.DivInitialTime = linkSyncSettings.DivInitialTime_R; - temp_sync_L.RTCInitialTime = linkSyncSettings.RTCInitialTime_L; - temp_sync_R.RTCInitialTime = linkSyncSettings.RTCInitialTime_R; - - L = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider }, - game_L, rom_L, temp_set_L, temp_sync_L); - - R = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider }, - game_R, rom_R, temp_set_R, temp_sync_R); - - ser.Register(this); - ser.Register(this); - - _tracer = new TraceBuffer { Header = L.cpu.TraceHeader }; - ser.Register(_tracer); - - ServiceProvider = ser; - - SetupMemoryDomains(); - - HardReset(); - } - - public void HardReset() - { - L.HardReset(); - R.HardReset(); - } - - public DisplayType Region => DisplayType.NTSC; - - public int _frame = 0; - - private readonly GBHawkLinkControllerDeck _controllerDeck; - - private readonly ITraceable _tracer; - - public bool LinkConnected - { - get { return _cableconnected; } - set { _cableconnected = value; } - } - - private void ExecFetch(ushort addr) +using System; + +using BizHawk.Emulation.Common; + +using BizHawk.Emulation.Cores.Nintendo.GBHawk; + +namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink +{ + [Core( + "GBHawkLink", + "", + isPorted: false, + isReleased: true)] + [ServiceNotApplicable(typeof(IDriveLight))] + public partial class GBHawkLink : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable, ILinkable, + ISettable + { + // we want to create two GBHawk instances that we will run concurrently + // maybe up to 4 eventually? + public GBHawk.GBHawk L; + public GBHawk.GBHawk R; + + // if true, the link cable is currently connected + private bool _cableconnected = true; + + // if true, the link cable toggle signal is currently asserted + private bool _cablediscosignal = false; + + private bool do_r_next = false; + + //[CoreConstructor("GB", "GBC")] + public GBHawkLink(CoreComm comm, GameInfo game_L, byte[] rom_L, GameInfo game_R, byte[] rom_R, /*string gameDbFn,*/ object settings, object syncSettings) { - uint flags = (uint)(MemoryCallbackFlags.AccessExecute); - MemoryCallbacks.CallMemoryCallbacks(addr, 0, flags, "System Bus"); - } - } -} + var ser = new BasicServiceProvider(this); + + linkSettings = (GBLinkSettings)settings ?? new GBLinkSettings(); + linkSyncSettings = (GBLinkSyncSettings)syncSettings ?? new GBLinkSyncSettings(); + _controllerDeck = new GBHawkLinkControllerDeck(GBHawkLinkControllerDeck.DefaultControllerName, GBHawkLinkControllerDeck.DefaultControllerName); + + CoreComm = comm; + + var temp_set_L = new GBHawk.GBHawk.GBSettings(); + var temp_set_R = new GBHawk.GBHawk.GBSettings(); + + var temp_sync_L = new GBHawk.GBHawk.GBSyncSettings(); + var temp_sync_R = new GBHawk.GBHawk.GBSyncSettings(); + + temp_sync_L.ConsoleMode = linkSyncSettings.ConsoleMode_L; + temp_sync_R.ConsoleMode = linkSyncSettings.ConsoleMode_R; + + temp_sync_L.DivInitialTime = linkSyncSettings.DivInitialTime_L; + temp_sync_R.DivInitialTime = linkSyncSettings.DivInitialTime_R; + temp_sync_L.RTCInitialTime = linkSyncSettings.RTCInitialTime_L; + temp_sync_R.RTCInitialTime = linkSyncSettings.RTCInitialTime_R; + + L = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider }, + game_L, rom_L, temp_set_L, temp_sync_L); + + R = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider }, + game_R, rom_R, temp_set_R, temp_sync_R); + + ser.Register(this); + ser.Register(this); + + _tracer = new TraceBuffer { Header = L.cpu.TraceHeader }; + ser.Register(_tracer); + + ServiceProvider = ser; + + SetupMemoryDomains(); + + HardReset(); + } + + public void HardReset() + { + L.HardReset(); + R.HardReset(); + } + + public DisplayType Region => DisplayType.NTSC; + + public int _frame = 0; + + private readonly GBHawkLinkControllerDeck _controllerDeck; + + private readonly ITraceable _tracer; + + public bool LinkConnected + { + get { return _cableconnected; } + set { _cableconnected = value; } + } + + private void ExecFetch(ushort addr) + { + uint flags = (uint)(MemoryCallbackFlags.AccessExecute); + MemoryCallbacks.CallMemoryCallbacks(addr, 0, flags, "System Bus"); + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambattePrinter.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambattePrinter.cs index 2cc834e5ff..9654403751 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambattePrinter.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambattePrinter.cs @@ -1,10 +1,6 @@ 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.Common; namespace BizHawk.Emulation.Cores.Nintendo.Gameboy { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/IGameboyCommon.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/IGameboyCommon.cs index 6ad5fc0fe6..d12ba2b19a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/IGameboyCommon.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/IGameboyCommon.cs @@ -1,10 +1,6 @@ using BizHawk.Common; using BizHawk.Emulation.Common; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/LibSameboy.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/LibSameboy.cs index 0e33c042fe..38497fc352 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/LibSameboy.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/LibSameboy.cs @@ -1,11 +1,8 @@ using BizHawk.Common.BizInvoke; using BizHawk.Emulation.Cores.Waterbox; using System; -using System.Collections.Generic; -using System.Linq; + using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Sameboy.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Sameboy.cs index 59a3c7aa7c..b8ed05b9de 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Sameboy.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Sameboy.cs @@ -3,12 +3,10 @@ using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Properties; using BizHawk.Emulation.Cores.Waterbox; using System; -using System.Collections.Generic; + using System.ComponentModel; using System.IO; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy { diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.cs index 9f58497577..401bebf97d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.cs @@ -1,11 +1,8 @@ using System; -using BizHawk.Common.BufferExtensions; using BizHawk.Emulation.Common; -using BizHawk.Emulation.Cores.Components.Z80A; using BizHawk.Emulation.Cores.Sega.MasterSystem; -using System.Runtime.InteropServices; namespace BizHawk.Emulation.Cores.Sega.GGHawkLink {