+2010-04-02
+ * added initial, experimental support for different screen sizes
+
2010-03-27
* added support for native Sokoban solution files in pure 'udlrUDLR'
format with extension ".sln" instead of ".tape" for solution tapes
static walls, not for in-game dynamically changing walls using CEs.)
2010-03-16
- * continued code cleanup of native Supaplex game engine
-
-2010-03-15
- * continued code cleanup of native Supaplex game engine
+ * finished code cleanup of native Supaplex game engine
2010-03-14
* started code cleanup of native Supaplex game engine
{ "[player].sleeping_delay_fixed", "2000" },
{ "[player].sleeping_delay_random", "2000" },
+ { "global.screen.width", "672" },
+ { "global.screen.height", "560" },
+
{ NULL, NULL }
};
"[player].sleeping_delay_random",
&game.player_sleeping_delay_random
},
+ {
+ "global.screen.width",
+ &global.screen.width
+ },
+ {
+ "global.screen.height",
+ &global.screen.height
+ },
{
NULL,
NULL
-#define COMPILE_DATE_STRING "2010-03-31 10:44"
+#define COMPILE_DATE_STRING "2010-04-02 22:02"
ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
SX + ED_SCROLL_HORIZONTAL_XPOS, SY + ED_SCROLL_HORIZONTAL_YPOS,
ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE,
-#if 1
SX, SY,
SXSIZE, SYSIZE,
-#else
- 0, 0,
- SX + SXSIZE + SX, WIN_YSIZE,
-#endif
GD_TYPE_SCROLLBAR_HORIZONTAL,
GADGET_ID_SCROLL_HORIZONTAL,
"scroll level editing area horizontally"
ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
SX + ED_SCROLL_VERTICAL_XPOS, SY + ED_SCROLL_VERTICAL_YPOS,
ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE,
-#if 1
SX, SY,
SXSIZE, SYSIZE,
-#else
- 0, 0,
- SX + SXSIZE + SX, WIN_YSIZE,
-#endif
GD_TYPE_SCROLLBAR_VERTICAL,
GADGET_ID_SCROLL_VERTICAL,
"scroll level editing area vertically"
ED_SCROLLBAR2_XPOS, ED_SCROLLBAR2_YPOS,
DX + ED_SCROLL2_VERTICAL_XPOS, DY + ED_SCROLL2_VERTICAL_YPOS,
ED_SCROLL2_VERTICAL_XSIZE, ED_SCROLL2_VERTICAL_YSIZE,
-#if 1
DX, DY,
DXSIZE, DYSIZE,
-#else
- SX + SXSIZE + SX, 0,
- WIN_XSIZE - (SX + SXSIZE + SX), WIN_YSIZE,
-#endif
GD_TYPE_SCROLLBAR_VERTICAL,
GADGET_ID_SCROLL_LIST_VERTICAL,
"scroll element list vertically"
static void ScrollMiniLevel(int from_x, int from_y, int scroll)
{
-#if 0
- /* (directly solved in BlitBitmap() now) */
- static Bitmap *tmp_backbuffer = NULL;
-#endif
int x, y;
int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
-#if 0
- /* (directly solved in BlitBitmap() now) */
- if (tmp_backbuffer == NULL)
- tmp_backbuffer = CreateBitmap(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH);
-
- /* needed when blitting directly to same bitmap -- should not be needed with
- recent SDL libraries, but apparently does not work in 1.2.11 directly */
- BlitBitmap(drawto, tmp_backbuffer,
- SX + (dx == -1 ? MINI_TILEX : 0),
- SY + (dy == -1 ? MINI_TILEY : 0),
- (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0),
- (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
- SX + (dx == +1 ? MINI_TILEX : 0),
- SY + (dy == +1 ? MINI_TILEY : 0));
- BlitBitmap(tmp_backbuffer, drawto,
- SX + (dx == +1 ? MINI_TILEX : 0),
- SY + (dy == +1 ? MINI_TILEY : 0),
- (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0),
- (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
- SX + (dx == +1 ? MINI_TILEX : 0),
- SY + (dy == +1 ? MINI_TILEY : 0));
-
-#else
-
BlitBitmap(drawto, drawto,
SX + (dx == -1 ? MINI_TILEX : 0),
SY + (dy == -1 ? MINI_TILEY : 0),
(ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
SX + (dx == +1 ? MINI_TILEX : 0),
SY + (dy == +1 ? MINI_TILEY : 0));
-#endif
if (dx)
{
#define CONFIG_TOKEN_GLOBAL_BUSY "global.busy"
#define DEBUG_PRINT_INIT_TIMESTAMPS TRUE
-#define DEBUG_PRINT_INIT_TIMESTAMPS_DEPTH 10
+#define DEBUG_PRINT_INIT_TIMESTAMPS_DEPTH 1
static struct FontBitmapInfo font_initial[NUM_INITIAL_FONTS];
}
#endif
-#if 0
- anim_initial.anim_mode = ANIM_LOOP;
- anim_initial.anim_start_frame = 0;
- anim_initial.offset_x = anim_initial.width;
- anim_initial.offset_y = 0;
-#endif
-
-#if 1
- x = ALIGNED_TEXT_XPOS(&init.busy);
- y = ALIGNED_TEXT_YPOS(&init.busy);
-#else
- x = WIN_XSIZE / 2 - TILESIZE / 2;
- y = WIN_YSIZE / 2 - TILESIZE / 2;
-#endif
+ x = ALIGNED_TEXT_XPOS(&init_last.busy);
+ y = ALIGNED_TEXT_YPOS(&init_last.busy);
graphic_info = &anim_initial; /* graphic == 0 => anim_initial */
StartMixer();
}
+void InitGfxBuffers()
+{
+ ReCreateBitmap(&bitmap_db_cross, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH);
+ ReCreateBitmap(&bitmap_db_field, FXSIZE, FYSIZE, DEFAULT_DEPTH);
+ ReCreateBitmap(&bitmap_db_panel, DXSIZE, DYSIZE, DEFAULT_DEPTH);
+ ReCreateBitmap(&bitmap_db_door, 3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
+ ReCreateBitmap(&bitmap_db_toons, FULL_SXSIZE, FULL_SYSIZE, DEFAULT_DEPTH);
+
+ /* initialize screen properties */
+ InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
+ REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE,
+ bitmap_db_field);
+ InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
+ InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
+ InitGfxWindowInfo(WIN_XSIZE, WIN_YSIZE);
+ InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
+}
+
void InitGfx()
{
struct GraphicInfo *graphic_info_last = graphic_info;
if (filename_font_initial == NULL) /* should not happen */
Error(ERR_EXIT, "cannot get filename for '%s'", CONFIG_TOKEN_FONT_INITIAL);
+#if 1
+ InitGfxBuffers();
+#else
/* create additional image buffers for double-buffering and cross-fading */
bitmap_db_cross = CreateBitmap(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH);
bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
InitGfxWindowInfo(WIN_XSIZE, WIN_YSIZE);
InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
+#endif
+
InitGfxCustomArtworkInfo();
bitmap_font_initial = LoadCustomImage(filename_font_initial);
InitMenuDesignSettings_Static();
InitGfxDrawBusyAnimFunction(DrawInitAnim);
+
+ /* use copy of busy animation to prevent change while reloading artwork */
+ init_last = init;
#endif
}
game_status = last_game_status; /* restore current game status */
+ init_last = init; /* switch to new busy animation */
+
#if 0
printf("::: ----------------DELAY 1 ...\n");
Delay(3000);
void KeyboardAutoRepeatOffUnlessAutoplay();
+void InitGfxBuffers();
+
void OpenAll(void);
void CloseAllAndExit(int);
fullscreen_xoffset = (fullscreen_width - video.width) / 2;
fullscreen_yoffset = (fullscreen_height - video.height) / 2;
+#if 1
+ checked_free(video.fullscreen_modes);
+
+ video.fullscreen_modes = NULL;
+ video.fullscreen_mode_current = NULL;
+#endif
+
/* get available hardware supported fullscreen modes */
modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE);
should never be drawn to directly, it would do no harm nevertheless. */
/* create additional (symbolic) buffer for double-buffering */
+#if 1
+ ReCreateBitmap(window, video.width, video.height, video.depth);
+#else
*window = CreateBitmap(video.width, video.height, video.depth);
+#endif
}
boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
if (*backbuffer == NULL)
*backbuffer = CreateBitmapStruct();
+ /* (real bitmap might be larger in fullscreen mode with video offsets) */
+ (*backbuffer)->width = video.width;
+ (*backbuffer)->height = video.height;
+
if (fullscreen && !video.fullscreen_enabled && video.fullscreen_available)
{
setFullscreenParameters(setup.fullscreen_mode);
(*backbuffer)->surface = new_surface;
video.fullscreen_enabled = FALSE;
+
success = TRUE;
}
}
-
#if 1
SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
int dst_x = x, dst_y = y;
unsigned int time_last, time_current;
+ /* check if screen size has changed */
+ if (surface_source != NULL && (video.width != surface_source->w ||
+ video.height != surface_source->h))
+ {
+ SDL_FreeSurface(surface_source);
+ SDL_FreeSurface(surface_target);
+ SDL_FreeSurface(surface_black);
+
+ initialization_needed = TRUE;
+ }
+
src_rect.x = src_x;
src_rect.y = src_y;
src_rect.w = width;
gfx.field_save_buffer = field_save_buffer;
+#if 0
gfx.background_bitmap = NULL;
gfx.background_bitmap_mask = REDRAW_NONE;
+#endif
SetDrawDeactivationMask(REDRAW_NONE); /* do not deactivate drawing */
SetDrawBackgroundMask(REDRAW_NONE); /* deactivate masked drawing */
{
gfx.win_xsize = win_xsize;
gfx.win_ysize = win_ysize;
+
+#if 1
+ gfx.background_bitmap_mask = REDRAW_NONE;
+
+ ReCreateBitmap(&gfx.background_bitmap, win_xsize, win_ysize, DEFAULT_DEPTH);
+#endif
}
void InitGfxScrollbufferInfo(int scrollbuffer_width, int scrollbuffer_height)
else
gfx.background_bitmap_mask &= ~mask;
+#if 0
if (gfx.background_bitmap == NULL)
gfx.background_bitmap = CreateBitmap(video.width, video.height,
DEFAULT_DEPTH);
+#endif
if (background_bitmap_tile == NULL) /* empty background requested */
return;
video.fullscreen_available = FULLSCREEN_STATUS;
video.fullscreen_enabled = FALSE;
- video.fullscreen_modes = NULL;
+#if 0
video.fullscreen_mode_current = NULL;
+ video.fullscreen_modes = NULL;
+#endif
#if defined(TARGET_SDL)
SDLInitVideoBuffer(&backbuffer, &window, fullscreen);
drawto = backbuffer;
}
-Bitmap *CreateBitmapStruct(void)
-{
-#if defined(TARGET_SDL)
- return checked_calloc(sizeof(struct SDLSurfaceInfo));
-#else
- return checked_calloc(sizeof(struct X11DrawableInfo));
-#endif
-}
-
-Bitmap *CreateBitmap(int width, int height, int depth)
-{
- Bitmap *new_bitmap = CreateBitmapStruct();
- int real_width = MAX(1, width); /* prevent zero bitmap width */
- int real_height = MAX(1, height); /* prevent zero bitmap height */
- int real_depth = GetRealDepth(depth);
-
-#if defined(TARGET_SDL)
- SDLCreateBitmapContent(new_bitmap, real_width, real_height, real_depth);
-#else
- X11CreateBitmapContent(new_bitmap, real_width, real_height, real_depth);
-#endif
-
- new_bitmap->width = real_width;
- new_bitmap->height = real_height;
-
- return new_bitmap;
-}
-
inline static void FreeBitmapPointers(Bitmap *bitmap)
{
if (bitmap == NULL)
free(bitmap);
}
-void CloseWindow(DrawWindow *window)
+Bitmap *CreateBitmapStruct(void)
{
-#if defined(TARGET_X11)
- if (window->drawable)
+#if defined(TARGET_SDL)
+ return checked_calloc(sizeof(struct SDLSurfaceInfo));
+#else
+ return checked_calloc(sizeof(struct X11DrawableInfo));
+#endif
+}
+
+Bitmap *CreateBitmap(int width, int height, int depth)
+{
+ Bitmap *new_bitmap = CreateBitmapStruct();
+ int real_width = MAX(1, width); /* prevent zero bitmap width */
+ int real_height = MAX(1, height); /* prevent zero bitmap height */
+ int real_depth = GetRealDepth(depth);
+
+#if defined(TARGET_SDL)
+ SDLCreateBitmapContent(new_bitmap, real_width, real_height, real_depth);
+#else
+ X11CreateBitmapContent(new_bitmap, real_width, real_height, real_depth);
+#endif
+
+ new_bitmap->width = real_width;
+ new_bitmap->height = real_height;
+
+ return new_bitmap;
+}
+
+void ReCreateBitmap(Bitmap **bitmap, int width, int height, int depth)
+{
+ Bitmap *new_bitmap = CreateBitmap(width, height, depth);
+
+ if (*bitmap == NULL)
{
- XUnmapWindow(display, window->drawable);
- XDestroyWindow(display, window->drawable);
+ *bitmap = new_bitmap;
}
- if (window->gc)
- XFreeGC(display, window->gc);
+ else
+ {
+ TransferBitmapPointers(new_bitmap, *bitmap);
+ free(new_bitmap);
+ }
+}
+
+void CloseWindow(DrawWindow *window)
+{
+#if defined(TARGET_X11)
+ X11CloseWindow(window);
#endif
}
if (DrawingDeactivated(dst_x, dst_y, width, height))
return;
+#if 1
+ /* skip if rectangle starts outside bitmap */
+ if (src_x >= src_bitmap->width ||
+ src_y >= src_bitmap->height ||
+ dst_x >= dst_bitmap->width ||
+ dst_y >= dst_bitmap->height)
+ return;
+
+ /* clip if rectangle overlaps bitmap */
+ if (src_x + width > src_bitmap->width)
+ width = src_bitmap->width - src_x;
+ if (src_y + height > src_bitmap->height)
+ height = src_bitmap->height - src_y;
+ if (dst_x + width > dst_bitmap->width)
+ width = dst_bitmap->width - dst_x;
+ if (dst_y + height > dst_bitmap->height)
+ height = dst_bitmap->height - dst_y;
+#endif
+
#if 0
/* !!! 2009-03-30: Fixed by using self-compiled, patched SDL.dll !!! */
/* (This bug still exists in the actual (as of 2009-06-15) version 1.2.13,
if (DrawingDeactivated(x, y, width, height))
return;
+#if 1
+ /* skip if rectangle starts outside bitmap */
+ if (x >= bitmap->width ||
+ y >= bitmap->height)
+ return;
+
+ /* clip if rectangle overlaps bitmap */
+ if (x + width > bitmap->width)
+ width = bitmap->width - x;
+ if (y + height > bitmap->height)
+ height = bitmap->height - y;
+#endif
+
sysFillRectangle(bitmap, x, y, width, height, color);
}
void InitVideoBuffer(int, int, int, boolean);
Bitmap *CreateBitmapStruct(void);
Bitmap *CreateBitmap(int, int, int);
+void ReCreateBitmap(Bitmap **, int, int, int);
void FreeBitmap(Bitmap *);
void BlitBitmap(Bitmap *, Bitmap *, int, int, int, int, int, int);
void FadeRectangle(Bitmap *bitmap, int, int, int, int, int, int, int,
void X11InitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window)
{
+ if (*window != NULL)
+ X11CloseWindow(*window);
+
*window = X11InitWindow();
XMapWindow(display, (*window)->drawable);
+
FlushDisplay();
/* create additional (off-screen) buffer for double-buffering */
+#if 1
+ ReCreateBitmap(backbuffer, video.width, video.height, video.depth);
+#else
*backbuffer = CreateBitmap(video.width, video.height, video.depth);
+#endif
}
static void X11InitDisplay()
win_xpos = (screen_width - width) / 2;
win_ypos = (screen_height - height) / 2;
+ new_window->width = width;
+ new_window->height = height;
+
new_window->drawable = XCreateSimpleWindow(display,
RootWindow(display, screen),
win_xpos, win_ypos,
return new_window;
}
+void X11CloseWindow(DrawWindow *window)
+{
+ if (window->drawable)
+ {
+ XUnmapWindow(display, window->drawable);
+ XDestroyWindow(display, window->drawable);
+ }
+
+ if (window->gc)
+ XFreeGC(display, window->gc);
+
+ free(window);
+}
+
void X11ZoomBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap)
{
#if defined(TARGET_ALLEGRO)
void X11InitVideoDisplay(void);
void X11InitVideoBuffer(DrawBuffer **, DrawWindow **);
+void X11CloseWindow(DrawWindow *);
+
void X11ZoomBitmap(Bitmap *, Bitmap *);
Bitmap *X11LoadImage(char *);
int lev_fieldx, lev_fieldy;
int scroll_x, scroll_y;
+int WIN_XSIZE = 672;
+int WIN_YSIZE = 560;
+
int FX = SX, FY = SY;
int ScrollStepSize;
int ScreenMovDir = MV_NONE, ScreenMovPos = 0;
struct TitleMessageInfo titlemessage_default;
struct TitleMessageInfo titlemessage[MAX_NUM_TITLE_MESSAGES];
struct TitleMessageInfo readme;
-struct InitInfo init;
+struct InitInfo init, init_last;
struct MenuInfo menu;
struct DoorInfo door_1, door_2;
struct PreviewInfo preview;
#define SND_UNDEFINED (-1)
#define MUS_UNDEFINED (-1)
+#if 0
#define WIN_XSIZE 672
#define WIN_YSIZE 560
+#endif
#define DEFAULT_FULLSCREEN_MODE "800x600"
int fading_status;
int fading_type;
#endif
+
+ struct Rect screen;
};
struct ElementChangeInfo
extern int lev_fieldx, lev_fieldy;
extern int scroll_x, scroll_y;
+extern int WIN_XSIZE, WIN_YSIZE;
+
extern int FX, FY;
extern int ScrollStepSize;
extern int ScreenMovDir, ScreenMovPos, ScreenGfxPos;
extern struct TitleMessageInfo titlemessage_default;
extern struct TitleMessageInfo titlemessage[];
extern struct TitleMessageInfo readme;
-extern struct InitInfo init;
+extern struct InitInfo init, init_last;
extern struct MenuInfo menu;
extern struct DoorInfo door_1, door_2;
extern struct PreviewInfo preview;
/* store valid level series information */
leveldir_last_valid = leveldir_current;
+ init_last = init; /* switch to new busy animation */
+
/* needed if last screen (level choice) changed graphics, sounds or music */
ReloadCustomArtwork(0);
#endif
#endif
+#if 1
+ /* needed if newly loaded custom artwork requires a different screen mode */
+ ChangeScreenModeIfNeeded();
+#endif
+
#if defined(TARGET_SDL)
SetDrawtoField(DRAW_BACKBUFFER);
#endif
#include "libgame/libgame.h"
#include "tools.h"
+#include "init.h"
#include "game.h"
#include "events.h"
#include "cartoons.h"
if (!video.fullscreen_available)
return;
-#if 1
if (change_fullscreen || change_fullscreen_mode)
-#else
- if (setup.fullscreen != video.fullscreen_enabled ||
- setup.fullscreen_mode != video.fullscreen_mode_current)
-#endif
{
Bitmap *tmp_backbuffer = CreateBitmap(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH);
/* save backbuffer content which gets lost when toggling fullscreen mode */
BlitBitmap(backbuffer, tmp_backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
-#if 1
if (change_fullscreen_mode)
-#else
- if (setup.fullscreen && video.fullscreen_enabled)
-#endif
{
/* keep fullscreen, but change fullscreen mode (screen resolution) */
-#if 1
- /* (this is now set in sdl.c) */
-#else
- video.fullscreen_mode_current = setup.fullscreen_mode;
-#endif
video.fullscreen_enabled = FALSE; /* force new fullscreen mode */
}
#endif
}
}
+
+void ChangeScreenModeIfNeeded()
+{
+ if (global.screen.width == WIN_XSIZE &&
+ global.screen.height == WIN_YSIZE)
+ return;
+
+ WIN_XSIZE = global.screen.width;
+ WIN_YSIZE = global.screen.height;
+
+ InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen);
+ InitGfxBuffers();
+
+#if 1
+ SetDrawDeactivationMask(REDRAW_NONE);
+ SetDrawBackgroundMask(REDRAW_FIELD);
+
+ // RedrawBackground();
+#endif
+}
void PlaySoundSelecting();
void ToggleFullscreenIfNeeded();
+void ChangeScreenModeIfNeeded();
#endif /* TOOLS_H */