Atari 2600 - break up frame advance with StartNewFrame() and EndFrame() and wire them up to Cycle and Scanline advance, all methods are now smart enough to roll over to the next frame at the right time

This commit is contained in:
adelikat 2014-05-27 02:45:05 +00:00
parent 90af0b4858
commit 947470e1d9
4 changed files with 147 additions and 121 deletions

View File

@ -71,28 +71,28 @@
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.CoreInfoBox = new System.Windows.Forms.GroupBox();
this.LastAddressLabel = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.DistinctAccesLabel = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.TotalCyclesLabel = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.ScanlineLabel = new System.Windows.Forms.Label();
this.FrameLabel = new System.Windows.Forms.Label();
this.VBlankCheckbox = new System.Windows.Forms.CheckBox();
this.VSyncChexkbox = new System.Windows.Forms.CheckBox();
this.label8 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.TracerBox = new System.Windows.Forms.GroupBox();
this.TraceView = new BizHawk.Client.EmuHawk.VirtualListView();
this.Script = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.StepOverButton = new System.Windows.Forms.Button();
this.StepOutButton = new System.Windows.Forms.Button();
this.BreakpointGroupBox = new System.Windows.Forms.GroupBox();
this.AddBreakpointButton = new System.Windows.Forms.Button();
this.FrameLabel = new System.Windows.Forms.Label();
this.ScanlineLabel = new System.Windows.Forms.Label();
this.TotalCyclesLabel = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.DistinctAccesLabel = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.LastAddressLabel = new System.Windows.Forms.Label();
this.BreakpointView = new BizHawk.Client.EmuHawk.VirtualListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.TraceView = new BizHawk.Client.EmuHawk.VirtualListView();
this.Script = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.DebuggerMenu.SuspendLayout();
this.RegistersBox.SuspendLayout();
this.CoreInfoBox.SuspendLayout();
@ -516,10 +516,82 @@
this.CoreInfoBox.Controls.Add(this.label7);
this.CoreInfoBox.Location = new System.Drawing.Point(260, 27);
this.CoreInfoBox.Name = "CoreInfoBox";
this.CoreInfoBox.Size = new System.Drawing.Size(238, 155);
this.CoreInfoBox.Size = new System.Drawing.Size(265, 155);
this.CoreInfoBox.TabIndex = 5;
this.CoreInfoBox.TabStop = false;
//
// LastAddressLabel
//
this.LastAddressLabel.AutoSize = true;
this.LastAddressLabel.Location = new System.Drawing.Point(191, 15);
this.LastAddressLabel.Name = "LastAddressLabel";
this.LastAddressLabel.Size = new System.Drawing.Size(13, 13);
this.LastAddressLabel.TabIndex = 13;
this.LastAddressLabel.Text = "0";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(96, 15);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(71, 13);
this.label9.TabIndex = 12;
this.label9.Text = "Last Address:";
//
// DistinctAccesLabel
//
this.DistinctAccesLabel.AutoSize = true;
this.DistinctAccesLabel.Location = new System.Drawing.Point(191, 38);
this.DistinctAccesLabel.Name = "DistinctAccesLabel";
this.DistinctAccesLabel.Size = new System.Drawing.Size(13, 13);
this.DistinctAccesLabel.TabIndex = 11;
this.DistinctAccesLabel.Text = "0";
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(96, 38);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(94, 13);
this.label11.TabIndex = 10;
this.label11.Text = "Distinct Accesses:";
//
// TotalCyclesLabel
//
this.TotalCyclesLabel.AutoSize = true;
this.TotalCyclesLabel.Location = new System.Drawing.Point(72, 61);
this.TotalCyclesLabel.Name = "TotalCyclesLabel";
this.TotalCyclesLabel.Size = new System.Drawing.Size(13, 13);
this.TotalCyclesLabel.TabIndex = 9;
this.TotalCyclesLabel.Text = "0";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(6, 61);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(68, 13);
this.label10.TabIndex = 8;
this.label10.Text = "Total Cycles:";
//
// ScanlineLabel
//
this.ScanlineLabel.AutoSize = true;
this.ScanlineLabel.Location = new System.Drawing.Point(72, 38);
this.ScanlineLabel.Name = "ScanlineLabel";
this.ScanlineLabel.Size = new System.Drawing.Size(13, 13);
this.ScanlineLabel.TabIndex = 7;
this.ScanlineLabel.Text = "0";
//
// FrameLabel
//
this.FrameLabel.AutoSize = true;
this.FrameLabel.Location = new System.Drawing.Point(72, 15);
this.FrameLabel.Name = "FrameLabel";
this.FrameLabel.Size = new System.Drawing.Size(13, 13);
this.FrameLabel.TabIndex = 6;
this.FrameLabel.Text = "0";
//
// VBlankCheckbox
//
this.VBlankCheckbox.AutoSize = true;
@ -570,6 +642,35 @@
this.TracerBox.TabStop = false;
this.TracerBox.Text = "Trace log";
//
// TraceView
//
this.TraceView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.TraceView.BlazingFast = false;
this.TraceView.CheckBoxes = true;
this.TraceView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.Script});
this.TraceView.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.TraceView.FullRowSelect = true;
this.TraceView.GridLines = true;
this.TraceView.HideSelection = false;
this.TraceView.ItemCount = 0;
this.TraceView.Location = new System.Drawing.Point(8, 18);
this.TraceView.Name = "TraceView";
this.TraceView.SelectAllInProgress = false;
this.TraceView.selectedItem = -1;
this.TraceView.Size = new System.Drawing.Size(393, 414);
this.TraceView.TabIndex = 4;
this.TraceView.TabStop = false;
this.TraceView.UseCompatibleStateImageBehavior = false;
this.TraceView.View = System.Windows.Forms.View.Details;
//
// Script
//
this.Script.Text = "Instructions";
this.Script.Width = 599;
//
// StepOverButton
//
this.StepOverButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@ -614,78 +715,6 @@
this.AddBreakpointButton.UseVisualStyleBackColor = true;
this.AddBreakpointButton.Click += new System.EventHandler(this.AddBreakpointButton_Click);
//
// FrameLabel
//
this.FrameLabel.AutoSize = true;
this.FrameLabel.Location = new System.Drawing.Point(72, 15);
this.FrameLabel.Name = "FrameLabel";
this.FrameLabel.Size = new System.Drawing.Size(13, 13);
this.FrameLabel.TabIndex = 6;
this.FrameLabel.Text = "0";
//
// ScanlineLabel
//
this.ScanlineLabel.AutoSize = true;
this.ScanlineLabel.Location = new System.Drawing.Point(72, 38);
this.ScanlineLabel.Name = "ScanlineLabel";
this.ScanlineLabel.Size = new System.Drawing.Size(13, 13);
this.ScanlineLabel.TabIndex = 7;
this.ScanlineLabel.Text = "0";
//
// TotalCyclesLabel
//
this.TotalCyclesLabel.AutoSize = true;
this.TotalCyclesLabel.Location = new System.Drawing.Point(72, 61);
this.TotalCyclesLabel.Name = "TotalCyclesLabel";
this.TotalCyclesLabel.Size = new System.Drawing.Size(13, 13);
this.TotalCyclesLabel.TabIndex = 9;
this.TotalCyclesLabel.Text = "0";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(6, 61);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(68, 13);
this.label10.TabIndex = 8;
this.label10.Text = "Total Cycles:";
//
// DistinctAccesLabel
//
this.DistinctAccesLabel.AutoSize = true;
this.DistinctAccesLabel.Location = new System.Drawing.Point(191, 38);
this.DistinctAccesLabel.Name = "DistinctAccesLabel";
this.DistinctAccesLabel.Size = new System.Drawing.Size(13, 13);
this.DistinctAccesLabel.TabIndex = 11;
this.DistinctAccesLabel.Text = "0";
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(96, 38);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(94, 13);
this.label11.TabIndex = 10;
this.label11.Text = "Distinct Accesses:";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(96, 15);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(71, 13);
this.label9.TabIndex = 12;
this.label9.Text = "Last Address:";
//
// LastAddressLabel
//
this.LastAddressLabel.AutoSize = true;
this.LastAddressLabel.Location = new System.Drawing.Point(191, 15);
this.LastAddressLabel.Name = "LastAddressLabel";
this.LastAddressLabel.Size = new System.Drawing.Size(13, 13);
this.LastAddressLabel.TabIndex = 13;
this.LastAddressLabel.Text = "0";
//
// BreakpointView
//
this.BreakpointView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -721,35 +750,6 @@
this.columnHeader2.Text = "Type";
this.columnHeader2.Width = 103;
//
// TraceView
//
this.TraceView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.TraceView.BlazingFast = false;
this.TraceView.CheckBoxes = true;
this.TraceView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.Script});
this.TraceView.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.TraceView.FullRowSelect = true;
this.TraceView.GridLines = true;
this.TraceView.HideSelection = false;
this.TraceView.ItemCount = 0;
this.TraceView.Location = new System.Drawing.Point(8, 18);
this.TraceView.Name = "TraceView";
this.TraceView.SelectAllInProgress = false;
this.TraceView.selectedItem = -1;
this.TraceView.Size = new System.Drawing.Size(393, 414);
this.TraceView.TabIndex = 4;
this.TraceView.TabStop = false;
this.TraceView.UseCompatibleStateImageBehavior = false;
this.TraceView.View = System.Windows.Forms.View.Details;
//
// Script
//
this.Script.Text = "Instructions";
this.Script.Width = 599;
//
// Atari2600Debugger
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

View File

@ -315,7 +315,6 @@ namespace BizHawk.Client.EmuHawk
}
UpdateValues();
}
private void ScanlineAdvanceBtn_Click(object sender, EventArgs e)

View File

@ -340,7 +340,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
Cpu.PC = (ushort)(ReadMemory(0x1FFC) + (ReadMemory(0x1FFD) << 8)); // set the initial PC
}
public void FrameAdvance(bool render, bool rendersound)
private void StartNewFrame()
{
_frame++;
_islag = true;
@ -351,12 +351,10 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
}
_tia.BeginAudioFrame();
while (_tia.LineCount < _tia.NominalNumScanlines)
{
CycleAdvance();
}
//Console.WriteLine("{0}", _tia.CurrentScanLine);
}
private void FinishFrame()
{
_tia.CompleteAudioFrame();
if (_islag)
@ -367,7 +365,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_tia.LineCount = 0;
}
public void CycleAdvance()
private void Cycle()
{
_tia.Execute(1);
_tia.Execute(1);
@ -383,6 +381,29 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_mapper.ClockCpu();
}
public void FrameAdvance(bool render, bool rendersound)
{
StartNewFrame();
while (_tia.LineCount < _tia.NominalNumScanlines)
{
Cycle();
}
FinishFrame();
}
public void CycleAdvance()
{
Cycle();
if (_tia.LineCount >= _tia.NominalNumScanlines)
{
FinishFrame();
StartNewFrame();
}
}
public void ScanlineAdvance()
{
var currLineCount = _tia.LineCount;
@ -390,6 +411,12 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
CycleAdvance();
}
if (_tia.LineCount >= _tia.NominalNumScanlines)
{
FinishFrame();
StartNewFrame();
}
}
public byte ReadControls1(bool peek)

View File

@ -145,7 +145,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
public int CurrentScanLine
{
get { return _tia.CurrentScanLine; }
get { return _tia.LineCount; }
}
public bool IsVsync