+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)
-#define COMPILE_DATE_STRING "2010-06-19 00:55"
+#define COMPILE_DATE_STRING "2010-06-23 02:10"
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();
ScrollPlayfieldIfNeededExt(TRUE);
}
+#define DEBUG_REDRAW 0
+
void UpdatePlayfield(boolean force_redraw)
{
int x, y;
-#if 1
+
+#if DEBUG_REDRAW
int num_redrawn = 0;
#endif
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)
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
}
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)
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;
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)
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
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)
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();
#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);
}
int fading_status;
int fading_type;
#endif
+
+ boolean use_envelope_request;
};
struct ElementChangeInfo
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
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)
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)
{
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);
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)
{
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,
game_status = last_game_status; /* restore current game status */
#if 1
- if (use_envelope_request)
+ if (global.use_envelope_request)
{
/* !!! TMP !!! */
FreeToolButtons();
DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
#if 1
- if (use_envelope_request)
+ if (global.use_envelope_request)
{
ShowEnvelopeDoor(text, ACTION_OPENING);
#endif
#if 1
- if (!use_envelope_request)
+ if (!global.use_envelope_request)
OpenDoor(DOOR_OPEN_1);
#else
OpenDoor(DOOR_OPEN_1);
}
#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)
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();
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