update 6502 core generator legit-like
This commit is contained in:
parent
c5febf8e20
commit
4e85d82f14
|
@ -17,23 +17,23 @@ namespace BizHawk.Emulation.CPUs.M6502
|
||||||
PendingCycles += cycles;
|
PendingCycles += cycles;
|
||||||
while (PendingCycles > 0)
|
while (PendingCycles > 0)
|
||||||
{
|
{
|
||||||
if (NMI)
|
if (NMI)
|
||||||
{
|
{
|
||||||
WriteMemory((ushort)(S-- + 0x100), (byte)(PC >> 8));
|
WriteMemory((ushort)(S-- + 0x100), (byte)(PC >> 8));
|
||||||
WriteMemory((ushort)(S-- + 0x100), (byte)PC);
|
WriteMemory((ushort)(S-- + 0x100), (byte)PC);
|
||||||
byte oldP = P;
|
byte oldP = P;
|
||||||
FlagB = false;
|
FlagB = false;
|
||||||
FlagT = true;
|
FlagT = true;
|
||||||
WriteMemory((ushort)(S-- + 0x100), P);
|
WriteMemory((ushort)(S-- + 0x100), P);
|
||||||
P = oldP;
|
P = oldP;
|
||||||
FlagI = true;
|
FlagI = true;
|
||||||
PC = ReadWord(NMIVector);
|
PC = ReadWord(NMIVector);
|
||||||
PendingCycles -= 7;
|
PendingCycles -= 7;
|
||||||
NMI = false;
|
NMI = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(debug) Console.WriteLine(State());
|
if(debug) Console.WriteLine(State());
|
||||||
ushort this_pc = PC;
|
ushort this_pc = PC;
|
||||||
byte opcode = ReadMemory(PC++);
|
byte opcode = ReadMemory(PC++);
|
||||||
switch (opcode)
|
switch (opcode)
|
||||||
{
|
{
|
||||||
|
@ -748,10 +748,6 @@ FlagT = true;// this seems wrong
|
||||||
PendingCycles -= 4; TotalExecutedCycles += 4;
|
PendingCycles -= 4; TotalExecutedCycles += 4;
|
||||||
break;
|
break;
|
||||||
case 0xAD: // LDA addr
|
case 0xAD: // LDA addr
|
||||||
if (this_pc == 0x800A)
|
|
||||||
{
|
|
||||||
int zzz = 9;
|
|
||||||
}
|
|
||||||
A = ReadMemory(ReadWord(PC)); PC += 2;
|
A = ReadMemory(ReadWord(PC)); PC += 2;
|
||||||
P = (byte)((P & 0x7D) | TableNZ[A]);
|
P = (byte)((P & 0x7D) | TableNZ[A]);
|
||||||
PendingCycles -= 4; TotalExecutedCycles += 4;
|
PendingCycles -= 4; TotalExecutedCycles += 4;
|
||||||
|
|
|
@ -329,10 +329,25 @@ namespace M6502
|
||||||
w.WriteLine(" while (PendingCycles > 0)");
|
w.WriteLine(" while (PendingCycles > 0)");
|
||||||
w.WriteLine(" {");
|
w.WriteLine(" {");
|
||||||
|
|
||||||
|
w.WriteLine(" if (NMI)");
|
||||||
|
w.WriteLine(" {");
|
||||||
|
w.WriteLine(" WriteMemory((ushort)(S-- + 0x100), (byte)(PC >> 8));");
|
||||||
|
w.WriteLine(" WriteMemory((ushort)(S-- + 0x100), (byte)PC);");
|
||||||
|
w.WriteLine(" byte oldP = P;");
|
||||||
|
w.WriteLine(" FlagB = false;");
|
||||||
|
w.WriteLine(" FlagT = true;");
|
||||||
|
w.WriteLine(" WriteMemory((ushort)(S-- + 0x100), P);");
|
||||||
|
w.WriteLine(" P = oldP;");
|
||||||
|
w.WriteLine(" FlagI = true;");
|
||||||
|
w.WriteLine(" PC = ReadWord(NMIVector);");
|
||||||
|
w.WriteLine(" PendingCycles -= 7;");
|
||||||
|
w.WriteLine(" NMI = false;");
|
||||||
|
w.WriteLine(" }");
|
||||||
|
w.WriteLine("");
|
||||||
|
|
||||||
w.WriteLine("if(debug) Console.WriteLine(State());");
|
w.WriteLine("if(debug) Console.WriteLine(State());");
|
||||||
|
|
||||||
// TODO interrupts, halt state, shit like that
|
w.WriteLine(" ushort this_pc = PC;");
|
||||||
|
|
||||||
w.WriteLine(" byte opcode = ReadMemory(PC++);");
|
w.WriteLine(" byte opcode = ReadMemory(PC++);");
|
||||||
w.WriteLine(" switch (opcode)");
|
w.WriteLine(" switch (opcode)");
|
||||||
w.WriteLine(" {");
|
w.WriteLine(" {");
|
||||||
|
|
Loading…
Reference in New Issue