#define NUM_TOOL_BUTTONS 7
+/* constants for number of doors and door parts */
+#define NUM_DOORS 2
+#define MAX_NUM_DOOR_PARTS 8
+
+
+struct DoorPartOrderInfo
+{
+ int nr;
+ int sort_priority;
+};
+
+static struct DoorPartOrderInfo door_part_order[NUM_DOORS * MAX_NUM_DOOR_PARTS];
+
+struct DoorPartControlInfo
+{
+ int door_nr;
+ int graphic;
+ struct TextPosInfo *pos;
+};
+
+static struct DoorPartControlInfo door_part_controls[] =
+{
+ {
+ DOOR_1,
+ IMG_DOOR_1_GFX_PART_1,
+ &door_1.part_1
+ },
+ {
+ DOOR_1,
+ IMG_DOOR_1_GFX_PART_2,
+ &door_1.part_2
+ },
+ {
+ DOOR_1,
+ IMG_DOOR_1_GFX_PART_3,
+ &door_1.part_3
+ },
+ {
+ DOOR_1,
+ IMG_DOOR_1_GFX_PART_4,
+ &door_1.part_4
+ },
+ {
+ DOOR_1,
+ IMG_DOOR_1_GFX_PART_5,
+ &door_1.part_5
+ },
+ {
+ DOOR_1,
+ IMG_DOOR_1_GFX_PART_6,
+ &door_1.part_6
+ },
+ {
+ DOOR_1,
+ IMG_DOOR_1_GFX_PART_7,
+ &door_1.part_7
+ },
+ {
+ DOOR_1,
+ IMG_DOOR_1_GFX_PART_8,
+ &door_1.part_8
+ },
+ {
+ DOOR_2,
+ IMG_DOOR_2_GFX_PART_1,
+ &door_2.part_1
+ },
+ {
+ DOOR_2,
+ IMG_DOOR_2_GFX_PART_2,
+ &door_2.part_2
+ },
+ {
+ DOOR_2,
+ IMG_DOOR_2_GFX_PART_3,
+ &door_2.part_3
+ },
+ {
+ DOOR_2,
+ IMG_DOOR_2_GFX_PART_4,
+ &door_2.part_4
+ },
+ {
+ DOOR_2,
+ IMG_DOOR_2_GFX_PART_5,
+ &door_2.part_5
+ },
+ {
+ DOOR_2,
+ IMG_DOOR_2_GFX_PART_6,
+ &door_2.part_6
+ },
+ {
+ DOOR_2,
+ IMG_DOOR_2_GFX_PART_7,
+ &door_2.part_7
+ },
+ {
+ DOOR_2,
+ IMG_DOOR_2_GFX_PART_8,
+ &door_2.part_8
+ },
+
+ {
+ -1,
+ -1,
+ NULL
+ }
+};
+
+
/* forward declaration for internal use */
static void UnmapToolButtons();
static void HandleToolButtons(struct GadgetInfo *);
#endif
#if 1
+
+#if 1
+ if (IN_GFX_FIELD_FULL(x, y))
+ redraw_mask |= REDRAW_FIELD;
+ else if (IN_GFX_DOOR_1(x, y))
+ redraw_mask |= REDRAW_DOOR_1;
+ else if (IN_GFX_DOOR_2(x, y))
+ redraw_mask |= REDRAW_DOOR_2;
+ else if (IN_GFX_DOOR_3(x, y))
+ redraw_mask |= REDRAW_DOOR_3;
+#else
/* (this only works for the current arrangement of playfield and panels) */
if (x < gfx.dx)
redraw_mask |= REDRAW_FIELD;
redraw_mask |= REDRAW_DOOR_1;
else
redraw_mask |= REDRAW_DOOR_2;
+#endif
+
#else
/* (this is just wrong (when drawing to one of the two door panel areas)) */
redraw_mask |= REDRAW_FIELD;
#endif
+static int compareDoorPartOrderInfo(const void *object1, const void *object2)
+{
+ const struct DoorPartOrderInfo *dpo1 = (struct DoorPartOrderInfo *)object1;
+ const struct DoorPartOrderInfo *dpo2 = (struct DoorPartOrderInfo *)object2;
+ int compare_result;
+
+ if (dpo1->sort_priority != dpo2->sort_priority)
+ compare_result = dpo1->sort_priority - dpo2->sort_priority;
+ else
+ compare_result = dpo1->nr - dpo2->nr;
+
+ return compare_result;
+}
+
+void InitDoors()
+{
+ int i;
+
+ for (i = 0; door_part_controls[i].door_nr != -1; i++)
+ {
+ struct DoorPartControlInfo *dpc = &door_part_controls[i];
+ struct DoorPartOrderInfo *dpo = &door_part_order[i];
+
+ /* fill structure for door part draw order */
+ dpo->nr = i;
+ dpo->sort_priority = dpc->pos->sort_priority;
+ }
+
+ /* sort door part controls according to sort_priority and graphic number */
+ qsort(door_part_order, NUM_DOORS * MAX_NUM_DOOR_PARTS,
+ sizeof(struct DoorPartOrderInfo), compareDoorPartOrderInfo);
+}
+
unsigned int OpenDoor(unsigned int door_state)
{
if (door_state & DOOR_COPY_BACK)
return MoveDoor(door_state | DOOR_SET_STATE);
}
+#if 1
+
+// ========== TEST 1 ===========================================================
+
unsigned int MoveDoor(unsigned int door_state)
{
static int door1 = DOOR_OPEN_1;
static int door2 = DOOR_CLOSE_2;
+#if 0
unsigned int door_delay = 0;
unsigned int door_delay_value;
int stepsize = 1;
+#endif
+ int i, j;
+
+#if 1
+ if (door_1.width < 0 || door_1.width > DXSIZE)
+ door_1.width = DXSIZE;
+ if (door_1.height < 0 || door_1.height > DYSIZE)
+ door_1.height = DYSIZE;
+ if (door_2.width < 0 || door_2.width > VXSIZE)
+ door_2.width = VXSIZE;
+ if (door_2.height < 0 || door_2.height > VYSIZE)
+ door_2.height = VYSIZE;
+#endif
+
+ if (door_state == DOOR_GET_STATE)
+ return (door1 | door2);
+
+ if (door_state & DOOR_SET_STATE)
+ {
+ if (door_state & DOOR_ACTION_1)
+ door1 = door_state & DOOR_ACTION_1;
+ if (door_state & DOOR_ACTION_2)
+ door2 = door_state & DOOR_ACTION_2;
+
+ return (door1 | door2);
+ }
+
+ if (!(door_state & DOOR_FORCE_REDRAW))
+ {
+ if (door1 == DOOR_OPEN_1 && door_state & DOOR_OPEN_1)
+ door_state &= ~DOOR_OPEN_1;
+ else if (door1 == DOOR_CLOSE_1 && door_state & DOOR_CLOSE_1)
+ door_state &= ~DOOR_CLOSE_1;
+ if (door2 == DOOR_OPEN_2 && door_state & DOOR_OPEN_2)
+ door_state &= ~DOOR_OPEN_2;
+ else if (door2 == DOOR_CLOSE_2 && door_state & DOOR_CLOSE_2)
+ door_state &= ~DOOR_CLOSE_2;
+ }
#if 0
+ door_delay_value = (door_state & DOOR_ACTION_1 ? door_1.step_delay :
+ door_2.step_delay);
+
+ if (setup.quick_doors)
+ {
+ stepsize = 20; /* must be chosen to always draw last frame */
+ door_delay_value = 0;
+ }
+#endif
+
+ if (global.autoplay_leveldir)
+ {
+ door_state |= DOOR_NO_DELAY;
+ door_state &= ~DOOR_CLOSE_ALL;
+ }
+
+#if 1
+ if (game_status == GAME_MODE_EDITOR)
+ door_state |= DOOR_NO_DELAY;
+#endif
+
+ if (door_state & DOOR_ACTION)
+ {
+ for (i = 0; i < NUM_DOORS * MAX_NUM_DOOR_PARTS; i++)
+ {
+ int nr = door_part_order[i].nr;
+ struct DoorPartControlInfo *dpc = &door_part_controls[nr];
+ int door_token = dpc->door_nr;
+ int door_index = DOOR_INDEX_FROM_TOKEN(door_token);
+ int graphic = dpc->graphic;
+ struct GraphicInfo *g = &graphic_info[graphic];
+ struct TextPosInfo *pos = dpc->pos;
+ int panel_src_x, panel_src_y;
+ int dx, dy, dxsize, dysize;
+ static boolean door_panel_drawn[NUM_DOORS];
+
+ if (i == 0)
+ for (j = 0; j < NUM_DOORS; j++)
+ door_panel_drawn[j] = FALSE;
+
+ if (door_token == DOOR_1)
+ {
+ panel_src_x = DOOR_GFX_PAGEX1;
+ panel_src_y = DOOR_GFX_PAGEY1;
+ dx = DX;
+ dy = DY;
+ dxsize = DXSIZE;
+ dysize = DYSIZE;
+ }
+ else // DOOR_2
+ {
+ panel_src_x = DOOR_GFX_PAGEX1;
+ panel_src_y = DOOR_GFX_PAGEY2;
+ dx = VX;
+ dy = VY;
+ dxsize = VXSIZE;
+ dysize = VYSIZE;
+ }
+
+ if (!(door_state & door_token))
+ continue;
+
+ if (!g->bitmap)
+ continue;
+
+ if (!door_panel_drawn[door_index])
+ {
+ BlitBitmap(bitmap_db_door, drawto, panel_src_x, panel_src_y,
+ dxsize, dysize, dx, dy);
+
+ door_panel_drawn[door_index] = TRUE;
+ }
+
+#if 1
+ // !!! TEST !!!
+ if (!((door_state & door_token) & DOOR_CLOSE))
+ continue;
+#endif
+
+ BlitBitmapMasked(g->bitmap, drawto, g->src_x, g->src_y,
+ g->width, g->height, dx + pos->x, dy + pos->y);
+
+ redraw_mask |= REDRAW_DOOR_FROM_TOKEN(door_token);
+ }
+ }
+
+ redraw_mask |= REDRAW_ALL;
+
+ if (door_state & DOOR_ACTION_1)
+ door1 = door_state & DOOR_ACTION_1;
+ if (door_state & DOOR_ACTION_2)
+ door2 = door_state & DOOR_ACTION_2;
+
+ return (door1 | door2);
+}
+
+#else
+
+// ========== OLD ==============================================================
+
+unsigned int MoveDoor(unsigned int door_state)
+{
+ static int door1 = DOOR_OPEN_1;
+ static int door2 = DOOR_CLOSE_2;
+ unsigned int door_delay = 0;
+ unsigned int door_delay_value;
+ int stepsize = 1;
+
+#if 1
if (door_1.width < 0 || door_1.width > DXSIZE)
door_1.width = DXSIZE;
if (door_1.height < 0 || door_1.height > DYSIZE)
if (door_state & DOOR_ACTION)
{
+#if 1
+ struct GraphicInfo *g1_left = &graphic_info[IMG_DOOR_1_WING_LEFT];
+ struct GraphicInfo *g1_right = &graphic_info[IMG_DOOR_1_WING_RIGHT];
+ struct GraphicInfo *g2_left = &graphic_info[IMG_DOOR_2_WING_LEFT];
+ struct GraphicInfo *g2_right = &graphic_info[IMG_DOOR_2_WING_RIGHT];
+ int door_1_left_width = g1_left->width;
+ int door_1_left_height = g1_left->height;
+ int door_1_right_width = g1_right->width;
+ int door_1_right_height = g1_right->height;
+ int door_2_left_width = g2_left->width;
+ int door_2_left_height = g2_left->height;
+ int door_2_right_width = g2_right->width;
+ int door_2_right_height = g2_right->height;
+ int door_1_width = MAX(door_1_left_width, door_1_right_width);
+ int door_1_height = MAX(door_1_left_height, door_1_right_height);
+ int door_2_width = MAX(door_2_left_width, door_2_right_width);
+ int door_2_height = MAX(door_2_left_height, door_2_right_height);
+#endif
boolean handle_door_1 = (door_state & DOOR_ACTION_1);
boolean handle_door_2 = (door_state & DOOR_ACTION_2);
boolean door_1_done = (!handle_door_1);
boolean door_1_vertical = (door_1.anim_mode & ANIM_VERTICAL);
boolean door_2_vertical = (door_2.anim_mode & ANIM_VERTICAL);
#if 1
+#if 1
+ int door_size_1 = (door_1_vertical ? door_1_height : door_1_width);
+ int door_size_2 = (door_2_vertical ? door_2_height : door_2_width);
+#else
int door_size_1 = (door_1_vertical ? DYSIZE : DXSIZE);
int door_size_2 = (door_2_vertical ? VYSIZE : VXSIZE);
+#endif
#else
int door_size_1 = (door_1_vertical ? door_1.height : door_1.width);
int door_size_2 = (door_2_vertical ? door_2.height : door_2.width);
#endif
int max_door_size_1 = (door_1_vertical ? DYSIZE : DXSIZE);
int max_door_size_2 = (door_2_vertical ? VYSIZE : VXSIZE);
- int door_size = (handle_door_1 ? door_size_1 : door_size_2);
+ // int door_size = (handle_door_1 ? door_size_1 : door_size_2);
+ int door_size = (handle_door_2 ? door_size_2 : door_size_1);
int max_door_size = (handle_door_1 ? max_door_size_1 : max_door_size_2);
int door_skip = max_door_size - door_size;
int end = door_size;
for (k = start; k <= end && !(door_1_done && door_2_done); k += stepsize)
{
int x = k;
-#if 1
+#if 0
Bitmap *bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
GC gc = bitmap->stored_clip_gc;
#endif
- if (door_state & DOOR_ACTION_1)
+ if (door_state & DOOR_ACTION_1 &&
+ x * door_1.step_offset <= door_size_1)
{
int a = MIN(x * door_1.step_offset, end);
int p = (door_state & DOOR_OPEN_1 ? end - a : a);
+#if 1
+ int i = p;
+#else
int i = p + door_skip;
+#endif
#if 1
struct GraphicInfo *g_left = &graphic_info[IMG_DOOR_1_WING_LEFT];
GC gc_right = bm_right->stored_clip_gc;
#endif
+ int classic_dxsize = 100;
+ int classic_dysize = 280;
+ boolean classic_door_1_size = (DXSIZE == classic_dxsize &&
+ DYSIZE == classic_dysize);
+
if (door_1.anim_mode & ANIM_STATIC_PANEL)
{
BlitBitmap(bitmap_db_door, drawto,
DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1 + p / 2,
DXSIZE, DYSIZE - p / 2, DX, DY);
+#if 1
+ // printf("::: p == %d\n", p);
ClearRectangle(drawto, DX, DY + DYSIZE - p / 2, DXSIZE, p / 2);
+#endif
}
if (door_1.anim_mode & ANIM_HORIZONTAL && x <= DXSIZE)
dst2_x, dst2_y);
#endif
}
- else if (x <= DXSIZE) /* ANIM_DEFAULT */
+ else if (classic_door_1_size && x <= DXSIZE) /* ANIM_DEFAULT */
{
int j = (door_1.anim_mode == ANIM_DEFAULT ? (DXSIZE - i) / 3 : 0);
int ypos1 = 0, ypos2 = height2;
int ypos3 = DYSIZE / 2, ypos4 = DYSIZE - height2;
- SetClipOrigin(bitmap, gc, dst1_x - src1_x, dst1_y - src1_y + j);
- BlitBitmapMasked(bitmap, drawto,
+ SetClipOrigin(bm_right, gc_right,
+ dst1_x - src1_x, dst1_y - src1_y + j);
+ BlitBitmapMasked(bm_right, drawto,
src1_x, src1_y + ypos1, width, height2,
dst1_x, dst1_y + ypos1 + j);
- BlitBitmapMasked(bitmap, drawto,
+ BlitBitmapMasked(bm_right, drawto,
src1_x, src1_y + ypos3, width, height1,
dst1_x, dst1_y + ypos3 + j);
- SetClipOrigin(bitmap, gc, dst2_x - src2_x, dst2_y - src2_y - j);
- BlitBitmapMasked(bitmap, drawto,
+ SetClipOrigin(bm_left, gc_left,
+ dst2_x - src2_x, dst2_y - src2_y - j);
+ BlitBitmapMasked(bm_left, drawto,
src2_x, src2_y + ypos1 + j, width, height2 - j,
dst2_x, dst2_y + ypos1);
- BlitBitmapMasked(bitmap, drawto,
+ BlitBitmapMasked(bm_left, drawto,
src2_x, src2_y + ypos3, width, height1,
dst2_x, dst2_y + ypos3 - j);
- SetClipOrigin(bitmap, gc, dst2_x - src2_x, dst2_y - src2_y - j);
- BlitBitmapMasked(bitmap, drawto,
+ SetClipOrigin(bm_left, gc_left,
+ dst2_x - src2_x, dst2_y - src2_y - j);
+ BlitBitmapMasked(bm_left, drawto,
src2_x, src2_y + ypos2, width, height1,
dst2_x, dst2_y + ypos2 - j);
- BlitBitmapMasked(bitmap, drawto,
+ BlitBitmapMasked(bm_left, drawto,
src2_x, src2_y + ypos4, width, height2,
dst2_x, dst2_y + ypos4 - j);
- SetClipOrigin(bitmap, gc, dst1_x - src1_x, dst1_y - src1_y + j);
- BlitBitmapMasked(bitmap, drawto,
+ SetClipOrigin(bm_right, gc_right,
+ dst1_x - src1_x, dst1_y - src1_y + j);
+ BlitBitmapMasked(bm_right, drawto,
src1_x, src1_y + ypos2, width, height1,
dst1_x, dst1_y + ypos2 + j);
- BlitBitmapMasked(bitmap, drawto,
+ BlitBitmapMasked(bm_right, drawto,
src1_x, src1_y + ypos4, width, height2 - j,
dst1_x, dst1_y + ypos4 + j);
+
#else
int src1_x = DXSIZE, src1_y = DOOR_GFX_PAGEY1;
int src2_x = DXSIZE - i, src2_y = DOOR_GFX_PAGEY1;
door_1_done = (a == end);
}
- if (door_state & DOOR_ACTION_2)
+ if (door_state & DOOR_ACTION_2 &&
+ x * door_2.step_offset <= door_size_2)
{
int a = MIN(x * door_2.step_offset, door_size);
int p = (door_state & DOOR_OPEN_2 ? door_size - a : a);
GC gc_right = bm_right->stored_clip_gc;
#endif
+ int classic_vxsize = 100;
+ int classic_vysize = 100;
+ boolean classic_door_2_size = (VXSIZE == classic_vxsize &&
+ VYSIZE == classic_vysize);
+
if (door_2.anim_mode & ANIM_STATIC_PANEL)
{
BlitBitmap(bitmap_db_door, drawto,
dst2_x, dst2_y);
#endif
}
- else if (x <= VXSIZE) /* ANIM_DEFAULT */
+ else if (classic_door_2_size && x <= VXSIZE) /* ANIM_DEFAULT */
{
int j = (door_2.anim_mode == ANIM_DEFAULT ? (VXSIZE - i) / 3 : 0);
int height = VYSIZE / 2;
int ypos1 = 0, ypos2 = VYSIZE / 2;
- SetClipOrigin(bitmap, gc, dst1_x - src1_x, dst1_y - src1_y + j);
- BlitBitmapMasked(bitmap, drawto,
+ SetClipOrigin(bm_right, gc_right,
+ dst1_x - src1_x, dst1_y - src1_y + j);
+ BlitBitmapMasked(bm_right, drawto,
src1_x, src1_y + ypos1, width, height,
dst1_x, dst1_y + ypos1 + j);
- SetClipOrigin(bitmap, gc, dst2_x - src2_x, dst2_y - src2_y - j);
- BlitBitmapMasked(bitmap, drawto,
+ SetClipOrigin(bm_left, gc_left,
+ dst2_x - src2_x, dst2_y - src2_y - j);
+ BlitBitmapMasked(bm_left, drawto,
src2_x, src2_y + ypos1 + j, width, height - j,
dst2_x, dst2_y + ypos1);
- SetClipOrigin(bitmap, gc, dst2_x - src2_x, dst2_y - src2_y - j);
- BlitBitmapMasked(bitmap, drawto,
+ SetClipOrigin(bm_left, gc_left,
+ dst2_x - src2_x, dst2_y - src2_y - j);
+ BlitBitmapMasked(bm_left, drawto,
src2_x, src2_y + ypos2, width, height,
dst2_x, dst2_y + ypos2 - j);
- SetClipOrigin(bitmap, gc, dst1_x - src1_x, dst1_y - src1_y + j);
- BlitBitmapMasked(bitmap, drawto,
+ SetClipOrigin(bm_right, gc_right,
+ dst1_x - src1_x, dst1_y - src1_y + j);
+ BlitBitmapMasked(bm_right, drawto,
src1_x, src1_y + ypos2, width, height - j,
dst1_x, dst1_y + ypos2 + j);
#else
return (door1 | door2);
}
+#endif
+
void DrawSpecialEditorDoor()
{
#if 1
return getBeltSwitchElementFromBeltNrAndBeltDirNr(belt_nr, belt_dir_nr);
}
+#if 1
+boolean getTeamMode_EM()
+{
+ return game.team_mode;
+}
+#else
int getNumActivePlayers_EM()
{
+#if 1
int num_players = 0;
int i;
+ if (!tape.playing)
+ return (setup.team_mode ? MAX_PLAYERS : 1);
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ if (tape.player_participates[i])
+ num_players++;
+
+ return (num_players > 1 ? MAX_PLAYERS : 1);
+
+#else
+
+ int num_players = 0;
+ int i;
+
+ /* when recording game, activate all connected players */
if (!tape.playing)
return -1;
num_players++;
return num_players;
+#endif
}
+#endif
int getGameFrameDelay_EM(int native_em_game_frame_delay)
{