fixed redraw/fade bugs when redefining the playfield size or position
[rocksndiamonds.git] / src / libgame / system.h
index 0b2800f237065c83e853d5cd95a13541c9439ec7..f7259356ee8eb5932f8d76d43605975a4eccaf59 100644 (file)
@@ -1,15 +1,13 @@
-/***********************************************************
-* Artsoft Retro-Game Library                               *
-*----------------------------------------------------------*
-* (c) 1994-2006 Artsoft Entertainment                      *
-*               Holger Schemel                             *
-*               Detmolder Strasse 189                      *
-*               33604 Bielefeld                            *
-*               Germany                                    *
-*               e-mail: info@artsoft.org                   *
-*----------------------------------------------------------*
-* system.h                                                 *
-***********************************************************/
+// ============================================================================
+// Artsoft Retro-Game Library
+// ----------------------------------------------------------------------------
+// (c) 1995-2014 by Artsoft Entertainment
+//                         Holger Schemel
+//                 info@artsoft.org
+//                 http://www.artsoft.org/
+// ----------------------------------------------------------------------------
+// system.h
+// ============================================================================
 
 #ifndef SYSTEM_H
 #define SYSTEM_H
 #include "macosx.h"
 #elif defined(PLATFORM_WIN32)
 #include "windows.h"
-#elif defined(PLATFORM_MSDOS)
-#include "msdos.h"
 #elif defined(PLATFORM_ANDROID)
 #include "android.h"
 #endif
 
-#if defined(TARGET_SDL)
 #include "sdl.h"
-#elif defined(TARGET_X11)
-#include "x11.h"
-#endif
 
 
 /* the additional 'b' is needed for Win32 to open files in binary mode */
 
 #define SCALING_QUALITY_DEFAULT                SCALING_QUALITY_LINEAR
 
+/* values for touch control */
+#define TOUCH_CONTROL_VIRTUAL_BUTTONS  "virtual_buttons"
+#define TOUCH_CONTROL_WIPE_GESTURES    "wipe_gestures"
+
+#define TOUCH_CONTROL_DEFAULT          TOUCH_CONTROL_VIRTUAL_BUTTONS
+
+#define TOUCH_MOVE_DISTANCE_DEFAULT    2
+#define TOUCH_DROP_DISTANCE_DEFAULT    5
+
+
 /* default input keys */
 #define DEFAULT_KEY_LEFT               KSYM_Left
 #define DEFAULT_KEY_RIGHT              KSYM_Right
                                 REDRAW_MICROLEVEL)
 #define REDRAW_FPS             (1 << 11)
 
-#if defined(TARGET_X11)
-/* on old-style, classic and potentially slow graphics systems, redraw single
-   tiles instead of the whole playfield unless a certain threshold is reached;
-   when using the X11 target, this method should still be fast on all systems */
-#define REDRAWTILES_THRESHOLD  (SCR_FIELDX * SCR_FIELDY / 2)
-#else
-/* on modern graphics systems and when using the SDL target, this tile redraw
+/* on modern graphics systems and when using the SDL target, the old tile redraw
    optimization can slow things down a lot due to many small blits compared to
    one single playfield-sized blit (especially observed on Mac OS X with SDL) */
 #define REDRAWTILES_THRESHOLD  0
-#endif
 
 #define IN_GFX_FIELD_PLAY(x, y)        (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \
                                 y >= gfx.sy && y < gfx.sy + gfx.sysize)
 
 /* default values for undefined configuration file parameters */
 #define ARG_UNDEFINED          "-1000000"
-#define ARG_UNDEFINED_VALUE    (atoi(ARG_UNDEFINED))
+#define ARG_UNDEFINED_VALUE    (-1000000)
+
+/* default value for off-screen positions */
+#define POS_OFFSCREEN          (-1000000)
 
 /* definitions for game sub-directories */
 #ifndef RO_GAME_DIR
 #define DOCS_DIRECTORY         "docs"
 #define CACHE_DIRECTORY                "cache"
 
-#if !defined(PLATFORM_MSDOS)
 #define GFX_CLASSIC_SUBDIR     "gfx_classic"
 #define SND_CLASSIC_SUBDIR     "snd_classic"
 #define MUS_CLASSIC_SUBDIR     "mus_classic"
-#else
-#define GFX_CLASSIC_SUBDIR     "gfx_orig"
-#define SND_CLASSIC_SUBDIR     "snd_orig"
-#define MUS_CLASSIC_SUBDIR     "mus_orig"
-#endif
 
 #if defined(CREATE_SPECIAL_EDITION_RND_JUE)
 #define GFX_DEFAULT_SUBDIR     "jue0"
 #endif
 
 /* file names and filename extensions */
-#if !defined(PLATFORM_MSDOS)
 #define LEVELSETUP_DIRECTORY   "levelsetup"
 #define SETUP_FILENAME         "setup.conf"
 #define LEVELSETUP_FILENAME    "levelsetup.conf"
 #define LEVELFILE_EXTENSION    "level"
 #define TAPEFILE_EXTENSION     "tape"
 #define SCOREFILE_EXTENSION    "score"
-#else
-#define LEVELSETUP_DIRECTORY   "lvlsetup"
-#define SETUP_FILENAME         "setup.cnf"
-#define LEVELSETUP_FILENAME    "lvlsetup.cnf"
-#define EDITORSETUP_FILENAME   "edsetup.cnf"
-#define EDITORCASCADE_FILENAME "edcascad.conf"
-#define HELPANIM_FILENAME      "helpanim.cnf"
-#define HELPTEXT_FILENAME      "helptext.cnf"
-#define LEVELINFO_FILENAME     "lvlinfo.cnf"
-#define GRAPHICSINFO_FILENAME  "gfxinfo.cnf"
-#define SOUNDSINFO_FILENAME    "sndinfo.cnf"
-#define MUSICINFO_FILENAME     "musinfo.cnf"
-#define ARTWORKINFO_CACHE_FILE "artinfo.cac"
-#define LEVELFILE_EXTENSION    "lvl"
-#define TAPEFILE_EXTENSION     "tap"
-#define SCOREFILE_EXTENSION    "sco"
-#endif
 
 #define ERROR_BASENAME         "stderr.txt"
 
 #define STRING_NEWLINE_UNIX            "\n"
 #define STRING_NEWLINE_DOS             "\r\n"
 
-#if defined(PLATFORM_WIN32) || defined(PLATFORM_MSDOS)
+#if defined(PLATFORM_WIN32)
 #define CHAR_PATH_SEPARATOR    CHAR_PATH_SEPARATOR_DOS
 #define STRING_PATH_SEPARATOR  STRING_PATH_SEPARATOR_DOS
 #define STRING_NEWLINE         STRING_NEWLINE_DOS
@@ -693,13 +667,9 @@ struct ProgramInfo
   char *window_title;
   char *icon_title;
 
-  char *x11_icon_filename;
-  char *x11_iconmask_filename;
   char *sdl_icon_filename;
-  char *msdos_cursor_filename;
 
   char *cookie_prefix;
-  char *filename_prefix;       /* prefix to cut off from DOS filenames */
 
   char *error_filename;                /* filename where to write error messages to */
   FILE *error_file;            /* (used instead of 'stderr' on some systems) */
@@ -707,7 +677,10 @@ struct ProgramInfo
   int version_major;
   int version_minor;
   int version_patch;
+  int version_build;
+  int version_ident;
 
+  char *(*window_title_function)(void);
   void (*exit_message_function)(char *, va_list);
   void (*exit_function)(int);
 };
@@ -734,7 +707,6 @@ struct OptionInfo
   boolean network;
   boolean verbose;
   boolean debug;
-  boolean debug_x11_sync;
 };
 
 struct ScreenModeInfo
@@ -790,10 +762,6 @@ struct FontBitmapInfo
 
   int num_chars;
   int num_chars_per_line;
-
-#if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
-  Pixmap *clip_mask;           /* single-char-only clip mask array for X11 */
-#endif
 };
 
 struct GfxInfo
@@ -804,6 +772,8 @@ struct GfxInfo
   int full_sxsize, full_sysize;
   int scrollbuffer_width, scrollbuffer_height;
 
+  int game_tile_size, standard_tile_size;
+
   int dx, dy;
   int dxsize, dysize;
 
@@ -818,6 +788,8 @@ struct GfxInfo
   int draw_deactivation_mask;
   int draw_background_mask;
 
+  boolean drawing_area_changed;
+
   Bitmap *field_save_buffer;
 
   Bitmap *background_bitmap;
@@ -864,6 +836,13 @@ struct SetupKeyboardInfo
   Key snap, drop;
 };
 
+struct SetupTouchInfo
+{
+  char *control_type;
+  int move_distance;
+  int drop_distance;
+};
+
 struct SetupInputInfo
 {
   boolean use_joystick;
@@ -995,6 +974,7 @@ struct SetupInfo
   struct SetupEditorCascadeInfo editor_cascade;
   struct SetupShortcutInfo shortcut;
   struct SetupInputInfo input[MAX_PLAYERS];
+  struct SetupTouchInfo touch;
   struct SetupSystemInfo system;
   struct OptionInfo options;
 };
@@ -1214,6 +1194,9 @@ struct DoorPartPosInfo
   int step_xoffset;
   int step_yoffset;
   int step_delay;
+  int start_step;
+  int start_step_opening;
+  int start_step_closing;
   boolean draw_masked;
   int sort_priority;
 };
@@ -1259,11 +1242,6 @@ extern int                       level_nr;
 
 extern struct LevelStats       level_stats[];
 
-extern Display                *display;
-extern Visual                 *visual;
-extern int                     screen;
-extern Colormap                        cmap;
-
 extern DrawWindow             *window;
 extern DrawBuffer             *backbuffer;
 extern DrawBuffer             *drawto;
@@ -1283,14 +1261,18 @@ extern int                      FrameCounter;
 /* function definitions */
 
 void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
-                    char *, char *, char *, char *, char *, int);
+                    int);
+
+void SetWindowTitle();
 
+void InitWindowTitleFunction(char *(*window_title_function)(void));
 void InitExitMessageFunction(void (*exit_message_function)(char *, va_list));
 void InitExitFunction(void (*exit_function)(int));
 void InitPlatformDependentStuff(void);
 void ClosePlatformDependentStuff(void);
 
 void InitGfxFieldInfo(int, int, int, int, int, int, int, int, Bitmap *);
+void InitGfxTileSizeInfo(int, int);
 void InitGfxDoor1Info(int, int, int, int);
 void InitGfxDoor2Info(int, int, int, int);
 void InitGfxDoor3Info(int, int, int, int);
@@ -1321,10 +1303,9 @@ void FadeRectangle(Bitmap *bitmap, int, int, int, int, int, int, int,
 void FillRectangle(Bitmap *, int, int, int, int, Pixel);
 void ClearRectangle(Bitmap *, int, int, int, int);
 void ClearRectangleOnBackground(Bitmap *, int, int, int, int);
-void SetClipMask(Bitmap *, GC, Pixmap);
-void SetClipOrigin(Bitmap *, GC, int, int);
 void BlitBitmapMasked(Bitmap *, Bitmap *, int, int, int, int, int, int);
 boolean DrawingOnBackground(int, int);
+boolean DrawingAreaChanged();
 void BlitBitmapOnBackground(Bitmap *, Bitmap *, int, int, int, int, int, int);
 void DrawSimpleBlackLine(Bitmap *, int, int, int, int);
 void DrawSimpleWhiteLine(Bitmap *, int, int, int, int);
@@ -1333,8 +1314,6 @@ Pixel GetPixel(Bitmap *, int, int);
 Pixel GetPixelFromRGB(Bitmap *, unsigned int,unsigned int,unsigned int);
 Pixel GetPixelFromRGBcompact(Bitmap *, unsigned int);
 
-void FlushDisplay(void);
-void SyncDisplay(void);
 void KeyboardAutoRepeatOn(void);
 void KeyboardAutoRepeatOff(void);
 boolean PointerInWindow(DrawWindow *);
@@ -1346,8 +1325,9 @@ Bitmap *LoadCustomImage(char *);
 void ReloadCustomImage(Bitmap *, char *);
 
 Bitmap *ZoomBitmap(Bitmap *, int, int);
-void CreateBitmapWithSmallBitmaps(Bitmap *, int);
-void ScaleBitmap(Bitmap *, int);
+void ReCreateGameTileSizeBitmap(Bitmap **);
+void CreateBitmapWithSmallBitmaps(Bitmap **, int, int);
+void ScaleBitmap(Bitmap **, int);
 
 void SetMouseCursor(int);