A7800Hawk: Update timing
This commit is contained in:
parent
e4d66c52f5
commit
36585213c8
|
@ -13,7 +13,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
||||||
//Maria related variables
|
//Maria related variables
|
||||||
public int cycle;
|
public int cycle;
|
||||||
public int cpu_cycle;
|
public int cpu_cycle;
|
||||||
public int m6532_cycle;
|
|
||||||
public bool cpu_is_haltable;
|
public bool cpu_is_haltable;
|
||||||
public bool cpu_is_halted;
|
public bool cpu_is_halted;
|
||||||
public bool cpu_halt_pending;
|
public bool cpu_halt_pending;
|
||||||
|
@ -38,6 +37,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
||||||
// if the 6532 or TIA are accessed (PC goes to one of those addresses) the next access will be slower by 1/2 a CPU cycle
|
// if the 6532 or TIA are accessed (PC goes to one of those addresses) the next access will be slower by 1/2 a CPU cycle
|
||||||
// i.e. it will take 6 Maria cycles instead of 4
|
// i.e. it will take 6 Maria cycles instead of 4
|
||||||
public bool slow_access = false;
|
public bool slow_access = false;
|
||||||
|
public int slow_countdown;
|
||||||
|
|
||||||
public void FrameAdvance(IController controller, bool render, bool rendersound)
|
public void FrameAdvance(IController controller, bool render, bool rendersound)
|
||||||
{
|
{
|
||||||
|
@ -77,7 +77,15 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
||||||
|
|
||||||
public void RunCPUCycle()
|
public void RunCPUCycle()
|
||||||
{
|
{
|
||||||
cpu_cycle++;
|
if (slow_countdown==0)
|
||||||
|
{
|
||||||
|
cpu_cycle++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
slow_countdown--;
|
||||||
|
}
|
||||||
|
|
||||||
tia._hsyncCnt++;
|
tia._hsyncCnt++;
|
||||||
tia._hsyncCnt %= 454;
|
tia._hsyncCnt %= 454;
|
||||||
// do the audio sampling
|
// do the audio sampling
|
||||||
|
@ -87,11 +95,10 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
||||||
}
|
}
|
||||||
|
|
||||||
// tick the m6532 timer, which is still active although not recommended to use
|
// tick the m6532 timer, which is still active although not recommended to use
|
||||||
m6532_cycle++;
|
// also it runs off of the cpu cycle timer
|
||||||
if (m6532_cycle== 4)
|
if (cpu_cycle== 4)
|
||||||
{
|
{
|
||||||
m6532.Timer.Tick();
|
m6532.Timer.Tick();
|
||||||
m6532_cycle = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cpu_cycle <= (2 + (slow_access ? 1 : 0)))
|
if (cpu_cycle <= (2 + (slow_access ? 1 : 0)))
|
||||||
|
@ -110,6 +117,13 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
||||||
if (!cpu_is_halted)
|
if (!cpu_is_halted)
|
||||||
{
|
{
|
||||||
cpu.ExecuteOne();
|
cpu.ExecuteOne();
|
||||||
|
|
||||||
|
// we need to stall the next cpu cycle from starting if the current one is a slow access
|
||||||
|
if (slow_access)
|
||||||
|
{
|
||||||
|
slow_access = false;
|
||||||
|
slow_countdown = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -132,32 +146,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
||||||
cpu_is_halted = false;
|
cpu_is_halted = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine if the next access will be fast or slow
|
|
||||||
if ((cpu.PC & 0xFCE0) == 0)
|
|
||||||
{
|
|
||||||
// return TIA registers or control register if it is still unlocked
|
|
||||||
if ((A7800_control_register & 0x1) == 0)
|
|
||||||
{
|
|
||||||
slow_access = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
slow_access = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((cpu.PC & 0xFF80) == 0x280)
|
|
||||||
{
|
|
||||||
slow_access = true;
|
|
||||||
}
|
|
||||||
else if ((cpu.PC & 0xFE80) == 0x480)
|
|
||||||
{
|
|
||||||
slow_access = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
slow_access = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetControllerState(IController controller)
|
public void GetControllerState(IController controller)
|
||||||
|
|
|
@ -70,13 +70,13 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
||||||
|
|
||||||
ser.Sync("cycle", ref cycle);
|
ser.Sync("cycle", ref cycle);
|
||||||
ser.Sync("cpu_cycle", ref cpu_cycle);
|
ser.Sync("cpu_cycle", ref cpu_cycle);
|
||||||
ser.Sync("m6532_cycle", ref m6532_cycle);
|
|
||||||
ser.Sync("cpu_is_haltable", ref cpu_is_haltable);
|
ser.Sync("cpu_is_haltable", ref cpu_is_haltable);
|
||||||
ser.Sync("cpu_is_halted", ref cpu_is_halted);
|
ser.Sync("cpu_is_halted", ref cpu_is_halted);
|
||||||
ser.Sync("cpu_halt_pending", ref cpu_halt_pending);
|
ser.Sync("cpu_halt_pending", ref cpu_halt_pending);
|
||||||
ser.Sync("cpu_resume_pending", ref cpu_resume_pending);
|
ser.Sync("cpu_resume_pending", ref cpu_resume_pending);
|
||||||
|
|
||||||
ser.Sync("slow_access", ref slow_access);
|
ser.Sync("slow_access", ref slow_access);
|
||||||
|
ser.Sync("slow_access", ref slow_countdown);
|
||||||
ser.Sync("small flag", ref small_flag);
|
ser.Sync("small flag", ref small_flag);
|
||||||
ser.Sync("pal kara", ref PAL_Kara);
|
ser.Sync("pal kara", ref PAL_Kara);
|
||||||
ser.Sync("Cart RAM", ref cart_RAM);
|
ser.Sync("Cart RAM", ref cart_RAM);
|
||||||
|
|
|
@ -34,6 +34,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
slow_access = true;
|
||||||
return tia.ReadMemory((ushort)(addr & 0x1F), false);
|
return tia.ReadMemory((ushort)(addr & 0x1F), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,11 +51,12 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
||||||
}
|
}
|
||||||
else if ((addr & 0xFF80) == 0x280)
|
else if ((addr & 0xFF80) == 0x280)
|
||||||
{
|
{
|
||||||
//return regs_6532[addr & 0x1F];
|
slow_access = true;
|
||||||
return m6532.ReadMemory(addr, false);
|
return m6532.ReadMemory(addr, false);
|
||||||
}
|
}
|
||||||
else if ((addr & 0xFE80) == 0x480)
|
else if ((addr & 0xFE80) == 0x480)
|
||||||
{
|
{
|
||||||
|
slow_access = true;
|
||||||
return RAM_6532[addr & 0x7F];
|
return RAM_6532[addr & 0x7F];
|
||||||
}
|
}
|
||||||
else if ((addr >= 0x1800) && (addr < 0x2800))
|
else if ((addr >= 0x1800) && (addr < 0x2800))
|
||||||
|
@ -109,6 +111,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
slow_access = true;
|
||||||
tia.WriteMemory((ushort)(addr & 0x1F), value, false);
|
tia.WriteMemory((ushort)(addr & 0x1F), value, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,8 +133,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
||||||
Console.Write(Maria_regs[i]);
|
Console.Write(Maria_regs[i]);
|
||||||
Console.Write(" ");
|
Console.Write(" ");
|
||||||
}
|
}
|
||||||
Console.WriteLine(maria.scanline);
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -140,10 +143,12 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
||||||
}
|
}
|
||||||
else if ((addr & 0xFF80) == 0x280)
|
else if ((addr & 0xFF80) == 0x280)
|
||||||
{
|
{
|
||||||
|
slow_access = true;
|
||||||
m6532.WriteMemory(addr, value);
|
m6532.WriteMemory(addr, value);
|
||||||
}
|
}
|
||||||
else if ((addr & 0xFE80) == 0x480)
|
else if ((addr & 0xFE80) == 0x480)
|
||||||
{
|
{
|
||||||
|
slow_access = true;
|
||||||
RAM_6532[addr & 0x7F] = value;
|
RAM_6532[addr & 0x7F] = value;
|
||||||
}
|
}
|
||||||
else if ((addr >= 0x1800) && (addr < 0x2800))
|
else if ((addr >= 0x1800) && (addr < 0x2800))
|
||||||
|
|
Loading…
Reference in New Issue