From f58e776feec767136f4a8f4b62e0103d13c0a910 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 24 Feb 2014 17:50:31 +0100 Subject: [PATCH] rnd-20140224-1-src --- src/conf_gfx.c | 132 ++++++++++++++++++ src/conf_gfx.h | 30 ++++- src/conf_var.c | 256 +++++++++++++++++++++++++++++++++++ src/conftime.h | 2 +- src/events.c | 2 +- src/init.c | 2 + src/libgame/system.h | 2 +- src/main.h | 9 ++ src/tools.c | 311 +++++++++++++++++++++++++++++++++++++++++++ src/tools.h | 22 +++ 10 files changed, 758 insertions(+), 10 deletions(-) diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 12da9382..b0065b9e 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -5324,6 +5324,72 @@ struct ConfigInfo image_config[] = { "titlescreen_4", UNDEFINED_FILENAME }, { "titlescreen_5", UNDEFINED_FILENAME }, + { "door_1.gfx.part_1", "RocksDoor.png" }, + { "door_1.gfx.part_1.x", "0" }, + { "door_1.gfx.part_1.y", "0" }, + { "door_1.gfx.part_1.width", "100" }, + { "door_1.gfx.part_1.height", "77" }, + { "door_1.gfx.part_2", "RocksDoor.png" }, + { "door_1.gfx.part_2.x", "0" }, + { "door_1.gfx.part_2.y", "77" }, + { "door_1.gfx.part_2.width", "100" }, + { "door_1.gfx.part_2.height", "63" }, + { "door_1.gfx.part_3", "RocksDoor.png" }, + { "door_1.gfx.part_3.x", "0" }, + { "door_1.gfx.part_3.y", "140" }, + { "door_1.gfx.part_3.width", "100" }, + { "door_1.gfx.part_3.height", "63" }, + { "door_1.gfx.part_4", "RocksDoor.png" }, + { "door_1.gfx.part_4.x", "0" }, + { "door_1.gfx.part_4.y", "203" }, + { "door_1.gfx.part_4.width", "100" }, + { "door_1.gfx.part_4.height", "77" }, + { "door_1.gfx.part_5", "RocksDoor.png" }, + { "door_1.gfx.part_5.x", "100" }, + { "door_1.gfx.part_5.y", "0" }, + { "door_1.gfx.part_5.width", "100" }, + { "door_1.gfx.part_5.height", "77" }, + { "door_1.gfx.part_6", "RocksDoor.png" }, + { "door_1.gfx.part_6.x", "100" }, + { "door_1.gfx.part_6.y", "77" }, + { "door_1.gfx.part_6.width", "100" }, + { "door_1.gfx.part_6.height", "63" }, + { "door_1.gfx.part_7", "RocksDoor.png" }, + { "door_1.gfx.part_7.x", "100" }, + { "door_1.gfx.part_7.y", "140" }, + { "door_1.gfx.part_7.width", "100" }, + { "door_1.gfx.part_7.height", "63" }, + { "door_1.gfx.part_8", "RocksDoor.png" }, + { "door_1.gfx.part_8.x", "100" }, + { "door_1.gfx.part_8.y", "203" }, + { "door_1.gfx.part_8.width", "100" }, + { "door_1.gfx.part_8.height", "77" }, + + { "door_2.gfx.part_1", "RocksDoor.png" }, + { "door_2.gfx.part_1.x", "0" }, + { "door_2.gfx.part_1.y", "280" }, + { "door_2.gfx.part_1.width", "100" }, + { "door_2.gfx.part_1.height", "50" }, + { "door_2.gfx.part_2", "RocksDoor.png" }, + { "door_2.gfx.part_2.x", "0" }, + { "door_2.gfx.part_2.y", "330" }, + { "door_2.gfx.part_2.width", "100" }, + { "door_2.gfx.part_2.height", "50" }, + { "door_2.gfx.part_3", "RocksDoor.png" }, + { "door_2.gfx.part_3.x", "100" }, + { "door_2.gfx.part_3.y", "280" }, + { "door_2.gfx.part_3.width", "100" }, + { "door_2.gfx.part_3.height", "50" }, + { "door_2.gfx.part_4", "RocksDoor.png" }, + { "door_2.gfx.part_4.x", "100" }, + { "door_2.gfx.part_4.y", "330" }, + { "door_2.gfx.part_4.width", "100" }, + { "door_2.gfx.part_4.height", "50" }, + { "door_2.gfx.part_5", UNDEFINED_FILENAME }, + { "door_2.gfx.part_6", UNDEFINED_FILENAME }, + { "door_2.gfx.part_7", UNDEFINED_FILENAME }, + { "door_2.gfx.part_8", UNDEFINED_FILENAME }, + { "door_1.wing_left", "RocksDoor.png" }, { "door_1.wing_left.x", "0" }, { "door_1.wing_left.y", "0" }, @@ -5902,6 +5968,72 @@ struct ConfigInfo image_config[] = { "preview.step_delay", "50" }, { "preview.anim_mode", "default" }, + { "door_1.part_1.x", "0" }, + { "door_1.part_1.y", "0" }, + { "door_1.part_1.draw_masked", "true" }, + { "door_1.part_1.draw_order", "3" }, + { "door_1.part_2.x", "0" }, + { "door_1.part_2.y", "77" }, + { "door_1.part_2.draw_masked", "true" }, + { "door_1.part_2.draw_order", "5" }, + { "door_1.part_3.x", "0" }, + { "door_1.part_3.y", "140" }, + { "door_1.part_3.draw_masked", "true" }, + { "door_1.part_3.draw_order", "4" }, + { "door_1.part_4.x", "0" }, + { "door_1.part_4.y", "203" }, + { "door_1.part_4.draw_masked", "true" }, + { "door_1.part_4.draw_order", "6" }, + { "door_1.part_5.x", "0" }, + { "door_1.part_5.y", "0" }, + { "door_1.part_5.draw_masked", "true" }, + { "door_1.part_5.draw_order", "1" }, + { "door_1.part_6.x", "0" }, + { "door_1.part_6.y", "77" }, + { "door_1.part_6.draw_masked", "true" }, + { "door_1.part_6.draw_order", "7" }, + { "door_1.part_7.x", "0" }, + { "door_1.part_7.y", "140" }, + { "door_1.part_7.draw_masked", "true" }, + { "door_1.part_7.draw_order", "2" }, + { "door_1.part_8.x", "0" }, + { "door_1.part_8.y", "203" }, + { "door_1.part_8.draw_masked", "true" }, + { "door_1.part_8.draw_order", "8" }, + + { "door_2.part_1.x", "0" }, + { "door_2.part_1.y", "0" }, + { "door_2.part_1.draw_masked", "true" }, + { "door_2.part_1.draw_order", "2" }, + { "door_2.part_2.x", "0" }, + { "door_2.part_2.y", "50" }, + { "door_2.part_2.draw_masked", "true" }, + { "door_2.part_2.draw_order", "3" }, + { "door_2.part_3.x", "0" }, + { "door_2.part_3.y", "0" }, + { "door_2.part_3.draw_masked", "true" }, + { "door_2.part_3.draw_order", "1" }, + { "door_2.part_4.x", "0" }, + { "door_2.part_4.y", "50" }, + { "door_2.part_4.draw_masked", "true" }, + { "door_2.part_4.draw_order", "4" }, + { "door_2.part_5.x", "-1" }, + { "door_2.part_5.y", "-1" }, + { "door_2.part_5.draw_masked", "true" }, + { "door_2.part_5.draw_order", "0" }, + { "door_2.part_6.x", "-1" }, + { "door_2.part_6.y", "-1" }, + { "door_2.part_6.draw_masked", "true" }, + { "door_2.part_6.draw_order", "0" }, + { "door_2.part_7.x", "-1" }, + { "door_2.part_7.y", "-1" }, + { "door_2.part_7.draw_masked", "true" }, + { "door_2.part_7.draw_order", "0" }, + { "door_2.part_8.x", "-1" }, + { "door_2.part_8.y", "-1" }, + { "door_2.part_8.draw_masked", "true" }, + { "door_2.part_8.draw_order", "0" }, + { "door_1.width", "-1" }, { "door_1.height", "-1" }, { "door_1.step_offset", "2" }, diff --git a/src/conf_gfx.h b/src/conf_gfx.h index 015040f9..a2970b37 100644 --- a/src/conf_gfx.h +++ b/src/conf_gfx.h @@ -1868,13 +1868,29 @@ #define IMG_TITLESCREEN_3 1847 #define IMG_TITLESCREEN_4 1848 #define IMG_TITLESCREEN_5 1849 -#define IMG_DOOR_1_WING_LEFT 1850 -#define IMG_DOOR_1_WING_RIGHT 1851 -#define IMG_DOOR_2_WING_LEFT 1852 -#define IMG_DOOR_2_WING_RIGHT 1853 -#define IMG_DOOR_2_TOP_BORDER_CORRECTION 1854 -#define IMG_LAST_IMAGE_ENTRY_BUG 1855 +#define IMG_DOOR_1_GFX_PART_1 1850 +#define IMG_DOOR_1_GFX_PART_2 1851 +#define IMG_DOOR_1_GFX_PART_3 1852 +#define IMG_DOOR_1_GFX_PART_4 1853 +#define IMG_DOOR_1_GFX_PART_5 1854 +#define IMG_DOOR_1_GFX_PART_6 1855 +#define IMG_DOOR_1_GFX_PART_7 1856 +#define IMG_DOOR_1_GFX_PART_8 1857 +#define IMG_DOOR_2_GFX_PART_1 1858 +#define IMG_DOOR_2_GFX_PART_2 1859 +#define IMG_DOOR_2_GFX_PART_3 1860 +#define IMG_DOOR_2_GFX_PART_4 1861 +#define IMG_DOOR_2_GFX_PART_5 1862 +#define IMG_DOOR_2_GFX_PART_6 1863 +#define IMG_DOOR_2_GFX_PART_7 1864 +#define IMG_DOOR_2_GFX_PART_8 1865 +#define IMG_DOOR_1_WING_LEFT 1866 +#define IMG_DOOR_1_WING_RIGHT 1867 +#define IMG_DOOR_2_WING_LEFT 1868 +#define IMG_DOOR_2_WING_RIGHT 1869 +#define IMG_DOOR_2_TOP_BORDER_CORRECTION 1870 +#define IMG_LAST_IMAGE_ENTRY_BUG 1871 -#define NUM_IMAGE_FILES 1856 +#define NUM_IMAGE_FILES 1872 #endif /* CONF_GFX_H */ diff --git a/src/conf_var.c b/src/conf_var.c index 0c543d8a..7089c113 100644 --- a/src/conf_var.c +++ b/src/conf_var.c @@ -2092,6 +2092,262 @@ struct TokenIntPtrInfo image_config_vars[] = "preview.anim_mode", &preview.anim_mode }, + { + "door_1.part_1.x", + &door_1.part_1.x + }, + { + "door_1.part_1.y", + &door_1.part_1.y + }, + { + "door_1.part_1.draw_masked", + &door_1.part_1.draw_masked + }, + { + "door_1.part_1.draw_order", + &door_1.part_1.sort_priority + }, + { + "door_1.part_2.x", + &door_1.part_2.x + }, + { + "door_1.part_2.y", + &door_1.part_2.y + }, + { + "door_1.part_2.draw_masked", + &door_1.part_2.draw_masked + }, + { + "door_1.part_2.draw_order", + &door_1.part_2.sort_priority + }, + { + "door_1.part_3.x", + &door_1.part_3.x + }, + { + "door_1.part_3.y", + &door_1.part_3.y + }, + { + "door_1.part_3.draw_masked", + &door_1.part_3.draw_masked + }, + { + "door_1.part_3.draw_order", + &door_1.part_3.sort_priority + }, + { + "door_1.part_4.x", + &door_1.part_4.x + }, + { + "door_1.part_4.y", + &door_1.part_4.y + }, + { + "door_1.part_4.draw_masked", + &door_1.part_4.draw_masked + }, + { + "door_1.part_4.draw_order", + &door_1.part_4.sort_priority + }, + { + "door_1.part_5.x", + &door_1.part_5.x + }, + { + "door_1.part_5.y", + &door_1.part_5.y + }, + { + "door_1.part_5.draw_masked", + &door_1.part_5.draw_masked + }, + { + "door_1.part_5.draw_order", + &door_1.part_5.sort_priority + }, + { + "door_1.part_6.x", + &door_1.part_6.x + }, + { + "door_1.part_6.y", + &door_1.part_6.y + }, + { + "door_1.part_6.draw_masked", + &door_1.part_6.draw_masked + }, + { + "door_1.part_6.draw_order", + &door_1.part_6.sort_priority + }, + { + "door_1.part_7.x", + &door_1.part_7.x + }, + { + "door_1.part_7.y", + &door_1.part_7.y + }, + { + "door_1.part_7.draw_masked", + &door_1.part_7.draw_masked + }, + { + "door_1.part_7.draw_order", + &door_1.part_7.sort_priority + }, + { + "door_1.part_8.x", + &door_1.part_8.x + }, + { + "door_1.part_8.y", + &door_1.part_8.y + }, + { + "door_1.part_8.draw_masked", + &door_1.part_8.draw_masked + }, + { + "door_1.part_8.draw_order", + &door_1.part_8.sort_priority + }, + { + "door_2.part_1.x", + &door_2.part_1.x + }, + { + "door_2.part_1.y", + &door_2.part_1.y + }, + { + "door_2.part_1.draw_masked", + &door_2.part_1.draw_masked + }, + { + "door_2.part_1.draw_order", + &door_2.part_1.sort_priority + }, + { + "door_2.part_2.x", + &door_2.part_2.x + }, + { + "door_2.part_2.y", + &door_2.part_2.y + }, + { + "door_2.part_2.draw_masked", + &door_2.part_2.draw_masked + }, + { + "door_2.part_2.draw_order", + &door_2.part_2.sort_priority + }, + { + "door_2.part_3.x", + &door_2.part_3.x + }, + { + "door_2.part_3.y", + &door_2.part_3.y + }, + { + "door_2.part_3.draw_masked", + &door_2.part_3.draw_masked + }, + { + "door_2.part_3.draw_order", + &door_2.part_3.sort_priority + }, + { + "door_2.part_4.x", + &door_2.part_4.x + }, + { + "door_2.part_4.y", + &door_2.part_4.y + }, + { + "door_2.part_4.draw_masked", + &door_2.part_4.draw_masked + }, + { + "door_2.part_4.draw_order", + &door_2.part_4.sort_priority + }, + { + "door_2.part_5.x", + &door_2.part_5.x + }, + { + "door_2.part_5.y", + &door_2.part_5.y + }, + { + "door_2.part_5.draw_masked", + &door_2.part_5.draw_masked + }, + { + "door_2.part_5.draw_order", + &door_2.part_5.sort_priority + }, + { + "door_2.part_6.x", + &door_2.part_6.x + }, + { + "door_2.part_6.y", + &door_2.part_6.y + }, + { + "door_2.part_6.draw_masked", + &door_2.part_6.draw_masked + }, + { + "door_2.part_6.draw_order", + &door_2.part_6.sort_priority + }, + { + "door_2.part_7.x", + &door_2.part_7.x + }, + { + "door_2.part_7.y", + &door_2.part_7.y + }, + { + "door_2.part_7.draw_masked", + &door_2.part_7.draw_masked + }, + { + "door_2.part_7.draw_order", + &door_2.part_7.sort_priority + }, + { + "door_2.part_8.x", + &door_2.part_8.x + }, + { + "door_2.part_8.y", + &door_2.part_8.y + }, + { + "door_2.part_8.draw_masked", + &door_2.part_8.draw_masked + }, + { + "door_2.part_8.draw_order", + &door_2.part_8.sort_priority + }, { "door_1.width", &door_1.width diff --git a/src/conftime.h b/src/conftime.h index 14ad688f..efafec1c 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2014-02-22 14:10" +#define COMPILE_DATE_STRING "2014-02-24 17:29" diff --git a/src/events.c b/src/events.c index 9fb4ef03..d261a4db 100644 --- a/src/events.c +++ b/src/events.c @@ -1146,7 +1146,7 @@ void HandleButton(int mx, int my, int button, int button_nr) case GAME_MODE_PLAYING: #ifdef DEBUG - if (button == MB_PRESSED && !motion_status && IN_GFX_FIELD(mx, my)) + if (button == MB_PRESSED && !motion_status && IN_GFX_FIELD_PLAY(mx, my)) DumpTile(LEVELX((mx - SX) / TILEX), LEVELY((my - SY) / TILEY)); #endif break; diff --git a/src/init.c b/src/init.c index bd28fdc1..522b1b40 100644 --- a/src/init.c +++ b/src/init.c @@ -2469,6 +2469,8 @@ static void ReinitializeGraphics() print_timestamp_time("InitGadgets"); InitToons(); print_timestamp_time("InitToons"); + InitDoors(); + print_timestamp_time("InitDoors"); print_timestamp_done("ReinitializeGraphics"); } diff --git a/src/libgame/system.h b/src/libgame/system.h index b10232fe..5179c03b 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -317,7 +317,7 @@ #define REDRAWTILES_THRESHOLD 0 #endif -#define IN_GFX_FIELD(x, y) (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \ +#define IN_GFX_FIELD_PLAY(x, y) (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \ y >= gfx.sy && y < gfx.sy + gfx.sysize) #define IN_GFX_FIELD_FULL(x, y) (x >= gfx.real_sx && \ x < gfx.real_sx + gfx.full_sxsize && \ diff --git a/src/main.h b/src/main.h index 44d3f73c..10e48258 100644 --- a/src/main.h +++ b/src/main.h @@ -2300,6 +2300,15 @@ struct MenuInfo struct DoorInfo { + struct TextPosInfo part_1; + struct TextPosInfo part_2; + struct TextPosInfo part_3; + struct TextPosInfo part_4; + struct TextPosInfo part_5; + struct TextPosInfo part_6; + struct TextPosInfo part_7; + struct TextPosInfo part_8; + int width; int height; int step_offset; diff --git a/src/tools.c b/src/tools.c index 022677d4..59edb3d2 100644 --- a/src/tools.c +++ b/src/tools.c @@ -37,6 +37,117 @@ #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 *); @@ -1088,6 +1199,17 @@ void DrawBackground(int x, int y, int width, int height) #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; @@ -1095,6 +1217,8 @@ void DrawBackground(int x, int y, int width, int height) 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; @@ -5170,6 +5294,39 @@ boolean Request(char *text, unsigned int req_state) #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) @@ -5220,6 +5377,158 @@ unsigned int SetDoorState(unsigned int door_state) 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; @@ -5817,6 +6126,8 @@ unsigned int MoveDoor(unsigned int door_state) return (door1 | door2); } +#endif + void DrawSpecialEditorDoor() { #if 1 diff --git a/src/tools.h b/src/tools.h index dfe2e572..8f628963 100644 --- a/src/tools.h +++ b/src/tools.h @@ -33,10 +33,21 @@ #define USE_MASKING 1 /* for MoveDoor */ +#if 0 +#define DOOR_1 (1 << 0) +#define DOOR_2 (1 << 1) +#define DOOR_OPEN (1 << 2) +#define DOOR_CLOSE (1 << 3) +#define DOOR_OPEN_1 (DOOR_1 | DOOR_OPEN) +#define DOOR_OPEN_2 (DOOR_2 | DOOR_OPEN) +#define DOOR_CLOSE_1 (DOOR_1 | DOOR_CLOSE) +#define DOOR_CLOSE_2 (DOOR_2 | DOOR_CLOSE) +#else #define DOOR_OPEN_1 (1 << 0) #define DOOR_OPEN_2 (1 << 1) #define DOOR_CLOSE_1 (1 << 2) #define DOOR_CLOSE_2 (1 << 3) +#endif #define DOOR_OPEN_ALL (DOOR_OPEN_1 | DOOR_OPEN_2) #define DOOR_CLOSE_ALL (DOOR_CLOSE_1 | DOOR_CLOSE_2) #define DOOR_ACTION_1 (DOOR_OPEN_1 | DOOR_CLOSE_1) @@ -49,6 +60,16 @@ #define DOOR_GET_STATE (1 << 8) #define DOOR_SET_STATE (1 << 9) +#define DOOR_1 (DOOR_ACTION_1) +#define DOOR_2 (DOOR_ACTION_2) +#define DOOR_OPEN (DOOR_OPEN_ALL) +#define DOOR_CLOSE (DOOR_CLOSE_ALL) + +#define DOOR_INDEX_FROM_TOKEN(x) ((x) == DOOR_1 ? 0 : 1) +#define DOOR_TOKEN_FROM_INDEX(x) ((x) == 0 ? DOOR_1 ? : DOOR_2) +#define REDRAW_DOOR_FROM_TOKEN(x) ((x) == DOOR_1 ? REDRAW_DOOR_1 : \ + REDRAW_DOOR_2) + /* for Request */ #define REQ_ASK (1 << 0) #define REQ_CONFIRM (1 << 1) @@ -173,6 +194,7 @@ void DrawPreviewLevelAnimation(void); void WaitForEventToContinue(); boolean Request(char *, unsigned int); +void InitDoors(void); unsigned int OpenDoor(unsigned int); unsigned int CloseDoor(unsigned int); unsigned int GetDoorState(void); -- 2.34.1