static void printState() { byte[] ss = new byte[256]; int cons_y = Console.CursorTop; edio.memRD(Edio.ADDR_SSR, ss, 0, ss.Length); Console.SetCursorPosition(0, cons_y); for (int i = 0; i < ss.Length; i += 16) { if (i == 128) { Console.WriteLine(""); } if (i % 256 == 0) { Console.WriteLine(""); } Console.ForegroundColor = ConsoleColor.White; if (i >= 128 + 0 && i < 128 + 32) { Console.ForegroundColor = ConsoleColor.Yellow; } if (i >= 128 + 32 && i < 128 + 64) { Console.ForegroundColor = ConsoleColor.Green; } if (i >= 128 + 64 && i < 256) { Console.ForegroundColor = ConsoleColor.Cyan; } Console.WriteLine("" + BitConverter.ToString(ss, i, 8) + " " + BitConverter.ToString(ss, i + 8, 8)); } /* * Console.ForegroundColor = ConsoleColor.White; * Console.Write("Mapper regs, "); * Console.ForegroundColor = ConsoleColor.Yellow; * Console.Write("APU regs, "); * Console.ForegroundColor = ConsoleColor.Green; * Console.Write("PPU pal, "); * Console.ForegroundColor = ConsoleColor.Cyan; * Console.WriteLine("PPU regs + sst request src");*/ Console.ForegroundColor = ConsoleColor.White; }
static void printState() { byte[] ss = new byte[256]; int cons_y = Console.CursorTop; edio.memRD(Edio.ADDR_SSR, ss, 0, ss.Length); Console.SetCursorPosition(0, cons_y); for (int i = 0; i < ss.Length; i += 16) { if (i == 128) { Console.WriteLine(""); } if (i % 256 == 0) { Console.WriteLine(""); } if (i >= 128 + 32 && i < 128 + 64) { Console.ForegroundColor = ConsoleColor.Green; } else { Console.ForegroundColor = ConsoleColor.White; } Console.WriteLine("" + BitConverter.ToString(ss, i, 8) + " " + BitConverter.ToString(ss, i + 8, 8)); } }
int testMEM(string name, int addr, int size) { byte[] buff; Console.Write("Testing " + name + "..."); //simple data bus test buff = new byte[] { 0xAA }; edio.memWR(addr, buff, 0, buff.Length); edio.memRD(addr, buff, 0, buff.Length); if (buff[0] != 0xAA) { return(0x01); } buff = new byte[] { 0x55 }; edio.memWR(addr, buff, 0, buff.Length); edio.memRD(addr, buff, 0, buff.Length); if (buff[0] != 0x55) { return(0x01); } //full data bus + partial address bus test buff = new byte[256]; for (int i = 0; i < buff.Length; i++) { buff[i] = (byte)i; } edio.memWR(addr, buff, 0, buff.Length); edio.memRD(addr, buff, 0, buff.Length); for (int i = 0; i < buff.Length; i++) { if (buff[i] != i) { return(0x02); } } //full address bus test for (int i = 0; i < size; i *= 2) { buff = BitConverter.GetBytes(i); edio.memWR(addr + i, buff, 0, buff.Length); if (i == 0) { i = 2; } } for (int i = 0; i < size; i *= 2) { edio.memRD(addr + i, buff, 0, buff.Length); int val = BitConverter.ToInt32(buff, 0); if (val != i) { return(0x03); } if (i == 0) { i = 2; } } //random data test Random rnd = new Random((int)DateTime.Now.Ticks); byte[] rnd_dat = new byte[0x10000]; buff = new byte[rnd_dat.Length]; rnd.NextBytes(rnd_dat); edio.memWR(addr, rnd_dat, 0, rnd_dat.Length); edio.memRD(addr, buff, 0, buff.Length); for (int i = 0; i < buff.Length; i++) { if (buff[i] != rnd_dat[i]) { return(0x04); } } return(0); }