[Scummvm-cvs-logs] CVS: scummvm/backends/sdl sdl-common.cpp,1.62,1.63 sdl.cpp,1.35,1.36 sdl_gl.cpp,1.36,1.37 sdl-common.h,1.27,1.28
Max Horn
fingolfin at users.sourceforge.net
Sun Jun 22 04:56:03 CEST 2003
- Previous message: [Scummvm-cvs-logs] CVS: scummvm README,1.115,1.116
- Next message: [Scummvm-cvs-logs] CVS: scummvm/common gameDetector.h,1.45,1.46 gameDetector.cpp,1.113,1.114 scaler.cpp,1.22,1.23 scaler.h,1.11,1.12 system.h,1.32,1.33
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/backends/sdl
In directory sc8-pr-cvs1:/tmp/cvs-serv24404/backends/sdl
Modified Files:
sdl-common.cpp sdl.cpp sdl_gl.cpp sdl-common.h
Log Message:
Patch #757827: Aspect-ratio correction
Index: sdl-common.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.cpp,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- sdl-common.cpp 17 Jun 2003 15:33:17 -0000 1.62
+++ sdl-common.cpp 22 Jun 2003 11:55:39 -0000 1.63
@@ -41,22 +41,23 @@
#define JOY_BUT_SPACE 4
#define JOY_BUT_F5 5
-OSystem *OSystem_SDL_create(int gfx_mode, bool full_screen) {
- return OSystem_SDL_Common::create(gfx_mode, full_screen);
+OSystem *OSystem_SDL_create(int gfx_mode, bool full_screen, bool aspect_ratio) {
+ return OSystem_SDL_Common::create(gfx_mode, full_screen, aspect_ratio);
}
-OSystem *OSystem_SDL_Common::create(int gfx_mode, bool full_screen) {
+OSystem *OSystem_SDL_Common::create(int gfx_mode, bool full_screen, bool aspect_ratio) {
OSystem_SDL_Common *syst = OSystem_SDL_Common::create_intern();
- syst->init_intern(gfx_mode, full_screen);
+ syst->init_intern(gfx_mode, full_screen, aspect_ratio);
return syst;
}
-void OSystem_SDL_Common::init_intern(int gfx_mode, bool full_screen) {
+void OSystem_SDL_Common::init_intern(int gfx_mode, bool full_screen, bool aspect_ratio) {
_mode = gfx_mode;
_full_screen = full_screen;
+ _adjustAspectRatio = aspect_ratio;
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK) ==-1) {
error("Could not initialize SDL: %s.\n", SDL_GetError());
@@ -129,6 +130,10 @@
_screenWidth = w;
_screenHeight = h;
+
+ if (h != 200)
+ _adjustAspectRatio = false;
+
CKSUM_NUM = (_screenWidth * _screenHeight / (8 * 8));
if (_dirty_checksums)
free(_dirty_checksums);
@@ -576,20 +581,18 @@
}
}
- // Ctr-Alt-a will change aspect ratio in OpenGL backend
+ // Ctr-Alt-a will change aspect ratio
if (b == (KBD_CTRL|KBD_ALT) && ev.key.keysym.sym=='a') {
- Property prop;
- prop.gfx_mode = 11;
- property(PROP_SET_GFX_MODE, &prop);
- break;
+ property(PROP_TOGGLE_ASPECT_RATIO, NULL);
+ break;
}
// Ctr-Alt-b will change bilinear filtering in OpenGL backend
if (b == (KBD_CTRL|KBD_ALT) && ev.key.keysym.sym=='b') {
- Property prop;
- prop.gfx_mode = 12;
- property(PROP_SET_GFX_MODE, &prop);
- break;
+ Property prop;
+ prop.gfx_mode = GFX_BILINEAR;
+ property(PROP_SET_GFX_MODE, &prop);
+ break;
}
#ifdef QTOPIA
@@ -698,6 +701,8 @@
event->mouse.x /= _scaleFactor;
event->mouse.y /= _scaleFactor;
+ if (_adjustAspectRatio)
+ event->mouse.y = aspect2Real(event->mouse.y);
return true;
case SDL_MOUSEBUTTONDOWN:
@@ -718,6 +723,9 @@
event->mouse.x /= _scaleFactor;
event->mouse.y /= _scaleFactor;
+ if (_adjustAspectRatio)
+ event->mouse.y = aspect2Real(event->mouse.y);
+
return true;
case SDL_MOUSEBUTTONUP:
@@ -731,6 +739,10 @@
event->mouse.y = ev.button.y;
event->mouse.x /= _scaleFactor;
event->mouse.y /= _scaleFactor;
+
+ if (_adjustAspectRatio)
+ event->mouse.y = aspect2Real(event->mouse.y);
+
return true;
case SDL_JOYBUTTONDOWN:
@@ -835,6 +847,10 @@
event->mouse.y = km.y;
event->mouse.x /= _scaleFactor;
event->mouse.y /= _scaleFactor;
+
+ if (_adjustAspectRatio)
+ event->mouse.y = aspect2Real(event->mouse.y);
+
return true;
case SDL_VIDEOEXPOSE:
Index: sdl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- sdl.cpp 19 Jun 2003 16:16:35 -0000 1.35
+++ sdl.cpp 22 Jun 2003 11:55:39 -0000 1.36
@@ -147,12 +147,13 @@
//
// Create the surface that contains the scaled graphics in 16 bit mode
//
- _hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, _screenHeight * _scaleFactor, 16,
+
+ _hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, (_adjustAspectRatio ? 240 : _screenHeight) * _scaleFactor, 16,
_full_screen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
);
if (_hwscreen == NULL)
error("_hwscreen failed");
-
+
//
// Create the surface used for the graphics in 16 bit before scaling, and also the overlay
//
@@ -192,7 +193,7 @@
SDL_FreeSurface(_hwscreen);
_hwscreen = NULL;
}
-
+
if (_tmpscreen) {
free(_tmpscreen->pixels);
SDL_FreeSurface(_tmpscreen);
@@ -281,7 +282,7 @@
uint32 srcPitch, dstPitch;
SDL_Rect *last_rect = _dirty_rect_list + _num_dirty_rects;
- if (_scaler_proc == Normal1x) {
+ if (_scaler_proc == Normal1x && !_adjustAspectRatio) {
SDL_Surface *target = _overlayVisible ? _tmpscreen : _screen;
for (r = _dirty_rect_list; r != last_rect; ++r) {
dst = *r;
@@ -314,23 +315,32 @@
for (r = _dirty_rect_list; r != last_rect; ++r) {
register int dst_y = r->y + _currentShakePos;
register int dst_h = 0;
+ register int orig_dst_y = 0;
+
if (dst_y < _screenHeight) {
dst_h = r->h;
if (dst_h > _screenHeight - dst_y)
dst_h = _screenHeight - dst_y;
- dst_y *= _scaleFactor;
+ dst_y *= _scaleFactor;
- _scaler_proc((byte *)_tmpscreen->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch,
+ if (_adjustAspectRatio) {
+ orig_dst_y = dst_y;
+ dst_y = real2Aspect(dst_y);
+ }
+
+ _scaler_proc((byte *)_tmpscreen->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch,
(byte *)_hwscreen->pixels + r->x * 2 * _scaleFactor + dst_y * dstPitch, dstPitch, r->w, dst_h);
}
-
+
r->x *= _scaleFactor;
r->y = dst_y;
r->w *= _scaleFactor;
r->h = dst_h * _scaleFactor;
- }
+ if (_adjustAspectRatio && orig_dst_y / _scaleFactor < _screenHeight)
+ r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y);
+ }
SDL_UnlockSurface(_tmpscreen);
SDL_UnlockSurface(_hwscreen);
}
@@ -339,7 +349,7 @@
// This is necessary if shaking is active.
if (_forceFull) {
_dirty_rect_list[0].y = 0;
- _dirty_rect_list[0].h = _screenHeight * _scaleFactor;
+ _dirty_rect_list[0].h = (_adjustAspectRatio ? 240 : _screenHeight) * _scaleFactor;
}
// Finally, blit all our changes to the screen
@@ -374,6 +384,12 @@
hotswap_gfx_mode();
return 1;
+ } else if (param == PROP_TOGGLE_ASPECT_RATIO) {
+ if (_screenHeight == 200) {
+ assert(_hwscreen != 0);
+ _adjustAspectRatio ^= true;
+ hotswap_gfx_mode();
+ }
}
return OSystem_SDL_Common::property(param, value);
Index: sdl_gl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl_gl.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- sdl_gl.cpp 20 Jun 2003 10:59:22 -0000 1.36
+++ sdl_gl.cpp 22 Jun 2003 11:55:40 -0000 1.37
@@ -54,7 +54,6 @@
int _glFlags;
int _glScreenStart;
bool _glBilinearFilter;
- bool _glAspectRatio;
bool _usingOpenGL;
SDL_Surface *tmpSurface; // Used for black rectangles blitting
SDL_Rect tmpBlackRect; // Black rectangle at end of the GL screen
@@ -79,7 +78,6 @@
{
_glScreenStart = 0;
_glBilinearFilter = true;
- _glAspectRatio = false;
_usingOpenGL = false; // false => Switch to filters used in the sdl.cpp version
_glBottomOfTexture = 256; // height is always 256
// 640x480 resolution
@@ -165,7 +163,7 @@
case GFX_NORMAL:
normal_mode:;
- _scaleFactor = 1;
+ _scaleFactor = _usingOpenGL ? 2 : 1;
_scaler_proc = Normal1x;
break;
default:
@@ -199,8 +197,7 @@
fb2gl.init(_glWindow.w, _glWindow.h, 0, _glScreenStart? 15: 70,
_glFlags);
- }
- else { // SDL backend
+ } else { // SDL backend
_hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, _screenHeight * _scaleFactor, 16,
_full_screen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
@@ -234,8 +231,7 @@
Gmask,
Bmask,
Amask);
- }
- else { // SDL backend
+ } else { // SDL backend
_tmpscreen = SDL_CreateRGBSurfaceFrom(tmp_screen,
_tmpScreenWidth,
_screenHeight + 3,
@@ -346,8 +342,7 @@
SDL_FillRect(tmpSurface, &blackrect, 0);
fb2gl.blit16(tmpSurface, 1, &blackrect, 0, 0);
- }
- else { // SDL backend
+ } else { // SDL backend
SDL_Rect blackrect = {0, 0, _screenWidth * _scaleFactor, _newShakePos * _scaleFactor};
SDL_FillRect(_hwscreen, &blackrect, 0);
}
@@ -545,9 +540,30 @@
#endif
return 1;
- }
- else if (param == PROP_SET_GFX_MODE) {
+ } else if (param == PROP_TOGGLE_ASPECT_RATIO) {
+ if (!_usingOpenGL) {
+ _usingOpenGL = true;
+ _mode = GFX_NORMAL;
+ hotswap_gfx_mode();
+ }
+
+ _adjustAspectRatio ^= true;
+ if (_adjustAspectRatio) {
+ // Don't use the whole screen (black borders)
+ fb2gl.init(0, 0, 0, 15, _glFlags);
+ _glScreenStart = 20;
+ SDL_FillRect(tmpSurface, &tmpBlackRect, 0);
+ fb2gl.blit16(tmpSurface, 1, &tmpBlackRect, 0, 0);
+ } else {
+ // Use the whole screen
+ fb2gl.init(0, 0, 0, 70, _glFlags);
+ _glScreenStart = 0;
+ }
+
SDL_Rect full = {0, 0, _screenWidth, _screenHeight};
+ fb2gl.blit16(_tmpscreen, 1, &full, 0, _glScreenStart);
+ fb2gl.display();
+ } else if (param == PROP_SET_GFX_MODE) {
if (value->gfx_mode > 10) { // OpenGL modes
if (!_usingOpenGL) {
@@ -562,20 +578,6 @@
_glBilinearFilter ^= true;
fb2gl.setBilinearMode(_glBilinearFilter);
break;
- case GFX_ASPECTRATIO:
- _glAspectRatio ^= true;
- if (_glAspectRatio) {
- // Don't use the whole screen (black borders)
- fb2gl.init(0, 0, 0, 15, _glFlags);
- _glScreenStart = 20;
- SDL_FillRect(tmpSurface, &tmpBlackRect, 0);
- fb2gl.blit16(tmpSurface, 1, &tmpBlackRect, 0, 0);
- } else {
- // Use the whole screen
- fb2gl.init(0, 0, 0, 70, _glFlags);
- _glScreenStart = 0;
- }
- break;
default: // SDL backend
if (value->gfx_mode >= 10)
return 0;
@@ -589,6 +591,7 @@
};
if (_usingOpenGL) {
+ SDL_Rect full = {0, 0, _screenWidth, _screenHeight};
fb2gl.blit16(_tmpscreen, 1, &full, 0, _glScreenStart);
fb2gl.display();
}
Index: sdl-common.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- sdl-common.h 9 Jun 2003 01:19:25 -0000 1.27
+++ sdl-common.h 22 Jun 2003 11:55:40 -0000 1.28
@@ -123,7 +123,7 @@
virtual int16 RGBToColor(uint8 r, uint8 g, uint8 b);
virtual void colorToRGB(int16 color, uint8 &r, uint8 &g, uint8 &b);
- static OSystem *create(int gfx_mode, bool full_screen);
+ static OSystem *create(int gfx_mode, bool full_screenm, bool aspect_ratio);
protected:
OSystem_SDL_Common();
@@ -131,7 +131,7 @@
static OSystem_SDL_Common *create_intern();
- void init_intern(int gfx_mode, bool full_screen);
+ void init_intern(int gfx_mode, bool full_screen, bool aspect_ratio);
// unseen game screen
SDL_Surface *_screen;
@@ -141,6 +141,8 @@
SDL_Surface *_tmpscreen;
int _tmpScreenWidth;
bool _overlayVisible;
+
+ bool _adjustAspectRatio;
// CD Audio
SDL_CD *_cdrom;
- Previous message: [Scummvm-cvs-logs] CVS: scummvm README,1.115,1.116
- Next message: [Scummvm-cvs-logs] CVS: scummvm/common gameDetector.h,1.45,1.46 gameDetector.cpp,1.113,1.114 scaler.cpp,1.22,1.23 scaler.h,1.11,1.12 system.h,1.32,1.33
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list