HuC6280: Implement high/low speed modes
This commit is contained in:
parent
3ceb4ea890
commit
4c9057060b
|
@ -47,7 +47,6 @@ namespace BizHawk.Emulation.CPUs.H6280
|
|||
IRQControlByte = IRQNextControlByte;
|
||||
LagIFlag = FlagI;
|
||||
|
||||
//if (debug) Log.Note("CPU", State());
|
||||
byte opcode = ReadMemory(PC++);
|
||||
switch (opcode)
|
||||
{
|
||||
|
@ -717,6 +716,7 @@ throw new Exception("break");
|
|||
PendingCycles -= 5;
|
||||
break;
|
||||
case 0x54: // CSL
|
||||
LowSpeed = true;
|
||||
PendingCycles -= 3;
|
||||
break;
|
||||
case 0x55: // EOR zp,X
|
||||
|
@ -1710,6 +1710,7 @@ throw new Exception("break");
|
|||
PendingCycles -= temp;
|
||||
break;
|
||||
case 0xD4: // CSH
|
||||
LowSpeed = false;
|
||||
PendingCycles -= 3;
|
||||
break;
|
||||
case 0xD5: // CMP zp,X
|
||||
|
@ -2114,6 +2115,8 @@ throw new Exception("break");
|
|||
P &= 0xDF; // Clear T flag
|
||||
AfterClearTFlag: // SET command jumps here
|
||||
int delta = lastCycles - PendingCycles;
|
||||
if (LowSpeed)
|
||||
delta *= 4;
|
||||
TotalExecutedCycles += delta;
|
||||
|
||||
if (TimerEnabled)
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace BizHawk.Emulation.CPUs.H6280
|
|||
PendingCycles = 0;
|
||||
TotalExecutedCycles = 0;
|
||||
LagIFlag = true;
|
||||
LowSpeed = true;
|
||||
}
|
||||
|
||||
public void ResetPC()
|
||||
|
@ -47,8 +48,7 @@ namespace BizHawk.Emulation.CPUs.H6280
|
|||
|
||||
public int TotalExecutedCycles;
|
||||
public int PendingCycles;
|
||||
|
||||
public bool debug = true;
|
||||
public bool LowSpeed;
|
||||
|
||||
// -- Timer Support --
|
||||
|
||||
|
@ -74,6 +74,7 @@ namespace BizHawk.Emulation.CPUs.H6280
|
|||
writer.WriteLine("IRQNextControlByte {0:X2}", IRQNextControlByte);
|
||||
writer.WriteLine("ExecutedCycles {0}", TotalExecutedCycles);
|
||||
writer.WriteLine("PendingCycles {0}", PendingCycles);
|
||||
writer.WriteLine("LowSpeed {0}", TimerTickCounter);
|
||||
writer.WriteLine("TimerTickCounter {0}", TimerTickCounter);
|
||||
writer.WriteLine("TimerReloadValue {0}", TimerReloadValue);
|
||||
writer.WriteLine("TimerValue {0}", TimerValue);
|
||||
|
@ -114,6 +115,8 @@ namespace BizHawk.Emulation.CPUs.H6280
|
|||
TotalExecutedCycles = int.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")
|
||||
|
@ -142,6 +145,7 @@ namespace BizHawk.Emulation.CPUs.H6280
|
|||
writer.Write(IRQNextControlByte);
|
||||
writer.Write(TotalExecutedCycles);
|
||||
writer.Write(PendingCycles);
|
||||
writer.Write(LowSpeed);
|
||||
|
||||
writer.Write(TimerTickCounter);
|
||||
writer.Write(TimerReloadValue);
|
||||
|
@ -164,6 +168,7 @@ namespace BizHawk.Emulation.CPUs.H6280
|
|||
IRQNextControlByte = reader.ReadByte();
|
||||
TotalExecutedCycles = reader.ReadInt32();
|
||||
PendingCycles = reader.ReadInt32();
|
||||
LowSpeed = reader.ReadBoolean();
|
||||
|
||||
TimerTickCounter = reader.ReadInt32();
|
||||
TimerReloadValue = reader.ReadByte();
|
||||
|
@ -191,12 +196,10 @@ namespace BizHawk.Emulation.CPUs.H6280
|
|||
|
||||
value &= 7;
|
||||
IRQNextControlByte = value;
|
||||
//Console.WriteLine("WROTTEN TO IRQ COTRL {0:X2}", value);
|
||||
}
|
||||
|
||||
public void WriteIrqStatus()
|
||||
{
|
||||
//Console.WriteLine("ACKNOWLDGED TIMER INT");
|
||||
TimerAssert = false;
|
||||
}
|
||||
|
||||
|
@ -206,7 +209,6 @@ namespace BizHawk.Emulation.CPUs.H6280
|
|||
//if (IRQ2Assert) status |= 1;
|
||||
if (IRQ1Assert) status |= 2;
|
||||
if (TimerAssert) status |= 4;
|
||||
//Console.WriteLine("READING IRQ STATUS BYTE {0:X2}",status);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -214,7 +216,6 @@ namespace BizHawk.Emulation.CPUs.H6280
|
|||
{
|
||||
value &= 0x7F;
|
||||
TimerReloadValue = value;
|
||||
//Console.WriteLine("*** Timer Countdown Set {0}, {1} per sec",value,7160000/1024/(TimerReloadValue+1));
|
||||
}
|
||||
|
||||
public void WriteTimerEnable(byte value)
|
||||
|
@ -225,7 +226,6 @@ namespace BizHawk.Emulation.CPUs.H6280
|
|||
TimerTickCounter = 0;
|
||||
}
|
||||
TimerEnabled = (value & 1) == 1;
|
||||
//Console.WriteLine("*** Timer "+(TimerEnabled?"Enabled":"Disabled"));
|
||||
}
|
||||
|
||||
// ==== Flags ====
|
||||
|
|
|
@ -483,9 +483,6 @@ namespace HuC6280
|
|||
w.WriteLine(" LagIFlag = FlagI;");
|
||||
w.WriteLine();
|
||||
|
||||
// TODO halt state, shit like that
|
||||
w.WriteLine("//if (debug) Log.Note(\"CPU\", State());");
|
||||
|
||||
w.WriteLine(" byte opcode = ReadMemory(PC++);");
|
||||
w.WriteLine(" switch (opcode)");
|
||||
w.WriteLine(" {");
|
||||
|
@ -503,6 +500,8 @@ namespace HuC6280
|
|||
w.WriteLine(" P &= 0xDF; // Clear T flag");
|
||||
w.WriteLine(" AfterClearTFlag: // SET command jumps here");
|
||||
w.WriteLine(" int delta = lastCycles - PendingCycles;");
|
||||
w.WriteLine(" if (LowSpeed)");
|
||||
w.WriteLine(" delta *= 4;");
|
||||
w.WriteLine(" TotalExecutedCycles += delta;");
|
||||
w.WriteLine();
|
||||
w.WriteLine(" if (TimerEnabled)");
|
||||
|
@ -575,8 +574,8 @@ namespace HuC6280
|
|||
case "CMP": CMP_reg(op, w, "A"); break;
|
||||
case "CPX": CMP_reg(op, w, "X"); break;
|
||||
case "CPY": CMP_reg(op, w, "Y"); break;
|
||||
case "CSH": NOP(op, w); break; // TODO fixme
|
||||
case "CSL": NOP(op, w); break; // TODO fixme
|
||||
case "CSH": CSH(op, w); break;
|
||||
case "CSL": CSL(op, w); break;
|
||||
case "DEC": DEC(op, w); break;
|
||||
case "DEX": DEX(op, w); break;
|
||||
case "DEY": DEY(op, w); break;
|
||||
|
@ -661,8 +660,6 @@ namespace HuC6280
|
|||
|
||||
private void GetValue8(OpcodeInfo op, TextWriter w, string dest)
|
||||
{
|
||||
// TODO it APPEARS that the +1 opcode penalty applies to all AbsoluteX, AbsoluteY, and IndirectY
|
||||
// but this is not completely clear. the doc has some exceptions, but are they real?
|
||||
switch (op.AddressMode)
|
||||
{
|
||||
case AddrMode.Immediate:
|
||||
|
@ -697,14 +694,11 @@ namespace HuC6280
|
|||
break;
|
||||
default:
|
||||
throw new Exception("p"+op.Instruction);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void GetAddress(OpcodeInfo op, TextWriter w, string dest)
|
||||
{
|
||||
// TODO it APPEARS that the +1 opcode penalty applies to all AbsoluteX, AbsoluteY, and IndirectY
|
||||
// but this is not completely clear. the doc has some exceptions, but are they real?
|
||||
switch (op.AddressMode)
|
||||
{
|
||||
case AddrMode.ZeroPage:
|
||||
|
|
|
@ -178,6 +178,18 @@ namespace HuC6280
|
|||
w.WriteLine(Spaces + "PendingCycles -= {0};", op.Cycles);
|
||||
}
|
||||
|
||||
private void CSH(OpcodeInfo op, TextWriter w)
|
||||
{
|
||||
w.WriteLine(Spaces + "LowSpeed = false;");
|
||||
w.WriteLine(Spaces + "PendingCycles -= {0};", op.Cycles);
|
||||
}
|
||||
|
||||
private void CSL(OpcodeInfo op, TextWriter w)
|
||||
{
|
||||
w.WriteLine(Spaces + "LowSpeed = true;");
|
||||
w.WriteLine(Spaces + "PendingCycles -= {0};", op.Cycles);
|
||||
}
|
||||
|
||||
private void DEC(OpcodeInfo op, TextWriter w)
|
||||
{
|
||||
if (op.AddressMode != AddrMode.Accumulator)
|
||||
|
|
Loading…
Reference in New Issue