Update of /cvsroot/vba/VisualBoyAdvance/src/win32 In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv28465/src/win32 Modified Files: Direct3D.cpp MainWnd.cpp MainWndOptions.cpp VBA.cpp VBA.h display.cpp resource.h vba.rc Log Message: Added aspect ratio correct scaling to Direct3D (triggered by !theApp.fullScreenStretch) ReAdded texture filtering support to Direct3D. Removed remaining code pieces of flash size enhancedDetection. Changed some default settings Index: VBA.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/win32/VBA.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** VBA.cpp 22 Jul 2006 10:30:09 -0000 1.19 --- VBA.cpp 31 Jul 2006 15:51:01 -0000 1.20 *************** *** 242,246 **** ddrawUseVideoMemory = false; d3dFilter = 0; - d3dKeepAspectRatio = true; glFilter = 0; glType = 0; --- 242,245 ---- *************** *** 1183,1189 **** winSetLanguageOption(languageOption, true); ! frameSkip = regQueryDwordValue("frameSkip", 1); if(frameSkip < 0 || frameSkip > 9) ! frameSkip = 2; gbFrameSkip = regQueryDwordValue("gbFrameSkip", 0); --- 1182,1188 ---- winSetLanguageOption(languageOption, true); ! frameSkip = regQueryDwordValue("frameSkip", 0); if(frameSkip < 0 || frameSkip > 9) ! frameSkip = 0; gbFrameSkip = regQueryDwordValue("gbFrameSkip", 0); *************** *** 1197,1202 **** fullScreenStretch = regQueryDwordValue("stretch", 0) ? true : false; ! videoOption = regQueryDwordValue("video", 0); ! if(videoOption < 0 || videoOption > VIDEO_OTHER) videoOption = 0; --- 1196,1200 ---- fullScreenStretch = regQueryDwordValue("stretch", 0) ? true : false; ! videoOption = regQueryDwordValue("video", 1); if(videoOption < 0 || videoOption > VIDEO_OTHER) videoOption = 0; *************** *** 1229,1233 **** renderMethod = (DISPLAY_TYPE)regQueryDwordValue("renderMethod", DIRECT_DRAW); - if(renderMethod < GDI || renderMethod > OPENGL) renderMethod = DIRECT_DRAW; --- 1227,1230 ---- *************** *** 1257,1261 **** soundOffFlag = (regQueryDwordValue("soundOff", 0)) ? true : false; ! soundQuality = regQueryDwordValue("soundQuality", 2); soundEcho = regQueryDwordValue("soundEcho", 0) ? true : false; --- 1254,1258 ---- soundOffFlag = (regQueryDwordValue("soundOff", 0)) ? true : false; ! soundQuality = regQueryDwordValue("soundQuality", 1); soundEcho = regQueryDwordValue("soundEcho", 0) ? true : false; *************** *** 1270,1283 **** ddrawEmulationOnly = regQueryDwordValue("ddrawEmulationOnly", false) ? true : false; ! ddrawUseVideoMemory = regQueryDwordValue("ddrawUseVideoMemory", false) ? true : false; ! tripleBuffering = regQueryDwordValue("tripleBuffering", true) ? true : false; ! d3dFilter = regQueryDwordValue("d3dFilter", 0); if(d3dFilter < 0 || d3dFilter > 1) ! d3dFilter = 0; ! d3dKeepAspectRatio = regQueryDwordValue("d3dKeepAspectRatio", true) ? true : false; ! glFilter = regQueryDwordValue("glFilter", 0); if(glFilter < 0 || glFilter > 1) ! glFilter = 0; glType = regQueryDwordValue("glType", 0); if(glType < 0 || glType > 1) --- 1267,1281 ---- ddrawEmulationOnly = regQueryDwordValue("ddrawEmulationOnly", false) ? true : false; ! ddrawUseVideoMemory = regQueryDwordValue("ddrawUseVideoMemory", true) ? true : false; ! tripleBuffering = regQueryDwordValue("tripleBuffering", false) ? true : false; ! d3dFilter = regQueryDwordValue("d3dFilter", 1); if(d3dFilter < 0 || d3dFilter > 1) ! d3dFilter = 1; ! ! glFilter = regQueryDwordValue("glFilter", 1); if(glFilter < 0 || glFilter > 1) ! glFilter = 1; ! glType = regQueryDwordValue("glType", 0); if(glType < 0 || glType > 1) *************** *** 1288,1292 **** filterType = 0; ! disableMMX = regQueryDwordValue("disableMMX", 0) ? true: false; disableStatusMessage = regQueryDwordValue("disableStatus", 0) ? true : false; --- 1286,1290 ---- filterType = 0; ! disableMMX = regQueryDwordValue("disableMMX", false) ? true: false; disableStatusMessage = regQueryDwordValue("disableStatus", 0) ? true : false; *************** *** 1326,1332 **** winSaveType = 0; - cpuEnhancedDetection = regQueryDwordValue("enhancedDetection", 1) ? true : - false; - ifbType = regQueryDwordValue("ifbType", 0); if(ifbType < 0 || ifbType > 2) --- 1324,1327 ---- *************** *** 2175,2179 **** regSetDwordValue("d3dFilter", d3dFilter); - regSetDwordValue("d3dKeepAspectRatio", d3dKeepAspectRatio); regSetDwordValue("glFilter", glFilter); regSetDwordValue("glType", glType); --- 2170,2173 ---- *************** *** 2207,2212 **** regSetDwordValue("saveType", winSaveType); - regSetDwordValue("enhancedDetection", cpuEnhancedDetection); - regSetDwordValue("ifbType", ifbType); --- 2201,2204 ---- Index: VBA.h =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/win32/VBA.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** VBA.h 21 Jun 2006 16:58:15 -0000 1.10 --- VBA.h 31 Jul 2006 15:51:01 -0000 1.11 *************** *** 143,147 **** bool ddrawUseVideoMemory; int d3dFilter; - bool d3dKeepAspectRatio; int glFilter; int glType; --- 143,146 ---- Index: Direct3D.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/win32/Direct3D.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Direct3D.cpp 20 Jun 2006 10:35:17 -0000 1.11 --- Direct3D.cpp 31 Jul 2006 15:51:01 -0000 1.12 *************** *** 62,67 **** --- 62,70 ---- D3DPRESENT_PARAMETERS dpp; D3DFORMAT screenFormat; + LPDIRECT3DSURFACE9 emulatedImage; + D3DTEXTUREFILTERTYPE filter; int width; int height; + RECT destRect; bool failed; *************** *** 69,72 **** --- 72,78 ---- void createFont(); void destroyFont(); + void createSurface(); + void destroySurface(); + void calculateDestRect(); bool resetDevice(); *************** *** 83,89 **** virtual void renderMenu(); ! virtual bool changeRenderSize(int w, int h); ! virtual void setOption(const char *option, int value); ! virtual int selectFullScreenMode(GUID **); }; --- 89,96 ---- virtual void renderMenu(); ! virtual bool changeRenderSize( int w, int h ); ! virtual void resize( int w, int h ); ! virtual void setOption( const char *option, int value ); ! virtual int selectFullScreenMode( GUID ** ); }; *************** *** 98,101 **** --- 105,110 ---- failed = false; pFont = NULL; + emulatedImage = NULL; + filter = D3DTEXF_POINT; } *************** *** 110,113 **** --- 119,123 ---- { destroyFont(); + destroySurface(); if( pDevice ) { *************** *** 315,320 **** dpp.BackBufferCount = theApp.tripleBuffering ? 2 : 1; dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; ! dpp.BackBufferWidth = theApp.rect.right; ! dpp.BackBufferHeight = theApp.rect.bottom; dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; dpp.PresentationInterval = theApp.vsync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; --- 325,330 ---- dpp.BackBufferCount = theApp.tripleBuffering ? 2 : 1; dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; ! dpp.BackBufferWidth = 0; // use width of hDeviceWindow ! dpp.BackBufferHeight = 0; // use height of hDeviceWindow dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; dpp.PresentationInterval = theApp.vsync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; *************** *** 333,336 **** --- 343,350 ---- createFont(); + createSurface(); + calculateDestRect(); + + setOption( _T("d3dFilter"), theApp.d3dFilter ); if(failed) return false; *************** *** 359,362 **** --- 373,377 ---- void Direct3DDisplay::render() { + if( failed ) return; if(!pDevice) return; if( FAILED( pDevice->TestCooperativeLevel() ) ) return; *************** *** 366,374 **** pDevice->BeginScene(); HRESULT hr; D3DLOCKED_RECT lr; ! LPDIRECT3DSURFACE9 pBackBuffer; ! pDevice->GetBackBuffer( 0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer ); ! if( FAILED( hr = pBackBuffer->LockRect( &lr, NULL, D3DLOCK_DISCARD ) ) ) { DXTRACE_ERR_MSGBOX( _T("Can not lock back buffer"), hr ); return; --- 381,388 ---- pDevice->BeginScene(); + // copy pix to emulatedImage and apply pixel filter if selected HRESULT hr; D3DLOCKED_RECT lr; ! if( FAILED( hr = emulatedImage->LockRect( &lr, NULL, D3DLOCK_DISCARD ) ) ) { DXTRACE_ERR_MSGBOX( _T("Can not lock back buffer"), hr ); return; *************** *** 385,395 **** theApp.filterHeight); } ! pBackBuffer->UnlockRect(); } pBackBuffer->Release(); pBackBuffer = NULL; - - D3DCOLOR color = theApp.showSpeedTransparent ? D3DCOLOR_ARGB(0x7f, 0x00, 0x00, 0xff) : D3DCOLOR_ARGB(0xff, 0x00, 0x00, 0xff); RECT r; --- 399,416 ---- theApp.filterHeight); } ! emulatedImage->UnlockRect(); ! } ! ! // copy emulatedImage to pBackBuffer and scale with or without aspect ratio ! LPDIRECT3DSURFACE9 pBackBuffer; ! pDevice->GetBackBuffer( 0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer ); ! if( theApp.fullScreenStretch ) { ! pDevice->StretchRect( emulatedImage, NULL, pBackBuffer, NULL, filter ); ! } else { ! pDevice->StretchRect( emulatedImage, NULL, pBackBuffer, &destRect, filter ); } pBackBuffer->Release(); pBackBuffer = NULL; D3DCOLOR color = theApp.showSpeedTransparent ? D3DCOLOR_ARGB(0x7f, 0x00, 0x00, 0xff) : D3DCOLOR_ARGB(0xff, 0x00, 0x00, 0xff); RECT r; *************** *** 428,444 **** ! bool Direct3DDisplay::changeRenderSize(int w, int h) { if( (w != width) || (h != height) ) { width = w; height = h; dpp.BackBufferWidth = (UINT)w; dpp.BackBufferHeight = (UINT)h; ! return resetDevice(); } - return true; } ! int Direct3DDisplay::selectFullScreenMode(GUID **) { HRESULT hr; --- 449,478 ---- ! bool Direct3DDisplay::changeRenderSize( int w, int h ) { if( (w != width) || (h != height) ) { width = w; height = h; + if( pDevice ) { + destroySurface(); + createSurface(); + calculateDestRect(); + } + } + return true; + } + + + void Direct3DDisplay::resize( int w, int h ) + { + if( (w != dpp.BackBufferWidth) || (h != dpp.BackBufferHeight) ) { dpp.BackBufferWidth = (UINT)w; dpp.BackBufferHeight = (UINT)h; ! resetDevice(); ! calculateDestRect(); } } ! int Direct3DDisplay::selectFullScreenMode( GUID ** ) { HRESULT hr; *************** *** 469,474 **** { if( !pFont ) { ! D3DXCreateFont ! ( pDevice, 12, --- 503,507 ---- { if( !pFont ) { ! HRESULT hr = D3DXCreateFont( pDevice, 12, *************** *** 482,487 **** DEFAULT_PITCH || FF_DONTCARE, _T("Arial"), ! &pFont ! ); } } --- 515,522 ---- DEFAULT_PITCH || FF_DONTCARE, _T("Arial"), ! &pFont ); ! if( FAILED( hr ) ) { ! DXTRACE_ERR_MSGBOX( _T("createFont failed"), hr ); ! } } } *************** *** 497,501 **** ! void Direct3DDisplay::setOption(const char *option, int value) { if( !_tcscmp( option, _T("vsync") ) ) { --- 532,586 ---- ! void Direct3DDisplay::createSurface() ! { ! if( !emulatedImage ) { ! HRESULT hr = pDevice->CreateOffscreenPlainSurface( ! width, height, ! dpp.BackBufferFormat, ! D3DPOOL_DEFAULT, ! &emulatedImage, ! NULL ); ! if( FAILED( hr ) ) { ! DXTRACE_ERR_MSGBOX( _T("createSurface failed"), hr ); ! } ! } ! } ! ! ! void Direct3DDisplay::destroySurface() ! { ! if( emulatedImage ) { ! emulatedImage->Release(); ! emulatedImage = NULL; ! } ! } ! ! ! void Direct3DDisplay::calculateDestRect() ! { ! float scaleX = (float)dpp.BackBufferWidth / (float)width; ! float scaleY = (float)dpp.BackBufferHeight / (float)height; ! float min = (scaleX < scaleY) ? scaleX : scaleY; ! if( theApp.fsMaxScale && (min > theApp.fsMaxScale) ) { ! min = (float)theApp.fsMaxScale; ! } ! destRect.left = 0; ! destRect.top = 0; ! destRect.right = (LONG)(width * min); ! destRect.bottom = (LONG)(height * min); ! if( destRect.right != dpp.BackBufferWidth ) { ! LONG diff = (dpp.BackBufferWidth - destRect.right) / 2; ! destRect.left += diff; ! destRect.right += diff; ! } ! if( destRect.bottom != dpp.BackBufferHeight ) { ! LONG diff = (dpp.BackBufferHeight - destRect.bottom) / 2; ! destRect.top += diff; ! destRect.bottom += diff; ! } ! } ! ! ! void Direct3DDisplay::setOption( const char *option, int value ) { if( !_tcscmp( option, _T("vsync") ) ) { *************** *** 508,511 **** --- 593,608 ---- resetDevice(); } + + if( !_tcscmp( option, _T("d3dFilter") ) ) { + switch( value ) + { + case 0: //point + filter = D3DTEXF_POINT; + break; + case 1: //linear + filter = D3DTEXF_LINEAR; + break; + } + } } *************** *** 517,526 **** HRESULT hr; destroyFont(); if( FAILED( hr = pDevice->Reset( &dpp ) ) ) { ! DXTRACE_ERR_MSGBOX( _T("pDevice->Reset failed"), hr ); failed = true; return false; } createFont(); failed = false; return true; --- 614,625 ---- HRESULT hr; destroyFont(); + destroySurface(); if( FAILED( hr = pDevice->Reset( &dpp ) ) ) { ! //DXTRACE_ERR_MSGBOX( _T("pDevice->Reset failed"), hr ); failed = true; return false; } createFont(); + createSurface(); failed = false; return true; Index: display.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/win32/display.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** display.cpp 12 Jun 2006 22:01:51 -0000 1.4 --- display.cpp 31 Jul 2006 15:51:01 -0000 1.5 *************** *** 119,123 **** //*(dst+i+(x*nBytesPerPixel)+(y*destinationPitch)) = *(src+i+(x*nBytesPerPixel)+(y*srcPitch)); ! #endif // #ifdef ASM } --- 119,123 ---- //*(dst+i+(x*nBytesPerPixel)+(y*destinationPitch)) = *(src+i+(x*nBytesPerPixel)+(y*srcPitch)); ! #endif } Index: MainWnd.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/win32/MainWnd.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** MainWnd.cpp 18 Jul 2006 14:15:16 -0000 1.23 --- MainWnd.cpp 31 Jul 2006 15:51:01 -0000 1.24 *************** *** 532,538 **** cpuSaveType = theApp.winSaveType; - // if(cpuEnhancedDetection && winSaveType == 0) { - // utilGBAFindSave(rom, size); - // } GetModuleFileName(NULL, tempName, 2048); --- 532,535 ---- Index: vba.rc =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/win32/vba.rc,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** vba.rc 12 Jun 2006 22:03:24 -0000 1.57 --- vba.rc 31 Jul 2006 15:51:01 -0000 1.58 *************** *** 29,33 **** // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. ! IDI_ICON ICON "vbavista.ico" ///////////////////////////////////////////////////////////////////////////// --- 29,34 ---- // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. ! IDI_ICON ICON "ico00002.ico" ! ///////////////////////////////////////////////////////////////////////////// *************** *** 1636,1643 **** MENUITEM "None", ID_OPTIONS_EMULATOR_SAVETYPE_NONE MENUITEM SEPARATOR ! MENUITEM "Flash 64K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K ! MENUITEM "Flash 128K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M ! MENUITEM SEPARATOR ! MENUITEM "Enhanced detection", ID_OPTIONS_EMULATOR_SAVETYPE_ENHANCEDDETECTION END MENUITEM SEPARATOR --- 1637,1642 ---- MENUITEM "None", ID_OPTIONS_EMULATOR_SAVETYPE_NONE MENUITEM SEPARATOR ! MENUITEM "Flash 64 KB", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K ! MENUITEM "Flash 128 KB", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M END MENUITEM SEPARATOR Index: resource.h =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/win32/resource.h,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** resource.h 6 Jun 2006 14:33:43 -0000 1.44 --- resource.h 31 Jul 2006 15:51:01 -0000 1.45 *************** *** 738,742 **** #define ID_FILE_TOGGLEMENU 40263 #define ID_OPTIONS_EMULATOR_SAVETYPE_NONE 40264 - #define ID_OPTIONS_EMULATOR_SAVETYPE_ENHANCEDDETECTION 40265 #define ID_TOOLS_IOVIEWER 40266 #define ID_FILE_LOADGAME_MOSTRECENT 40267 --- 738,741 ---- Index: MainWndOptions.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/win32/MainWndOptions.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** MainWndOptions.cpp 21 Jun 2006 16:58:15 -0000 1.11 --- MainWndOptions.cpp 31 Jul 2006 15:51:01 -0000 1.12 *************** *** 377,381 **** { theApp.fullScreenStretch = !theApp.fullScreenStretch; - theApp.d3dKeepAspectRatio = !theApp.fullScreenStretch; theApp.updateWindowSize( theApp.videoOption ); if( theApp.display ) { --- 377,380 ---- *************** *** 383,387 **** theApp.display->clear( ); } ! theApp.display->setOption( _T("d3dKeepAspectRatio"), theApp.d3dKeepAspectRatio ); } } --- 382,386 ---- theApp.display->clear( ); } ! theApp.display->setOption( _T("fullScreenStretch"), theApp.fullScreenStretch ); } } |