/// <summary> /// Update the main processor values in the console. /// </summary> public static void UpdateMain(ushort programCounter, byte stackPointer, int cycles) { int baseX = 1, baseY = 4; AsciiRenderer.SetString(baseX + 4, baseY + 2, BM.UShortToHex(programCounter), (programCounter == 0xFFFC ? blue : white)); AsciiRenderer.SetString(baseX + 13, baseY + 2, BM.ByteToHex(stackPointer), (stackPointer == 0x00 ? dark_gray : white)); AsciiRenderer.SetString(baseX + 20, baseY + 2, cycles.ToString() + " ", (cycles == 0 ? dark_gray : red)); }
/// <summary> /// Update the memory in the console. /// </summary> public static void UpdateMemory(ushort programCounter, byte stackPointer, int currentPage, Mem memory) { int baseX = 1, baseY = 16; // Zero page: for (int y = 0; y < 16; y++) { for (int x = 0; x < 16; x++) { byte b = memory.Get(y * 16 + x); AsciiRenderer.SetString(baseX + 1 + 2 * x, baseY + 2 + y, BM.ByteToHex(b), b == 0x00 ? very_dark_gray : white); } } int s_baseX = 40, s_baseY = 16; // Stack page: for (int y = 0; y < 16; y++) { for (int x = 0; x < 16; x++) { int n = y * 16 + x; byte b = memory.Get(256 + n); AsciiRenderer.SetString(s_baseX + 1 + 2 * x, s_baseY + 2 + y, BM.ByteToHex(b), b == 0x00 ? very_dark_gray : white, n == stackPointer ? blue : black); } } int sc_baseX = 1, sc_baseY = 36; int pc = -1; if (programCounter >= currentPage * 256 && programCounter < currentPage * 256 + 256) { pc = programCounter - currentPage * 256; } AsciiRenderer.SetString(sc_baseX, sc_baseY, $"{PageNumberToName(currentPage)} (${BM.UShortToHex((ushort)(currentPage * 256))}-${BM.UShortToHex((ushort)(currentPage * 256 + 255))}): ", gray); // Current page: for (int y = 0; y < 8; y++) { for (int x = 0; x < 32; x++) { int n = y * 32 + x; byte b = memory.Get(currentPage * 256 + n); AsciiRenderer.SetString(sc_baseX + 1 + 2 * x, sc_baseY + 2 + y, BM.ByteToHex(b), b == 0x00 ? very_dark_gray : white, pc == n ? blue : black); } } int pa_baseX = 40, pa_baseY = 10; // Programmed Addresses: for (int x = 0; x < 6; x++) { byte b = memory.Get((int)Mem.MAX_MEM - 6 + x); AsciiRenderer.SetString(pa_baseX + 1 + 3 * x, pa_baseY + 2, BM.ByteToHex(b), b == 0x00 ? dark_gray : white); } }