more misc cleanup and removing some usings that should have been removed when moving things from one project to another
This commit is contained in:
parent
00308de99a
commit
e606429219
|
@ -2,115 +2,115 @@
|
|||
|
||||
namespace BizHawk.Emulation.Common.Components.M68000
|
||||
{
|
||||
public sealed class DisassemblyInfo
|
||||
{
|
||||
public int PC;
|
||||
public string Mnemonic;
|
||||
public string Args;
|
||||
public string RawBytes;
|
||||
public int Length;
|
||||
public sealed class DisassemblyInfo
|
||||
{
|
||||
public int PC;
|
||||
public string Mnemonic;
|
||||
public string Args;
|
||||
public string RawBytes;
|
||||
public int Length;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0:X6}: {3,-20} {1,-8} {2}", PC, Mnemonic, Args, RawBytes);
|
||||
}
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0:X6}: {3,-20} {1,-8} {2}", PC, Mnemonic, Args, RawBytes);
|
||||
}
|
||||
}
|
||||
|
||||
partial class MC68000
|
||||
{
|
||||
public DisassemblyInfo Disassemble(int pc)
|
||||
{
|
||||
var info = new DisassemblyInfo { Mnemonic = "UNKNOWN", PC = pc, Length = 2 };
|
||||
op = (ushort)ReadWord(pc);
|
||||
partial class MC68000
|
||||
{
|
||||
public DisassemblyInfo Disassemble(int pc)
|
||||
{
|
||||
var info = new DisassemblyInfo { Mnemonic = "UNKNOWN", PC = pc, Length = 2 };
|
||||
op = (ushort)ReadWord(pc);
|
||||
|
||||
if (Opcodes[op] == MOVE) MOVE_Disasm(info);
|
||||
else if (Opcodes[op] == MOVEA) MOVEA_Disasm(info);
|
||||
else if (Opcodes[op] == MOVEQ) MOVEQ_Disasm(info);
|
||||
else if (Opcodes[op] == MOVEM0) MOVEM0_Disasm(info);
|
||||
else if (Opcodes[op] == MOVEM1) MOVEM1_Disasm(info);
|
||||
else if (Opcodes[op] == LEA) LEA_Disasm(info);
|
||||
else if (Opcodes[op] == CLR) CLR_Disasm(info);
|
||||
else if (Opcodes[op] == EXT) EXT_Disasm(info);
|
||||
else if (Opcodes[op] == PEA) PEA_Disasm(info);
|
||||
if (Opcodes[op] == MOVE) MOVE_Disasm(info);
|
||||
else if (Opcodes[op] == MOVEA) MOVEA_Disasm(info);
|
||||
else if (Opcodes[op] == MOVEQ) MOVEQ_Disasm(info);
|
||||
else if (Opcodes[op] == MOVEM0) MOVEM0_Disasm(info);
|
||||
else if (Opcodes[op] == MOVEM1) MOVEM1_Disasm(info);
|
||||
else if (Opcodes[op] == LEA) LEA_Disasm(info);
|
||||
else if (Opcodes[op] == CLR) CLR_Disasm(info);
|
||||
else if (Opcodes[op] == EXT) EXT_Disasm(info);
|
||||
else if (Opcodes[op] == PEA) PEA_Disasm(info);
|
||||
|
||||
else if (Opcodes[op] == ANDI) ANDI_Disasm(info);
|
||||
else if (Opcodes[op] == EORI) EORI_Disasm(info);
|
||||
else if (Opcodes[op] == ORI) ORI_Disasm(info);
|
||||
else if (Opcodes[op] == ASLd) ASLd_Disasm(info);
|
||||
else if (Opcodes[op] == ASRd) ASRd_Disasm(info);
|
||||
else if (Opcodes[op] == LSLd) LSLd_Disasm(info);
|
||||
else if (Opcodes[op] == LSRd) LSRd_Disasm(info);
|
||||
else if (Opcodes[op] == ROXLd) ROXLd_Disasm(info);
|
||||
else if (Opcodes[op] == ROXRd) ROXRd_Disasm(info);
|
||||
else if (Opcodes[op] == ROLd) ROLd_Disasm(info);
|
||||
else if (Opcodes[op] == RORd) RORd_Disasm(info);
|
||||
else if (Opcodes[op] == SWAP) SWAP_Disasm(info);
|
||||
else if (Opcodes[op] == AND0) AND0_Disasm(info);
|
||||
else if (Opcodes[op] == AND1) AND1_Disasm(info);
|
||||
else if (Opcodes[op] == EOR) EOR_Disasm(info);
|
||||
else if (Opcodes[op] == OR0) OR0_Disasm(info);
|
||||
else if (Opcodes[op] == OR1) OR1_Disasm(info);
|
||||
else if (Opcodes[op] == NOT) NOT_Disasm(info);
|
||||
else if (Opcodes[op] == NEG) NEG_Disasm(info);
|
||||
else if (Opcodes[op] == ANDI) ANDI_Disasm(info);
|
||||
else if (Opcodes[op] == EORI) EORI_Disasm(info);
|
||||
else if (Opcodes[op] == ORI) ORI_Disasm(info);
|
||||
else if (Opcodes[op] == ASLd) ASLd_Disasm(info);
|
||||
else if (Opcodes[op] == ASRd) ASRd_Disasm(info);
|
||||
else if (Opcodes[op] == LSLd) LSLd_Disasm(info);
|
||||
else if (Opcodes[op] == LSRd) LSRd_Disasm(info);
|
||||
else if (Opcodes[op] == ROXLd) ROXLd_Disasm(info);
|
||||
else if (Opcodes[op] == ROXRd) ROXRd_Disasm(info);
|
||||
else if (Opcodes[op] == ROLd) ROLd_Disasm(info);
|
||||
else if (Opcodes[op] == RORd) RORd_Disasm(info);
|
||||
else if (Opcodes[op] == SWAP) SWAP_Disasm(info);
|
||||
else if (Opcodes[op] == AND0) AND0_Disasm(info);
|
||||
else if (Opcodes[op] == AND1) AND1_Disasm(info);
|
||||
else if (Opcodes[op] == EOR) EOR_Disasm(info);
|
||||
else if (Opcodes[op] == OR0) OR0_Disasm(info);
|
||||
else if (Opcodes[op] == OR1) OR1_Disasm(info);
|
||||
else if (Opcodes[op] == NOT) NOT_Disasm(info);
|
||||
else if (Opcodes[op] == NEG) NEG_Disasm(info);
|
||||
|
||||
else if (Opcodes[op] == JMP) JMP_Disasm(info);
|
||||
else if (Opcodes[op] == JSR) JSR_Disasm(info);
|
||||
else if (Opcodes[op] == Bcc) Bcc_Disasm(info);
|
||||
else if (Opcodes[op] == BRA) BRA_Disasm(info);
|
||||
else if (Opcodes[op] == BSR) BSR_Disasm(info);
|
||||
else if (Opcodes[op] == DBcc) DBcc_Disasm(info);
|
||||
else if (Opcodes[op] == Scc) Scc_Disasm(info);
|
||||
else if (Opcodes[op] == RTE) RTE_Disasm(info);
|
||||
else if (Opcodes[op] == RTS) RTS_Disasm(info);
|
||||
else if (Opcodes[op] == RTR) RTR_Disasm(info);
|
||||
else if (Opcodes[op] == TST) TST_Disasm(info);
|
||||
else if (Opcodes[op] == BTSTi) BTSTi_Disasm(info);
|
||||
else if (Opcodes[op] == BTSTr) BTSTr_Disasm(info);
|
||||
else if (Opcodes[op] == BCHGi) BCHGi_Disasm(info);
|
||||
else if (Opcodes[op] == BCHGr) BCHGr_Disasm(info);
|
||||
else if (Opcodes[op] == BCLRi) BCLRi_Disasm(info);
|
||||
else if (Opcodes[op] == BCLRr) BCLRr_Disasm(info);
|
||||
else if (Opcodes[op] == BSETi) BSETi_Disasm(info);
|
||||
else if (Opcodes[op] == BSETr) BSETr_Disasm(info);
|
||||
else if (Opcodes[op] == LINK) LINK_Disasm(info);
|
||||
else if (Opcodes[op] == UNLK) UNLK_Disasm(info);
|
||||
else if (Opcodes[op] == NOP) NOP_Disasm(info);
|
||||
else if (Opcodes[op] == JMP) JMP_Disasm(info);
|
||||
else if (Opcodes[op] == JSR) JSR_Disasm(info);
|
||||
else if (Opcodes[op] == Bcc) Bcc_Disasm(info);
|
||||
else if (Opcodes[op] == BRA) BRA_Disasm(info);
|
||||
else if (Opcodes[op] == BSR) BSR_Disasm(info);
|
||||
else if (Opcodes[op] == DBcc) DBcc_Disasm(info);
|
||||
else if (Opcodes[op] == Scc) Scc_Disasm(info);
|
||||
else if (Opcodes[op] == RTE) RTE_Disasm(info);
|
||||
else if (Opcodes[op] == RTS) RTS_Disasm(info);
|
||||
else if (Opcodes[op] == RTR) RTR_Disasm(info);
|
||||
else if (Opcodes[op] == TST) TST_Disasm(info);
|
||||
else if (Opcodes[op] == BTSTi) BTSTi_Disasm(info);
|
||||
else if (Opcodes[op] == BTSTr) BTSTr_Disasm(info);
|
||||
else if (Opcodes[op] == BCHGi) BCHGi_Disasm(info);
|
||||
else if (Opcodes[op] == BCHGr) BCHGr_Disasm(info);
|
||||
else if (Opcodes[op] == BCLRi) BCLRi_Disasm(info);
|
||||
else if (Opcodes[op] == BCLRr) BCLRr_Disasm(info);
|
||||
else if (Opcodes[op] == BSETi) BSETi_Disasm(info);
|
||||
else if (Opcodes[op] == BSETr) BSETr_Disasm(info);
|
||||
else if (Opcodes[op] == LINK) LINK_Disasm(info);
|
||||
else if (Opcodes[op] == UNLK) UNLK_Disasm(info);
|
||||
else if (Opcodes[op] == NOP) NOP_Disasm(info);
|
||||
|
||||
else if (Opcodes[op] == ADD0) ADD_Disasm(info);
|
||||
else if (Opcodes[op] == ADD1) ADD_Disasm(info);
|
||||
else if (Opcodes[op] == ADDA) ADDA_Disasm(info);
|
||||
else if (Opcodes[op] == ADDI) ADDI_Disasm(info);
|
||||
else if (Opcodes[op] == ADDQ) ADDQ_Disasm(info);
|
||||
else if (Opcodes[op] == SUB0) SUB_Disasm(info);
|
||||
else if (Opcodes[op] == SUB1) SUB_Disasm(info);
|
||||
else if (Opcodes[op] == SUBA) SUBA_Disasm(info);
|
||||
else if (Opcodes[op] == SUBI) SUBI_Disasm(info);
|
||||
else if (Opcodes[op] == SUBQ) SUBQ_Disasm(info);
|
||||
else if (Opcodes[op] == CMP) CMP_Disasm(info);
|
||||
else if (Opcodes[op] == CMPM) CMPM_Disasm(info);
|
||||
else if (Opcodes[op] == CMPA) CMPA_Disasm(info);
|
||||
else if (Opcodes[op] == ADD0) ADD_Disasm(info);
|
||||
else if (Opcodes[op] == ADD1) ADD_Disasm(info);
|
||||
else if (Opcodes[op] == ADDA) ADDA_Disasm(info);
|
||||
else if (Opcodes[op] == ADDI) ADDI_Disasm(info);
|
||||
else if (Opcodes[op] == ADDQ) ADDQ_Disasm(info);
|
||||
else if (Opcodes[op] == SUB0) SUB_Disasm(info);
|
||||
else if (Opcodes[op] == SUB1) SUB_Disasm(info);
|
||||
else if (Opcodes[op] == SUBA) SUBA_Disasm(info);
|
||||
else if (Opcodes[op] == SUBI) SUBI_Disasm(info);
|
||||
else if (Opcodes[op] == SUBQ) SUBQ_Disasm(info);
|
||||
else if (Opcodes[op] == CMP) CMP_Disasm(info);
|
||||
else if (Opcodes[op] == CMPM) CMPM_Disasm(info);
|
||||
else if (Opcodes[op] == CMPA) CMPA_Disasm(info);
|
||||
|
||||
else if (Opcodes[op] == CMPI) CMPI_Disasm(info);
|
||||
else if (Opcodes[op] == MULU) MULU_Disasm(info);
|
||||
else if (Opcodes[op] == MULS) MULS_Disasm(info);
|
||||
else if (Opcodes[op] == DIVU) DIVU_Disasm(info);
|
||||
else if (Opcodes[op] == DIVS) DIVS_Disasm(info);
|
||||
else if (Opcodes[op] == CMPI) CMPI_Disasm(info);
|
||||
else if (Opcodes[op] == MULU) MULU_Disasm(info);
|
||||
else if (Opcodes[op] == MULS) MULS_Disasm(info);
|
||||
else if (Opcodes[op] == DIVU) DIVU_Disasm(info);
|
||||
else if (Opcodes[op] == DIVS) DIVS_Disasm(info);
|
||||
|
||||
else if (Opcodes[op] == MOVEtSR) MOVEtSR_Disasm(info);
|
||||
else if (Opcodes[op] == MOVEfSR) MOVEfSR_Disasm(info);
|
||||
else if (Opcodes[op] == MOVEUSP) MOVEUSP_Disasm(info);
|
||||
else if (Opcodes[op] == ANDI_SR) ANDI_SR_Disasm(info);
|
||||
else if (Opcodes[op] == EORI_SR) EORI_SR_Disasm(info);
|
||||
else if (Opcodes[op] == ORI_SR) ORI_SR_Disasm(info);
|
||||
else if (Opcodes[op] == MOVECCR) MOVECCR_Disasm(info);
|
||||
else if (Opcodes[op] == TRAP) TRAP_Disasm(info);
|
||||
else if (Opcodes[op] == MOVEtSR) MOVEtSR_Disasm(info);
|
||||
else if (Opcodes[op] == MOVEfSR) MOVEfSR_Disasm(info);
|
||||
else if (Opcodes[op] == MOVEUSP) MOVEUSP_Disasm(info);
|
||||
else if (Opcodes[op] == ANDI_SR) ANDI_SR_Disasm(info);
|
||||
else if (Opcodes[op] == EORI_SR) EORI_SR_Disasm(info);
|
||||
else if (Opcodes[op] == ORI_SR) ORI_SR_Disasm(info);
|
||||
else if (Opcodes[op] == MOVECCR) MOVECCR_Disasm(info);
|
||||
else if (Opcodes[op] == TRAP) TRAP_Disasm(info);
|
||||
|
||||
var sb = new StringBuilder();
|
||||
for (int p = info.PC; p < info.PC + info.Length; p++)
|
||||
sb.AppendFormat("{0:X2}", ReadByte(p));
|
||||
info.RawBytes = sb.ToString();
|
||||
var sb = new StringBuilder();
|
||||
for (int p = info.PC; p < info.PC + info.Length; p++)
|
||||
sb.AppendFormat("{0:X2}", ReadByte(p));
|
||||
info.RawBytes = sb.ToString();
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Common.Components.CP1610
|
|||
|
||||
private bool FlagS, FlagC, FlagZ, FlagO, FlagI, FlagD, IntRM, BusRq, BusAk, Interruptible, Interrupted;
|
||||
//private bool MSync;
|
||||
private ushort[] Register = new ushort[8];
|
||||
private readonly ushort[] Register = new ushort[8];
|
||||
private ushort RegisterSP { get { return Register[6]; } set { Register[6] = value; } }
|
||||
private ushort RegisterPC { get { return Register[7]; } set { Register[7] = value; } }
|
||||
|
||||
|
@ -21,7 +21,7 @@ namespace BizHawk.Emulation.Common.Components.CP1610
|
|||
public Func<ushort, ushort, bool> WriteMemory;
|
||||
|
||||
private static bool Logging = true;
|
||||
private static StreamWriter Log;
|
||||
private static readonly StreamWriter Log;
|
||||
|
||||
static CP1610()
|
||||
{
|
||||
|
|
|
@ -185,7 +185,7 @@ namespace BizHawk.Emulation.Common.Components.CP1610
|
|||
// Unknown opcode.
|
||||
throw new ArgumentException();
|
||||
}
|
||||
RegisterPC = (ushort)addr;
|
||||
RegisterPC = addr;
|
||||
cycles = 12;
|
||||
Interruptible = true;
|
||||
break;
|
||||
|
|
|
@ -6,398 +6,398 @@ using BizHawk.Common;
|
|||
|
||||
namespace BizHawk.Emulation.Common.Components.H6280
|
||||
{
|
||||
public sealed partial class HuC6280
|
||||
{
|
||||
public HuC6280()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
public sealed partial class HuC6280
|
||||
{
|
||||
public HuC6280()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
A = 0;
|
||||
X = 0;
|
||||
Y = 0;
|
||||
//P = 0x14; // Set I and B
|
||||
P = 0x04; // Set I
|
||||
S = 0;
|
||||
PC = 0;
|
||||
PendingCycles = 0;
|
||||
TotalExecutedCycles = 0;
|
||||
LagIFlag = true;
|
||||
LowSpeed = true;
|
||||
}
|
||||
public void Reset()
|
||||
{
|
||||
A = 0;
|
||||
X = 0;
|
||||
Y = 0;
|
||||
//P = 0x14; // Set I and B
|
||||
P = 0x04; // Set I
|
||||
S = 0;
|
||||
PC = 0;
|
||||
PendingCycles = 0;
|
||||
TotalExecutedCycles = 0;
|
||||
LagIFlag = true;
|
||||
LowSpeed = true;
|
||||
}
|
||||
|
||||
public void ResetPC()
|
||||
{
|
||||
PC = ReadWord(ResetVector);
|
||||
}
|
||||
public void ResetPC()
|
||||
{
|
||||
PC = ReadWord(ResetVector);
|
||||
}
|
||||
|
||||
// ==== CPU State ====
|
||||
// ==== CPU State ====
|
||||
|
||||
public byte A;
|
||||
public byte X;
|
||||
public byte Y;
|
||||
public byte P;
|
||||
public ushort PC;
|
||||
public byte S;
|
||||
public byte[] MPR = new byte[8];
|
||||
public byte A;
|
||||
public byte X;
|
||||
public byte Y;
|
||||
public byte P;
|
||||
public ushort PC;
|
||||
public byte S;
|
||||
public byte[] MPR = new byte[8];
|
||||
|
||||
public bool LagIFlag;
|
||||
public bool IRQ1Assert;
|
||||
public bool IRQ2Assert;
|
||||
public bool TimerAssert;
|
||||
public byte IRQControlByte, IRQNextControlByte;
|
||||
public bool LagIFlag;
|
||||
public bool IRQ1Assert;
|
||||
public bool IRQ2Assert;
|
||||
public bool TimerAssert;
|
||||
public byte IRQControlByte, IRQNextControlByte;
|
||||
|
||||
public long TotalExecutedCycles;
|
||||
public int PendingCycles;
|
||||
public bool LowSpeed;
|
||||
public long TotalExecutedCycles;
|
||||
public int PendingCycles;
|
||||
public bool LowSpeed;
|
||||
|
||||
private bool InBlockTransfer = false;
|
||||
private ushort btFrom;
|
||||
private ushort btTo;
|
||||
private ushort btLen;
|
||||
private int btAlternator;
|
||||
private bool InBlockTransfer = false;
|
||||
private ushort btFrom;
|
||||
private ushort btTo;
|
||||
private ushort btLen;
|
||||
private int btAlternator;
|
||||
|
||||
// -- Timer Support --
|
||||
// -- Timer Support --
|
||||
|
||||
public int TimerTickCounter;
|
||||
public byte TimerReloadValue;
|
||||
public byte TimerValue;
|
||||
public bool TimerEnabled;
|
||||
public int TimerTickCounter;
|
||||
public byte TimerReloadValue;
|
||||
public byte TimerValue;
|
||||
public bool TimerEnabled;
|
||||
|
||||
public void SaveStateText(TextWriter writer)
|
||||
{
|
||||
writer.WriteLine("[HuC6280]");
|
||||
writer.WriteLine("A {0:X2}", A);
|
||||
writer.WriteLine("X {0:X2}", X);
|
||||
writer.WriteLine("Y {0:X2}", Y);
|
||||
writer.WriteLine("P {0:X2}", P);
|
||||
writer.WriteLine("PC {0:X4}", PC);
|
||||
writer.WriteLine("S {0:X2}", S);
|
||||
writer.Write("MPR ");
|
||||
MPR.SaveAsHex(writer);
|
||||
writer.WriteLine("LagIFlag {0}", LagIFlag);
|
||||
writer.WriteLine("IRQ1Assert {0}", IRQ1Assert);
|
||||
writer.WriteLine("IRQ2Assert {0}", IRQ2Assert);
|
||||
writer.WriteLine("TimerAssert {0}", TimerAssert);
|
||||
writer.WriteLine("IRQControlByte {0:X2}", IRQControlByte);
|
||||
writer.WriteLine("IRQNextControlByte {0:X2}", IRQNextControlByte);
|
||||
writer.WriteLine("ExecutedCycles {0}", TotalExecutedCycles);
|
||||
writer.WriteLine("PendingCycles {0}", PendingCycles);
|
||||
writer.WriteLine("LowSpeed {0}", LowSpeed);
|
||||
writer.WriteLine("TimerTickCounter {0}", TimerTickCounter);
|
||||
writer.WriteLine("TimerReloadValue {0}", TimerReloadValue);
|
||||
writer.WriteLine("TimerValue {0}", TimerValue);
|
||||
writer.WriteLine("TimerEnabled {0}", TimerEnabled);
|
||||
writer.WriteLine("InBlockTransfer {0}", InBlockTransfer);
|
||||
writer.WriteLine("BTFrom {0}", btFrom);
|
||||
writer.WriteLine("BTTo {0}", btTo);
|
||||
writer.WriteLine("BTLen {0}", btLen);
|
||||
writer.WriteLine("BTAlternator {0}", btAlternator);
|
||||
writer.WriteLine("[/HuC6280]\n");
|
||||
}
|
||||
public void SaveStateText(TextWriter writer)
|
||||
{
|
||||
writer.WriteLine("[HuC6280]");
|
||||
writer.WriteLine("A {0:X2}", A);
|
||||
writer.WriteLine("X {0:X2}", X);
|
||||
writer.WriteLine("Y {0:X2}", Y);
|
||||
writer.WriteLine("P {0:X2}", P);
|
||||
writer.WriteLine("PC {0:X4}", PC);
|
||||
writer.WriteLine("S {0:X2}", S);
|
||||
writer.Write("MPR ");
|
||||
MPR.SaveAsHex(writer);
|
||||
writer.WriteLine("LagIFlag {0}", LagIFlag);
|
||||
writer.WriteLine("IRQ1Assert {0}", IRQ1Assert);
|
||||
writer.WriteLine("IRQ2Assert {0}", IRQ2Assert);
|
||||
writer.WriteLine("TimerAssert {0}", TimerAssert);
|
||||
writer.WriteLine("IRQControlByte {0:X2}", IRQControlByte);
|
||||
writer.WriteLine("IRQNextControlByte {0:X2}", IRQNextControlByte);
|
||||
writer.WriteLine("ExecutedCycles {0}", TotalExecutedCycles);
|
||||
writer.WriteLine("PendingCycles {0}", PendingCycles);
|
||||
writer.WriteLine("LowSpeed {0}", LowSpeed);
|
||||
writer.WriteLine("TimerTickCounter {0}", TimerTickCounter);
|
||||
writer.WriteLine("TimerReloadValue {0}", TimerReloadValue);
|
||||
writer.WriteLine("TimerValue {0}", TimerValue);
|
||||
writer.WriteLine("TimerEnabled {0}", TimerEnabled);
|
||||
writer.WriteLine("InBlockTransfer {0}", InBlockTransfer);
|
||||
writer.WriteLine("BTFrom {0}", btFrom);
|
||||
writer.WriteLine("BTTo {0}", btTo);
|
||||
writer.WriteLine("BTLen {0}", btLen);
|
||||
writer.WriteLine("BTAlternator {0}", btAlternator);
|
||||
writer.WriteLine("[/HuC6280]\n");
|
||||
}
|
||||
|
||||
public void LoadStateText(TextReader reader)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
string[] args = reader.ReadLine().Split(' ');
|
||||
if (args[0].Trim() == "") continue;
|
||||
if (args[0] == "[/HuC6280]") break;
|
||||
if (args[0] == "A")
|
||||
A = byte.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "X")
|
||||
X = byte.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "Y")
|
||||
Y = byte.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "P")
|
||||
P = byte.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "PC")
|
||||
PC = ushort.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "S")
|
||||
S = byte.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "MPR")
|
||||
MPR.ReadFromHex(args[1]);
|
||||
else if (args[0] == "LagIFlag")
|
||||
LagIFlag = bool.Parse(args[1]);
|
||||
else if (args[0] == "IRQ1Assert")
|
||||
IRQ1Assert = bool.Parse(args[1]);
|
||||
else if (args[0] == "IRQ2Assert")
|
||||
IRQ2Assert = bool.Parse(args[1]);
|
||||
else if (args[0] == "TimerAssert")
|
||||
TimerAssert = bool.Parse(args[1]);
|
||||
else if (args[0] == "IRQControlByte")
|
||||
IRQControlByte = byte.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "IRQNextControlByte")
|
||||
IRQNextControlByte = byte.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "ExecutedCycles")
|
||||
TotalExecutedCycles = long.Parse(args[1]);
|
||||
else if (args[0] == "PendingCycles")
|
||||
PendingCycles = int.Parse(args[1]);
|
||||
else if (args[0] == "LowSpeed")
|
||||
LowSpeed = bool.Parse(args[1]);
|
||||
else if (args[0] == "TimerTickCounter")
|
||||
TimerTickCounter = int.Parse(args[1]);
|
||||
else if (args[0] == "TimerReloadValue")
|
||||
TimerReloadValue = byte.Parse(args[1]);
|
||||
else if (args[0] == "TimerValue")
|
||||
TimerValue = byte.Parse(args[1]);
|
||||
else if (args[0] == "TimerEnabled")
|
||||
TimerEnabled = bool.Parse(args[1]);
|
||||
else if (args[0] == "InBlockTransfer")
|
||||
InBlockTransfer = bool.Parse(args[1]);
|
||||
else if (args[0] == "BTFrom")
|
||||
btFrom = ushort.Parse(args[1]);
|
||||
else if (args[0] == "BTTo")
|
||||
btTo = ushort.Parse(args[1]);
|
||||
else if (args[0] == "BTLen")
|
||||
btLen = ushort.Parse(args[1]);
|
||||
else if (args[0] == "BTAlternator")
|
||||
btAlternator = int.Parse(args[1]);
|
||||
else
|
||||
Console.WriteLine("Skipping unrecognized identifier " + args[0]);
|
||||
}
|
||||
}
|
||||
public void LoadStateText(TextReader reader)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
string[] args = reader.ReadLine().Split(' ');
|
||||
if (args[0].Trim() == "") continue;
|
||||
if (args[0] == "[/HuC6280]") break;
|
||||
if (args[0] == "A")
|
||||
A = byte.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "X")
|
||||
X = byte.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "Y")
|
||||
Y = byte.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "P")
|
||||
P = byte.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "PC")
|
||||
PC = ushort.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "S")
|
||||
S = byte.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "MPR")
|
||||
MPR.ReadFromHex(args[1]);
|
||||
else if (args[0] == "LagIFlag")
|
||||
LagIFlag = bool.Parse(args[1]);
|
||||
else if (args[0] == "IRQ1Assert")
|
||||
IRQ1Assert = bool.Parse(args[1]);
|
||||
else if (args[0] == "IRQ2Assert")
|
||||
IRQ2Assert = bool.Parse(args[1]);
|
||||
else if (args[0] == "TimerAssert")
|
||||
TimerAssert = bool.Parse(args[1]);
|
||||
else if (args[0] == "IRQControlByte")
|
||||
IRQControlByte = byte.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "IRQNextControlByte")
|
||||
IRQNextControlByte = byte.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "ExecutedCycles")
|
||||
TotalExecutedCycles = long.Parse(args[1]);
|
||||
else if (args[0] == "PendingCycles")
|
||||
PendingCycles = int.Parse(args[1]);
|
||||
else if (args[0] == "LowSpeed")
|
||||
LowSpeed = bool.Parse(args[1]);
|
||||
else if (args[0] == "TimerTickCounter")
|
||||
TimerTickCounter = int.Parse(args[1]);
|
||||
else if (args[0] == "TimerReloadValue")
|
||||
TimerReloadValue = byte.Parse(args[1]);
|
||||
else if (args[0] == "TimerValue")
|
||||
TimerValue = byte.Parse(args[1]);
|
||||
else if (args[0] == "TimerEnabled")
|
||||
TimerEnabled = bool.Parse(args[1]);
|
||||
else if (args[0] == "InBlockTransfer")
|
||||
InBlockTransfer = bool.Parse(args[1]);
|
||||
else if (args[0] == "BTFrom")
|
||||
btFrom = ushort.Parse(args[1]);
|
||||
else if (args[0] == "BTTo")
|
||||
btTo = ushort.Parse(args[1]);
|
||||
else if (args[0] == "BTLen")
|
||||
btLen = ushort.Parse(args[1]);
|
||||
else if (args[0] == "BTAlternator")
|
||||
btAlternator = int.Parse(args[1]);
|
||||
else
|
||||
Console.WriteLine("Skipping unrecognized identifier " + args[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveStateBinary(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(A);
|
||||
writer.Write(X);
|
||||
writer.Write(Y);
|
||||
writer.Write(P);
|
||||
writer.Write(PC);
|
||||
writer.Write(S);
|
||||
writer.Write(MPR);
|
||||
writer.Write(LagIFlag);
|
||||
writer.Write(IRQ1Assert);
|
||||
writer.Write(IRQ2Assert);
|
||||
writer.Write(TimerAssert);
|
||||
writer.Write(IRQControlByte);
|
||||
writer.Write(IRQNextControlByte);
|
||||
writer.Write(TotalExecutedCycles);
|
||||
writer.Write(PendingCycles);
|
||||
writer.Write(LowSpeed);
|
||||
public void SaveStateBinary(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(A);
|
||||
writer.Write(X);
|
||||
writer.Write(Y);
|
||||
writer.Write(P);
|
||||
writer.Write(PC);
|
||||
writer.Write(S);
|
||||
writer.Write(MPR);
|
||||
writer.Write(LagIFlag);
|
||||
writer.Write(IRQ1Assert);
|
||||
writer.Write(IRQ2Assert);
|
||||
writer.Write(TimerAssert);
|
||||
writer.Write(IRQControlByte);
|
||||
writer.Write(IRQNextControlByte);
|
||||
writer.Write(TotalExecutedCycles);
|
||||
writer.Write(PendingCycles);
|
||||
writer.Write(LowSpeed);
|
||||
|
||||
writer.Write(TimerTickCounter);
|
||||
writer.Write(TimerReloadValue);
|
||||
writer.Write(TimerValue);
|
||||
writer.Write(TimerEnabled);
|
||||
writer.Write(TimerTickCounter);
|
||||
writer.Write(TimerReloadValue);
|
||||
writer.Write(TimerValue);
|
||||
writer.Write(TimerEnabled);
|
||||
|
||||
writer.Write(InBlockTransfer);
|
||||
writer.Write(btFrom);
|
||||
writer.Write(btTo);
|
||||
writer.Write(btLen);
|
||||
writer.Write((byte)btAlternator);
|
||||
}
|
||||
writer.Write(InBlockTransfer);
|
||||
writer.Write(btFrom);
|
||||
writer.Write(btTo);
|
||||
writer.Write(btLen);
|
||||
writer.Write((byte)btAlternator);
|
||||
}
|
||||
|
||||
public void LoadStateBinary(BinaryReader reader)
|
||||
{
|
||||
A = reader.ReadByte();
|
||||
X = reader.ReadByte();
|
||||
Y = reader.ReadByte();
|
||||
P = reader.ReadByte();
|
||||
PC = reader.ReadUInt16();
|
||||
S = reader.ReadByte();
|
||||
MPR = reader.ReadBytes(8);
|
||||
LagIFlag = reader.ReadBoolean();
|
||||
IRQ1Assert = reader.ReadBoolean();
|
||||
IRQ2Assert = reader.ReadBoolean();
|
||||
TimerAssert = reader.ReadBoolean();
|
||||
IRQControlByte = reader.ReadByte();
|
||||
IRQNextControlByte = reader.ReadByte();
|
||||
TotalExecutedCycles = reader.ReadInt64();
|
||||
PendingCycles = reader.ReadInt32();
|
||||
LowSpeed = reader.ReadBoolean();
|
||||
public void LoadStateBinary(BinaryReader reader)
|
||||
{
|
||||
A = reader.ReadByte();
|
||||
X = reader.ReadByte();
|
||||
Y = reader.ReadByte();
|
||||
P = reader.ReadByte();
|
||||
PC = reader.ReadUInt16();
|
||||
S = reader.ReadByte();
|
||||
MPR = reader.ReadBytes(8);
|
||||
LagIFlag = reader.ReadBoolean();
|
||||
IRQ1Assert = reader.ReadBoolean();
|
||||
IRQ2Assert = reader.ReadBoolean();
|
||||
TimerAssert = reader.ReadBoolean();
|
||||
IRQControlByte = reader.ReadByte();
|
||||
IRQNextControlByte = reader.ReadByte();
|
||||
TotalExecutedCycles = reader.ReadInt64();
|
||||
PendingCycles = reader.ReadInt32();
|
||||
LowSpeed = reader.ReadBoolean();
|
||||
|
||||
TimerTickCounter = reader.ReadInt32();
|
||||
TimerReloadValue = reader.ReadByte();
|
||||
TimerValue = reader.ReadByte();
|
||||
TimerEnabled = reader.ReadBoolean();
|
||||
TimerTickCounter = reader.ReadInt32();
|
||||
TimerReloadValue = reader.ReadByte();
|
||||
TimerValue = reader.ReadByte();
|
||||
TimerEnabled = reader.ReadBoolean();
|
||||
|
||||
InBlockTransfer = reader.ReadBoolean();
|
||||
btFrom = reader.ReadUInt16();
|
||||
btTo = reader.ReadUInt16();
|
||||
btLen = reader.ReadUInt16();
|
||||
btAlternator = reader.ReadByte();
|
||||
}
|
||||
InBlockTransfer = reader.ReadBoolean();
|
||||
btFrom = reader.ReadUInt16();
|
||||
btTo = reader.ReadUInt16();
|
||||
btLen = reader.ReadUInt16();
|
||||
btAlternator = reader.ReadByte();
|
||||
}
|
||||
|
||||
// ==== Interrupts ====
|
||||
// ==== Interrupts ====
|
||||
|
||||
private const ushort ResetVector = 0xFFFE;
|
||||
private const ushort NMIVector = 0xFFFC;
|
||||
private const ushort TimerVector = 0xFFFA;
|
||||
private const ushort IRQ1Vector = 0xFFF8;
|
||||
private const ushort IRQ2Vector = 0xFFF6;
|
||||
private const ushort ResetVector = 0xFFFE;
|
||||
private const ushort NMIVector = 0xFFFC;
|
||||
private const ushort TimerVector = 0xFFFA;
|
||||
private const ushort IRQ1Vector = 0xFFF8;
|
||||
private const ushort IRQ2Vector = 0xFFF6;
|
||||
|
||||
private const byte IRQ2Selector = 0x01;
|
||||
private const byte IRQ1Selector = 0x02;
|
||||
private const byte TimerSelector = 0x04;
|
||||
private const byte IRQ2Selector = 0x01;
|
||||
private const byte IRQ1Selector = 0x02;
|
||||
private const byte TimerSelector = 0x04;
|
||||
|
||||
public void WriteIrqControl(byte value)
|
||||
{
|
||||
// There is a single-instruction delay before writes to the IRQ Control Byte take effect.
|
||||
value &= 7;
|
||||
IRQNextControlByte = value;
|
||||
}
|
||||
public void WriteIrqControl(byte value)
|
||||
{
|
||||
// There is a single-instruction delay before writes to the IRQ Control Byte take effect.
|
||||
value &= 7;
|
||||
IRQNextControlByte = value;
|
||||
}
|
||||
|
||||
public void WriteIrqStatus()
|
||||
{
|
||||
TimerAssert = false;
|
||||
}
|
||||
public void WriteIrqStatus()
|
||||
{
|
||||
TimerAssert = false;
|
||||
}
|
||||
|
||||
public byte ReadIrqStatus()
|
||||
{
|
||||
byte status = 0;
|
||||
if (IRQ2Assert) status |= 1;
|
||||
if (IRQ1Assert) status |= 2;
|
||||
if (TimerAssert) status |= 4;
|
||||
return status;
|
||||
}
|
||||
public byte ReadIrqStatus()
|
||||
{
|
||||
byte status = 0;
|
||||
if (IRQ2Assert) status |= 1;
|
||||
if (IRQ1Assert) status |= 2;
|
||||
if (TimerAssert) status |= 4;
|
||||
return status;
|
||||
}
|
||||
|
||||
public void WriteTimer(byte value)
|
||||
{
|
||||
value &= 0x7F;
|
||||
TimerReloadValue = value;
|
||||
}
|
||||
public void WriteTimer(byte value)
|
||||
{
|
||||
value &= 0x7F;
|
||||
TimerReloadValue = value;
|
||||
}
|
||||
|
||||
public void WriteTimerEnable(byte value)
|
||||
{
|
||||
if (TimerEnabled == false && (value & 1) == 1)
|
||||
{
|
||||
TimerValue = TimerReloadValue; // timer value is reset when toggled from off to on
|
||||
TimerTickCounter = 0;
|
||||
}
|
||||
TimerEnabled = (value & 1) == 1;
|
||||
}
|
||||
public void WriteTimerEnable(byte value)
|
||||
{
|
||||
if (TimerEnabled == false && (value & 1) == 1)
|
||||
{
|
||||
TimerValue = TimerReloadValue; // timer value is reset when toggled from off to on
|
||||
TimerTickCounter = 0;
|
||||
}
|
||||
TimerEnabled = (value & 1) == 1;
|
||||
}
|
||||
|
||||
public byte ReadTimerValue()
|
||||
{
|
||||
if (TimerTickCounter + 5 > 1024)
|
||||
{
|
||||
// There exists a slight delay between when the timer counter is decremented and when
|
||||
// the interrupt fires; games can detect it, so we hack it this way.
|
||||
return (byte) ((TimerValue - 1) & 0x7F);
|
||||
}
|
||||
return TimerValue;
|
||||
}
|
||||
public byte ReadTimerValue()
|
||||
{
|
||||
if (TimerTickCounter + 5 > 1024)
|
||||
{
|
||||
// There exists a slight delay between when the timer counter is decremented and when
|
||||
// the interrupt fires; games can detect it, so we hack it this way.
|
||||
return (byte)((TimerValue - 1) & 0x7F);
|
||||
}
|
||||
return TimerValue;
|
||||
}
|
||||
|
||||
// ==== Flags ====
|
||||
// ==== Flags ====
|
||||
|
||||
/// <summary>Carry Flag</summary>
|
||||
private bool FlagC
|
||||
{
|
||||
get { return (P & 0x01) != 0; }
|
||||
set { P = (byte)((P & ~0x01) | (value ? 0x01 : 0x00)); }
|
||||
}
|
||||
/// <summary>Carry Flag</summary>
|
||||
private bool FlagC
|
||||
{
|
||||
get { return (P & 0x01) != 0; }
|
||||
set { P = (byte)((P & ~0x01) | (value ? 0x01 : 0x00)); }
|
||||
}
|
||||
|
||||
/// <summary>Zero Flag</summary>
|
||||
private bool FlagZ
|
||||
{
|
||||
get { return (P & 0x02) != 0; }
|
||||
set { P = (byte)((P & ~0x02) | (value ? 0x02 : 0x00)); }
|
||||
}
|
||||
/// <summary>Zero Flag</summary>
|
||||
private bool FlagZ
|
||||
{
|
||||
get { return (P & 0x02) != 0; }
|
||||
set { P = (byte)((P & ~0x02) | (value ? 0x02 : 0x00)); }
|
||||
}
|
||||
|
||||
/// <summary>Interrupt Disable Flag</summary>
|
||||
private bool FlagI
|
||||
{
|
||||
get { return (P & 0x04) != 0; }
|
||||
set { P = (byte)((P & ~0x04) | (value ? 0x04 : 0x00)); }
|
||||
}
|
||||
/// <summary>Interrupt Disable Flag</summary>
|
||||
private bool FlagI
|
||||
{
|
||||
get { return (P & 0x04) != 0; }
|
||||
set { P = (byte)((P & ~0x04) | (value ? 0x04 : 0x00)); }
|
||||
}
|
||||
|
||||
/// <summary>Decimal Mode Flag</summary>
|
||||
private bool FlagD
|
||||
{
|
||||
get { return (P & 0x08) != 0; }
|
||||
set { P = (byte)((P & ~0x08) | (value ? 0x08 : 0x00)); }
|
||||
}
|
||||
/// <summary>Decimal Mode Flag</summary>
|
||||
private bool FlagD
|
||||
{
|
||||
get { return (P & 0x08) != 0; }
|
||||
set { P = (byte)((P & ~0x08) | (value ? 0x08 : 0x00)); }
|
||||
}
|
||||
|
||||
/// <summary>Break Flag</summary>
|
||||
private bool FlagB
|
||||
{
|
||||
get { return (P & 0x10) != 0; }
|
||||
set { P = (byte)((P & ~0x10) | (value ? 0x10 : 0x00)); }
|
||||
}
|
||||
/// <summary>Break Flag</summary>
|
||||
private bool FlagB
|
||||
{
|
||||
get { return (P & 0x10) != 0; }
|
||||
set { P = (byte)((P & ~0x10) | (value ? 0x10 : 0x00)); }
|
||||
}
|
||||
|
||||
/// <summary>T... Flag</summary>
|
||||
private bool FlagT
|
||||
{
|
||||
get { return (P & 0x20) != 0; }
|
||||
set { P = (byte)((P & ~0x20) | (value ? 0x20 : 0x00)); }
|
||||
}
|
||||
/// <summary>T... Flag</summary>
|
||||
private bool FlagT
|
||||
{
|
||||
get { return (P & 0x20) != 0; }
|
||||
set { P = (byte)((P & ~0x20) | (value ? 0x20 : 0x00)); }
|
||||
}
|
||||
|
||||
/// <summary>Overflow Flag</summary>
|
||||
private bool FlagV
|
||||
{
|
||||
get { return (P & 0x40) != 0; }
|
||||
set { P = (byte)((P & ~0x40) | (value ? 0x40 : 0x00)); }
|
||||
}
|
||||
/// <summary>Overflow Flag</summary>
|
||||
private bool FlagV
|
||||
{
|
||||
get { return (P & 0x40) != 0; }
|
||||
set { P = (byte)((P & ~0x40) | (value ? 0x40 : 0x00)); }
|
||||
}
|
||||
|
||||
/// <summary>Negative Flag</summary>
|
||||
private bool FlagN
|
||||
{
|
||||
get { return (P & 0x80) != 0; }
|
||||
set { P = (byte)((P & ~0x80) | (value ? 0x80 : 0x00)); }
|
||||
}
|
||||
/// <summary>Negative Flag</summary>
|
||||
private bool FlagN
|
||||
{
|
||||
get { return (P & 0x80) != 0; }
|
||||
set { P = (byte)((P & ~0x80) | (value ? 0x80 : 0x00)); }
|
||||
}
|
||||
|
||||
// ==== Memory ====
|
||||
// ==== Memory ====
|
||||
|
||||
public Func<int, byte> ReadMemory21;
|
||||
public Action<int, byte> WriteMemory21;
|
||||
public Action<int, byte> WriteVDC;
|
||||
public Action<int> ThinkAction = delegate { };
|
||||
public Func<int, byte> ReadMemory21;
|
||||
public Action<int, byte> WriteMemory21;
|
||||
public Action<int, byte> WriteVDC;
|
||||
public Action<int> ThinkAction = delegate { };
|
||||
|
||||
public byte ReadMemory(ushort address)
|
||||
{
|
||||
byte page = MPR[address >> 13];
|
||||
return ReadMemory21((page << 13) | (address & 0x1FFF));
|
||||
}
|
||||
public byte ReadMemory(ushort address)
|
||||
{
|
||||
byte page = MPR[address >> 13];
|
||||
return ReadMemory21((page << 13) | (address & 0x1FFF));
|
||||
}
|
||||
|
||||
public void WriteMemory(ushort address, byte value)
|
||||
{
|
||||
byte page = MPR[address >> 13];
|
||||
WriteMemory21((page << 13) | (address & 0x1FFF), value);
|
||||
}
|
||||
public void WriteMemory(ushort address, byte value)
|
||||
{
|
||||
byte page = MPR[address >> 13];
|
||||
WriteMemory21((page << 13) | (address & 0x1FFF), value);
|
||||
}
|
||||
|
||||
private ushort ReadWord(ushort address)
|
||||
{
|
||||
byte l = ReadMemory(address);
|
||||
byte h = ReadMemory(++address);
|
||||
return (ushort)((h << 8) | l);
|
||||
}
|
||||
private ushort ReadWord(ushort address)
|
||||
{
|
||||
byte l = ReadMemory(address);
|
||||
byte h = ReadMemory(++address);
|
||||
return (ushort)((h << 8) | l);
|
||||
}
|
||||
|
||||
private void WriteWord(ushort address, ushort value)
|
||||
{
|
||||
byte l = (byte)(value & 0xFF);
|
||||
byte h = (byte)(value >> 8);
|
||||
WriteMemory(address, l);
|
||||
WriteMemory(++address, h);
|
||||
}
|
||||
private void WriteWord(ushort address, ushort value)
|
||||
{
|
||||
byte l = (byte)(value & 0xFF);
|
||||
byte h = (byte)(value >> 8);
|
||||
WriteMemory(address, l);
|
||||
WriteMemory(++address, h);
|
||||
}
|
||||
|
||||
private ushort ReadWordPageWrap(ushort address)
|
||||
{
|
||||
ushort highAddress = (ushort)((address & 0xFF00) + ((address + 1) & 0xFF));
|
||||
return (ushort)(ReadMemory(address) | (ReadMemory(highAddress) << 8));
|
||||
}
|
||||
private ushort ReadWordPageWrap(ushort address)
|
||||
{
|
||||
ushort highAddress = (ushort)((address & 0xFF00) + ((address + 1) & 0xFF));
|
||||
return (ushort)(ReadMemory(address) | (ReadMemory(highAddress) << 8));
|
||||
}
|
||||
|
||||
public string State()
|
||||
{
|
||||
int notused;
|
||||
string a = string.Format("{0:X4} {1:X2} {2} ", PC, ReadMemory(PC), Disassemble(PC, out notused)).PadRight(41);
|
||||
string b = string.Format("A:{0:X2} X:{1:X2} Y:{2:X2} P:{3:X2} SP:{4:X2} Cy:{5}", A, X, Y, P, S, TotalExecutedCycles);
|
||||
string val = a + b + " ";
|
||||
if (FlagN) val = val + "N";
|
||||
if (FlagV) val = val + "V";
|
||||
if (FlagT) val = val + "T";
|
||||
if (FlagB) val = val + "B";
|
||||
if (FlagD) val = val + "D";
|
||||
if (FlagI) val = val + "I";
|
||||
if (FlagZ) val = val + "Z";
|
||||
if (FlagC) val = val + "C";
|
||||
return val;
|
||||
}
|
||||
public string State()
|
||||
{
|
||||
int notused;
|
||||
string a = string.Format("{0:X4} {1:X2} {2} ", PC, ReadMemory(PC), Disassemble(PC, out notused)).PadRight(41);
|
||||
string b = string.Format("A:{0:X2} X:{1:X2} Y:{2:X2} P:{3:X2} SP:{4:X2} Cy:{5}", A, X, Y, P, S, TotalExecutedCycles);
|
||||
string val = a + b + " ";
|
||||
if (FlagN) val = val + "N";
|
||||
if (FlagV) val = val + "V";
|
||||
if (FlagT) val = val + "T";
|
||||
if (FlagB) val = val + "B";
|
||||
if (FlagD) val = val + "D";
|
||||
if (FlagI) val = val + "I";
|
||||
if (FlagZ) val = val + "Z";
|
||||
if (FlagC) val = val + "C";
|
||||
return val;
|
||||
}
|
||||
|
||||
private static readonly byte[] TableNZ =
|
||||
private static readonly byte[] TableNZ =
|
||||
{
|
||||
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
@ -416,5 +416,5 @@ namespace BizHawk.Emulation.Common.Components.H6280
|
|||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,7 +29,7 @@ namespace BizHawk.Emulation.Common.Components.M6502
|
|||
mi = 0;
|
||||
opcode = 256;
|
||||
iflag_pending = true;
|
||||
RDY = true;
|
||||
RDY = true;
|
||||
}
|
||||
|
||||
public void NESSoftReset()
|
||||
|
@ -220,23 +220,23 @@ namespace BizHawk.Emulation.Common.Components.M6502
|
|||
}
|
||||
|
||||
private static readonly byte[] TableNZ =
|
||||
{
|
||||
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80
|
||||
};
|
||||
{
|
||||
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80
|
||||
};
|
||||
}
|
||||
}
|
|
@ -12,8 +12,8 @@ namespace BizHawk.Emulation.Common.Components.M6502
|
|||
/// </summary>
|
||||
public class MOS6502XDouble
|
||||
{
|
||||
MOS6502X m;
|
||||
MOS6502X_CPP n;
|
||||
readonly MOS6502X m;
|
||||
readonly MOS6502X_CPP n;
|
||||
|
||||
public MOS6502XDouble(Action<System.Runtime.InteropServices.GCHandle> DisposeBuilder)
|
||||
{
|
||||
|
|
|
@ -7,27 +7,27 @@ namespace BizHawk.Emulation.Common.Components.M6502
|
|||
{
|
||||
public static class MOS6502X_DLL
|
||||
{
|
||||
[UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.Cdecl)]
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate byte ReadMemoryD(ushort addr);
|
||||
[UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.Cdecl)]
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void WriteMemoryD(ushort addr, byte value);
|
||||
|
||||
[DllImport("MOS6502XNative.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr Create();
|
||||
internal static extern IntPtr Create();
|
||||
[DllImport("MOS6502XNative.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void Destroy(IntPtr ptr);
|
||||
internal static extern void Destroy(IntPtr ptr);
|
||||
|
||||
[DllImport("MOS6502XNative.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?Reset@MOS6502X@@QAEXXZ")]
|
||||
public static extern void Reset(IntPtr ptr);
|
||||
internal static extern void Reset(IntPtr ptr);
|
||||
|
||||
[DllImport("MOS6502XNative.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?NESSoftReset@MOS6502X@@QAEXXZ")]
|
||||
public static extern void NESSoftReset(IntPtr ptr);
|
||||
internal static extern void NESSoftReset(IntPtr ptr);
|
||||
|
||||
[DllImport("MOS6502XNative.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?ExecuteOne@MOS6502X@@QAEXXZ")]
|
||||
public static extern void ExecuteOne(IntPtr ptr);
|
||||
internal static extern void ExecuteOne(IntPtr ptr);
|
||||
|
||||
[DllImport("MOS6502XNative.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?SetTrampolines@MOS6502X@@QAEXP6AEG@Z0P6AXGE@Z@Z")]
|
||||
public static extern void SetTrampolines(IntPtr ptr, ReadMemoryD Read, ReadMemoryD DummyRead, WriteMemoryD Write);
|
||||
internal static extern void SetTrampolines(IntPtr ptr, ReadMemoryD Read, ReadMemoryD DummyRead, WriteMemoryD Write);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -213,8 +213,6 @@ namespace BizHawk.Emulation.Common.Components.M6502
|
|||
DisposeBuilder(h2);
|
||||
DisposeBuilder(h3);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace BizHawk.Emulation.Common
|
||||
|
@ -123,7 +122,7 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
public class InputCallbackSystem
|
||||
{
|
||||
private List<Action> _list = new List<Action>();
|
||||
private readonly List<Action> _list = new List<Action>();
|
||||
|
||||
public void Add(Action action)
|
||||
{
|
||||
|
@ -159,14 +158,14 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
public class MemoryCallbackSystem
|
||||
{
|
||||
private List<Action> _reads = new List<Action>();
|
||||
private List<uint?> _readAddrs = new List<uint?>();
|
||||
private readonly List<Action> _reads = new List<Action>();
|
||||
private readonly List<uint?> _readAddrs = new List<uint?>();
|
||||
|
||||
private List<Action> _writes = new List<Action>();
|
||||
private List<uint?> _writeAddrs = new List<uint?>();
|
||||
private readonly List<Action> _writes = new List<Action>();
|
||||
private readonly List<uint?> _writeAddrs = new List<uint?>();
|
||||
|
||||
private List<Action> _executes = new List<Action>();
|
||||
private List<uint> _execAddrs = new List<uint>();
|
||||
private readonly List<Action> _executes = new List<Action>();
|
||||
private readonly List<uint> _execAddrs = new List<uint>();
|
||||
|
||||
public void AddRead(Action function, uint? addr)
|
||||
{
|
||||
|
|
|
@ -105,7 +105,7 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
public class MemoryDomainList : ReadOnlyCollection<MemoryDomain>
|
||||
{
|
||||
private int _mainMemoryIndex = 0;
|
||||
private readonly int _mainMemoryIndex;
|
||||
|
||||
public MemoryDomainList(IList<MemoryDomain> domains)
|
||||
: base(domains)
|
||||
|
|
|
@ -4,7 +4,6 @@ using System.Globalization;
|
|||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Common.Components
|
||||
{
|
||||
|
@ -30,15 +29,15 @@ namespace BizHawk.Emulation.Common.Components
|
|||
public PSGChannel[] Channels = new PSGChannel[8];
|
||||
|
||||
public byte VoiceLatch;
|
||||
byte WaveTableWriteOffset;
|
||||
private byte WaveTableWriteOffset;
|
||||
|
||||
Queue<QueuedCommand> commands = new Queue<QueuedCommand>(256);
|
||||
long frameStartTime, frameStopTime;
|
||||
private readonly Queue<QueuedCommand> commands = new Queue<QueuedCommand>(256);
|
||||
private long frameStartTime, frameStopTime;
|
||||
|
||||
const int SampleRate = 44100;
|
||||
const int PsgBase = 3580000;
|
||||
static byte[] LogScale = { 0, 0, 10, 10, 13, 13, 16, 16, 20, 20, 26, 26, 32, 32, 40, 40, 51, 51, 64, 64, 81, 81, 102, 102, 128, 128, 161, 161, 203, 203, 255, 255 };
|
||||
static byte[] VolumeReductionTable = { 0x1F, 0x1D, 0x1B, 0x19, 0x17, 0x15, 0x13, 0x10, 0x0F, 0x0D, 0x0B, 0x09, 0x07, 0x05, 0x03, 0x00 };
|
||||
static readonly byte[] LogScale = { 0, 0, 10, 10, 13, 13, 16, 16, 20, 20, 26, 26, 32, 32, 40, 40, 51, 51, 64, 64, 81, 81, 102, 102, 128, 128, 161, 161, 203, 203, 255, 255 };
|
||||
static readonly byte[] VolumeReductionTable = { 0x1F, 0x1D, 0x1B, 0x19, 0x17, 0x15, 0x13, 0x10, 0x0F, 0x0D, 0x0B, 0x09, 0x07, 0x05, 0x03, 0x00 };
|
||||
|
||||
public byte MainVolumeLeft;
|
||||
public byte MainVolumeRight;
|
||||
|
@ -49,7 +48,9 @@ namespace BizHawk.Emulation.Common.Components
|
|||
MaxVolume = short.MaxValue;
|
||||
Waves.InitWaves();
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
Channels[i] = new PSGChannel();
|
||||
}
|
||||
}
|
||||
|
||||
public void BeginFrame(long cycles)
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Common.Components
|
||||
|
@ -12,19 +8,19 @@ namespace BizHawk.Emulation.Common.Components
|
|||
class Pulse
|
||||
{
|
||||
// regs
|
||||
int V;
|
||||
int T;
|
||||
int L;
|
||||
int D;
|
||||
bool LenCntDisable;
|
||||
bool ConstantVolume;
|
||||
bool Enable;
|
||||
private int V;
|
||||
private int T;
|
||||
private int L;
|
||||
private int D;
|
||||
private bool LenCntDisable;
|
||||
private bool ConstantVolume;
|
||||
private bool Enable;
|
||||
// envelope
|
||||
bool estart;
|
||||
int etime;
|
||||
int ecount;
|
||||
private bool estart;
|
||||
private int etime;
|
||||
private int ecount;
|
||||
// length
|
||||
static int[] lenlookup =
|
||||
private static readonly int[] lenlookup =
|
||||
{
|
||||
10,254, 20, 2, 40, 4, 80, 6, 160, 8, 60, 10, 14, 12, 26, 14,
|
||||
12, 16, 24, 18, 48, 20, 96, 22, 192, 24, 72, 26, 16, 28, 32, 30
|
||||
|
@ -32,18 +28,18 @@ namespace BizHawk.Emulation.Common.Components
|
|||
int length;
|
||||
|
||||
// pulse
|
||||
int sequence;
|
||||
static int[,] sequencelookup =
|
||||
private int sequence;
|
||||
private static readonly int[,] sequencelookup =
|
||||
{
|
||||
{0,0,0,0,0,0,0,1},
|
||||
{0,0,0,0,0,0,1,1},
|
||||
{0,0,0,0,1,1,1,1},
|
||||
{1,1,1,1,1,1,0,0}
|
||||
};
|
||||
int clock;
|
||||
int output;
|
||||
private int clock;
|
||||
private int output;
|
||||
|
||||
public Action<int> SendDiff;
|
||||
private readonly Action<int> SendDiff;
|
||||
|
||||
public Pulse(Action<int> SendDiff)
|
||||
{
|
||||
|
@ -165,7 +161,7 @@ namespace BizHawk.Emulation.Common.Components
|
|||
}
|
||||
}
|
||||
|
||||
Pulse[] pulse = new Pulse[2];
|
||||
private readonly Pulse[] pulse = new Pulse[2];
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
@ -245,15 +241,15 @@ namespace BizHawk.Emulation.Common.Components
|
|||
RaiseIRQ(PCMEnableIRQ && PCMIRQTriggered);
|
||||
}
|
||||
|
||||
Action<bool> RaiseIRQ;
|
||||
private readonly Action<bool> RaiseIRQ;
|
||||
|
||||
const int framereload = 7458; // ???
|
||||
int frame = 0;
|
||||
bool PCMRead;
|
||||
bool PCMEnableIRQ;
|
||||
bool PCMIRQTriggered;
|
||||
byte PCMVal;
|
||||
byte PCMNextVal;
|
||||
private int frame;
|
||||
private bool PCMRead;
|
||||
private bool PCMEnableIRQ;
|
||||
private bool PCMIRQTriggered;
|
||||
private byte PCMVal;
|
||||
private byte PCMNextVal;
|
||||
|
||||
public void SyncState(Serializer ser)
|
||||
{
|
||||
|
@ -288,14 +284,14 @@ namespace BizHawk.Emulation.Common.Components
|
|||
}
|
||||
if (PCMNextVal != PCMVal)
|
||||
{
|
||||
enqueuer(20 * (int)(PCMVal - PCMNextVal));
|
||||
enqueuer(20 * (PCMVal - PCMNextVal));
|
||||
PCMVal = PCMNextVal;
|
||||
}
|
||||
}
|
||||
|
||||
Action<int> enqueuer;
|
||||
private readonly Action<int> enqueuer;
|
||||
|
||||
void PulseAddDiff(int value)
|
||||
private void PulseAddDiff(int value)
|
||||
{
|
||||
enqueuer(value * 370);
|
||||
//Console.WriteLine(value);
|
||||
|
|
|
@ -3,8 +3,6 @@ using System.Collections.Generic;
|
|||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
// TODO the freq->note translation should be moved to a separate utility class.
|
||||
|
||||
namespace BizHawk.Emulation.Common.Components
|
||||
|
@ -26,7 +24,7 @@ namespace BizHawk.Emulation.Common.Components
|
|||
public bool Right = true;
|
||||
|
||||
const int SampleRate = 44100;
|
||||
static byte[] LogScale = { 0, 10, 13, 16, 20, 26, 32, 40, 51, 64, 81, 102, 128, 161, 203, 255 };
|
||||
private static readonly byte[] LogScale = { 0, 10, 13, 16, 20, 26, 32, 40, 51, 64, 81, 102, 128, 161, 203, 255 };
|
||||
|
||||
public void Mix(short[] samples, int start, int len, int maxVolume)
|
||||
{
|
||||
|
@ -52,7 +50,7 @@ namespace BizHawk.Emulation.Common.Components
|
|||
public Channel[] Channels = new Channel[4];
|
||||
public byte PsgLatch;
|
||||
|
||||
Queue<QueuedCommand> commands = new Queue<QueuedCommand>(256);
|
||||
private readonly Queue<QueuedCommand> commands = new Queue<QueuedCommand>(256);
|
||||
int frameStartTime, frameStopTime;
|
||||
|
||||
const int PsgBase = 111861;
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Common.Components
|
||||
|
@ -16,15 +12,15 @@ namespace BizHawk.Emulation.Common.Components
|
|||
{
|
||||
class Pulse
|
||||
{
|
||||
Action<int> SendDiff;
|
||||
private readonly Action<int> SendDiff;
|
||||
// regs
|
||||
int Period;
|
||||
bool Disable;
|
||||
int Volume;
|
||||
private int Period;
|
||||
private bool Disable;
|
||||
private int Volume;
|
||||
// state
|
||||
int clock;
|
||||
int sequence;
|
||||
int output;
|
||||
private int clock;
|
||||
private int sequence;
|
||||
private int output;
|
||||
|
||||
public void SyncState(Serializer ser)
|
||||
{
|
||||
|
@ -45,7 +41,10 @@ namespace BizHawk.Emulation.Common.Components
|
|||
{
|
||||
int newout = 1;
|
||||
if (!Disable)
|
||||
{
|
||||
newout = sequence;
|
||||
}
|
||||
|
||||
newout *= Volume;
|
||||
if (newout != output)
|
||||
{
|
||||
|
@ -87,7 +86,7 @@ namespace BizHawk.Emulation.Common.Components
|
|||
}
|
||||
|
||||
int RegNum;
|
||||
Pulse[] pulse = new Pulse[3];
|
||||
readonly Pulse[] pulse = new Pulse[3];
|
||||
|
||||
public void RegSelect(byte val)
|
||||
{
|
||||
|
@ -132,8 +131,8 @@ namespace BizHawk.Emulation.Common.Components
|
|||
ser.EndSection();
|
||||
}
|
||||
|
||||
Action<int> enqueuer;
|
||||
void PulseAddDiff(int val)
|
||||
private readonly Action<int> enqueuer;
|
||||
private void PulseAddDiff(int val)
|
||||
{
|
||||
enqueuer(val * 250);
|
||||
}
|
||||
|
@ -142,13 +141,17 @@ namespace BizHawk.Emulation.Common.Components
|
|||
{
|
||||
this.enqueuer = enqueuer;
|
||||
for (int i = 0; i < pulse.Length; i++)
|
||||
{
|
||||
pulse[i] = new Pulse(PulseAddDiff);
|
||||
}
|
||||
}
|
||||
|
||||
public void Clock()
|
||||
{
|
||||
for (int i = 0; i < pulse.Length; i++)
|
||||
pulse[i].Clock();
|
||||
foreach (Pulse p in pulse)
|
||||
{
|
||||
p.Clock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace BizHawk.Emulation.Common
|
||||
|
@ -9,7 +6,7 @@ namespace BizHawk.Emulation.Common
|
|||
/// <summary>
|
||||
/// wrapper around blargg's unmanaged blip_buf
|
||||
/// </summary>
|
||||
public class BlipBuffer : IDisposable
|
||||
public sealed class BlipBuffer : IDisposable
|
||||
{
|
||||
// this is transitional only. if the band-limited synthesis idea works out, i'll
|
||||
// make a managed MIT implementation
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
// Generates SEMI-synchronous sound, or "buffered asynchronous" sound.
|
||||
|
@ -34,10 +32,10 @@ namespace BizHawk.Emulation.Common
|
|||
{
|
||||
public ISoundProvider BaseSoundProvider;
|
||||
|
||||
Queue<short> buffer = new Queue<short>(4096);
|
||||
readonly Queue<short> buffer = new Queue<short>(4096);
|
||||
|
||||
int SamplesInOneFrame = 1470;
|
||||
int TargetExtraSamples = 882;
|
||||
private int SamplesInOneFrame = 1470;
|
||||
private int TargetExtraSamples = 882;
|
||||
const int MaxExcessSamples = 4096;
|
||||
|
||||
/// <summary>
|
||||
|
@ -72,11 +70,15 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
BaseSoundProvider.GetSamples(mySamples);
|
||||
|
||||
for (int i = 0; i < mySamples.Length; i++)
|
||||
buffer.Enqueue(mySamples[i]);
|
||||
foreach (short s in mySamples)
|
||||
{
|
||||
buffer.Enqueue(s);
|
||||
}
|
||||
|
||||
for (int i = 0; i < samples.Length; i++)
|
||||
{
|
||||
samples[i] = buffer.Dequeue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +1,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// implements a DC block filter on top of an ISoundProvider. rather simple.
|
||||
/// </summary>
|
||||
public class DCFilter : ISoundProvider, ISyncSoundProvider
|
||||
sealed public class DCFilter : ISoundProvider, ISyncSoundProvider
|
||||
{
|
||||
/*
|
||||
* A note about accuracy:
|
||||
|
@ -78,7 +73,7 @@ namespace BizHawk.Emulation.Common
|
|||
PushThroughSamples(samples, samples, length);
|
||||
}
|
||||
|
||||
void PushThroughSamples(short[] samplesin, short[] samplesout, int length)
|
||||
private void PushThroughSamples(short[] samplesin, short[] samplesout, int length)
|
||||
{
|
||||
for (int i = 0; i < length; i += 2)
|
||||
{
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
// C# port of C-based 3-band equalizer (C) Neil C / Etanza Systems / 2006
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -10,8 +8,8 @@ namespace BizHawk.Emulation.Common
|
|||
/// </summary>
|
||||
public class MetaspuAsync : ISoundProvider
|
||||
{
|
||||
ISynchronizingAudioBuffer buffer;
|
||||
ISyncSoundProvider input;
|
||||
private readonly ISynchronizingAudioBuffer buffer;
|
||||
private readonly ISyncSoundProvider input;
|
||||
public MetaspuAsync(ISyncSoundProvider input, ESynchMethod method)
|
||||
{
|
||||
buffer = Metaspu.metaspu_construct(method);
|
||||
|
@ -49,7 +47,7 @@ namespace BizHawk.Emulation.Common
|
|||
{
|
||||
}
|
||||
|
||||
short[] pullBuffer = new short[1470];
|
||||
private readonly short[] pullBuffer = new short[1470];
|
||||
public void PullSamples(ISoundProvider source)
|
||||
{
|
||||
Array.Clear(pullBuffer, 0, 1470);
|
||||
|
@ -124,7 +122,7 @@ namespace BizHawk.Emulation.Common
|
|||
}
|
||||
|
||||
//adjustobuf(200,1000)
|
||||
bool mixqueue_go = false;
|
||||
bool mixqueue_go;
|
||||
|
||||
public void clear()
|
||||
{
|
||||
|
@ -177,7 +175,7 @@ namespace BizHawk.Emulation.Common
|
|||
return done;
|
||||
}
|
||||
|
||||
Adjustobuf adjustobuf;
|
||||
private readonly Adjustobuf adjustobuf;
|
||||
class Adjustobuf
|
||||
{
|
||||
public Adjustobuf(int _minLatency, int _maxLatency)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
|
@ -7,7 +6,7 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
public sealed class SoundMixer : ISoundProvider
|
||||
{
|
||||
List<ISoundProvider> SoundProviders;
|
||||
private readonly List<ISoundProvider> SoundProviders;
|
||||
|
||||
public SoundMixer(params ISoundProvider[] soundProviders)
|
||||
{
|
||||
|
@ -41,7 +40,9 @@ namespace BizHawk.Emulation.Common
|
|||
{
|
||||
int eachVolume = short.MaxValue / SoundProviders.Count;
|
||||
foreach (var source in SoundProviders)
|
||||
{
|
||||
source.MaxVolume = eachVolume;
|
||||
}
|
||||
}
|
||||
|
||||
// Not actually supported on mixer.
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -259,29 +254,29 @@ namespace BizHawk.Emulation.Common
|
|||
/// <summary>
|
||||
/// opaque pointer to state
|
||||
/// </summary>
|
||||
IntPtr st = IntPtr.Zero;
|
||||
private IntPtr st = IntPtr.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// function to call to dispatch output
|
||||
/// </summary>
|
||||
Action<short[], int> drainer;
|
||||
private readonly Action<short[], int> drainer;
|
||||
|
||||
// TODO: this size is roughly based on how big you can make the buffer before the snes resampling (32040.5 -> 44100) gets screwed up
|
||||
short[] inbuf = new short[512]; //[8192]; // [512];
|
||||
private short[] inbuf = new short[512]; //[8192]; // [512];
|
||||
|
||||
short[] outbuf;
|
||||
private short[] outbuf;
|
||||
|
||||
// for ISyncSoundProvider
|
||||
short[] outbuf2 = new short[16];
|
||||
int outbuf2pos = 0;
|
||||
private short[] outbuf2 = new short[16];
|
||||
private int outbuf2pos = 0;
|
||||
|
||||
// to accept an ISyncSoundProvder input
|
||||
ISyncSoundProvider input;
|
||||
private readonly ISyncSoundProvider input;
|
||||
|
||||
/// <summary>
|
||||
/// in buffer position in samples (not sample pairs)
|
||||
/// </summary>
|
||||
int inbufpos = 0;
|
||||
private int inbufpos = 0;
|
||||
|
||||
/// <summary>
|
||||
/// throw an exception based on error state
|
||||
|
@ -327,10 +322,7 @@ namespace BizHawk.Emulation.Common
|
|||
if (drainer != null && input != null)
|
||||
throw new ArgumentException("Can't autofetch without being an ISyncSoundProvider?");
|
||||
|
||||
if (drainer != null)
|
||||
this.drainer = drainer;
|
||||
else
|
||||
this.drainer = InternalDrain;
|
||||
this.drainer = drainer ?? InternalDrain;
|
||||
this.input = input;
|
||||
|
||||
outbuf = new short[inbuf.Length * ratioden / rationum / 2 * 2 + 128];
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Common.Components
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
using System;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Common.Components
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue