⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fxdbg.cpp

📁 SFC游戏模拟器 snes9x 1.43 的原代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*******************************************************************************  Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.   (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com) and                            Jerremy Koot (jkoot@snes9x.com)  (c) Copyright 2001 - 2004 John Weidman (jweidman@slip.net)  (c) Copyright 2002 - 2004 Brad Jorsch (anomie@users.sourceforge.net),                            funkyass (funkyass@spam.shaw.ca),                            Joel Yliluoma (http://iki.fi/bisqwit/)                            Kris Bleakley (codeviolation@hotmail.com),                            Matthew Kendora,                            Nach (n-a-c-h@users.sourceforge.net),                            Peter Bortas (peter@bortas.org) and                            zones (kasumitokoduck@yahoo.com)  C4 x86 assembler and some C emulation code  (c) Copyright 2000 - 2003 zsKnight (zsknight@zsnes.com),                            _Demo_ (_demo_@zsnes.com), and Nach  C4 C++ code  (c) Copyright 2003 Brad Jorsch  DSP-1 emulator code  (c) Copyright 1998 - 2004 Ivar (ivar@snes9x.com), _Demo_, Gary Henderson,                            John Weidman, neviksti (neviksti@hotmail.com),                            Kris Bleakley, Andreas Naive  DSP-2 emulator code  (c) Copyright 2003 Kris Bleakley, John Weidman, neviksti, Matthew Kendora, and                     Lord Nightmare (lord_nightmare@users.sourceforge.net  OBC1 emulator code  (c) Copyright 2001 - 2004 zsKnight, pagefault (pagefault@zsnes.com) and                            Kris Bleakley  Ported from x86 assembler to C by sanmaiwashi  SPC7110 and RTC C++ emulator code  (c) Copyright 2002 Matthew Kendora with research by                     zsKnight, John Weidman, and Dark Force  S-DD1 C emulator code  (c) Copyright 2003 Brad Jorsch with research by                     Andreas Naive and John Weidman   S-RTC C emulator code  (c) Copyright 2001 John Weidman    ST010 C++ emulator code  (c) Copyright 2003 Feather, Kris Bleakley, John Weidman and Matthew Kendora  Super FX x86 assembler emulator code   (c) Copyright 1998 - 2003 zsKnight, _Demo_, and pagefault   Super FX C emulator code   (c) Copyright 1997 - 1999 Ivar, Gary Henderson and John Weidman  SH assembler code partly based on x86 assembler code  (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)    Specific ports contains the works of other authors. See headers in  individual files.   Snes9x homepage: http://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",

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -