📄 fxdbg.cpp
字号:
/* * Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. * * (c) Copyright 1996 - 2001 Gary Henderson (gary@daniver.demon.co.uk) and * Jerremy Koot (jkoot@snes9x.com) * * Super FX C emulator code * (c) Copyright 1997 - 1999 Ivar (Ivar@snes9x.com) and * Gary Henderson. * Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_. * * DSP1 emulator code (c) Copyright 1998 Ivar, _Demo_ and Gary Henderson. * C4 asm and some C emulation code (c) Copyright 2000 zsKnight and _Demo_. * C4 C code (c) Copyright 2001 Gary Henderson (gary@daniver.demon.co.uk). * * DOS port code contains the works of other authors. See headers in * individual files. * * Snes9x homepage: www.snes9x.com * * Permission to use, copy, modify and distribute Snes9x in both binary and * source form, for non-commercial purposes, is hereby granted without fee, * providing that this license information and copyright notice appear with * all copies and any derived work. * * This software is provided 'as-is', without any express or implied * warranty. In no event shall the authors be held liable for any damages * arising from the use of this software. * * Snes9x is freeware for PERSONAL USE only. Commercial users should * seek permission of the copyright holders first. Commercial use includes * charging money for Snes9x or software derived from Snes9x. * * The copyright holders request that bug fixes and improvements to the code * should be forwarded to them so everyone can benefit from the modifications * in future versions. * * Super NES and Super Nintendo Entertainment System are trademarks of * Nintendo Co., Limited and its subsidiary companies. */#include "fxemu.h"#include "fxinst.h"#include <stdio.h>#include <string.h>extern const char *fx_apvMnemonicTable[];extern struct FxRegs_s GSU;/* When printing a line from the pipe, it could look like this: 01:8006 f4 fb 86 iwt r4,#$86fb The values are: program bank: 01 adress: 8006 values at memory address 8006: f4 fb 86 instruction in the pipe: iwt r4,#$86fb Note! If the instruction has more than one byte (like in 'iwt') and the instruction is in a delay slot, the second and third byte displayed will not be the same as those used. Since the instrction is in a delay slot, the first byte of the instruction will be taken from the pipe at the address after the branch instruction, and the next one or two bytes will be taken from the address that the branch points to. This is a bit complicated, but I've taken this into account, in this debug function. (See the diffrence of how the values vPipe1 and vPipe2 are read, compared to the values vByte1 and vByte2) */void FxPipeString(char * pvString){ char *p; uint32 vOpcode = (GSU.vStatusReg & 0x300) | ((uint32)PIPE); const char *m = fx_apvMnemonicTable[vOpcode]; uint8 vPipe1,vPipe2,vByte1,vByte2; uint8 vPipeBank = GSU.vPipeAdr >> 16; /* The next two bytes after the pipe's address */ vPipe1 = GSU.apvRomBank[vPipeBank][USEX16(GSU.vPipeAdr+1)]; vPipe2 = GSU.apvRomBank[vPipeBank][USEX16(GSU.vPipeAdr+2)]; /* The actual next two bytes to be read */ vByte1 = PRGBANK(USEX16(R15)); vByte2 = PRGBANK(USEX16(R15+1)); /* Print ROM address of the pipe */ sprintf(pvString, "%02x:%04x %02x ", USEX8(vPipeBank), USEX16(GSU.vPipeAdr), USEX8(PIPE)); p = &pvString[strlen(pvString)]; /* Check if it's a branch instruction */ if( PIPE >= 0x05 && PIPE <= 0x0f ) { sprintf(&pvString[11], "%02x ", USEX8(vPipe1));#ifdef BRANCH_DELAY_RELATIVE sprintf(p, m, USEX16(R15 + SEX8(vByte1) + 1 ) );#else sprintf(p, m, USEX16(R15 + SEX8(vByte1) - 1 ) );#endif } /* Check for 'move' instruction */ else if( PIPE >= 0x10 && PIPE <= 0x1f && TF(B) ) sprintf(p, "move r%d,r%d", USEX8(PIPE & 0x0f), GSU.pvSreg - GSU.avReg); /* Check for 'ibt', 'lms' or 'sms' */ else if( PIPE >= 0xa0 && PIPE <= 0xaf ) { sprintf(&pvString[11], "%02x ", USEX8(vPipe1)); if( (GSU.vStatusReg & 0x300) == 0x100 || (GSU.vStatusReg & 0x300) == 0x200 ) sprintf(p, m, USEX16(vByte1) << 1 ); else sprintf(p, m, USEX16(vByte1) ); } /* Check for 'moves' */ else if( PIPE >= 0xb0 && PIPE <= 0xbf && TF(B) ) sprintf(p, "moves r%d,r%d", GSU.pvDreg - GSU.avReg, USEX8(PIPE & 0x0f) ); /* Check for 'iwt', 'lm' or 'sm' */ else if( PIPE >= 0xf0 ) { sprintf(&pvString[11], "%02x %02x ", USEX8(vPipe1), USEX8(vPipe2)); sprintf(p, m, USEX8(vByte1) | (USEX16(vByte2)<<8) ); } /* Normal instruction */ else strcpy(p, m);}const char *fx_apvMnemonicTable[] ={ /* * ALT0 Table */ /* 00 - 0f */ "stop", "nop", "cache", "lsr", "rol", "bra $%04x","blt $%04x","bge $%04x", "bne $%04x","beq $%04x","bpl $%04x","bmi $%04x","bcc $%04x","bcs $%04x","bvc $%04x","bvs $%04x", /* 10 - 1f */ "to r0", "to r1", "to r2", "to r3", "to r4", "to r5", "to r6", "to r7", "to r8", "to r9", "to r10", "to r11", "to r12", "to r13", "to r14", "to r15", /* 20 - 2f */ "with r0", "with r1", "with r2", "with r3", "with r4", "with r5", "with r6", "with r7", "with r8", "with r9", "with r10", "with r11", "with r12", "with r13", "with r14", "with r15", /* 30 - 3f */ "stw (r0)","stw (r1)","stw (r2)", "stw (r3)", "stw (r4)", "stw (r5)", "stw (r6)", "stw (r7)", "stw (r8)","stw (r9)","stw (r10)","stw (r11)","loop", "alt1", "alt2", "alt3", /* 40 - 4f */ "ldw (r0)","ldw (r1)","ldw (r2)", "ldw (r3)", "ldw (r4)", "ldw (r5)", "ldw (r6)", "ldw (r7)", "ldw (r8)","ldw (r9)","ldw (r10)","ldw (r11)","plot", "swap", "color", "not", /* 50 - 5f */ "add r0", "add r1", "add r2", "add r3", "add r4", "add r5", "add r6", "add r7", "add r8", "add r9", "add r10", "add r11", "add r12", "add r13", "add r14", "add r15", /* 60 - 6f */ "sub r0", "sub r1", "sub r2", "sub r3", "sub r4", "sub r5", "sub r6", "sub r7", "sub r8", "sub r9", "sub r10", "sub r11", "sub r12", "sub r13", "sub r14", "sub r15", /* 70 - 7f */ "merge", "and r1", "and r2", "and r3", "and r4", "and r5", "and r6", "and r7", "and r8", "and r9", "and r10", "and r11", "and r12", "and r13", "and r14", "and r15", /* 80 - 8f */ "mult r0", "mult r1", "mult r2", "mult r3", "mult r4", "mult r5", "mult r6", "mult r7", "mult r8", "mult r9", "mult r10", "mult r11", "mult r12", "mult r13", "mult r14", "mult r15", /* 90 - 9f */ "sbk", "link #1", "link #2", "link #3", "link #4", "sex", "asr", "ror", "jmp (r8)","jmp (r9)","jmp (r10)","jmp (r11)","jmp (r12)","jmp (r13)","lob", "fmult", /* a0 - af */ "ibt r0,#$%02x", "ibt r1,#$%02x", "ibt r2,#$%02x", "ibt r3,#$%02x", "ibt r4,#$%02x", "ibt r5,#$%02x", "ibt r6,#$%02x", "ibt r7,#$%02x", "ibt r8,#$%02x", "ibt r9,#$%02x", "ibt r10,#$%02x", "ibt r11,#$%02x", "ibt r12,#$%02x", "ibt r13,#$%02x", "ibt r14,#$%02x", "ibt r15,#$%02x", /* b0 - bf */ "from r0", "from r1", "from r2", "from r3", "from r4", "from r5", "from r6", "from r7", "from r8", "from r9", "from r10", "from r11", "from r12", "from r13", "from r14", "from r15", /* c0 - cf */ "hib", "or r1", "or r2", "or r3", "or r4", "or r5", "or r6", "or r7", "or r8", "or r9", "or r10", "or r11", "or r12", "or r13", "or r14", "or r15", /* d0 - df */ "inc r0", "inc r1", "inc r2", "inc r3", "inc r4", "inc r5", "inc r6", "inc r7", "inc r8", "inc r9", "inc r10", "inc r11", "inc r12", "inc r13", "inc r14", "getc", /* e0 - ef */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -