GBHawk: Speed change and window fixes
This commit is contained in:
parent
75bd2f8063
commit
a914cb69e0
|
@ -603,7 +603,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902
|
||||||
// Stop loop
|
// Stop loop
|
||||||
instr_table[256 * 60 * 2 + 60 * 5] = IDLE;
|
instr_table[256 * 60 * 2 + 60 * 5] = IDLE;
|
||||||
instr_table[256 * 60 * 2 + 60 * 5 + 1] = IDLE;
|
instr_table[256 * 60 * 2 + 60 * 5 + 1] = IDLE;
|
||||||
instr_table[256 * 60 * 2 + 60 * 5 + 2] = IDLE;
|
instr_table[256 * 60 * 2 + 60 * 5 + 2] = HALT_CHK;
|
||||||
instr_table[256 * 60 * 2 + 60 * 5 + 3] = STOP;
|
instr_table[256 * 60 * 2 + 60 * 5 + 3] = STOP;
|
||||||
|
|
||||||
// interrupt vectors
|
// interrupt vectors
|
||||||
|
|
|
@ -430,12 +430,41 @@ namespace BizHawk.Emulation.Cores.Components.LR35902
|
||||||
}
|
}
|
||||||
|
|
||||||
interrupt_src_reg = GetIntRegs(0);
|
interrupt_src_reg = GetIntRegs(0);
|
||||||
|
|
||||||
if (stop_time > 0)
|
if (stop_time > 0)
|
||||||
{
|
{
|
||||||
if (stop_time == (32768 - 43))
|
// Timer interrupts can prematurely terminate a speedchange, nt sure about other sources
|
||||||
|
// NOTE: some testing around the edge case of where the speed actually changes is needed
|
||||||
|
if (I_use && interrupts_enabled)
|
||||||
{
|
{
|
||||||
SpeedFunc(1);
|
interrupts_enabled = false;
|
||||||
|
I_use = false;
|
||||||
|
|
||||||
|
TraceCallback?.Invoke(new TraceInfo
|
||||||
|
{
|
||||||
|
Disassembly = "====un-stop====",
|
||||||
|
RegisterInfo = ""
|
||||||
|
});
|
||||||
|
|
||||||
|
stopped = false;
|
||||||
|
stop_check = false;
|
||||||
|
stop_time = 0;
|
||||||
|
|
||||||
|
TraceCallback?.Invoke(new TraceInfo
|
||||||
|
{
|
||||||
|
Disassembly = "====IRQ====",
|
||||||
|
RegisterInfo = ""
|
||||||
|
});
|
||||||
|
|
||||||
|
// call interrupt processor
|
||||||
|
// lowest bit set is highest priority
|
||||||
|
instr_pntr = 256 * 60 * 2 + 60 * 6; // point to Interrupt
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stop_time == (32768 - 2))
|
||||||
|
{
|
||||||
|
SpeedFunc(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_time--;
|
stop_time--;
|
||||||
|
@ -454,16 +483,22 @@ namespace BizHawk.Emulation.Cores.Components.LR35902
|
||||||
instr_pntr = 256 * 60 * 2 + 60;
|
instr_pntr = 256 * 60 * 2 + 60;
|
||||||
|
|
||||||
stop_check = false;
|
stop_check = false;
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// If a button is pressed during speed change, the processor will jam
|
||||||
|
if (interrupt_src_reg.Bit(4))
|
||||||
{
|
{
|
||||||
instr_pntr = 256 * 60 * 2 + 60 * 5; // point to stop loop
|
stop_time++;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (interrupt_src_reg.Bit(4)) // button pressed, even if interrupts are not enabled, still exists stop
|
|
||||||
|
// Button press will exit stop loop even if speed change in progress, even without interrupts enabled
|
||||||
|
if (interrupt_src_reg.Bit(4))
|
||||||
{
|
{
|
||||||
// TODO: On a gameboy, you can only un-STOP once, needs further testing
|
// TODO: On a gameboy, you can only un-STOP once, needs further testing
|
||||||
|
|
||||||
TraceCallback?.Invoke(new TraceInfo
|
TraceCallback?.Invoke(new TraceInfo
|
||||||
{
|
{
|
||||||
Disassembly = "====un-stop====",
|
Disassembly = "====un-stop====",
|
||||||
|
|
|
@ -790,7 +790,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
total_counter = 0;
|
total_counter = 0;
|
||||||
|
|
||||||
// TODO: If Window is turned on midscanline what happens? When is this check done exactly?
|
// TODO: If Window is turned on midscanline what happens? When is this check done exactly?
|
||||||
if ((window_started && window_latch) || (window_is_reset && !window_latch && (LY >= window_y_latch)))
|
if ((window_started && window_latch) || (window_is_reset && !window_latch && (LY > window_y_latch)))
|
||||||
{
|
{
|
||||||
window_y_tile_inc++;
|
window_y_tile_inc++;
|
||||||
if (window_y_tile_inc==8)
|
if (window_y_tile_inc==8)
|
||||||
|
@ -973,7 +973,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
pixel_counter++;
|
pixel_counter++;
|
||||||
|
|
||||||
if (pixel_counter == 160)
|
if (pixel_counter == 160)
|
||||||
{
|
{
|
||||||
read_case = 8;
|
read_case = 8;
|
||||||
hbl_countdown = 2;
|
hbl_countdown = 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -788,7 +788,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
total_counter = 0;
|
total_counter = 0;
|
||||||
|
|
||||||
// TODO: If Window is turned on midscanline what happens? When is this check done exactly?
|
// TODO: If Window is turned on midscanline what happens? When is this check done exactly?
|
||||||
if ((window_started && window_latch) || (window_is_reset && !window_latch && (LY >= window_y_latch)))
|
if ((window_started && window_latch) || (window_is_reset && !window_latch && (LY > window_y_latch)))
|
||||||
{
|
{
|
||||||
window_y_tile_inc++;
|
window_y_tile_inc++;
|
||||||
if (window_y_tile_inc==8)
|
if (window_y_tile_inc==8)
|
||||||
|
|
|
@ -285,7 +285,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
{
|
{
|
||||||
speed_switch = false;
|
speed_switch = false;
|
||||||
Console.WriteLine("Speed Switch: " + cpu.TotalExecutedCycles);
|
Console.WriteLine("Speed Switch: " + cpu.TotalExecutedCycles);
|
||||||
int ret = double_speed ? 32768 - 20 : 32768 - 20; // actual time needs checking
|
|
||||||
|
// reset the divider (only way for speed_change_timing_fine.gbc and speed_change_cancel.gbc to both work)
|
||||||
|
timer.divider_reg = 0;
|
||||||
|
|
||||||
|
int ret = double_speed ? 32769 : 32769; // actual time needs checking
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@ using BizHawk.Emulation.Cores.Components.LR35902;
|
||||||
using BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy;
|
using BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// TODO: mode1_disableint_gbc.gbc behaves differently between GBC and GBA, why?
|
||||||
|
|
||||||
namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
{
|
{
|
||||||
[Core(
|
[Core(
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
{
|
{
|
||||||
// don't draw for one frame after turning on
|
// don't draw for one frame after turning on
|
||||||
blank_frame = true;
|
blank_frame = true;
|
||||||
}
|
}
|
||||||
LCDC = value;
|
LCDC = value;
|
||||||
break;
|
break;
|
||||||
case 0xFF41: // STAT
|
case 0xFF41: // STAT
|
||||||
|
@ -481,7 +481,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
total_counter = 0;
|
total_counter = 0;
|
||||||
|
|
||||||
// TODO: If Window is turned on midscanline what happens? When is this check done exactly?
|
// TODO: If Window is turned on midscanline what happens? When is this check done exactly?
|
||||||
if ((window_started && window_latch) || (window_is_reset && !window_latch && (LY >= window_y_latch)))
|
if ((window_started && window_latch) || (window_is_reset && !window_latch && (LY > window_y_latch)))
|
||||||
{
|
{
|
||||||
window_y_tile_inc++;
|
window_y_tile_inc++;
|
||||||
if (window_y_tile_inc==8)
|
if (window_y_tile_inc==8)
|
||||||
|
|
|
@ -68,6 +68,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
case 0xFF07:
|
case 0xFF07:
|
||||||
timer_control = (byte)((timer_control & 0xf8) | (value & 0x7)); // only bottom 3 bits function
|
timer_control = (byte)((timer_control & 0xf8) | (value & 0x7)); // only bottom 3 bits function
|
||||||
|
|
||||||
|
// NOTE: On GBA models, there is a race condition when enabling with a change in bit check
|
||||||
|
// that would result in a state change that is not consistent in all models, see tac_set_disabled.gbc
|
||||||
|
|
||||||
// NOTE: On GBA only, there is a glitch where if the current timer control is 7 and the written value is 7 and
|
// NOTE: On GBA only, there is a glitch where if the current timer control is 7 and the written value is 7 and
|
||||||
// there is a coincident timer increment, there will be an additional increment along with this write.
|
// there is a coincident timer increment, there will be an additional increment along with this write.
|
||||||
// not sure it effects all models or of exact details, see test tac_set_timer_disabled.gbc
|
// not sure it effects all models or of exact details, see test tac_set_timer_disabled.gbc
|
||||||
|
|
Loading…
Reference in New Issue