From ee742e6020248f9695cc9ce5bbace5f42814383e Mon Sep 17 00:00:00 2001 From: alekseiplusplus Date: Fri, 21 Apr 2023 03:44:47 +1000 Subject: have to call it a night. --- headers/debug.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 headers/debug.h (limited to 'headers/debug.h') diff --git a/headers/debug.h b/headers/debug.h new file mode 100644 index 0000000..bb6ba40 --- /dev/null +++ b/headers/debug.h @@ -0,0 +1,41 @@ +// debug.h +// Various functions useful for use during development. + +// Converts a single character to hexadecimal +int dCharToNum(char c){ + // 0x0 - 0x9 + if (c != 0x20 && (c >= 0x30 && c <= 0x39)){ + return (c - 0x30); + } + // 0xA - 0xF + else if (c != 0x20 && (c >= 0x41 && c <= 0x46)){ + return (c - 0x37); + // 0xa - 0xf + }else if (c != 0x20 && (c >= 0x61 && c <= 0x66)){ + return (c - 0x57); + // Invalid + }else{ + return -1; + } +} + +// Dump a particular page in memory. +void dPageDump(short m){ + m <<= 8; + for(int i = 0; i < 256; i+=16){ + printf("\t"); + for(int j = 0; j < 16; j+=1){ + printf("%2x ", Memory[(m+(i+j))]); + } + printf("\n"); + } +} + +// Dump CPU values +void dStatusDump(void){ + printf(" acc:\t%x\n X:\t%x\n Y:\t%x\nstack:\t%x\nflags:\t%x\n", acc, X, Y, S, P); +} + +void dIdataDump(void){ + printf("cycles:\t%d\nlength:\t%d\n add:\t%x\n value:\t%x\n", idata.cycles, idata.length, idata.add, idata.value); +} \ No newline at end of file -- cgit v1.2.3