GBHawk: work on STOP

This commit is contained in:
alyosha-tas 2020-04-30 10:18:46 -04:00
parent 2ef2f8f119
commit 084d768cca
3 changed files with 16 additions and 5 deletions

View File

@ -424,7 +424,8 @@ namespace BizHawk.Emulation.Cores.Components.LR35902
stopped = true;
if (!stop_check)
{
stop_time = SpeedFunc(0);
// Z contains the second stop byte, not sure if it's useful at all
stop_time = SpeedFunc(Regs[Z]);
stop_check = true;
}
@ -433,6 +434,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902
if (stop_time > 0)
{
stop_time--;
if (stop_time == 0)
{
TraceCallback?.Invoke(new TraceInfo
@ -454,8 +456,10 @@ namespace BizHawk.Emulation.Cores.Components.LR35902
instr_pntr = 256 * 60 * 2 + 60 * 5; // point to stop loop
}
}
else if (interrupt_src_reg.Bit(4)) // button pressed, not actually an interrupt though
else if (interrupt_src_reg.Bit(4)) // button pressed, even if interrupts are not enabled, still exists stop
{
// TODO: OnExecFetch a gameboy, you can only un-STOP once, needs further testing
TraceCallback?.Invoke(new TraceInfo
{
Disassembly = "====un-stop====",

View File

@ -17,6 +17,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
public bool in_vblank_old;
public bool in_vblank;
public bool vblank_rise;
public bool controller_was_checked;
public bool FrameAdvance(IController controller, bool render, bool rendersound)
{
@ -56,10 +57,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
_islag = true;
controller_was_checked = false;
do_frame(controller);
// if the game is stopped but controller interrupts are on, check for interrupts
if ((cpu.stopped || cpu.halted) && _islag && ((REG_FFFF & 0x10) == 0x10))
// if the game is halted but controller interrupts are on, check for interrupts
// if the game is stopped, any button press will un-stop even if interrupts are off
if ((cpu.stopped && !controller_was_checked) || (cpu.halted && ((REG_FFFF & 0x10) == 0x10)))
{
// update the controller state on VBlank
GetControllerState(controller);
@ -125,6 +129,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{
_islag = false;
controller_was_checked = true;
// update the controller state on VBlank
GetControllerState(controller);
@ -262,7 +268,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
return 0;
}
// if we are in GB mode, return 0 indicating not switching speed
// if we are in GB mode, return 0, cannot switch speed
return 0;
}

View File

@ -35,6 +35,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
ser.Sync(nameof(in_vblank), ref in_vblank);
ser.Sync(nameof(in_vblank_old), ref in_vblank_old);
ser.Sync(nameof(vblank_rise), ref vblank_rise);
ser.Sync(nameof(controller_was_checked), ref controller_was_checked);
ser.Sync(nameof(GB_bios_register), ref GB_bios_register);
ser.Sync(nameof(input_register), ref input_register);