commodore64: implement proper lag frame counting
This commit is contained in:
parent
aca129d5f6
commit
8d6e55e2a9
|
@ -100,6 +100,7 @@
|
|||
<Compile Include="Computers\Commodore64\SidSoundProvider.cs" />
|
||||
<Compile Include="Computers\Commodore64\SidWaveformCalculator.cs" />
|
||||
<Compile Include="Computers\Commodore64\SidWaveformGenerator.cs" />
|
||||
<Compile Include="Computers\Commodore64\Timing.cs" />
|
||||
<Compile Include="Computers\Commodore64\Via.cs" />
|
||||
<Compile Include="Computers\Commodore64\VicIINew.cs" />
|
||||
<Compile Include="Computers\Commodore64\VicIINewPipeline.cs" />
|
||||
|
|
|
@ -91,11 +91,13 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
// process frame
|
||||
public void FrameAdvance(bool render, bool rendersound)
|
||||
{
|
||||
_frame++;
|
||||
_islag = true;
|
||||
|
||||
int cyclesPerFrame = vic.CyclesPerFrame;
|
||||
|
||||
// bizhawk interface setup
|
||||
_frame++;
|
||||
mem.inputWasRead = false;
|
||||
|
||||
// apply any media if needed
|
||||
foreach (IMedia media in mediaAttached)
|
||||
{
|
||||
if (!media.Loaded() && media.Ready())
|
||||
|
@ -104,8 +106,10 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
}
|
||||
}
|
||||
|
||||
// refresh the input values
|
||||
PollInput();
|
||||
|
||||
// perform the cycle
|
||||
for (int i = 0; i < cyclesPerFrame; i++)
|
||||
{
|
||||
vic.PerformCycle();
|
||||
|
@ -124,6 +128,8 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
}
|
||||
}
|
||||
|
||||
_islag = !mem.inputWasRead;
|
||||
|
||||
if (_islag)
|
||||
{
|
||||
LagCount++;
|
||||
|
|
|
@ -62,6 +62,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
|
||||
// registers
|
||||
public byte busData;
|
||||
public bool inputWasRead;
|
||||
public bool readTrigger = true;
|
||||
public bool writeTrigger = true;
|
||||
|
||||
|
@ -364,6 +365,8 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
|||
result = ReadColorRam(addr);
|
||||
break;
|
||||
case MemoryDesignation.Cia0:
|
||||
if ((addr & 0xF) < 0x02)
|
||||
inputWasRead = true;
|
||||
result = cia0.Read(addr);
|
||||
break;
|
||||
case MemoryDesignation.Cia1:
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BizHawk.Emulation.Computers.Commodore64
|
||||
{
|
||||
public class Timing
|
||||
{
|
||||
public int crystalFreq;
|
||||
public uint timer;
|
||||
|
||||
public Timing(Region timingRegion)
|
||||
{
|
||||
switch (timingRegion)
|
||||
{
|
||||
case Region.NTSC:
|
||||
crystalFreq = 14318181;
|
||||
break;
|
||||
case Region.PAL:
|
||||
crystalFreq = 17734472;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Advance()
|
||||
{
|
||||
// need an unchecked block here since the timer will wrap
|
||||
unchecked
|
||||
{
|
||||
timer++;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsCycle(int divisor)
|
||||
{
|
||||
return (timer % divisor) == 0;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue