GBHawk: Speed switch timing fix.
This commit is contained in:
parent
e075012b70
commit
c96a233d5d
|
@ -576,7 +576,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902
|
|||
// exit halt / stop loop
|
||||
instr_table[256 * 60 * 2 + 60] = IDLE;
|
||||
instr_table[256 * 60 * 2 + 60 + 1] = IDLE;
|
||||
instr_table[256 * 60 * 2 + 60 + 2] = IDLE;
|
||||
instr_table[256 * 60 * 2 + 60 + 2] = HALT_CHK;
|
||||
instr_table[256 * 60 * 2 + 60 + 3] = OP;
|
||||
|
||||
// skipped loop
|
||||
|
|
|
@ -425,7 +425,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902
|
|||
if (!stop_check)
|
||||
{
|
||||
// Z contains the second stop byte, not sure if it's useful at all
|
||||
stop_time = SpeedFunc(Regs[Z]);
|
||||
stop_time = SpeedFunc(0);
|
||||
stop_check = true;
|
||||
}
|
||||
|
||||
|
@ -433,6 +433,11 @@ namespace BizHawk.Emulation.Cores.Components.LR35902
|
|||
|
||||
if (stop_time > 0)
|
||||
{
|
||||
if (stop_time == (32768 - 43))
|
||||
{
|
||||
SpeedFunc(1);
|
||||
}
|
||||
|
||||
stop_time--;
|
||||
|
||||
if (stop_time == 0)
|
||||
|
|
|
@ -101,10 +101,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
{
|
||||
// These things all tick twice as fast in GBC double speed mode
|
||||
// Note that DMA is halted when the CPU is halted
|
||||
if (ppu.DMA_start && !cpu.halted && !cpu.stopped) { ppu.DMA_tick(); }
|
||||
serialport.serial_transfer_tick();
|
||||
cpu.ExecuteOne();
|
||||
timer.tick();
|
||||
|
||||
if (double_speed)
|
||||
{
|
||||
|
@ -113,17 +109,22 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
cpu.ExecuteOne();
|
||||
timer.tick();
|
||||
}
|
||||
|
||||
if (ppu.DMA_start && !cpu.halted && !cpu.stopped) { ppu.DMA_tick(); }
|
||||
serialport.serial_transfer_tick();
|
||||
cpu.ExecuteOne();
|
||||
timer.tick();
|
||||
}
|
||||
else
|
||||
{
|
||||
cpu.TotalExecutedCycles++;
|
||||
timer.tick();
|
||||
|
||||
if (double_speed)
|
||||
{
|
||||
cpu.TotalExecutedCycles++;
|
||||
timer.tick();
|
||||
}
|
||||
|
||||
cpu.TotalExecutedCycles++;
|
||||
timer.tick();
|
||||
}
|
||||
|
||||
if (in_vblank && !in_vblank_old)
|
||||
|
@ -254,23 +255,30 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
// Switch Speed (GBC only)
|
||||
public int SpeedFunc(int temp)
|
||||
{
|
||||
if (is_GBC)
|
||||
if (temp == 0)
|
||||
{
|
||||
if (speed_switch)
|
||||
if (is_GBC)
|
||||
{
|
||||
speed_switch = false;
|
||||
Console.WriteLine("Speed Switch: " + cpu.TotalExecutedCycles);
|
||||
int ret = double_speed ? (32768 - 20) : (32768 - 20); // actual time needs checking
|
||||
double_speed = !double_speed;
|
||||
return ret;
|
||||
if (speed_switch)
|
||||
{
|
||||
speed_switch = false;
|
||||
Console.WriteLine("Speed Switch: " + cpu.TotalExecutedCycles);
|
||||
int ret = double_speed ? 32768 - 20 : 32768 - 20; // actual time needs checking
|
||||
return ret;
|
||||
}
|
||||
|
||||
// if we are not switching speed, return 0
|
||||
return 0;
|
||||
}
|
||||
|
||||
// if we are not switching speed, return 0
|
||||
// if we are in GB mode, return 0, cannot switch speed
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
double_speed = !double_speed;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// if we are in GB mode, return 0, cannot switch speed
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void GetControllerState(IController controller)
|
||||
|
|
|
@ -101,7 +101,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
|||
case 0xFF4D:
|
||||
if (GBC_compat)
|
||||
{
|
||||
ret = (byte)(((double_speed ? 1 : 0) << 7) + ((speed_switch ? 1 : 0)));
|
||||
ret = (byte)(((double_speed ? 1 : 0) << 7) | (speed_switch ? 1 : 0) | 0x7E);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue