void DrawMaskedBorder_FIELD()
{
- if (game_status >= GAME_MODE_TITLE &&
- game_status <= GAME_MODE_PLAYING &&
- border.draw_masked[game_status])
+ if (global.border_status >= GAME_MODE_TITLE &&
+ global.border_status <= GAME_MODE_PLAYING &&
+ border.draw_masked[global.border_status])
DrawMaskedBorder_Rect(REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
}
void DrawMaskedBorder_DOOR_1()
{
if (border.draw_masked[GFX_SPECIAL_ARG_DOOR] &&
- (game_status != GAME_MODE_EDITOR ||
+ (global.border_status != GAME_MODE_EDITOR ||
border.draw_masked[GFX_SPECIAL_ARG_EDITOR]))
DrawMaskedBorder_Rect(DX, DY, DXSIZE, DYSIZE);
}
void DrawMaskedBorder_DOOR_2()
{
if (border.draw_masked[GFX_SPECIAL_ARG_DOOR] &&
- game_status != GAME_MODE_EDITOR)
+ global.border_status != GAME_MODE_EDITOR)
DrawMaskedBorder_Rect(VX, VY, VXSIZE, VYSIZE);
}
void DrawMaskedBorder(int redraw_mask)
{
/* do not draw masked screen borders when displaying title screens */
- if (effectiveGameStatus() == GAME_MODE_TITLE ||
- effectiveGameStatus() == GAME_MODE_MESSAGE)
+ if (effectiveGameStatus() == GAME_MODE_TITLE)
return;
if (redraw_mask & REDRAW_ALL)
void FadeExt(int fade_mask, int fade_mode)
{
+ static int fade_mode_skip = FADE_MODE_NONE;
void (*draw_border_function)(void) = NULL;
- Bitmap *bitmap = (fade_mode == FADE_MODE_CROSSFADE ? bitmap_db_cross : NULL);
+#if 0
+ Bitmap *bitmap = (fade_mode != FADE_MODE_FADE_IN ? bitmap_db_cross : NULL);
+#else
+ Bitmap *bitmap = (fade_mode & FADE_TYPE_TRANSFORM ? bitmap_db_cross : NULL);
+#endif
int x, y, width, height;
int fade_delay, post_delay;
+ redraw_mask |= fade_mask;
+
+ if (fade_mode & FADE_TYPE_SKIP)
+ {
+#if 0
+ printf("::: will skip %d ... [%d]\n", fade_mode, fade_mode_skip);
+#endif
+
+ fade_mode_skip = fade_mode;
+
+ return;
+ }
+
+ if (fade_mode_skip & FADE_TYPE_SKIP)
+ {
+#if 0
+ printf("::: skipping %d ... [%d]\n", fade_mode, fade_mode_skip);
+#endif
+
+ /* skip all fade operations until specified fade operation */
+ if (fade_mode & fade_mode_skip)
+ fade_mode_skip = FADE_MODE_NONE;
+
+ return;
+ }
+
+#if 1
+ if (global.autoplay_leveldir)
+ {
+ // fading.fade_mode = FADE_MODE_NONE;
+
+ return;
+ }
+#endif
+
+#if 1
+ if (fading.fade_mode == FADE_MODE_NONE)
+ {
+ BackToFront();
+
+ return;
+ }
+#endif
+
if (fade_mask & REDRAW_FIELD)
{
x = REAL_SX;
width = FULL_SXSIZE;
height = FULL_SYSIZE;
- fade_delay = menu.fade_delay;
- post_delay = (fade_mode == FADE_MODE_FADE_OUT ? menu.post_delay : 0);
+ fade_delay = fading.fade_delay;
+ post_delay = (fade_mode == FADE_MODE_FADE_OUT ? fading.post_delay : 0);
- draw_border_function = DrawMaskedBorder_FIELD;
+ if (border.draw_masked_when_fading)
+ draw_border_function = DrawMaskedBorder_FIELD; /* update when fading */
+ else
+ DrawMaskedBorder_FIELD(); /* draw once */
}
else /* REDRAW_ALL */
{
width = WIN_XSIZE;
height = WIN_YSIZE;
- fade_delay = title.fade_delay_final;
- post_delay = (fade_mode == FADE_MODE_FADE_OUT ? title.post_delay_final : 0);
+ fade_delay = fading.fade_delay;
+ post_delay = (fade_mode == FADE_MODE_FADE_OUT ? fading.post_delay : 0);
}
- redraw_mask |= fade_mask;
-
+#if 1
if (!setup.fade_screens || fade_delay == 0)
+#else
+ if (!setup.fade_screens || fade_delay == 0 || fading.anim_mode == ANIM_NONE)
+#endif
{
if (fade_mode == FADE_MODE_FADE_OUT)
ClearRectangle(backbuffer, x, y, width, height);
void FadeIn(int fade_mask)
{
+#if 0
+ global.border_status = game_status;
+#endif
+
+#if 0
+ global.fading_status = game_status;
+
+ if (global.fading_type == TYPE_ENTER_MENU)
+ fading = menu.enter_menu;
+ else if (global.fading_type == TYPE_LEAVE_MENU)
+ fading = menu.leave_menu;
+ else if (global.fading_type == TYPE_ENTER_SCREEN)
+ fading = menu.enter_screen[global.fading_status];
+ else if (global.fading_type == TYPE_LEAVE_SCREEN)
+ fading = menu.leave_screen[global.fading_status];
+
+ printf("::: FadeIn: %s [0x%08x] [%d]\n",
+ global.fading_type == TYPE_ENTER_MENU ? "enter_menu" :
+ global.fading_type == TYPE_LEAVE_MENU ? "leave_menu" :
+ global.fading_type == TYPE_ENTER_SCREEN ? "enter_screen" :
+ global.fading_type == TYPE_LEAVE_SCREEN ? "leave_screen" : "(?)",
+ global.fading_type,
+ global.fading_status);
+#endif
+
+#if 1
+ // printf("::: now fading in...\n");
+
+ if (fading.fade_mode & FADE_TYPE_TRANSFORM)
+ FadeExt(fade_mask, fading.fade_mode);
+ else
+ FadeExt(fade_mask, FADE_MODE_FADE_IN);
+#else
+#if 1
+ if (fading.fade_mode == FADE_MODE_CROSSFADE)
+ FadeExt(fade_mask, FADE_MODE_CROSSFADE);
+ else
+ FadeExt(fade_mask, FADE_MODE_FADE_IN);
+#else
FadeExt(fade_mask, FADE_MODE_FADE_IN);
+#endif
+#endif
}
void FadeOut(int fade_mask)
{
+#if 0
+ if (global.fading_type == TYPE_ENTER_MENU)
+ fading = menu.enter_menu;
+ else if (global.fading_type == TYPE_LEAVE_MENU)
+ fading = menu.leave_menu;
+ else if (global.fading_type == TYPE_ENTER_SCREEN)
+ fading = menu.enter_screen[global.fading_status];
+ else if (global.fading_type == TYPE_LEAVE_SCREEN)
+ fading = menu.leave_screen[global.fading_status];
+
+ printf("::: FadeOut: %s [0x%08x] [%d]\n",
+ global.fading_type == TYPE_ENTER_MENU ? "enter_menu" :
+ global.fading_type == TYPE_LEAVE_MENU ? "leave_menu" :
+ global.fading_type == TYPE_ENTER_SCREEN ? "enter_screen" :
+ global.fading_type == TYPE_LEAVE_SCREEN ? "leave_screen" : "(?)",
+ global.fading_type,
+ global.fading_status);
+#endif
+
+#if 1
+ // printf("::: fading.fade_mode == %d\n", fading.fade_mode);
+
+ if (fading.fade_mode & FADE_TYPE_TRANSFORM)
+ FadeCrossSaveBackbuffer();
+ else
+ FadeExt(fade_mask, FADE_MODE_FADE_OUT);
+#else
+#if 1
+ if (fading.fade_mode == FADE_MODE_CROSSFADE)
+ FadeCrossSaveBackbuffer();
+ else
+ FadeExt(fade_mask, FADE_MODE_FADE_OUT);
+#else
FadeExt(fade_mask, FADE_MODE_FADE_OUT);
+#endif
+#endif
+
+#if 1
+ global.border_status = game_status;
+#endif
}
void FadeCross(int fade_mask)
BlitBitmap(backbuffer, bitmap_db_cross, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
}
+#if 0
+void FadeSetEnterMenu()
+{
+ global.fading_type = TYPE_ENTER_MENU;
+}
+
+void FadeSetLeaveMenu()
+{
+ global.fading_type = TYPE_LEAVE_MENU;
+}
+
+void FadeSetEnterScreen()
+{
+ global.fading_type = TYPE_ENTER_SCREEN;
+}
+
+void FadeSetLeaveScreen()
+{
+ // global.fading_type = TYPE_LEAVE_SCREEN;
+
+ global.fading_type = (global.fading_type == TYPE_ENTER_SCREEN ?
+ TYPE_LEAVE_SCREEN : TYPE_LEAVE_MENU);
+}
+
+#else
+
+static void FadeSetLeaveNext(struct TitleFadingInfo fading_leave, boolean set)
+{
+ static struct TitleFadingInfo fading_leave_stored;
+
+ if (set)
+ fading_leave_stored = fading_leave;
+ else
+ fading = fading_leave_stored;
+}
+
+void FadeSetEnterMenu()
+{
+ fading = menu.enter_menu;
+
+#if 0
+ printf("::: storing enter_menu\n");
+#endif
+
+ FadeSetLeaveNext(fading, TRUE); /* (keep same fade mode) */
+}
+
+void FadeSetLeaveMenu()
+{
+ fading = menu.leave_menu;
+
+#if 0
+ printf("::: storing leave_menu\n");
+#endif
+
+ FadeSetLeaveNext(fading, TRUE); /* (keep same fade mode) */
+}
+
+void FadeSetEnterScreen()
+{
+ fading = menu.enter_screen[game_status];
+
+#if 0
+ printf("::: storing leave_screen[%d]\n", game_status);
+#endif
+
+#if 0
+ printf("::: - %d, %d / %d, %d\n",
+ menu.enter_screen[game_status].fade_mode,
+ menu.enter_screen[game_status].fade_delay,
+ menu.leave_screen[game_status].fade_mode,
+ menu.leave_screen[game_status].fade_delay);
+#endif
+
+ FadeSetLeaveNext(menu.leave_screen[game_status], TRUE); /* store */
+}
+
+void FadeSetLeaveScreen()
+{
+#if 0
+ printf("::: recalling last stored value\n");
+#endif
+
+ FadeSetLeaveNext(menu.leave_screen[game_status], FALSE); /* recall */
+}
+
+#endif
+
+void FadeSetFromType(int type)
+{
+ if (type & TYPE_ENTER_SCREEN)
+ FadeSetEnterScreen();
+ else if (type & TYPE_ENTER)
+ FadeSetEnterMenu();
+ else if (type & TYPE_LEAVE)
+ FadeSetLeaveMenu();
+}
+
+void FadeSetDisabled()
+{
+ static struct TitleFadingInfo fading_none = { FADE_MODE_NONE, -1, -1, -1 };
+
+ fading = fading_none;
+}
+
+void FadeSkipNextFadeIn()
+{
+ FadeExt(0, FADE_MODE_SKIP_FADE_IN);
+}
+
+void FadeSkipNextFadeOut()
+{
+ FadeExt(0, FADE_MODE_SKIP_FADE_OUT);
+}
+
void SetWindowBackgroundImageIfDefined(int graphic)
{
if (graphic_info[graphic].bitmap)
sync_frame);
}
+void getSizedGraphicSource(int graphic, int frame, int tilesize_raw,
+ Bitmap **bitmap, int *x, int *y)
+{
+ struct
+ {
+ int width_mult, width_div;
+ int height_mult, height_div;
+ }
+ offset_calc[6] =
+ {
+ { 15, 16, 2, 3 }, /* 1 x 1 */
+ { 7, 8, 2, 3 }, /* 2 x 2 */
+ { 3, 4, 2, 3 }, /* 4 x 4 */
+ { 1, 2, 2, 3 }, /* 8 x 8 */
+ { 0, 1, 2, 3 }, /* 16 x 16 */
+ { 0, 1, 0, 1 }, /* 32 x 32 */
+ };
+ struct GraphicInfo *g = &graphic_info[graphic];
+ Bitmap *src_bitmap = g->bitmap;
+ int tilesize = MIN(MAX(1, tilesize_raw), TILESIZE);
+ int offset_calc_pos = log_2(tilesize);
+ int width_mult = offset_calc[offset_calc_pos].width_mult;
+ int width_div = offset_calc[offset_calc_pos].width_div;
+ int height_mult = offset_calc[offset_calc_pos].height_mult;
+ 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;
+ int src_x = g->src_x * tilesize / TILESIZE;
+ int src_y = g->src_y * tilesize / TILESIZE;
+ int width = g->width * tilesize / TILESIZE;
+ int height = g->height * tilesize / TILESIZE;
+ int offset_x = g->offset_x * tilesize / TILESIZE;
+ int offset_y = g->offset_y * tilesize / TILESIZE;
+
+ if (g->offset_y == 0) /* frames are ordered horizontally */
+ {
+ int max_width = g->anim_frames_per_line * width;
+ int pos = (src_y / height) * max_width + src_x + frame * offset_x;
+
+ src_x = pos % max_width;
+ src_y = src_y % height + pos / max_width * height;
+ }
+ else if (g->offset_x == 0) /* frames are ordered vertically */
+ {
+ int max_height = g->anim_frames_per_line * height;
+ int pos = (src_x / width) * max_height + src_y + frame * offset_y;
+
+ src_x = src_x % width + pos / max_height * width;
+ src_y = pos % max_height;
+ }
+ else /* frames are ordered diagonally */
+ {
+ src_x = src_x + frame * offset_x;
+ src_y = src_y + frame * offset_y;
+ }
+
+ *bitmap = src_bitmap;
+ *x = startx + src_x;
+ *y = starty + src_y;
+}
+
+void getMiniGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y)
+{
+#if 1
+ getSizedGraphicSource(graphic, 0, MINI_TILESIZE, bitmap, x, y);
+#else
+ struct GraphicInfo *g = &graphic_info[graphic];
+ int mini_startx = 0;
+ int mini_starty = g->bitmap->height * 2 / 3;
+
+ *bitmap = g->bitmap;
+ *x = mini_startx + g->src_x / 2;
+ *y = mini_starty + g->src_y / 2;
+#endif
+}
+
inline void getGraphicSourceExt(int graphic, int frame, Bitmap **bitmap,
int *x, int *y, boolean get_backside)
{
BlitBitmapMasked(src_bitmap, d, src_x, src_y, TILEX, TILEY, dst_x, dst_y);
}
-void DrawMiniGraphic(int x, int y, int graphic)
+void DrawSizedGraphic(int x, int y, int graphic, int frame, int tilesize)
{
- DrawMiniGraphicExt(drawto, SX + x * MINI_TILEX,SY + y * MINI_TILEY, graphic);
- MarkTileDirty(x / 2, y / 2);
+ DrawSizedGraphicExt(drawto, SX + x * tilesize, SY + y * tilesize, graphic,
+ frame, tilesize);
+ MarkTileDirty(x / tilesize, y / tilesize);
}
-void getMiniGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y)
+void DrawSizedGraphicExt(DrawBuffer *d, int x, int y, int graphic, int frame,
+ int tilesize)
{
- struct GraphicInfo *g = &graphic_info[graphic];
- int mini_startx = 0;
- int mini_starty = g->bitmap->height * 2 / 3;
+ Bitmap *src_bitmap;
+ int src_x, src_y;
- *bitmap = g->bitmap;
- *x = mini_startx + g->src_x / 2;
- *y = mini_starty + g->src_y / 2;
+ getSizedGraphicSource(graphic, frame, tilesize, &src_bitmap, &src_x, &src_y);
+ BlitBitmap(src_bitmap, d, src_x, src_y, tilesize, tilesize, x, y);
+}
+
+void DrawMiniGraphic(int x, int y, int graphic)
+{
+ DrawMiniGraphicExt(drawto, SX + x * MINI_TILEX,SY + y * MINI_TILEY, graphic);
+ MarkTileDirty(x / 2, y / 2);
}
void DrawMiniGraphicExt(DrawBuffer *d, int x, int y, int graphic)
level.envelope[envelope_nr].text, font_nr, max_xsize,
xsize - 2, ysize - 2, mask_mode,
level.envelope[envelope_nr].autowrap,
- level.envelope[envelope_nr].centered);
+ level.envelope[envelope_nr].centered, FALSE);
#else
DrawTextToTextArea(SX + sx + font_width, SY + sy + font_height,
level.envelope[envelope_nr].text, font_nr, max_xsize,
BackToFront();
}
-void getPreviewGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y,
- int tilesize)
-{
- struct
- {
- int width_mult, width_div;
- int height_mult, height_div;
- } offset_calc[4] =
- {
- { 0, 1, 0, 1 },
- { 0, 1, 2, 3 },
- { 1, 2, 2, 3 },
- { 3, 4, 2, 3 },
- };
- int offset_calc_pos = (tilesize < MICRO_TILESIZE || tilesize > TILESIZE ? 3 :
- 5 - log_2(tilesize));
- Bitmap *src_bitmap = graphic_info[graphic].bitmap;
- int width_mult = offset_calc[offset_calc_pos].width_mult;
- int width_div = offset_calc[offset_calc_pos].width_div;
- int height_mult = offset_calc[offset_calc_pos].height_mult;
- int height_div = offset_calc[offset_calc_pos].height_div;
- int mini_startx = src_bitmap->width * width_mult / width_div;
- int mini_starty = src_bitmap->height * height_mult / height_div;
- int src_x = mini_startx + graphic_info[graphic].src_x * tilesize / TILESIZE;
- int src_y = mini_starty + graphic_info[graphic].src_y * tilesize / TILESIZE;
-
- *bitmap = src_bitmap;
- *x = src_x;
- *y = src_y;
-}
-
void DrawPreviewElement(int dst_x, int dst_y, int element, int tilesize)
{
Bitmap *src_bitmap;
int src_x, src_y;
int graphic = el2preimg(element);
- getPreviewGraphicSource(graphic, &src_bitmap, &src_x, &src_y, tilesize);
+ getSizedGraphicSource(graphic, 0, tilesize, &src_bitmap, &src_x, &src_y);
BlitBitmap(src_bitmap, drawto, src_x, src_y, tilesize, tilesize, dst_x,dst_y);
}
int real_preview_xsize = MIN(level_xsize, preview.xsize);
int real_preview_ysize = MIN(level_ysize, preview.ysize);
int dst_x = SX + ALIGNED_XPOS(preview.x, preview_width, preview.align);
- int dst_y = SY + preview.y;
+ int dst_y = SY + ALIGNED_YPOS(preview.y, preview_height, preview.valign);
int x, y;
DrawBackground(dst_x, dst_y, preview_width, preview_height);
struct TextPosInfo *pos = &menu.main.text.level_info_2;
char label_text[MAX_OUTPUT_LINESIZE + 1];
int max_len_label_text;
+#if 1
+ int font_nr = pos->font;
+ int i;
+
+ if (mode == MICROLABEL_LEVEL_AUTHOR_HEAD ||
+ mode == MICROLABEL_IMPORTED_FROM_HEAD ||
+ mode == MICROLABEL_IMPORTED_BY_HEAD)
+ font_nr = pos->font_alt;
+#else
int font_nr = FONT_TEXT_2;
int i;
mode == MICROLABEL_IMPORTED_FROM_HEAD ||
mode == MICROLABEL_IMPORTED_BY_HEAD)
font_nr = FONT_TEXT_3;
+#endif
#if 1
max_len_label_text = getMaxTextLength(pos, font_nr);
#endif
#if 1
- if (pos->chars != -1)
- max_len_label_text = pos->chars;
+ if (pos->size != -1)
+ max_len_label_text = pos->size;
#endif
for (i = 0; i < max_len_label_text; i++)
int level_ysize = lev_fieldy + (show_level_border ? 2 : 0);
int last_game_status = game_status; /* save current game status */
+#if 0
/* force PREVIEW font on preview level */
game_status = GAME_MODE_PSEUDO_PREVIEW;
+#endif
if (restart)
{
{
struct TextPosInfo *pos = &menu.main.text.level_info_1;
char label_text[MAX_OUTPUT_LINESIZE + 1];
+#if 1
+ int font_nr = pos->font;
+#else
int font_nr = FONT_TEXT_1;
+#endif
#if 1
int max_len_label_text = getMaxTextLength(pos, font_nr);
#else
#endif
#if 1
- if (pos->chars != -1)
- max_len_label_text = pos->chars;
+ if (pos->size != -1)
+ max_len_label_text = pos->size;
#endif
strncpy(label_text, leveldir_current->name, max_len_label_text);
/* clear door drawing field */
DrawBackground(DX, DY, DXSIZE, DYSIZE);
- /* force DOOR font on preview level */
+ /* force DOOR font inside door area */
game_status = GAME_MODE_PSEUDO_DOOR;
/* write text for request */
case EVENT_KEYPRESS:
switch (GetEventKey((KeyEvent *)&event, TRUE))
{
+ case KSYM_space:
+ if (req_state & REQ_CONFIRM)
+ result = 1;
+ break;
+
case KSYM_Return:
result = 1;
break;
default:
break;
}
+
if (req_state & REQ_PLAYER)
result = 0;
break;
if (game_status == GAME_MODE_PLAYING && local_player->LevelSolved_GameEnd)
{
HandleGameActions();
- BackToFront();
}
else
{
Delay(10);
}
+ BackToFront();
+
#else
DoAnimation();
if (setup.quick_doors)
{
- stepsize = 20; /* must be choosen to always draw last frame */
+ stepsize = 20; /* must be chosen to always draw last frame */
door_delay_value = 0;
}
return element_info[element].special_graphic[GFX_SPECIAL_ARG_PREVIEW];
}
+int el2panelimg(int element)
+{
+ element = GFX_ELEMENT(element);
+
+ return element_info[element].special_graphic[GFX_SPECIAL_ARG_PANEL];
+}
+
int font2baseimg(int font_nr)
{
return font_info[font_nr].special_graphic[GFX_SPECIAL_ARG_DEFAULT];
}
+int getBeltNrFromBeltElement(int element)
+{
+ return (element < EL_CONVEYOR_BELT_2_LEFT ? 0 :
+ element < EL_CONVEYOR_BELT_3_LEFT ? 1 :
+ element < EL_CONVEYOR_BELT_4_LEFT ? 2 : 3);
+}
+
+int getBeltNrFromBeltActiveElement(int element)
+{
+ return (element < EL_CONVEYOR_BELT_2_LEFT_ACTIVE ? 0 :
+ element < EL_CONVEYOR_BELT_3_LEFT_ACTIVE ? 1 :
+ element < EL_CONVEYOR_BELT_4_LEFT_ACTIVE ? 2 : 3);
+}
+
+int getBeltNrFromBeltSwitchElement(int element)
+{
+ return (element < EL_CONVEYOR_BELT_2_SWITCH_LEFT ? 0 :
+ element < EL_CONVEYOR_BELT_3_SWITCH_LEFT ? 1 :
+ element < EL_CONVEYOR_BELT_4_SWITCH_LEFT ? 2 : 3);
+}
+
+int getBeltDirNrFromBeltElement(int element)
+{
+ static int belt_base_element[4] =
+ {
+ EL_CONVEYOR_BELT_1_LEFT,
+ EL_CONVEYOR_BELT_2_LEFT,
+ EL_CONVEYOR_BELT_3_LEFT,
+ EL_CONVEYOR_BELT_4_LEFT
+ };
+
+ int belt_nr = getBeltNrFromBeltElement(element);
+ int belt_dir_nr = element - belt_base_element[belt_nr];
+
+ return (belt_dir_nr % 3);
+}
+
+int getBeltDirNrFromBeltSwitchElement(int element)
+{
+ static int belt_base_element[4] =
+ {
+ EL_CONVEYOR_BELT_1_SWITCH_LEFT,
+ EL_CONVEYOR_BELT_2_SWITCH_LEFT,
+ EL_CONVEYOR_BELT_3_SWITCH_LEFT,
+ EL_CONVEYOR_BELT_4_SWITCH_LEFT
+ };
+
+ int belt_nr = getBeltNrFromBeltSwitchElement(element);
+ int belt_dir_nr = element - belt_base_element[belt_nr];
+
+ return (belt_dir_nr % 3);
+}
+
+int getBeltDirFromBeltElement(int element)
+{
+ static int belt_move_dir[3] =
+ {
+ MV_LEFT,
+ MV_NONE,
+ MV_RIGHT
+ };
+
+ int belt_dir_nr = getBeltDirNrFromBeltElement(element);
+
+ return belt_move_dir[belt_dir_nr];
+}
+
+int getBeltDirFromBeltSwitchElement(int element)
+{
+ static int belt_move_dir[3] =
+ {
+ MV_LEFT,
+ MV_NONE,
+ MV_RIGHT
+ };
+
+ int belt_dir_nr = getBeltDirNrFromBeltSwitchElement(element);
+
+ return belt_move_dir[belt_dir_nr];
+}
+
+int getBeltElementFromBeltNrAndBeltDirNr(int belt_nr, int belt_dir_nr)
+{
+ static int belt_base_element[4] =
+ {
+ EL_CONVEYOR_BELT_1_LEFT,
+ EL_CONVEYOR_BELT_2_LEFT,
+ EL_CONVEYOR_BELT_3_LEFT,
+ EL_CONVEYOR_BELT_4_LEFT
+ };
+
+ return belt_base_element[belt_nr] + belt_dir_nr;
+}
+
+int getBeltElementFromBeltNrAndBeltDir(int belt_nr, int belt_dir)
+{
+ int belt_dir_nr = (belt_dir == MV_LEFT ? 0 : belt_dir == MV_RIGHT ? 2 : 1);
+
+ return getBeltElementFromBeltNrAndBeltDirNr(belt_nr, belt_dir_nr);
+}
+
+int getBeltSwitchElementFromBeltNrAndBeltDirNr(int belt_nr, int belt_dir_nr)
+{
+ static int belt_base_element[4] =
+ {
+ EL_CONVEYOR_BELT_1_SWITCH_LEFT,
+ EL_CONVEYOR_BELT_2_SWITCH_LEFT,
+ EL_CONVEYOR_BELT_3_SWITCH_LEFT,
+ EL_CONVEYOR_BELT_4_SWITCH_LEFT
+ };
+
+ return belt_base_element[belt_nr] + belt_dir_nr;
+}
+
+int getBeltSwitchElementFromBeltNrAndBeltDir(int belt_nr, int belt_dir)
+{
+ int belt_dir_nr = (belt_dir == MV_LEFT ? 0 : belt_dir == MV_RIGHT ? 2 : 1);
+
+ return getBeltSwitchElementFromBeltNrAndBeltDirNr(belt_nr, belt_dir_nr);
+}
+
int getNumActivePlayers_EM()
{
int num_players = 0;
return InitEngineRandom_RND(seed);
}
+#if 1
+static struct Mapping_EM_to_RND_object object_mapping[TILE_MAX];
+static struct Mapping_EM_to_RND_player player_mapping[MAX_PLAYERS][SPR_MAX];
+#endif
+
+void ResetGfxAnimation_EM(int x, int y, int tile)
+{
+ GfxFrame[x][y] = 0;
+}
+
+void SetGfxAnimation_EM(int tile, int frame_em, int x, int y)
+{
+#if 0
+ int element = object_mapping[tile].element_rnd;
+#endif
+ int action = object_mapping[tile].action;
+ int direction = object_mapping[tile].direction;
+ boolean is_backside = object_mapping[tile].is_backside;
+ boolean action_removing = (action == ACTION_DIGGING ||
+ action == ACTION_SNAPPING ||
+ action == ACTION_COLLECTING);
+
+#if 0
+ printf("::: SET: %d, %d: '%s'\n", x, y, EL_NAME(element));
+#endif
+
+#if 1
+ if (action_removing)
+ {
+#if 0
+ printf("::: %d, %d: action_removing [%s]\n", x, y, EL_NAME(element));
+#endif
+
+ GfxFrame[x][y] = 7 - frame_em;
+ }
+ else if (action == ACTION_FALLING ||
+ action == ACTION_MOVING ||
+ action == ACTION_PUSHING ||
+ action == ACTION_EATING ||
+ action == ACTION_FILLING ||
+ action == ACTION_EMPTYING)
+ {
+ int move_dir =
+ (action == ACTION_FALLING ||
+ action == ACTION_FILLING ||
+ action == ACTION_EMPTYING ? MV_DOWN : direction);
+
+ if (is_backside)
+ {
+ GfxFrame[x][y]++;
+
+ if (move_dir == MV_LEFT)
+ GfxFrame[x - 1][y] = GfxFrame[x][y];
+ else if (move_dir == MV_RIGHT)
+ GfxFrame[x + 1][y] = GfxFrame[x][y];
+ else if (move_dir == MV_UP)
+ GfxFrame[x][y - 1] = GfxFrame[x][y];
+ else if (move_dir == MV_DOWN)
+ GfxFrame[x][y + 1] = GfxFrame[x][y];
+ }
+
+#if 0
+ printf("::: %d, %d: %s, %d, %d [%d]\n", x, y, EL_NAME(element), is_backside,
+ move_dir, GfxFrame[x][y]);
+#endif
+ }
+ else
+ GfxFrame[x][y]++;
+#else
+ GfxFrame[x][y] = 7 - frame_em;
+#endif
+}
+
+void getGraphicSourceObjectExt_EM(int tile, int frame_em,
+ Bitmap **src_bitmap, int *src_x, int *src_y,
+ int x, int y)
+{
+ int element = object_mapping[tile].element_rnd;
+ int action = object_mapping[tile].action;
+ int direction = object_mapping[tile].direction;
+ boolean is_backside = object_mapping[tile].is_backside;
+ boolean action_removing = (action == ACTION_DIGGING ||
+ action == ACTION_SNAPPING ||
+ action == ACTION_COLLECTING);
+ int effective_element = (frame_em > 0 ? element :
+ is_backside ? EL_EMPTY :
+ action_removing ? EL_EMPTY :
+ element);
+ int graphic = (direction == MV_NONE ?
+ el_act2img(effective_element, action) :
+ el_act_dir2img(effective_element, action, direction));
+ struct GraphicInfo *g = &graphic_info[graphic];
+ int sync_frame;
+
+#if 0
+ printf("::: GET: %d, %d: '%s'\n", x, y, EL_NAME(element));
+#endif
+
+#if 0
+ if (GfxFrame[x][y] < 8)
+ printf("::: %d, %d: %d [%s]\n", x, y, GfxFrame[x][y], EL_NAME(element));
+#endif
+
+#if 1
+ if (graphic_info[graphic].anim_global_sync)
+ sync_frame = FrameCounter;
+ else if (IN_FIELD(x, y, MAX_LEV_FIELDX, MAX_LEV_FIELDY))
+ sync_frame = GfxFrame[x][y];
+ else
+ sync_frame = 0; /* steel border */
+#else
+ if (graphic_info[graphic].anim_global_sync)
+ sync_frame = FrameCounter;
+ else
+ sync_frame = 7 - frame_em;
+#endif
+
+ SetRandomAnimationValue(x, y);
+
+ int frame = getAnimationFrame(g->anim_frames,
+ g->anim_delay,
+ g->anim_mode,
+ g->anim_start_frame,
+ sync_frame);
+
+ getGraphicSourceExt(graphic, frame, src_bitmap, src_x, src_y, FALSE);
+}
+
+void getGraphicSourcePlayerExt_EM(int player_nr, int anim, int frame_em,
+ Bitmap **src_bitmap, int *src_x, int *src_y)
+{
+ int element = player_mapping[player_nr][anim].element_rnd;
+ int action = player_mapping[player_nr][anim].action;
+ int direction = player_mapping[player_nr][anim].direction;
+ int graphic = (direction == MV_NONE ?
+ el_act2img(element, action) :
+ el_act_dir2img(element, action, direction));
+ struct GraphicInfo *g = &graphic_info[graphic];
+ int sync_frame;
+
+ InitPlayerGfxAnimation(&stored_player[player_nr], action, direction);
+
+ stored_player[player_nr].StepFrame = 7 - frame_em;
+
+ sync_frame = stored_player[player_nr].Frame;
+
+#if 0
+ printf("::: %d: %d, %d [%d]\n",
+ player_nr,
+ stored_player[player_nr].Frame,
+ stored_player[player_nr].StepFrame,
+ FrameCounter);
+#endif
+
+ int frame = getAnimationFrame(g->anim_frames,
+ g->anim_delay,
+ g->anim_mode,
+ g->anim_start_frame,
+ sync_frame);
+
+ getGraphicSourceExt(graphic, frame, src_bitmap, src_x, src_y, FALSE);
+}
+
void InitGraphicInfo_EM(void)
{
+#if 0
struct Mapping_EM_to_RND_object object_mapping[TILE_MAX];
struct Mapping_EM_to_RND_player player_mapping[MAX_PLAYERS][SPR_MAX];
+#endif
int i, j, p;
#if DEBUG_EM_GFX
g->anim_start_frame,
sync_frame);
- getGraphicSourceExt(graphic, frame, &src_bitmap, &src_x,&src_y, FALSE);
+ getGraphicSourceExt(graphic, frame, &src_bitmap, &src_x, &src_y, FALSE);
g_em->bitmap = src_bitmap;
g_em->src_x = src_x;
#endif
}
-void PlayMenuSound()
+void PlayMenuSoundExt(int sound)
{
- int sound = menu.sound[game_status];
-
if (sound == SND_UNDEFINED)
return;
PlaySound(sound);
}
+void PlayMenuSound()
+{
+ PlayMenuSoundExt(menu.sound[game_status]);
+}
+
void PlayMenuSoundStereo(int sound, int stereo_position)
{
if (sound == SND_UNDEFINED)
PlaySoundStereo(sound, stereo_position);
}
-void PlayMenuSoundIfLoop()
+void PlayMenuSoundIfLoopExt(int sound)
{
- int sound = menu.sound[game_status];
-
if (sound == SND_UNDEFINED)
return;
PlaySoundLoop(sound);
}
-void PlayMenuMusic()
+void PlayMenuSoundIfLoop()
{
- int music = menu.music[game_status];
+ PlayMenuSoundIfLoopExt(menu.sound[game_status]);
+}
+void PlayMenuMusicExt(int music)
+{
if (music == MUS_UNDEFINED)
return;
PlayMusic(music);
}
+void PlayMenuMusic()
+{
+ PlayMenuMusicExt(menu.music[game_status]);
+}
+
void PlaySoundActivating()
{
#if 0