void MainWnd::OnOptionsVideoFullscreen() { theApp.winCheckFullscreen(); GUID *pGUID = NULL; int size = theApp.display->selectFullScreenMode(&pGUID); if(size != -1) { int width = (size >> 12) & 4095; int height = (size & 4095); int colorDepth = (size >> 24); if(width != theApp.fsWidth || height != theApp.fsHeight || colorDepth != theApp.fsColorDepth || pGUID != theApp.pVideoDriverGUID || theApp.videoOption != VIDEO_OTHER) { theApp.fsForceChange = true; theApp.fsWidth = width; theApp.fsHeight = height; theApp.fsColorDepth = colorDepth; theApp.pVideoDriverGUID = pGUID; if(pGUID) { theApp.videoDriverGUID = *pGUID; regSetDwordValue("defaultVideoDriver", FALSE); regSetBinaryValue("videoDriverGUID", (char *)pGUID, sizeof(GUID)); } else { regSetDwordValue("defaultVideoDriver", TRUE); } theApp.updateVideoSize(ID_OPTIONS_VIDEO_FULLSCREEN); theApp.m_pMainWnd->PostMessage(VBA_CONFIRM_MODE); } }
bool MainWnd::fileOpenSelect() { theApp.dir = ""; CString initialDir = regQueryStringValue("romdir","."); if(!initialDir.IsEmpty()) theApp.dir = initialDir; int selectedFilter = regQueryDwordValue("selectedFilter", 0); if(selectedFilter < 0 || selectedFilter > 2) selectedFilter = 0; theApp.szFile = ""; LPCTSTR exts[] = { "" }; CString filter = winLoadFilter(IDS_FILTER_ROM); CString title = winResLoadString(IDS_SELECT_ROM); FileDlg dlg(this, "", filter, selectedFilter, "", exts, theApp.dir, title, false); if(dlg.DoModal() == IDOK) { regSetDwordValue("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] == '\\') theApp.dir = theApp.dir.Left(theApp.dir.GetLength()-1); regSetStringValue("romdir", theApp.dir); return true; } return false; }
void winSaveKeys() { for(int i = 0; i < JOYPADS; i++) { winSaveKey("Left", i, theApp.input->joypaddata[JOYPAD(i,KEY_LEFT)]); winSaveKey("Right", i, theApp.input->joypaddata[JOYPAD(i,KEY_RIGHT)]); winSaveKey("Up", i, theApp.input->joypaddata[JOYPAD(i,KEY_UP)]); winSaveKey("Speed", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_SPEED)]); winSaveKey("Capture", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_CAPTURE)]); winSaveKey("GS", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_GS)]); winSaveKey("Down", i, theApp.input->joypaddata[JOYPAD(i,KEY_DOWN)]); winSaveKey("A", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_A)]); winSaveKey("B", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_B)]); winSaveKey("L", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_L)]); winSaveKey("R", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_R)]); winSaveKey("Start", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_START)]); winSaveKey("Select", i, theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_SELECT)]); } regSetDwordValue("joyVersion", 1); winSaveKey("Motion_Left", theApp.input->joypaddata[MOTION(KEY_LEFT)]); winSaveKey("Motion_Right", theApp.input->joypaddata[MOTION(KEY_RIGHT)]); winSaveKey("Motion_Up", theApp.input->joypaddata[MOTION(KEY_UP)]); winSaveKey("Motion_Down", theApp.input->joypaddata[MOTION(KEY_DOWN)]); }
void MainWnd::OnMove(int x, int y) { CWnd::OnMove(x, y); if(!theApp.changingVideoSize) { if(this) { if(!IsIconic()) { RECT r; GetWindowRect(&r); theApp.windowPositionX = r.left; theApp.windowPositionY = r.top; theApp.adjustDestRect(); regSetDwordValue("windowX", theApp.windowPositionX); regSetDwordValue("windowY", theApp.windowPositionY); } } } }
void MemoryViewerDlg::On32Bit() { m_viewer.setSize(2); regSetDwordValue("memViewerDataSize", 2); }
void MemoryViewerDlg::On16Bit() { m_viewer.setSize(1); regSetDwordValue("memViewerDataSize", 1); }
void GBMapView::OnStretch() { mapView.setStretch(!mapView.getStretch()); paint(); regSetDwordValue("mapViewStretch", mapView.getStretch()); }
void VBA::updateWindowSize(int value) { regSetDwordValue("video", value); if(value == VIDEO_OTHER) { regSetDwordValue("fsWidth", fsWidth); regSetDwordValue("fsHeight", fsHeight); regSetDwordValue("fsColorDepth", fsColorDepth); } if(((value >= VIDEO_320x240) && (videoOption != value)) || (videoOption >= VIDEO_320x240 && value <= VIDEO_4X) || fsForceChange) { fsForceChange = false; changingVideoSize = true; if( videoOption <= VIDEO_4X ) { lastWindowed = (VIDEO_SIZE)videoOption; // save for when leaving full screen } else { lastFullscreen = (VIDEO_SIZE)videoOption; // save for when using quick switch to fullscreen } shutdownDisplay(); if(input) { delete input; input = NULL; } m_pMainWnd->DragAcceptFiles(FALSE); CWnd *pWnd = m_pMainWnd; m_pMainWnd = NULL; pWnd->DestroyWindow(); delete pWnd; videoOption = value; if(!initDisplay()) { if(videoOption == VIDEO_320x240 || videoOption == VIDEO_640x480 || videoOption == VIDEO_800x600 || videoOption == VIDEO_1024x768 || videoOption == VIDEO_1280x1024 || videoOption == VIDEO_OTHER) { regSetDwordValue("video", VIDEO_1X); } changingVideoSize = false; AfxPostQuitMessage(0); return; } if(!initInput()) { changingVideoSize = false; AfxPostQuitMessage(0); return; } input->checkKeys(); changingVideoSize = FALSE; updateWindowSize(videoOption); return; } sizeX = 240; sizeY = 160; videoOption = value; surfaceSizeX = sizeX; surfaceSizeY = sizeY; switch(videoOption) { case VIDEO_1X: surfaceSizeX = sizeX; surfaceSizeY = sizeY; break; case VIDEO_2X: surfaceSizeX = sizeX * 2; surfaceSizeY = sizeY * 2; break; case VIDEO_3X: surfaceSizeX = sizeX * 3; surfaceSizeY = sizeY * 3; break; case VIDEO_4X: surfaceSizeX = sizeX * 4; surfaceSizeY = sizeY * 4; break; case VIDEO_320x240: case VIDEO_640x480: case VIDEO_800x600: case VIDEO_1024x768: case VIDEO_1280x1024: case VIDEO_OTHER: { int scaleX = 1; int scaleY = 1; scaleX = (fsWidth / sizeX); scaleY = (fsHeight / sizeY); int min = scaleX < scaleY ? scaleX : scaleY; if(maxScale) min = min > maxScale ? maxScale : min; surfaceSizeX = min * sizeX; surfaceSizeY = min * sizeY; if(fullScreenStretch) { surfaceSizeX = fsWidth; surfaceSizeY = fsHeight; } } break; } rect.right = sizeX; rect.bottom = sizeY; int winSizeX = sizeX; int winSizeY = sizeY; if(videoOption <= VIDEO_4X) { dest.left = 0; dest.top = 0; dest.right = surfaceSizeX; dest.bottom = surfaceSizeY; DWORD style = WS_POPUP | WS_VISIBLE; style |= WS_OVERLAPPEDWINDOW; AdjustWindowRectEx(&dest, style, TRUE, 0); //WS_EX_TOPMOST); winSizeX = dest.right-dest.left; winSizeY = dest.bottom-dest.top; m_pMainWnd->SetWindowPos(0, //HWND_TOPMOST, windowPositionX, windowPositionY, winSizeX, winSizeY, SWP_NOMOVE | SWP_SHOWWINDOW); // content of old seperate 'winCheckMenuBarInfo' function: MENUBARINFO info; info.cbSize = sizeof(MENUBARINFO); GetMenuBarInfo( theApp.m_pMainWnd->GetSafeHwnd(), OBJID_MENU, 0, &info ); int menuHeight = GetSystemMetrics(SM_CYMENU); // includes white line if((info.rcBar.bottom - info.rcBar.top) > menuHeight) // check for double height menu { winSizeY += (info.rcBar.bottom - info.rcBar.top) - menuHeight + 1; m_pMainWnd->SetWindowPos( 0, //HWND_TOPMOST, theApp.windowPositionX, theApp.windowPositionY, winSizeX, winSizeY, SWP_NOMOVE | SWP_SHOWWINDOW); } } adjustDestRect(); if(display) display->resize(theApp.dest.right-theApp.dest.left, theApp.dest.bottom-theApp.dest.top); m_pMainWnd->RedrawWindow(NULL,NULL,RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN); }
BOOL VBA::InitInstance() { SetRegistryKey(_T("VBA")); wndClass = AfxRegisterWndClass(0, LoadCursor(IDC_ARROW), (HBRUSH)GetStockObject(BLACK_BRUSH), LoadIcon(IDI_MAINICON)); char winBuffer[2048]; GetModuleFileName(NULL, winBuffer, 2048); char *p = strrchr(winBuffer, '\\'); if(p) *p = 0; bool force = false; if (m_lpCmdLine[0]) { if(__argc > 0) { if( 0 == strcmp( __argv[1], "--configpath" ) ) { if( __argc > 2 ) { strcpy( winBuffer, __argv[2] ); force = true; if( __argc > 3 ) { filename = __argv[3]; } } } else { filename = __argv[1]; } } } regInit(winBuffer, force); loadSettings(); if(!initDisplay()) { if(videoOption >= VIDEO_320x240) { regSetDwordValue("video", VIDEO_2X); } return FALSE; } if(!initInput()) return FALSE; hAccel = LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ACCELERATOR)); winAccelMgr.Connect((MainWnd *)m_pMainWnd); winAccelMgr.SetRegKey(HKEY_CURRENT_USER, "Software\\Emulators\\VisualBoyAdvance"); extern void winAccelAddCommands(CAcceleratorManager&); winAccelAddCommands(winAccelMgr); winAccelMgr.CreateDefaultTable(); winAccelMgr.Load(); winAccelMgr.UpdateWndTable(); winAccelMgr.UpdateMenu(menu); if( !filename.IsEmpty() ) { if(((MainWnd*)m_pMainWnd)->FileRun()) emulating = true; else emulating = false; } return TRUE; }
void VBA::saveSettings() { regSetDwordValue("language", languageOption); regSetStringValue("languageName", languageName); regSetDwordValue("syncToVideo", syncToVideo); regSetDwordValue("syncToAudio", syncToAudio); regSetDwordValue("stretch", fullScreenStretch); regSetDwordValue("video", videoOption); regSetDwordValue("fsAdapter", fsAdapter); regSetDwordValue("fsWidth", fsWidth); regSetDwordValue("fsHeight", fsHeight); regSetDwordValue("fsColorDepth", fsColorDepth); regSetDwordValue("fsFrequency", fsFrequency); regSetDwordValue("windowX", windowPositionX); regSetDwordValue("windowY", windowPositionY); regSetDwordValue("useBiosGBA", useBiosFileGBA); regSetDwordValue("skipBios", skipBiosFile); if(!biosFileNameGBA.IsEmpty()) regSetStringValue("biosFileGBA", biosFileNameGBA); regSetDwordValue("soundEnable", soundGetEnable() & 0x30f); regSetDwordValue("soundQuality", 44100 / soundGetSampleRate() ); regSetDwordValue("soundVolume", (DWORD)(soundGetVolume() * 100.0f)); regSetDwordValue( "gbaSoundInterpolation", soundInterpolation ? 1 : 0 ); regSetDwordValue( "gbaSoundFiltering", (DWORD)( soundFiltering * 100.0f ) ); regSetDwordValue("gpuBilinear", gpuBilinear ? 1 : 0); regSetDwordValue("gpuMotionBlur", gpuMotionBlur ? 1 : 0); regSetDwordValue("disableStatus", disableStatusMessage); regSetDwordValue("showSpeed", showSpeed); regSetDwordValue("showSpeedTransparent", showSpeedTransparent); regSetDwordValue("recentFreeze", recentFreeze); CString buffer; for(int i = 0; i < 10; i++) { buffer.Format("recent%d", i); regSetStringValue(buffer, recentFiles[i]); } regSetDwordValue("joypadDefault", joypadDefault); regSetDwordValue("autoLoadMostRecent", autoLoadMostRecent); regSetDwordValue("maxScale", maxScale); regSetDwordValue("lastFullscreen", lastFullscreen); regSetDwordValue("pauseWhenInactive", pauseWhenInactive); regSetDwordValue( "xa2Device", xa2Device ); regSetDwordValue( "xa2BufferCount", xa2BufferCount ); regSetDwordValue( "xa2Upmixing", xa2Upmixing ? 1 : 0 ); }
void GBTileView::OnStretch() { tileView.setStretch(!tileView.getStretch()); paint(); regSetDwordValue("tileViewStretch", tileView.getStretch()); }
bool DirectDrawDisplay::initialize() { theApp.sizeX = 240; theApp.sizeY = 160; switch(theApp.videoOption) { case VIDEO_1X: theApp.surfaceSizeX = theApp.sizeX; theApp.surfaceSizeY = theApp.sizeY; break; case VIDEO_2X: theApp.surfaceSizeX = theApp.sizeX * 2; theApp.surfaceSizeY = theApp.sizeY * 2; break; case VIDEO_3X: theApp.surfaceSizeX = theApp.sizeX * 3; theApp.surfaceSizeY = theApp.sizeY * 3; break; case VIDEO_4X: theApp.surfaceSizeX = theApp.sizeX * 4; theApp.surfaceSizeY = theApp.sizeY * 4; break; case VIDEO_320x240: case VIDEO_640x480: case VIDEO_800x600: case VIDEO_OTHER: { int scaleX = (theApp.fsWidth / theApp.sizeX); int scaleY = (theApp.fsHeight / theApp.sizeY); int min = scaleX < scaleY ? scaleX : scaleY; if(theApp.fsMaxScale) min = min > theApp.fsMaxScale ? theApp.fsMaxScale : min; theApp.surfaceSizeX = theApp.sizeX * min; theApp.surfaceSizeY = theApp.sizeY * min; if(theApp.fullScreenStretch) { theApp.surfaceSizeX = theApp.fsWidth; theApp.surfaceSizeY = theApp.fsHeight; } } break; } theApp.rect.left = 0; theApp.rect.top = 0; theApp.rect.right = theApp.sizeX; theApp.rect.bottom = theApp.sizeY; theApp.dest.left = 0; theApp.dest.top = 0; theApp.dest.right = theApp.surfaceSizeX; theApp.dest.bottom = theApp.surfaceSizeY; DWORD style = WS_POPUP | WS_VISIBLE; DWORD styleEx = 0; if(theApp.videoOption <= VIDEO_4X) style |= WS_OVERLAPPEDWINDOW; else styleEx = WS_EX_TOPMOST; if(theApp.videoOption <= VIDEO_4X) AdjustWindowRectEx(&theApp.dest, style, TRUE, styleEx); else AdjustWindowRectEx(&theApp.dest, style, FALSE, styleEx); int winSizeX = theApp.dest.right-theApp.dest.left; int winSizeY = theApp.dest.bottom-theApp.dest.top; int x = 0; int y = 0; if(theApp.videoOption <= VIDEO_4X) { x = theApp.windowPositionX; y = theApp.windowPositionY; } // Create a window MainWnd *pWnd = new MainWnd; theApp.m_pMainWnd = pWnd; pWnd->CreateEx(styleEx, theApp.wndClass, "VisualBoyAdvance", style, x,y,winSizeX,winSizeY, NULL, 0); if (!(HWND)*pWnd) { winlog("Error creating Window %08x\n", GetLastError()); return FALSE; } theApp.updateMenuBar(); theApp.adjustDestRect(); GUID *guid = NULL; if(theApp.ddrawEmulationOnly) guid = (GUID *)DDCREATE_EMULATIONONLY; if(theApp.pVideoDriverGUID) guid = theApp.pVideoDriverGUID; ddrawDLL = AfxLoadLibrary("DDRAW.DLL"); HRESULT (WINAPI *DDrawCreateEx)(GUID *,LPVOID *,REFIID,IUnknown *); if(ddrawDLL != NULL) { DDrawCreateEx = (HRESULT (WINAPI *)(GUID *,LPVOID *,REFIID,IUnknown *)) GetProcAddress(ddrawDLL, "DirectDrawCreateEx"); if(DDrawCreateEx == NULL) { theApp.directXMessage("DirectDrawCreateEx"); return FALSE; } } else { theApp.directXMessage("DDRAW.DLL"); return FALSE; } theApp.ddrawUsingEmulationOnly = theApp.ddrawEmulationOnly; HRESULT hret = DDrawCreateEx(guid, (void **)&pDirectDraw, IID_IDirectDraw7, NULL); if(hret != DD_OK) { winlog("Error creating DirectDraw object %08x\n", hret); if(theApp.ddrawEmulationOnly) { // disable emulation only setting in case of failure regSetDwordValue("ddrawEmulationOnly", 0); } // errorMessage(myLoadString(IDS_ERROR_DISP_DRAWCREATE), hret); return FALSE; } if(theApp.ddrawDebug) { DDCAPS driver; DDCAPS hel; ZeroMemory(&driver, sizeof(driver)); ZeroMemory(&hel, sizeof(hel)); driver.dwSize = sizeof(driver); hel.dwSize = sizeof(hel); pDirectDraw->GetCaps(&driver, &hel); int i; DWORD *p = (DWORD *)&driver; for(i = 0; i < (int)driver.dwSize; i+=4) winlog("Driver CAPS %2d: %08x\n", i>>2, *p++); p = (DWORD *)&hel; for(i = 0; i < (int)hel.dwSize; i+=4) winlog("HEL CAPS %2d: %08x\n", i>>2, *p++); }
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; }
void GBOamView::OnStretch() { oamView.setStretch(!oamView.getStretch()); paint(); regSetDwordValue(_T("GBOamViewStretch"), oamView.getStretch()); }