From 9c299f0c6d66d7d0a246bbecdf2669fe5db25547 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 28 Jun 2010 18:30:01 +0200 Subject: [PATCH] rnd-20100628-1-src --- src/conftime.h | 2 +- src/files.c | 17 ++--- src/game_em/graphics.c | 66 +++++++++++++++++++- src/game_sp/DDSpriteBuffer.c | 7 +++ src/game_sp/MainForm.c | 7 +++ src/libgame/system.h | 1 + src/main.c | 2 +- src/screens.c | 1 + src/tools.c | 118 +++++++++++++++++++++++++++++++---- 9 files changed, 197 insertions(+), 24 deletions(-) diff --git a/src/conftime.h b/src/conftime.h index fe5d77ae..e6600b90 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-06-24 20:41" +#define COMPILE_DATE_STRING "2010-06-28 18:25" diff --git a/src/files.c b/src/files.c index d25a4798..74702b8d 100644 --- a/src/files.c +++ b/src/files.c @@ -9001,14 +9001,15 @@ void SaveScore(int nr) #define SETUP_TOKEN_PREFER_AGA_GRAPHICS 23 #define SETUP_TOKEN_GAME_FRAME_DELAY 24 #define SETUP_TOKEN_SP_SHOW_BORDER_ELEMENTS 25 -#define SETUP_TOKEN_GRAPHICS_SET 26 -#define SETUP_TOKEN_SOUNDS_SET 27 -#define SETUP_TOKEN_MUSIC_SET 28 -#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS 29 -#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS 30 -#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC 31 +#define SETUP_TOKEN_SMALL_GAME_GRAPHICS 26 +#define SETUP_TOKEN_GRAPHICS_SET 27 +#define SETUP_TOKEN_SOUNDS_SET 28 +#define SETUP_TOKEN_MUSIC_SET 29 +#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS 30 +#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS 31 +#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC 32 -#define NUM_GLOBAL_SETUP_TOKENS 32 +#define NUM_GLOBAL_SETUP_TOKENS 33 /* editor setup */ #define SETUP_TOKEN_EDITOR_EL_BOULDERDASH 0 @@ -9144,6 +9145,7 @@ static struct TokenInfo global_setup_tokens[] = { TYPE_SWITCH, &si.prefer_aga_graphics, "prefer_aga_graphics" }, { TYPE_INTEGER,&si.game_frame_delay, "game_frame_delay" }, { TYPE_SWITCH, &si.sp_show_border_elements, "sp_show_border_elements" }, + { TYPE_SWITCH, &si.small_game_graphics, "small_game_graphics" }, { TYPE_STRING, &si.graphics_set, "graphics_set" }, { TYPE_STRING, &si.sounds_set, "sounds_set" }, { TYPE_STRING, &si.music_set, "music_set" }, @@ -9311,6 +9313,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->prefer_aga_graphics = TRUE; si->game_frame_delay = GAME_FRAME_DELAY; si->sp_show_border_elements = FALSE; + si->small_game_graphics = FALSE; si->graphics_set = getStringCopy(GFX_DEFAULT_SUBDIR); si->sounds_set = getStringCopy(SND_DEFAULT_SUBDIR); diff --git a/src/game_em/graphics.c b/src/game_em/graphics.c index ff6e4c6c..455979ea 100644 --- a/src/game_em/graphics.c +++ b/src/game_em/graphics.c @@ -65,6 +65,16 @@ void BlitScreenToBitmap_EM(Bitmap *target_bitmap) { int x = screen_x % (MAX_BUF_XSIZE * TILEX); int y = screen_y % (MAX_BUF_YSIZE * TILEY); + int sx, sy, sxsize, sysize; + int xsize = SXSIZE; + int ysize = SYSIZE; + int full_xsize = lev.width * TILEX; + int full_ysize = lev.height * TILEY; + + sxsize = (full_xsize < xsize ? full_xsize : xsize); + sysize = (full_ysize < ysize ? full_ysize : ysize); + sx = SX + (full_xsize < xsize ? (xsize - full_xsize) / 2 : 0); + sy = SY + (full_ysize < ysize ? (ysize - full_ysize) / 2 : 0); #if 0 printf("::: %d, %d\n", screenBitmap->width, screenBitmap->height); @@ -72,6 +82,46 @@ void BlitScreenToBitmap_EM(Bitmap *target_bitmap) return; #endif +#if 1 + if (x < 2 * TILEX && y < 2 * TILEY) + { + BlitBitmap(screenBitmap, target_bitmap, x, y, + sxsize, sysize, sx, sy); + } + else if (x < 2 * TILEX && y >= 2 * TILEY) + { + BlitBitmap(screenBitmap, target_bitmap, x, y, + sxsize, MAX_BUF_YSIZE * TILEY - y, + sx, sy); + BlitBitmap(screenBitmap, target_bitmap, x, 0, + sxsize, y - 2 * TILEY, + sx, sy + MAX_BUF_YSIZE * TILEY - y); + } + else if (x >= 2 * TILEX && y < 2 * TILEY) + { + BlitBitmap(screenBitmap, target_bitmap, x, y, + MAX_BUF_XSIZE * TILEX - x, sysize, + sx, sy); + BlitBitmap(screenBitmap, target_bitmap, 0, y, + x - 2 * TILEX, sysize, + sx + MAX_BUF_XSIZE * TILEX - x, sy); + } + else + { + BlitBitmap(screenBitmap, target_bitmap, x, y, + MAX_BUF_XSIZE * TILEX - x, MAX_BUF_YSIZE * TILEY - y, + sx, sy); + BlitBitmap(screenBitmap, target_bitmap, 0, y, + x - 2 * TILEX, MAX_BUF_YSIZE * TILEY - y, + sx + MAX_BUF_XSIZE * TILEX - x, sy); + BlitBitmap(screenBitmap, target_bitmap, x, 0, + MAX_BUF_XSIZE * TILEX - x, y - 2 * TILEY, + sx, sy + MAX_BUF_YSIZE * TILEY - y); + BlitBitmap(screenBitmap, target_bitmap, 0, 0, + x - 2 * TILEX, y - 2 * TILEY, + sx + MAX_BUF_XSIZE * TILEX - x, sy + MAX_BUF_YSIZE * TILEY - y); + } +#else if (x < 2 * TILEX && y < 2 * TILEY) { BlitBitmap(screenBitmap, target_bitmap, x, y, @@ -110,6 +160,7 @@ void BlitScreenToBitmap_EM(Bitmap *target_bitmap) x - 2 * TILEX, y - 2 * TILEY, SX + MAX_BUF_XSIZE * TILEX - x, SY + MAX_BUF_YSIZE * TILEY - y); } +#endif } void BackToFront_EM(void) @@ -150,6 +201,17 @@ void BackToFront_EM(void) boolean half_shifted_y = (EVEN(SCR_FIELDY) && screen_y % TILEY != 0); #endif + int sx, sy, sxsize, sysize; + int xsize = SXSIZE; + int ysize = SYSIZE; + int full_xsize = lev.width * TILEX; + int full_ysize = lev.height * TILEY; + + sxsize = (full_xsize < xsize ? full_xsize : xsize); + sysize = (full_ysize < ysize ? full_ysize : ysize); + sx = SX + (full_xsize < xsize ? (xsize - full_xsize) / 2 : 0); + sy = SY + (full_ysize < ysize ? (ysize - full_ysize) / 2 : 0); + #if 0 #if 1 printf("::: %d, %d\n", EVEN(SCR_FIELDX), screen_x); @@ -176,8 +238,8 @@ void BackToFront_EM(void) if (redraw[xx][yy]) BlitBitmap(screenBitmap, window, xx * TILEX, yy * TILEY, TILEX, TILEY, - SX + x * TILEX - scroll_xoffset, - SY + y * TILEY - scroll_yoffset); + sx + x * TILEX - scroll_xoffset, + sy + y * TILEY - scroll_yoffset); } } diff --git a/src/game_sp/DDSpriteBuffer.c b/src/game_sp/DDSpriteBuffer.c index 8f524c02..47ec6aa3 100644 --- a/src/game_sp/DDSpriteBuffer.c +++ b/src/game_sp/DDSpriteBuffer.c @@ -8,16 +8,23 @@ static void Blt(int pX, int pY, Bitmap *bitmap, int SpriteX, int SpriteY) { #if NEW_TILESIZE +#if 0 int pseudo_sxsize = SXSIZE * TILESIZE / TILESIZE_VAR; int pseudo_sysize = SYSIZE * TILESIZE / TILESIZE_VAR; +#endif #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 +#if 1 + int sx2 = scx + (SCR_FIELDX + 1) * TILEX; + int sy2 = scy + (SCR_FIELDY + 1) * TILEY; +#else int sx2 = scx + pseudo_sxsize + 1 * TILEX; int sy2 = scy + pseudo_sysize + 1 * TILEY; +#endif #else int sx2 = scx + SXSIZE + 1 * TILEX; int sy2 = scy + SYSIZE + 1 * TILEY; diff --git a/src/game_sp/MainForm.c b/src/game_sp/MainForm.c index d2e401b0..d33191d6 100644 --- a/src/game_sp/MainForm.c +++ b/src/game_sp/MainForm.c @@ -188,8 +188,10 @@ static void ReStretch() void SetScrollEdges() { #if NEW_TILESIZE +#if 0 int pseudo_sxsize = SXSIZE * TILESIZE / TILESIZE_VAR; int pseudo_sysize = SYSIZE * TILESIZE / TILESIZE_VAR; +#endif #endif int border1_offset = (menBorder ? 1 : 2); int border2_offset = (menBorder ? 0 : TILESIZE / 2); @@ -198,8 +200,13 @@ void SetScrollEdges() ScrollMinX = 0; ScrollMinY = 0; #if NEW_TILESIZE +#if 1 + ScrollMaxX = (DisplayMaxX + border1_offset - SCR_FIELDX) * TILEX; + ScrollMaxY = (DisplayMaxY + border1_offset - SCR_FIELDY) * TILEY; +#else ScrollMaxX = (DisplayMaxX + border1_offset) * TILEX - pseudo_sxsize; ScrollMaxY = (DisplayMaxY + border1_offset) * TILEY - pseudo_sysize; +#endif #else ScrollMaxX = (DisplayMaxX + border1_offset) * TILEX - SXSIZE; ScrollMaxY = (DisplayMaxY + border1_offset) * TILEY - SYSIZE; diff --git a/src/libgame/system.h b/src/libgame/system.h index 06ad220d..d9b42bac 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -917,6 +917,7 @@ struct SetupInfo boolean prefer_aga_graphics; int game_frame_delay; boolean sp_show_border_elements; + boolean small_game_graphics; char *graphics_set; char *sounds_set; diff --git a/src/main.c b/src/main.c index 796fb9fb..3e3ad2a7 100644 --- a/src/main.c +++ b/src/main.c @@ -105,7 +105,7 @@ 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; +int TILESIZE_VAR = TILESIZE; #if 1 int FX, FY; diff --git a/src/screens.c b/src/screens.c index a20d5c24..cd9edc46 100644 --- a/src/screens.c +++ b/src/screens.c @@ -4241,6 +4241,7 @@ static struct TokenInfo setup_info_graphics[] = { TYPE_SWITCH, &setup.toons, "Show Toons:" }, { TYPE_ECS_AGA, &setup.prefer_aga_graphics,"EMC graphics preference:" }, { TYPE_SWITCH, &setup.sp_show_border_elements,"Supaplex Border Elements:" }, + { TYPE_SWITCH, &setup.small_game_graphics, "Small Game Graphics:" }, { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Back" }, diff --git a/src/tools.c b/src/tools.c index 82fb4d0c..9fa29564 100644 --- a/src/tools.c +++ b/src/tools.c @@ -8831,17 +8831,27 @@ 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; + int new_real_sx = vp_playfield->x; + int new_real_sy = vp_playfield->y; + int new_full_sxsize = vp_playfield->width; + int new_full_sysize = vp_playfield->height; #if NEW_TILESIZE + int new_tilesize_var = TILESIZE / (setup.small_game_graphics ? 2 : 1); + int tilesize = (gfx_game_mode == GAME_MODE_PLAYING ? new_tilesize_var : + gfx_game_mode == GAME_MODE_EDITOR ? MINI_TILESIZE : TILESIZE); int new_scr_fieldx = new_sxsize / tilesize; int new_scr_fieldy = new_sysize / tilesize; + int new_scr_fieldx_buffers = new_sxsize / new_tilesize_var; + int new_scr_fieldy_buffers = new_sysize / new_tilesize_var; #else int new_scr_fieldx = (vp_playfield->width - 2 * border_size) / TILESIZE; int new_scr_fieldy = (vp_playfield->height - 2 * border_size) / TILESIZE; #endif + boolean init_gfx_buffers = FALSE; + boolean init_video_buffer = FALSE; + boolean init_gadgets_and_toons = FALSE; #if 0 /* !!! TEST ONLY !!! */ @@ -8855,6 +8865,10 @@ void ChangeViewportPropertiesIfNeeded() WIN_XSIZE = viewport.window.width; WIN_YSIZE = viewport.window.height; +#if 1 + init_video_buffer = TRUE; + init_gfx_buffers = TRUE; +#else InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen); InitGfxBuffers(); @@ -8864,45 +8878,123 @@ void ChangeViewportPropertiesIfNeeded() // RedrawBackground(); #endif +#endif + + // printf("::: video: init_video_buffer, init_gfx_buffers\n"); } if (new_scr_fieldx != SCR_FIELDX || - new_scr_fieldy != SCR_FIELDY || - new_sx != SX || + new_scr_fieldy != SCR_FIELDY) + { + /* this always toggles between MAIN and GAME when using small tile size */ + + SCR_FIELDX = new_scr_fieldx; + SCR_FIELDY = new_scr_fieldy; + + // printf("::: new_scr_fieldx != SCR_FIELDX ...\n"); + } + +#if 0 + if (new_tilesize_var != TILESIZE_VAR && + gfx_game_mode == GAME_MODE_PLAYING) + { + /* doing this outside GAME_MODE_PLAYING would give wrong playfield size */ + + TILESIZE_VAR = new_tilesize_var; + + init_gfx_buffers = TRUE; + + // printf("::: tilesize: init_gfx_buffers\n"); + } +#endif + + if (new_sx != SX || new_sy != SY || - vp_playfield->x != REAL_SX || - vp_playfield->y != REAL_SY || + new_sxsize != SXSIZE || + new_sysize != SYSIZE || + new_real_sx != REAL_SX || + new_real_sy != REAL_SY || + new_full_sxsize != FULL_SXSIZE || + new_full_sysize != FULL_SYSIZE || + new_tilesize_var != TILESIZE_VAR || vp_door_1->x != *door_1_x || vp_door_1->y != *door_1_y || vp_door_2->x != *door_2_x || vp_door_2->y != *door_2_y) { - SCR_FIELDX = new_scr_fieldx; - SCR_FIELDY = new_scr_fieldy; SX = new_sx; SY = new_sy; - 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; + REAL_SX = new_real_sx; + REAL_SY = new_real_sy; + FULL_SXSIZE = new_full_sxsize; + FULL_SYSIZE = new_full_sysize; + TILESIZE_VAR = new_tilesize_var; + +#if 0 + printf("::: %d, %d, %d [%d]\n", + SCR_FIELDX, SCR_FIELDY, TILESIZE_VAR, + setup.small_game_graphics); +#endif *door_1_x = vp_door_1->x; *door_1_y = vp_door_1->y; *door_2_x = vp_door_2->x; *door_2_y = vp_door_2->y; +#if 1 + init_gfx_buffers = TRUE; + + // printf("::: viewports: init_gfx_buffers\n"); +#else InitGfxBuffers(); +#endif if (gfx_game_mode == GAME_MODE_MAIN) { +#if 1 + init_gadgets_and_toons = TRUE; + + // printf("::: viewports: init_gadgets_and_toons\n"); +#else InitGadgets(); InitToons(); +#endif } } + if (init_gfx_buffers) + { + // printf("::: init_gfx_buffers\n"); + + SCR_FIELDX = new_scr_fieldx_buffers; + SCR_FIELDY = new_scr_fieldy_buffers; + + InitGfxBuffers(); + + SCR_FIELDX = new_scr_fieldx; + SCR_FIELDY = new_scr_fieldy; + } + + if (init_video_buffer) + { + // printf("::: init_video_buffer\n"); + + InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen); + + SetDrawDeactivationMask(REDRAW_NONE); + SetDrawBackgroundMask(REDRAW_FIELD); + } + + if (init_gadgets_and_toons) + { + // printf("::: init_gadgets_and_toons\n"); + + InitGadgets(); + InitToons(); + } + #if 0 printf("::: %d, %d / %d, %d [%d]\n", VX, VY, EX, EY, game_status); #endif -- 2.34.1