[NES] update savestates
This commit is contained in:
parent
72100bd304
commit
f72be10bd1
|
@ -13,21 +13,14 @@ using System.Diagnostics;
|
|||
|
||||
//TODO - tweak nametable / chr viewer to be more useful
|
||||
|
||||
//FUTURE - we may need to split this into a separate MMC5 class. but for now it is just a pain.
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
class MMC5
|
||||
{
|
||||
NES.NESBoardBase board;
|
||||
public MMC5(NES.NESBoardBase board)
|
||||
{
|
||||
this.board = board;
|
||||
}
|
||||
}
|
||||
|
||||
public class ExROM : NES.NESBoardBase
|
||||
{
|
||||
//configuraton
|
||||
int prg_bank_mask_8k, chr_bank_mask_1k; //board setup (to be isolated from ExROM later into mmc5 class)
|
||||
int prg_bank_mask_8k, chr_bank_mask_1k; //board setup (to be isolated from mmc5 code later, when we need the separate mmc5 class)
|
||||
|
||||
//state
|
||||
int irq_target, irq_counter;
|
||||
|
@ -51,6 +44,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
|||
|
||||
public override void SyncState(Serializer ser)
|
||||
{
|
||||
base.SyncState(ser);
|
||||
ser.Sync("irq_target", ref irq_target);
|
||||
ser.Sync("irq_counter", ref irq_counter);
|
||||
ser.Sync("irq_enabled", ref irq_enabled);
|
||||
|
|
|
@ -27,6 +27,15 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
|||
chr_regs_1k.Dispose();
|
||||
}
|
||||
|
||||
public override void SyncState(Serializer ser)
|
||||
{
|
||||
base.SyncState(ser);
|
||||
ser.Sync("prg_regs_8k", ref prg_regs_8k);
|
||||
ser.Sync("chr_regs_1k", ref chr_regs_1k);
|
||||
ser.Sync("prg_mode", ref chr_regs_1k);
|
||||
ser.Sync("mirror_mode", ref chr_regs_1k);
|
||||
}
|
||||
|
||||
public override bool Configure(NES.EDetectionOrigin origin)
|
||||
{
|
||||
//configure
|
||||
|
|
|
@ -30,6 +30,18 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
|||
chr_regs_1k.Dispose();
|
||||
}
|
||||
|
||||
public override void SyncState(Serializer ser)
|
||||
{
|
||||
base.SyncState(ser);
|
||||
ser.Sync("prg_regs_8k", ref prg_regs_8k);
|
||||
ser.Sync("chr_regs_1k", ref chr_regs_1k);
|
||||
ser.Sync("irq_counter_enabled", ref irq_counter_enabled);
|
||||
ser.Sync("irq_asserted", ref irq_asserted);
|
||||
ser.Sync("irq_counter", ref irq_counter);
|
||||
ser.Sync("irq_reload", ref irq_reload);
|
||||
ser.Sync("clock_counter", ref clock_counter);
|
||||
}
|
||||
|
||||
public override bool Configure(NES.EDetectionOrigin origin)
|
||||
{
|
||||
//configure
|
||||
|
|
|
@ -20,8 +20,14 @@ using System.Diagnostics;
|
|||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
// this is the base class for the MMC3 mapper
|
||||
public class Namcot109 : IDisposable
|
||||
{
|
||||
//state
|
||||
public int chr_mode, prg_mode, reg_addr;
|
||||
ByteBuffer chr_regs_1k = new ByteBuffer(8);
|
||||
ByteBuffer prg_regs_8k = new ByteBuffer(8);
|
||||
|
||||
protected NES.NESBoardBase board;
|
||||
public Namcot109(NES.NESBoardBase board)
|
||||
{
|
||||
|
@ -52,11 +58,14 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
|||
prg_regs_8k.Dispose();
|
||||
}
|
||||
|
||||
//state
|
||||
public int chr_mode, prg_mode, reg_addr;
|
||||
|
||||
ByteBuffer chr_regs_1k = new ByteBuffer(8);
|
||||
ByteBuffer prg_regs_8k = new ByteBuffer(8);
|
||||
public virtual void SyncState(Serializer ser)
|
||||
{
|
||||
ser.Sync("chr_mode", ref chr_mode);
|
||||
ser.Sync("prg_mode", ref prg_mode);
|
||||
ser.Sync("reg_addr", ref reg_addr);
|
||||
ser.Sync("chr_regs_1k", ref chr_regs_1k);
|
||||
ser.Sync("prg_regs_8k", ref prg_regs_8k);
|
||||
}
|
||||
|
||||
public virtual void WritePRG(int addr, byte value)
|
||||
{
|
||||
|
@ -106,16 +115,38 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
|||
|
||||
public class MMC3 : Namcot109
|
||||
{
|
||||
//state
|
||||
public byte mirror;
|
||||
int a12_old;
|
||||
byte irq_reload, irq_counter;
|
||||
bool irq_pending, irq_enable;
|
||||
|
||||
//it really seems like these should be the same but i cant seem to unify them.
|
||||
//theres no sense in delaying the IRQ, so its logic must be tied to the separator.
|
||||
//the hint, of course, is that the countdown value is the same.
|
||||
//will someone else try to unify them?
|
||||
int separator_counter;
|
||||
int irq_countdown;
|
||||
|
||||
public NES.NESBoardBase.EMirrorType MirrorType { get { return mirror == 0 ? NES.NESBoardBase.EMirrorType.Vertical : NES.NESBoardBase.EMirrorType.Horizontal; } }
|
||||
|
||||
public MMC3(NES.NESBoardBase board, int num_prg_banks)
|
||||
: base(board)
|
||||
{
|
||||
}
|
||||
|
||||
//state
|
||||
public NES.NESBoardBase.EMirrorType mirror;
|
||||
int a12_old;
|
||||
byte irq_reload, irq_counter;
|
||||
bool irq_pending, irq_enable;
|
||||
public override void SyncState(Serializer ser)
|
||||
{
|
||||
base.SyncState(ser);
|
||||
ser.Sync("mirror", ref mirror);
|
||||
ser.Sync("mirror", ref a12_old);
|
||||
ser.Sync("irq_reload", ref irq_reload);
|
||||
ser.Sync("irq_counter", ref irq_counter);
|
||||
ser.Sync("irq_pending", ref irq_pending);
|
||||
ser.Sync("irq_enable", ref irq_enable);
|
||||
ser.Sync("separator_counter", ref separator_counter);
|
||||
ser.Sync("irq_countdown", ref irq_countdown);
|
||||
}
|
||||
|
||||
void SyncIRQ()
|
||||
{
|
||||
|
@ -132,9 +163,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
|||
break;
|
||||
case 0x2000: //$A000
|
||||
//mirroring
|
||||
if ((value & 1) == 0) mirror = NES.NESBoardBase.EMirrorType.Vertical;
|
||||
else mirror = NES.NESBoardBase.EMirrorType.Horizontal;
|
||||
board.SetMirrorType(mirror);
|
||||
mirror = (byte)(value & 1);
|
||||
board.SetMirrorType(MirrorType);
|
||||
break;
|
||||
case 0x2001: //$A001
|
||||
//wram enable/protect
|
||||
|
@ -189,13 +219,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
|||
}
|
||||
}
|
||||
|
||||
//it really seems like these should be the same but i cant seem to unify them.
|
||||
//theres no sense in delaying the IRQ, so its logic must be tied to the separator.
|
||||
//the hint, of course, is that the countdown value is the same.
|
||||
//will someone else try to unify them?
|
||||
int separator_counter;
|
||||
int irq_countdown;
|
||||
|
||||
public void ClockPPU()
|
||||
{
|
||||
if (separator_counter > 0)
|
||||
|
@ -237,6 +260,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
|||
|
||||
public abstract class MMC3_Family_Board_Base : NES.NESBoardBase
|
||||
{
|
||||
protected Namcot109 mapper;
|
||||
|
||||
//configuration
|
||||
protected int prg_mask, chr_mask;
|
||||
|
||||
|
@ -245,7 +270,11 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
|||
mapper.Dispose();
|
||||
}
|
||||
|
||||
protected Namcot109 mapper;
|
||||
public override void SyncState(Serializer ser)
|
||||
{
|
||||
base.SyncState(ser);
|
||||
mapper.SyncState(ser);
|
||||
}
|
||||
|
||||
int MapCHR(int addr)
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
|||
public override void WritePRG(int addr, byte value)
|
||||
{
|
||||
base.WritePRG(addr, value);
|
||||
SetMirrorType(mmc3.mirror); //often redundant, but gets the job done
|
||||
SetMirrorType(mmc3.MirrorType); //often redundant, but gets the job done
|
||||
}
|
||||
|
||||
public override byte[] SaveRam
|
||||
|
|
|
@ -28,6 +28,16 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
|||
prg_regs_16k.Dispose();
|
||||
}
|
||||
|
||||
public override void SyncState(Serializer ser)
|
||||
{
|
||||
base.SyncState(ser);
|
||||
ser.Sync("chr_regs_2k", ref chr_regs_2k);
|
||||
ser.Sync("nt_regs", ref nt_regs);
|
||||
ser.Sync("prg_regs_16k", ref prg_regs_16k);
|
||||
ser.Sync("flag_m", ref flag_m);
|
||||
ser.Sync("flag_r", ref flag_r);
|
||||
}
|
||||
|
||||
public override bool Configure(NES.EDetectionOrigin origin)
|
||||
{
|
||||
//configure
|
||||
|
|
|
@ -28,6 +28,14 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
|||
chr_regs_1k.Dispose();
|
||||
}
|
||||
|
||||
public override void SyncState(Serializer ser)
|
||||
{
|
||||
base.SyncState(ser);
|
||||
ser.Sync("prg_regs_8k", ref prg_regs_8k);
|
||||
ser.Sync("chr_regs_1k", ref chr_regs_1k);
|
||||
ser.Sync("mirror_mode", ref mirror_mode);
|
||||
}
|
||||
|
||||
public override bool Configure(NES.EDetectionOrigin origin)
|
||||
{
|
||||
//configure
|
||||
|
|
Loading…
Reference in New Issue