From: Holger Schemel Date: Thu, 24 Jun 2010 18:46:30 +0000 (+0200) Subject: rnd-20100624-3-src X-Git-Tag: 3.3.1.0^2~18 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=1d3eff06cde10309320341fa92abec5b14f1c6f6;p=rocksndiamonds.git rnd-20100624-3-src --- diff --git a/ChangeLog b/ChangeLog index c2872eed..6a2e7abc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,5 @@ 2010-06-24 - * started adding alternative (smaller) tile size option for playing game + * added alternative game mode for playing with half size playfield tiles * fixed another memory violation bug in the native Supaplex game engine (this potential memory bug was also in the original Megaplex code, but apparently only occured under rare conditions triggered by using the diff --git a/src/conftime.h b/src/conftime.h index 604c7cfb..fe5d77ae 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-06-24 11:02" +#define COMPILE_DATE_STRING "2010-06-24 20:41" diff --git a/src/game_em/export.h b/src/game_em/export.h index 05e7ae65..b9a7e412 100644 --- a/src/game_em/export.h +++ b/src/game_em/export.h @@ -727,6 +727,8 @@ extern struct EngineSnapshotInfo_EM engine_snapshot_em; extern void em_open_all(); extern void em_close_all(); +extern void InitGfxBuffers_EM(); + extern void InitGameEngine_EM(); extern void GameActions_EM(byte *, boolean); diff --git a/src/game_em/global.h b/src/game_em/global.h index 8cd8624a..9590d196 100644 --- a/src/game_em/global.h +++ b/src/game_em/global.h @@ -14,6 +14,10 @@ extern int debug; extern char *progname; extern char *arg_basedir; +#if 0 +extern int TILEX, TILEY; +#endif + extern int frame; extern short ulaw_to_linear[256]; diff --git a/src/game_em/graphics.c b/src/game_em/graphics.c index 5764e9e3..ff6e4c6c 100644 --- a/src/game_em/graphics.c +++ b/src/game_em/graphics.c @@ -29,6 +29,12 @@ #define USE_EXTENDED_GRAPHICS_ENGINE 1 + +#if 0 +int TILEX = ORIG_TILEX * ZOOM_FACTOR; +int TILEY = ORIG_TILEY * ZOOM_FACTOR; +#endif + int frame; /* current screen frame */ int screen_x, screen_y; /* current scroll position */ @@ -60,6 +66,12 @@ void BlitScreenToBitmap_EM(Bitmap *target_bitmap) int x = screen_x % (MAX_BUF_XSIZE * TILEX); int y = screen_y % (MAX_BUF_YSIZE * TILEY); +#if 0 + printf("::: %d, %d\n", screenBitmap->width, screenBitmap->height); + BlitBitmap(screenBitmap, target_bitmap, 0, 0, 544, 544, SX, SY); + return; +#endif + if (x < 2 * TILEX && y < 2 * TILEY) { BlitBitmap(screenBitmap, target_bitmap, x, y, @@ -231,12 +243,21 @@ static void DrawLevelField_EM(int x, int y, int sx, int sy, boolean draw_masked) { struct GraphicInfo_EM *g = getObjectGraphic(x, y); +#if NEW_TILESIZE + int src_x = g->src_x + g->src_offset_x * TILESIZE_VAR / TILESIZE; + int src_y = g->src_y + g->src_offset_y * TILESIZE_VAR / TILESIZE; + int dst_x = sx * TILEX + g->dst_offset_x * TILESIZE_VAR / TILESIZE; + int dst_y = sy * TILEY + g->dst_offset_y * TILESIZE_VAR / TILESIZE; + int width = g->width * TILESIZE_VAR / TILESIZE; + int height = g->height * TILESIZE_VAR / TILESIZE; +#else int src_x = g->src_x + g->src_offset_x; int src_y = g->src_y + g->src_offset_y; int dst_x = sx * TILEX + g->dst_offset_x; int dst_y = sy * TILEY + g->dst_offset_y; int width = g->width; int height = g->height; +#endif int left = screen_x / TILEX; int top = screen_y / TILEY; @@ -274,6 +295,7 @@ static void DrawLevelFieldCrumbled_EM(int x, int y, int sx, int sy, #else struct GraphicInfo_EM *g = getObjectGraphic(x, y); #endif + int crumbled_border_size; int left = screen_x / TILEX; int top = screen_y / TILEY; int i; @@ -290,6 +312,12 @@ static void DrawLevelFieldCrumbled_EM(int x, int y, int sx, int sy, g = getObjectGraphic(x, y); #endif + crumbled_border_size = g->crumbled_border_size; + +#if NEW_TILESIZE + crumbled_border_size = crumbled_border_size * TILESIZE_VAR / TILESIZE; +#endif + #if 0 if (x == 3 && y == 3 && frame == 0) printf("::: %d, %d\n", @@ -305,17 +333,17 @@ static void DrawLevelFieldCrumbled_EM(int x, int y, int sx, int sy, if (i == 1 || i == 2) { - width = g->crumbled_border_size; + width = crumbled_border_size; height = TILEY; - cx = (i == 2 ? TILEX - g->crumbled_border_size : 0); + cx = (i == 2 ? TILEX - crumbled_border_size : 0); cy = 0; } else { width = TILEX; - height = g->crumbled_border_size; + height = crumbled_border_size; cx = 0; - cy = (i == 3 ? TILEY - g->crumbled_border_size : 0); + cy = (i == 3 ? TILEY - crumbled_border_size : 0); } if (width > 0 && height > 0) diff --git a/src/game_em/init.c b/src/game_em/init.c index 6e7fe948..12c0ad97 100644 --- a/src/game_em/init.c +++ b/src/game_em/init.c @@ -154,10 +154,15 @@ int open_all(void) sprmaskBitmap = emc_bitmaps[1]->clip_mask; #endif +#if 0 + printf("::: CreateBitmap: %d, %d => %d\n", + MAX_BUF_XSIZE, TILEX, MAX_BUF_XSIZE * TILEX); + screenBitmap = CreateBitmap(MAX_BUF_XSIZE * TILEX, MAX_BUF_YSIZE * TILEY, DEFAULT_DEPTH); global_em_info.screenbuffer = screenBitmap; +#endif #endif @@ -245,6 +250,33 @@ int open_all(void) return(0); } +void InitGfxBuffers_EM() +{ + +#if 1 + +#if 0 + printf("::: InitGfxBuffers_EM: %d, %d => %d\n", + MAX_BUF_XSIZE, TILEX, MAX_BUF_XSIZE * TILEX); +#endif + + ReCreateBitmap(&screenBitmap, MAX_BUF_XSIZE * TILEX, MAX_BUF_YSIZE * TILEY, + DEFAULT_DEPTH); + + global_em_info.screenbuffer = screenBitmap; + +#else + + printf("::: CreateBitmap: %d, %d => %d\n", + MAX_BUF_XSIZE, TILEX, MAX_BUF_XSIZE * TILEX); + + screenBitmap = CreateBitmap(MAX_BUF_XSIZE * TILEX, MAX_BUF_YSIZE * TILEY, + DEFAULT_DEPTH); + + global_em_info.screenbuffer = screenBitmap; +#endif +} + void em_open_all() { /* pre-calculate some data */ diff --git a/src/game_em/main_em.h b/src/game_em/main_em.h index c5efc415..c8776452 100644 --- a/src/game_em/main_em.h +++ b/src/game_em/main_em.h @@ -45,6 +45,10 @@ /* screen sizes and positions for EM engine */ +#define NEW_TILESIZE 1 + +#define ORIG_TILESIZE 16 + #define ORIG_TILEX 16 #define ORIG_TILEY 16 #define ORIG_SCOREX 8 @@ -54,10 +58,22 @@ #define ORIG_MENUFONTX 12 #define ORIG_MENUFONTY 16 +#if NEW_TILESIZE +#define ZOOM_FACTOR (2 * TILESIZE_VAR / TILESIZE) +#else #define ZOOM_FACTOR 2 +#endif +#define TILESIZE 32 + +#if NEW_TILESIZE +extern int TILESIZE_VAR; +#define TILEX TILESIZE_VAR +#define TILEY TILESIZE_VAR +#else #define TILEX (ORIG_TILEX * ZOOM_FACTOR) #define TILEY (ORIG_TILEY * ZOOM_FACTOR) +#endif #define SCOREX (ORIG_SCOREX * ZOOM_FACTOR) #define SCOREY (ORIG_SCOREY * ZOOM_FACTOR) #define GFXMENUFONTX (ORIG_GFXMENUFONTX * ZOOM_FACTOR) diff --git a/src/game_sp/DDScrollBuffer.c b/src/game_sp/DDScrollBuffer.c index 263f31f6..fa5f0814 100644 --- a/src/game_sp/DDScrollBuffer.c +++ b/src/game_sp/DDScrollBuffer.c @@ -50,6 +50,15 @@ static void ScrollPlayfield(int dx, int dy) int y2 = mScrollY_last / TILEY + (SCR_FIELDY - 1) + 2; int x, y; +#if NEW_TILESIZE + BlitBitmap(bitmap_db_field_sp, bitmap_db_field_sp, + TILEX_VAR * (dx == -1), + TILEY_VAR * (dy == -1), + (MAX_BUF_XSIZE * TILEX_VAR) - TILEX_VAR * (dx != 0), + (MAX_BUF_YSIZE * TILEY_VAR) - TILEY_VAR * (dy != 0), + TILEX_VAR * (dx == 1), + TILEY_VAR * (dy == 1)); +#else BlitBitmap(bitmap_db_field_sp, bitmap_db_field_sp, TILEX * (dx == -1), TILEY * (dy == -1), @@ -57,6 +66,7 @@ static void ScrollPlayfield(int dx, int dy) (MAX_BUF_YSIZE * TILEY) - TILEY * (dy != 0), TILEX * (dx == 1), TILEY * (dy == 1)); +#endif /* when scrolling the whole playfield, do not redraw single tiles */ #if 1 @@ -251,8 +261,17 @@ void BlitScreenToBitmap_SP(Bitmap *target_bitmap) int xsize = SXSIZE; int ysize = SYSIZE; +#if NEW_TILESIZE + int full_xsize = (FieldWidth - (menBorder ? 0 : 1)) * TILEX_VAR; + int full_ysize = (FieldHeight - (menBorder ? 0 : 1)) * TILEY_VAR; +#else int full_xsize = (FieldWidth - (menBorder ? 0 : 1)) * TILEX; int full_ysize = (FieldHeight - (menBorder ? 0 : 1)) * TILEY; +#endif + +#if NEW_TILESIZE + +#endif sxsize = (full_xsize < xsize ? full_xsize : xsize); sysize = (full_ysize < ysize ? full_ysize : ysize); @@ -271,6 +290,22 @@ void BlitScreenToBitmap_SP(Bitmap *target_bitmap) } #endif +#if NEW_TILESIZE + px = px * TILESIZE_VAR / TILESIZE; + py = py * TILESIZE_VAR / TILESIZE; +#endif + +#if 0 + printf("::: (%d, %d) (%d, %d) (%d, %d) [%d / %d]\n", + px, py, sxsize, sysize, sx, sy, + FieldHeight, menBorder); +#endif + +#if 0 + printf("::: (%d, %d)\n", + bitmap_db_field_sp->width, bitmap_db_field_sp->height); +#endif + BlitBitmap(bitmap_db_field_sp, target_bitmap, px, py, sxsize, sysize, sx, sy); } @@ -307,13 +342,23 @@ void BackToFront_SP(void) int scroll_yoffset = mScrollY - mScrollY_last + game_sp.scroll_yoffset; int x1 = 0, x2 = SCR_FIELDX - (scroll_xoffset != 0 ? 0 : 1); int y1 = 0, y2 = SCR_FIELDY - (scroll_yoffset != 0 ? 0 : 1); +#if NEW_TILESIZE + int full_xsize = (FieldWidth - (menBorder ? 0 : 1)) * TILEX_VAR; + int full_ysize = (FieldHeight - (menBorder ? 0 : 1)) * TILEY_VAR; +#else int full_xsize = (FieldWidth - (menBorder ? 0 : 1)) * TILEX; int full_ysize = (FieldHeight - (menBorder ? 0 : 1)) * TILEY; +#endif int sx = SX + (full_xsize < SXSIZE ? (SXSIZE - full_xsize) / 2 : 0); int sy = SY + (full_ysize < SYSIZE ? (SYSIZE - full_ysize) / 2 : 0); InitGfxClipRegion(TRUE, SX, SY, SXSIZE, SYSIZE); +#if NEW_TILESIZE + scroll_xoffset = scroll_xoffset * TILESIZE_VAR / TILESIZE; + scroll_yoffset = scroll_yoffset * TILESIZE_VAR / TILESIZE; +#endif + for (x = x1; x <= x2; x++) { for (y = y1; y <= y2; y++) @@ -321,11 +366,19 @@ void BackToFront_SP(void) int xx = 2 + x; int yy = 2 + y; +#if NEW_TILESIZE + if (redraw[xx][yy]) + BlitBitmap(bitmap_db_field_sp, window, + xx * TILEX_VAR, yy * TILEY_VAR, TILEX_VAR, TILEY_VAR, + sx + x * TILEX_VAR - scroll_xoffset, + sy + y * TILEY_VAR - scroll_yoffset); +#else if (redraw[xx][yy]) BlitBitmap(bitmap_db_field_sp, window, xx * TILEX, yy * TILEY, TILEX, TILEY, sx + x * TILEX - scroll_xoffset, sy + y * TILEY - scroll_yoffset); +#endif } } diff --git a/src/game_sp/DDSpriteBuffer.c b/src/game_sp/DDSpriteBuffer.c index 9377eac3..8f524c02 100644 --- a/src/game_sp/DDSpriteBuffer.c +++ b/src/game_sp/DDSpriteBuffer.c @@ -7,12 +7,21 @@ static void Blt(int pX, int pY, Bitmap *bitmap, int SpriteX, int SpriteY) { +#if NEW_TILESIZE + int pseudo_sxsize = SXSIZE * TILESIZE / TILESIZE_VAR; + int pseudo_sysize = SYSIZE * TILESIZE / TILESIZE_VAR; +#endif int scx = (mScrollX_last < 0 ? 0 : mScrollX_last); int scy = (mScrollY_last < 0 ? 0 : mScrollY_last); int sx1 = scx - 2 * TILEX; int sy1 = scy - 2 * TILEY; +#if NEW_TILESIZE + int sx2 = scx + pseudo_sxsize + 1 * TILEX; + int sy2 = scy + pseudo_sysize + 1 * TILEY; +#else int sx2 = scx + SXSIZE + 1 * TILEX; int sy2 = scy + SYSIZE + 1 * TILEY; +#endif int sx = pX - sx1; int sy = pY - sy1; int tile_x = sx / TILESIZE; @@ -27,8 +36,22 @@ static void Blt(int pX, int pY, Bitmap *bitmap, int SpriteX, int SpriteY) if (pX < sx1 || pX > sx2 || pY < sy1 || pY > sy2) return; +#if NEW_TILESIZE + +#if 0 + SpriteX = SpriteX * TILESIZE_VAR / TILESIZE; + SpriteY = SpriteY * TILESIZE_VAR / TILESIZE; +#endif + + sx = sx * TILESIZE_VAR / TILESIZE; + sy = sy * TILESIZE_VAR / TILESIZE; + + BlitBitmap(bitmap, bitmap_db_field_sp, SpriteX, SpriteY, + TILEX_VAR, TILEY_VAR, sx, sy); +#else BlitBitmap(bitmap, bitmap_db_field_sp, SpriteX, SpriteY, TILEX, TILEY, sx, sy); +#endif redraw[tile_x][tile_y] = TRUE; redraw_tiles++; diff --git a/src/game_sp/Globals.h b/src/game_sp/Globals.h index 5de5b8c8..c2a56c7c 100644 --- a/src/game_sp/Globals.h +++ b/src/game_sp/Globals.h @@ -15,7 +15,12 @@ #define ScrollDelta ((long)1) +#if NEW_TILESIZE +// #define ZoomFactor (ZOOM_FACTOR) #define ZoomFactor (2) +#else +#define ZoomFactor (2) +#endif #define StretchWidth (ZoomFactor * 16) #define TwoPixels (ZoomFactor * 2) diff --git a/src/game_sp/MainForm.c b/src/game_sp/MainForm.c index c54bf63d..d2e401b0 100644 --- a/src/game_sp/MainForm.c +++ b/src/game_sp/MainForm.c @@ -187,14 +187,23 @@ static void ReStretch() void SetScrollEdges() { +#if NEW_TILESIZE + int pseudo_sxsize = SXSIZE * TILESIZE / TILESIZE_VAR; + int pseudo_sysize = SYSIZE * TILESIZE / TILESIZE_VAR; +#endif int border1_offset = (menBorder ? 1 : 2); int border2_offset = (menBorder ? 0 : TILESIZE / 2); /* scroll correction for border frame (1 tile) or border element (2 tiles) */ ScrollMinX = 0; ScrollMinY = 0; +#if NEW_TILESIZE + ScrollMaxX = (DisplayMaxX + border1_offset) * TILEX - pseudo_sxsize; + ScrollMaxY = (DisplayMaxY + border1_offset) * TILEY - pseudo_sysize; +#else ScrollMaxX = (DisplayMaxX + border1_offset) * TILEX - SXSIZE; ScrollMaxY = (DisplayMaxY + border1_offset) * TILEY - SYSIZE; +#endif /* scroll correction for border element (half tile on left and right side) */ ScrollMinX += border2_offset; diff --git a/src/game_sp/main_sp.h b/src/game_sp/main_sp.h index 6e61508b..ac239390 100644 --- a/src/game_sp/main_sp.h +++ b/src/game_sp/main_sp.h @@ -27,13 +27,28 @@ /* screen sizes and positions for SP engine */ +#define NEW_TILESIZE 1 + #define ORIG_TILESIZE 16 +#if NEW_TILESIZE +#define ZOOM_FACTOR (2 * TILESIZE_VAR / TILESIZE) +#else #define ZOOM_FACTOR 2 +#endif +#if NEW_TILESIZE +extern int TILESIZE_VAR; +#define TILESIZE 32 +#define TILEX TILESIZE +#define TILEY TILESIZE +#define TILEX_VAR TILESIZE_VAR +#define TILEY_VAR TILESIZE_VAR +#else #define TILESIZE (ORIG_TILESIZE * ZOOM_FACTOR) #define TILEX TILESIZE #define TILEY TILESIZE +#endif #define ORIG_SCR_MENUX 20 #define ORIG_SCR_MENUY 12 @@ -55,10 +70,18 @@ extern int SX, SY; #define SX 8 #define SY 8 #endif + +#if NEW_TILESIZE +#define SXSIZE (SCR_FIELDX * TILEX_VAR) +#define SYSIZE (SCR_FIELDY * TILEY_VAR) +#define FXSIZE (MAX_BUF_XSIZE * TILEX_VAR) +#define FYSIZE (MAX_BUF_YSIZE * TILEY_VAR) +#else #define SXSIZE (SCR_FIELDX * TILEX) #define SYSIZE (SCR_FIELDY * TILEY) #define FXSIZE (MAX_BUF_XSIZE * TILEX) #define FYSIZE (MAX_BUF_YSIZE * TILEY) +#endif #if 1 extern int REAL_SX, REAL_SY; diff --git a/src/init.c b/src/init.c index 62b1b950..506f9354 100644 --- a/src/init.c +++ b/src/init.c @@ -5559,6 +5559,7 @@ void InitGfxBuffers() InitGfxScrollbufferInfo(FXSIZE, FYSIZE); InitGfxClipRegion(FALSE, -1, -1, -1, -1); + InitGfxBuffers_EM(); InitGfxBuffers_SP(); } diff --git a/src/tools.c b/src/tools.c index f09c8517..82fb4d0c 100644 --- a/src/tools.c +++ b/src/tools.c @@ -3663,7 +3663,9 @@ boolean Request(char *text, unsigned int req_state) char *text_ptr; int i; - global.use_envelope_request = TRUE * 1; +#if 1 + global.use_envelope_request = 0; +#endif #if 1 if (maxWordLengthInString(text) > MAX_REQUEST_LINE_FONT1_LEN)