NESHawk: update lag definition and add sprite address glitch

This commit is contained in:
alyosha-tas 2021-06-18 23:08:04 -04:00
parent 427d0351af
commit 02cd2f47f3
4 changed files with 27 additions and 8 deletions

View File

@ -744,6 +744,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
private void write_joyport(byte value) private void write_joyport(byte value)
{ {
//Console.WriteLine("cont " + value + " frame " + Frame);
var si = new StrobeInfo(latched4016, value); var si = new StrobeInfo(latched4016, value);
ControllerDeck.Strobe(si, _controller); ControllerDeck.Strobe(si, _controller);
latched4016 = value; latched4016 = value;
@ -752,13 +754,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{ {
controller_was_latched = true; controller_was_latched = true;
alt_lag = false; alt_lag = false;
lagged = false;
} }
current_strobe = new_strobe;
} }
private byte read_joyport(int addr) private byte read_joyport(int addr)
{ {
InputCallbacks.Call(); InputCallbacks.Call();
lagged = false;
byte ret; byte ret;
if (_isVS) if (_isVS)
{ {

View File

@ -3,7 +3,7 @@ using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Nintendo.NES namespace BizHawk.Emulation.Cores.Nintendo.NES
{ {
public sealed partial class PPU public partial class PPU
{ {
public int cpu_step, cpu_stepcounter; public int cpu_step, cpu_stepcounter;
@ -260,6 +260,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
ser.Sync(nameof(yp), ref yp); ser.Sync(nameof(yp), ref yp);
ser.Sync(nameof(target), ref target); ser.Sync(nameof(target), ref target);
ser.Sync(nameof(ppu_was_on), ref ppu_was_on); ser.Sync(nameof(ppu_was_on), ref ppu_was_on);
ser.Sync(nameof(ppu_was_on_spr), ref ppu_was_on_spr);
ser.Sync(nameof(spriteHeight), ref spriteHeight); ser.Sync(nameof(spriteHeight), ref spriteHeight);
ser.Sync(nameof(install_2006), ref install_2006); ser.Sync(nameof(install_2006), ref install_2006);
ser.Sync(nameof(race_2006), ref race_2006); ser.Sync(nameof(race_2006), ref race_2006);
@ -356,6 +357,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
ppu_open_bus = 0; ppu_open_bus = 0;
ppu_open_bus_decay_timer = new int[8]; ppu_open_bus_decay_timer = new int[8];
double_2007_read = 0; double_2007_read = 0;
start_up_offset = 2;
} }
private void runppu() private void runppu()

View File

@ -12,7 +12,7 @@ using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Nintendo.NES namespace BizHawk.Emulation.Cores.Nintendo.NES
{ {
sealed partial class PPU public partial class PPU
{ {
public sealed class Reg_2001 public sealed class Reg_2001
{ {
@ -294,7 +294,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public PPUREGS ppur; public PPUREGS ppur;
public Reg_2000 reg_2000; public Reg_2000 reg_2000;
public Reg_2001 reg_2001; public Reg_2001 reg_2001;
private byte reg_2003; public byte reg_2003;
public byte reg_2006_2; public byte reg_2006_2;
private void regs_reset() private void regs_reset()
@ -436,7 +436,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{ {
OAM[reg_2003] = value; OAM[reg_2003] = value;
reg_2003++; reg_2003++;
} }
} }
else else
{ {

View File

@ -2,11 +2,12 @@
using BizHawk.Common; using BizHawk.Common;
using BizHawk.Common.NumberExtensions; using BizHawk.Common.NumberExtensions;
using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
namespace BizHawk.Emulation.Cores.Nintendo.NES namespace BizHawk.Emulation.Cores.Nintendo.NES
{ {
sealed partial class PPU public partial class PPU
{ {
private struct BGDataRecord private struct BGDataRecord
{ {
@ -36,6 +37,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public int spriteHeight; public int spriteHeight;
public byte[] soam = new byte[256]; // in a real nes, this would only be 32, but we wish to allow more then 8 sprites per scanline public byte[] soam = new byte[256]; // in a real nes, this would only be 32, but we wish to allow more then 8 sprites per scanline
public bool ppu_was_on; public bool ppu_was_on;
public bool ppu_was_on_spr;
public byte[] sl_sprites = new byte[3 * 256]; public byte[] sl_sprites = new byte[3 * 256];
// installing vram address is delayed after second write to 2006, set this up here // installing vram address is delayed after second write to 2006, set this up here
@ -131,7 +133,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
private bool nmi_destiny; private bool nmi_destiny;
private bool evenOddDestiny; private bool evenOddDestiny;
private static readonly int start_up_offset = 2; private int start_up_offset;
private int NMI_offset; private int NMI_offset;
private int yp_shift; private int yp_shift;
private int sprite_eval_cycle; private int sprite_eval_cycle;
@ -524,7 +526,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//check all the conditions that can cause things to render in these 8px //check all the conditions that can cause things to render in these 8px
renderspritenow = show_obj_new && (xt > 0 || reg_2001.show_obj_leftmost); renderspritenow = show_obj_new && (xt > 0 || reg_2001.show_obj_leftmost);
} }
if (ppur.status.cycle > 63)
{
if (ppu_was_on_spr && !PPUON)
{
Console.WriteLine("oam addr glitch " + ppur.status.sl + " " + ppur.status.cycle);
reg_2003++;
}
}
ppu_was_on_spr = PPUON;
} }
else else
{ {