[Scummvm-cvs-logs] CVS: scummvm gfx.cpp,1.25,1.26 saveload.cpp,1.21,1.22 scumm.h,1.36,1.37 scummvm.dsp,1.17,1.18 sdl.cpp,1.27,1.28 windows.cpp,1.23,1.24
Ludvig Strigeus
strigeus at users.sourceforge.net
Fri Dec 28 07:27:01 CET 2001
Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv11763
Modified Files:
gfx.cpp saveload.cpp scumm.h scummvm.dsp sdl.cpp windows.cpp
Log Message:
implemented shaking,
added a toggle fullscreen patch (doesn't work for me though)
Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gfx.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** gfx.cpp 2001/12/27 17:51:58 1.25
--- gfx.cpp 2001/12/28 15:26:28 1.26
***************
*** 102,105 ****
--- 102,112 ----
}
+ /* power of 2 */
+ #define NUM_SHAKE_POSITIONS 8
+
+ static const int8 shake_positions[NUM_SHAKE_POSITIONS] = {
+ 0,1*2,2*2,1*2,0*2,2*2,3*2,1*2
+ };
+
void Scumm::drawDirtyScreenParts() {
int i;
***************
*** 126,131 ****
--- 133,166 ----
}
}
+
+ /* Handle shaking */
+ if (_shakeEnabled) {
+ _shakeFrame = (_shakeFrame + 1) & (NUM_SHAKE_POSITIONS-1);
+ setShakePos(this,shake_positions[_shakeFrame]);
+ }
}
+ void Scumm::redrawLines(int from, int to) {
+ VirtScreen *vs = virtscr;
+ int i,j;
+
+ if (to<=from)
+ return;
+
+ for(i=0; i!=ARRAYSIZE(virtscr); i++,vs++) {
+ if (to > vs->topline && from < vs->topline + vs->height) {
+ int min = from - vs->topline;
+ int max = to - vs->topline;
+ if (min < 0) min = 0;
+ if (max > vs->height) max = vs->height;
+ for (j=0; j!=40; j++) {
+ vs->tdirty[j] = min;
+ vs->bdirty[j] = max;
+ }
+ gdi.updateDirtyScreen(vs);
+ }
+ }
+ }
+
void Scumm::updateDirtyScreen(int slot) {
gdi.updateDirtyScreen(&virtscr[slot]);
***************
*** 494,499 ****
break;
case 129:
! setDirtyRange(0, 0, vs->height);
! updateDirtyScreen(0);
/* XXX: EGA_proc4(0); */
break;
--- 529,534 ----
break;
case 129:
! // setDirtyRange(0, 0, vs->height);
! // updateDirtyScreen(0);
/* XXX: EGA_proc4(0); */
break;
***************
*** 1396,1400 ****
}
} else {
- /* DE92 */
if (l<0 || l>=40 || b<=t)
continue;
--- 1431,1434 ----
***************
*** 1426,1435 ****
void Scumm::setShake(int mode) {
! if (mode!=-1)
! _shakeMode = mode;
! else
! mode = 0;
! /* XXX: not implemented */
! warning("stub setShake(%d)",mode);
}
--- 1460,1466 ----
void Scumm::setShake(int mode) {
! _shakeEnabled = mode != 0;
! _shakeFrame = 0;
! setShakePos(this,0);
}
Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saveload.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** saveload.cpp 2001/12/27 17:51:58 1.21
--- saveload.cpp 2001/12/28 15:26:28 1.22
***************
*** 398,402 ****
MKLINE(Scumm,_randSeed2,sleUint32),
! MKLINE(Scumm,_shakeMode,sleInt16),
MKLINE(Scumm,_keepText,sleByte),
--- 398,404 ----
MKLINE(Scumm,_randSeed2,sleUint32),
! /* XXX: next time the save game format changes,
! * convert _shakeEnabled to boolean and add a _shakeFrame field */
! MKLINE(Scumm,_shakeEnabled,sleInt16),
MKLINE(Scumm,_keepText,sleByte),
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** scumm.h 2001/12/27 17:51:58 1.36
--- scumm.h 2001/12/28 15:26:28 1.37
***************
*** 1055,1060 ****
int16 _talkDelay;
- int16 _shakeMode;
int16 _virtual_mouse_x, _virtual_mouse_y;
--- 1055,1062 ----
int16 _talkDelay;
+ bool _shakeEnabled;
+ uint _shakeFrame;
+
int16 _virtual_mouse_x, _virtual_mouse_y;
***************
*** 2066,2069 ****
--- 2068,2073 ----
byte cost_increaseAnim(LoadedCostume *lc, Actor *a, int slot);
void cost_decodeData(Actor *a, int frame, uint usemask);
+
+ void redrawLines(int from, int to);
};
***************
*** 2197,2199 ****
void playSfxSound(void *sound, uint32 size, uint rate);
bool isSfxFinished();
! void waitForTimer(Scumm *s, int msec_delay);
\ No newline at end of file
--- 2201,2204 ----
void playSfxSound(void *sound, uint32 size, uint rate);
bool isSfxFinished();
! void waitForTimer(Scumm *s, int msec_delay);
! void setShakePos(Scumm *s, int shake_pos);
\ No newline at end of file
Index: scummvm.dsp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scummvm.dsp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** scummvm.dsp 2001/12/27 17:51:58 1.17
--- scummvm.dsp 2001/12/28 15:26:28 1.18
***************
*** 67,71 ****
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
! # ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "./sound" /I "./" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "ALLOW_GDI" /D "BYPASS_COPY_PROT" /D "USE_ADLIB" /D "DUMP_SCRIPTS" /D "FULL_THROTTLE" /D "CHECK_HEAP" /Yu"stdafx.h" /FD /GZ /c
# SUBTRACT CPP /Fr
# ADD BASE RSC /l 0x41d /d "_DEBUG"
--- 67,71 ----
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
! # ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "./sound" /I "./" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "ALLOW_GDI" /D "BYPASS_COPY_PROT" /D "USE_ADLIB" /D "DUMP_SCRIPTS" /Yu"stdafx.h" /FD /GZ /c
# SUBTRACT CPP /Fr
# ADD BASE RSC /l 0x41d /d "_DEBUG"
Index: sdl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sdl.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** sdl.cpp 2001/12/27 17:51:58 1.27
--- sdl.cpp 2001/12/28 15:26:28 1.28
***************
*** 26,30 ****
#include "gui.h"
#include "sound.h"
-
#include "SDL_thread.h"
--- 26,29 ----
***************
*** 40,43 ****
--- 39,44 ----
static SDL_Surface *screen;
+ static int current_shake_pos;
+
void updateScreen(Scumm *s);
***************
*** 97,116 ****
s->_saveLoadFlag = 2;
s->_saveLoadCompatible = false;
! }
! if (event.key.keysym.sym=='z' && event.key.keysym.mod&KMOD_CTRL) {
exit(1);
! }
! if (event.key.keysym.sym=='f' && event.key.keysym.mod&KMOD_CTRL) {
s->_fastMode ^= 1;
! }
! if (event.key.keysym.sym=='g' && event.key.keysym.mod&KMOD_CTRL) {
s->_fastMode ^= 2;
! }
!
! if (event.key.keysym.sym=='d' && event.key.keysym.mod&KMOD_CTRL) {
debugger.attach(s);
! }
! if (event.key.keysym.sym=='s' && event.key.keysym.mod&KMOD_CTRL) {
s->resourceStats();
}
--- 98,113 ----
s->_saveLoadFlag = 2;
s->_saveLoadCompatible = false;
! } else if (event.key.keysym.sym=='z' && event.key.keysym.mod&KMOD_CTRL) {
exit(1);
! } else if (event.key.keysym.sym=='f' && event.key.keysym.mod&KMOD_CTRL) {
s->_fastMode ^= 1;
! } else if (event.key.keysym.sym=='g' && event.key.keysym.mod&KMOD_CTRL) {
s->_fastMode ^= 2;
! } else if (event.key.keysym.sym=='d' && event.key.keysym.mod&KMOD_CTRL) {
debugger.attach(s);
! } else if (event.key.keysym.sym=='s' && event.key.keysym.mod&KMOD_CTRL) {
s->resourceStats();
+ } else if (event.key.keysym.sym==SDLK_RETURN && event.key.keysym.mod&KMOD_ALT) {
+ SDL_WM_ToggleFullScreen(screen);
}
***************
*** 206,209 ****
--- 203,260 ----
}
+ #define MAX(a,b) (((a)<(b)) ? (b) : (a))
+ #define MIN(a,b) (((a)>(b)) ? (b) : (a))
+
+ void setShakePos(Scumm *s, int shake_pos) {
+ int old_shake_pos = current_shake_pos;
+ int dirty_height, dirty_blackheight;
+ int dirty_top, dirty_blacktop;
+
+ if (shake_pos != old_shake_pos) {
+ current_shake_pos = shake_pos;
+ fullRedraw = true;
+
+ /* Old shake pos was current_shake_pos, new is shake_pos.
+ * Move the screen up or down to account for the change.
+ */
+ #if defined(SCALEUP_2x2)
+ SDL_Rect dstr = {0,shake_pos*2,640,400}, srcr = {0,old_shake_pos*2,640,400};
+ #else
+ SDL_Rect dstr = {0,shake_pos,320,200}, srcr = {0,old_shake_pos,320,200};
+ #endif
+ SDL_BlitSurface(screen, &srcr, screen, &dstr);
+
+ /* Also adjust the mouse pointer backup Y coordinate.
+ * There is a minor mouse glitch when the mouse is moved
+ * at the blackness of the shake area, but it's hardly noticable */
+ old_mouse_y += shake_pos - old_shake_pos;
+
+ /* Refresh either the upper part of the screen,
+ * or the lower part */
+ if (shake_pos > old_shake_pos) {
+ dirty_height = MIN(shake_pos, 0) - MIN(old_shake_pos,0);
+ dirty_top = -MIN(shake_pos,0);
+ dirty_blackheight = MAX(shake_pos,0) - MAX(old_shake_pos,0);
+ dirty_blacktop = MAX(old_shake_pos,0);
+ } else {
+ dirty_height = MAX(old_shake_pos,0) - MAX(shake_pos, 0);
+ dirty_top = 200 - MAX(old_shake_pos,0);
+ dirty_blackheight = MIN(old_shake_pos,0) - MIN(shake_pos,0);
+ dirty_blacktop = 200 + MIN(shake_pos,0);
+ }
+
+ /* Fill the dirty area with blackness or the scumm image */
+ {
+ #if defined(SCALEUP_2x2)
+ SDL_Rect blackrect = {0, dirty_blacktop*2, 640, dirty_blackheight*2};
+ #else
+ SDL_Rect blackrect = {0, dirty_blacktop, 320, dirty_blackheight};
+ #endif
+ SDL_FillRect(screen, &blackrect, 0);
+ s->redrawLines(dirty_top, dirty_top + dirty_height);
+ }
+ }
+ }
+
/* Copy part of bitmap */
void blitToScreen(Scumm *s, byte *src,int x, int y, int w, int h) {
***************
*** 216,219 ****
--- 267,276 ----
}
+ /* Account for the shaking and do Y clipping */
+ y += current_shake_pos;
+ if (y < 0 ) { h += y; src -= y*320; y = 0; }
+ if (h > 200 - y) { h = 200 - y; }
+ if (h<=0) return;
+
if (SDL_LockSurface(screen)==-1)
error("SDL_LockSurface failed: %s.\n", SDL_GetError());
***************
*** 254,258 ****
s->drawMouse();
}
!
if(s->_palDirtyMax != -1) {
updatePalette(s);
--- 311,315 ----
s->drawMouse();
}
!
if(s->_palDirtyMax != -1) {
updatePalette(s);
***************
*** 310,313 ****
--- 367,372 ----
if (visible) {
+ ydraw += current_shake_pos;
+
dst = (byte*)screen->pixels + ydraw*640*2 + xdraw*2;
bak = old_backup;
***************
*** 346,349 ****
--- 405,410 ----
}
if (visible) {
+ ydraw += current_shake_pos;
+
dst = (byte*)screen->pixels + ydraw*320 + xdraw;
bak = old_backup;
***************
*** 411,414 ****
--- 472,477 ----
SDL_AudioSpec desired;
+ putenv("SDL_VIDEODRIVER=windib");
+
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO)==-1) {
error("Could not initialize SDL: %s.\n", SDL_GetError());
***************
*** 439,442 ****
--- 502,507 ----
SDL_CreateThread((int (*)(void *))&music_thread, &scumm);
}
+
+
#if !defined(SCALEUP_2x2)
Index: windows.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/windows.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** windows.cpp 2001/12/27 17:51:58 1.23
--- windows.cpp 2001/12/28 15:26:28 1.24
***************
*** 423,426 ****
--- 423,428 ----
}
+ void setShakePos(Scumm *s, int shake_pos) {}
+
int clock;
More information about the Scummvm-git-logs
mailing list