diff options
author | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-05-01 14:16:00 +1000 |
---|---|---|
committer | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-05-01 14:16:00 +1000 |
commit | 65e93275c17c14eea06d495958ed77fe569ce8f1 (patch) | |
tree | 4e9ee5a9bbbc6ac1ea5a4b38dd2cace48bbb5c70 /src/debug.h | |
parent | 8f09f4249cec8ccc187b3f9ee5094fb3080900a9 (diff) |
changed directory structure, and other minor stuff
Diffstat (limited to 'src/debug.h')
-rw-r--r-- | src/debug.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/debug.h b/src/debug.h new file mode 100644 index 0000000..06d4733 --- /dev/null +++ b/src/debug.h @@ -0,0 +1,44 @@ +// 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 page m from memory to stdout. +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("%02x ", Memory[(m+(i+j))]); + } + printf("\n"); + } +} + +// Dump CPU values +void dStatusDump(void){ +printf("\ +\t..acc:\t%x\tcycles:\t%d\n\ +\t....X:\t%x\tlength:\t%d\n\ +\t....Y:\t%x\t...add:\t%x\n\ +\tstack:\t%x\t.value:\t%x\n\ +\tflags:\t%x\n\ +\n\ +", acc, idata.cycles, X, idata.length, Y, idata.add, S, idata.value, P); +} |