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

📄 main.cpp

📁 SNES game emulator. C and asm files.
💻 CPP
字号:
/*	MAIN.CPP - Main module.
	Ah, protected mode!  I love it!  I can have variables as big as I want and allocate
	4 MB memory chunks without so much as an swap-file manager.

	Command line arguments:

	<filename> - automatically load the specified ROM.
	-Ta - Specifies ROM type (to bypass the autodetect). These apply only to the
		  ROM also specified on the command line. 'a' is one of these:
		  H - ROM is assumed to be HiROM
		  L - ROM is assumed to be LoROM
		  I - ROM is assumed to be in interleaved format (interleave format support
		      NOT implemented since I don't know how to recognise or decode it.)
		  N - emulator will pretend it is a NTSC system
		  P - emulator will pretend it is a PAL system
	-Im - Video mode of user interface
	-Gm - Video mode of game.
		Video modes:
		1=Chained mode Q (256x256)
		2=Chained Mode 13H (320x200)
		3=Original Mode X (320x240)
		4=GUI Normal (360x240)
		5=GUI Tall (360x360)
	-B - Graphics Benchmark: tests all video modes speed of clears and pageflips
*/

#include "Common.hpp"
#include "GrEngine.hpp"
#include "FileMan.hpp"
#include "GUI.hpp"
#include "CPU.hpp"
#include "SPC700.hpp"

/*void runsystem (char *filename);
void displaymenu ();
int getmenuchoice ();
void filemenu ();
*/
/*char ts [6][30] = {
	"Fontedit\\..\\..\\hello\\goodbye",
	"Fontedit\\font8.pas",
	"Invalid\\invalid.pas",
	"C:\\Windows\\",
	"C:\\Windows",
	"C:\\Windows\\sol.exe"
};*/

int main (int argc, char *argv [])
{
	int x, y, key = 0;
	int retval = GUIRETURN, starttime;
	int ms[6],fps[6];
	boolean th = false, tl = false, tn = false, tp = false;
	char *loadromnow = NULL;
	boolean nogui = false;

	printf ("\n%s: Super Nintendo Emulator... Coded by Qwertie.\n", PROGRAMNAME);
	printf ("This project started about Oct 08 1997. (for the second time!)\n");
	printf ("This EXE file generated on %s at %s MST.\n",__DATE__,__TIME__);
	printf ("Initializing: debug-out, timer, mouse, keyboard, GUI, palette, file manager...\n");
	fflush (stdout);
	restartdebug ();
	inittimer ();
	initmouse ();
	initkeyboard ();
	initcustompalette ();
	initfilemanager (argv[0]);
	loadsettings ("SNEqr.Cfg");
	for (y = 1; y < argc; y++) {
		if (argv [y][0] == '-' || argv [y][0] == '/') {
			strupr (argv [y]);
			switch (argv [y][1]) {
			case 'B':
				for (x = 1; x < 6; x++) {
					setvideomode (x, false);
					applycustompalette ();
					starttime = tmsec;
					for (y = 0; y < 256; y++) {
						memset (&vs [y * xres], y, xres);
						copyscreen ();
						clearscreen();
					}
					ms[x] = tmsec - starttime;
					fps[x] = 256000 / ms[x];
				}
				setvideomode (0, false);
				for (x = 1; x < 6; x++) {
					printf ("Video mode %d: 256 pageflips in %d milliseconds (%d fps.)\n", x, ms[x], fps[x]);
					debug0 ("Video mode %d: 256 pageflips in %d milliseconds (%d fps.)\n", x, ms[x], fps[x]);
				}
				printf ("<Press any key>\n");
				getch ();
				enddebug ();
				return 0;
			case 'X':
				nogui = true;
				break;
			case 'I':
				if (argv [y][2] == 'M' && argv [y][3] >= '1' && argv [y][3] <= '5')
					guires = argv [y][3] - '0';
				else
					printf ("Bad GUI option: %s", argv[y]);
				break;
			case 'G':
				if (argv [y][2] == 'M' && argv [y][3] >= '1' && argv [y][3] <= '5')
					gameres = argv [y][3] - '0';
				else
					printf ("Bad game option: %s", argv[y]);
				break;
			case 'T':
				switch (argv [y][2]) {
				case 'H': th = true; break;
				case 'L': tl = true; break;
				case 'N': tn = true; break;
				case 'P': tp = true; break;
				default: printf ("Bad ROM type option: %s", argv[y]);
				}
				break;
			default:
				printf ("Unrecognised switch: %s", argv[y]);
				break;
			}
		} else {
			loadromnow = argv [y];
			// Filename
		}
	}
	tdelay (250);
	if (loadromnow != NULL) {
		loadrom (loadromnow, false, th ? FORCEHIROM : (tl ? FORCELOROM : 0));
	}
	printf ("Press any key to continue.");
	fflush (stdout);
	getch ();
    /*do {
		if (kbhit ())
			key = getch();
		checkmouse ();
		printf ("ticks: %d msec: %d oldticks: %d, mouse: %d, %d (%d/%d)\n", ticks, tmsec, oldticks, mousex, mousey, lbutton, rbutton);
    } while (key != 27); */
	/*setvideomode (guires, false);
	applycustompalette ();
	do {
		key = 0;
		if (kbhit ())
			key = getch();
		clearscreen ();
		
		setcolor (rand() % 4 + 12);
		for (y = 0; y < 16; y++) {
			for (x = 0; x < 8; x++) {
				printf8 (x * 32, y * 8, "%s:%d", keyname [y * 8 + x], keydown [y * 8 + x]);
			}
		}
		setcolor (103); printf10 (1, 191, "This is a test of the 10 pt font - ~`'!@#$%^&*[]_+=|\\/?;:0123456789");
		setcolor (111); printf10 (0, 190, "This is a test of the 10 pt font - ~`'!@#$%^&*[]_+=|\\/?;:0123456789");
		setcolor (103); printf10 (0, 200, "ABCDEFGHIJKLMNOPQRSTUVWXYZ; abcdefghijklmnopqrstuvwxyz");
		setcolor (103); printf8 (1, 211, "This is a test of the 8 pt font - ~`'!@#$%^&*{[(<>)]}_+=|\\/?;:0123456789");
		setcolor (111); printf8 (0, 210, "This is a test of the 8 pt font - ~`'!@#$%^&*{[(<>)]}_+=|\\/?;:0123456789");
		setcolor (103); printf8 (0, 218, "ABCDEFGHIJKLMNOPQRSTUVWXYZ; abcdefghijklmnopqrstuvwxyz");
		if (keydown [2]) drawwindow (mainwindow);
		if (keydown [3]) drawwindow (saveloadwindow);
		if (keydown [4]) drawwindow (startupwindow);
		if (keydown [5]) drawwindow (ingamewindow);
		if (keydown [6]) drawwindow (joypadwindow);
		if (keydown [7]) drawwindow (guisettingwindow);
		if (keydown [8]) drawwindow (cheatcodewindow);
		if (keydown [9]) drawwindow (loadwindow);
		if (keydown[10]) drawwindow (messagewindow);
		checkmouse ();
		drawmouse ();
		copyscreen ();
	} while (key != 27);*/
	/* Create initial SNES screen (welcome screen) */
	debug0 ("curgs=%P",curgs);
	setvideomode (loadromnow ? gameres : guires, true);
	applycustompalette ();
	savegamepalette (); // now gamepalette==custompalette
	for (y = 0; y < 16; y++) {
		drawbox (0, y * 16, 255, y * 16 + 15, y);
		if (y != 15)
			drawpatternbox (0, y * 16 + 8, 255, y * 16 + 15, y + 1, 1);
	}
	setcolor (0x1E); printf10 (6,10,"%s v%s", PROGRAMNAME, PROGRAMVERSION);
	setcolor (0x2E); printf10 (6,22,"Copyright %c1998 by David Piepgrass",1);
	setcolor (0x3E); printf8  (6,34,"Compiled in Watcom C++ v10.6 on %s at %s",__DATE__,__TIME__);
	setcolor (0x4E); printf8  (6,46,"E-Mail:Qwertie@sixtyfour.com; ICQ:5188638");
	if (!loadromnow) setvideomode (guires, false);
	
	memcpy (snesscreen, vs, 0x10000);
	initgui ();
	debug0 ("after initgui curgs=%P",curgs);
	while (true) {
		if (loadromnow == NULL && !nogui)
			retval = rungui ();
		else
			loadromnow = NULL;
		if (retval != GUIRETURN)
			break;
		if (keydown [KEYLSHIFT] || keydown [KEYRSHIFT])
			debugmode = true;
		runsnes ();
		if (nogui)
			break;
	}

	savetallies ();
	
	unloadcurrentrom ();
	setvideomode (0, false);
	printf ("Exit: Saving settings...\n");
	savesettings ("SNEqr.Cfg");
	enddebug ();
	uninittimer ();
	uninitkeyboard ();

	printf ("Program terminated normally.  Thank you for using this great emulator.\n");
	
	return 0;
}

⌨️ 快捷键说明

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