From 2a28a1e857d26b99600747264c4810c1e0c7be0c Mon Sep 17 00:00:00 2001 From: nakeee Date: Tue, 5 May 2009 20:32:59 +0000 Subject: [PATCH] DSP small program to print result dump files. (Looking for suggestions on how to make it look nicer) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3157 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/DSPSpy/printresult.cpp | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Source/DSPSpy/printresult.cpp diff --git a/Source/DSPSpy/printresult.cpp b/Source/DSPSpy/printresult.cpp new file mode 100644 index 0000000000..5ea511b9af --- /dev/null +++ b/Source/DSPSpy/printresult.cpp @@ -0,0 +1,55 @@ +#include +#include +#include + +typedef unsigned short u16; + +u16 reg_in[32], reg_out[1000][32]; + +void printRegs(u16 *lastRegs, u16 *regs) { + for (int i = 0; i < 32; i++) { + if (! lastRegs || lastRegs[i] != regs[i]) { + printf("%02x %04x ", i, htons(regs[i])); + } else { + printf(" "); + } + + if ((i+1) % 8 == 0) + printf("\n"); + } +} + +int main(int argc, char **argv) { + + if (argc != 2) { + fprintf(stderr, "Usage %s: \n", argv[0]); + exit(1); + } + + FILE *f = fopen(argv[1], "rb"); + int steps; + if (f) { + // read initial regs + fread(reg_in, 1, 32 * 2, f); + + // read initial regs (guess number of steps) + steps = fread(reg_out, 32 * 2, 1000, f); + fclose(f); + } else { + fprintf(stderr, "Error opening file %s\n", argv[1]); + exit(1); + } + + printf("Start with:\n"); + printRegs(NULL, reg_in); + + printf("\nStep 0:\n"); + printRegs(reg_in, reg_out[0]); + + for (int i=1;i < steps;i++) { + printf("\nStep %d:\n", i); + printRegs(reg_out[i-1], reg_out[i]); + } + + exit(0); +}