From: Holger Schemel Date: Tue, 15 Sep 1998 01:00:03 +0000 (+0200) Subject: rnd-19980915 X-Git-Tag: 1.2.0^2~83 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=4b0c6356359ee52f98cee8fa578179c6c41d4ef1;p=rocksndiamonds.git rnd-19980915 --- diff --git a/src/cartoons.c b/src/cartoons.c index 2edb0e4e..1d537314 100644 --- a/src/cartoons.c +++ b/src/cartoons.c @@ -125,7 +125,7 @@ void HandleAnimation(int mode) reset_delay = TRUE; /* Fill empty backbuffer for animation functions */ - if (direct_draw_on && game_status==PLAYING) + if (direct_draw_on && game_status == PLAYING) { int xx,yy; @@ -139,7 +139,7 @@ void HandleAnimation(int mode) SetDrawtoField(DRAW_DIRECT); } - if (soft_scrolling_on && game_status==PLAYING) + if (soft_scrolling_on && game_status == PLAYING) { int fx = FX, fy = FY; diff --git a/src/events.c b/src/events.c index af4a4c56..c669e5e7 100644 --- a/src/events.c +++ b/src/events.c @@ -70,10 +70,13 @@ void EventLoop(void) has its own synchronization and is CPU friendly, too */ if (game_status != PLAYING) - Delay(1000); + { + XSync(display, FALSE); + Delay(10000); + } } - if (game_status==EXITGAME) + if (game_status == EXITGAME) return; } } @@ -173,10 +176,17 @@ void HandleExposeEvent(XExposeEvent *event) SetDrawtoField(DRAW_DIRECT); } - if (soft_scrolling_on && game_status==PLAYING) + if (soft_scrolling_on && game_status == PLAYING) + { + int fx = FX, fy = FY; + + fx += (PlayerMovDir & (MV_LEFT|MV_RIGHT) ? ScreenMovPos : 0); + fy += (PlayerMovDir & (MV_UP|MV_DOWN) ? ScreenMovPos : 0); + XCopyArea(display,fieldbuffer,backbuffer,gc, - FX,FY, SXSIZE,SYSIZE, + fx,fy, SXSIZE,SYSIZE, SX,SY); + } XCopyArea(display,drawto,window,gc, x,y, width,height, x,y); @@ -288,9 +298,6 @@ void HandleButton(int mx, int my, int button) } } -int GameSpeed = 2; -int MoveSpeed = 8; - void HandleKey(KeySym key, int key_status) { int joy = 0; @@ -700,6 +707,7 @@ void HandleJoystick() break; case PLAYING: { + static int player_frame_reset_delay = 0; BOOL moved = FALSE, snapped = FALSE, bombed = FALSE; if (GameOver && newbutton) @@ -715,6 +723,8 @@ void HandleJoystick() if (joy) { + player_frame_reset_delay = 0; + if (button1) snapped = SnapField(dx,dy); else @@ -737,7 +747,8 @@ void HandleJoystick() { DigField(0,0,0,0,DF_NO_PUSH); SnapField(0,0); - PlayerFrame = 0; + if (++player_frame_reset_delay > MoveSpeed) + PlayerFrame = 0; } if (tape.playing && !tape.pausing && !joy && tape.counter %ld / %ld [%d]\n", - new_Counter - last_Counter, - new_Counter, - FrameCounter); - last_Counter = new_Counter; - } - - - - - /* - if (!DelayReached(&action_delay, action_delay_value)) - return; - */ - - while(!DelayReached(&action_delay, action_delay_value)) - Delay(1000); - - - - - /* - printf("-----------\n"); - */ - + Delay(5000); + if (tape.pausing || (tape.playing && !TapePlayDelay())) + return; + else if (tape.recording) + TapeRecordDelay(); FrameCounter++; + TimeFrames++; - - - /* - if (PlayerMovPos) - ScrollFigure(0); - - DrawPlayerField(); - */ - - - tst2 = tst; - tst = 0; - - - - if (0) - { - static long last_Counter = 0; - long new_Counter = Counter(); - - printf("--> %ld / %ld [%d]\n", - new_Counter - last_Counter, - new_Counter, - FrameCounter); - last_Counter = new_Counter; - } - - - /* - printf("--> %ld / ", Counter()); - */ - - + for(y=0;y0) + JustHit[x][y]--; - TimeFrames++; - - for(y=0;y0) - JustHit[x][y]--; + int oldx,oldy; -#if DEBUG - if (IS_BLOCKED(x,y)) + Blocked2Moving(x,y,&oldx,&oldy); + if (!IS_MOVING(oldx,oldy)) { - int oldx,oldy; - - Blocked2Moving(x,y,&oldx,&oldy); - if (!IS_MOVING(oldx,oldy)) - { - printf("GameActions(): (BLOCKED=>MOVING) context corrupted!\n"); - printf("GameActions(): BLOCKED: x = %d, y = %d\n",x,y); - printf("GameActions(): !MOVING: oldx = %d, oldy = %d\n",oldx,oldy); - printf("GameActions(): This should never happen!\n"); - } + printf("GameActions(): (BLOCKED=>MOVING) context corrupted!\n"); + printf("GameActions(): BLOCKED: x = %d, y = %d\n",x,y); + printf("GameActions(): !MOVING: oldx = %d, oldy = %d\n",oldx,oldy); + printf("GameActions(): This should never happen!\n"); } + } #endif + } - } + for(y=0;y0 && TimeFrames>=(100/GameSpeed) && !tape.pausing) { TimeFrames = 0; @@ -2834,8 +2731,6 @@ void GameActions() } DrawPlayerField(); - - BackToFront(); } void ScrollLevel(int dx, int dy) @@ -2991,79 +2886,18 @@ BOOL MoveFigure(int dx, int dy) void ScrollFigure(int init) { static long actual_frame_counter = 0; - static int oldJX = -1, oldJY = -1; if (init) { - - - PlayerGfxPos = ScrollStepSize * (PlayerMovPos / ScrollStepSize); - - - - /* - ScreenMovPos = PlayerGfxPos; - redraw_mask |= REDRAW_FIELD; - */ - - - - if (0) - { - static long last_Counter = 0; - long new_Counter = Counter(); - - printf("--> %ld / %ld [%d, %d]\n", - new_Counter - last_Counter, - new_Counter, - FrameCounter, - tst2); - last_Counter = new_Counter; - } - - - - - if (oldJX != -1 && oldJY != -1) - DrawLevelElement(oldJX,oldJY, Feld[oldJX][oldJY]); + actual_frame_counter = FrameCounter; if (Feld[lastJX][lastJY] == EL_LEERRAUM && IN_LEV_FIELD(lastJX,lastJY-1) && CAN_FALL(Feld[lastJX][lastJY-1])) Feld[lastJX][lastJY] = EL_PLAYER_IS_LEAVING; - DrawLevelElement(lastJX,lastJY, Feld[lastJX][lastJY]); - DrawPlayerField(); - - oldJX = lastJX; - oldJY = lastJY; - actual_frame_counter = FrameCounter; - - if (PlayerPushing) - { - int nextJX = JX + (JX - lastJX); - int nextJY = JY + (JY - lastJY); - - if (Feld[nextJX][nextJY] == EL_SOKOBAN_FELD_VOLL) - DrawLevelElement(nextJX,nextJY, EL_SOKOBAN_FELD_LEER); - else - DrawLevelElement(nextJX,nextJY, EL_LEERRAUM); - } DrawPlayerField(); - - if (Store[lastJX][lastJY]) - { - DrawGraphic(SCROLLX(lastJX),SCROLLY(lastJY), - el2gfx(Store[lastJX][lastJY])); - DrawGraphicThruMask(SCROLLX(lastJX),SCROLLY(lastJY), - el2gfx(Feld[lastJX][lastJY])); - } - else if (Feld[lastJX][lastJY]==EL_DYNAMIT) - DrawDynamite(lastJX,lastJY); - else - DrawLevelField(lastJX,lastJY); - return; } else if (!FrameReached(&actual_frame_counter,1)) @@ -3072,59 +2906,21 @@ void ScrollFigure(int init) PlayerMovPos += (PlayerMovPos > 0 ? -1 : 1) * TILEX/8; PlayerGfxPos = ScrollStepSize * (PlayerMovPos / ScrollStepSize); - - /* - printf("PlayerGfxPos = %d\n", PlayerGfxPos); - */ - - if (ScreenMovPos && ScreenMovPos != PlayerGfxPos) { ScreenMovPos = PlayerGfxPos; redraw_mask |= REDRAW_FIELD; } - if (Feld[oldJX][oldJY] == EL_PLAYER_IS_LEAVING) - Feld[oldJX][oldJY] = EL_LEERRAUM; + if (Feld[lastJX][lastJY] == EL_PLAYER_IS_LEAVING) + Feld[lastJX][lastJY] = EL_LEERRAUM; - DrawLevelElement(oldJX,oldJY, Feld[oldJX][oldJY]); DrawPlayerField(); - - - if (Store[oldJX][oldJY]) - { - DrawGraphic(SCROLLX(oldJX),SCROLLY(oldJY),el2gfx(Store[oldJX][oldJY])); - DrawGraphicThruMask(SCROLLX(oldJX),SCROLLY(oldJY), - el2gfx(Feld[oldJX][oldJY])); - } - else if (Feld[oldJX][oldJY]==EL_DYNAMIT) - DrawDynamite(oldJX,oldJY); - else - DrawLevelField(oldJX,oldJY); - - if (PlayerPushing) - { - int nextJX = JX + (JX - lastJX); - int nextJY = JY + (JY - lastJY); - - if (PlayerGfxPos) - { - if (Feld[nextJX][nextJY] == EL_SOKOBAN_FELD_VOLL) - DrawLevelElement(nextJX,nextJY, EL_SOKOBAN_FELD_LEER); - else - DrawLevelElement(nextJX,nextJY, EL_LEERRAUM); - } - else - DrawLevelElement(nextJX,nextJY, Feld[nextJX][nextJY]); - } - if (!PlayerMovPos) { lastJX = JX; lastJY = JY; - - oldJX = oldJY = -1; } } diff --git a/src/gif.c b/src/gif.c index bbeb6aba..d2fdda81 100644 --- a/src/gif.c +++ b/src/gif.c @@ -492,12 +492,18 @@ Image *gifLoad(char *fullname) return(NULL); } + + + /* printf("%s:\n %dx%d %s%s image with %d colors at depth %d\n", fullname, gifin_img_width, gifin_img_height, (gifin_interlace_flag ? "interlaced " : ""), gif_version_name[gifin_version], (gifin_l_cmap_flag ? gifin_l_ncolors : gifin_g_ncolors), (gifin_l_cmap_flag ? gifin_l_pixel_bits : gifin_g_pixel_bits)); + */ + + image = newRGBImage(gifin_img_width, gifin_img_height, (gifin_l_cmap_flag ? gifin_l_pixel_bits : diff --git a/src/gifload.c b/src/gifload.c index fc2fc28a..215d32a0 100644 --- a/src/gifload.c +++ b/src/gifload.c @@ -18,7 +18,9 @@ #include "xli.h" #ifdef DEBUG +/* #define DEBUG_TIMING +*/ #endif diff --git a/src/init.c b/src/init.c index 0262c37e..61055359 100644 --- a/src/init.c +++ b/src/init.c @@ -25,7 +25,9 @@ #include #ifdef DEBUG +/* #define DEBUG_TIMING +*/ #endif struct PictureFileInfo diff --git a/src/main.c b/src/main.c index 9028fb6b..302b5418 100644 --- a/src/main.c +++ b/src/main.c @@ -14,6 +14,7 @@ #include "main.h" #include "init.h" +#include "game.h" #include "events.h" #include "sound.h" #include "joystick.h" @@ -88,6 +89,7 @@ int level_nr, leveldir_nr, num_leveldirs; int lev_fieldx,lev_fieldy, scroll_x,scroll_y; int FX = SX, FY = SY, ScreenMovPos = 0, ScrollStepSize = TILEX/8; +int GameSpeed = GAME_FRAME_DELAY, MoveSpeed = 8; int BX1 = 0, BY1 = 0, BX2 = SCR_FIELDX-1, BY2 = SCR_FIELDY-1; int JX,JY, lastJX,lastJY, ZX,ZY, ExitX,ExitY; int PlayerMovDir, PlayerMovPos, PlayerPushing; diff --git a/src/main.h b/src/main.h index be08fcdb..37131fef 100644 --- a/src/main.h +++ b/src/main.h @@ -328,6 +328,7 @@ extern int level_nr, leveldir_nr, num_leveldirs; extern int lev_fieldx,lev_fieldy, scroll_x,scroll_y; extern int FX,FY, ScreenMovPos, ScrollStepSize; +extern int GameSpeed, MoveSpeed; extern int BX1,BY1, BX2,BY2; extern int JX,JY, lastJX,lastJY, ZX,ZY, ExitX,ExitY; extern int PlayerMovDir, PlayerMovPos, PlayerPushing; diff --git a/src/misc.c b/src/misc.c index 14007b7e..657bc164 100644 --- a/src/misc.c +++ b/src/misc.c @@ -26,14 +26,31 @@ void microsleep(unsigned long usec) { - struct timeval delay; + if (usec < 5000) + { + /* we want to wait less than 5 ms -- if we assume that we have a + kernel timer resolution of 10 ms, we would wait far to long; + therefore it's better to do a short interval of busy waiting + to get our sleeping time more accurate */ - delay.tv_sec = usec / 1000000; - delay.tv_usec = usec % 1000000; + long base_counter = Counter2(), actual_counter = Counter2(); + long delay = usec/1000; - if (select(0,NULL,NULL,NULL,&delay)!=0) - fprintf(stderr,"%s: in function microsleep: select failed!\n", - progname); + while (actual_counter < base_counter+delay && + actual_counter >= base_counter) + actual_counter = Counter2(); + } + else + { + struct timeval delay; + + delay.tv_sec = usec / 1000000; + delay.tv_usec = usec % 1000000; + + if (select(0,NULL,NULL,NULL,&delay) != 0) + fprintf(stderr,"%s: in function microsleep: select failed!\n", + progname); + } } long mainCounter(int mode) diff --git a/src/screens.c b/src/screens.c index 37c8128c..e4f8f8a1 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1312,6 +1312,8 @@ void HandleGameActions() TapeStop(); GameActions(); + + BackToFront(); } void HandleVideoButtons(int mx, int my, int button) diff --git a/src/tools.c b/src/tools.c index 499469d6..f611f5cd 100644 --- a/src/tools.c +++ b/src/tools.c @@ -339,7 +339,6 @@ void DrawPlayerField() int element = Feld[x][y]; int graphic, phase; - BOOL draw_thru_mask = FALSE; if (PlayerGone) return; @@ -360,39 +359,43 @@ void DrawPlayerField() if (direct_draw_on) SetDrawtoField(DRAW_BUFFERED); - /* draw things behind the player (EL_PFORTE* || mole/penguin/pig/dragon) */ - - + /* draw things in the field the player is leaving, if needed */ + if (lastJX != JX || lastJY != JY) + { + if (Store[lastJX][lastJY]) + { + DrawLevelElement(lastJX,lastJY, Store[lastJX][lastJY]); + DrawLevelElementThruMask(lastJX,lastJY, Feld[lastJX][lastJY]); + } + else if (Feld[lastJX][lastJY] == EL_DYNAMIT) + DrawDynamite(lastJX,lastJY); + else + DrawLevelField(lastJX,lastJY); - DrawLevelField(x,y); + if (PlayerPushing) + { + int nextJX = JX + (JX - lastJX); + int nextJY = JY + (JY - lastJY); + if (PlayerGfxPos) + { + if (Feld[nextJX][nextJY] == EL_SOKOBAN_FELD_VOLL) + DrawLevelElement(nextJX,nextJY, EL_SOKOBAN_FELD_LEER); + else + DrawLevelElement(nextJX,nextJY, EL_LEERRAUM); + } + else + DrawLevelField(nextJX,nextJY); + } + } + /* draw things behind the player, if needed */ if (Store[x][y]) - { - DrawGraphic(sx,sy, el2gfx(Store[x][y])); - draw_thru_mask = TRUE; - } - else if (element!=EL_DYNAMIT && element!=EL_DYNABOMB) - { - DrawLevelField(x,y); - draw_thru_mask = TRUE; - } - - /* - else if (element!=EL_LEERRAUM && element!=EL_DYNAMIT && element!=EL_DYNABOMB) - { + DrawLevelElement(x,y, Store[x][y]); + else if (element != EL_DYNAMIT && element != EL_DYNABOMB) DrawLevelField(x,y); - draw_thru_mask = TRUE; - } - */ - - - draw_thru_mask = TRUE; - - - /* draw player himself */ @@ -407,7 +410,6 @@ void DrawPlayerField() graphic += PlayerFrame; - if (PlayerGfxPos) { if (PlayerMovDir == MV_LEFT || PlayerMovDir == MV_RIGHT) @@ -416,31 +418,10 @@ void DrawPlayerField() syy = PlayerGfxPos; } - if (!soft_scrolling_on && ScreenMovPos) sxx = syy = 0; - - - - - - if (draw_thru_mask) - DrawGraphicShiftedThruMask(sx,sy,sxx,syy,graphic,CUT_NO_CUTTING); - /* - DrawGraphicThruMask(sx, sy, graphic); - */ - else - DrawGraphicShifted(sx,sy,sxx,syy,graphic,CUT_NO_CUTTING); - /* - DrawGraphic(sx, sy, graphic); - */ - - - - MarkTileDirty(sx,sy); - - + DrawGraphicShiftedThruMask(sx,sy, sxx,syy, graphic, NO_CUTTING); if (PlayerPushing && PlayerGfxPos) { @@ -450,9 +431,7 @@ void DrawPlayerField() if (Feld[JX][JY] == EL_SOKOBAN_FELD_LEER || Feld[nextJX][nextJY] == EL_SOKOBAN_FELD_VOLL) - DrawGraphicShiftedThruMask(px,py,sxx,syy, - GFX_SOKOBAN_OBJEKT, - CUT_NO_CUTTING); + DrawGraphicShiftedThruMask(px,py,sxx,syy, GFX_SOKOBAN_OBJEKT,NO_CUTTING); else { int element = Feld[nextJX][nextJY]; @@ -466,21 +445,12 @@ void DrawPlayerField() graphic += phase; else graphic += (phase+4)%4; - - - /* - printf("----> (%d, %d, %d)\n", - PlayerGfxPos, phase, graphic); - */ - } - DrawGraphicShifted(px,py, sxx,syy, graphic, CUT_NO_CUTTING); + DrawGraphicShifted(px,py, sxx,syy, graphic, NO_CUTTING, NO_MASKING); } } - - /* draw things in front of player (EL_DYNAMIT || EL_DYNABOMB) */ if (element == EL_DYNAMIT || element == EL_DYNABOMB) @@ -520,6 +490,8 @@ void DrawPlayerField() dest_x,dest_y, x_size,y_size, dest_x,dest_y); SetDrawtoField(DRAW_DIRECT); } + + MarkTileDirty(sx,sy); } static int getGraphicAnimationPhase(int frames, int delay, int mode) @@ -648,11 +620,17 @@ void DrawGraphicThruMask(int x, int y, int graphic) MarkTileDirty(x,y); } -void DrawElementThruMask(int x, int y, int element) +void DrawScreenElementThruMask(int x, int y, int element) { DrawGraphicThruMask(x,y,el2gfx(element)); } +void DrawLevelElementThruMask(int x, int y, int element) +{ + if (IN_LEV_FIELD(x,y) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y))) + DrawScreenElementThruMask(SCROLLX(x),SCROLLY(y),element); +} + void DrawMiniGraphic(int x, int y, int graphic) { DrawMiniGraphicExt(drawto, gc, x, y, graphic); @@ -687,10 +665,12 @@ void DrawMiniGraphicExtHiRes(Drawable d, GC gc, int x, int y, int graphic) XFillRectangle(display,d,gc, x,y, MINI_TILEX,MINI_TILEY); } -void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, int cut_mode) +void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, + int cut_mode, int mask_mode) { int width = TILEX, height = TILEY; int cx = 0, cy = 0; + int src_x,src_y, dest_x,dest_y; if (graphic < 0) { @@ -765,18 +745,38 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, int cut_mode) if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN) { graphic -= GFX_START_ROCKSSCREEN; - XCopyArea(display,pix[PIX_BACK],drawto_field,gc, - SX+(graphic % GFX_PER_LINE)*TILEX+cx, - SY+(graphic / GFX_PER_LINE)*TILEY+cy, - width,height, FX+x*TILEX+dx,FY+y*TILEY+dy); + src_x = SX+(graphic % GFX_PER_LINE)*TILEX+cx; + src_y = SY+(graphic / GFX_PER_LINE)*TILEY+cy; + dest_x = FX+x*TILEX+dx; + dest_y = FY+y*TILEY+dy; + + if (mask_mode == USE_MASKING) + { + XSetClipOrigin(display,clip_gc[PIX_BACK],dest_x-src_x,dest_y-src_y); + XCopyArea(display,pix[PIX_BACK],drawto_field,clip_gc[PIX_BACK], + src_x,src_y, width,height, dest_x,dest_y); + } + else + XCopyArea(display,pix[PIX_BACK],drawto_field,gc, + src_x,src_y, width,height, dest_x,dest_y); } else if (graphic >= GFX_START_ROCKSHEROES && graphic <= GFX_END_ROCKSHEROES) { graphic -= GFX_START_ROCKSHEROES; - XCopyArea(display,pix[PIX_HEROES],drawto_field,gc, - (graphic % HEROES_PER_LINE)*TILEX+cx, - (graphic / HEROES_PER_LINE)*TILEY+cy, - width,height, FX+x*TILEX+dx,FY+y*TILEY+dy); + src_x = (graphic % HEROES_PER_LINE)*TILEX+cx; + src_y = (graphic / HEROES_PER_LINE)*TILEY+cy; + dest_x = FX+x*TILEX+dx; + dest_y = FY+y*TILEY+dy; + + if (mask_mode == USE_MASKING) + { + XSetClipOrigin(display,clip_gc[PIX_HEROES],dest_x-src_x,dest_y-src_y); + XCopyArea(display,pix[PIX_HEROES],drawto_field,clip_gc[PIX_HEROES], + src_x,src_y, width,height, dest_x,dest_y); + } + else + XCopyArea(display,pix[PIX_HEROES],drawto_field,gc, + src_x,src_y, width,height, dest_x,dest_y); } #if DEBUG @@ -791,7 +791,14 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, int cut_mode) MarkTileDirty(x,y); } -void DrawElementShifted(int x, int y, int dx, int dy, int element,int cut_mode) +void DrawGraphicShiftedThruMask(int x,int y, int dx,int dy, int graphic, + int cut_mode) +{ + DrawGraphicShifted(x,y, dx,dy, graphic, cut_mode, USE_MASKING); +} + +void DrawScreenElementShifted(int x, int y, int dx, int dy, int element, + int cut_mode) { int ux = UNSCROLLX(x), uy = UNSCROLLY(y); int graphic = el2gfx(element); @@ -872,124 +879,16 @@ void DrawElementShifted(int x, int y, int dx, int dy, int element,int cut_mode) } if (dx || dy) - DrawGraphicShifted(x,y, dx,dy, graphic, cut_mode); + DrawGraphicShifted(x,y, dx,dy, graphic, cut_mode, NO_MASKING); else DrawGraphic(x,y, graphic); } -void DrawGraphicShiftedThruMask(int x,int y, int dx,int dy, int graphic, - int cut_mode) +void DrawLevelElementShifted(int x, int y, int dx, int dy, int element, + int cut_mode) { - int width = TILEX, height = TILEY; - int cx = 0, cy = 0; - int src_x,src_y, dest_x,dest_y; - - if (graphic < 0) - { - DrawGraphic(x,y,graphic); - return; - } - - if (dx || dy) /* Verschiebung der Grafik? */ - { - if (x < BX1) /* Element kommt von links ins Bild */ - { - x = BX1; - width = dx; - cx = TILEX - dx; - dx = 0; - } - else if (x > BX2) /* Element kommt von rechts ins Bild */ - { - x = BX2; - width = -dx; - dx = TILEX + dx; - } - else if (x==BX1 && dx<0) /* Element verläßt links das Bild */ - { - width += dx; - cx = -dx; - dx = 0; - } - else if (x==BX2 && dx>0) /* Element verläßt rechts das Bild */ - width -= dx; - else if (dx) /* allg. Bewegung in x-Richtung */ - MarkTileDirty(x + SIGN(dx), y); - - if (y < BY1) /* Element kommt von oben ins Bild */ - { - if (cut_mode==CUT_BELOW) /* Element oberhalb des Bildes */ - return; - - y = BY1; - height = dy; - cy = TILEY - dy; - dy = 0; - } - else if (y > BY2) /* Element kommt von unten ins Bild */ - { - y = BY2; - height = -dy; - dy = TILEY + dy; - } - else if (y==BY1 && dy<0) /* Element verläßt oben das Bild */ - { - height += dy; - cy = -dy; - dy = 0; - } - else if (dy > 0 && cut_mode==CUT_ABOVE) - { - if (y == BY2) /* Element unterhalb des Bildes */ - return; - - height = dy; - cy = TILEY-dy; - dy = TILEY; - MarkTileDirty(x, y + 1); - } /* Element verläßt unten das Bild */ - else if (dy > 0 && (y == BY2 || cut_mode==CUT_BELOW)) - height -= dy; - else if (dy) /* allg. Bewegung in y-Richtung */ - MarkTileDirty(x, y + SIGN(dy)); - } - - if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN) - { - graphic -= GFX_START_ROCKSSCREEN; - src_x = SX+(graphic % GFX_PER_LINE)*TILEX+cx; - src_y = SY+(graphic / GFX_PER_LINE)*TILEY+cy; - dest_x = FX+x*TILEX+dx; - dest_y = FY+y*TILEY+dy; - - XSetClipOrigin(display,clip_gc[PIX_BACK],dest_x-src_x,dest_y-src_y); - XCopyArea(display,pix[PIX_BACK],drawto_field,clip_gc[PIX_BACK], - src_x,src_y, width,height, dest_x,dest_y); - } - else if (graphic >= GFX_START_ROCKSHEROES && graphic <= GFX_END_ROCKSHEROES) - { - graphic -= GFX_START_ROCKSHEROES; - src_x = (graphic % HEROES_PER_LINE)*TILEX+cx; - src_y = (graphic / HEROES_PER_LINE)*TILEY+cy; - dest_x = FX+x*TILEX+dx; - dest_y = FY+y*TILEY+dy; - - XSetClipOrigin(display,clip_gc[PIX_HEROES],dest_x-src_x,dest_y-src_y); - XCopyArea(display,pix[PIX_HEROES],drawto_field,clip_gc[PIX_HEROES], - src_x,src_y, width,height, dest_x,dest_y); - } - -#if DEBUG - if (!IN_SCR_FIELD(x,y)) - { - printf("DrawGraphicShiftedThruMask(): x = %d, y = %d, graphic = %d\n", - x,y,graphic); - printf("DrawGraphicShifted(): This should never happen!\n"); - return; - } -#endif - - MarkTileDirty(x,y); + if (IN_LEV_FIELD(x,y) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y))) + DrawScreenElementShifted(SCROLLX(x),SCROLLY(y), dx,dy, element, cut_mode); } void ErdreichAnbroeckeln(int x, int y) @@ -1029,10 +928,6 @@ void ErdreichAnbroeckeln(int x, int y) else element = Feld[uxx][uyy]; -/* - if (element==EL_ERDREICH || IS_SOLID(element)) - continue; -*/ if (element==EL_ERDREICH) continue; @@ -1071,11 +966,6 @@ void ErdreichAnbroeckeln(int x, int y) yy = y+xy[i][1]; uxx = ux+xy[i][0]; uyy = uy+xy[i][1]; -/* - if (!IN_LEV_FIELD(uxx,uyy) || Feld[uxx][uyy]!=EL_ERDREICH || - !IN_SCR_FIELD(xx,yy) || IS_SOLID(element)) - continue; -*/ if (!IN_LEV_FIELD(uxx,uyy) || Feld[uxx][uyy]!=EL_ERDREICH || !IN_SCR_FIELD(xx,yy)) @@ -1108,7 +998,7 @@ void ErdreichAnbroeckeln(int x, int y) void DrawScreenElement(int x, int y, int element) { - DrawElementShifted(x,y,0,0,element,CUT_NO_CUTTING); + DrawScreenElementShifted(x,y, 0,0, element, NO_CUTTING); ErdreichAnbroeckeln(x,y); } @@ -1134,7 +1024,7 @@ void DrawScreenField(int x, int y) if (IS_MOVING(ux,uy)) { int horiz_move = (MovDir[ux][uy]==MV_LEFT || MovDir[ux][uy]==MV_RIGHT); - BOOL cut_mode = CUT_NO_CUTTING; + BOOL cut_mode = NO_CUTTING; if (Store[ux][uy]==EL_MORAST_LEER || Store[ux][uy]==EL_SIEB_LEER || @@ -1148,21 +1038,21 @@ void DrawScreenField(int x, int y) cut_mode = CUT_BELOW; if (cut_mode==CUT_ABOVE) - DrawElementShifted(x,y,0,0,Store[ux][uy],CUT_NO_CUTTING); + DrawScreenElementShifted(x,y, 0,0, Store[ux][uy], NO_CUTTING); else DrawScreenElement(x,y,EL_LEERRAUM); if (horiz_move) - DrawElementShifted(x,y,MovPos[ux][uy],0,element,CUT_NO_CUTTING); + DrawScreenElementShifted(x,y, MovPos[ux][uy],0, element, NO_CUTTING); else - DrawElementShifted(x,y,0,MovPos[ux][uy],element,cut_mode); + DrawScreenElementShifted(x,y, 0,MovPos[ux][uy], element, cut_mode); } else if (IS_BLOCKED(ux,uy)) { int oldx,oldy; int sx, sy; int horiz_move; - BOOL cut_mode = CUT_NO_CUTTING; + BOOL cut_mode = NO_CUTTING; Blocked2Moving(ux,uy,&oldx,&oldy); sx = SCROLLX(oldx); @@ -1179,9 +1069,9 @@ void DrawScreenField(int x, int y) element = Feld[oldx][oldy]; if (horiz_move) - DrawElementShifted(sx,sy,MovPos[oldx][oldy],0,element,CUT_NO_CUTTING); + DrawScreenElementShifted(sx,sy, MovPos[oldx][oldy],0,element,NO_CUTTING); else - DrawElementShifted(sx,sy,0,MovPos[oldx][oldy],element,cut_mode); + DrawScreenElementShifted(sx,sy, 0,MovPos[oldx][oldy],element,cut_mode); } else if (IS_DRAWABLE(element)) DrawScreenElement(x,y,element); @@ -1666,7 +1556,7 @@ unsigned int MoveDoor(unsigned int door_state) BackToFront(); - if (game_status==MAINMENU) + if (game_status == MAINMENU) DoAnimation(); } } diff --git a/src/tools.h b/src/tools.h index 2d31f211..459011a1 100644 --- a/src/tools.h +++ b/src/tools.h @@ -19,19 +19,23 @@ #include -/* für SetDrawtoField */ +/* for SetDrawtoField */ #define DRAW_DIRECT 0 #define DRAW_BUFFERED 1 #define DRAW_BACKBUFFER 2 -/* für DrawElementShifted */ -#define CUT_NO_CUTTING 0 +/* for DrawElementShifted */ +#define NO_CUTTING 0 #define CUT_ABOVE 1 #define CUT_BELOW 2 #define CUT_LEFT 4 #define CUT_RIGHT 8 -/* für MoveDoor */ +/* for masking functions */ +#define NO_MASKING 0 +#define USE_MASKING 1 + +/* for MoveDoor */ #define DOOR_OPEN_1 1 #define DOOR_OPEN_2 2 #define DOOR_CLOSE_1 4 @@ -45,7 +49,7 @@ #define DOOR_NO_DELAY 32 #define DOOR_GET_STATE 64 -/* für AreYouSure */ +/* for AreYouSure */ #define AYS_ASK 1 #define AYS_OPEN 2 #define AYS_CLOSE 4 @@ -65,13 +69,15 @@ void DrawGraphic(int, int, int); void DrawGraphicExt(Drawable, GC, int, int, int); void DrawGraphicExtHiRes(Drawable, GC, int, int, int); void DrawGraphicThruMask(int, int, int); -void DrawElementThruMask(int, int, int); +void DrawScreenElementThruMask(int, int, int); +void DrawLevelElementThruMask(int, int, int); void DrawMiniGraphic(int, int, int); void DrawMiniGraphicExt(Drawable, GC, int, int, int); void DrawMiniGraphicExtHiRes(Drawable, GC, int, int, int); -void DrawGraphicShifted(int, int, int, int, int, int); -void DrawElementShifted(int, int, int, int, int, int); +void DrawGraphicShifted(int, int, int, int, int, int, int); void DrawGraphicShiftedThruMask(int, int, int, int, int, int); +void DrawScreenElementShifted(int, int, int, int, int, int); +void DrawLevelElementShifted(int, int, int, int, int, int); void ErdreichAnbroeckeln(int, int); void DrawScreenElement(int, int, int); void DrawLevelElement(int, int, int);