// 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("%2x ", Memory[(m+(i+j))]); } printf("\n"); } } // Dump CPU values void dStatusDump(void){ printf("\ ..acc:\t%x\tcycles:\t%d\n\ ....X:\t%x\tlength:\t%d\n\ ....Y:\t%x\t...add:\t%x\n\ stack:\t%x\t.value:\t%x\n\ flags:\t%x\n\ ", acc, idata.cycles, X, idata.length, Y, idata.add, S, idata.value, P); }