static void JSRTest0() { memory = new byte[0x10000]; byte[] instructions = { 0xA9, 0x43, 0x20, 0x07, 0x06, 0x69, 0x01, 0x69, 0x01, 0xFF }; instructions.CopyTo(memory, StartingAddress); mos6502.Memory.CopyFrom(memory); AdditionalConditionsDelegate additionalConditions = () => { return(mos6502.Memory[0x01FF] == 0x04 && mos6502.Memory[0x01FE] == 0x06); }; mos6502.LogicalReset(); mos6502.Run(StartingAddress); ReportTest("JSRTest0", 0x60A, 0xFD, 0x44, 0, 0, Convert.ToByte("00100100", 2), 10, additionalConditions); }
static void BRKTest0() { memory = new byte[0x10000]; byte[] instructions = { 0x58, 0xA9, 0x80, 0x69, 0x05, 0x00 }; instructions.CopyTo(memory, StartingAddress); memory[0x0750] = 0x69; memory[0x0751] = 0x01; memory[0x0752] = 0xFF; memory[0xFFFE] = 0x50; memory[0xFFFF] = 0x07; mos6502.Memory.CopyFrom(memory); mos6502.LogicalReset(); mos6502.Run(StartingAddress); AdditionalConditionsDelegate additionalConditions = () => { return(mos6502.Memory[0x01FF] == 0x06 && mos6502.Memory[0x01FE] == 0x06 && mos6502.Memory[0x01FD] == 0xB0); }; ReportTest("BRKTest0", 0x0753, 0xFC, 0x86, 0, 0, Convert.ToByte("10100100", 2), 15, additionalConditions); }
static void ReportTest( string testName, int pc, int sp, int a, int x, int y, int s, int c, AdditionalConditionsDelegate additionalConditions) { bool pcMatch = pc == mos6502.ProgramCounter; bool spMatch = sp == mos6502.StackPointer; bool aMatch = a == mos6502.Accumulator; bool xMatch = x == mos6502.IndexX; bool yMatch = y == mos6502.IndexY; bool sMatch = s == mos6502.Status; bool cMatch = c == mos6502.Clock; bool acMatch = (additionalConditions != null ? additionalConditions() : true); if (pcMatch && spMatch && aMatch && xMatch && yMatch && sMatch && cMatch) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(testName + " - PASSED"); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(testName + " - FAILED"); ReportCondition("Program Counter", pc, mos6502.ProgramCounter); ReportCondition("Stack Pointer", sp, mos6502.StackPointer); ReportCondition("Accumulator", a, mos6502.Accumulator); ReportCondition("IndexX", x, mos6502.IndexX); ReportCondition("IndexY", y, mos6502.IndexY); ReportCondition("Status", s, mos6502.Status); ReportCondition("Clock", c, mos6502.Clock); if (additionalConditions != null) { ReportCondition("Additional Conditions", acMatch); } } Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(); }
static void DECTest0() { memory = new byte[0x10000]; byte[] instructions = { 0xC6, 0x05, 0xFF }; instructions.CopyTo(memory, StartingAddress); memory[0x05] = 0x00; mos6502.Memory.CopyFrom(memory); AdditionalConditionsDelegate additionalConditions = () => { return(mos6502.Memory[0x05] == 0xFF); }; mos6502.LogicalReset(); mos6502.Run(StartingAddress); ReportTest("DECTest0", 0x603, 255, 0, 0, 0, Convert.ToByte("10100100", 2), 5, additionalConditions); }
static void ASLTest1() { memory = new byte[0x10000]; byte[] instructions = { 0x06, 0x34, 0xFF }; instructions.CopyTo(memory, StartingAddress); memory[0x34] = 21; mos6502.Memory.CopyFrom(memory); mos6502.LogicalReset(); mos6502.Run(StartingAddress); AdditionalConditionsDelegate additionalConditions = () => { return(mos6502.Memory[0x34] == 42); }; ReportTest("ASLTest1", 0x603, 255, 0, 0, 0, Convert.ToByte("00100100", 2), 5, additionalConditions); }