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

📄 snes9x.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 <stdlib.h>#include <stdio.h>#ifdef HAVE_STRINGS_H#include <strings.h>#endif#include "snes9x.h"#include "memmap.h"#include "display.h"#include "cheats.h"#ifdef DEBUGGERextern FILE *trace;#endifvoid S9xUsage (){    S9xMessage (S9X_INFO, S9X_USAGE, "snes9x: S9xUsage: snes9x <options> <rom image filename>\n\n");    S9xMessage (S9X_INFO, S9X_USAGE, "Where <options> can be:\n");        S9xMessage (S9X_INFO, S9X_USAGE, "\-cycles or -h <num>       Percentage of CPU cycles to execute every scan line (default 90)\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-frameskip or -f <num>    Screen update frame skip rate (default 2)\n");    S9xExtraUsage ();    S9xMessage (S9X_INFO, S9X_USAGE, "\-hirom or -fh or -hr      Force Hi-ROM memory map, useful for hacked ROM images.\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-lorom or -fl or -lr      Force Lo-ROM memory map, useful for hacked ROM images.\n");    //FIXME: -old bsolete?    S9xMessage (S9X_INFO, S9X_USAGE, "\-old or -o                Enable old-style SNES joypad emulation\n");    //FIXME: -noold obsolete?    S9xMessage (S9X_INFO, S9X_USAGE, "\-noold or -no             Disbale old-style SNES joypad emulation\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-soundskip or -ss <num>   Sound CPU skip-waiting method, 0 - 3 (default 0)\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-sound or -s              Enable digital sound output (default: enabled)\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-nosound or -ns           Disable digital sound output\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-soundquality or -r <num> Sound sample playback rate/quality, 0-7 (default 4)\n");#ifdef __sgi/* BS: changed the sample rate values to match the IRIX options */    S9xMessage (S9X_INFO, S9X_USAGE, "\                          0 - off, 1 - 8192, 2 - 11025, 3 - 16000,\n\                          4 - 22050 (default), 5 - 32000, 6 - 44100,\n\                          7 - 48000\n");#else    S9xMessage (S9X_INFO, S9X_USAGE, "\                          0 - off, 1 - 8192, 2 - 11025, 3 - 16500,\n\                          4 - 22050 (default), 5 - 29300, 6 - 36600,\n\                          7 - 44000\n");#endif    S9xMessage (S9X_INFO, S9X_USAGE, "\-stereo                   Enable stereo sound (default: mono sound)\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-mono                     Enable mono sound (default: mono sound)\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-buffersize or -B         Sound playback buffer size (default auto for playback rate)\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-nospeedhacks or -N       Disable some internal speed ups that break a few  ROMs\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-speedhacks or -SH        Enable some internal speed ups that break a few ROMs\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-loadsnapshot or -l <filename>\n\                          Load saved game position snapshot file & required ROM\n\                          image.\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-swapjoypads or -s        Swap joypad 1 and 2 around\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-pal or -p                Fool ROM into thinking that this is a PAL SNES system\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-ntsc or -n               Fool ROM into thinking that this is a NTCS SNES system\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-interleaved or -i        ROM image is in interleaved format.\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-interleaved2 or -i2      ROM image is in interleaved 2 format\n");	    S9xMessage (S9X_INFO, S9X_USAGE, "\-interleavedgd24 or -gd24 ROM image is in Game Doctor 24 Mbit format\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-nohdma or -H             Disable H-DMA emulation (default: enabled)\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-hdma or -NH              Enable H-DMA emulation (default: enabled)\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-layering or -L           Swap some background priority levels - helps some games\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-graphicwindows           Enable graphic window effects (default: enabled)\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-nographicwindows or -nw  Disable graphic window effects (default: enabled)\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-nopatch                  Disable IPS autopatching\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-nocheat                  Disable the cheat system\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-cheat                    Enables the cheat system\n");#ifdef DEBUGGER    S9xMessage (S9X_INFO, S9X_USAGE, "\-noirq or -I              Disable processor IRQ (for debugging)\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-debug or -d              Enter debug mode once ROM has loaded\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-trace or -t              Trace CPU instructions to file (WARNING: file gets very large!)\n");#endif    #ifdef JOYSTICK_SUPPORT#ifdef __linux    S9xMessage (S9X_INFO, S9X_USAGE, "\-joydevX /dev/jsY         Use joystick device /dev/jsY for emulation of gamepad X\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-joymapX 0 1 2 3 4 5 6 7  Joystick buttons which should be assigned to gamepad X - A B X Y TL TR Start and Select\n");#else    S9xMessage (S9X_INFO, S9X_USAGE, "\-four or -4               Single standard PC joystick has four buttons\n");    S9xMessage (S9X_INFO, S9X_USAGE, "\-six or -6                Single standard PC joystick has six buttons\n");#endif    S9xMessage (S9X_INFO, S9X_USAGE, "\-nojoy or -j              Disable joystick support\n");#endif        S9xMessage (S9X_INFO, S9X_USAGE, "\\nROM image needs to be in Super MagiCom (*.smc), Super FamiCom (*.sfc),\n\*.fig, or split (*.1, *.2, or sf32527a, sf32527b, etc) format and can be\n\compressed with gzip or compress.\n");    exit (1);}#ifdef STORMextern int dofps;extern int hicolor;extern int secondjoy;extern int minimal;int prelude=0;extern int unit;#endifchar *S9xParseArgs (char **argv, int argc){    char *rom_filename = NULL;    for (int i = 1; i < argc; i++)    {	if (*argv[i] == '-')	{            if (strcasecmp (argv [i], "--selftest") == 0)	    {              // FIXME: Probable missuse of S9X_USAGE              // FIXME: Actual tests. But at least this checks for coredumps.              S9xMessage (S9X_INFO, S9X_USAGE, "Running selftest ...");              S9xMessage (S9X_INFO, S9X_USAGE, "snes9x started:\t[OK]");              S9xMessage (S9X_INFO, S9X_USAGE, "All tests ok.");              exit(0);	    }	    if (strcasecmp (argv [i], "-so") == 0 ||		strcasecmp (argv [i], "-sound") == 0)	    {		Settings.NextAPUEnabled = TRUE;	    }	    else if (strcasecmp (argv [i], "-ns") == 0 ||		     strcasecmp (argv [i], "-nosound") == 0)	    {		Settings.NextAPUEnabled = FALSE;	    }	    else if (strcasecmp (argv [i], "-soundskip") == 0 ||		     strcasecmp (argv [i], "-sk") == 0)	    {		if (i + 1 < argc)		    Settings.SoundSkipMethod = atoi (argv [++i]);		else		    S9xUsage ();	    }	    else if (strcasecmp (argv [i], "-ra") == 0 ||		     strcasecmp (argv [i], "-ratio") == 0)	    {		if ((i + 1) < argc)		{		}		else		    S9xUsage ();	    }	    else if (strcasecmp (argv [i], "-h") == 0 ||		     strcasecmp (argv [i], "-cycles") == 0)	    {		if (i + 1 < argc)		{		    int p = atoi (argv [++i]);		    if (p > 0 && p < 200)			Settings.CyclesPercentage = p;		}		else		    S9xUsage ();	    }	    else if (strcasecmp (argv [i], "-nh") == 0 ||		     strcasecmp (argv [i], "-nohdma") == 0)	    {		Settings.DisableHDMA = TRUE;	    }	    else if (strcasecmp (argv [i], "-ha") == 0 ||		     strcasecmp (argv [i], "-hdma") == 0)	    {		Settings.DisableHDMA = FALSE;	    }	    else if (strcasecmp (argv [i], "-n") == 0 ||		     strcasecmp (argv [i], "-nospeedhacks") == 0)	    {		Settings.ShutdownMaster = FALSE;	    }	    else if (strcasecmp (argv [i], "-sh") == 0 ||		     strcasecmp (argv [i], "-speedhacks") == 0)	    {		Settings.ShutdownMaster = TRUE;	    }	    else if (strcasecmp (argv [i], "-p") == 0 ||		     strcasecmp (argv [i], "-pal") == 0)	    {		Settings.ForcePAL = TRUE;	    }	    else if (strcasecmp (argv [i], "-n") == 0 ||		     strcasecmp (argv [i], "-ntsc") == 0)	    {		Settings.ForceNTSC = TRUE;	    }	    else if (strcasecmp (argv [i], "-f") == 0 ||		     strcasecmp (argv [i], "-frameskip") == 0)	    {		if (i + 1 < argc)		    Settings.SkipFrames = atoi (argv [++i]) + 1;		else		    S9xUsage ();	    }	    else if (strcasecmp (argv [i], "-fh") == 0 ||		     strcasecmp (argv [i], "-hr") == 0 ||		     strcasecmp (argv [i], "-hirom") == 0)		Settings.ForceHiROM = TRUE;	    else if (strcasecmp (argv [i], "-fl") == 0 ||		     strcasecmp (argv [i], "-lr") == 0 ||		     strcasecmp (argv [i], "-lorom") == 0)		Settings.ForceLoROM = TRUE;	    else if (strcasecmp (argv [i], "-hd") == 0 ||		     strcasecmp (argv [i], "-header") == 0 ||		     strcasecmp (argv [i], "-he") == 0)	    {		Settings.ForceHeader = TRUE;	    }	    else if (strcasecmp (argv [i], "-nhd") == 0 ||		     strcasecmp (argv [i], "-noheader") == 0)	    {		Settings.ForceNoHeader = TRUE;	    }	    else if (strcasecmp (argv [i], "-bs") == 0)	    {		Settings.BS = TRUE;	    }#ifdef DEBUGGER	    else if (strcasecmp (argv [i], "-d") == 0 ||		     strcasecmp (argv [i], "-debug") == 0)	    {		CPU.Flags |= DEBUG_MODE_FLAG;	    }	    else if (strcasecmp (argv [i], "-t") == 0 ||		     strcasecmp (argv [i], "-trace") == 0)	    {		trace = fopen ("trace.log", "wb");		CPU.Flags |= TRACE_FLAG;	    }#endif	    else if (strcasecmp (argv [i], "-L") == 0 ||		     strcasecmp (argv [i], "-layering") == 0)		Settings.BGLayering = TRUE;	    else if (strcasecmp (argv [i], "-nl") == 0 ||		     strcasecmp (argv [i], "-nolayering") == 0)		Settings.BGLayering = FALSE;	    else if (strcasecmp (argv [i], "-O") == 0 ||		     strcasecmp (argv [i], "-tileredraw") == 0)	    {	    }	    else if (strcasecmp (argv [i], "-no") == 0 ||		     strcasecmp (argv [i], "-lineredraw") == 0)	    {	    }	    else if (strcasecmp (argv [i], "-tr") == 0 ||		     strcasecmp (argv [i], "-transparency") == 0)	    {		Settings.ForceTransparency = TRUE;		Settings.ForceNoTransparency = FALSE;	    }	    else if (strcasecmp (argv [i], "-nt") == 0 ||		     strcasecmp (argv [i], "-notransparency") == 0)	    {		Settings.ForceNoTransparency = TRUE;		Settings.ForceTransparency = FALSE;

⌨️ 快捷键说明

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