void MainWnd::screenCapture(int captureNumber) { CString buffer; CString captureDir = regQueryStringValue("captureDir", ""); int index = theApp.filename.ReverseFind('\\'); CString name; if(index != -1) name = theApp.filename.Right(theApp.filename.GetLength()-index-1); else name = theApp.filename; if(captureDir.IsEmpty()) captureDir = getDirFromFile(theApp.filename); LPCTSTR ext = "png"; if(theApp.captureFormat != 0) ext = "bmp"; if(isDriveRoot(captureDir)) buffer.Format("%s%s_%02d.%s", captureDir, name, captureNumber, ext); else buffer.Format("%s\\%s_%02d.%s", captureDir, name, captureNumber, ext); if(theApp.captureFormat == 0) theApp.emulator.emuWritePNG(buffer); else theApp.emulator.emuWriteBMP(buffer); CString msg = winResLoadString(IDS_SCREEN_CAPTURE); systemScreenMessage(msg); }
void MainWnd::readBatteryFile() { CString buffer; CString filename; int index = theApp.filename.ReverseFind('\\'); if(index != -1) buffer = theApp.filename.Right(theApp.filename.GetLength()-index-1); else buffer = theApp.filename; CString saveDir = regQueryStringValue("batteryDir", NULL); if( saveDir[0] == '.' ) { // handle as relative path char baseDir[MAX_PATH+1]; GetModuleFileName( NULL, baseDir, MAX_PATH ); baseDir[MAX_PATH] = '\0'; // for security reasons PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash strcat( baseDir, "\\" ); strcat( baseDir, saveDir ); saveDir = baseDir; } if(saveDir.IsEmpty()) saveDir = getDirFromFile(theApp.filename); if(isDriveRoot(saveDir)) filename.Format("%s%s.sav", saveDir, buffer); else filename.Format("%s\\%s.sav", saveDir, buffer); bool res = false; if(theApp.emulator.emuReadBattery) res = theApp.emulator.emuReadBattery(MakeInstanceFilename(filename)); if(res) systemScreenMessage(winResLoadString(IDS_LOADED_BATTERY)); }
void MainWnd::winLoadCheatListDefault() { CString name; CString filename; int index = theApp.filename.ReverseFind('\\'); if(index != -1) name = theApp.filename.Right(theApp.filename.GetLength()-index-1); else name = theApp.filename; CString dir = regQueryStringValue("saveDir", NULL); if(!dir.GetLength()) dir = getDirFromFile(filename); if(isDriveRoot(dir)) filename.Format("%s%s.clt", dir, name); else filename.Format("%s\\%s.clt", dir, name); winLoadCheatList(filename); }
void MainWnd::OnToolsPlayStartmovieplaying() { static bool moviePlayMessage = false; if(!moviePlayMessage) { moviePlayMessage = true; CString msg = winResLoadString(IDS_MOVIE_PLAY); CString title = winResLoadString(IDS_CONFIRM_ACTION); if(MessageBox(msg, title, MB_OKCANCEL) == IDCANCEL) return; } CString captureBuffer; CString capdir = regQueryStringValue("movieRecordDir", ""); if(capdir.IsEmpty()) capdir = getDirFromFile(theApp.filename); CString filter = theApp.winLoadFilter(IDS_FILTER_VMV); CString title = winResLoadString(IDS_SELECT_MOVIE_NAME); LPCTSTR exts[] = { ".VMV" }; FileDlg dlg(this, "", filter, 1, "VMV", exts, capdir, title, false); if(dlg.DoModal() == IDCANCEL) { return; } CString movieName = dlg.GetPathName(); captureBuffer = movieName; theApp.movieFile = fopen(movieName, "rb"); if(!theApp.movieFile) { systemMessage(IDS_CANNOT_OPEN_FILE, "Cannot open file %s", (const char *)movieName); return; } int version = 0; fread(&version, 1, sizeof(int), theApp.movieFile); if(version != 1) { systemMessage(IDS_UNSUPPORTED_MOVIE_VERSION, "Unsupported movie version %d.", version); fclose(theApp.movieFile); theApp.movieFile = NULL; return; } movieName = movieName.Left(movieName.GetLength()-3)+"VM0"; if(loadSaveGame(movieName)) { moviePlaying = true; movieFrame = 0; moviePlayFrame = 0; movieLastJoypad = 0; theApp.movieReadNext(); } else { systemMessage(IDS_CANNOT_OPEN_FILE, "Cannot open file %s", (const char *)movieName); } }
void MainWnd::OnToolsRecordStartavirecording() { CString captureBuffer; CString capdir = regQueryStringValue( "aviRecordDir", NULL ); if( capdir.IsEmpty() ) { capdir = getDirFromFile( theApp.filename ); } CString filter = theApp.winLoadFilter( IDS_FILTER_AVI ); CString title = winResLoadString( IDS_SELECT_AVI_NAME ); LPCTSTR exts[] = { ".AVI" }; FileDlg dlg( this, "", filter, 1, "AVI", exts, capdir, title, true ); if( dlg.DoModal() == IDCANCEL ) { return; } captureBuffer = theApp.soundRecordName = dlg.GetPathName(); theApp.aviRecordName = captureBuffer; aviRecording = true; if( dlg.m_ofn.nFileOffset > 0 ) { captureBuffer = captureBuffer.Left( dlg.m_ofn.nFileOffset ); } int len = captureBuffer.GetLength(); if( ( len > 3 ) && captureBuffer[ len - 1 ] == '\\' ) { captureBuffer = captureBuffer.Left( len - 1 ); } regSetStringValue( "aviRecordDir", captureBuffer ); // create AVI file bool ret; if( theApp.aviRecorder ) { delete theApp.aviRecorder; theApp.aviRecorder = NULL; } theApp.aviRecorder = new AVIWrite(); // create AVI file ret = theApp.aviRecorder->CreateAVIFile( theApp.aviRecordName ); if( !ret ) { systemMessage( IDS_AVI_CANNOT_CREATE_AVI, "Cannot create AVI file." ); delete theApp.aviRecorder; theApp.aviRecorder = NULL; aviRecording = false; return; } // add video stream ret = theApp.aviRecorder->CreateVideoStream( sizeX, sizeY, ( systemColorDepth == 32 ) ? 24 : 16, 60, this->GetSafeHwnd() ); if( !ret ) { systemMessage( IDS_AVI_CANNOT_CREATE_VIDEO, "Cannot create video stream in AVI file. Make sure the selected codec supports input in RGB24 color space!" ); delete theApp.aviRecorder; theApp.aviRecorder = NULL; aviRecording = false; return; } // add audio stream ret = theApp.aviRecorder->CreateAudioStream( 2, soundGetSampleRate(), 16, this->GetSafeHwnd() ); if( !ret ) { systemMessage( IDS_AVI_CANNOT_CREATE_AUDIO, "Cannot create audio stream in AVI file." ); delete theApp.aviRecorder; theApp.aviRecorder = NULL; aviRecording = false; return; } }
void VBA::loadSettings() { CString buffer; lastFullscreen = (VIDEO_SIZE)regQueryDwordValue("lastFullscreen", VIDEO_1024x768); languageOption = regQueryDwordValue("language", 1); if(languageOption < 0 || languageOption > 2) languageOption = 1; buffer = regQueryStringValue("languageName", ""); if(!buffer.IsEmpty()) { languageName = buffer.Left(3); } else languageName = ""; winSetLanguageOption(languageOption, true); syncToVideo = regQueryDwordValue("syncToVideo", false) ? true : false ; syncToAudio = regQueryDwordValue("syncToAudio", 1) ? true : false; fullScreenStretch = regQueryDwordValue("stretch", 0) ? true : false; videoOption = regQueryDwordValue("video", VIDEO_3X); if(videoOption < VIDEO_1X || videoOption > VIDEO_OTHER) videoOption = VIDEO_3X; fsAdapter = regQueryDwordValue("fsAdapter", 0); fsWidth = regQueryDwordValue("fsWidth", 800); fsHeight = regQueryDwordValue("fsHeight", 600); fsColorDepth = regQueryDwordValue("fsColorDepth", 32); fsFrequency = regQueryDwordValue("fsFrequency", 60); if(videoOption == VIDEO_OTHER) { if(fsWidth < 0 || fsWidth > 4095 || fsHeight < 0 || fsHeight > 4095) videoOption = 0; if(fsColorDepth != 16 && fsColorDepth != 24 && fsColorDepth != 32) videoOption = 0; } windowPositionX = regQueryDwordValue("windowX", 0); if(windowPositionX < 0) windowPositionX = 0; windowPositionY = regQueryDwordValue("windowY", 0); if(windowPositionY < 0) windowPositionY = 0; useBiosFileGBA = ( regQueryDwordValue("useBiosGBA", 0) == 1 ) ? true : false; skipBiosFile = regQueryDwordValue("skipBios", 0) ? true : false; buffer = regQueryStringValue("biosFileGBA", ""); if(!buffer.IsEmpty()) { biosFileNameGBA = buffer; } int res = regQueryDwordValue("soundEnable", 0x30f); soundSetEnable(res); long soundQuality = regQueryDwordValue("soundQuality", 1); soundSetSampleRate(44100 / soundQuality); soundSetVolume( (float)(regQueryDwordValue("soundVolume", 100)) / 100.0f ); soundInterpolation = 1 == regQueryDwordValue( "gbaSoundInterpolation", 1 ); soundFiltering = (float)regQueryDwordValue( "gbaSoundFiltering", 50 ) / 100.0f; gpuBilinear = ( 1 == regQueryDwordValue("gpuBilinear", 0) ) ? true : false ; gpuMotionBlur = ( 1 == regQueryDwordValue("gpuMotionBlur", 0) ) ? true : false; disableStatusMessage = regQueryDwordValue("disableStatus", 0) ? true : false; showSpeed = regQueryDwordValue("showSpeed", 0); if(showSpeed < 0 || showSpeed > 2) showSpeed = 0; showSpeedTransparent = regQueryDwordValue("showSpeedTransparent", TRUE) ? TRUE : FALSE; pauseWhenInactive = regQueryDwordValue("pauseWhenInactive", 1) ? true : false; recentFreeze = regQueryDwordValue("recentFreeze", false) ? true : false; switch(videoOption) { case VIDEO_320x240: fsWidth = 320; fsHeight = 240; fsColorDepth = 16; fsFrequency = 60; break; case VIDEO_640x480: fsWidth = 640; fsHeight = 480; fsColorDepth = 16; fsFrequency = 60; break; case VIDEO_800x600: fsWidth = 800; fsHeight = 600; fsColorDepth = 16; fsFrequency = 60; break; case VIDEO_1024x768: fsWidth = 1024; fsHeight = 768; fsColorDepth = 16; fsFrequency = 60; break; case VIDEO_1280x1024: fsWidth = 1280; fsHeight = 1024; fsColorDepth = 16; fsFrequency = 60; break; } for(int i = 0; i < 10; i++) { buffer.Format("recent%d", i); char *s = regQueryStringValue(buffer, NULL); if(s == NULL) break; recentFiles[i] = s; } joypadDefault = regQueryDwordValue("joypadDefault", 0); if(joypadDefault < 0 || joypadDefault > 3) joypadDefault = 0; autoLoadMostRecent = ( 1 == regQueryDwordValue("autoLoadMostRecent", 0) ) ? true : false; maxScale = regQueryDwordValue("maxScale", 0); xa2Device = regQueryDwordValue( "xa2Device", 0 ); xa2BufferCount = regQueryDwordValue( "xa2BufferCount", 4 ); xa2Upmixing = ( 1 == regQueryDwordValue( "xa2Upmixing", 0 ) ); }
bool MainWnd::fileOpenSelect( int system ) { theApp.dir = _T(""); CString initialDir; int selectedFilter = 0; LPCTSTR exts[] = { _T(""), _T(""), _T(""), _T("") }; CString filter; CString title; switch( system ) { case 0: // GBA initialDir = regQueryStringValue( _T("romdir"), _T(".") ); selectedFilter = regQueryDwordValue( _T("selectedFilter"), 0); if( (selectedFilter < 0) || (selectedFilter > 2) ) { selectedFilter = 0; } filter = winLoadFilter( IDS_FILTER_GBAROM ); break; case 1: // GBC initialDir = regQueryStringValue( _T("gbcromdir"), _T(".") ); // TODO: memorize selected filter for GBC as well filter = winLoadFilter( IDS_FILTER_GBCROM ); break; case 2: // GB initialDir = regQueryStringValue( _T("gbromdir"), _T(".") ); // TODO: memorize selected filter for GB as well filter = winLoadFilter( IDS_FILTER_GBROM ); break; } title = winResLoadString( IDS_SELECT_ROM ); if( !initialDir.IsEmpty() ) { theApp.dir = initialDir; } if( initialDir[0] == '.' ) { // handle as relative path char baseDir[MAX_PATH+1]; GetModuleFileName( NULL, baseDir, MAX_PATH ); baseDir[MAX_PATH] = '\0'; // for security reasons PathRemoveFileSpec( baseDir ); // removes the trailing file name and backslash strcat( baseDir, "\\" ); strcat( baseDir, initialDir ); initialDir = baseDir; } theApp.szFile = _T(""); FileDlg dlg( this, _T(""), filter, selectedFilter, _T(""), exts, theApp.dir, title, false); if( dlg.DoModal() == IDOK ) { if( system == 0 ) { regSetDwordValue( _T("selectedFilter"), dlg.m_ofn.nFilterIndex ); } theApp.szFile = dlg.GetPathName(); theApp.dir = theApp.szFile.Left( dlg.m_ofn.nFileOffset ); if( (theApp.dir.GetLength() > 3) && (theApp.dir[theApp.dir.GetLength()-1] == _T('\\')) ) { theApp.dir = theApp.dir.Left( theApp.dir.GetLength() - 1 ); } SetCurrentDirectory( theApp.dir ); regSetStringValue( _T("lastDir"), theApp.dir ); return true; } return false; }