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
-#define COMPILE_DATE_STRING "2010-06-24 11:02"
+#define COMPILE_DATE_STRING "2010-06-24 20:41"
extern void em_open_all();
extern void em_close_all();
+extern void InitGfxBuffers_EM();
+
extern void InitGameEngine_EM();
extern void GameActions_EM(byte *, boolean);
extern char *progname;
extern char *arg_basedir;
+#if 0
+extern int TILEX, TILEY;
+#endif
+
extern int frame;
extern short ulaw_to_linear[256];
#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 */
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,
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;
#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;
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",
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)
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
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 */
/* 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
#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)
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),
(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
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);
}
#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);
}
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++)
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
}
}
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;
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++;
#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)
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;
/* 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
#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;
InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
InitGfxClipRegion(FALSE, -1, -1, -1, -1);
+ InitGfxBuffers_EM();
InitGfxBuffers_SP();
}
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)