From 2486a7a849210371bb59e733e37b0271a4332d8b Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 30 Apr 2014 21:41:30 +0200 Subject: [PATCH] rnd-20140430-1-src --- src/Makefile | 3 ++- src/conftime.h | 2 +- src/game.c | 31 +++++++++++++++++++++++++++++++ src/libgame/sdl.c | 37 +++++++++++++++++++++++++++++++++---- src/libgame/sdl.h | 3 ++- src/main.h | 8 ++++---- src/tools.c | 24 ++++++++++++++++++++++++ 7 files changed, 97 insertions(+), 11 deletions(-) diff --git a/src/Makefile b/src/Makefile index ebe3091f..8efe88c6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -75,7 +75,8 @@ endif ifeq ($(PLATFORM),cross-win32) # cross-compiling to Windows PROGNAME = ../$(PROGBASE).exe EXTRA_LDFLAGS = -lshfolder -lwsock32 -TARGET = sdl +# TARGET = sdl +TARGET = sdl2 endif ifeq ($(PLATFORM),cross-msdos) # cross-compiling to MS-DOS diff --git a/src/conftime.h b/src/conftime.h index 5aca865a..556b90cc 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2014-04-18 02:47" +#define COMPILE_DATE_STRING "2014-04-30 21:41" diff --git a/src/game.c b/src/game.c index a5a9396c..8b9d1132 100644 --- a/src/game.c +++ b/src/game.c @@ -3520,6 +3520,9 @@ int get_num_special_action(int element, int action_first, int action_last) void InitGame() { + int full_lev_fieldx = lev_fieldx + (BorderElement != EL_EMPTY ? 2 : 0); + int full_lev_fieldy = lev_fieldy + (BorderElement != EL_EMPTY ? 2 : 0); + boolean emulate_bd = TRUE; /* unless non-BOULDERDASH elements found */ boolean emulate_sb = TRUE; /* unless non-SOKOBAN elements found */ boolean emulate_sp = TRUE; /* unless non-SUPAPLEX elements found */ @@ -4301,16 +4304,44 @@ void InitGame() #if NEW_TILESIZE + // printf("::: START-0: %d, %d\n", lev_fieldx, SCR_FIELDX); + // printf("::: START-1: %d, %d\n", SBX_Left, SBX_Right); + +#if 1 + if (full_lev_fieldx <= SCR_FIELDX) + SBX_Left = SBX_Right = -1 * (SCR_FIELDX - lev_fieldx) / 2; + + if (full_lev_fieldy <= SCR_FIELDY) + SBY_Upper = SBY_Lower = -1 * (SCR_FIELDY - lev_fieldy) / 2; +#else if (lev_fieldx + (SBX_Left < 0 ? 2 : 0) <= SCR_FIELDX) SBX_Left = SBX_Right = -1 * (SCR_FIELDX - lev_fieldx) / 2; if (lev_fieldy + (SBY_Upper < 0 ? 2 : 0) <= SCR_FIELDY) SBY_Upper = SBY_Lower = -1 * (SCR_FIELDY - lev_fieldy) / 2; +#endif + /* + printf("::: START-2: %d, %d (%d)\n", SBX_Left, SBX_Right, + SBX_Right - SBX_Left + 1); + */ + +#if 1 + if (EVEN(SCR_FIELDX) && full_lev_fieldx > SCR_FIELDX) + SBX_Left--; + if (EVEN(SCR_FIELDY) && full_lev_fieldy > SCR_FIELDY) + SBY_Upper--; +#else if (EVEN(SCR_FIELDX)) SBX_Left--; if (EVEN(SCR_FIELDY)) SBY_Upper--; +#endif + + /* + printf("::: START-3: %d, %d\n", SBX_Left, SBX_Right); + printf("\n"); + */ #else diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index bfcd7ead..0b27fafb 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -816,13 +816,26 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen) { SDL_SysWMinfo wminfo; HWND hwnd; + boolean wminfo_success = FALSE; SDL_VERSION(&wminfo.version); - SDL_GetWMInfo(&wminfo); +#if defined(TARGET_SDL2) + if (sdl_window) + wminfo_success = SDL_GetWindowWMInfo(sdl_window, &wminfo); +#else + wminfo_success = (SDL_GetWMInfo(&wminfo) == 1); +#endif - hwnd = wminfo.window; + if (wminfo_success) + { +#if defined(TARGET_SDL2) + hwnd = wminfo.info.win.window; +#else + hwnd = wminfo.window; +#endif - DragAcceptFiles(hwnd, TRUE); + DragAcceptFiles(hwnd, TRUE); + } } #endif #endif @@ -830,12 +843,16 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen) return success; } -#if defined(TARGET_SDL2) void SDLSetWindowTitle() { +#if defined(TARGET_SDL2) SDL_SetWindowTitle(sdl_window, program.window_title); +#else + SDL_WM_SetCaption(program.window_title, program.window_title); +#endif } +#if defined(TARGET_SDL2) void SDLSetWindowScaling(int window_scaling_percent) { if (sdl_window == NULL) @@ -2508,9 +2525,17 @@ void SDLHandleWindowManagerEvent(Event *event) SDL_SysWMEvent *syswmevent = (SDL_SysWMEvent *)event; SDL_SysWMmsg *syswmmsg = (SDL_SysWMmsg *)(syswmevent->msg); +#if defined(TARGET_SDL2) + if (syswmmsg->msg.win.msg == WM_DROPFILES) +#else if (syswmmsg->msg == WM_DROPFILES) +#endif { +#if defined(TARGET_SDL2) + HDROP hdrop = (HDROP)syswmmsg->msg.win.wParam; +#else HDROP hdrop = (HDROP)syswmmsg->wParam; +#endif int i, num_files; printf("::: SDL_SYSWMEVENT:\n"); @@ -2527,7 +2552,11 @@ void SDLHandleWindowManagerEvent(Event *event) printf("::: - '%s'\n", buffer); } +#if defined(TARGET_SDL2) + DragFinish((HDROP)syswmmsg->msg.win.wParam); +#else DragFinish((HDROP)syswmmsg->wParam); +#endif } #endif } diff --git a/src/libgame/sdl.h b/src/libgame/sdl.h index a69e2350..00b2698a 100644 --- a/src/libgame/sdl.h +++ b/src/libgame/sdl.h @@ -437,13 +437,14 @@ struct MouseCursorInfo #if defined(TARGET_SDL2) SDL_Surface *SDL_DisplayFormat(SDL_Surface *); -void SDLSetWindowTitle(void); void SDLSetWindowScaling(int); void SDLSetWindowScalingQuality(char *); void SDLSetWindowFullscreen(boolean); void SDLRedrawWindow(); #endif +void SDLSetWindowTitle(void); + void SDLLimitScreenUpdates(boolean); void SDLInitVideoDisplay(void); void SDLInitVideoBuffer(DrawBuffer **, DrawWindow **, boolean); diff --git a/src/main.h b/src/main.h index 29f84f2f..0e2259a5 100644 --- a/src/main.h +++ b/src/main.h @@ -2072,10 +2072,10 @@ /* program information and versioning definitions */ -#define PROGRAM_VERSION_MAJOR 3 -#define PROGRAM_VERSION_MINOR 3 -#define PROGRAM_VERSION_PATCH 1 -#define PROGRAM_VERSION_BUILD 3 +#define PROGRAM_VERSION_MAJOR 4 +#define PROGRAM_VERSION_MINOR 0 +#define PROGRAM_VERSION_PATCH 0 +#define PROGRAM_VERSION_BUILD 0 #define PROGRAM_TITLE_STRING "Rocks'n'Diamonds" #define PROGRAM_AUTHOR_STRING "Holger Schemel" diff --git a/src/tools.c b/src/tools.c index 7986e8bc..8954a19d 100644 --- a/src/tools.c +++ b/src/tools.c @@ -437,6 +437,8 @@ void BlitScreenToBitmap(Bitmap *target_bitmap) { DrawBuffer *buffer = (drawto_field == window ? backbuffer : drawto_field); int fx = FX, fy = FY; + int full_lev_fieldx = lev_fieldx + (BorderElement != EL_EMPTY ? 2 : 0); + int full_lev_fieldy = lev_fieldy + (BorderElement != EL_EMPTY ? 2 : 0); #if NEW_TILESIZE int dx = (ScreenMovDir & (MV_LEFT | MV_RIGHT) ? ScreenGfxPos : 0); @@ -487,6 +489,28 @@ void BlitScreenToBitmap(Bitmap *target_bitmap) fx, fy); #endif +#if 1 + if (full_lev_fieldx <= SCR_FIELDX) + { + // printf(":1: PLAYFIELD FITS TO SCREEN [%d, %d, %d]\n", fx, ffx, dx_var); + + if (EVEN(SCR_FIELDX)) + fx = 2 * TILEX_VAR - (ODD(lev_fieldx) ? TILEX_VAR / 2 : 0); + else + fx = 2 * TILEX_VAR - (EVEN(lev_fieldx) ? TILEX_VAR / 2 : 0); + + // printf(":2: PLAYFIELD FITS TO SCREEN [%d, %d, %d]\n", fx, ffx, dx_var); + } + + if (full_lev_fieldy <= SCR_FIELDY) + { + if (EVEN(SCR_FIELDY)) + fy = 2 * TILEY_VAR - (ODD(lev_fieldy) ? TILEY_VAR / 2 : 0); + else + fy = 2 * TILEY_VAR - (EVEN(lev_fieldy) ? TILEY_VAR / 2 : 0); + } +#endif + if (border.draw_masked[GAME_MODE_PLAYING]) { if (buffer != backbuffer) -- 2.34.1