From: Holger Schemel Date: Wed, 23 Jun 2010 23:42:53 +0000 (+0200) Subject: rnd-20100624-1-src X-Git-Tag: 3.3.1.0^2~20 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=1e422c29292f0583391b0ce9e9c872b38f035ac0;p=rocksndiamonds.git rnd-20100624-1-src * started adding alternative (smaller) tile size option for playing game --- diff --git a/ChangeLog b/ChangeLog index c500d17a..f8da0e50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2010-06-24 + * started adding alternative (smaller) tile size option for playing game + 2010-06-23 * added graphics performance optimization to native Supaplex game engine * fixed bug with accidentally removing preceding buffer in SP engine diff --git a/src/conf_gfx.c b/src/conf_gfx.c index b620dcbd..259f7317 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -6652,6 +6652,7 @@ struct ConfigInfo image_config[] = { "game.use_native_emc_graphics_engine", "false" }, { "game.use_native_sp_graphics_engine", "true" }, { "game.use_masked_pushing", "false" }, + { "game.tile_size", "32" }, { "[player].boring_delay_fixed", "1000" }, { "[player].boring_delay_random", "1000" }, diff --git a/src/conf_var.c b/src/conf_var.c index 17cc2aee..f29e8b55 100644 --- a/src/conf_var.c +++ b/src/conf_var.c @@ -5340,6 +5340,10 @@ struct TokenIntPtrInfo image_config_vars[] = "game.use_masked_pushing", &game.use_masked_pushing }, + { + "game.tile_size", + &game.tile_size + }, { "[player].boring_delay_fixed", &game.player_boring_delay_fixed diff --git a/src/conftime.h b/src/conftime.h index 49e7060b..c706413c 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-06-23 13:30" +#define COMPILE_DATE_STRING "2010-06-24 01:23" diff --git a/src/editor.c b/src/editor.c index 5752d742..2cffb843 100644 --- a/src/editor.c +++ b/src/editor.c @@ -971,8 +971,13 @@ #define RANDOM_USE_QUANTITY 1 /* maximal size of level editor drawing area */ +#if NEW_TILESIZE +#define MAX_ED_FIELDX (SCR_FIELDX) +#define MAX_ED_FIELDY (SCR_FIELDY - 1) +#else #define MAX_ED_FIELDX (2 * SCR_FIELDX) #define MAX_ED_FIELDY (2 * SCR_FIELDY - 1) +#endif /* @@ -5143,7 +5148,7 @@ static void DrawElementBorder(int dest_x, int dest_y, int width, int height, int by2 = TILEY - by; int i; - getGraphicSource(border_graphic, 0, &src_bitmap, &src_x, &src_y); + getFixedGraphicSource(border_graphic, 0, &src_bitmap, &src_x, &src_y); BlitBitmap(src_bitmap, drawto, src_x, src_y, bx, by, dest_x - bx, dest_y - by); @@ -8812,7 +8817,7 @@ static void DrawEditorElementAnimation(int x, int y) ANIM_MODE(graphic) == ANIM_CE_SCORE ? custom_element.collect_score_initial : FrameCounter); - DrawGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING); + DrawFixedGraphicAnimationExt(drawto, x, y, graphic, frame, NO_MASKING); } static void DrawEditorElementName(int x, int y, int element) @@ -10717,10 +10722,10 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) gi->y + sy * MINI_TILEY, el2edimg(new_element)); else - DrawGraphicExt(drawto, - gi->x + sx * TILEX, - gi->y + sy * TILEY, - el2img(new_element), 0); + DrawFixedGraphicExt(drawto, + gi->x + sx * TILEX, + gi->y + sy * TILEY, + el2img(new_element), 0); if (id == GADGET_ID_CUSTOM_GRAPHIC) new_element = GFX_ELEMENT(new_element); diff --git a/src/events.c b/src/events.c index 6c8cf2f0..cb810adf 100644 --- a/src/events.c +++ b/src/events.c @@ -1020,17 +1020,17 @@ void HandleKey(Key key, int key_status) break; case KSYM_f: - ScrollStepSize = TILEX/8; + ScrollStepSize = TILEX / 8; printf("ScrollStepSize == %d (1/8)\n", ScrollStepSize); break; case KSYM_g: - ScrollStepSize = TILEX/4; + ScrollStepSize = TILEX / 4; printf("ScrollStepSize == %d (1/4)\n", ScrollStepSize); break; case KSYM_h: - ScrollStepSize = TILEX/2; + ScrollStepSize = TILEX / 2; printf("ScrollStepSize == %d (1/2)\n", ScrollStepSize); break; diff --git a/src/files.c b/src/files.c index 8f018be0..d25a4798 100644 --- a/src/files.c +++ b/src/files.c @@ -10873,8 +10873,9 @@ void CreateLevelSketchImages() filename1 = getPath2(global.create_images_dir, basename1); filename2 = getPath2(global.create_images_dir, basename2); - getGraphicSource(graphic, 0, &src_bitmap, &src_x, &src_y); - BlitBitmap(src_bitmap, bitmap1, src_x, src_y, TILEX, TILEY, 0, 0); + getFixedGraphicSource(graphic, 0, &src_bitmap, &src_x, &src_y); + BlitBitmap(src_bitmap, bitmap1, src_x, src_y, TILEX, TILEY, + 0, 0); if (SDL_SaveBMP(bitmap1->surface, filename1) != 0) Error(ERR_EXIT, "cannot save level sketch image file '%s'", filename1); @@ -10925,7 +10926,7 @@ void CreateCustomElementImages() TILEY * (NUM_CUSTOM_ELEMENTS + NUM_GROUP_ELEMENTS) / 16, DEFAULT_DEPTH); - getGraphicSource(dummy_graphic, 0, &src_bitmap, &src_x, &src_y); + getFixedGraphicSource(dummy_graphic, 0, &src_bitmap, &src_x, &src_y); for (i = 0; i < NUM_CUSTOM_ELEMENTS; i++) { @@ -10937,18 +10938,22 @@ void CreateCustomElementImages() BlitBitmap(src_bitmap, bitmap, 0, 0, TILEX, TILEY, TILEX * x, TILEY * y + yoffset_ce); - BlitBitmap(src_bitmap, bitmap, 0, TILEY, TILEX, TILEY, - TILEX * x + TILEX * 16, TILEY * y + yoffset_ce); + BlitBitmap(src_bitmap, bitmap, 0, TILEY, + TILEX, TILEY, + TILEX * x + TILEX * 16, + TILEY * y + yoffset_ce); for (j = 2; j >= 0; j--) { int c = ii % 10; - BlitBitmap(src_bitmap, bitmap, TILEX + c * 7, 0, 6, 10, + BlitBitmap(src_bitmap, bitmap, + TILEX + c * 7, 0, 6, 10, TILEX * x + 6 + j * 7, TILEY * y + 11 + yoffset_ce); - BlitBitmap(src_bitmap, bitmap, TILEX + c * 8, TILEY, 6, 10, + BlitBitmap(src_bitmap, bitmap, + TILEX + c * 8, TILEY, 6, 10, TILEX * 16 + TILEX * x + 6 + j * 8, TILEY * y + 10 + yoffset_ce); @@ -10966,8 +10971,10 @@ void CreateCustomElementImages() BlitBitmap(src_bitmap, bitmap, 0, 0, TILEX, TILEY, TILEX * x, TILEY * y + yoffset_ge); - BlitBitmap(src_bitmap, bitmap, 0, TILEY, TILEX, TILEY, - TILEX * x + TILEX * 16, TILEY * y + yoffset_ge); + BlitBitmap(src_bitmap, bitmap, 0, TILEY, + TILEX, TILEY, + TILEX * x + TILEX * 16, + TILEY * y + yoffset_ge); for (j = 1; j >= 0; j--) { @@ -10977,7 +10984,8 @@ void CreateCustomElementImages() TILEX * x + 6 + j * 10, TILEY * y + 11 + yoffset_ge); - BlitBitmap(src_bitmap, bitmap, TILEX + c * 8, TILEY + 12, 6, 10, + BlitBitmap(src_bitmap, bitmap, + TILEX + c * 8, TILEY + 12, 6, 10, TILEX * 16 + TILEX * x + 10 + j * 8, TILEY * y + 10 + yoffset_ge); diff --git a/src/game.c b/src/game.c index cc304274..a88b3f04 100644 --- a/src/game.c +++ b/src/game.c @@ -8138,7 +8138,7 @@ void StartMoving(int x, int y) else if (Feld[x][y + 1] == EL_MAGIC_WALL_ACTIVE) { if (!MovDelay[x][y]) - MovDelay[x][y] = TILEY/4 + 1; + MovDelay[x][y] = TILEY / 4 + 1; if (MovDelay[x][y]) { @@ -8166,7 +8166,7 @@ void StartMoving(int x, int y) else if (Feld[x][y + 1] == EL_BD_MAGIC_WALL_ACTIVE) { if (!MovDelay[x][y]) - MovDelay[x][y] = TILEY/4 + 1; + MovDelay[x][y] = TILEY / 4 + 1; if (MovDelay[x][y]) { @@ -8194,7 +8194,7 @@ void StartMoving(int x, int y) else if (Feld[x][y + 1] == EL_DC_MAGIC_WALL_ACTIVE) { if (!MovDelay[x][y]) - MovDelay[x][y] = TILEY/4 + 1; + MovDelay[x][y] = TILEY / 4 + 1; if (MovDelay[x][y]) { @@ -13368,12 +13368,29 @@ void ScrollLevel(int dx, int dy) #else +#if NEW_TILESIZE +#if NEW_SCROLL + int softscroll_offset = (setup.soft_scrolling ? 2 * TILEX_VAR : 0); +#else + int softscroll_offset = (setup.soft_scrolling ? TILEX_VAR : 0); +#endif +#else #if NEW_SCROLL int softscroll_offset = (setup.soft_scrolling ? 2 * TILEX : 0); #else int softscroll_offset = (setup.soft_scrolling ? TILEX : 0); #endif +#endif +#if NEW_TILESIZE + BlitBitmap(drawto_field, drawto_field, + FX + TILEX_VAR * (dx == -1) - softscroll_offset, + FY + TILEY_VAR * (dy == -1) - softscroll_offset, + SXSIZE - TILEX_VAR * (dx != 0) + 2 * softscroll_offset, + SYSIZE - TILEY_VAR * (dy != 0) + 2 * softscroll_offset, + FX + TILEX_VAR * (dx == 1) - softscroll_offset, + FY + TILEY_VAR * (dy == 1) - softscroll_offset); +#else BlitBitmap(drawto_field, drawto_field, FX + TILEX * (dx == -1) - softscroll_offset, FY + TILEY * (dy == -1) - softscroll_offset, @@ -13382,6 +13399,8 @@ void ScrollLevel(int dx, int dy) FX + TILEX * (dx == 1) - softscroll_offset, FY + TILEY * (dy == 1) - softscroll_offset); #endif + +#endif #endif if (dx != 0) diff --git a/src/game.h b/src/game.h index a8345e27..18cac2ed 100644 --- a/src/game.h +++ b/src/game.h @@ -122,6 +122,7 @@ struct GameInfo boolean use_masked_pushing; int forced_scroll_delay_value; int scroll_delay_value; + int tile_size; /* values for engine initialization */ int default_push_delay_fixed; diff --git a/src/init.c b/src/init.c index f074cd94..62b1b950 100644 --- a/src/init.c +++ b/src/init.c @@ -217,7 +217,7 @@ void DrawInitAnim() int height = graphic_info[graphic].height; int frame = getGraphicAnimationFrame(graphic, sync_frame); - getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y); + getFixedGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y); BlitBitmap(src_bitmap, window, src_x, src_y, width, height, x, y); #else /* !!! this can only draw TILEX/TILEY size animations !!! */ @@ -862,8 +862,8 @@ void InitElementGraphicInfo() if (swap_movement_tiles_always || swap_movement_tiles_autodetected) { /* get current (wrong) backside tile coordinates */ - getGraphicSourceExt(graphic, 0, &dummy, &src_x_back, &src_y_back, - TRUE); + getFixedGraphicSourceExt(graphic, 0, &dummy, + &src_x_back, &src_y_back, TRUE); /* set frontside tile coordinates to backside tile coordinates */ g->src_x = src_x_back; @@ -1967,7 +1967,7 @@ static void InitGraphicInfo() /* check if first animation frame is inside specified bitmap */ first_frame = 0; - getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y); + getFixedGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y); #if 1 /* this avoids calculating wrong start position for out-of-bounds frame */ @@ -2001,7 +2001,7 @@ static void InitGraphicInfo() /* check if last animation frame is inside specified bitmap */ last_frame = graphic_info[i].anim_frames - 1; - getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y); + getFixedGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y); if (src_x < 0 || src_y < 0 || src_x + width > src_bitmap_width || @@ -2015,6 +2015,7 @@ static void InitGraphicInfo() Error(ERR_INFO, "error: last animation frame (%d) out of bounds (%d, %d) [%d, %d]", last_frame, src_x, src_y, src_bitmap_width, src_bitmap_height); + Error(ERR_INFO, "::: %d, %d", width, height); Error(ERR_INFO, "custom graphic rejected for this element/action"); if (i == fallback_graphic) @@ -2028,7 +2029,7 @@ static void InitGraphicInfo() #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND) /* currently we only need a tile clip mask from the first frame */ - getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y); + getFixedGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y); if (copy_clipmask_gc == None) { diff --git a/src/main.c b/src/main.c index cfe34b76..796fb9fb 100644 --- a/src/main.c +++ b/src/main.c @@ -101,6 +101,11 @@ int DX = 566, DY = 60; int VX = 566, VY = 400; int EX = 566, EY = 356; int dDX, dDY; +int SXSIZE = 17 * TILEX; /* SCR_FIELDX * TILEX */ +int SYSIZE = 17 * TILEY; /* SCR_FIELDY * TILEY */ +int FULL_SXSIZE = 2 + 17 * TILEX + 2; /* 2 + SXSIZE + 2 */ +int FULL_SYSIZE = 2 + 17 * TILEY + 2; /* 2 + SYSIZE + 2 */ +int TILESIZE_VAR = TILESIZE / 2; #if 1 int FX, FY; diff --git a/src/main.h b/src/main.h index 34f8bcbf..0c16dce6 100644 --- a/src/main.h +++ b/src/main.h @@ -31,6 +31,7 @@ #include "conf_mus.h" /* include auto-generated data structure definitions */ +#define NEW_TILESIZE 1 #define NEW_SCROLL 0 #define IMG_UNDEFINED (-1) @@ -964,6 +965,8 @@ #define TILESIZE 32 #define TILEX TILESIZE #define TILEY TILESIZE +#define TILEX_VAR TILESIZE_VAR +#define TILEY_VAR TILESIZE_VAR #define MINI_TILESIZE (TILESIZE / 2) #define MINI_TILEX MINI_TILESIZE #define MINI_TILEY MINI_TILESIZE @@ -972,18 +975,49 @@ #define MICRO_TILEY MICRO_TILESIZE #define MIDPOSX (SCR_FIELDX / 2) #define MIDPOSY (SCR_FIELDY / 2) +#if NEW_TILESIZE +#if NEW_SCROLL +#if 0 +#define SXSIZE (SCR_FIELDX * TILEX_VAR) +#define SYSIZE (SCR_FIELDY * TILEY_VAR) +#endif +#define FXSIZE ((2 + SCR_FIELDX + 2) * TILEX_VAR) +#define FYSIZE ((2 + SCR_FIELDY + 2) * TILEY_VAR) +#else +#if 0 +#define SXSIZE (SCR_FIELDX * TILEX_VAR) +#define SYSIZE (SCR_FIELDY * TILEY_VAR) +#endif +#define FXSIZE ((SCR_FIELDX + 2) * TILEX_VAR) +#define FYSIZE ((SCR_FIELDY + 2) * TILEY_VAR) +#endif +#else +#if NEW_SCROLL +#if 0 #define SXSIZE (SCR_FIELDX * TILEX) #define SYSIZE (SCR_FIELDY * TILEY) +#endif +#define FXSIZE ((2 + SCR_FIELDX + 2) * TILEX) +#define FYSIZE ((2 + SCR_FIELDY + 2) * TILEY) +#else +#if 0 +#define SXSIZE (SCR_FIELDX * TILEX) +#define SYSIZE (SCR_FIELDY * TILEY) +#endif #define FXSIZE ((SCR_FIELDX + 2) * TILEX) #define FYSIZE ((SCR_FIELDY + 2) * TILEY) +#endif +#endif #define DXSIZE 100 #define DYSIZE 280 #define VXSIZE DXSIZE #define VYSIZE 100 #define EXSIZE DXSIZE #define EYSIZE (VYSIZE + 44) +#if 0 #define FULL_SXSIZE (2 + SXSIZE + 2) #define FULL_SYSIZE (2 + SYSIZE + 2) +#endif #define MICROLEVEL_XSIZE ((STD_LEV_FIELDX + 2) * MICRO_TILEX) #define MICROLEVEL_YSIZE ((STD_LEV_FIELDY + 2) * MICRO_TILEY) #define MICROLEVEL_XPOS (SX + (SXSIZE - MICROLEVEL_XSIZE) / 2) @@ -2889,6 +2923,9 @@ extern int DX, DY; extern int VX, VY; extern int EX, EY; extern int dDX, dDY; +extern int SXSIZE, SYSIZE; +extern int FULL_SXSIZE, FULL_SYSIZE; +extern int TILESIZE_VAR; extern int FX, FY; extern int ScrollStepSize; diff --git a/src/screens.c b/src/screens.c index fb511433..a20d5c24 100644 --- a/src/screens.c +++ b/src/screens.c @@ -945,7 +945,7 @@ static void DrawCursorAndText_Main_Ext(int nr, boolean active_text, int y = mSY + pos->y; DrawBackgroundForGraphic(x, y, pos->width, pos->height, button_graphic); - DrawGraphicThruMaskExt(drawto, x, y, button_graphic, 0); + DrawFixedGraphicThruMaskExt(drawto, x, y, button_graphic, 0); } if (visibleTextPos(pos_text) && text != NULL) @@ -1046,7 +1046,7 @@ static void drawCursorExt(int xpos, int ypos, boolean active, int graphic) graphic = BUTTON_ACTIVE(graphic); DrawBackgroundForGraphic(x, y, TILEX, TILEY, graphic); - DrawGraphicThruMaskExt(drawto, x, y, graphic, 0); + DrawFixedGraphicThruMaskExt(drawto, x, y, graphic, 0); } static void initCursor(int ypos, int graphic) @@ -2197,8 +2197,8 @@ void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init) ClearRectangleOnBackground(drawto, xstart, ystart2 + (i - start) * ystep, TILEX, TILEY); - DrawGraphicAnimationExt(drawto, xstart, ystart2 + (i - start) * ystep, - graphic, sync_frame, USE_MASKING); + DrawFixedGraphicAnimationExt(drawto, xstart, ystart2 + (i - start) * ystep, + graphic, sync_frame, USE_MASKING); if (init) DrawInfoScreen_HelpText(element, action, direction, i - start); @@ -5013,8 +5013,8 @@ static void drawPlayerSetupInputInfo(int player_nr, boolean active) ClearRectangleOnBackground(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY, TILEX, TILEY); - DrawGraphicThruMaskExt(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY, - PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0); + DrawFixedGraphicThruMaskExt(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY, + PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0); if (setup.input[player_nr].use_joystick) { @@ -5370,7 +5370,7 @@ static boolean CalibrateJoystickMain(int player_nr) { for (x = 0; x < 3; x++) { - DrawGraphic(xpos + x - 1, ypos + y - 1, IMG_MENU_CALIBRATE_BLUE, 0); + DrawFixedGraphic(xpos + x - 1, ypos + y - 1, IMG_MENU_CALIBRATE_BLUE, 0); check[x][y] = FALSE; } } @@ -5394,7 +5394,7 @@ static boolean CalibrateJoystickMain(int player_nr) new_joystick_xmiddle = joy_x; new_joystick_ymiddle = joy_y; - DrawGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_RED, 0); + DrawFixedGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_RED, 0); FadeIn(REDRAW_FIELD); @@ -5466,8 +5466,10 @@ static boolean CalibrateJoystickMain(int player_nr) if (x != last_x || y != last_y) { - DrawGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_YELLOW, 0); - DrawGraphic(xpos + x, ypos + y, IMG_MENU_CALIBRATE_RED, 0); + DrawFixedGraphic(xpos + last_x, ypos + last_y, + IMG_MENU_CALIBRATE_YELLOW, 0); + DrawFixedGraphic(xpos + x, ypos + y, + IMG_MENU_CALIBRATE_RED, 0); last_x = x; last_y = y; diff --git a/src/tools.c b/src/tools.c index eb6f0765..f09c8517 100644 --- a/src/tools.c +++ b/src/tools.c @@ -108,6 +108,27 @@ void SetDrawtoField(int mode) { if (mode == DRAW_BUFFERED && setup.soft_scrolling) { +#if NEW_TILESIZE +#if NEW_SCROLL + FX = 2 * TILEX_VAR; + FY = 2 * TILEY_VAR; + BX1 = -2; + BY1 = -2; + BX2 = SCR_FIELDX + 1; + BY2 = SCR_FIELDY + 1; + redraw_x1 = 2; + redraw_y1 = 2; +#else + FX = TILEX_VAR; + FY = TILEY_VAR; + BX1 = -1; + BY1 = -1; + BX2 = SCR_FIELDX; + BY2 = SCR_FIELDY; + redraw_x1 = 1; + redraw_y1 = 1; +#endif +#else #if NEW_SCROLL FX = 2 * TILEX; FY = 2 * TILEY; @@ -126,6 +147,7 @@ void SetDrawtoField(int mode) BY2 = SCR_FIELDY; redraw_x1 = 1; redraw_y1 = 1; +#endif #endif drawto_field = fieldbuffer; @@ -381,8 +403,28 @@ void BackToFront() if (setup.soft_scrolling) { +#if NEW_TILESIZE + int dx = (ScreenMovDir & (MV_LEFT | MV_RIGHT) ? ScreenGfxPos : 0); + int dy = (ScreenMovDir & (MV_UP | MV_DOWN) ? ScreenGfxPos : 0); + + fx += dx * TILESIZE_VAR / TILESIZE; + fy += dy * TILESIZE_VAR / TILESIZE; +#else fx += (ScreenMovDir & (MV_LEFT | MV_RIGHT) ? ScreenGfxPos : 0); fy += (ScreenMovDir & (MV_UP | MV_DOWN) ? ScreenGfxPos : 0); +#endif + +#if 0 + printf("::: %d, %d [%d, %d] [%d, %d]\n", + fx, fy, FX, FY, ScreenMovDir, ScreenGfxPos); +#endif + +#if 0 +#if NEW_TILESIZE + fx = fx * TILESIZE_VAR / TILESIZE; + fy = fy * TILESIZE_VAR / TILESIZE; +#endif +#endif } if (setup.soft_scrolling || @@ -455,12 +497,22 @@ void BackToFront() printf("::: REDRAW_TILES\n"); #endif +#if NEW_TILESIZE + for (x = 0; x < SCR_FIELDX; x++) + for (y = 0 ; y < SCR_FIELDY; y++) + if (redraw[redraw_x1 + x][redraw_y1 + y]) + BlitBitmap(buffer, window, + FX + x * TILEX_VAR, FY + y * TILEY_VAR, + TILEX_VAR, TILEY_VAR, + SX + x * TILEX_VAR, SY + y * TILEY_VAR); +#else for (x = 0; x < SCR_FIELDX; x++) for (y = 0 ; y < SCR_FIELDY; y++) if (redraw[redraw_x1 + x][redraw_y1 + y]) BlitBitmap(buffer, window, FX + x * TILEX, FY + y * TILEY, TILEX, TILEY, SX + x * TILEX, SY + y * TILEY); +#endif } if (redraw_mask & REDRAW_FPS) /* display frames per second */ @@ -962,8 +1014,9 @@ inline int getGraphicAnimationFrame(int graphic, int sync_frame) sync_frame); } -void getSizedGraphicSource(int graphic, int frame, int tilesize_raw, - Bitmap **bitmap, int *x, int *y) +void getSizedGraphicSourceExt(int graphic, int frame, int tilesize_raw, + Bitmap **bitmap, int *x, int *y, + boolean get_backside) { struct { @@ -989,8 +1042,15 @@ void getSizedGraphicSource(int graphic, int frame, int tilesize_raw, int height_div = offset_calc[offset_calc_pos].height_div; int startx = src_bitmap->width * width_mult / width_div; int starty = src_bitmap->height * height_mult / height_div; +#if NEW_TILESIZE + int src_x = (g->src_x + (get_backside ? g->offset2_x : 0)) * + tilesize / TILESIZE; + int src_y = (g->src_y + (get_backside ? g->offset2_y : 0)) * + tilesize / TILESIZE; +#else int src_x = g->src_x * tilesize / TILESIZE; int src_y = g->src_y * tilesize / TILESIZE; +#endif int width = g->width * tilesize / TILESIZE; int height = g->height * tilesize / TILESIZE; int offset_x = g->offset_x * tilesize / TILESIZE; @@ -1023,6 +1083,25 @@ void getSizedGraphicSource(int graphic, int frame, int tilesize_raw, *y = starty + src_y; } +void getFixedGraphicSourceExt(int graphic, int frame, Bitmap **bitmap, + int *x, int *y, boolean get_backside) +{ + getSizedGraphicSourceExt(graphic, frame, TILESIZE, bitmap, x, y, + get_backside); +} + +void getSizedGraphicSource(int graphic, int frame, int tilesize_raw, + Bitmap **bitmap, int *x, int *y) +{ + getSizedGraphicSourceExt(graphic, frame, tilesize_raw, bitmap, x, y, FALSE); +} + +void getFixedGraphicSource(int graphic, int frame, + Bitmap **bitmap, int *x, int *y) +{ + getSizedGraphicSourceExt(graphic, frame, TILESIZE, bitmap, x, y, FALSE); +} + void getMiniGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y) { #if 1 @@ -1045,6 +1124,12 @@ inline void getGraphicSourceExt(int graphic, int frame, Bitmap **bitmap, int src_x = g->src_x + (get_backside ? g->offset2_x : 0); int src_y = g->src_y + (get_backside ? g->offset2_y : 0); +#if NEW_TILESIZE + if (TILESIZE_VAR != TILESIZE) + return getSizedGraphicSourceExt(graphic, frame, TILESIZE_VAR, bitmap, x, y, + get_backside); +#endif + *bitmap = g->bitmap; if (g->offset_y == 0) /* frames are ordered horizontally */ @@ -1086,7 +1171,28 @@ void DrawGraphic(int x, int y, int graphic, int frame) } #endif +#if NEW_TILESIZE + DrawGraphicExt(drawto_field, FX + x * TILEX_VAR, FY + y * TILEY_VAR, graphic, + frame); +#else DrawGraphicExt(drawto_field, FX + x * TILEX, FY + y * TILEY, graphic, frame); +#endif + MarkTileDirty(x, y); +} + +void DrawFixedGraphic(int x, int y, int graphic, int frame) +{ +#if DEBUG + if (!IN_SCR_FIELD(x, y)) + { + printf("DrawGraphic(): x = %d, y = %d, graphic = %d\n", x, y, graphic); + printf("DrawGraphic(): This should never happen!\n"); + return; + } +#endif + + DrawFixedGraphicExt(drawto_field, FX + x * TILEX, FY + y * TILEY, graphic, + frame); MarkTileDirty(x, y); } @@ -1097,6 +1203,20 @@ void DrawGraphicExt(DrawBuffer *dst_bitmap, int x, int y, int graphic, int src_x, src_y; getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y); +#if NEW_TILESIZE + BlitBitmap(src_bitmap, dst_bitmap, src_x, src_y, TILEX_VAR, TILEY_VAR, x, y); +#else + BlitBitmap(src_bitmap, dst_bitmap, src_x, src_y, TILEX, TILEY, x, y); +#endif +} + +void DrawFixedGraphicExt(DrawBuffer *dst_bitmap, int x, int y, int graphic, + int frame) +{ + Bitmap *src_bitmap; + int src_x, src_y; + + getFixedGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y); BlitBitmap(src_bitmap, dst_bitmap, src_x, src_y, TILEX, TILEY, x, y); } @@ -1111,8 +1231,29 @@ void DrawGraphicThruMask(int x, int y, int graphic, int frame) } #endif - DrawGraphicThruMaskExt(drawto_field, FX + x * TILEX, FY + y *TILEY, graphic, +#if NEW_TILESIZE + DrawGraphicThruMaskExt(drawto_field, FX + x * TILEX_VAR, FY + y * TILEY_VAR, + graphic, frame); +#else + DrawGraphicThruMaskExt(drawto_field, FX + x * TILEX, FY + y * TILEY, graphic, frame); +#endif + MarkTileDirty(x, y); +} + +void DrawFixedGraphicThruMask(int x, int y, int graphic, int frame) +{ +#if DEBUG + if (!IN_SCR_FIELD(x, y)) + { + printf("DrawGraphicThruMask(): x = %d,y = %d, graphic = %d\n",x,y,graphic); + printf("DrawGraphicThruMask(): This should never happen!\n"); + return; + } +#endif + + DrawFixedGraphicThruMaskExt(drawto_field, FX + x * TILEX, FY + y * TILEY, + graphic, frame); MarkTileDirty(x, y); } @@ -1124,6 +1265,24 @@ void DrawGraphicThruMaskExt(DrawBuffer *d, int dst_x, int dst_y, int graphic, getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y); + SetClipOrigin(src_bitmap, src_bitmap->stored_clip_gc, + dst_x - src_x, dst_y - src_y); +#if NEW_TILESIZE + BlitBitmapMasked(src_bitmap, d, src_x, src_y, TILEX_VAR, TILEY_VAR, + dst_x, dst_y); +#else + BlitBitmapMasked(src_bitmap, d, src_x, src_y, TILEX, TILEY, dst_x, dst_y); +#endif +} + +void DrawFixedGraphicThruMaskExt(DrawBuffer *d, int dst_x, int dst_y, + int graphic, int frame) +{ + Bitmap *src_bitmap; + int src_x, src_y; + + getFixedGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y); + SetClipOrigin(src_bitmap, src_bitmap->stored_clip_gc, dst_x - src_x, dst_y - src_y); BlitBitmapMasked(src_bitmap, d, src_x, src_y, TILEX, TILEY, dst_x, dst_y); @@ -1244,6 +1403,15 @@ inline static void DrawGraphicShiftedNormal(int x, int y, int dx, int dy, } #endif +#if NEW_TILESIZE + width = width * TILESIZE_VAR / TILESIZE; + height = height * TILESIZE_VAR / TILESIZE; + cx = cx * TILESIZE_VAR / TILESIZE; + cy = cy * TILESIZE_VAR / TILESIZE; + dx = dx * TILESIZE_VAR / TILESIZE; + dy = dy * TILESIZE_VAR / TILESIZE; +#endif + if (width > 0 && height > 0) { getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y); @@ -1251,8 +1419,13 @@ inline static void DrawGraphicShiftedNormal(int x, int y, int dx, int dy, src_x += cx; src_y += cy; +#if NEW_TILESIZE + dst_x = FX + x * TILEX_VAR + dx; + dst_y = FY + y * TILEY_VAR + dy; +#else dst_x = FX + x * TILEX + dx; dst_y = FY + y * TILEY + dy; +#endif if (mask_mode == USE_MASKING) { @@ -1276,7 +1449,11 @@ inline static void DrawGraphicShiftedDouble(int x, int y, int dx, int dy, Bitmap *src_bitmap; int src_x, src_y; int dst_x, dst_y; +#if NEW_TILESIZE + int width = TILEX_VAR, height = TILEY_VAR; +#else int width = TILEX, height = TILEY; +#endif int x1 = x; int y1 = y; int x2 = x + SIGN(dx); @@ -1323,8 +1500,13 @@ inline static void DrawGraphicShiftedDouble(int x, int y, int dx, int dy, { getGraphicSourceExt(graphic, frame, &src_bitmap, &src_x, &src_y, TRUE); +#if NEW_TILESIZE + dst_x = FX + x1 * TILEX_VAR; + dst_y = FY + y1 * TILEY_VAR; +#else dst_x = FX + x1 * TILEX; dst_y = FY + y1 * TILEY; +#endif if (mask_mode == USE_MASKING) { @@ -1345,8 +1527,13 @@ inline static void DrawGraphicShiftedDouble(int x, int y, int dx, int dy, { getGraphicSourceExt(graphic, frame, &src_bitmap, &src_x, &src_y, FALSE); +#if NEW_TILESIZE + dst_x = FX + x2 * TILEX_VAR; + dst_y = FY + y2 * TILEY_VAR; +#else dst_x = FX + x2 * TILEX; dst_y = FY + y2 * TILEY; +#endif if (mask_mode == USE_MASKING) { @@ -1516,6 +1703,15 @@ static void DrawLevelFieldCrumbledInnerCorners(int x, int y, int dx, int dy, getGraphicSource(graphic, 1, &src_bitmap, &src_x, &src_y); +#if NEW_TILESIZE + width = crumbled_border_size * TILESIZE_VAR / TILESIZE; + height = crumbled_border_size * TILESIZE_VAR / TILESIZE; + cx = (dx > 0 ? TILEX - crumbled_border_size : 0) * TILESIZE_VAR / TILESIZE; + cy = (dy > 0 ? TILEY - crumbled_border_size : 0) * TILESIZE_VAR / TILESIZE; + + BlitBitmap(src_bitmap, drawto_field, src_x + cx, src_y + cy, + width, height, FX + sx * TILEX_VAR + cx, FY + sy * TILEY_VAR + cy); +#else width = crumbled_border_size; height = crumbled_border_size; cx = (dx > 0 ? TILEX - crumbled_border_size : 0); @@ -1523,6 +1719,7 @@ static void DrawLevelFieldCrumbledInnerCorners(int x, int y, int dx, int dy, BlitBitmap(src_bitmap, drawto_field, src_x + cx, src_y + cy, width, height, FX + sx * TILEX + cx, FY + sy * TILEY + cy); +#endif } static void DrawLevelFieldCrumbledBorders(int x, int y, int graphic, int frame, @@ -1561,8 +1758,18 @@ static void DrawLevelFieldCrumbledBorders(int x, int y, int graphic, int frame, } #endif +#if NEW_TILESIZE + BlitBitmap(src_bitmap, drawto_field, + src_x + cx * TILESIZE_VAR / TILESIZE, + src_y + cy * TILESIZE_VAR / TILESIZE, + width * TILESIZE_VAR / TILESIZE, + height * TILESIZE_VAR / TILESIZE, + FX + sx * TILEX_VAR + cx * TILESIZE_VAR / TILESIZE, + FY + sy * TILEY_VAR + cy * TILESIZE_VAR / TILESIZE); +#else BlitBitmap(src_bitmap, drawto_field, src_x + cx, src_y + cy, width, height, FX + sx * TILEX + cx, FY + sy * TILEY + cy); +#endif /* (remaining middle border part must be at least as big as corner part) */ if (!(graphic_info[graphic].style & STYLE_ACCURATE_BORDERS) || @@ -1609,8 +1816,18 @@ static void DrawLevelFieldCrumbledBorders(int x, int y, int graphic, int frame, by = cy; } +#if NEW_TILESIZE + BlitBitmap(src_bitmap, drawto_field, + src_x + bx * TILESIZE_VAR / TILESIZE, + src_y + by * TILESIZE_VAR / TILESIZE, + width * TILESIZE_VAR / TILESIZE, + height * TILESIZE_VAR / TILESIZE, + FX + sx * TILEX_VAR + cx * TILESIZE_VAR / TILESIZE, + FY + sy * TILEY_VAR + cy * TILESIZE_VAR / TILESIZE); +#else BlitBitmap(src_bitmap, drawto_field, src_x + bx, src_y + by, width, height, FX + sx * TILEX + cx, FY + sy * TILEY + cy); +#endif } } #else @@ -2061,7 +2278,7 @@ void DrawEnvelopeBackground(int envelope_nr, int startx, int starty, int inner_sy = (height >= 3 * font_height ? font_height : 0); boolean draw_masked = graphic_info[graphic].draw_masked; - getGraphicSource(graphic, 0, &src_bitmap, &src_x, &src_y); + getFixedGraphicSource(graphic, 0, &src_bitmap, &src_x, &src_y); if (src_bitmap == NULL || width < font_width || height < font_height) { @@ -2860,6 +3077,18 @@ inline void DrawGraphicAnimationExt(DrawBuffer *dst_bitmap, int x, int y, DrawGraphicExt(dst_bitmap, x, y, graphic, frame); } +inline void DrawFixedGraphicAnimationExt(DrawBuffer *dst_bitmap, int x, int y, + int graphic, int sync_frame, + int mask_mode) +{ + int frame = getGraphicAnimationFrame(graphic, sync_frame); + + if (mask_mode == USE_MASKING) + DrawFixedGraphicThruMaskExt(dst_bitmap, x, y, graphic, frame); + else + DrawFixedGraphicExt(dst_bitmap, x, y, graphic, frame); +} + inline void DrawGraphicAnimation(int x, int y, int graphic) { int lx = LEVELX(x), ly = LEVELY(y); @@ -2867,6 +3096,23 @@ inline void DrawGraphicAnimation(int x, int y, int graphic) if (!IN_SCR_FIELD(x, y)) return; +#if NEW_TILESIZE + DrawGraphicAnimationExt(drawto_field, FX + x * TILEX_VAR, FY + y * TILEY_VAR, + graphic, GfxFrame[lx][ly], NO_MASKING); +#else + DrawGraphicAnimationExt(drawto_field, FX + x * TILEX, FY + y * TILEY, + graphic, GfxFrame[lx][ly], NO_MASKING); +#endif + MarkTileDirty(x, y); +} + +inline void DrawFixedGraphicAnimation(int x, int y, int graphic) +{ + int lx = LEVELX(x), ly = LEVELY(y); + + if (!IN_SCR_FIELD(x, y)) + return; + DrawGraphicAnimationExt(drawto_field, FX + x * TILEX, FY + y * TILEY, graphic, GfxFrame[lx][ly], NO_MASKING); MarkTileDirty(x, y); @@ -8583,8 +8829,17 @@ void ChangeViewportPropertiesIfNeeded() int border_size = vp_playfield->border_size; int new_sx = vp_playfield->x + border_size; int new_sy = vp_playfield->y + border_size; + int tilesize = (gfx_game_mode == GAME_MODE_PLAYING ? TILESIZE_VAR : + gfx_game_mode == GAME_MODE_EDITOR ? MINI_TILESIZE : TILESIZE); + int new_sxsize = vp_playfield->width - 2 * border_size; + int new_sysize = vp_playfield->height - 2 * border_size; +#if NEW_TILESIZE + int new_scr_fieldx = new_sxsize / tilesize; + int new_scr_fieldy = new_sysize / tilesize; +#else int new_scr_fieldx = (vp_playfield->width - 2 * border_size) / TILESIZE; int new_scr_fieldy = (vp_playfield->height - 2 * border_size) / TILESIZE; +#endif #if 0 /* !!! TEST ONLY !!! */ @@ -8627,6 +8882,11 @@ void ChangeViewportPropertiesIfNeeded() REAL_SX = vp_playfield->x; REAL_SY = vp_playfield->y; + SXSIZE = new_sxsize; + SYSIZE = new_sysize; + FULL_SXSIZE = vp_playfield->width; + FULL_SYSIZE = vp_playfield->width; + *door_1_x = vp_door_1->x; *door_1_y = vp_door_1->y; *door_2_x = vp_door_2->x; diff --git a/src/tools.h b/src/tools.h index 510524af..c4a0252b 100644 --- a/src/tools.h +++ b/src/tools.h @@ -103,8 +103,13 @@ void FloodFillLevel(int, int, int, short[MAX_LEV_FIELDX][MAX_LEV_FIELDY], void SetRandomAnimationValue(int, int); int getGraphicAnimationFrame(int, int); -void DrawGraphicAnimationExt(DrawBuffer *, int, int, int, int, int); + void DrawGraphicAnimation(int, int, int); +void DrawGraphicAnimationExt(DrawBuffer *, int, int, int, int, int); + +void DrawFixedGraphicAnimation(int, int, int); +void DrawFixedGraphicAnimationExt(DrawBuffer *, int, int, int, int, int); + void DrawLevelGraphicAnimation(int, int, int); void DrawLevelElementAnimation(int, int, int); void DrawLevelGraphicAnimationIfNeeded(int, int, int); @@ -114,17 +119,27 @@ void DrawAllPlayers(void); void DrawPlayerField(int, int); void DrawPlayer(struct PlayerInfo *); +void getSizedGraphicSourceExt(int, int, int, Bitmap **, int *, int *, boolean); +void getFixedGraphicSourceExt(int, int, Bitmap **, int *, int *, boolean); void getSizedGraphicSource(int, int, int, Bitmap **, int *, int *); +void getFixedGraphicSource(int, int, Bitmap **, int *, int *); void getMiniGraphicSource(int, Bitmap **, int *, int *); void getGraphicSourceExt(int, int, Bitmap **, int *, int *, boolean); void getGraphicSource(int, int, Bitmap **, int *, int *); + void DrawGraphic(int, int, int, int); void DrawGraphicExt(DrawBuffer *, int, int, int, int); void DrawGraphicThruMask(int, int, int, int); void DrawGraphicThruMaskExt(DrawBuffer *, int, int, int, int); +void DrawFixedGraphic(int, int, int, int); +void DrawFixedGraphicExt(DrawBuffer *, int, int, int, int); +void DrawFixedGraphicThruMask(int, int, int, int); +void DrawFixedGraphicThruMaskExt(DrawBuffer *, int, int, int, int); + void DrawSizedGraphic(int, int, int, int, int); void DrawSizedGraphicExt(DrawBuffer *, int, int, int, int, int); + void DrawMiniGraphic(int, int, int); void DrawMiniGraphicExt(DrawBuffer *, int, int, int);