From: Holger Schemel Date: Wed, 23 Jun 2010 00:15:37 +0000 (+0200) Subject: rnd-20100623-1-src X-Git-Tag: 3.3.1.0^2~23 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=97baecdfcf386d972f6f8e6eec9ddfd3021ed7ed;p=rocksndiamonds.git rnd-20100623-1-src * added graphics performance optimization to native Supaplex game engine --- diff --git a/ChangeLog b/ChangeLog index 6acb9f33..98b0c92b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2010-06-23 + * added graphics performance optimization to native Supaplex game engine + 2010-06-18 * added separately configurable game panel background to graphics config * fixed displaying Supaplex time (now based on 35 fps instead of 50 fps) diff --git a/src/conftime.h b/src/conftime.h index c2d1ae25..68918680 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-06-19 00:55" +#define COMPILE_DATE_STRING "2010-06-23 02:10" diff --git a/src/game_sp/DDScrollBuffer.c b/src/game_sp/DDScrollBuffer.c index e8bd2fbc..263f31f6 100644 --- a/src/game_sp/DDScrollBuffer.c +++ b/src/game_sp/DDScrollBuffer.c @@ -59,9 +59,15 @@ static void ScrollPlayfield(int dx, int dy) TILEY * (dy == 1)); /* when scrolling the whole playfield, do not redraw single tiles */ +#if 1 + for (x = 0; x < 2 + MAX_PLAYFIELD_WIDTH + 2; x++) + for (y = 0; y < 2 + MAX_PLAYFIELD_HEIGHT + 2; y++) + redraw[x][y] = FALSE; +#else for (x = 0; x < MAX_BUF_XSIZE; x++) for (y = 0; y < MAX_BUF_YSIZE; y++) redraw[x][y] = FALSE; +#endif redraw_tiles = 0; DrawFrameIfNeeded(); @@ -145,10 +151,13 @@ void InitScrollPlayfield() ScrollPlayfieldIfNeededExt(TRUE); } +#define DEBUG_REDRAW 0 + void UpdatePlayfield(boolean force_redraw) { int x, y; -#if 1 + +#if DEBUG_REDRAW int num_redrawn = 0; #endif @@ -161,8 +170,10 @@ void UpdatePlayfield(boolean force_redraw) int sync_frame = GfxFrame[x][y]; boolean redraw = force_redraw; +#if DEBUG_REDRAW #if 0 redraw = TRUE; // !!! TEST ONLY -- ALWAYS REDRAW !!! +#endif #endif if (graphic < 0) @@ -201,20 +212,22 @@ void UpdatePlayfield(boolean force_redraw) int sx = x * StretchWidth; int sy = y * StretchWidth; +#if DEBUG_REDRAW #if 0 printf("::: REDRAW (%d, %d): %d, %d\n", x, y, graphic, sync_frame); +#endif #endif DDSpriteBuffer_BltImg(sx, sy, graphic, sync_frame); -#if 1 +#if DEBUG_REDRAW num_redrawn++; #endif } } } -#if 0 +#if DEBUG_REDRAW printf("::: FRAME %d: %d redrawn\n", FrameCounter, num_redrawn); #endif } @@ -263,44 +276,79 @@ void BlitScreenToBitmap_SP(Bitmap *target_bitmap) void BackToFront_SP(void) { + static int scroll_x_last = -1, scroll_y_last = -1; static boolean scrolling_last = FALSE; - int left = mScrollX / TILEX; - int top = mScrollY / TILEY; + static boolean ExplosionShakeMurphy_last = -1; +#if 1 + boolean scrolling = (mScrollX != scroll_x_last || mScrollY != scroll_y_last); + // boolean scrolling = (mScrollX != mScrollX_last || mScrollY != mScrollY_last); +#else boolean scrolling = (mScrollX % TILEX != 0 || mScrollY % TILEY != 0); +#endif int x, y; +#if 0 + printf("::: %d, %d / %d, %d [%d, %d]\n", + mScrollX, mScrollY, + mScrollX_last, mScrollY_last, + game_sp.scroll_xoffset, game_sp.scroll_yoffset); +#endif + SyncDisplay(); - if (1 || - redraw_tiles > REDRAWTILES_THRESHOLD || scrolling || scrolling_last) + if (redraw_tiles > REDRAWTILES_THRESHOLD || scrolling || scrolling_last || + ExplosionShakeMurphy != 0 || ExplosionShakeMurphy_last != 0) { BlitScreenToBitmap_SP(window); } else { - for (x = 0; x < SCR_FIELDX; x++) + int scroll_xoffset = mScrollX - mScrollX_last + game_sp.scroll_xoffset; + int scroll_yoffset = mScrollY - mScrollY_last + game_sp.scroll_yoffset; + int x1 = 0, x2 = SCR_FIELDX - (scroll_xoffset != 0 ? 0 : 1); + int y1 = 0, y2 = SCR_FIELDY - (scroll_yoffset != 0 ? 0 : 1); + int full_xsize = (FieldWidth - (menBorder ? 0 : 1)) * TILEX; + int full_ysize = (FieldHeight - (menBorder ? 0 : 1)) * TILEY; + int sx = SX + (full_xsize < SXSIZE ? (SXSIZE - full_xsize) / 2 : 0); + int sy = SY + (full_ysize < SYSIZE ? (SYSIZE - full_ysize) / 2 : 0); + + InitGfxClipRegion(TRUE, SX, SY, SXSIZE, SYSIZE); + + for (x = x1; x <= x2; x++) { - for (y = 0; y < SCR_FIELDY; y++) + for (y = y1; y <= y2; y++) { - int xx = (left + x) % MAX_BUF_XSIZE; - int yy = (top + y) % MAX_BUF_YSIZE; + int xx = 2 + x; + int yy = 2 + y; if (redraw[xx][yy]) BlitBitmap(bitmap_db_field_sp, window, xx * TILEX, yy * TILEY, TILEX, TILEY, - SX + x * TILEX, SY + y * TILEY); + sx + x * TILEX - scroll_xoffset, + sy + y * TILEY - scroll_yoffset); } } + + InitGfxClipRegion(FALSE, -1, -1, -1, -1); } FlushDisplay(); +#if 1 + for (x = 0; x < 2 + MAX_PLAYFIELD_WIDTH + 2; x++) + for (y = 0; y < 2 + MAX_PLAYFIELD_HEIGHT + 2; y++) + redraw[x][y] = FALSE; +#else for (x = 0; x < MAX_BUF_XSIZE; x++) for (y = 0; y < MAX_BUF_YSIZE; y++) redraw[x][y] = FALSE; +#endif redraw_tiles = 0; + scroll_x_last = mScrollX; + scroll_y_last = mScrollY; scrolling_last = scrolling; + ExplosionShakeMurphy_last = ExplosionShakeMurphy; } void DDScrollBuffer_ScrollTo(int X, int Y) diff --git a/src/game_sp/DDSpriteBuffer.c b/src/game_sp/DDSpriteBuffer.c index 4683d319..9377eac3 100644 --- a/src/game_sp/DDSpriteBuffer.c +++ b/src/game_sp/DDSpriteBuffer.c @@ -13,9 +13,12 @@ static void Blt(int pX, int pY, Bitmap *bitmap, int SpriteX, int SpriteY) int sy1 = scy - 2 * TILEY; int sx2 = scx + SXSIZE + 1 * TILEX; int sy2 = scy + SYSIZE + 1 * TILEY; - int sx = pX - sx1; int sy = pY - sy1; + int tile_x = sx / TILESIZE; + int tile_y = sy / TILESIZE; + int move_x = (sx + TILESIZE - 1) / TILESIZE; + int move_y = (sy + TILESIZE - 1) / TILESIZE; if (NoDisplayFlag) return; @@ -26,6 +29,20 @@ static void Blt(int pX, int pY, Bitmap *bitmap, int SpriteX, int SpriteY) BlitBitmap(bitmap, bitmap_db_field_sp, SpriteX, SpriteY, TILEX, TILEY, sx, sy); + + redraw[tile_x][tile_y] = TRUE; + redraw_tiles++; + + if (move_x != tile_x) + { + redraw[move_x][tile_y] = TRUE; + redraw_tiles++; + } + else if (move_y != tile_y) + { + redraw[tile_x][move_y] = TRUE; + redraw_tiles++; + } } void DDSpriteBuffer_BltImg(int pX, int pY, int graphic, int sync_frame) diff --git a/src/game_sp/main.c b/src/game_sp/main.c index 818d4e36..4fe06feb 100644 --- a/src/game_sp/main.c +++ b/src/game_sp/main.c @@ -67,7 +67,8 @@ void RedrawPlayfield_SP(boolean force_redraw) void DrawGameDoorValues_SP() { #if 1 - game_sp.time_played = TimerVar / FRAMES_PER_SECOND_SP; + // game_sp.time_played = TimerVar / FRAMES_PER_SECOND_SP; + game_sp.time_played = TimerVar / FRAMES_PER_SECOND; #else game_sp.time_played = TimerVar * setup.game_frame_delay / 1000; #endif diff --git a/src/init.c b/src/init.c index 5fe252ff..f074cd94 100644 --- a/src/init.c +++ b/src/init.c @@ -5123,6 +5123,8 @@ static void InitGlobal() global.fading_status = GAME_MODE_MAIN; global.fading_type = TYPE_ENTER_MENU; #endif + + global.use_envelope_request = FALSE; /* !!! MOVE TO ARTWORK CONFIG !!! */ } void Execute_Command(char *command) @@ -6304,11 +6306,18 @@ void OpenAll() InitSetup(); + print_timestamp_time("[init setup/config stuff (1)]"); + InitGameInfo(); + print_timestamp_time("[init setup/config stuff (2)]"); InitPlayerInfo(); + print_timestamp_time("[init setup/config stuff (3)]"); InitArtworkInfo(); /* needed before loading gfx, sound & music */ + print_timestamp_time("[init setup/config stuff (4)]"); InitArtworkConfig(); /* needed before forking sound child process */ + print_timestamp_time("[init setup/config stuff (5)]"); InitMixer(); + print_timestamp_time("[init setup/config stuff (6)]"); #if 0 InitCounter(); diff --git a/src/libgame/system.c b/src/libgame/system.c index c2e9a300..dce2b888 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -736,6 +736,12 @@ void BlitBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap, #endif #endif +#if 0 + if (dst_x < gfx.sx + gfx.sxsize) + printf("::: %d: BlitBitmap(%d, %d, %d, %d)\n", + FrameCounter, dst_x, dst_y, width, height); +#endif + sysCopyArea(src_bitmap, dst_bitmap, src_x, src_y, width, height, dst_x, dst_y, BLIT_OPAQUE); } diff --git a/src/main.h b/src/main.h index b37e21c5..e5631b49 100644 --- a/src/main.h +++ b/src/main.h @@ -2466,6 +2466,8 @@ struct GlobalInfo int fading_status; int fading_type; #endif + + boolean use_envelope_request; }; struct ElementChangeInfo diff --git a/src/tools.c b/src/tools.c index bc9e6df3..326af5f9 100644 --- a/src/tools.c +++ b/src/tools.c @@ -251,6 +251,11 @@ void DrawMaskedBorder(int redraw_mask) effectiveGameStatus() == GAME_MODE_TITLE) return; + /* never draw masked screen borders when displaying request outside door */ + if (effectiveGameStatus() == GAME_MODE_PSEUDO_DOOR && + global.use_envelope_request) + return; + if (redraw_mask & REDRAW_ALL) DrawMaskedBorder_ALL(); else @@ -332,7 +337,7 @@ void BackToFront() SyncDisplay(); - /* prevent drawing masked border to backbuffer when using playfield buffer */ + /* never draw masked border to backbuffer when using playfield buffer */ if (game_status != GAME_MODE_PLAYING || redraw_mask & REDRAW_FROM_BACKBUFFER || buffer == backbuffer) @@ -2431,7 +2436,7 @@ void ShowEnvelopeDoor(char *text, int action) game.envelope_active = FALSE; #if 1 - game_status = last_game_status; /* restore current game status */ + // game_status = last_game_status; /* restore current game status */ if (action == ACTION_CLOSING) { @@ -2459,6 +2464,9 @@ void ShowEnvelopeDoor(char *text, int action) BackToFront(); + /* (important: after "BackToFront()", but before "SetDrawtoField()") */ + game_status = last_game_status; /* restore current game status */ + if (game_status == GAME_MODE_PLAYING && level.game_engine_type == GAME_ENGINE_TYPE_RND) SetDrawtoField(DRAW_BUFFERED); @@ -3392,13 +3400,14 @@ boolean Request(char *text, unsigned int req_state) int last_game_status = game_status; /* save current game status */ int max_request_line_len = MAX_REQUEST_LINE_FONT1_LEN; int font_nr = FONT_TEXT_2; - boolean use_envelope_request = TRUE * 0; #if 0 int max_word_len = 0; #endif char *text_ptr; int i; + global.use_envelope_request = TRUE * 1; + #if 1 if (maxWordLengthInString(text) > MAX_REQUEST_LINE_FONT1_LEN) { @@ -3454,13 +3463,21 @@ boolean Request(char *text, unsigned int req_state) UnmapAllGadgets(); -#if 1 - if (old_door_state & DOOR_OPEN_1 && !use_envelope_request) + /* draw released gadget before proceeding */ + // BackToFront(); + +#if 0 + if (old_door_state & DOOR_OPEN_1 && !global.use_envelope_request) #else if (old_door_state & DOOR_OPEN_1) #endif { +#if 1 + if (!global.use_envelope_request) + CloseDoor(DOOR_CLOSE_1); +#else CloseDoor(DOOR_CLOSE_1); +#endif /* save old door content */ BlitBitmap(bitmap_db_door, bitmap_db_door, @@ -3516,7 +3533,7 @@ boolean Request(char *text, unsigned int req_state) game_status = last_game_status; /* restore current game status */ #if 1 - if (use_envelope_request) + if (global.use_envelope_request) { /* !!! TMP !!! */ FreeToolButtons(); @@ -3547,7 +3564,7 @@ boolean Request(char *text, unsigned int req_state) DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1); #if 1 - if (use_envelope_request) + if (global.use_envelope_request) { ShowEnvelopeDoor(text, ACTION_OPENING); @@ -3571,7 +3588,7 @@ boolean Request(char *text, unsigned int req_state) #endif #if 1 - if (!use_envelope_request) + if (!global.use_envelope_request) OpenDoor(DOOR_OPEN_1); #else OpenDoor(DOOR_OPEN_1); @@ -3593,7 +3610,7 @@ boolean Request(char *text, unsigned int req_state) } #if 1 - if (game_status != GAME_MODE_MAIN && !use_envelope_request) + if (game_status != GAME_MODE_MAIN && !global.use_envelope_request) InitAnimation(); #else if (game_status != GAME_MODE_MAIN) @@ -3735,8 +3752,16 @@ boolean Request(char *text, unsigned int req_state) Delay(10); } +#if 1 + game_status = GAME_MODE_PSEUDO_DOOR; +#endif + BackToFront(); +#if 1 + game_status = last_game_status; /* restore current game status */ +#endif + #else DoAnimation(); @@ -3758,12 +3783,12 @@ boolean Request(char *text, unsigned int req_state) UnmapToolButtons(); #if 1 - if (use_envelope_request) + if (global.use_envelope_request) ShowEnvelopeDoor(text, ACTION_CLOSING); #endif #if 1 - if (!(req_state & REQ_STAY_OPEN) && !use_envelope_request) + if (!(req_state & REQ_STAY_OPEN) && !global.use_envelope_request) #else if (!(req_state & REQ_STAY_OPEN)) #endif