projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rnd-20131209-1-src
[rocksndiamonds.git]
/
src
/
libgame
/
system.c
diff --git
a/src/libgame/system.c
b/src/libgame/system.c
index c2e9a3008f982c79a6dafbd5ae62381e2ca51507..4c43f02d29751da31bb018f64127d22b320e55e4 100644
(file)
--- a/
src/libgame/system.c
+++ b/
src/libgame/system.c
@@
-46,6
+46,8
@@
LevelDirTree *leveldir_first = NULL;
LevelDirTree *leveldir_current = NULL;
int level_nr;
LevelDirTree *leveldir_current = NULL;
int level_nr;
+struct LevelStats level_stats[MAX_LEVELS];
+
Display *display = NULL;
Visual *visual = NULL;
int screen = 0;
Display *display = NULL;
Visual *visual = NULL;
int screen = 0;
@@
-57,6
+59,9
@@
DrawBuffer *drawto = NULL;
int button_status = MB_NOT_PRESSED;
boolean motion_status = FALSE;
int button_status = MB_NOT_PRESSED;
boolean motion_status = FALSE;
+#if defined(TARGET_SDL2)
+boolean keyrepeat_status = TRUE;
+#endif
int redraw_mask = REDRAW_NONE;
int redraw_tiles = 0;
int redraw_mask = REDRAW_NONE;
int redraw_tiles = 0;
@@
-103,6
+108,11
@@
void InitProgramInfo(char *argv0,
program.error_file = stderr;
}
program.error_file = stderr;
}
+void InitExitMessageFunction(void (*exit_message_function)(char *, va_list))
+{
+ program.exit_message_function = exit_message_function;
+}
+
void InitExitFunction(void (*exit_function)(int))
{
program.exit_function = exit_function;
void InitExitFunction(void (*exit_function)(int))
{
program.exit_function = exit_function;
@@
-119,6
+129,9
@@
void InitExitFunction(void (*exit_function)(int))
void InitPlatformDependentStuff(void)
{
void InitPlatformDependentStuff(void)
{
+ // this is initialized in GetOptions(), but may already be used before
+ options.verbose = TRUE;
+
#if defined(PLATFORM_MSDOS)
_fmode = O_BINARY;
#endif
#if defined(PLATFORM_MSDOS)
_fmode = O_BINARY;
#endif
@@
-127,12
+140,22
@@
void InitPlatformDependentStuff(void)
updateUserGameDataDir();
#endif
updateUserGameDataDir();
#endif
+#if 1
+ openErrorFile();
+#else
#if !defined(PLATFORM_UNIX) || defined(PLATFORM_MACOSX)
openErrorFile();
#endif
#if !defined(PLATFORM_UNIX) || defined(PLATFORM_MACOSX)
openErrorFile();
#endif
+#endif
#if defined(TARGET_SDL)
#if defined(TARGET_SDL)
- if (SDL_Init(SDL_INIT_EVENTTHREAD | SDL_INIT_NOPARACHUTE) < 0)
+#if defined(TARGET_SDL2)
+ int sdl_init_flags = SDL_INIT_EVENTS | SDL_INIT_NOPARACHUTE;
+#else
+ int sdl_init_flags = SDL_INIT_EVENTTHREAD | SDL_INIT_NOPARACHUTE;
+#endif
+
+ if (SDL_Init(sdl_init_flags) < 0)
Error(ERR_EXIT, "SDL_Init() failed: %s", SDL_GetError());
SDLNet_Init();
Error(ERR_EXIT, "SDL_Init() failed: %s", SDL_GetError());
SDLNet_Init();
@@
-736,6
+759,12
@@
void BlitBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap,
#endif
#endif
#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);
}
sysCopyArea(src_bitmap, dst_bitmap,
src_x, src_y, width, height, dst_x, dst_y, BLIT_OPAQUE);
}
@@
-989,7
+1018,7
@@
Pixel GetPixelFromRGBcompact(Bitmap *bitmap, unsigned int color)
/* execute all pending screen drawing operations */
void FlushDisplay(void)
{
/* execute all pending screen drawing operations */
void FlushDisplay(void)
{
-#if
ndef TARGET_SDL
+#if
!defined(TARGET_SDL)
XFlush(display);
#endif
}
XFlush(display);
#endif
}
@@
-997,7
+1026,7
@@
void FlushDisplay(void)
/* execute and wait for all pending screen drawing operations */
void SyncDisplay(void)
{
/* execute and wait for all pending screen drawing operations */
void SyncDisplay(void)
{
-#if
ndef TARGET_SDL
+#if
!defined(TARGET_SDL)
XSync(display, FALSE);
#endif
}
XSync(display, FALSE);
#endif
}
@@
-1005,9
+1034,13
@@
void SyncDisplay(void)
void KeyboardAutoRepeatOn(void)
{
#if defined(TARGET_SDL)
void KeyboardAutoRepeatOn(void)
{
#if defined(TARGET_SDL)
+#if defined(TARGET_SDL2)
+ keyrepeat_status = TRUE;
+#else
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY / 2,
SDL_DEFAULT_REPEAT_INTERVAL / 2);
SDL_EnableUNICODE(1);
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY / 2,
SDL_DEFAULT_REPEAT_INTERVAL / 2);
SDL_EnableUNICODE(1);
+#endif
#else
if (display)
XAutoRepeatOn(display);
#else
if (display)
XAutoRepeatOn(display);
@@
-1017,8
+1050,12
@@
void KeyboardAutoRepeatOn(void)
void KeyboardAutoRepeatOff(void)
{
#if defined(TARGET_SDL)
void KeyboardAutoRepeatOff(void)
{
#if defined(TARGET_SDL)
+#if defined(TARGET_SDL2)
+ keyrepeat_status = FALSE;
+#else
SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
SDL_EnableUNICODE(0);
SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
SDL_EnableUNICODE(0);
+#endif
#else
if (display)
XAutoRepeatOff(display);
#else
if (display)
XAutoRepeatOff(display);
@@
-1172,7
+1209,9
@@
static void CreateScaledBitmaps(Bitmap *old_bitmap, int zoom_factor,
int width_4, height_4;
int width_8, height_8;
int width_16, height_16;
int width_4, height_4;
int width_8, height_8;
int width_16, height_16;
+#if 0
int width_32, height_32;
int width_32, height_32;
+#endif
int new_width, new_height;
/* calculate new image dimensions for normal sized image */
int new_width, new_height;
/* calculate new image dimensions for normal sized image */
@@
-1203,8
+1242,10
@@
static void CreateScaledBitmaps(Bitmap *old_bitmap, int zoom_factor,
height_8 = height_1 / 8;
width_16 = width_1 / 16;
height_16 = height_1 / 16;
height_8 = height_1 / 8;
width_16 = width_1 / 16;
height_16 = height_1 / 16;
+#if 0
width_32 = width_1 / 32;
height_32 = height_1 / 32;
width_32 = width_1 / 32;
height_32 = height_1 / 32;
+#endif
UPDATE_BUSY_STATE();
UPDATE_BUSY_STATE();
@@
-1267,11
+1308,11
@@
static void CreateScaledBitmaps(Bitmap *old_bitmap, int zoom_factor,
if (old_bitmap->surface_masked)
SDL_FreeSurface(old_bitmap->surface_masked);
if (old_bitmap->surface_masked)
SDL_FreeSurface(old_bitmap->surface_masked);
- SDL_SetColorKey(tmp_surface_1, S
DL_SRCCOLORKEY
,
+ SDL_SetColorKey(tmp_surface_1, S
ET_TRANSPARENT_PIXEL
,
SDL_MapRGB(tmp_surface_1->format, 0x00, 0x00, 0x00));
if ((old_bitmap->surface_masked = SDL_DisplayFormat(tmp_surface_1)) ==NULL)
Error(ERR_EXIT, "SDL_DisplayFormat() failed");
SDL_MapRGB(tmp_surface_1->format, 0x00, 0x00, 0x00));
if ((old_bitmap->surface_masked = SDL_DisplayFormat(tmp_surface_1)) ==NULL)
Error(ERR_EXIT, "SDL_DisplayFormat() failed");
- SDL_SetColorKey(tmp_surface_1,
0, 0); /* reset transparent pixel */
+ SDL_SetColorKey(tmp_surface_1,
UNSET_TRANSPARENT_PIXEL, 0);
#endif
}
#endif
#endif
}
#endif
@@
-1358,11
+1399,11
@@
static void CreateScaledBitmaps(Bitmap *old_bitmap, int zoom_factor,
if (old_bitmap->surface_masked)
SDL_FreeSurface(old_bitmap->surface_masked);
if (old_bitmap->surface_masked)
SDL_FreeSurface(old_bitmap->surface_masked);
- SDL_SetColorKey(old_surface, S
DL_SRCCOLORKEY
,
+ SDL_SetColorKey(old_surface, S
ET_TRANSPARENT_PIXEL
,
SDL_MapRGB(old_surface->format, 0x00, 0x00, 0x00));
if ((old_bitmap->surface_masked = SDL_DisplayFormat(old_surface)) ==NULL)
Error(ERR_EXIT, "SDL_DisplayFormat() failed");
SDL_MapRGB(old_surface->format, 0x00, 0x00, 0x00));
if ((old_bitmap->surface_masked = SDL_DisplayFormat(old_surface)) ==NULL)
Error(ERR_EXIT, "SDL_DisplayFormat() failed");
- SDL_SetColorKey(old_surface,
0, 0); /* reset transparent pixel */
+ SDL_SetColorKey(old_surface,
UNSET_TRANSPARENT_PIXEL, 0);
#endif
}
#endif
#endif
}
#endif
@@
-1600,10
+1641,14
@@
void SetAudioMode(boolean enabled)
void InitEventFilter(EventFilter filter_function)
{
void InitEventFilter(EventFilter filter_function)
{
-#if defined(TARGET_SDL)
/* set event filter to filter out certain events */
/* set event filter to filter out certain events */
+#if defined(TARGET_SDL)
+#if defined(TARGET_SDL2)
+ SDL_SetEventFilter(filter_function, NULL);
+#else
SDL_SetEventFilter(filter_function);
#endif
SDL_SetEventFilter(filter_function);
#endif
+#endif
}
boolean PendingEvent(void)
}
boolean PendingEvent(void)
@@
-1627,7
+1672,11
@@
void NextEvent(Event *event)
void PeekEvent(Event *event)
{
#if defined(TARGET_SDL)
void PeekEvent(Event *event)
{
#if defined(TARGET_SDL)
+#if defined(TARGET_SDL2)
+ SDL_PeepEvents(event, 1, SDL_PEEKEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT);
+#else
SDL_PeepEvents(event, 1, SDL_PEEKEVENT, SDL_ALLEVENTS);
SDL_PeepEvents(event, 1, SDL_PEEKEVENT, SDL_ALLEVENTS);
+#endif
#else
XPeekEvent(display, event);
#endif
#else
XPeekEvent(display, event);
#endif
@@
-1636,6
+1685,10
@@
void PeekEvent(Event *event)
Key GetEventKey(KeyEvent *event, boolean with_modifiers)
{
#if defined(TARGET_SDL)
Key GetEventKey(KeyEvent *event, boolean with_modifiers)
{
#if defined(TARGET_SDL)
+#if defined(TARGET_SDL2)
+ /* key up/down events in SDL2 do not return text characters anymore */
+ return event->keysym.sym;
+#else
#if 0
printf("unicode == '%d', sym == '%d', mod == '0x%04x'\n",
#if 0
printf("unicode == '%d', sym == '%d', mod == '0x%04x'\n",
@@
-1651,6
+1704,7
@@
Key GetEventKey(KeyEvent *event, boolean with_modifiers)
else
return event->keysym.sym;
else
return event->keysym.sym;
+#endif
#else
#if 0
#else
#if 0