From 20e8ddf6734bcf63738510b91e7d58aa6f7de0a6 Mon Sep 17 00:00:00 2001 From: saxxonpike Date: Tue, 10 Dec 2013 07:04:44 +0000 Subject: [PATCH] C64: Fixed a misspelling in timer constant name. Added method to track lag cycles from VIC. --- .../Computers/Commodore64/C64.cs | 2 ++ .../Computers/Commodore64/MOS/MOS6510.cs | 27 +++++++++++++++---- .../Computers/Commodore64/MOS/Vic.Parse.cs | 4 +-- .../Computers/Commodore64/MOS/Vic.Render.cs | 1 + .../Commodore64/MOS/Vic.TimingBuilder.cs | 2 +- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs index ff41dcfc64..15d38251dd 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs @@ -96,6 +96,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 { board.inputRead = false; board.PollInput(); + board.cpu.LagCycles = 0; for (int count = 0; count < cyclesPerFrame; count++) { @@ -133,6 +134,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 //Console.WriteLine("CPUPC: " + C64Util.ToHex(board.cpu.PC, 4) + " 1541PC: " + C64Util.ToHex(disk.PC, 4)); + int test = board.cpu.LagCycles; CoreComm.DriveLED = DriveLED; } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6510.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6510.cs index 7f8f629444..9c9f0999a9 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6510.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6510.cs @@ -14,6 +14,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 // ------------------------------------ MOS6502X cpu; + int lagCycles; bool pinNMILast; LatchedPort port; bool thisNMI; @@ -78,13 +79,29 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 if (!thisNMI && pinNMILast) cpu.NMI = true; - if (ReadAEC()) - { - cpu.ExecuteOne(); - pinNMILast = thisNMI; - } + if (ReadAEC()) + { + cpu.ExecuteOne(); + pinNMILast = thisNMI; + } + else + { + lagCycles++; + } } + public int LagCycles + { + get + { + return lagCycles; + } + set + { + lagCycles = value; + } + } + // ------------------------------------ public ushort PC diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Parse.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Parse.cs index e0c60d51f6..3fde5da000 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Parse.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Parse.cs @@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 { const int baResetCounter = 7; const int pipelineUpdateVc = 1; - const int pipelineChkSprChunch = 2; + const int pipelineChkSprCrunch = 2; const int pipelineUpdateMcBase = 4; const int pipelineChkBrdL1 = 8; const int pipelineChkBrdL0 = 16; @@ -169,7 +169,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 if (parseact != 0) { - if ((parseact & pipelineChkSprChunch) != 0) + if ((parseact & pipelineChkSprCrunch) != 0) { foreach (SpriteGenerator spr in sprites) { diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Render.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Render.cs index b0b96e0d8c..beecf7ce0d 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Render.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Render.cs @@ -213,6 +213,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 if (bufOffset == bufLength) bufOffset = 0; } + pixBuffer[pixBufferIndex] = pixel; pixBufferIndex++; diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.TimingBuilder.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.TimingBuilder.cs index 91c5aae3d3..ebe9e21e93 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.TimingBuilder.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.TimingBuilder.cs @@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 static int[] TimingBuilder_Cycle14Act = new int[] { pipelineUpdateVc, 0, - pipelineChkSprChunch, 0, + pipelineChkSprCrunch, 0, pipelineUpdateMcBase, 0, }; static int[] TimingBuilder_Cycle55Act = new int[]