GBHawk: Fix behaviour of button pressed during STOP

This commit is contained in:
alyosha-tas 2020-10-22 20:24:54 -04:00
parent 3709968757
commit d7c59e8bd4
5 changed files with 15 additions and 8 deletions

View File

@ -19,7 +19,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902
// unsaved variables
public bool checker;
byte interrupt_src_reg, interrupt_enable_reg;
byte interrupt_src_reg, interrupt_enable_reg, buttons_pressed;
public void BuildInstructionTable()
{

View File

@ -92,7 +92,8 @@ namespace BizHawk.Emulation.Cores.Components.LR35902
public Func<ushort, byte> PeekMemory;
public Func<ushort, byte> DummyReadMemory;
// Get external interrupt registers
// Get external interrupt registers and button presses
public Func<ushort, byte> GetButtons;
public Func<ushort, byte> GetIntRegs;
public Action<byte> SetIntRegs;
@ -477,11 +478,11 @@ namespace BizHawk.Emulation.Cores.Components.LR35902
stop_check = true;
}
interrupt_src_reg = GetIntRegs(0);
buttons_pressed = GetButtons(0);
if (stop_time > 0)
{
// Timer interrupts can prematurely terminate a speedchange, nt sure about other sources
// Timer interrupts can prematurely terminate a speedchange, not sure about other sources
// NOTE: some testing around the edge case of where the speed actually changes is needed
if (I_use && interrupts_enabled)
{
@ -536,7 +537,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902
}
// If a button is pressed during speed change, the processor will jam
if (interrupt_src_reg.Bit(4))
if ((buttons_pressed & 0xF) != 0xF)
{
stop_time++;
break;
@ -544,7 +545,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902
}
// Button press will exit stop loop even if speed change in progress, even without interrupts enabled
if (interrupt_src_reg.Bit(4))
if ((buttons_pressed & 0xF) != 0xF)
{
// TODO: On a gameboy, you can only un-STOP once, needs further testing
TraceCallback?.Invoke(new TraceInfo

View File

@ -119,7 +119,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
if (ppu.DMA_start && !cpu.halted && !cpu.stopped) { ppu.DMA_tick(); }
serialport.serial_transfer_tick();
timer.tick();
timer.tick();
cpu.ExecuteOne();
timer.divider_reg++;
@ -344,6 +344,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
Acc_Y_state = _controllerDeck.ReadAccY1(controller);
}
public byte GetButtons(ushort r)
{
return input_register;
}
public byte GetIntRegs(ushort r)
{
if (r==0)

View File

@ -109,6 +109,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
DummyReadMemory = ReadMemory,
OnExecFetch = ExecFetch,
SpeedFunc = SpeedFunc,
GetButtons = GetButtons,
GetIntRegs = GetIntRegs,
SetIntRegs = SetIntRegs
};

View File

@ -1,5 +1,6 @@
using BizHawk.Common;
using BizHawk.Emulation.Cores.Components.LR35902;
using System;
namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{
@ -60,7 +61,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{
return 0xFF;
}
}
else
{