added support for game cycle delay in BD engine to level editor
authorHolger Schemel <info@artsoft.org>
Sun, 10 Mar 2024 14:41:28 +0000 (15:41 +0100)
committerHolger Schemel <info@artsoft.org>
Sun, 10 Mar 2024 14:41:31 +0000 (15:41 +0100)
src/editor.c
src/files.c
src/main.h

index bc82cd1fbf28bc47b8be6ddb774d2b4b58b5a65f..c5b1b4a7438e0d111df54a712e70d926ae331436 100644 (file)
@@ -429,6 +429,12 @@ enum
   GADGET_ID_LEVELSET_NUM_LEVELS_DOWN,
   GADGET_ID_LEVELSET_NUM_LEVELS_TEXT,
   GADGET_ID_LEVELSET_NUM_LEVELS_UP,
+  GADGET_ID_BD_CYCLE_DELAY_MS_DOWN,
+  GADGET_ID_BD_CYCLE_DELAY_MS_TEXT,
+  GADGET_ID_BD_CYCLE_DELAY_MS_UP,
+  GADGET_ID_BD_CYCLE_DELAY_C64_DOWN,
+  GADGET_ID_BD_CYCLE_DELAY_C64_TEXT,
+  GADGET_ID_BD_CYCLE_DELAY_C64_UP,
   GADGET_ID_ELEMENT_VALUE1_DOWN,
   GADGET_ID_ELEMENT_VALUE1_TEXT,
   GADGET_ID_ELEMENT_VALUE1_UP,
@@ -752,6 +758,8 @@ enum
   ED_COUNTER_ID_LEVEL_RANDOM_SEED,
   ED_COUNTER_ID_LEVELSET_NUM_LEVELS,
   ED_COUNTER_ID_LEVEL_RANDOM,
+  ED_COUNTER_ID_BD_CYCLE_DELAY_MS,
+  ED_COUNTER_ID_BD_CYCLE_DELAY_C64,
   ED_COUNTER_ID_ELEMENT_VALUE1,
   ED_COUNTER_ID_ELEMENT_VALUE2,
   ED_COUNTER_ID_ELEMENT_VALUE3,
@@ -1489,6 +1497,24 @@ static struct
     &random_placement_value,
     "random element placement:",       NULL, "in"
   },
+  {
+    ED_COUNTER_ID_BD_CYCLE_DELAY_MS,
+    ED_LEVEL_SETTINGS_XPOS(0),         ED_LEVEL_SETTINGS_YPOS(3),
+    50,                                        500,
+    GADGET_ID_BD_CYCLE_DELAY_MS_DOWN,  GADGET_ID_BD_CYCLE_DELAY_MS_UP,
+    GADGET_ID_BD_CYCLE_DELAY_MS_TEXT,  GADGET_ID_NONE,
+    &level.bd_cycle_delay_ms,
+    NULL,                              NULL, "game cycle delay (ms)"
+  },
+  {
+    ED_COUNTER_ID_BD_CYCLE_DELAY_C64,
+    ED_LEVEL_SETTINGS_XPOS(0),         ED_LEVEL_SETTINGS_YPOS(3),
+    0,                                 32,
+    GADGET_ID_BD_CYCLE_DELAY_C64_DOWN, GADGET_ID_BD_CYCLE_DELAY_C64_UP,
+    GADGET_ID_BD_CYCLE_DELAY_C64_TEXT, GADGET_ID_NONE,
+    &level.bd_cycle_delay_c64,
+    NULL,                              NULL, "game cycle delay (C64-style)"
+  },
 
   // ---------- element settings: configure (various elements) ----------------
 
@@ -10044,6 +10070,12 @@ static void DrawLevelConfigEngine(void)
 {
   int i;
 
+  // draw counter gadgets
+  if (level.bd_scheduling_type == GD_SCHEDULING_MILLISECONDS)
+    MapCounterButtons(ED_COUNTER_ID_BD_CYCLE_DELAY_MS);
+  else
+    MapCounterButtons(ED_COUNTER_ID_BD_CYCLE_DELAY_C64);
+
   // draw checkbutton gadgets
   for (i = ED_CHECKBUTTON_ID_ENGINE_FIRST; i <= ED_CHECKBUTTON_ID_ENGINE_LAST; i++)
     MapCheckbuttonGadget(i);
@@ -14561,6 +14593,11 @@ static void HandleSelectboxGadgets(struct GadgetInfo *gi)
     ReinitializeElementList();
     ModifyEditorElementList();
   }
+  else if (type_id == ED_SELECTBOX_ID_BD_SCHEDULING_TYPE)
+  {
+    // update BD cycle delay counter gadgets depending on BD scheduling type
+    DrawLevelConfigWindow();
+  }
 
   // do not mark level as modified for certain non-level-changing gadgets
   if (type_id == ED_SELECTBOX_ID_LEVELSET_SAVE_MODE ||
index 4b2db0f89a9b80bf642e88db6133d1dd8f303b62..898b33bbb867cf68bdbdcb967455c0813b4acc46 100644 (file)
@@ -291,6 +291,18 @@ static struct LevelFileConfigInfo chunk_config_INFO[] =
     &li.bd_pal_timing,                 FALSE
   },
 
+  {
+    -1,                                        -1,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(6),
+    &li.bd_cycle_delay_ms,             200
+  },
+
+  {
+    -1,                                        -1,
+    TYPE_INTEGER,                      CONF_VALUE_8_BIT(17),
+    &li.bd_cycle_delay_c64,            0
+  },
+
   {
     -1,                                        -1,
     -1,                                        -1,
@@ -3727,14 +3739,16 @@ static void CopyNativeLevel_RND_to_BD(struct LevelInfo *level)
     cave->level_time[i]                        = level->time;
     cave->level_diamonds[i]            = level->gems_needed;
     cave->level_magic_wall_time[i]     = level->time_magic_wall;
+
+    cave->level_speed[i]               = level->bd_cycle_delay_ms;
+    cave->level_ckdelay[i]             = level->bd_cycle_delay_c64;
+
     cave->level_timevalue[i]           = level->score[SC_TIME_BONUS];
   }
 
   cave->diamond_value                  = level->score[SC_EMERALD];
   cave->extra_diamond_value            = level->score[SC_DIAMOND_EXTRA];
 
-  cave->level_speed[0]                 = 160;  // set cave speed
-
   cave->scheduling                     = level->bd_scheduling_type;
   cave->pal_timing                     = level->bd_pal_timing;
   cave->intermission                   = level->bd_intermission;
@@ -3762,6 +3776,9 @@ static void CopyNativeLevel_BD_to_RND(struct LevelInfo *level)
   level->gems_needed                   = cave->level_diamonds[bd_level_nr];
   level->time_magic_wall               = cave->level_magic_wall_time[bd_level_nr];
 
+  level->bd_cycle_delay_ms             = cave->level_speed[bd_level_nr];
+  level->bd_cycle_delay_c64            = cave->level_ckdelay[bd_level_nr];
+
   level->score[SC_TIME_BONUS]          = cave->level_timevalue[bd_level_nr];
   level->score[SC_EMERALD]             = cave->diamond_value;
   level->score[SC_DIAMOND_EXTRA]       = cave->extra_diamond_value;
index 18479583a49caf67063c72bed6eb8f87b1cef332..fc1a1cecb7629a8c97a6800e85aa762d4731647d 100644 (file)
@@ -3482,6 +3482,8 @@ struct LevelInfo
 
   boolean bd_scheduling_type;          // BD engine scheduling type
   boolean bd_pal_timing;               // BD engine special timing
+  boolean bd_cycle_delay_ms;           // BD game cycle delay (in milliseconds)
+  boolean bd_cycle_delay_c64;          // BD game cycle delay (in C64 game units)
   boolean bd_intermission;             // BD level is intermission
   boolean bd_diagonal_movements;       // BD style diagonal movements
   boolean em_slippery_gems;            // EM style "gems slip from wall" behaviour