Пример #1
0
void SNES9X_Quit(void)
{
	DeinitGameWindow();

	if (cartOpen)
	{
		SNES9X_SaveSRAM();
		S9xSaveCheatFile(S9xGetFilename(".cht", PATCH_DIR));
	}

	if (Settings.SPC7110)
		(*CleanUp7110)();
	
	finished = true;
}
Пример #2
0
void
S9xLoadState (const char *filename)
{
    S9xFreezeGame (S9xGetFilename (".undo", SNAPSHOT_DIR));

    if (S9xUnfreezeGame (filename))
    {
        sprintf (buf, "%s loaded", filename);
        S9xSetInfoString (buf);
    }
    else
    {
        fprintf (stderr, "Failed to load state file: %s\n", filename);
    }
}
Пример #3
0
void pauseGame()
{
	if (!autosave) return;

	const char * file = S9xGetFilename(FILE_FREEZE);
	int result = S9xFreezeGame(file);

	printf("Freeze: %s", file);

	if (!result) {
		Config.snapshotSave = false; // Serves as a flag to Hgw
		puts(" failed");
	} else {
		puts(" ok");
	}
}
Пример #4
0
void
S9xExit()
{
	if(GFX.ZBuffer) {
		delete [] GFX.ZBuffer;
		GFX.ZBuffer = 0; 
	}
	
	if(GFX.SubZBuffer) {
		delete [] GFX.SubZBuffer;
		GFX.SubZBuffer = 0;
	}
	Memory.SaveSRAM (S9xGetFilename (".srm"));
    Memory.Deinit ();
    S9xDeinitAPU ();
}
Пример #5
0
void S9xSDD1LoadLoggedData ()
{
    FILE *fs = fopen (S9xGetFilename (".dat"), "rb");

    Memory.SDD1LoggedDataCount = Memory.SDD1LoggedDataCountPrev = 0;

    if (fs)
    {
	int c = fread (Memory.SDD1LoggedData, 8, 
		       MEMMAP_MAX_SDD1_LOGGED_ENTRIES, fs);

	if (c != EOF)
	    Memory.SDD1LoggedDataCount = Memory.SDD1LoggedDataCountPrev = c;
	fclose (fs);
    }
}
Пример #6
0
void S9xSaveSRAM (void)
{
	char path[MAX_PATH];
	
	if (CPU.SRAMModified)
	{
		sprintf(path,"%s%s%s",snesSramDir,DIR_SEP,S9xGetFilename (".srm"));
		Memory.SaveSRAM (path);
		CPU.SRAMModified = FALSE;
		if (snesMenuOptions.autoSram == 2) { 
			Draw16x16Square(framebuffer16[0], 320-16, 240-16, 0, 0, 0);
			Draw16x16Square(framebuffer16[1], 320-16, 240-16, 0, 0, 0);
			Draw16x16Square(framebuffer16[2], 320-16, 240-16, 0, 0, 0);
			Draw16x16Square(framebuffer16[3], 320-16, 240-16, 0, 0, 0);
			}	
		sync();
	}
}
Пример #7
0
void S9xSaveSRAM (int showWarning)
{
	if (CPU.SRAMModified)
	{
		if(Memory.SaveSRAM ((s8*)S9xGetFilename (".srm")))
		{
			sync();
		}
		else
		{
			MenuMessageBox("Saving SRAM...Failed","SRAM Not Saved!","",MENU_MESSAGE_BOX_MODE_PAUSE);
		}
	}
	else if(showWarning)
	{
		MenuMessageBox("Saving SRAM...Ignored!","No changes have been made to SRAM","So there is nothing to save!",MENU_MESSAGE_BOX_MODE_MSG);
	}
	sleep(1);
}
Пример #8
0
static int S9xGetSDD1Dir(char * packdir)
{
	char dir[_MAX_DIR + 1];
	char drive[_MAX_DRIVE + 1];
	char name[_MAX_FNAME + 1];
	char ext[_MAX_EXT + 1];

	PathSplit(S9xGetFilename(FILE_ROM), drive, dir, name, ext);

	if (strncmp(Memory.ROMName, "Star Ocean", 10) == 0) {
        PathMake(packdir, drive, dir, "socnsdd1", 0);
        return 1;
	} else if(strncmp(Memory.ROMName, "STREET FIGHTER ALPHA2", 21) == 0) {
		PathMake(packdir, drive, dir, "sfa2sdd1", 0);
		return 1;
	} else {
		S9xMessage(S9X_WARNING, S9X_ROM_INFO,
			"WARNING: No default SDD1 pack for this ROM");
		return 0;
	}
}
Пример #9
0
void S9xSDD1SaveLoggedData()
{
   if (Memory.SDD1LoggedDataCount != Memory.SDD1LoggedDataCountPrev)
   {
      qsort(Memory.SDD1LoggedData, Memory.SDD1LoggedDataCount, 8,
            S9xCompareSDD1LoggedDataEntries);

      FILE* fs = fopen(S9xGetFilename(".dat"), "wb");

      if (fs)
      {
         fwrite(Memory.SDD1LoggedData, 8,
                Memory.SDD1LoggedDataCount, fs);
         fclose(fs);
#if defined(__linux)
         //chown (S9xGetFilename (".dat"), getuid (), getgid ());
#endif
      }
      Memory.SDD1LoggedDataCountPrev = Memory.SDD1LoggedDataCount;
   }
}
Пример #10
0
static bool8 NPClientBeginOpenROMImage(WindowRef window)
{
	CFStringRef			numRef, romRef, baseRef;
	CFMutableStringRef  mesRef;
	SInt32				replaceAt;
	bool8				r;

	DeinitGameWindow();

	if (cartOpen)
	{
		SNES9X_SaveSRAM();
		S9xSaveCheatFile(S9xGetFilename(".cht", PATCH_DIR));
	}
	
	cartOpen = false;
	
	Settings.MouseMaster = true;
	Settings.SuperScopeMaster = true;
	Settings.MultiPlayer5Master = true;
	Settings.JustifierMaster = true;

	ResetCheatFinder();
	
	romRef  = CFStringCreateWithCString(kCFAllocatorDefault, nprominfo.fname, MAC_PATH_ENCODING);
	numRef  = CFCopyLocalizedString(CFSTR("NPROMNamePos"), "1");
	baseRef = CFCopyLocalizedString(CFSTR("NPROMNameMes"), "NPROM");
	mesRef  = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, baseRef);
	replaceAt = CFStringGetIntValue(numRef);
	CFStringReplace(mesRef, CFRangeMake(replaceAt - 1, 1), romRef);

	r = NavBeginOpenROMImageSheet(window, mesRef);

	CFRelease(mesRef);
	CFRelease(baseRef);
	CFRelease(numRef);
	CFRelease(romRef);
	
	return (r);
}
Пример #11
0
void S9xSDD1SaveLoggedData ()
{
    if (Memory.SDD1LoggedDataCount != Memory.SDD1LoggedDataCountPrev)
    {
	qsort (Memory.SDD1LoggedData, Memory.SDD1LoggedDataCount, 8,
	       S9xCompareSDD1LoggedDataEntries);

	const char * sdd1_dat_file = S9xGetFilename(FILE_SDD1_DAT);
	FILE *fs = fopen (sdd1_dat_file, "wb");

	if (fs)
	{
	    fwrite (Memory.SDD1LoggedData, 8,
		    Memory.SDD1LoggedDataCount, fs);
	    fclose (fs);
#if defined(__linux)
	    chown (sdd1_dat_file, getuid (), getgid ());
#endif
	}
	Memory.SDD1LoggedDataCountPrev = Memory.SDD1LoggedDataCount;
    }
}
Пример #12
0
static bool8 NPClientBeginOpenROMImage (WindowRef window)
{
	CFStringRef			numRef, romRef, baseRef;
	CFMutableStringRef	mesRef;
	SInt32				replaceAt;
	bool8				r;

	DeinitGameWindow();

	if (cartOpen)
	{
		SNES9X_SaveSRAM();
		S9xResetSaveTimer(false);
		S9xSaveCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
	}

	cartOpen = false;

	ResetCheatFinder();

	romRef  = CFStringCreateWithCString(kCFAllocatorDefault, nprominfo.fname, kCFStringEncodingUTF8);
	numRef  = CFCopyLocalizedString(CFSTR("NPROMNamePos"), "1");
	baseRef = CFCopyLocalizedString(CFSTR("NPROMNameMes"), "NPROM");
	mesRef  = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, baseRef);
	replaceAt = CFStringGetIntValue(numRef);
	CFStringReplace(mesRef, CFRangeMake(replaceAt - 1, 1), romRef);

	r = NavBeginOpenROMImageSheet(window, mesRef);

	CFRelease(mesRef);
	CFRelease(baseRef);
	CFRelease(numRef);
	CFRelease(romRef);

	return (r);
}
Пример #13
0
void
S9xAutoSaveSRAM ()
{
    Memory.SaveSRAM (S9xGetFilename (".srm", SRAM_DIR));
    S9xSaveCheatFile (S9xGetFilename (".cht", CHEAT_DIR));
}
Пример #14
0
void S9xLoadSRAM (void)
{
	Memory.LoadSRAM ((s8*)S9xGetFilename (".srm"));
}
Пример #15
0
void
S9xAutoSaveSRAM ()
{
    Memory.SaveSRAM (S9xGetFilename (S9x_FILESRM));
}
Пример #16
0
int
S9xOpenROM (const char *rom_filename)
{
    uint32 flags;
    bool8  loaded;

    if (gui_config->rom_loaded)
    {
        S9xAutoSaveSRAM ();
    }

#ifdef NETPLAY_SUPPORT
    S9xNetplayDisconnect ();
#endif

    flags = CPU.Flags;

    loaded = FALSE;

    if (Settings.Multi)
        loaded = Memory.LoadMultiCart (Settings.CartAName, Settings.CartBName);
    else if (rom_filename)
        loaded = Memory.LoadROM (rom_filename);

    Settings.StopEmulation = !loaded;

    if (!loaded && rom_filename)
    {
        char dir [_MAX_DIR + 1];
        char drive [_MAX_DRIVE + 1];
        char name [_MAX_FNAME + 1];
        char ext [_MAX_EXT + 1];
        char fname [_MAX_PATH + 1];

        _splitpath (rom_filename, drive, dir, name, ext);
        _makepath (fname, drive, dir, name, ext);

        strcpy (fname, S9xGetDirectory (ROM_DIR));
        strcat (fname, SLASH_STR);
        strcat (fname, name);

        if (ext [0])
        {
            strcat (fname, ".");
            strcat (fname, ext);
        }

        _splitpath (fname, drive, dir, name, ext);
        _makepath (fname, drive, dir, name, ext);

        if ((Settings.StopEmulation = !Memory.LoadROM (fname)))
        {
            fprintf (stderr, _("Error opening: %s\n"), rom_filename);

            loaded = FALSE;
        }
        else
            loaded = TRUE;
    }

    if (loaded)
    {
        Memory.LoadSRAM (S9xGetFilename (".srm", SRAM_DIR));
    }
    else
    {
        CPU.Flags = flags;
        Settings.Paused = 1;

        S9xNoROMLoaded ();
        top_level->refresh ();

        return 1;
    }

    CPU.Flags = flags;

    if (stateMan.init (gui_config->rewind_buffer_size * 1024 * 1024))
    {
        printf ("Using rewind buffer of %uMB\n", gui_config->rewind_buffer_size);
    }

    S9xROMLoaded ();

    return 0;
}
Пример #17
0
bool8 S9xDoScreenshot(int width, int height){
#ifdef HAVE_LIBPNG
    FILE *fp;
    png_structp png_ptr;
    png_infop info_ptr;
    png_color_8 sig_bit;
    png_color pngpal[256];
    int imgwidth;
    int imgheight;
    const char *fname=S9xGetFilename( FILE_SCREENSHOT );
    
#if 0
    Settings.TakeScreenshot=FALSE;
#endif

    if((fp=fopen(fname, "wb"))==NULL){
        perror("Screenshot failed");
        return FALSE;
    }

    png_ptr=png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
    if(!png_ptr){
        fclose(fp);
        unlink(fname);
        return FALSE;
    }
    info_ptr=png_create_info_struct(png_ptr);
    if(!info_ptr){
        png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
        fclose(fp);
        unlink(fname);
        return FALSE;
    }

    if(setjmp(png_jmpbuf(png_ptr))){
        perror("Screenshot: setjmp");
        png_destroy_write_struct(&png_ptr, &info_ptr);
        fclose(fp);
        unlink(fname);
        return FALSE;
    }

    imgwidth=width;
    imgheight=height;
#if 0
    if(Settings.StretchScreenshots==1){
        if(width<=256 && height>SNES_HEIGHT_EXTENDED) imgwidth=width<<1;
        if(width>256 && height<=SNES_HEIGHT_EXTENDED) imgheight=height<<1;
    } else if(Settings.StretchScreenshots==2){
#endif
        if(width<=256) imgwidth=width<<1;
        if(height<=SNES_HEIGHT_EXTENDED) imgheight=height<<1;
#if 0
    }
#endif
    
    png_init_io(png_ptr, fp);
    png_set_IHDR(png_ptr, info_ptr, imgwidth, imgheight, 8, 
                 (PNG_COLOR_TYPE_RGB),
                 PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
                 PNG_FILTER_TYPE_DEFAULT);

    /* 5 bits per color */
    sig_bit.red=5;
    sig_bit.green=5;
    sig_bit.blue=5;
    png_set_sBIT(png_ptr, info_ptr, &sig_bit);
    png_set_shift(png_ptr, &sig_bit);

    png_write_info(png_ptr, info_ptr);
    
    png_set_packing(png_ptr);

    png_byte *row_pointer=new png_byte [png_get_rowbytes(png_ptr, info_ptr)];
    uint8 *screen=GFX.Screen;
    for(int y=0; y<height; y++, screen+=GFX.Pitch){
        png_byte *rowpix = row_pointer;
        for(int x=0; x<width; x++){
                uint32 r, g, b;
                DECOMPOSE_PIXEL((*(uint16 *)(screen+2*x)), r, g, b);
                *(rowpix++) = r;
                *(rowpix++) = g;
                *(rowpix++) = b;
                if(imgwidth!=width){
                    *(rowpix++) = r;
                    *(rowpix++) = g;
                    *(rowpix++) = b;
                }
        }
        png_write_row(png_ptr, row_pointer);
        if(imgheight!=height)
            png_write_row(png_ptr, row_pointer);
    }

    delete [] row_pointer;
        
    png_write_end(png_ptr, info_ptr);
    png_destroy_write_struct(&png_ptr, &info_ptr);

    fclose(fp);
    fprintf(stderr, "%s saved.\n", fname);
    return TRUE;
#else
    perror("Screenshot support not available (libpng was not found at build time)");
	return FALSE;
#endif
}
Пример #18
0
int
S9xOpenROM (const char *rom_filename)
{
    uint32 flags;
    bool8  loaded;

    if (gui_config->rom_loaded)
    {
        S9xAutoSaveSRAM ();
    }

#ifdef NETPLAY_SUPPORT
    S9xNetplayDisconnect ();
#endif

    flags = CPU.Flags;

    loaded = FALSE;

    if (Settings.Multi)
        loaded = Memory.LoadMultiCart (Settings.CartAName, Settings.CartBName);
    else if (rom_filename)
        loaded = Memory.LoadROM (rom_filename);

    Settings.StopEmulation = !loaded;

    if (!loaded && rom_filename)
    {
        char dir [_MAX_DIR + 1];
        char drive [_MAX_DRIVE + 1];
        char name [_MAX_FNAME + 1];
        char ext [_MAX_EXT + 1];
        char fname [_MAX_PATH + 1];

        _splitpath (rom_filename, drive, dir, name, ext);
        _makepath (fname, drive, dir, name, ext);

        strcpy (fname, S9xGetDirectory (ROM_DIR));
        strcat (fname, SLASH_STR);
        strcat (fname, name);

        if (ext [0])
        {
            strcat (fname, ".");
            strcat (fname, ext);
        }

        _splitpath (fname, drive, dir, name, ext);
        _makepath (fname, drive, dir, name, ext);

        if ((Settings.StopEmulation = !Memory.LoadROM (fname)))
        {
            fprintf (stderr, _("Error opening: %s\n"), rom_filename);

            loaded = FALSE;
        }
        else
            loaded = TRUE;
    }

    if (loaded)
    {
        Memory.LoadSRAM (S9xGetFilename (".srm", SRAM_DIR));
        S9xLoadCheatFile (S9xGetFilename (".cht", CHEAT_DIR));

        for (unsigned int i = 0; i < Cheat.num_cheats; i++)
        {
            if (Cheat.c[i].enabled)
            {
                /* RAM is fresh, so we need to clean out old saved values */
                Cheat.c[i].saved = FALSE;
                S9xApplyCheat (i);
            }
        }
    }
    else
    {
        S9xReset ();

        CPU.Flags = flags;
        Settings.Paused = 1;

        S9xNoROMLoaded ();
        top_level->refresh ();

        return 1;
    }

    CPU.Flags = flags;

    S9xROMLoaded ();

    return 0;
}
Пример #19
0
bool8 SNES9X_OpenMultiCart (void)
{
	Boolean	r;
	char	cart[2][PATH_MAX + 1];

	DeinitGameWindow();

	if (cartOpen)
	{
		SNES9X_SaveSRAM();
		S9xResetSaveTimer(false);
		S9xSaveCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
	}

	ResetCheatFinder();

	if (!MultiCartDialog())
	{
		cartOpen = false;
		return (false);
	}

	spcFileCount = pngFileCount = 0;

	Settings.ForceHeader   = (headerDetect     == kHeaderForce  );
	Settings.ForceNoHeader = (headerDetect     == kNoHeaderForce);
	Settings.ForcePAL      = (videoDetect      == kPALForce     );
	Settings.ForceNTSC     = (videoDetect      == kNTSCForce    );

	GFX.InfoString = NULL;
	GFX.InfoStringTimeout = 0;

	S9xResetSaveTimer(true);

	for (int i = 0; i < 2; i++)
	{
		cart[i][0] = 0;
		if (multiCartPath[i])
			r = CFStringGetCString(multiCartPath[i], cart[i], PATH_MAX, kCFStringEncodingUTF8);
	}

	SNES9X_InitSound();

	if (Memory.LoadMultiCart(cart[0], cart[1]))
	{
		cartOpen = true;

		SNES9X_LoadSRAM();

		for (int i = 0; i < 2; i++)
		{
			if (cart[i][0])
				ChangeTypeAndCreator(cart[i], 'CART', '~9X~');
		}

		ApplyNSRTHeaderControllers();

		for (int a = 0; a < MAC_MAX_PLAYERS; a++)
			for (int b = 0; b < 12; b++)
				autofireRec[a].nextTime[b] = 0;

		return (true);
	}
	else
	{
		cartOpen = false;
		return (false);
	}
}
Пример #20
0
void menu_dispupdate(void)
{
//	char temp[256];
//	char disptxt[20][256];

	//memset(GFX.Screen + 320*12*2,0x11,320*200*2);
	//draw blue screen
	for(int y=0;y<240;y++){
		for(int x=0;x<256*2;x+=2){
			memset(GFX.Screen + 320*y*2+x,0x11,2);
		}
	}
	

	strcpy(disptxt[0],"Snes9x4P v20120226");

	strcpy(disptxt[1],"------------------");
	strcpy(disptxt[2],"Exit Emulator");
	strcpy(disptxt[3],"Reset Game");
	strcpy(disptxt[4],"Credits");
	strcpy(disptxt[5],"------------------");
	strcpy(disptxt[6],"Save State");
	strcpy(disptxt[7],"Load State");
	strcpy(disptxt[8],"State Slot                  No.");
	sprintf(temp,"%s%d",disptxt[8],SaveSlotNum);
	strcpy(disptxt[8],temp);
	strcpy(disptxt[9],"------------------");
	
	strcpy(disptxt[10],"Display mode     ");
	sprintf ( temp, "%s%s", disptxt [10], blit_scalers [ g_scale ].desc_en );
	strcpy ( disptxt[10], temp );
	
	strcpy(disptxt[11],"Frameskip                  ");
	if (Settings.SkipFrames == AUTO_FRAMERATE)
		sprintf(temp,"%s Auto",disptxt[11]);
	else
		sprintf(temp,"%s %02d/%d",disptxt[11],(int) Memory.ROMFramesPerSecond, Settings.SkipFrames);
	strcpy(disptxt[11],temp);
	
	strcpy(disptxt[12],"V-Sync                     ");
	if(g_vsync)
		sprintf(temp,"%s   On",disptxt[12]);
	else
		sprintf(temp,"%s  Off",disptxt[12]);
	strcpy(disptxt[12],temp);
	
	strcpy(disptxt[13],"Display Frame Rate         ");
	if(Settings.DisplayFrameRate)
		sprintf(temp,"%s   On",disptxt[13]);
	else
		sprintf(temp,"%s  Off",disptxt[13]);
	strcpy(disptxt[13],temp);
	
	strcpy(disptxt[14],"Transparency               ");
	if(Settings.Transparency)
		sprintf(temp,"%s   On",disptxt[14]);
	else
		sprintf(temp,"%s  Off",disptxt[14]);
	strcpy(disptxt[14],temp);
	
	strcpy(disptxt[15],"Cut Top                        ");
	sprintf(temp,"%s%d",disptxt[15],cut_top);
	strcpy(disptxt[15],temp);
	strcpy(disptxt[16],"Cut Bottom                     ");
	sprintf(temp,"%s%d",disptxt[16],cut_bottom);
	strcpy(disptxt[16],temp);
	strcpy(disptxt[17],"Cut Left                       ");
	sprintf(temp,"%s%d",disptxt[17],cut_left);
	strcpy(disptxt[17],temp);
	strcpy(disptxt[18],"Cut Right                      ");
	sprintf(temp,"%s%d",disptxt[18],cut_right);
	strcpy(disptxt[18],temp);
	
	strcpy(disptxt[19],"------------------");
	
	strcpy(disptxt[20],"Alt. Sample Decoding       ");
	if(Settings.AltSampleDecode)
		sprintf(temp,"%s   On",disptxt[20]);
	else
		sprintf(temp,"%s  Off",disptxt[20]);
	strcpy(disptxt[20],temp);
	
	strcpy(disptxt[21],"");
	battery_level = batt_level();
	strcpy(disptxt[22],"                   Battery:");
	if (battery_level >= 100)
		sprintf(temp,"%s %d%%",disptxt[22],battery_level);
	else if (battery_level >=10)
		sprintf(temp,"%s  %d%%",disptxt[22],battery_level);
	else
		sprintf(temp,"%s   %d%%",disptxt[22],battery_level);
	strcpy(disptxt[22],temp);
	


	for(int i=0;i<=22;i++)
	{
		if(i==cursor)
			sprintf(temp," >%s",disptxt[i]);
		else
			sprintf(temp,"  %s",disptxt[i]);
		strcpy(disptxt[i],temp);

		if ( i<=21 )
			S9xDisplayString (disptxt[i], GFX.Screen, 640,i*10+50);
		else //put the last line (for the battery indicator) a little lower than the rest
			S9xDisplayString (disptxt[i], GFX.Screen, 640,i*10+55);
	}

	//show screen shot for snapshot
	if(SaveSlotNum_old != SaveSlotNum)
	{
		strcpy(temp," Loading...");
		S9xDisplayString (temp, GFX.Screen +320/*280*/, 640,80/*204*/);
		//S9xDeinitUpdate (320, 240);
		char fname[256], ext[8];
		sprintf(ext, ".s0%d", SaveSlotNum);
		strcpy(fname, S9xGetFilename (ext));
		load_screenshot(fname);
		SaveSlotNum_old = SaveSlotNum;
	}
	show_screenshot();
	S9xDeinitUpdate (320, 240);
}
Пример #21
0
void menu_loop(void)
{
	bool8_32 exit_loop = false;
	char fname[256], ext[8];
	char snapscreen_tmp[17120];

	uint8 *keyssnes = 0;

	SaveSlotNum_old = -1;

	Scale_org = Scale;
	highres_current=Settings.SupportHiRes;

	capt_screenshot();
	memcpy(snapscreen_tmp,snapscreen,17120);

	Scale = false;
	Settings.SupportHiRes=FALSE;
	S9xDeinitDisplay();
	S9xInitDisplay(0, 0);

	menu_dispupdate();
	sys_sleep(100000);

	SDL_Event event;

	do
	{
		while(SDL_PollEvent(&event)==1)
		{

				//PANDORA & DINGOO & WIN32 -----------------------------------------------------
				keyssnes = SDL_GetKeyState(NULL);

				if(keyssnes[sfc_key[UP_1]] == SDL_PRESSED)
					cursor--;
				else if(keyssnes[sfc_key[DOWN_1]] == SDL_PRESSED)
					cursor++;
				else if( (keyssnes[sfc_key[A_1]] == SDL_PRESSED) ||
						 (keyssnes[sfc_key[LEFT_1]] == SDL_PRESSED) ||
						 (keyssnes[sfc_key[RIGHT_1]] == SDL_PRESSED) )
				{
					switch(cursor)
					{
						case 2: //exit snes9x
							if (keyssnes[sfc_key[A_1]] == SDL_PRESSED)
								S9xExit();
							break;
						case 3: //reset snes9x
							if ((keyssnes[sfc_key[A_1]] == SDL_PRESSED))
							{
								//make sure the sram is stored before resetting the console
								//it should work without, but better safe than sorry...
								Memory.SaveSRAM (S9xGetFilename (".srm"));
								S9xReset();
								exit_loop = TRUE;
							}
							break;
						case 4:
							if (keyssnes[sfc_key[A_1]] == SDL_PRESSED)
								ShowCredit();
							break;
						case 6: //save state
							if (keyssnes[sfc_key[A_1]] == SDL_PRESSED)
							{
								memcpy(snapscreen,snapscreen_tmp,16050);
								show_screenshot();
								strcpy(fname," Saving...");
								S9xDisplayString (temp, GFX.Screen +320/*280*/, 640,80/*204*/);
								S9xDeinitUpdate (320, 240);
								sprintf(ext, ".s0%d", SaveSlotNum);
								strcpy(fname, S9xGetFilename (ext));
								save_screenshot(fname);
								sprintf(ext, ".00%d", SaveSlotNum);
								strcpy(fname, S9xGetFilename (ext));
								S9xFreezeGame (fname);
								sync();
								exit_loop = TRUE;
							}
							break;
						case 7: //load state
							if (keyssnes[sfc_key[A_1]] == SDL_PRESSED)
							{
								sprintf(ext, ".00%d", SaveSlotNum);
								strcpy(fname, S9xGetFilename (ext));
								S9xLoadSnapshot (fname);
								exit_loop = TRUE;
							}
							break;
						case 8: //select save state slot
							if (keyssnes[sfc_key[LEFT_1]] == SDL_PRESSED)
							{
								if ( SaveSlotNum == 0 )
									SaveSlotNum = MAX_SAVE_SLOTS-1; // slots start at 0, so 10 slots means slot 0 to 9
								else
									--SaveSlotNum;
							}
							else
							if (keyssnes[sfc_key[RIGHT_1]] == SDL_PRESSED)
							{
								if ( SaveSlotNum == MAX_SAVE_SLOTS-1 ) // slots start at 0, so 10 slots means slot 0 to 9
									SaveSlotNum = 0;
								else
									++SaveSlotNum;
							}
							break;
						case 10: // rotate through scalers
							if (keyssnes[sfc_key[RIGHT_1]] == SDL_PRESSED)
							{
								do
								{
									g_scale = (blit_scaler_e) ( ( g_scale + 1 ) % bs_max );
								} while ( ( blit_scalers [ g_scale ].valid == bs_invalid )
											|| ( highres_current && !(blit_scalers [ g_scale ].support_hires) ) );
							} else if (keyssnes[sfc_key[LEFT_1]] == SDL_PRESSED)
							{
								do
								{
									g_scale = (blit_scaler_e) ( g_scale - 1 );
									if (g_scale < 1) g_scale = (blit_scaler_e)(bs_max-1);
								} while ( ( blit_scalers [ g_scale ].valid == bs_invalid )
											|| ( highres_current && !(blit_scalers [ g_scale ].support_hires) ) );
							}
							// now force update the display, so that the new scaler is directly used (fixes some glitches)
							S9xDeinitDisplay();
							S9xInitDisplay(0, 0);
							break;
						case 11: // set frameskip
							if (Settings.SkipFrames == AUTO_FRAMERATE)
								Settings.SkipFrames = 10;
	
							if (keyssnes[sfc_key[LEFT_1]] == SDL_PRESSED)
								Settings.SkipFrames--;
							else
								Settings.SkipFrames++;
	
							if(Settings.SkipFrames<=0 || Settings.SkipFrames==10)
								Settings.SkipFrames = AUTO_FRAMERATE;
							else if (Settings.SkipFrames>=11)
								Settings.SkipFrames = 1;
							break;
						case 12: // set vsync
							if (g_vsync)
								g_vsync = 0;
							else 
								g_vsync = 1;
							break;
						case 13: // set display fps
							Settings.DisplayFrameRate = !Settings.DisplayFrameRate;
							break;
						case 14: // set transparency
							Settings.Transparency = !Settings.Transparency;
							break;
						case 15: // cut lines from top
							if (keyssnes[sfc_key[RIGHT_1]] == SDL_PRESSED)
								cut_top++;
							else if (keyssnes[sfc_key[LEFT_1]] == SDL_PRESSED && cut_top>0)
								cut_top--;
							// now force update the display, so that the new scaler is directly used (fixes some glitches)
							S9xDeinitDisplay();
							S9xInitDisplay(0, 0);
							break;
						case 16: // cut lines from bottom
							if (keyssnes[sfc_key[RIGHT_1]] == SDL_PRESSED)
								cut_bottom++;
							else if (keyssnes[sfc_key[LEFT_1]] == SDL_PRESSED && cut_bottom>0)
								cut_bottom--;
							S9xDeinitDisplay();
							S9xInitDisplay(0, 0);
							break;
						case 17: // cut from the left
							if (keyssnes[sfc_key[RIGHT_1]] == SDL_PRESSED)
								cut_left++;
							else if (keyssnes[sfc_key[LEFT_1]] == SDL_PRESSED && cut_left>0)
								cut_left--;
							S9xDeinitDisplay();
							S9xInitDisplay(0, 0);
							break;
						case 18: // cut from the right
							if (keyssnes[sfc_key[RIGHT_1]] == SDL_PRESSED)
								cut_right++;
							else if (keyssnes[sfc_key[LEFT_1]] == SDL_PRESSED && cut_right>0)
								cut_right--;
							S9xDeinitDisplay();
							S9xInitDisplay(0, 0);
							break;
						case 20:
//offer an option to change to alternative sample decoding
//cf. http://www.gp32x.com/board/index.php?/topic/55378-snes9x4d4p-another-new-build-now-with-hi-res-and-new-rom-picker/page__view__findpost__p__958860
							if (Settings.AltSampleDecode)
								Settings.AltSampleDecode = 0;
							else 
								Settings.AltSampleDecode = 1;
							break;
					}
				}

				if(cursor==1)
					cursor=20;
				else if(cursor==21)	
					cursor=2;
				if(cursor==5 || cursor==9 || cursor==19) {
					if(keyssnes[sfc_key[UP_1]] == SDL_PRESSED)
						cursor--;
					else if(keyssnes[sfc_key[DOWN_1]] == SDL_PRESSED)
						cursor++;
				}

				menu_dispupdate();
				sys_sleep(1000);

				break;
		}
	}
	while( exit_loop!=TRUE && keyssnes[sfc_key[B_1]] != SDL_PRESSED );

	Scale = Scale_org;
	Settings.SupportHiRes=highres_current;
	S9xDeinitDisplay();
	S9xInitDisplay(0, 0);
}
Пример #22
0
bool8 SNES9X_OpenCart (FSRef *inRef)
{
	OSStatus	err;
	FSRef		cartRef;
	char		filename[PATH_MAX + 1];

	DeinitGameWindow();

	if (cartOpen)
	{
		SNES9X_SaveSRAM();
		S9xResetSaveTimer(false);
		S9xSaveCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
	}

	ResetCheatFinder();

	if (!inRef)
	{
		if (!NavOpenROMImage(&cartRef))
		{
			cartOpen = false;
			return (false);
		}
	}
	else
		cartRef = *inRef;

	spcFileCount = pngFileCount = 0;

	CheckSaveFolder(&cartRef);

	Settings.ForceLoROM          = (romDetect        == kLoROMForce       );
	Settings.ForceHiROM          = (romDetect        == kHiROMForce       );
	Settings.ForceHeader         = (headerDetect     == kHeaderForce      );
	Settings.ForceNoHeader       = (headerDetect     == kNoHeaderForce    );
	Settings.ForceInterleaved    = (interleaveDetect == kInterleaveForce  );
	Settings.ForceInterleaved2   = (interleaveDetect == kInterleave2Force );
	Settings.ForceInterleaveGD24 = (interleaveDetect == kInterleaveGD24   );
	Settings.ForceNotInterleaved = (interleaveDetect == kNoInterleaveForce);
	Settings.ForcePAL            = (videoDetect      == kPALForce         );
	Settings.ForceNTSC           = (videoDetect      == kNTSCForce        );

	GFX.InfoString = NULL;
	GFX.InfoStringTimeout = 0;

	S9xResetSaveTimer(true);

	err = FSRefMakePath(&cartRef, (unsigned char *) filename, PATH_MAX);

	SNES9X_InitSound();

	if (Memory.LoadROM(filename))
	{
		cartOpen = true;

		SNES9X_LoadSRAM();

		ChangeTypeAndCreator(filename, 'CART', '~9X~');

		AddRecentItem(&cartRef);
		BuildRecentMenu();

		ApplyNSRTHeaderControllers();

		for (int a = 0; a < MAC_MAX_PLAYERS; a++)
			for (int b = 0; b < 12; b++)
				autofireRec[a].nextTime[b] = 0;

		return (true);
	}
	else
	{
		cartOpen = false;
		return (false);
	}
}
Пример #23
0
bool8 SNES9X_OpenCart(FSRef *inRef)
{
	OSStatus		err;
	FSCatalogInfo	info;
	FSRef			cartRef;
	char			filename[PATH_MAX + 1];
	
	DeinitGameWindow();	

	if (cartOpen)
	{
		SNES9X_SaveSRAM();
		S9xSaveCheatFile(S9xGetFilename(".cht", PATCH_DIR));
	}

	Settings.MouseMaster = true;
	Settings.SuperScopeMaster = true;
	Settings.MultiPlayer5Master = true;
	Settings.JustifierMaster = true;

	ResetCheatFinder();
	
	if (!inRef)
	{
		DisableMenus();
		
		if (!NavOpenROMImage(&cartRef))
		{
			cartOpen = false;
			EnableMenus();
			return false;
		}
		
		EnableMenus();
	}
	else
		cartRef = *inRef;
		
	spcFileCount = pngFileCount = 0;

	err = FSGetCatalogInfo(&cartRef, kFSCatInfoVolume, &info, nil, nil, nil);
	lockedROMMedia = IsLockedMedia(info.volume);

	Settings.ForceLoROM          = (romDetect        == kLoROMForce       );
	Settings.ForceHiROM          = (romDetect        == kHiROMForce       );
	Settings.ForceNotInterleaved = (interleaveDetect == kNoInterleaveForce);
	Settings.ForceInterleaved    = (interleaveDetect == kInterleaveForce  );
	Settings.ForceInterleaved2   = (interleaveDetect == kInterleave2Force );
	Settings.ForceInterleaveGD24 = (interleaveDetect == kInterleaveGD24   );
	Settings.ForcePAL            = (videoDetect      == kPALForce         );
	Settings.ForceNTSC           = (videoDetect      == kNTSCForce        );
	Settings.ForceHeader         = (headerDetect     == kHeaderForce      );
	Settings.ForceNoHeader       = (headerDetect     == kNoHeaderForce    );
	
	Settings.ForceSuperFX = Settings.ForceNoSuperFX = false;
	Settings.ForceDSP1    = Settings.ForceNoDSP1    = false;
	Settings.ForceSA1     = Settings.ForceNoSA1     = false;
	Settings.ForceC4      = Settings.ForceNoC4      = false;
	Settings.ForceSDD1    = Settings.ForceNoSDD1    = false;
	
	GFX.InfoString = nil;
	GFX.InfoStringTimeout = 0;
	
	err = FSRefMakePath(&cartRef, (unsigned char *) filename, PATH_MAX);
		
	if (Memory.LoadROM(filename))
	{
		cartOpen = true;

		SNES9X_InitSound();
		SNES9X_LoadSRAM();
		
		ChangeTypeAndCreator(filename, 'CART', '~9X~');
		
		AddRecentItem(&cartRef);
		BuildRecentMenu();
		
		for (int a = 0; a < MAC_MAX_PLAYERS; a++)
			for (int b = 0; b < 12; b++)
				autofireRec[a].nextTime[b] = 0;

		return true;
	}
	else
	{
		cartOpen = false;
		return false;
	}
}
Пример #24
0
void S9xAutoSaveSRAM()
{
	Memory.SaveSRAM(S9xGetFilename(FILE_SRAM));
}
Пример #25
0
int main(int argc, char ** argv) {
	// Initialise SDL
	if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) < 0) 
		DIE("SDL_Init: %s", SDL_GetError());

  GL_Init();

  //Init SDL_TTF to print text to the screen...
  if ( TTF_Init() )
  {
    fprintf( stderr, "Error initializing SDL_ttf!\n" );
    exit ( 1 );
  }

	S9xInitDisplay(argc, argv);

	// Configure snes9x
#if CONF_GUI
	OssoInit();						// Hildon-games-wrapper initialization.
#endif
	S9xLoadConfig(argc, argv);		// Load config files and parse cmd line.
  readOptions();
#if CONF_GUI
	OssoConfig();					// Apply specific hildon-games config.
#endif

  // S9x initialization
  S9xInitDisplay(argc, argv);
  S9xInitAudioOutput();
  S9xInitInputDevices();

  while(1)
  {
    S9xInit();
    S9xReset();

    char * rom = romSelector();
    S9xSetRomFile(rom);
    free(rom);

    // Load rom and related files: state, unfreeze if needed
    loadRom();
    resumeGame();

    // Late initialization
    sprintf(String, "DrNokSnes - %s", Memory.ROMName);
    S9xSetTitle(String);
    S9xHacksLoadFile(Config.hacksFile);
    if (!S9xGraphicsInit())
      DIE("S9xGraphicsInit failed");
    S9xAudioOutputEnable(true);
    SDL_PauseAudio(0);
    S9xVideoReset();

    Config.running = true;
    do {
      frameSync();			// May block, or set frameskip to true.
      S9xMainLoop();			// Does CPU things, renders if needed.
      pollEvents();
      //Ouch that this is going here...
      updateBindingMessage();
    } while (Config.running);

    S9xVideoReset();
    S9xGraphicsDeinit();

    // Save state
    Memory.SaveSRAM(S9xGetFilename(FILE_SRAM));
    pauseGame();
    Memory.Deinit();
    S9xDeinitAPU();
  }

  // Deinitialization
  S9xAudioOutputEnable(false);
  S9xDeinitInputDevices();
  S9xDeinitAudioOutput();
  S9xDeinitDisplay();

	// Late deinitialization
	S9xUnloadConfig();
#if CONF_GUI
	OssoDeinit();
#endif

	SDL_Quit();

	return 0;
}
Пример #26
0
void SNES9X_LoadSRAM(void)
{
	if (cartOpen)
		Memory.LoadSRAM(S9xGetFilename(".srm", SRAM_DIR));
}