minor code formatting changes
[rocksndiamonds.git] / src / game_bd / bd_c64import.c
index 40764a4baef6ba1e5d634193c59b9f11854444df..ff71031f72da3760a591dde33f23128d7ac3ddf0 100644 (file)
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <glib.h>
-#include <glib/gi18n.h>
-
 #include "main_bd.h"
 
 
-/* make all caves selectable. */
+// make all caves selectable.
 static boolean gd_import_as_all_caves_selectable = TRUE;
 
-/* conversion table for imported bd1 caves. */
+// conversion table for imported bd1 caves.
 static const GdElement bd1_import_table[] =
 {
   /*  0 */ O_SPACE, O_DIRT, O_BRICK, O_MAGIC_WALL,
@@ -32,7 +29,8 @@ static const GdElement bd1_import_table[] =
   /*  c */ O_FIREFLY_1, O_FIREFLY_2, O_FIREFLY_3, O_FIREFLY_4,
   /* 10 */ O_STONE, O_STONE, O_STONE_F, O_STONE_F,
   /* 14 */ O_DIAMOND, O_DIAMOND, O_DIAMOND_F, O_DIAMOND_F,
-  /* 18 */ O_ACID, O_ACID, O_EXPLODE_1, O_EXPLODE_2,    /* ACID: marek roth extension in crazy dream 3 */
+  // ----- ACID: marek roth extension in crazy dream 3
+  /* 18 */ O_ACID, O_ACID, O_EXPLODE_1, O_EXPLODE_2,
   /* 1c */ O_EXPLODE_3, O_EXPLODE_4, O_EXPLODE_5, O_PRE_DIA_1,
   /* 20 */ O_PRE_DIA_2, O_PRE_DIA_3, O_PRE_DIA_4, O_PRE_DIA_5,
   /* 24 */ O_PRE_DIA_5, O_INBOX, O_PRE_PL_1, O_PRE_PL_2,
@@ -44,7 +42,7 @@ static const GdElement bd1_import_table[] =
   /* 3c */ O_VOODOO, O_INVIS_OUTBOX, O_SLIME, O_UNKNOWN
 };
 
-/* conversion table for imported plck caves. */
+// conversion table for imported plck caves.
 static const GdElement plck_import_nybble[] =
 {
   /*  0 */ O_STONE, O_DIAMOND, O_MAGIC_WALL, O_BRICK,
@@ -53,7 +51,7 @@ static const GdElement plck_import_nybble[] =
   /* 12 */ O_PRE_INVIS_OUTBOX, O_PRE_OUTBOX, O_INBOX, O_SPACE
 };
 
-/* conversion table for imported 1stb caves. */
+// conversion table for imported 1stb caves.
 static const GdElement firstboulder_import_table[] =
 {
   /*  0 */ O_SPACE, O_DIRT, O_BRICK, O_MAGIC_WALL,
@@ -66,7 +64,8 @@ static const GdElement firstboulder_import_table[] =
   /* 1c */ O_BITER_SWITCH, O_BITER_SWITCH, O_BLADDER_SPENDER, O_PRE_DIA_1,
   /* 20 */ O_PRE_DIA_1, O_PRE_DIA_2, O_PRE_DIA_3, O_PRE_DIA_4,
   /* 24 */ O_PRE_DIA_5, O_INBOX, O_PRE_PL_1, O_PRE_PL_2,
-  /* 28 */ O_PRE_PL_3, O_CLOCK, O_H_EXPANDING_WALL, O_H_EXPANDING_WALL,    /* CLOCK: not mentioned in marek's bd inside faq */
+  // ----- CLOCK: not mentioned in marek's bd inside faq
+  /* 28 */ O_PRE_PL_3, O_CLOCK, O_H_EXPANDING_WALL, O_H_EXPANDING_WALL,
   /* 2c */ O_CREATURE_SWITCH, O_CREATURE_SWITCH, O_EXPANDING_WALL_SWITCH, O_EXPANDING_WALL_SWITCH,
   /* 30 */ O_BUTTER_3, O_BUTTER_4, O_BUTTER_1, O_BUTTER_2,
   /* 34 */ O_BUTTER_3, O_BUTTER_4, O_BUTTER_1, O_BUTTER_2,
@@ -90,7 +89,7 @@ static const GdElement firstboulder_import_table[] =
   /* 7c */ O_BITER_1, O_BITER_2, O_BITER_3, O_BITER_4,
 };
 
-/* conversion table for imported crazy dream caves. */
+// conversion table for imported crazy dream caves.
 static const GdElement crazydream_import_table[] =
 {
   /*  0 */ O_SPACE, O_DIRT, O_BRICK, O_MAGIC_WALL,
@@ -100,10 +99,12 @@ static const GdElement crazydream_import_table[] =
   /* 10 */ O_STONE, O_STONE, O_STONE_F, O_STONE_F,
   /* 14 */ O_DIAMOND, O_DIAMOND, O_DIAMOND_F, O_DIAMOND_F,
   /* 18 */ O_PRE_CLOCK_1, O_PRE_CLOCK_2, O_PRE_CLOCK_3, O_PRE_CLOCK_4,
-  /* 1c */ O_BITER_SWITCH, O_BITER_SWITCH, O_BLADDER_SPENDER, O_PRE_DIA_1,    /* 6 different stages */
+  /* 1c */ O_BITER_SWITCH, O_BITER_SWITCH, O_BLADDER_SPENDER, O_PRE_DIA_1,
+  // ----- 6 different stages
   /* 20 */ O_PRE_DIA_1, O_PRE_DIA_2, O_PRE_DIA_3, O_PRE_DIA_4,
   /* 24 */ O_PRE_DIA_5, O_INBOX, O_PRE_PL_1, O_PRE_PL_2,
-  /* 28 */ O_PRE_PL_3, O_CLOCK, O_H_EXPANDING_WALL, O_H_EXPANDING_WALL,    /* CLOCK: not mentioned in marek's bd inside faq */
+  // ----- CLOCK: not mentioned in marek's bd inside faq
+  /* 28 */ O_PRE_PL_3, O_CLOCK, O_H_EXPANDING_WALL, O_H_EXPANDING_WALL,
   /* 2c */ O_CREATURE_SWITCH, O_CREATURE_SWITCH, O_EXPANDING_WALL_SWITCH, O_EXPANDING_WALL_SWITCH,
   /* 30 */ O_BUTTER_3, O_BUTTER_4, O_BUTTER_1, O_BUTTER_2,
   /* 34 */ O_BUTTER_3, O_BUTTER_4, O_BUTTER_1, O_BUTTER_2,
@@ -162,7 +163,7 @@ static const GdElement crazydream_import_table[] =
   /* fc */ O_WATER, O_WATER, O_WATER, O_WATER,
 };
 
-/* conversion table for imported 1stb caves. */
+// conversion table for imported 1stb caves.
 const GdElement gd_crazylight_import_table[] =
 {
   /*  0 */ O_SPACE, O_DIRT, O_BRICK, O_MAGIC_WALL,
@@ -172,10 +173,12 @@ const GdElement gd_crazylight_import_table[] =
   /* 10 */ O_STONE, O_STONE|SCANNED, O_STONE_F, O_STONE_F|SCANNED,
   /* 14 */ O_DIAMOND, O_DIAMOND|SCANNED, O_DIAMOND_F, O_DIAMOND_F|SCANNED,
   /* 18 */ O_PRE_CLOCK_1, O_PRE_CLOCK_2, O_PRE_CLOCK_3, O_PRE_CLOCK_4,
-  /* 1c */ O_BITER_SWITCH, O_BITER_SWITCH, O_BLADDER_SPENDER, O_PRE_DIA_1,    /* 6 different stages, the first is the pre_dia_0 */
+  /* 1c */ O_BITER_SWITCH, O_BITER_SWITCH, O_BLADDER_SPENDER, O_PRE_DIA_1,
+  // ----- 6 different stages, the first is the pre_dia_0
   /* 20 */ O_PRE_DIA_1, O_PRE_DIA_2, O_PRE_DIA_3, O_PRE_DIA_4,
   /* 24 */ O_PRE_DIA_5, O_INBOX, O_PRE_PL_1, O_PRE_PL_2,
-  /* 28 */ O_PRE_PL_3, O_CLOCK, O_H_EXPANDING_WALL, O_H_EXPANDING_WALL|SCANNED,    /* CLOCK: not mentioned in marek's bd inside faq */
+  // ----- CLOCK: not mentioned in marek's bd inside faq
+  /* 28 */ O_PRE_PL_3, O_CLOCK, O_H_EXPANDING_WALL, O_H_EXPANDING_WALL|SCANNED,
   /* 2c */ O_CREATURE_SWITCH, O_CREATURE_SWITCH, O_EXPANDING_WALL_SWITCH, O_EXPANDING_WALL_SWITCH,
   /* 30 */ O_BUTTER_3, O_BUTTER_4, O_BUTTER_1, O_BUTTER_2,
   /* 34 */ O_BUTTER_3|SCANNED, O_BUTTER_4|SCANNED, O_BUTTER_1|SCANNED, O_BUTTER_2|SCANNED,
@@ -201,216 +204,230 @@ const GdElement gd_crazylight_import_table[] =
 
 GdPropertyDefault gd_defaults_bd1[] =
 {
-  {CAVE_OFFSET(level_amoeba_threshold), 200},
-  {CAVE_OFFSET(amoeba_growth_prob), 31250},
-  {CAVE_OFFSET(amoeba_fast_growth_prob), 250000},
-  {CAVE_OFFSET(amoeba_timer_started_immediately), TRUE},
-  {CAVE_OFFSET(amoeba_timer_wait_for_hatching), FALSE},
-  {CAVE_OFFSET(lineshift), TRUE},
-  {CAVE_OFFSET(wraparound_objects), TRUE},
-  {CAVE_OFFSET(diagonal_movements), FALSE},
-  {CAVE_OFFSET(voodoo_collects_diamonds), FALSE},
-  {CAVE_OFFSET(voodoo_dies_by_stone), FALSE},
-  {CAVE_OFFSET(voodoo_disappear_in_explosion), TRUE},
-  {CAVE_OFFSET(voodoo_any_hurt_kills_player), FALSE},
-  {CAVE_OFFSET(creatures_backwards), FALSE},
-  {CAVE_OFFSET(creatures_direction_auto_change_on_start), FALSE},
-  {CAVE_OFFSET(creatures_direction_auto_change_time), 0},
-  {CAVE_OFFSET(level_hatching_delay_time[0]), 2},
-  {CAVE_OFFSET(intermission_instantlife), TRUE},
-  {CAVE_OFFSET(intermission_rewardlife), FALSE},
-  {CAVE_OFFSET(magic_wall_stops_amoeba), TRUE},
-  {CAVE_OFFSET(magic_timer_wait_for_hatching), FALSE},
-  {CAVE_OFFSET(pushing_stone_prob), 250000},
-  {CAVE_OFFSET(pushing_stone_prob_sweet), 1000000},
-  {CAVE_OFFSET(active_is_first_found), FALSE},
-  {CAVE_OFFSET(short_explosions), TRUE},
-  {CAVE_OFFSET(slime_predictable), TRUE},
-  {CAVE_OFFSET(snap_element), O_SPACE},
-  {CAVE_OFFSET(max_time), 999},
-
-  {CAVE_OFFSET(scheduling), GD_SCHEDULING_BD1},
-  {CAVE_OFFSET(pal_timing), TRUE},
-
-  {-1},
+  { CAVE_OFFSET(level_amoeba_threshold), 200 },
+  { CAVE_OFFSET(amoeba_growth_prob), 31250 },
+  { CAVE_OFFSET(amoeba_fast_growth_prob), 250000 },
+  { CAVE_OFFSET(amoeba_timer_started_immediately), TRUE },
+  { CAVE_OFFSET(amoeba_timer_wait_for_hatching), FALSE },
+  { CAVE_OFFSET(lineshift), TRUE },
+  { CAVE_OFFSET(wraparound_objects), TRUE },
+  { CAVE_OFFSET(diagonal_movements), FALSE },
+  { CAVE_OFFSET(voodoo_collects_diamonds), FALSE },
+  { CAVE_OFFSET(voodoo_dies_by_stone), FALSE },
+  { CAVE_OFFSET(voodoo_disappear_in_explosion), TRUE },
+  { CAVE_OFFSET(voodoo_any_hurt_kills_player), FALSE },
+  { CAVE_OFFSET(creatures_backwards), FALSE },
+  { CAVE_OFFSET(creatures_direction_auto_change_on_start), FALSE },
+  { CAVE_OFFSET(creatures_direction_auto_change_time), 0 },
+  { CAVE_OFFSET(level_hatching_delay_time[0]), 2 },
+  { CAVE_OFFSET(intermission_instantlife), TRUE },
+  { CAVE_OFFSET(intermission_rewardlife), FALSE },
+  { CAVE_OFFSET(magic_wall_stops_amoeba), TRUE },
+  { CAVE_OFFSET(magic_wall_breakscan), TRUE },
+  { CAVE_OFFSET(magic_timer_zero_is_infinite), TRUE },
+  { CAVE_OFFSET(magic_timer_wait_for_hatching), FALSE },
+  { CAVE_OFFSET(pushing_stone_prob), 250000 },
+  { CAVE_OFFSET(pushing_stone_prob_sweet), 1000000 },
+  { CAVE_OFFSET(active_is_first_found), FALSE },
+  { CAVE_OFFSET(short_explosions), TRUE },
+  { CAVE_OFFSET(slime_predictable), TRUE },
+  { CAVE_OFFSET(snap_element), O_SPACE },
+  { CAVE_OFFSET(max_time), 999 },
+
+  { CAVE_OFFSET(scheduling), GD_SCHEDULING_BD1 },
+  { CAVE_OFFSET(pal_timing), TRUE },
+
+  { -1 },
 };
 
 GdPropertyDefault gd_defaults_bd2[] =
 {
-  {CAVE_OFFSET(level_amoeba_threshold), 200},
-  {CAVE_OFFSET(amoeba_growth_prob), 31250},
-  {CAVE_OFFSET(amoeba_fast_growth_prob), 250000},
-  {CAVE_OFFSET(amoeba_timer_started_immediately), FALSE},
-  {CAVE_OFFSET(amoeba_timer_wait_for_hatching), FALSE},
-  {CAVE_OFFSET(lineshift), TRUE},
-  {CAVE_OFFSET(wraparound_objects), TRUE},
-  {CAVE_OFFSET(diagonal_movements), FALSE},
-  {CAVE_OFFSET(voodoo_collects_diamonds), FALSE},
-  {CAVE_OFFSET(voodoo_dies_by_stone), FALSE},
-  {CAVE_OFFSET(voodoo_disappear_in_explosion), TRUE},
-  {CAVE_OFFSET(voodoo_any_hurt_kills_player), FALSE},
-  {CAVE_OFFSET(creatures_backwards), FALSE},
-  {CAVE_OFFSET(creatures_direction_auto_change_on_start), FALSE},
-  {CAVE_OFFSET(creatures_direction_auto_change_time), 0},
-  {CAVE_OFFSET(level_hatching_delay_time[0]), 2},
-  {CAVE_OFFSET(intermission_instantlife), TRUE},
-  {CAVE_OFFSET(intermission_rewardlife), FALSE},
-  {CAVE_OFFSET(magic_wall_stops_amoeba), FALSE},    /* marek roth bd inside faq 3.0 */
-  {CAVE_OFFSET(magic_timer_wait_for_hatching), FALSE},
-  {CAVE_OFFSET(pushing_stone_prob), 250000},
-  {CAVE_OFFSET(pushing_stone_prob_sweet), 1000000},
-  {CAVE_OFFSET(active_is_first_found), FALSE},
-  {CAVE_OFFSET(short_explosions), TRUE},
-  {CAVE_OFFSET(slime_predictable), TRUE},
-  {CAVE_OFFSET(snap_element), O_SPACE},
-  {CAVE_OFFSET(max_time), 999},
-
-  {CAVE_OFFSET(pal_timing), TRUE},
-  {CAVE_OFFSET(scheduling), GD_SCHEDULING_BD2},
-
-  {-1},
+  { CAVE_OFFSET(level_amoeba_threshold), 200 },
+  { CAVE_OFFSET(amoeba_growth_prob), 31250 },
+  { CAVE_OFFSET(amoeba_fast_growth_prob), 250000 },
+  { CAVE_OFFSET(amoeba_timer_started_immediately), FALSE },
+  { CAVE_OFFSET(amoeba_timer_wait_for_hatching), FALSE },
+  { CAVE_OFFSET(lineshift), TRUE },
+  { CAVE_OFFSET(wraparound_objects), TRUE },
+  { CAVE_OFFSET(diagonal_movements), FALSE },
+  { CAVE_OFFSET(voodoo_collects_diamonds), FALSE },
+  { CAVE_OFFSET(voodoo_dies_by_stone), FALSE },
+  { CAVE_OFFSET(voodoo_disappear_in_explosion), TRUE },
+  { CAVE_OFFSET(voodoo_any_hurt_kills_player), FALSE },
+  { CAVE_OFFSET(creatures_backwards), FALSE },
+  { CAVE_OFFSET(creatures_direction_auto_change_on_start), FALSE },
+  { CAVE_OFFSET(creatures_direction_auto_change_time), 0 },
+  { CAVE_OFFSET(level_hatching_delay_time[0]), 2 },
+  { CAVE_OFFSET(intermission_instantlife), TRUE },
+  { CAVE_OFFSET(intermission_rewardlife), FALSE },
+  { CAVE_OFFSET(magic_wall_stops_amoeba), FALSE },    // marek roth bd inside faq 3.0
+  { CAVE_OFFSET(magic_timer_zero_is_infinite), TRUE },
+  { CAVE_OFFSET(magic_timer_wait_for_hatching), FALSE },
+  { CAVE_OFFSET(pushing_stone_prob), 250000 },
+  { CAVE_OFFSET(pushing_stone_prob_sweet), 1000000 },
+  { CAVE_OFFSET(active_is_first_found), FALSE },
+  { CAVE_OFFSET(short_explosions), TRUE },
+  { CAVE_OFFSET(slime_predictable), TRUE },
+  { CAVE_OFFSET(snap_element), O_SPACE },
+  { CAVE_OFFSET(max_time), 999 },
+
+  { CAVE_OFFSET(pal_timing), TRUE },
+  { CAVE_OFFSET(scheduling), GD_SCHEDULING_BD2 },
+
+  { -1 },
 };
 
 GdPropertyDefault gd_defaults_plck[] =
 {
-  {CAVE_OFFSET(amoeba_growth_prob), 31250},
-  {CAVE_OFFSET(amoeba_fast_growth_prob), 250000},
-  {CAVE_OFFSET(amoeba_timer_started_immediately), FALSE},
-  {CAVE_OFFSET(amoeba_timer_wait_for_hatching), FALSE},
-  {CAVE_OFFSET(lineshift), TRUE},
-  {CAVE_OFFSET(wraparound_objects), TRUE},
-  {CAVE_OFFSET(border_scan_first_and_last), FALSE},
-  {CAVE_OFFSET(diagonal_movements), FALSE},
-  {CAVE_OFFSET(voodoo_collects_diamonds), FALSE},
-  {CAVE_OFFSET(voodoo_dies_by_stone), FALSE},
-  {CAVE_OFFSET(voodoo_disappear_in_explosion), TRUE},
-  {CAVE_OFFSET(voodoo_any_hurt_kills_player), FALSE},
-  {CAVE_OFFSET(creatures_backwards), FALSE},
-  {CAVE_OFFSET(creatures_direction_auto_change_on_start), FALSE},
-  {CAVE_OFFSET(creatures_direction_auto_change_time), 0},
-  {CAVE_OFFSET(level_hatching_delay_time[0]), 2},
-  {CAVE_OFFSET(intermission_instantlife), TRUE},
-  {CAVE_OFFSET(intermission_rewardlife), FALSE},
-  {CAVE_OFFSET(magic_wall_stops_amoeba), FALSE},
-  {CAVE_OFFSET(magic_timer_wait_for_hatching), FALSE},
-  {CAVE_OFFSET(pushing_stone_prob), 250000},
-  {CAVE_OFFSET(pushing_stone_prob_sweet), 1000000},
-  {CAVE_OFFSET(active_is_first_found), FALSE},
-  {CAVE_OFFSET(short_explosions), TRUE},
-  {CAVE_OFFSET(snap_element), O_SPACE},
-  {CAVE_OFFSET(max_time), 999},
-
-  {CAVE_OFFSET(pal_timing), TRUE},
-  {CAVE_OFFSET(scheduling), GD_SCHEDULING_PLCK},
-
-  {-1},
+  { CAVE_OFFSET(amoeba_growth_prob), 31250 },
+  { CAVE_OFFSET(amoeba_fast_growth_prob), 250000 },
+  { CAVE_OFFSET(amoeba_timer_started_immediately), FALSE },
+  { CAVE_OFFSET(amoeba_timer_wait_for_hatching), FALSE },
+  { CAVE_OFFSET(lineshift), TRUE },
+  { CAVE_OFFSET(wraparound_objects), TRUE },
+  { CAVE_OFFSET(border_scan_first_and_last), FALSE },
+  { CAVE_OFFSET(diagonal_movements), FALSE },
+  { CAVE_OFFSET(voodoo_collects_diamonds), FALSE },
+  { CAVE_OFFSET(voodoo_dies_by_stone), FALSE },
+  { CAVE_OFFSET(voodoo_disappear_in_explosion), TRUE },
+  { CAVE_OFFSET(voodoo_any_hurt_kills_player), FALSE },
+  { CAVE_OFFSET(creatures_backwards), FALSE },
+  { CAVE_OFFSET(creatures_direction_auto_change_on_start), FALSE },
+  { CAVE_OFFSET(creatures_direction_auto_change_time), 0 },
+  { CAVE_OFFSET(level_hatching_delay_time[0]), 2 },
+  { CAVE_OFFSET(intermission_instantlife), TRUE },
+  { CAVE_OFFSET(intermission_rewardlife), FALSE },
+  { CAVE_OFFSET(magic_wall_stops_amoeba), FALSE },
+  { CAVE_OFFSET(magic_timer_zero_is_infinite), TRUE },
+  { CAVE_OFFSET(magic_timer_wait_for_hatching), FALSE },
+  { CAVE_OFFSET(pushing_stone_prob), 250000 },
+  { CAVE_OFFSET(pushing_stone_prob_sweet), 1000000 },
+  { CAVE_OFFSET(active_is_first_found), FALSE },
+  { CAVE_OFFSET(short_explosions), TRUE },
+  { CAVE_OFFSET(snap_element), O_SPACE },
+  { CAVE_OFFSET(max_time), 999 },
+
+  { CAVE_OFFSET(pal_timing), TRUE },
+  { CAVE_OFFSET(scheduling), GD_SCHEDULING_PLCK },
+
+  { -1 },
 };
 
 GdPropertyDefault gd_defaults_1stb[] =
 {
-  {CAVE_OFFSET(amoeba_growth_prob), 31250},
-  {CAVE_OFFSET(amoeba_fast_growth_prob), 250000},
-  {CAVE_OFFSET(amoeba_timer_started_immediately), FALSE},
-  {CAVE_OFFSET(amoeba_timer_wait_for_hatching), TRUE},
-  {CAVE_OFFSET(lineshift), TRUE},
-  {CAVE_OFFSET(wraparound_objects), TRUE},
-  {CAVE_OFFSET(voodoo_collects_diamonds), TRUE},
-  {CAVE_OFFSET(voodoo_dies_by_stone), TRUE},
-  {CAVE_OFFSET(voodoo_disappear_in_explosion), FALSE},
-  {CAVE_OFFSET(voodoo_any_hurt_kills_player), FALSE},
-  {CAVE_OFFSET(creatures_direction_auto_change_on_start), TRUE},
-  {CAVE_OFFSET(level_hatching_delay_time[0]), 2},
-  {CAVE_OFFSET(intermission_instantlife), FALSE},
-  {CAVE_OFFSET(intermission_rewardlife), TRUE},
-  {CAVE_OFFSET(magic_timer_wait_for_hatching), TRUE},
-  {CAVE_OFFSET(pushing_stone_prob), 250000},
-  {CAVE_OFFSET(pushing_stone_prob_sweet), 1000000},
-  {CAVE_OFFSET(active_is_first_found), TRUE},
-  {CAVE_OFFSET(short_explosions), FALSE},
-  {CAVE_OFFSET(slime_predictable), TRUE},
-  {CAVE_OFFSET(snap_element), O_SPACE},
-  {CAVE_OFFSET(max_time), 999},
-
-  {CAVE_OFFSET(pal_timing), TRUE},
-  {CAVE_OFFSET(scheduling), GD_SCHEDULING_PLCK},
-  {CAVE_OFFSET(amoeba_enclosed_effect), O_PRE_DIA_1},    /* not immediately to diamond, but with animation */
-  {CAVE_OFFSET(dirt_looks_like), O_DIRT2},
-
-  {-1},
+  { CAVE_OFFSET(amoeba_growth_prob), 31250 },
+  { CAVE_OFFSET(amoeba_fast_growth_prob), 250000 },
+  { CAVE_OFFSET(amoeba_timer_started_immediately), FALSE },
+  { CAVE_OFFSET(amoeba_timer_wait_for_hatching), TRUE },
+  { CAVE_OFFSET(lineshift), TRUE },
+  { CAVE_OFFSET(wraparound_objects), TRUE },
+  { CAVE_OFFSET(voodoo_collects_diamonds), TRUE },
+  { CAVE_OFFSET(voodoo_dies_by_stone), TRUE },
+  { CAVE_OFFSET(voodoo_disappear_in_explosion), FALSE },
+  { CAVE_OFFSET(voodoo_any_hurt_kills_player), FALSE },
+  { CAVE_OFFSET(creatures_direction_auto_change_on_start), TRUE },
+  { CAVE_OFFSET(level_hatching_delay_time[0]), 2 },
+  { CAVE_OFFSET(intermission_instantlife), FALSE },
+  { CAVE_OFFSET(intermission_rewardlife), TRUE },
+  { CAVE_OFFSET(magic_timer_zero_is_infinite), TRUE },
+  { CAVE_OFFSET(magic_timer_wait_for_hatching), TRUE },
+  { CAVE_OFFSET(pushing_stone_prob), 250000 },
+  { CAVE_OFFSET(pushing_stone_prob_sweet), 1000000 },
+  { CAVE_OFFSET(active_is_first_found), TRUE },
+  { CAVE_OFFSET(short_explosions), FALSE },
+  { CAVE_OFFSET(slime_predictable), TRUE },
+  { CAVE_OFFSET(snap_element), O_SPACE },
+  { CAVE_OFFSET(max_time), 999 },
+
+  { CAVE_OFFSET(pal_timing), TRUE },
+  { CAVE_OFFSET(scheduling), GD_SCHEDULING_PLCK },
+  // not immediately to diamond, but with animation
+  { CAVE_OFFSET(amoeba_enclosed_effect), O_PRE_DIA_1 },
+  { CAVE_OFFSET(dirt_looks_like), O_DIRT2 },
+
+  { -1 },
 };
 
 GdPropertyDefault gd_defaults_crdr_7[] =
 {
-  {CAVE_OFFSET(amoeba_growth_prob), 31250},
-  {CAVE_OFFSET(amoeba_fast_growth_prob), 250000},
-  {CAVE_OFFSET(amoeba_timer_started_immediately), FALSE},
-  {CAVE_OFFSET(amoeba_timer_wait_for_hatching), TRUE},
-  {CAVE_OFFSET(lineshift), TRUE},
-  {CAVE_OFFSET(wraparound_objects), TRUE},
-  {CAVE_OFFSET(voodoo_collects_diamonds), TRUE},
-  {CAVE_OFFSET(voodoo_dies_by_stone), TRUE},
-  {CAVE_OFFSET(voodoo_disappear_in_explosion), FALSE},
-  {CAVE_OFFSET(voodoo_any_hurt_kills_player), FALSE},
-  {CAVE_OFFSET(creatures_direction_auto_change_on_start), FALSE},
-  {CAVE_OFFSET(level_hatching_delay_time[0]), 2},
-  {CAVE_OFFSET(intermission_instantlife), FALSE},
-  {CAVE_OFFSET(intermission_rewardlife), TRUE},
-  {CAVE_OFFSET(magic_timer_wait_for_hatching), TRUE},
-  {CAVE_OFFSET(pushing_stone_prob), 250000},
-  {CAVE_OFFSET(pushing_stone_prob_sweet), 1000000},
-  {CAVE_OFFSET(active_is_first_found), TRUE},
-  {CAVE_OFFSET(short_explosions), FALSE},
-  {CAVE_OFFSET(slime_predictable), TRUE},
-  {CAVE_OFFSET(snap_element), O_SPACE},
-  {CAVE_OFFSET(max_time), 999},
-
-  {CAVE_OFFSET(pal_timing), TRUE},
-  {CAVE_OFFSET(scheduling), GD_SCHEDULING_CRDR},
-  {CAVE_OFFSET(amoeba_enclosed_effect), O_PRE_DIA_1},    /* not immediately to diamond, but with animation */
-  {CAVE_OFFSET(water_does_not_flow_down), TRUE},
-  {CAVE_OFFSET(skeletons_worth_diamonds), 1},    /* in crdr, skeletons can also be used to open the gate */
-  {CAVE_OFFSET(gravity_affects_all), FALSE},    /* the intermission "survive" needs this flag */
-
-  {-1},
+  { CAVE_OFFSET(amoeba_growth_prob), 31250 },
+  { CAVE_OFFSET(amoeba_fast_growth_prob), 250000 },
+  { CAVE_OFFSET(amoeba_timer_started_immediately), FALSE },
+  { CAVE_OFFSET(amoeba_timer_wait_for_hatching), TRUE },
+  { CAVE_OFFSET(lineshift), TRUE },
+  { CAVE_OFFSET(wraparound_objects), TRUE },
+  { CAVE_OFFSET(voodoo_collects_diamonds), TRUE },
+  { CAVE_OFFSET(voodoo_dies_by_stone), TRUE },
+  { CAVE_OFFSET(voodoo_disappear_in_explosion), FALSE },
+  { CAVE_OFFSET(voodoo_any_hurt_kills_player), FALSE },
+  { CAVE_OFFSET(creatures_direction_auto_change_on_start), FALSE },
+  { CAVE_OFFSET(level_hatching_delay_time[0]), 2 },
+  { CAVE_OFFSET(intermission_instantlife), FALSE },
+  { CAVE_OFFSET(intermission_rewardlife), TRUE },
+  { CAVE_OFFSET(magic_timer_zero_is_infinite), FALSE },
+  { CAVE_OFFSET(magic_timer_wait_for_hatching), TRUE },
+  { CAVE_OFFSET(pushing_stone_prob), 250000 },
+  { CAVE_OFFSET(pushing_stone_prob_sweet), 1000000 },
+  { CAVE_OFFSET(active_is_first_found), TRUE },
+  { CAVE_OFFSET(short_explosions), FALSE },
+  { CAVE_OFFSET(slime_predictable), TRUE },
+  { CAVE_OFFSET(snap_element), O_SPACE },
+  { CAVE_OFFSET(max_time), 999 },
+
+  { CAVE_OFFSET(pal_timing), TRUE },
+  { CAVE_OFFSET(scheduling), GD_SCHEDULING_CRDR },
+  // not immediately to diamond, but with animation
+  { CAVE_OFFSET(amoeba_enclosed_effect), O_PRE_DIA_1 },
+  { CAVE_OFFSET(water_does_not_flow_down), TRUE },
+  // in crdr, skeletons can also be used to open the gate
+  { CAVE_OFFSET(skeletons_worth_diamonds), 1 },
+  // the intermission "survive" needs this flag
+  { CAVE_OFFSET(gravity_affects_all), FALSE },
+
+  { -1 },
 };
 
 GdPropertyDefault gd_defaults_crli[] =
 {
-  {CAVE_OFFSET(amoeba_growth_prob), 31250},
-  {CAVE_OFFSET(amoeba_fast_growth_prob), 250000},
-  {CAVE_OFFSET(amoeba_timer_started_immediately), FALSE},
-  {CAVE_OFFSET(amoeba_timer_wait_for_hatching), TRUE},
-  {CAVE_OFFSET(lineshift), TRUE},
-  {CAVE_OFFSET(wraparound_objects), TRUE},
-  {CAVE_OFFSET(voodoo_collects_diamonds), TRUE},
-  {CAVE_OFFSET(voodoo_dies_by_stone), TRUE},
-  {CAVE_OFFSET(voodoo_disappear_in_explosion), FALSE},
-  {CAVE_OFFSET(voodoo_any_hurt_kills_player), FALSE},
-  {CAVE_OFFSET(creatures_direction_auto_change_on_start), FALSE},
-  {CAVE_OFFSET(level_hatching_delay_time[0]), 2},
-  {CAVE_OFFSET(intermission_instantlife), FALSE},
-  {CAVE_OFFSET(intermission_rewardlife), TRUE},
-  {CAVE_OFFSET(magic_timer_wait_for_hatching), TRUE},
-  {CAVE_OFFSET(pushing_stone_prob), 250000},
-  {CAVE_OFFSET(pushing_stone_prob_sweet), 1000000},
-  {CAVE_OFFSET(active_is_first_found), TRUE},
-  {CAVE_OFFSET(short_explosions), FALSE},
-  {CAVE_OFFSET(slime_predictable), TRUE},
-  {CAVE_OFFSET(max_time), 999},
-
-  {CAVE_OFFSET(pal_timing), TRUE},
-  {CAVE_OFFSET(scheduling), GD_SCHEDULING_PLCK},
-  {CAVE_OFFSET(amoeba_enclosed_effect), O_PRE_DIA_1},    /* not immediately to diamond, but with animation */
-
-  {-1},
+  { CAVE_OFFSET(amoeba_growth_prob), 31250 },
+  { CAVE_OFFSET(amoeba_fast_growth_prob), 250000 },
+  { CAVE_OFFSET(amoeba_timer_started_immediately), FALSE },
+  { CAVE_OFFSET(amoeba_timer_wait_for_hatching), TRUE },
+  { CAVE_OFFSET(lineshift), TRUE },
+  { CAVE_OFFSET(wraparound_objects), TRUE },
+  { CAVE_OFFSET(voodoo_collects_diamonds), TRUE },
+  { CAVE_OFFSET(voodoo_dies_by_stone), TRUE },
+  { CAVE_OFFSET(voodoo_disappear_in_explosion), FALSE },
+  { CAVE_OFFSET(voodoo_any_hurt_kills_player), FALSE },
+  { CAVE_OFFSET(creatures_direction_auto_change_on_start), FALSE },
+  { CAVE_OFFSET(level_hatching_delay_time[0]), 2 },
+  { CAVE_OFFSET(intermission_instantlife), FALSE },
+  { CAVE_OFFSET(intermission_rewardlife), TRUE },
+  { CAVE_OFFSET(magic_timer_zero_is_infinite), FALSE },
+  { CAVE_OFFSET(magic_timer_wait_for_hatching), TRUE },
+  { CAVE_OFFSET(pushing_stone_prob), 250000 },
+  { CAVE_OFFSET(pushing_stone_prob_sweet), 1000000 },
+  { CAVE_OFFSET(active_is_first_found), TRUE },
+  { CAVE_OFFSET(short_explosions), FALSE },
+  { CAVE_OFFSET(slime_predictable), TRUE },
+  { CAVE_OFFSET(max_time), 999 },
+
+  { CAVE_OFFSET(pal_timing), TRUE },
+  { CAVE_OFFSET(scheduling), GD_SCHEDULING_PLCK },
+  // not immediately to diamond, but with animation
+  { CAVE_OFFSET(amoeba_enclosed_effect), O_PRE_DIA_1 },
+
+  { -1 },
 };
 
-/* internal character (letter) codes in c64 games.
-   missing: "triple line" after >, diamond between ()s, player's head after )
-   used for converting names of caves imported from crli and other types of binary data */
-const char gd_bd_internal_chars[] = "            ,!./0123456789:*<=>  ABCDEFGHIJKLMNOPQRSTUVWXYZ( ) _";
 
-/* used for bdcff engine flag. */
+// internal character (letter) codes in c64 games.
+// missing: "triple line" after >, diamond between ()s, player's head after )
+// used for converting names of caves imported from crli and other types of binary data
+const char gd_bd_internal_chars[] =
+  "            ,!./0123456789:*<=>  ABCDEFGHIJKLMNOPQRSTUVWXYZ( ) _";
+
+// used for bdcff engine flag.
 const char *gd_engines[] =
 {
   "BD1",
@@ -421,7 +438,7 @@ const char *gd_engines[] =
   "CrLi"
 };
 
-/* to convert predictable slime values to bit masks */
+// to convert predictable slime values to bit masks
 static int slime_shift_msb(int c64_data)
 {
   int i, perm;
@@ -429,15 +446,15 @@ static int slime_shift_msb(int c64_data)
   perm = 0;
 
   for (i = 0; i < c64_data; i++)
-    /* shift in this many msb 1's */
+    // shift in this many msb 1's
     perm = (0x100|perm) >> 1;
 
   return perm;
 }
 
-static GdElement bd1_import(guint8 c, int i)
+static GdElement bd1_import(byte c, int i)
 {
-  if (c < G_N_ELEMENTS(bd1_import_table))
+  if (c < ARRAY_SIZE(bd1_import_table))
     return bd1_import_table[c];
 
   Warn("Invalid BD1 element in imported file at cave data %d: %d", i, c);
@@ -445,8 +462,8 @@ static GdElement bd1_import(guint8 c, int i)
   return O_UNKNOWN;
 }
 
-/* deluxe caves 1 contained a special element, non-sloped brick. */
-static GdElement deluxecaves_1_import(guint8 c, int i)
+// deluxe caves 1 contained a special element, non-sloped brick.
+static GdElement deluxecaves_1_import(byte c, int i)
 {
   GdElement e = bd1_import(c, i);
 
@@ -456,9 +473,9 @@ static GdElement deluxecaves_1_import(guint8 c, int i)
   return e;
 }
 
-static GdElement firstboulder_import(guint8 c, int i)
+static GdElement firstboulder_import(byte c, int i)
 {
-  if (c < G_N_ELEMENTS(firstboulder_import_table))
+  if (c < ARRAY_SIZE(firstboulder_import_table))
     return firstboulder_import_table[c];
 
   Warn("Invalid 1stB element in imported file at cave data %d: %d", i, c);
@@ -466,10 +483,10 @@ static GdElement firstboulder_import(guint8 c, int i)
   return O_UNKNOWN;
 }
 
-static GdElement crazylight_import(guint8 c, int i)
+static GdElement crazylight_import(byte c, int i)
 {
-  if (c < G_N_ELEMENTS(gd_crazylight_import_table))
-    return gd_crazylight_import_table[c] & O_MASK;    /* & O_MASK: do not import "scanned" flag */
+  if (c < ARRAY_SIZE(gd_crazylight_import_table))
+    return gd_crazylight_import_table[c] & O_MASK;    // & O_MASK: do not import "scanned" flag
 
   Warn("Invalid CrLi element in imported file at cave data %d: %d", i, c);
 
@@ -504,7 +521,7 @@ GdPropertyDefault *gd_get_engine_default_array(GdEngine engine)
       return gd_defaults_crli;
       break;
 
-      /* to avoid compiler warning */
+      // to avoid compiler warning
     case GD_ENGINE_INVALID:
       break;
   }
@@ -516,8 +533,8 @@ void gd_cave_set_engine_defaults(GdCave *cave, GdEngine engine)
 {
   gd_cave_set_defaults_from_array(cave, gd_get_engine_default_array(engine));
 
-  /* these have hardcoded ckdelay. */
-  /* setting this ckdelay array does not fit into the gd_struct_default scheme. */
+  // these have hardcoded ckdelay.
+  // setting this ckdelay array does not fit into the gd_struct_default scheme.
   if (engine == GD_ENGINE_BD1)
   {
     cave->level_ckdelay[0] = 12;
@@ -529,11 +546,11 @@ void gd_cave_set_engine_defaults(GdCave *cave, GdEngine engine)
 
   if (engine == GD_ENGINE_BD2)
   {
-    cave->level_ckdelay[0] = 9;    /* 180ms */
-    cave->level_ckdelay[1] = 8;    /* 160ms */
-    cave->level_ckdelay[2] = 7;    /* 140ms */
-    cave->level_ckdelay[3] = 6;    /* 120ms */
-    cave->level_ckdelay[4] = 6;    /* 120ms (!) not faster than level4 */
+    cave->level_ckdelay[0] = 9;    // 180ms
+    cave->level_ckdelay[1] = 8;    // 160ms
+    cave->level_ckdelay[2] = 7;    // 140ms
+    cave->level_ckdelay[3] = 6;    // 120ms
+    cave->level_ckdelay[4] = 6;    // 120ms (!) not faster than level4
   }
 }
 
@@ -548,13 +565,13 @@ GdEngine gd_cave_get_engine_from_string(const char *param)
   return GD_ENGINE_INVALID;
 }
 
-/****************************************************************************
- *
- * cave import routines.
- * take a cave, data, and maybe remaining bytes.
- * return the number of bytes read, -1 if error.
- *
- ****************************************************************************/
+// ============================================================================
+//
+// cave import routines.
+// take a cave, data, and maybe remaining bytes.
+// return the number of bytes read, -1 if error.
+//
+// ============================================================================
 
 /*
   take care of required diamonds values == 0 or > 100.
@@ -567,20 +584,20 @@ GdEngine gd_cave_get_engine_from_string(const char *param)
   http://www.boulder-dash.nl/forum/viewtopic.php?t=88
 */
 
-/* import bd1 cave data into our format. */
-static int cave_copy_from_bd1(GdCave *cave, const guint8 *data, int remaining_bytes,
+// import bd1 cave data into our format.
+static int cave_copy_from_bd1(GdCave *cave, const byte *data, int remaining_bytes,
                              GdCavefileFormat format)
 {
   int length, direction;
   int index;
   int level;
   int x1, y1, x2, y2;
-  guint8 code;
+  byte code;
   GdElement elem;
-  GdElement (* import_func) (guint8 c, int i);
+  GdElement (* import_func) (byte c, int i);
   int i;
 
-  /* cant be shorted than this: header + no objects + delimiter */
+  // cant be shorted than this: header + no objects + delimiter
   if (remaining_bytes < 33)
   {
     Error("truncated BD1 cave data, %d bytes", remaining_bytes);
@@ -598,14 +615,14 @@ static int cave_copy_from_bd1(GdCave *cave, const guint8 *data, int remaining_by
   else
     import_func = bd1_import;
 
-  /* set visible size for intermission */
+  // set visible size for intermission
   if (cave->intermission)
   {
     cave->x2 = 19;
     cave->y2 = 11;
   }
 
-  /* cave number data[0] */
+  // cave number data[0]
   cave->diamond_value = data[2];
   cave->extra_diamond_value = data[3];
 
@@ -613,47 +630,48 @@ static int cave_copy_from_bd1(GdCave *cave, const guint8 *data, int remaining_by
   {
     cave->level_amoeba_time[level] = data[1];
 
-    /* 0 immediately underflowed to 999, so we use 999. example: sendydash 3, cave 02. */
+    // 0 immediately underflowed to 999, so we use 999. example: sendydash 3, cave 02.
     if (cave->level_amoeba_time[level] == 0)
       cave->level_amoeba_time[level] = 999;
 
     cave->level_magic_wall_time[level] = data[1];
     cave->level_rand[level] = data[4 + level];
-    cave->level_diamonds[level] = data[9 + level] % 100;    /* check comment above */
+    cave->level_diamonds[level] = data[9 + level] % 100;    // check comment above
 
-    /* gate opening is checked AFTER adding to diamonds collected, so 0 here means 100 to collect */
+    // gate opening is checked AFTER adding to diamonds collected, so 0 here means 100 to collect
     if (cave->level_diamonds[level] == 0)
       cave->level_diamonds[level] = 100;
     cave->level_time[level] = data[14 + level];
   }
 
-  /* LogicDeLuxe extension: acid
-     $16 Acid speed (unused in the original BD1)
-     $17 Bit 2: if set, Acid's original position converts to explosion puff during spreading.
-     Otherwise, Acid remains intact, ie. it's just growing. (unused in the original BD1)
-     $1C Acid eats this element. (also Probability of element 1)
-
-     there is no problem importing these; as other bd1 caves did not contain acid at all,
-     so it does not matter how we set the values.
+  /*
+    LogicDeLuxe extension: acid
+    $16 Acid speed (unused in the original BD1)
+    $17 Bit 2: if set, Acid's original position converts to explosion puff during spreading.
+    Otherwise, Acid remains intact, ie. it's just growing. (unused in the original BD1)
+    $1C Acid eats this element. (also Probability of element 1)
+
+    there is no problem importing these; as other bd1 caves did not contain acid at all,
+    so it does not matter how we set the values.
   */
 
-  /* 0x1c index: same as probability1 !!!!! don't be surprised. we do a &0x3f because of this */
+  // 0x1c index: same as probability1 !!!!! don't be surprised. we do a &0x3f because of this
   cave->acid_eats_this = import_func(data[0x1c] & 0x3F, 0x1c);
 
-  /* acid speed, *1e6 as probabilities are stored in int */
+  // acid speed, *1e6 as probabilities are stored in int
   cave->acid_spread_ratio = data[0x16] / 255.0 * 1E6 + 0.5;
 
   cave->acid_turns_to = (data[0x17] & (1 << 2)) ? O_EXPLODE_3 : O_ACID;
 
-  cave->colorb = GD_GDASH_BLACK;    /* border - black */
-  cave->color0 = GD_GDASH_BLACK;    /* background - black */
+  cave->colorb = GD_GDASH_BLACK;    // border - black
+  cave->color0 = GD_GDASH_BLACK;    // background - black
   cave->color1= GD_GDASH_RED;
   cave->color2 = GD_GDASH_PURPLE;
   cave->color3 = GD_GDASH_YELLOW;
-  cave->color4 = cave->color3;    /* in bd1, amoeba was color3 */
-  cave->color5 = cave->color3;    /* no slime, but let it be color 3 */
+  cave->color4 = cave->color3;    // in bd1, amoeba was color3
+  cave->color5 = cave->color3;    // no slime, but let it be color 3
 
-  /* random fill */
+  // random fill
   for (i = 0; i < 4; i++)
   {
     cave->random_fill[i] = import_func(data[24 + i], 24 + i);
@@ -669,13 +687,13 @@ static int cave_copy_from_bd1(GdCave *cave, const guint8 *data, int remaining_by
   {
     code = data[index];
 
-    /* crazy dream 3 extension: */
+    // crazy dream 3 extension:
     if (code == 0x0f)
     {
       int x1, y1, nx, ny, dx, dy;
       int x, y;
 
-      /* as this one uses nonstandard dx dy values, create points instead */
+      // as this one uses nonstandard dx dy values, create points instead
       elem = import_func(data[index + 1], index + 1);
       x1 = data[index + 2];
       y1 = data[index + 3] - 2;
@@ -690,7 +708,7 @@ static int cave_copy_from_bd1(GdCave *cave, const guint8 *data, int remaining_by
        {
          int pos = x1 + y1 * 40 + y * dy * 40 + x * dx;
 
-         cave->objects = g_list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, pos % 40, pos / 40, elem));
+         cave->objects = list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, pos % 40, pos / 40, elem));
        }
       }
 
@@ -698,27 +716,27 @@ static int cave_copy_from_bd1(GdCave *cave, const guint8 *data, int remaining_by
     }
     else
     {
-      /* object is code&3f, object type is upper 2 bits */
+      // object is code & 3f, object type is upper 2 bits
       elem = import_func(code & 0x3F, index);
 
       switch ((code >> 6) & 3)
       {
-       case 0:                /* 00: POINT */
+       case 0:                // 00: POINT
          x1 = data[index + 1];
          y1 = data[index + 2] - 2;
 
          if (x1 >= cave->w || y1 >= cave->h)
            Warn("invalid point coordinates %d,%d at byte %d", x1, y1, index);
 
-         cave->objects = g_list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem));
+         cave->objects = list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem));
 
          index += 3;
          break;
 
-       case 1:                /* 01: LINE */
+       case 1:                // 01: LINE
          x1 = data[index + 1];
          y1 = data[index + 2] - 2;
-         length = (gint8)data[index + 3] - 1;
+         length = (byte)data[index + 3] - 1;
          direction = data[index + 4];
 
          if (length < 0)
@@ -742,17 +760,17 @@ static int cave_copy_from_bd1(GdCave *cave, const guint8 *data, int remaining_by
                y2 >= cave->h)
              Warn("invalid line coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index);
 
-           cave->objects = g_list_append(cave->objects, gd_object_new_line(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem));
+           cave->objects = list_append(cave->objects, gd_object_new_line(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem));
          }
 
          index += 5;
          break;
 
-       case 2:                /* 10: FILLED RECTANGLE */
+       case 2:                // 10: FILLED RECTANGLE
          x1 = data[index + 1];
          y1 = data[index + 2] - 2;
-         x2 = x1 + data[index + 3] - 1;    /* width */
-         y2 = y1 + data[index + 4] - 1;    /* height */
+         x2 = x1 + data[index + 3] - 1;    // width
+         y2 = y1 + data[index + 4] - 1;    // height
 
          if (x1 >= cave->w ||
              y1 >= cave->h ||
@@ -760,12 +778,12 @@ static int cave_copy_from_bd1(GdCave *cave, const guint8 *data, int remaining_by
              y2 >= cave->h)
            Warn("invalid filled rectangle coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index);
 
-         cave->objects = g_list_append(cave->objects, gd_object_new_filled_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem, import_func(data[index + 5], index + 5)));
+         cave->objects = list_append(cave->objects, gd_object_new_filled_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem, import_func(data[index + 5], index + 5)));
 
          index += 6;
          break;
 
-       case 3:                /* 11: OPEN RECTANGLE (OUTLINE) */
+       case 3:                // 11: OPEN RECTANGLE (OUTLINE)
          x1 = data[index + 1];
          y1 = data[index + 2] - 2;
          x2 = x1 + data[index + 3] - 1;
@@ -777,7 +795,7 @@ static int cave_copy_from_bd1(GdCave *cave, const guint8 *data, int remaining_by
              y2 >= cave->h)
            Warn("invalid rectangle coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index);
 
-         cave->objects = g_list_append(cave->objects, gd_object_new_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem));
+         cave->objects = list_append(cave->objects, gd_object_new_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem));
 
          index += 5;
          break;
@@ -794,9 +812,9 @@ static int cave_copy_from_bd1(GdCave *cave, const guint8 *data, int remaining_by
   return index + 1;
 }
 
-/* import bd2 cave data into our format. return number of bytes if pointer passed.
-   this is pretty much the same as above, only the encoding was different. */
-static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_bytes,
+// import bd2 cave data into our format. return number of bytes if pointer passed.
+// this is pretty much the same as above, only the encoding was different.
+static int cave_copy_from_bd2(GdCave *cave, const byte *data, int remaining_bytes,
                              GdCavefileFormat format)
 {
   int index;
@@ -813,10 +831,10 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by
 
   gd_cave_set_engine_defaults(cave, GD_ENGINE_BD2);
 
-  if (format==GD_FORMAT_BD2_ATARI)
+  if (format == GD_FORMAT_BD2_ATARI)
     cave->scheduling = GD_SCHEDULING_BD2_PLCK_ATARI;
 
-  /* set visible size for intermission */
+  // set visible size for intermission
   if (cave->intermission)
   {
     cave->x2 = 19;
@@ -828,12 +846,12 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by
 
   for (i = 0; i < 5; i++)
   {
-    /* 0 immediately underflowed to 999, so we use 999. example: sendydash 3, cave 02. */
-    cave->level_amoeba_time[i] = data[0]==0 ? 999 : data[0];
+    // 0 immediately underflowed to 999, so we use 999. example: sendydash 3, cave 02.
+    cave->level_amoeba_time[i] = data[0] == 0 ? 999 : data[0];
     cave->level_rand[i] = data[13 + i];
 
-    /* gate opening is checked AFTER adding to diamonds collected, so 0 here is 1000 needed */
-    cave->level_diamonds[i] = data[8 + i]==0 ? 1000 : data[8 + i];
+    // gate opening is checked AFTER adding to diamonds collected, so 0 here is 1000 needed
+    cave->level_diamonds[i] = data[8 + i] == 0 ? 1000 : data[8 + i];
     cave->level_time[i] = data[3 + i];
     cave->level_magic_wall_time[i] = data[0];
   }
@@ -858,12 +876,12 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by
 
     switch (data[index])
     {
-      case 0:                /* LINE */
+      case 0:                // LINE
        elem = bd1_import(data[index + 1], index + 1);
        y1 = data[index + 2];
        x1 = data[index + 3];
 
-       /* they are multiplied by two - 0 is up, 2 is upright, 4 is right... */
+       // they are multiplied by two - 0 is up, 2 is upright, 4 is right...
        direction = data[index + 4] / 2;
        length = data[index + 5] - 1;
 
@@ -882,16 +900,16 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by
            y2 >= cave->h)
          Warn("invalid line coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index);
 
-       cave->objects = g_list_append(cave->objects, gd_object_new_line(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem));
+       cave->objects = list_append(cave->objects, gd_object_new_line(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem));
 
        index += 6;
        break;
 
-      case 1:                /* OPEN RECTANGLE */
+      case 1:                // OPEN RECTANGLE
        elem = bd1_import(data[index + 1], index + 1);
        y1 = data[index + 2];
        x1 = data[index + 3];
-       y2 = y1 + data[index + 4] - 1;    /* height */
+       y2 = y1 + data[index + 4] - 1;    // height
        x2 = x1 + data[index + 5] - 1;
 
        if (x1 >= cave->w ||
@@ -900,12 +918,12 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by
            y2 >= cave->h)
          Warn("invalid rectangle coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index);
 
-       cave->objects = g_list_append(cave->objects, gd_object_new_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem));
+       cave->objects = list_append(cave->objects, gd_object_new_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem));
 
        index += 6;
        break;
 
-      case 2:                /* FILLED RECTANGLE */
+      case 2:                // FILLED RECTANGLE
        elem = bd1_import(data[index + 1], index + 1);
        y1 = data[index + 2];
        x1 = data[index + 3];
@@ -918,12 +936,12 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by
            y2 >= cave->h)
          Warn("invalid filled rectangle coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index);
 
-       cave->objects = g_list_append(cave->objects, gd_object_new_filled_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem, bd1_import(data[index+6], index+6)));
+       cave->objects = list_append(cave->objects, gd_object_new_filled_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem, bd1_import(data[index+6], index+6)));
 
        index += 7;
        break;
 
-      case 3:                /* POINT */
+      case 3:                // POINT
        elem = bd1_import(data[index + 1], index + 1);
        y1 = data[index + 2];
        x1 = data[index + 3];
@@ -932,23 +950,23 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by
            y1 >= cave->h)
          Warn("invalid point coordinates %d,%d at byte %d", x1, y1, index);
 
-       cave->objects = g_list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem));
+       cave->objects = list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem));
 
        index += 4;
        break;
 
-      case 4:                /* RASTER */
+      case 4:                // RASTER
        elem = bd1_import(data[index + 1], index + 1);
-       y1 = data[index + 2];   /* starting pos */
+       y1 = data[index + 2];     // starting pos
        x1 = data[index + 3];
-       ny = data[index + 4] - 1; /* number of elements */
+       ny = data[index + 4] - 1; // number of elements
        nx = data[index + 5] - 1;
-       dy = data[index + 6];   /* displacement */
+       dy = data[index + 6];     // displacement
        dx = data[index + 7];
-       y2 = y1 + dy * ny;    /* calculate rectangle */
+       y2 = y1 + dy * ny;        // calculate rectangle
        x2 = x1 + dx * nx;
 
-       /* guess this has to be here, after x2,y2 calculation, because of some bugs in imported data */
+       // guess this has to be here, after x2,y2 calculation, because of some bugs in imported data
        if (dy < 1)
          dy = 1;
        if (dx < 1)
@@ -960,24 +978,24 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by
            y2 >= cave->h)
          Warn("invalid raster coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index);
 
-       cave->objects = g_list_append(cave->objects, gd_object_new_raster(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, dx, dy, elem));
+       cave->objects = list_append(cave->objects, gd_object_new_raster(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, dx, dy, elem));
 
        index += 8;
        break;
 
       case 5:
-       /* profi boulder extension: bitmap */
+       // profi boulder extension: bitmap
        elem = bd1_import(data[index + 1], index + 1);
-       bytes = data[index + 2];    /* number of bytes in bitmap */
+       bytes = data[index + 2];    // number of bytes in bitmap
 
        if (bytes >= cave->w * cave->h / 8)
          Warn("invalid bitmap length at byte %d", index - 4);
 
        addr = 0;
-       addr += data[index + 3];    /*msb */
-       addr += data[index + 4] << 8;    /*lsb */
+       addr += data[index + 3];         // msb
+       addr += data[index + 4] << 8;    // lsb
 
-       /* this was a pointer to the cave work memory (used during game). */
+       // this was a pointer to the cave work memory (used during game).
        addr -= 0x0850;
 
        if (addr >= cave->w * cave->h)
@@ -988,40 +1006,40 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by
 
        for (i = 0; i < bytes; i++)
        {
-         /* for ("bytes" number of bytes) */
+         // for ("bytes" number of bytes)
          val = data[index + 5 + i];
 
          for (n = 0; n < 8; n++)
          {
-           /* for (8 bits in a byte) */
-           if ((val & 1) != 0) /* convert to single points... */
-             cave->objects = g_list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem));
+           // for (8 bits in a byte)
+           if ((val & 1) != 0) // convert to single points...
+             cave->objects = list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem));
 
            val >>= 1;
-           x1++;   /* next cave pos */
+           x1++;   // next cave pos
 
            if (x1 >= cave->w)
            {
-             /* maybe next line in map */
+             // maybe next line in map
              x1 = 0;
              y1++;
            }
          }
        }
 
-       index += 5 + bytes;    /* 5 description bytes and "bytes" data bytes */
+       index += 5 + bytes;    // 5 description bytes and "bytes" data bytes
        break;
 
-      case 6:                /* JOIN */
+      case 6:                // JOIN
        dy = data[index + 3] / 40;
-       dx = data[index + 3] % 40;    /* same byte!!! */
-       cave->objects = g_list_append(cave->objects, gd_object_new_join(GD_OBJECT_LEVEL_ALL, dx, dy, bd1_import(data[index+1], index+1), bd1_import(data[index+2], index+2)));
+       dx = data[index + 3] % 40;    // same byte!!!
+       cave->objects = list_append(cave->objects, gd_object_new_join(GD_OBJECT_LEVEL_ALL, dx, dy, bd1_import(data[index+1], index+1), bd1_import(data[index+2], index+2)));
 
        index += 4;
        break;
 
-      case 7:             /* SLIME PERMEABILITY */
-       /* interesting this is set here, and not in the cave header */
+      case 7:             // SLIME PERMEABILITY
+       // interesting this is set here, and not in the cave header
        for (i = 0; i < 5; i++)
          cave->level_slime_permeability_c64[i] = data[index + 1];
 
@@ -1029,8 +1047,8 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by
        break;
 
       case 9:
-       /* profi boulder extension by player: plck-like cave map. the import
-          routine (any2gdash) inserts it here. */
+       // profi boulder extension by player: plck-like cave map. the import
+       // routine (any2gdash) inserts it here.
        if (cave->map != NULL)
        {
          Error("contains more than one PLCK map");
@@ -1041,32 +1059,32 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by
 
        for (x = 0; x < cave->w; x++)
        {
-         /* fill the first and the last row with steel wall. */
+         // fill the first and the last row with steel wall.
          cave->map[0][x] = O_STEEL;
          cave->map[cave->h - 1][x] = O_STEEL;
        }
 
-       n = 0;    /* number of bytes read from map */
+       n = 0;    // number of bytes read from map
 
-       /* the first and the last rows are not stored. */
+       // the first and the last rows are not stored.
        for (y = 1; y < cave->h - 1; y++)
        {
          for (x = 0; x < cave->w; x += 2)
          {
-           cave->map[y][x]     = plck_import_nybble[data[index + 3 + n] >> 4];    /* msb 4 bits */
-           cave->map[y][x + 1] = plck_import_nybble[data[index + 3 + n] % 16];    /* lsb 4 bits */
+           cave->map[y][x]     = plck_import_nybble[data[index + 3 + n] >> 4];    // msb 4 bits
+           cave->map[y][x + 1] = plck_import_nybble[data[index + 3 + n] % 16];    // lsb 4 bits
            n++;
          }
        }
 
-       /* the position of inbox is stored. this is to check the cave */
+       // the position of inbox is stored. this is to check the cave
        ry = data[index + 1] - 2;
        rx = data[index + 2];
 
-       /* at the start of the cave, bd scrolled to the last player placed during the drawing
-          (setup) of the cave.
-          i think this is why a map also stored the coordinates of the player - we can use
-          this to check its integrity */
+       // at the start of the cave, bd scrolled to the last player placed during the drawing
+       // (setup) of the cave.
+       // i think this is why a map also stored the coordinates of the player - we can use
+       // this to check its integrity
        if (rx >= cave->w || ry < 0 ||
            ry >= cave->h || cave->map[ry][rx] != O_INBOX)
          Warn ("embedded PLCK map may be corrupted, player coordinates %d,%d", rx, rx);
@@ -1077,7 +1095,7 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by
       default:
        Warn ("unknown bd2 extension no. %02x at byte %d", data[index], index);
 
-       index += 1;    /* skip that byte */
+       index += 1;    // skip that byte
     }
   }
 
@@ -1087,32 +1105,32 @@ static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_by
     return -1;
   }
 
-  /* skip delimiter */
+  // skip delimiter
   index++;
 
-  /* animation byte - told the engine which objects to animate - to make game faster */
+  // animation byte - told the engine which objects to animate - to make game faster
   index++;
 
-  /* the colors from the memory dump are appended here by any2gdash */
-  cave->colorb = GD_GDASH_BLACK;    /* border - black */
-  cave->color0 = GD_GDASH_BLACK;    /* background - black */
+  // the colors from the memory dump are appended here by any2gdash
+  cave->colorb = GD_GDASH_BLACK;    // border - black
+  cave->color0 = GD_GDASH_BLACK;    // background - black
   cave->color1 = GD_GDASH_RED;
   cave->color2 = GD_GDASH_PURPLE;
   cave->color3 = GD_GDASH_YELLOW;
-  cave->color4 = cave->color3;    /* in bd1, amoeba was color3 */
-  cave->color5 = cave->color3;    /* no slime, but let it be color 3 */
+  cave->color4 = cave->color3;      // in bd1, amoeba was color3
+  cave->color5 = cave->color3;      // no slime, but let it be color 3
 
   return index;
 }
 
-/* import plck cave data into our format.
-   length is always 512 bytes, and contains if it is an intermission cave. */
-static int cave_copy_from_plck(GdCave *cave, const guint8 *data,
+// import plck cave data into our format.
+// length is always 512 bytes, and contains if it is an intermission cave.
+static int cave_copy_from_plck(GdCave *cave, const byte *data,
                               int remaining_bytes, GdCavefileFormat format)
 {
-  /* i don't really think that all this table is needed, but included to be complete. */
-  /* this is for the dirt and expanding wall looks like effect. */
-  /* it also contains the individual frames */
+  // i don't really think that all this table is needed, but included to be complete.
+  // this is for the dirt and expanding wall looks like effect.
+  // it also contains the individual frames
   static GdElement plck_graphic_table[] =
   {
     /* 3000 */ O_UNKNOWN, O_UNKNOWN, O_UNKNOWN, O_UNKNOWN, O_UNKNOWN, O_UNKNOWN, O_UNKNOWN, O_UNKNOWN,
@@ -1144,32 +1162,32 @@ static int cave_copy_from_plck(GdCave *cave, const guint8 *data,
 
   if (cave->intermission)
   {
-    /* set visible size for intermission */
+    // set visible size for intermission
     cave->x2 = 19;
     cave->y2 = 11;
   }
 
-  /* cave selection table, was not part of cave data, rather given in game packers.
-   * if a new enough version of any2gdash is used, it will put information after the cave.
-   * detect this here and act accordingly */
+  // cave selection table, was not part of cave data, rather given in game packers.
+  // if a new enough version of any2gdash is used, it will put information after the cave.
+  // detect this here and act accordingly
   if ((data[0x1f0] == data[0x1f1] - 1) &&
       (data[0x1f0] == 0x19 ||
        data[0x1f0] == 0x0e))
   {
     int j;
 
-    /* found selection table */
+    // found selection table
     cave->selectable = data[0x1f0] == 0x19;
     gd_strcpy(cave->name, "              ");
 
     for (j = 0; j < 12; j++)
       cave->name[j] = data[0x1f2 + j];
 
-    g_strchomp(cave->name);    /* remove spaces */
+    chompString(cave->name);    // remove spaces
   }
   else
   {
-    /* no selection info found, let intermissions be unselectable */
+    // no selection info found, let intermissions be unselectable
     cave->selectable = !cave->intermission;
   }
 
@@ -1178,17 +1196,17 @@ static int cave_copy_from_plck(GdCave *cave, const guint8 *data,
 
   for (i = 0; i < 5; i++)
   {
-    /* plck doesnot really have levels, so just duplicate data five times */
+    // plck doesnot really have levels, so just duplicate data five times
     cave->level_amoeba_time[i] = data[0x1c4];
 
-    /* immediately underflowed to 999, so we use 999. example: sendydash 3, cave 02. */
+    // immediately underflowed to 999, so we use 999. example: sendydash 3, cave 02.
     if (cave->level_amoeba_time[i] == 0)
       cave->level_amoeba_time[i] = 999;
 
     cave->level_time[i] = data[0x1ba];
     cave->level_diamonds[i] = data[0x1bc];
 
-    /* gate opening is checked AFTER adding to diamonds collected, so 0 here is 1000 needed */
+    // gate opening is checked AFTER adding to diamonds collected, so 0 here is 1000 needed
     if (cave->level_diamonds[i] == 0)
       cave->level_diamonds[i] = 1000;
 
@@ -1197,68 +1215,62 @@ static int cave_copy_from_plck(GdCave *cave, const guint8 *data,
     cave->level_slime_permeability_c64[i] = slime_shift_msb(data[0x1c2]);
   }
 
-  cave->colorb = GD_GDASH_BLACK;    /* border - black */
-  cave->color0 = GD_GDASH_BLACK;    /* background - black */
+  cave->colorb = GD_GDASH_BLACK;    // border - black
+  cave->color0 = GD_GDASH_BLACK;    // background - black
   cave->color1 = GD_GDASH_RED;
   cave->color2 = GD_GDASH_PURPLE;
   cave->color3 = GD_GDASH_YELLOW;
-  cave->color4 = cave->color3;    /* in bd1, amoeba was color3 */
-  cave->color5 = cave->color3;    /* no slime, but let it be color 3 */
+  cave->color4 = cave->color3;      // in bd1, amoeba was color3
+  cave->color5 = cave->color3;      // no slime, but let it be color 3
 
-  /* ... the cave is stored like a map. */
+  // ... the cave is stored like a map.
   cave->map = gd_cave_map_new(cave, GdElement);
 
-  /* cave map looked like this. */
-  /* two rows of steel wall ($44's), then cave description, 20 bytes (40 nybbles) for each line. */
-  /* the bottom and top lines were not stored... originally. */
-  /* some games write to the top line; so we import that, too. */
-  /* also dlp 155 allowed writing to the bottom line; the first 20 $44-s now store the bottom line. */
-  /* so the cave is essentially shifted one row down in the file: cave->map[y][x] = data[... y+1 mod height ][x] */
+  // cave map looked like this.
+  // two rows of steel wall ($44's), then cave description, 20 bytes (40 nybbles) for each line.
+  // the bottom and top lines were not stored... originally.
+  // some games write to the top line; so we import that, too.
+  // also dlp 155 allowed writing to the bottom line; the first 20 $44-s now store the bottom line.
+  // so the cave is essentially shifted one row down in the file:
+  // cave->map[y][x] = data[... y+1 mod height ][x]
   for (y = 0; y < cave->h; y++)
   {
     for (x = 0; x < cave->w; x += 2)
     {
-      /* msb 4 bits: we do not check index ranges, as >>4 and %16 will result in 0..15 */
+      // msb 4 bits: we do not check index ranges, as >>4 and %16 will result in 0..15
       cave->map[y][x]     = plck_import_nybble[data[((y + 1) % cave->h) * 20 + x / 2] >> 4];
 
-      /* lsb 4 bits */
+      // lsb 4 bits
       cave->map[y][x + 1] = plck_import_nybble[data[((y + 1) % cave->h) * 20 + x / 2] % 16];
     }
   }
 
-  /* FOR NOW, WE DO NOT IMPORT THE BOTTOM BORDER */
+  // FOR NOW, WE DO NOT IMPORT THE BOTTOM BORDER
   for (x = 0; x < cave->w; x++)
     cave->map[cave->h - 1][x] = O_STEEL;
 
-  /*
-    if (steels && data[0]==0x55)
-    cave->map[cave->h - 1][0] = cave->map[cave->h - 1][1] = O_STEEL;
-  */
-
-  /* check for diego-effects */
-  /* c64 magic values (byte sequences)  0x20 0x90 0x46, also 0xa9 0x1c 0x85 */
-  if ((data[0x1e5] == 0x20 &&
-       data[0x1e6] == 0x90 &&
-       data[0x1e7] == 0x46) ||
-      (data[0x1e5] == 0xa9 &&
-       data[0x1e6] == 0x1c &&
-       data[0x1e7] == 0x85))
+  // check for diego-effects
+  // c64 magic values (byte sequences)  0x20 0x90 0x46, also 0xa9 0x1c 0x85
+  if ((data[0x1e5] == 0x20 && data[0x1e6] == 0x90 && data[0x1e7] == 0x46) ||
+      (data[0x1e5] == 0xa9 && data[0x1e6] == 0x1c && data[0x1e7] == 0x85))
   {
-    /* diego effects enabled. */
+    // diego effects enabled.
     cave->stone_bouncing_effect = bd1_import(data[0x1ea], 0x1ea);
     cave->diamond_falling_effect = bd1_import(data[0x1eb], 0x1eb);
 
-    /* explosions: 0x1e was explosion 5, if this is set to default, we also do not read it,
-       as in our engine this would cause an O_EXPLODE_5 to stay there. */
+    // explosions: 0x1e was explosion 5, if this is set to default, we also do not read it,
+    // as in our engine this would cause an O_EXPLODE_5 to stay there.
     if (data[0x1ec] != 0x1e)
       cave->explosion_effect = bd1_import(data[0x1ec], 0x1ec);
 
-    /* pointer to element graphic.
-       two bytes/column (one element), that is data[xxx] % 16 / 2.
-       also there are 16bytes/row.
-       that is, 0x44 = stone, upper left character. 0x45 = upper right,
-       0x54 = lower right, 0x55 = lower right.
-       so high nybble must be shifted right twice -> data[xxx]/16*4. */
+    /*
+      pointer to element graphic.
+      two bytes/column (one element), that is data[xxx] % 16 / 2.
+      also there are 16bytes/row.
+      that is, 0x44 = stone, upper left character. 0x45 = upper right,
+      0x54 = lower right, 0x55 = lower right.
+      so high nybble must be shifted right twice -> data[xxx]/16*4.
+    */
     cave->dirt_looks_like           = plck_graphic_table[(data[0x1ed] / 16) * 4 + (data[0x1ed] % 16) / 2];
     cave->expanding_wall_looks_like = plck_graphic_table[(data[0x1ee] / 16) * 4 + (data[0x1ee] % 16) / 2];
 
@@ -1269,36 +1281,36 @@ static int cave_copy_from_plck(GdCave *cave, const guint8 *data,
   return 512;
 }
 
-/* no one's delight boulder dash essentially: rle compressed plck maps. */
-static int cave_copy_from_dlb(GdCave *cave, const guint8 *data, int remaining_bytes)
+// no one's delight boulder dash essentially: rle compressed plck maps.
+static int cave_copy_from_dlb(GdCave *cave, const byte *data, int remaining_bytes)
 {
-  guint8 decomp[512];
+  byte decomp[512];
   enum
   {
-    START,        /* initial state */
-    SEPARATOR,    /* got a separator */
-    RLE,          /* after a separator, got the byte to duplicate */
-    NORMAL        /* normal, copy bytes till separator */
+    START,        // initial state
+    SEPARATOR,    // got a separator
+    RLE,          // after a separator, got the byte to duplicate
+    NORMAL        // normal, copy bytes till separator
   } state;
   int pos, cavepos, i, x, y;
-  guint8 byte, separator;
+  byte byte, separator;
 
-  gd_cave_set_engine_defaults(cave, GD_ENGINE_PLCK); /* essentially the plck engine */
+  gd_cave_set_engine_defaults(cave, GD_ENGINE_PLCK); // essentially the plck engine
 
   for (i = 0; i < 5; i++)
   {
-    /* does not really have levels, so just duplicate data five times */
+    // does not really have levels, so just duplicate data five times
     cave->level_time[i] = data[1];
     cave->level_diamonds[i] = data[2];
 
-    /* gate opening is checked AFTER adding to diamonds collected, so 0 here is 1000 needed */
+    // gate opening is checked AFTER adding to diamonds collected, so 0 here is 1000 needed
     if (cave->level_diamonds[i] == 0)
       cave->level_diamonds[i] = 1000;
 
     cave->level_ckdelay[i] = data[0];
     cave->level_amoeba_time[i] = data[6];
 
-    /* 0 immediately underflowed to 999, so we use 999. example: sendydash 3, cave 02. */
+    // 0 immediately underflowed to 999, so we use 999. example: sendydash 3, cave 02.
     if (cave->level_amoeba_time[i] == 0)
       cave->level_amoeba_time[i] = 999;
 
@@ -1309,22 +1321,22 @@ static int cave_copy_from_dlb(GdCave *cave, const guint8 *data, int remaining_by
   cave->diamond_value = data[3];
   cave->extra_diamond_value = data[4];
 
-  /* then 5 color bytes follow */
-  cave->colorb = gd_c64_color(data[8]  & 0xf);    /* border */
+  // then 5 color bytes follow
+  cave->colorb = gd_c64_color(data[8]  & 0xf);    // border
   cave->color0 = gd_c64_color(data[9]  & 0xf);
   cave->color1 = gd_c64_color(data[10] & 0xf);
   cave->color2 = gd_c64_color(data[11] & 0xf);
-  cave->color3 = gd_c64_color(data[12] & 0x7);     /* lower 3 bits only! */
-  cave->color4 = cave->color3;    /* in plck, amoeba was color3 */
-  cave->color5 = cave->color3;    /* same for slime */
+  cave->color3 = gd_c64_color(data[12] & 0x7);    // lower 3 bits only!
+  cave->color4 = cave->color3;                    // in plck, amoeba was color3
+  cave->color5 = cave->color3;                    // same for slime
 
-  /* cave map */
-  pos = 13;    /* those 13 bytes were the cave values above */
+  // cave map
+  pos = 13;                     // those 13 bytes were the cave values above
   cavepos = 0;
-  byte = 0;                    /* just to get rid of compiler warning */
-  separator = 0;               /* just to get rid of compiler warning */
+  byte = 0;                     // just to get rid of compiler warning
+  separator = 0;                // just to get rid of compiler warning
 
-  /* employ a state machine. */
+  // employ a state machine.
   state = START;
 
   while (cavepos < 400 && pos < remaining_bytes)
@@ -1332,25 +1344,25 @@ static int cave_copy_from_dlb(GdCave *cave, const guint8 *data, int remaining_by
     switch (state)
     {
       case START:
-       /* first byte is a separator. remember it */
+       // first byte is a separator. remember it
        separator = data[pos];
 
-       /* after the first separator, no rle data, just copy. */
+       // after the first separator, no rle data, just copy.
        state = NORMAL;
        break;
 
       case SEPARATOR:
-       /* we had a separator. remember this byte, as this will be duplicated (or more) */
+       // we had a separator. remember this byte, as this will be duplicated (or more)
        byte = data[pos];
        state = RLE;
        break;
 
       case RLE:
-       /* we had the first byte, duplicate this n times. */
+       // we had the first byte, duplicate this n times.
        if (data[pos] == 0xff)
        {
-         /* if it is a 0xff, we will have another byte, which is also a length specifier. */
-         /* and for this one, duplicate only 254 times */
+         // if it is a 0xff, we will have another byte, which is also a length specifier.
+         // and for this one, duplicate only 254 times
          if (cavepos + 254 > 400)
          {
            Error("DLB import error: RLE data overflows buffer");
@@ -1362,7 +1374,7 @@ static int cave_copy_from_dlb(GdCave *cave, const guint8 *data, int remaining_by
        }
        else
        {
-         /* if not 0xff, duplicate n times and back to copy mode */
+         // if not 0xff, duplicate n times and back to copy mode
          if (cavepos + data[pos] > 400)
          {
            Error("DLB import error: RLE data overflows buffer");
@@ -1377,11 +1389,11 @@ static int cave_copy_from_dlb(GdCave *cave, const guint8 *data, int remaining_by
        break;
 
       case NORMAL:
-       /* bytes duplicated; now only copy the remaining, till the next separator. */
+       // bytes duplicated; now only copy the remaining, till the next separator.
        if (data[pos] == separator)
          state = SEPARATOR;
        else
-         decomp[cavepos++] = data[pos];    /* copy this byte and state is still NORMAL */
+         decomp[cavepos++] = data[pos];    // copy this byte and state is still NORMAL
        break;
     }
 
@@ -1394,12 +1406,12 @@ static int cave_copy_from_dlb(GdCave *cave, const guint8 *data, int remaining_by
     return -1;
   }
 
-  /* process uncompressed map */
+  // process uncompressed map
   cave->map = gd_cave_map_new(cave, GdElement);
 
   for (x = 0; x < cave->w; x++)
   {
-    /* fill the first and the last row with steel wall. */
+    // fill the first and the last row with steel wall.
     cave->map[0][x] = O_STEEL;
     cave->map[cave->h - 1][x] = O_STEEL;
   }
@@ -1408,19 +1420,19 @@ static int cave_copy_from_dlb(GdCave *cave, const guint8 *data, int remaining_by
   {
     for (x = 0; x < cave->w; x += 2)
     {
-      /* msb 4 bits */
+      // msb 4 bits
       cave->map[y][x]     = plck_import_nybble[decomp[((y - 1) * cave->w + x) / 2] >> 4];
-      /* lsb 4 bits */
+      // lsb 4 bits
       cave->map[y][x + 1] = plck_import_nybble[decomp[((y - 1) * cave->w + x) / 2] % 16];
     }
   }
 
-  /* return number of bytes read from buffer */
+  // return number of bytes read from buffer
   return pos;
 }
 
-/* import plck cave data into our format. */
-static int cave_copy_from_1stb(GdCave *cave, const guint8 *data, int remaining_bytes)
+// import plck cave data into our format.
+static int cave_copy_from_1stb(GdCave *cave, const byte *data, int remaining_bytes)
 {
   int i;
   int x, y;
@@ -1434,14 +1446,14 @@ static int cave_copy_from_1stb(GdCave *cave, const guint8 *data, int remaining_b
 
   gd_cave_set_engine_defaults(cave, GD_ENGINE_1STB);
 
-  /* copy name */
+  // copy name
   gd_strcpy(cave->name, "              ");
 
   for (i = 0; i < 14; i++)
   {
     int c = data[0x3a0 + i];
 
-    /* import cave name; a conversion table is used for each character */
+    // import cave name; a conversion table is used for each character
     if (c < 0x40)
       c = gd_bd_internal_chars[c];
     else if (c == 0x74)
@@ -1449,19 +1461,19 @@ static int cave_copy_from_1stb(GdCave *cave, const guint8 *data, int remaining_b
     else if (c == 0x76)
       c = '?';
     else
-      c = ' ';    /* don't know this, so change to space */
+      c = ' ';    // don't know this, so change to space
 
     if (i > 0)
-      c = g_ascii_tolower(c);
+      c = tolower(c);
 
     cave->name[i] = c;
   }
 
-  g_strchomp(cave->name);
+  chompString(cave->name);
 
   cave->intermission = data[0x389] != 0;
 
-  /* if it is intermission but not scrollable */
+  // if it is intermission but not scrollable
   if (cave->intermission && !data[0x38c])
   {
     cave->x2 = 19;
@@ -1473,23 +1485,23 @@ static int cave_copy_from_1stb(GdCave *cave, const guint8 *data, int remaining_b
 
   for (i = 0; i < 5; i++)
   {
-    /* plck doesnot really have levels, so just duplicate data five times */
+    // plck doesnot really have levels, so just duplicate data five times
     cave->level_time[i] = 100 * data[0x370] + 10 * data[0x370+1] + data[0x370 + 2];
 
-    /* same as gate opening after 0 diamonds */
+    // same as gate opening after 0 diamonds
     if (cave->level_time[i] == 0)
       cave->level_time[i] = 1000;
 
     cave->level_diamonds[i] = 100 * data[0x373] + 10 * data[0x373 + 1] + data[0x373 + 2];
 
-    /* gate opening is checked AFTER adding to diamonds collected, so 0 here is 1000 (!) needed */
+    // gate opening is checked AFTER adding to diamonds collected, so 0 here is 1000 (!) needed
     if (cave->level_diamonds[i] == 0)
       cave->level_diamonds[i] = 1000;
 
     cave->level_ckdelay[i] = data[0x38a];
     cave->level_amoeba_time[i] = 256 * (int)data[0x37c] + data[0x37d];
 
-    /* 0 immediately underflowed to 999, so we use 999. example: sendydash 3, cave 02. */
+    // 0 immediately underflowed to 999, so we use 999. example: sendydash 3, cave 02.
     if (cave->level_amoeba_time[i] == 0)
       cave->level_amoeba_time[i] = 999;
 
@@ -1500,16 +1512,17 @@ static int cave_copy_from_1stb(GdCave *cave, const guint8 *data, int remaining_b
     cave->level_amoeba_threshold[i] = 256 * (int)data[0x390] + data[0x390 + 1];
   }
 
-  /* also has no random data... */
-  cave->colorb = gd_c64_color(data[0x384] & 0xf);    /* border */
+  // also has no random data...
+
+  cave->colorb = gd_c64_color(data[0x384] & 0xf);    // border
   cave->color0 = gd_c64_color(data[0x385] & 0xf);
   cave->color1 = gd_c64_color(data[0x386] & 0xf);
   cave->color2 = gd_c64_color(data[0x387] & 0xf);
-  cave->color3 = gd_c64_color(data[0x388] & 0x7);     /* lower 3 bits only! */
+  cave->color3 = gd_c64_color(data[0x388] & 0x7);     // lower 3 bits only!
   cave->color4 = cave->color1;
   cave->color5 = cave->color1;
 
-  cave->amoeba_growth_prob = (4.0 * 1E6 / (data[0x382] + 1)) + 0.5;   /* probabilities store *1M */
+  cave->amoeba_growth_prob = (4.0 * 1E6 / (data[0x382] + 1)) + 0.5;   // probabilities store *1M
   if (cave->amoeba_growth_prob > 1000000)
     cave->amoeba_growth_prob = 1000000;
 
@@ -1522,7 +1535,7 @@ static int cave_copy_from_1stb(GdCave *cave, const guint8 *data, int remaining_b
   else
     cave->diagonal_movements = data[0x381] != 0;
 
-  /* ... the cave is stored like a map. */
+  // ... the cave is stored like a map.
   cave->map = gd_cave_map_new(cave, GdElement);
   for (y = 0; y < cave->h; y++)
     for (x = 0; x < cave->w; x++)
@@ -1530,14 +1543,14 @@ static int cave_copy_from_1stb(GdCave *cave, const guint8 *data, int remaining_b
 
   cave->magic_wall_sound = data[0x38d] == 0xf1;
 
-  /* 2d was a normal switch, 2e a changed one. */
+  // 2d was a normal switch, 2e a changed one.
   cave->creatures_backwards = data[0x38f] == 0x2d;
 
-  /* 2e horizontal, 2f vertical. */
+  // 2e horizontal, 2f vertical.
   cave->expanding_wall_changed = data[0x38e] == 0x2f;
 
   cave->biter_delay_frame      = data[0x394];
-  cave->magic_wall_stops_amoeba        = data[0x395] == 0;    /* negated!! */
+  cave->magic_wall_stops_amoeba        = data[0x395] == 0;    // negated!!
 
   cave->bomb_explosion_effect  = firstboulder_import(data[0x396], 0x396);
   cave->explosion_effect       = firstboulder_import(data[0x397], 0x397);
@@ -1554,24 +1567,24 @@ static int cave_copy_from_1stb(GdCave *cave, const guint8 *data, int remaining_b
   cave->slime_converts_2       = firstboulder_import(data[0x39f] + 3, 0x39f);
   cave->magic_diamond_to       = firstboulder_import(data[0x39a], 0x39a);
 
-  /* length is always 1024 bytes */
+  // length is always 1024 bytes
   return 1024;
 }
 
-/* crazy dream 7 */
-static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining_bytes)
+// crazy dream 7
+static int cave_copy_from_crdr_7(GdCave *cave, const byte *data, int remaining_bytes)
 {
   int i, index;
-  guint8 checksum;
+  byte checksum;
 
-  /* if we have name, convert */
+  // if we have name, convert
   gd_strcpy(cave->name, "              ");
 
   for (i = 0; i < 14; i++)
   {
     int c = data[i];
 
-    /* import cave name; a conversion table is used for each character */
+    // import cave name; a conversion table is used for each character
     if (c < 0x40)
       c = gd_bd_internal_chars[c];
     else if (c == 0x74)
@@ -1581,16 +1594,16 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining
     else
       c = ' ';
     if (i > 0)
-      c = g_ascii_tolower(c);
+      c = tolower(c);
 
     cave->name[i] = c;
   }
 
-  g_strchomp(cave->name);    /* remove trailing and leading spaces */
+  chompString(cave->name);    // remove trailing and leading spaces
 
   cave->selectable = data[14] != 0;
 
-  /* jump 15 bytes, 14 was the name and 15 selectability */
+  // jump 15 bytes, 14 was the name and 15 selectability
   data += 15;
 
   if (memcmp((char *)data + 0x30, "V4\0020", 4) != 0)
@@ -1602,13 +1615,13 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining
   {
     cave->level_time[i] = (int)data[0x0] * 100 + data[0x1] * 10 + data[0x2];
 
-    /* same as gate opening after 0 diamonds */
+    // same as gate opening after 0 diamonds
     if (cave->level_time[i] == 0)
       cave->level_time[i] = 1000;
 
     cave->level_diamonds[i] = (int)data[0x3] * 100 + data[0x4] * 10 + data[0x5];
 
-    /* gate opening is checked AFTER adding to diamonds collected, so 0 here is 1000 (!) needed */
+    // gate opening is checked AFTER adding to diamonds collected, so 0 here is 1000 (!) needed
     if (cave->level_diamonds[i] == 0)
       cave->level_diamonds[i] = 1000;
 
@@ -1616,7 +1629,7 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining
     cave->level_rand[i] = data[0x40];
     cave->level_amoeba_time[i] = (int)data[0xC] * 256 + data[0xD];
 
-    /* 0 immediately underflowed to 999, so we use 999. example: sendydash 3, cave 02. */
+    // 0 immediately underflowed to 999, so we use 999. example: sendydash 3, cave 02.
     if (cave->level_amoeba_time[i] == 0)
       cave->level_amoeba_time[i] = 999;
 
@@ -1635,34 +1648,36 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining
   if (data[0x10])
     cave->creatures_direction_auto_change_time = data[0x11];
 
-  cave->colorb = gd_c64_color(data[0x14] & 0xf);    /* border */
+  cave->colorb = gd_c64_color(data[0x14] & 0xf);    // border
   cave->color0 = gd_c64_color(data[0x15] & 0xf);
   cave->color1 = gd_c64_color(data[0x16] & 0xf);
   cave->color2 = gd_c64_color(data[0x17] & 0xf);
-  cave->color3 = gd_c64_color(data[0x18] & 0x7);     /* lower 3 bits only! */
+  cave->color3 = gd_c64_color(data[0x18] & 0x7);    // lower 3 bits only!
   cave->color4 = cave->color3;
   cave->color5 = cave->color1;
+
   cave->intermission = data[0x19] != 0;
 
-  /* if it is intermission but not scrollable */
+  // if it is intermission but not scrollable
   if (cave->intermission && !data[0x1c])
   {
     cave->x2 = 19;
     cave->y2 = 11;
   }
 
-  /* AMOEBA in crazy dash 8:
-     jsr $2500      ; generate true random
-     and $94        ; binary and the current "probability"
-     cmp #$04       ; compare to 4
-     bcs out        ; jump out (do not expand) if carry set, ie. result was less than 4.
-
-     prob values can be like num = 3, 7, 15, 31, 63, ... n lsb bits count.
-     0..3>=4?  0..7>=4?  0..15>=4? and similar.
-     this way, probability of growing is 4/(num+1)
+  /*
+    AMOEBA in crazy dash 8:
+    jsr $2500      ; generate true random
+    and $94        ; binary and the current "probability"
+    cmp #$04       ; compare to 4
+    bcs out        ; jump out (do not expand) if carry set, ie. result was less than 4.
+
+    prob values can be like num = 3, 7, 15, 31, 63, ... n lsb bits count.
+    0..3>=4?  0..7>=4?  0..15>=4? and similar.
+    this way, probability of growing is 4/(num+1)
   */
 
-  cave->amoeba_growth_prob = (4.0 * 1E6 / (data[0x12] + 1)) + 0.5;   /* probabilities store * 1M */
+  cave->amoeba_growth_prob = (4.0 * 1E6 / (data[0x12] + 1)) + 0.5;   // probabilities store * 1M
   if (cave->amoeba_growth_prob > 1000000)
     cave->amoeba_growth_prob = 1000000;
 
@@ -1670,13 +1685,13 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining
   if (cave->amoeba_fast_growth_prob > 1000000)
     cave->amoeba_fast_growth_prob = 1000000;
 
-  /* expanding wall direction change - 2e horizontal, 2f vertical */
+  // expanding wall direction change - 2e horizontal, 2f vertical
   cave->expanding_wall_changed = data[0x1e] == 0x2f;
 
-  /* 2c was a normal switch, 2d a changed one. */
+  // 2c was a normal switch, 2d a changed one.
   cave->creatures_backwards    = data[0x1f] == 0x2d;
   cave->biter_delay_frame      = data[0x24];
-  cave->magic_wall_stops_amoeba        = data[0x25] == 0;    /* negated!! */
+  cave->magic_wall_stops_amoeba        = data[0x25] == 0;    // negated!!
 
   cave->bomb_explosion_effect  = crazydream_import_table[data[0x26]];
   cave->explosion_effect       = crazydream_import_table[data[0x27]];
@@ -1707,7 +1722,7 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining
     ie. random<=ratio, then acid grows.
   */
 
-  /* 1e6, probabilities are stored as int */
+  // 1e6, probabilities are stored as int
   cave->acid_spread_ratio = data[0x38] / 255.0 * 1E6 + 0.5;
 
   cave->acid_eats_this = crazydream_import_table[data[0x39]];
@@ -1721,7 +1736,7 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining
 
   cave->snap_element = ((data[0x3a] & 4) != 0) ? O_EXPLODE_1 : O_SPACE;
 
-  /* we do not know the values for these, so do not import */
+  // we do not know the values for these, so do not import
   //    cave->dirt_looks_like... data[0x3c]
   //    cave->expanding_wall_looks_like... data[0x3b]
   for (i = 0; i < 4; i++)
@@ -1740,29 +1755,29 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining
     int nx, ny;
     int length, direction;
 
-    /* for copy&paste; copy&paste are different objects, static = ugly solution :) */
+    // for copy&paste; copy&paste are different objects, static = ugly solution :)
     static int cx1, cy1, cw, ch;
 
     switch (data[index])
     {
-      case 1:    /* point */
+      case 1:    // point
        elem = crazydream_import_table[data[index + 1]];
        x1 = data[index + 2];
        y1 = data[index + 3];
        if (x1 >= cave->w || y1 >= cave->h)
          Warn("invalid point coordinates %d,%d at byte %d", x1, y1, index);
 
-       cave->objects = g_list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem));
+       cave->objects = list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem));
 
        index += 4;
        break;
 
-      case 2: /* rectangle */
+      case 2: // rectangle
        elem = crazydream_import_table[data[index + 1]];
        x1 = data[index + 2];
        y1 = data[index + 3];
        x2 = x1 + data[index + 4] - 1;
-       y2 = y1 + data[index + 5] - 1;    /* height */
+       y2 = y1 + data[index + 5] - 1;    // height
 
        if (x1 >= cave->w ||
            y1 >= cave->h ||
@@ -1770,12 +1785,12 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining
            y2 >= cave->h)
          Warn("invalid rectangle coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index);
 
-       cave->objects = g_list_append(cave->objects, gd_object_new_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem));
+       cave->objects = list_append(cave->objects, gd_object_new_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem));
 
        index += 6;
        break;
 
-      case 3: /* fillrect */
+      case 3: // fillrect
        x1 = data[index + 2];
        y1 = data[index + 3];
        x2 = x1 + data[index + 4] - 1;
@@ -1787,13 +1802,13 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining
            y2 >= cave->h)
          Warn("invalid filled rectangle coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index);
 
-       /* border and inside of fill is the same element. */
-       cave->objects = g_list_append(cave->objects, gd_object_new_filled_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, crazydream_import_table[data[index + 1]], crazydream_import_table[data[index + 1]]));
+       // border and inside of fill is the same element.
+       cave->objects = list_append(cave->objects, gd_object_new_filled_rectangle(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, crazydream_import_table[data[index + 1]], crazydream_import_table[data[index + 1]]));
 
        index += 6;
        break;
 
-      case 4: /* line */
+      case 4: // line
        elem = crazydream_import_table[data[index + 1]];
        if (elem == O_UNKNOWN)
          Warn("unknown element at %d: %x", index + 1, data[index + 1]);
@@ -1807,32 +1822,32 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining
        x2 = x1 + (length - 1) * nx;
        y2 = y1 + (length - 1) * ny;
 
-       /* if either is bigger than one, we cannot treat this as a line. create points instead */
+       // if either is bigger than one, we cannot treat this as a line. create points instead
        if (ABS(nx) >= 2 || ABS(ny) >= 2)
        {
          for (i = 0; i < length; i++)
          {
-           cave->objects = g_list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem));
+           cave->objects = list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, x1, y1, elem));
            x1 += nx;
            y1 += ny;
          }
        }
        else
        {
-         /* this is a normal line, and will be appended. only do the checking here */
+         // this is a normal line, and will be appended. only do the checking here
          if (x1 >= cave->w ||
              y1 >= cave->h ||
              x2 >= cave->w ||
              y2 >= cave->h)
            Warn("invalid line coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index - 5);
 
-         cave->objects = g_list_append(cave->objects, gd_object_new_line(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem));
+         cave->objects = list_append(cave->objects, gd_object_new_line(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, elem));
        }
 
        index += 6;
        break;
 
-      case 6: /* copy */
+      case 6: // copy
        cx1 = data[index + 1];
        cy1 = data[index + 2];
        cw = data[index + 3];
@@ -1847,14 +1862,14 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining
        index += 5;
        break;
 
-      case 7: /* paste */
+      case 7: // paste
        x1 = cx1;
        y1 = cy1;
 
-       /* original stored width and height, we store the coordinates of the source area */
+       // original stored width and height, we store the coordinates of the source area
        x2 = cx1 + cw - 1;
        y2 = cy1 + ch - 1;
-       dx = data[index + 1];    /* new pos */
+       dx = data[index + 1];    // new pos
        dy = data[index + 2];
 
        if (dx >= cave->w ||
@@ -1863,12 +1878,12 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining
            dy + ch > cave->h)
          Warn("invalid paste coordinates %d,%d at byte %d", dx, dy, index);
 
-       cave->objects = g_list_append(cave->objects, gd_object_new_copy_paste(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, dx, dy, FALSE, FALSE));
+       cave->objects = list_append(cave->objects, gd_object_new_copy_paste(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, dx, dy, FALSE, FALSE));
 
        index += 3;
        break;
 
-      case 11: /* raster */
+      case 11: // raster
        elem = crazydream_import_table[data[index + 1]];
        x1 = data[index + 2];
        y1 = data[index + 3];
@@ -1876,7 +1891,7 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining
        dy = data[index + 5];
        nx = data[index + 6] - 1;
        ny = data[index + 7] - 1;
-       x2 = x1 + dx * nx;    /* calculate rectangle we use */
+       x2 = x1 + dx * nx;    // calculate rectangle we use
        y2 = y1 + dy * ny;
 
        if (dx < 1)
@@ -1890,21 +1905,21 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining
            y2 >= cave->h)
          Warn("invalid raster coordinates %d,%d %d,%d at byte %d", x1, y1, x2, y2, index);
 
-       cave->objects = g_list_append(cave->objects, gd_object_new_raster(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, dx, dy, elem));
+       cave->objects = list_append(cave->objects, gd_object_new_raster(GD_OBJECT_LEVEL_ALL, x1, y1, x2, y2, dx, dy, elem));
 
        index += 8;
        break;
 
       default:
        Warn ("unknown crdr extension no. %02x at byte %d", data[index], index);
-       index += 1;    /* skip that byte */
+       index += 1;    // skip that byte
        break;
     }
   }
 
-  index++;    /* skip $ff */
+  index++;    // skip $ff
 
-  /* crazy dream 7 hack */
+  // crazy dream 7 hack
   checksum = 0;
 
   for (i = 0; i < 0x3b0; i++)
@@ -1916,99 +1931,120 @@ static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining
   return 15 + 0x49 + index;
 }
 
-static void crazy_dream_9_add_specials(GdCave *cave, const guint8 *buf, const int length)
+static void crazy_dream_9_add_specials(GdCave *cave, const byte *buf, const int length)
 {
-  guint8 checksum;
+  byte checksum;
   int i;
 
-  /* crazy dream 9 hack */
+  // crazy dream 9 hack
   checksum = 0;
   for (i = 0; i < length; i++)
     checksum = checksum^buf[i];
 
-  /* check cave name and the checksum. both are hardcoded here */
+  // check cave name and the checksum. both are hardcoded here
   if (strEqual(cave->name, "Rockfall") && checksum == 134)
   {
     GdElement rand[4] = { O_DIAMOND, O_STONE, O_ACID, O_DIRT };
-    gint32 prob[4] = { 37, 32, 2, 0 };
-    gint32 seeds[5] = { -1, -1, -1, -1, -1 };
+    int prob[4] = { 37, 32, 2, 0 };
+    int seeds[5] = { -1, -1, -1, -1, -1 };
 
-    cave->objects = g_list_append(cave->objects, gd_object_new_random_fill(GD_OBJECT_LEVEL_ALL, 0, 0, 39, 21, seeds, O_DIRT, rand, prob, O_BLADDER_SPENDER, FALSE));
+    cave->objects =
+      list_append(cave->objects,
+                 gd_object_new_random_fill(GD_OBJECT_LEVEL_ALL, 0, 0, 39, 21, seeds,
+                                           O_DIRT, rand, prob, O_BLADDER_SPENDER, FALSE));
   }
 
   if (strEqual(cave->name, "Roll dice now!") && checksum == 235)
   {
     GdElement rand[4] = { O_STONE, O_BUTTER_3, O_DIRT, O_DIRT };
-    gint32 prob[4] = { 0x18, 0x08, 0, 0 };
-    gint32 seeds[5] = { -1, -1, -1, -1, -1 };
+    int prob[4] = { 0x18, 0x08, 0, 0 };
+    int seeds[5] = { -1, -1, -1, -1, -1 };
 
-    cave->objects = g_list_append(cave->objects, gd_object_new_random_fill(GD_OBJECT_LEVEL_ALL, 0, 0, 39, 21, seeds, O_DIRT, rand, prob, O_BLADDER_SPENDER, FALSE));
+    cave->objects =
+      list_append(cave->objects,
+                 gd_object_new_random_fill(GD_OBJECT_LEVEL_ALL, 0, 0, 39, 21, seeds,
+                                           O_DIRT, rand, prob, O_BLADDER_SPENDER, FALSE));
   }
 
   if (strEqual(cave->name, "Random maze") && checksum == 24)
   {
-    gint32 seeds[5] = { -1, -1, -1, -1, -1 };
-    cave->objects = g_list_append(cave->objects, gd_object_new_maze(GD_OBJECT_LEVEL_ALL, 1, 4, 35, 20, 1, 1, O_NONE, O_DIRT, 50, seeds));
+    int seeds[5] = { -1, -1, -1, -1, -1 };
+    cave->objects =
+      list_append(cave->objects,
+                 gd_object_new_maze(GD_OBJECT_LEVEL_ALL, 1, 4, 35, 20, 1, 1,
+                                    O_NONE, O_DIRT, 50, seeds));
   }
 
   if (strEqual(cave->name, "Metamorphosis") && checksum == 53)
   {
-    gint32 seeds[5] = { -1, -1, -1, -1, -1 };
+    int seeds[5] = { -1, -1, -1, -1, -1 };
     GdElement rand[4] = { O_STONE, O_DIRT, O_DIRT, O_DIRT };
-    gint32 prob[4] = { 0x18, 0, 0, 0 };
+    int prob[4] = { 0x18, 0, 0, 0 };
+
+    cave->objects =
+      list_append(cave->objects,
+                 gd_object_new_maze(GD_OBJECT_LEVEL_ALL, 4, 1, 38, 19, 1, 3,
+                                    O_NONE, O_BLADDER_SPENDER, 50, seeds));
 
-    cave->objects = g_list_append(cave->objects, gd_object_new_maze(GD_OBJECT_LEVEL_ALL, 4, 1, 38, 19, 1, 3, O_NONE, O_BLADDER_SPENDER, 50, seeds));
-    cave->objects = g_list_append(cave->objects, gd_object_new_random_fill(GD_OBJECT_LEVEL_ALL, 4, 1, 38, 19, seeds, O_DIRT, rand, prob, O_BLADDER_SPENDER, FALSE));
-    cave->creatures_backwards = TRUE;    /* for some reason, this level worked like that */
+    cave->objects =
+      list_append(cave->objects,
+                 gd_object_new_random_fill(GD_OBJECT_LEVEL_ALL, 4, 1, 38, 19, seeds,
+                                           O_DIRT, rand, prob, O_BLADDER_SPENDER, FALSE));
+
+    cave->creatures_backwards = TRUE;    // for some reason, this level worked like that
   }
 
   if (strEqual(cave->name, "All the way") && checksum == 33)
   {
-    gint32 seeds[5] = { -1, -1, -1, -1, -1 };
+    int seeds[5] = { -1, -1, -1, -1, -1 };
 
-    cave->objects = g_list_append(cave->objects, gd_object_new_maze_unicursal(GD_OBJECT_LEVEL_ALL, 1, 1, 35, 19, 1, 1, O_BRICK, O_PRE_DIA_1, 50, seeds));
+    cave->objects =
+      list_append(cave->objects,
+                 gd_object_new_maze_unicursal(GD_OBJECT_LEVEL_ALL, 1, 1, 35, 19, 1, 1,
+                                              O_BRICK, O_PRE_DIA_1, 50, seeds));
 
-    /* a point which "breaks" the unicursal maze, making it one very long path */
-    cave->objects = g_list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, 35, 18, O_BRICK));
+    // a point which "breaks" the unicursal maze, making it one very long path
+    cave->objects =
+      list_append(cave->objects, gd_object_new_point(GD_OBJECT_LEVEL_ALL, 35, 18, O_BRICK));
   }
 }
 
-/* crazy light contruction kit */
-static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_bytes)
+// crazy light contruction kit
+static int cave_copy_from_crli(GdCave *cave, const byte *data, int remaining_bytes)
 {
-  guint8 uncompressed[1024];
+  byte uncompressed[1024];
   int datapos, cavepos, i, x, y;
   boolean cavefile;
   const char *versions[] = { "V2.2", "V2.6", "V3.0" };
   enum
   {
     none,
-    V2_2,    /* XXX whats the difference between 2.2 and 2.6?*/
+    V2_2,    // XXX whats the difference between 2.2 and 2.6?
     V2_6,
     V3_0
   } version = none;
-  GdElement (*import) (guint8 c, int i) = NULL;    /* import function */
+  GdElement (*import) (byte c, int i) = NULL;    // import function
 
   gd_cave_set_engine_defaults(cave, GD_ENGINE_CRLI);
 
-  /* detect if this is a cavefile */
+  // detect if this is a cavefile
   if (data[0] == 0 &&
       data[1] == 0xc4 &&
       data[2] == 'D' &&
       data[3] == 'L' &&
       data[4] == 'P')
   {
-    datapos = 5;    /* cavefile, skipping 0x00 0xc4 D L P */
+    datapos = 5;    // cavefile, skipping 0x00 0xc4 D L P
     cavefile = TRUE;
   }
   else
   {
-    /* converted from snapshot, skip "selectable" and 14byte name */
+    // converted from snapshot, skip "selectable" and 14byte name
     datapos = 15;
     cavefile = FALSE;
   }
 
-  /* if we have name, convert */
+  // if we have name, convert
   if (!cavefile)
   {
     gd_strcpy(cave->name, "              ");
@@ -2017,7 +2053,7 @@ static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_b
     {
       int c = data[i + 1];
 
-      /* import cave name; a conversion table is used for each character */
+      // import cave name; a conversion table is used for each character
       if (c < 0x40)
        c = gd_bd_internal_chars[c];
       else if (c == 0x74)
@@ -2028,20 +2064,20 @@ static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_b
        c = ' ';
 
       if (i > 0)
-       c = g_ascii_tolower(c);
+       c = tolower(c);
 
       cave->name[i] = c;
     }
 
-    g_strchomp(cave->name);    /* remove trailing and leading spaces */
+    chompString(cave->name);    // remove trailing and leading spaces
   }
 
-  /* uncompress rle data */
+  // uncompress rle data
   cavepos = 0;
 
   while (cavepos < 0x3b0)
   {
-    /* <- loop until the uncompressed reaches its size */
+    // <- loop until the uncompressed reaches its size
     if (datapos >= remaining_bytes)
     {
       Error("truncated crli cave data");
@@ -2050,7 +2086,7 @@ static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_b
 
     if (data[datapos] == 0xbf)
     {
-      /* magic value 0xbf is the escape byte */
+      // magic value 0xbf is the escape byte
       if (datapos + 2 >= remaining_bytes)
       {
        Error("truncated crli cave data");
@@ -2059,12 +2095,12 @@ static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_b
 
       if (data[datapos + 2] + datapos >= sizeof(uncompressed))
       {
-       /* we would run out of buffer, this must be some error */
+       // we would run out of buffer, this must be some error
        Error("invalid crli cave data - RLE length value is too big");
        return -1;
       }
 
-      /* 0xbf, number, byte to dup */
+      // 0xbf, number, byte to dup
       for (i = 0; i < data[datapos + 2]; i++)
        uncompressed[cavepos++] = data[datapos + 1];
 
@@ -2076,12 +2112,12 @@ static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_b
     }
   }
 
-  /* check crli version */
-  for (i = 0; i < G_N_ELEMENTS(versions); i++)
+  // check crli version
+  for (i = 0; i < ARRAY_SIZE(versions); i++)
     if (memcmp((char *)uncompressed + 0x3a0, versions[i], 4) == 0)
       version = i + 1;
 
-  /* v3.0 has falling wall and box, and no ghost. */
+  // v3.0 has falling wall and box, and no ghost.
   import = version >= V3_0 ? crazylight_import : firstboulder_import;
 
   if (version == none)
@@ -2090,7 +2126,7 @@ static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_b
     import = crazylight_import;
   }
 
-  /* process map */
+  // process map
   cave->map = gd_cave_map_new(cave, GdElement);
 
   for (y = 0; y < cave->h; y++)
@@ -2103,25 +2139,25 @@ static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_b
     }
   }
 
-  /* crli has no levels */
+  // crli has no levels
   for (i = 0; i < 5; i++)
   {
     cave->level_time[i] = (int)uncompressed[0x370] * 100 + uncompressed[0x371] * 10 + uncompressed[0x372];
 
-    /* same as gate opening after 0 diamonds */
+    // same as gate opening after 0 diamonds
     if (cave->level_time[i] == 0)
       cave->level_time[i] = 1000;
 
     cave->level_diamonds[i] = (int)uncompressed[0x373] * 100 + uncompressed[0x374] * 10 + uncompressed[0x375];
 
-    /* gate opening is checked AFTER adding to diamonds collected, so 0 here is 1000 (!) needed */
+    // gate opening is checked AFTER adding to diamonds collected, so 0 here is 1000 (!) needed
     if (cave->level_diamonds[i] == 0)
       cave->level_diamonds[i] = 1000;
 
     cave->level_ckdelay[i] = uncompressed[0x38A];
     cave->level_amoeba_time[i] = (int)uncompressed[0x37C] * 256 + uncompressed[0x37D];
 
-    /* 0 immediately underflowed to 999, so we use 999. example: sendydash 3, cave 02. */
+    // 0 immediately underflowed to 999, so we use 999. example: sendydash 3, cave 02.
     if (cave->level_amoeba_time[i] == 0)
       cave->level_amoeba_time[i] = 999;
 
@@ -2138,34 +2174,36 @@ static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_b
   if (uncompressed[0x380])
     cave->creatures_direction_auto_change_time = uncompressed[0x381];
 
-  cave->colorb = gd_c64_color(uncompressed[0x384]&0xf);    /* border */
-  cave->color0 = gd_c64_color(uncompressed[0x385]&0xf);
-  cave->color1 = gd_c64_color(uncompressed[0x386]&0xf);
-  cave->color2 = gd_c64_color(uncompressed[0x387]&0xf);
-  cave->color3 = gd_c64_color(uncompressed[0x388]&0x7);     /* lower 3 bits only! */
+  cave->colorb = gd_c64_color(uncompressed[0x384] & 0xf);    // border
+  cave->color0 = gd_c64_color(uncompressed[0x385] & 0xf);
+  cave->color1 = gd_c64_color(uncompressed[0x386] & 0xf);
+  cave->color2 = gd_c64_color(uncompressed[0x387] & 0xf);
+  cave->color3 = gd_c64_color(uncompressed[0x388] & 0x7);    // lower 3 bits only!
   cave->color4 = cave->color3;
   cave->color5 = cave->color1;
-  cave->intermission = uncompressed[0x389]!=0;
 
-  /* if it is intermission but not scrollable */
+  cave->intermission = uncompressed[0x389] != 0;
+
+  // if it is intermission but not scrollable
   if (cave->intermission && !uncompressed[0x38c])
   {
     cave->x2 = 19;
     cave->y2 = 11;
   }
 
-  /* AMOEBA in crazy dash 8:
-     jsr $2500        ; generate true random
-     and $94            ; binary and the current "probability"
-     cmp #$04        ; compare to 4
-     bcs out            ; jump out (do not expand) if carry set, ie. result was less than 4.
-
-     prob values can be like num = 3, 7, 15, 31, 63, ... n lsb bits count.
-     0..3>=4?  0..7>=4?  0..15>=4? and similar.
-     this way, probability of growing is 4/(num+1)
+  /*
+    AMOEBA in crazy dash 8:
+    jsr $2500        ; generate true random
+    and $94            ; binary and the current "probability"
+    cmp #$04        ; compare to 4
+    bcs out            ; jump out (do not expand) if carry set, ie. result was less than 4.
+
+    prob values can be like num = 3, 7, 15, 31, 63, ... n lsb bits count.
+    0..3>=4?  0..7>=4?  0..15>=4? and similar.
+    this way, probability of growing is 4/(num+1)
   */
 
-  /* probabilities store * 1M */
+  // probabilities store * 1M
   cave->amoeba_growth_prob = (1E6 * 4.0 / (uncompressed[0x382] + 1)) + 0.5;
 
   if (cave->amoeba_growth_prob > 1000000)
@@ -2176,11 +2214,11 @@ static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_b
   if (cave->amoeba_fast_growth_prob > 1000000)
     cave->amoeba_fast_growth_prob = 1000000;
 
-  /* 2c was a normal switch, 2d a changed one. */
+  // 2c was a normal switch, 2d a changed one.
   cave->creatures_backwards = uncompressed[0x38f] == 0x2d;
   cave->magic_wall_sound = uncompressed[0x38d] == 0xf1;
 
-  /* 2e horizontal, 2f vertical. we implement this by changing them */
+  // 2e horizontal, 2f vertical. we implement this by changing them
   if (uncompressed[0x38e] == 0x2f)
   {
     for (y = 0; y < cave->h; y++)
@@ -2193,27 +2231,27 @@ static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_b
     }
   }
 
-  cave->biter_delay_frame = uncompressed[0x394];
-  cave->magic_wall_stops_amoeba = uncompressed[0x395]==0;    /* negated!! */
-  cave->bomb_explosion_effect = import(uncompressed[0x396], 0x396);
-  cave->explosion_effect = import(uncompressed[0x397], 0x397);
-  cave->stone_bouncing_effect = import(uncompressed[0x398], 0x398);
-  cave->diamond_birth_effect = import(uncompressed[0x399], 0x399);
-  cave->magic_diamond_to = import(uncompressed[0x39a], 0x39a);
-
-  cave->bladder_converts_by = import(uncompressed[0x39b], 0x39b);
-  cave->diamond_falling_effect = import(uncompressed[0x39c], 0x39c);
-  cave->biter_eat = import(uncompressed[0x39d], 0x39d);
-  cave->slime_eats_1 = import(uncompressed[0x39e], 0x39e);
-  cave->slime_converts_1 = import(uncompressed[0x39e] + 3, 0x39e);
-  cave->slime_eats_2 = import(uncompressed[0x39f], 0x39f);
-  cave->slime_converts_2 = import(uncompressed[0x39f] + 3, 0x39f);
-
-  /* v3.0 has some new properties. */
+  cave->biter_delay_frame      = uncompressed[0x394];
+  cave->magic_wall_stops_amoeba        = uncompressed[0x395] == 0;    // negated!!
+  cave->bomb_explosion_effect  = import(uncompressed[0x396], 0x396);
+  cave->explosion_effect       = import(uncompressed[0x397], 0x397);
+  cave->stone_bouncing_effect  = import(uncompressed[0x398], 0x398);
+  cave->diamond_birth_effect   = import(uncompressed[0x399], 0x399);
+  cave->magic_diamond_to       = import(uncompressed[0x39a], 0x39a);
+
+  cave->bladder_converts_by    = import(uncompressed[0x39b], 0x39b);
+  cave->diamond_falling_effect = import(uncompressed[0x39c], 0x39c);
+  cave->biter_eat              = import(uncompressed[0x39d], 0x39d);
+  cave->slime_eats_1           = import(uncompressed[0x39e], 0x39e);
+  cave->slime_converts_1       = import(uncompressed[0x39e] + 3, 0x39e);
+  cave->slime_eats_2           = import(uncompressed[0x39f], 0x39f);
+  cave->slime_converts_2       = import(uncompressed[0x39f] + 3, 0x39f);
+
+  // v3.0 has some new properties.
   if (version >= V3_0)
   {
-    cave->diagonal_movements = uncompressed[0x3a4] != 0;
-    cave->amoeba_too_big_effect = import(uncompressed[0x3a6], 0x3a6);
+    cave->diagonal_movements    = uncompressed[0x3a4] != 0;
+    cave->amoeba_too_big_effect         = import(uncompressed[0x3a6], 0x3a6);
     cave->amoeba_enclosed_effect = import(uncompressed[0x3a7], 0x3a7);
 
     /*
@@ -2225,16 +2263,16 @@ static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_b
       ie. random<=ratio, then acid grows.
     */
 
-    /* * 1e6, probabilities are stored as int */
-    cave->acid_spread_ratio = uncompressed[0x3a8] / 255.0 * 1E6;
-    cave->acid_eats_this = import(uncompressed[0x3a9], 0x3a9);
-    cave->expanding_wall_looks_like = import(uncompressed[0x3ab], 0x3ab);
-    cave->dirt_looks_like = import(uncompressed[0x3ac], 0x3ac);
+    // * 1e6, probabilities are stored as int
+    cave->acid_spread_ratio            = uncompressed[0x3a8] / 255.0 * 1E6;
+    cave->acid_eats_this               = import(uncompressed[0x3a9], 0x3a9);
+    cave->expanding_wall_looks_like    = import(uncompressed[0x3ab], 0x3ab);
+    cave->dirt_looks_like              = import(uncompressed[0x3ac], 0x3ac);
   }
   else
   {
-    /* version is <= 3.0, so this is a 1stb cave. */
-    /* the only parameters, for which this matters, are these: */
+    // version is <= 3.0, so this is a 1stb cave.
+    // the only parameters, for which this matters, are these:
     if (uncompressed[0x380] != 0)
       cave->creatures_direction_auto_change_time = uncompressed[0x381];
     else
@@ -2242,14 +2280,14 @@ static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_b
   }
 
   if (cavefile)
-    cave->selectable = !cave->intermission;    /* best we can do */
+    cave->selectable = !cave->intermission;     // best we can do
   else
-    cave->selectable = !data[0];    /* given by converter */
+    cave->selectable = !data[0];                // given by converter
 
   return datapos;
 }
 
-GdCavefileFormat gd_caveset_imported_get_format(const guint8 *buf)
+GdCavefileFormat gd_caveset_imported_get_format(const byte *buf)
 {
   const char *s_bd1       = "GDashBD1";
   const char *s_bd1_atari = "GDashB1A";
@@ -2292,18 +2330,20 @@ GdCavefileFormat gd_caveset_imported_get_format(const guint8 *buf)
   return GD_FORMAT_UNKNOWN;
 }
 
-/*
-  Load caveset from memory buffer.
-  Loads the caveset from a memory buffer.
-  returns: GList * of caves.
-*/
-GList *gd_caveset_import_from_buffer (const guint8 *buf, gsize length)
+
+// ----------------------------------------------------------------------------
+//  Load caveset from memory buffer.
+//  Loads the caveset from a memory buffer.
+//  returns: List * of caves.
+// ----------------------------------------------------------------------------
+
+List *gd_caveset_import_from_buffer (const byte *buf, size_t length)
 {
   boolean numbering;
   int cavenum, intermissionnum, num;
   int cavelength, bufp;
-  GList *caveset = NULL, *iter;
-  guint32 encodedlength;
+  List *caveset = NULL, *iter;
+  unsigned int encodedlength;
   GdCavefileFormat format;
 
   if (length != -1 && length < 12)
@@ -2312,7 +2352,7 @@ GList *gd_caveset_import_from_buffer (const guint8 *buf, gsize length)
     return NULL;
   }
 
-  encodedlength = GUINT32_FROM_LE(*((guint32 *)(buf + 8)));
+  encodedlength = (unsigned int)(*((unsigned int *)(buf + 8)));
   if (length != -1 && encodedlength != length - 12)
   {
     Warn("file length and data size mismatch in GDash datafile");
@@ -2320,7 +2360,7 @@ GList *gd_caveset_import_from_buffer (const guint8 *buf, gsize length)
   }
 
   format = gd_caveset_imported_get_format(buf);
-  if (format==GD_FORMAT_UNKNOWN)
+  if (format == GD_FORMAT_UNKNOWN)
   {
     Warn("buffer does not contain a GDash datafile");
     return NULL;
@@ -2335,29 +2375,29 @@ GList *gd_caveset_import_from_buffer (const guint8 *buf, gsize length)
   while (bufp < length)
   {
     GdCave *newcave;
-    /* default is to append cave to caveset; g_list_insert appends when pos = -1 */
+    // default is to append cave to caveset; list_insert appends when pos = -1
     int insertpos = -1;
 
     newcave = gd_cave_new();
 
-    cavelength = 0;    /* to avoid compiler warning */
+    cavelength = 0;    // to avoid compiler warning
 
     switch (format)
     {
-      case GD_FORMAT_BD1:                /* boulder dash 1 */
-      case GD_FORMAT_BD1_ATARI:          /* boulder dash 1, atari version */
-      case GD_FORMAT_DC1:                /* deluxe caves 1 */
-      case GD_FORMAT_BD2:                /* boulder dash 2 */
-      case GD_FORMAT_BD2_ATARI:          /* boulder dash 2 */
-       /* these are not in the data so we guess */
+      case GD_FORMAT_BD1:                // boulder dash 1
+      case GD_FORMAT_BD1_ATARI:          // boulder dash 1, atari version
+      case GD_FORMAT_DC1:                // deluxe caves 1
+      case GD_FORMAT_BD2:                // boulder dash 2
+      case GD_FORMAT_BD2_ATARI:          // boulder dash 2
+       // these are not in the data so we guess
        newcave->selectable = (cavenum < 16) && (cavenum % 4 == 0);
        newcave->intermission = cavenum > 15;
 
-       /* no name, so we make up one */
+       // no name, so we make up one
        if (newcave->intermission)
-         g_snprintf(newcave->name, sizeof(newcave->name), _("Intermission %d"), cavenum - 15);
+         snprintf(newcave->name, sizeof(newcave->name), _("Intermission %d"), cavenum - 15);
        else
-         g_snprintf(newcave->name, sizeof(newcave->name), _("Cave %c"), 'A' + cavenum);
+         snprintf(newcave->name, sizeof(newcave->name), _("Cave %c"), 'A' + cavenum);
 
        switch(format)
        {
@@ -2375,8 +2415,8 @@ GList *gd_caveset_import_from_buffer (const guint8 *buf, gsize length)
            break;
        };
 
-       /* original bd1 had level order ABCDEFGH... and then the last four were the intermissions.
-        * those should be inserted between D-E, H-I... caves. */
+       // original bd1 had level order ABCDEFGH... and then the last four were the intermissions.
+       // those should be inserted between D-E, H-I... caves.
        if (cavenum > 15)
          insertpos = (cavenum - 15) * 5 - 1;
        break;
@@ -2384,32 +2424,35 @@ GList *gd_caveset_import_from_buffer (const guint8 *buf, gsize length)
       case GD_FORMAT_FIRSTB:
        cavelength = cave_copy_from_1stb(newcave, buf + bufp, length - bufp);
 
-       /* every fifth cave (4+1 intermission) is selectable. */
+       // every fifth cave (4+1 intermission) is selectable.
        newcave->selectable = cavenum % 5 == 0;
        break;
 
-      case GD_FORMAT_PLC:                /* peter liepa construction kit */
-      case GD_FORMAT_PLC_ATARI:          /* peter liepa construction kit, atari version */
+      case GD_FORMAT_PLC:                // peter liepa construction kit
+      case GD_FORMAT_PLC_ATARI:          // peter liepa construction kit, atari version
        cavelength = cave_copy_from_plck(newcave, buf + bufp, length - bufp, format);
        break;
 
       case GD_FORMAT_DLB:
-       /* no one's delight boulder dash, something like rle compressed plck caves */
-       /* but there are 20 of them, as if it was a bd1 or bd2 game. also num%5 = 4 is intermission. */
-       /* we have to set intermission flag on our own, as the file did not contain the info explicitly */
+       // no one's delight boulder dash, something like rle compressed plck caves
+       // but there are 20 of them, as if it was a bd1 or bd2 game.
+       // also num%5 = 4 is intermission.
+       // we have to set intermission flag on our own, as the file did not contain
+       // the info explicitly
+
        newcave->intermission = (cavenum % 5) == 4;
        if (newcave->intermission)
        {
-         /* also set visible size */
+         // also set visible size
          newcave->x2 = 19;
          newcave->y2 = 11;
        }
 
-       newcave->selectable = cavenum % 5 == 0;    /* original selection scheme */
+       newcave->selectable = cavenum % 5 == 0;    // original selection scheme
        if (newcave->intermission)
-         g_snprintf(newcave->name, sizeof(newcave->name), _("Intermission %d"), cavenum / 5 + 1);
+         snprintf(newcave->name, sizeof(newcave->name), _("Intermission %d"), cavenum / 5 + 1);
        else
-         g_snprintf(newcave->name, sizeof(newcave->name), _("Cave %c"), 'A'+(cavenum % 5 + cavenum / 5 * 4));
+         snprintf(newcave->name, sizeof(newcave->name), _("Cave %c"), 'A'+(cavenum % 5 + cavenum / 5 * 4));
 
        cavelength = cave_copy_from_dlb (newcave, buf + bufp, length - bufp);
        break;
@@ -2441,13 +2484,13 @@ GList *gd_caveset_import_from_buffer (const guint8 *buf, gsize length)
     }
     else
     {
-      caveset = g_list_insert(caveset, newcave, insertpos);
+      caveset = list_insert(caveset, newcave, insertpos);
     }
 
     cavenum++;
     bufp += cavelength;
 
-    /* hack: some dlb files contain junk data after 20 caves. */
+    // hack: some dlb files contain junk data after 20 caves.
     if (format == GD_FORMAT_DLB && cavenum == 20)
     {
       if (bufp < length)
@@ -2456,18 +2499,18 @@ GList *gd_caveset_import_from_buffer (const guint8 *buf, gsize length)
     }
   }
 
-  /* try to detect if plc caves are in standard layout. */
-  /* that is, caveset looks like an original, (4 cave,1 intermission)+ */
+  // try to detect if plc caves are in standard layout.
+  // that is, caveset looks like an original, (4 cave,1 intermission)+
   if (format == GD_FORMAT_PLC)
-    /* if no selection table stored by any2gdash */
+    // if no selection table stored by any2gdash
     if ((buf[2 + 0x1f0] != buf[2 + 0x1f1] - 1) ||
        (buf[2 + 0x1f0] != 0x19 && buf[2 + 0x1f0] != 0x0e))
     {
-      GList *iter;
+      List *iter;
       int n;
       boolean standard;
 
-      standard = (g_list_length(caveset)%5) == 0;    /* cave count % 5 != 0 -> nonstandard */
+      standard = (list_length(caveset)%5) == 0;    // cave count % 5 != 0 -> nonstandard
 
       for (n = 0, iter = caveset; iter != NULL; n++, iter = iter->next)
       {
@@ -2475,48 +2518,48 @@ GList *gd_caveset_import_from_buffer (const guint8 *buf, gsize length)
 
        if ((n % 5 == 4 && !cave->intermission) ||
            (n % 5 != 4 && cave->intermission))
-         standard = FALSE;    /* 4 cave, 1 intermission */
+         standard = FALSE;    // 4 cave, 1 intermission
       }
 
-      /* if test passed, update selectability */
+      // if test passed, update selectability
       if (standard)
        for (n = 0, iter = caveset; iter != NULL; n++, iter = iter->next)
        {
          GdCave *cave = iter->data;
 
-         /* update "selectable" */
+         // update "selectable"
          cave->selectable = (n % 5) == 0;
        }
     }
 
-  /* try to give some names for the caves */
+  // try to give some names for the caves
   cavenum = 1;
   intermissionnum = 1;
   num = 1;
 
-  /* use numbering instead of letters, if following formats or too many caves
-     (as we would run out of letters) */
-  numbering = format == GD_FORMAT_PLC || format==GD_FORMAT_CRLI || g_list_length(caveset) > 26;
+  // use numbering instead of letters, if following formats or too many caves
+  // (as we would run out of letters)
+  numbering = format == GD_FORMAT_PLC || format == GD_FORMAT_CRLI || list_length(caveset) > 26;
 
   for (iter = caveset; iter != NULL; iter = iter->next)
   {
     GdCave *cave = (GdCave *)iter->data;
 
-    if (!strEqual(cave->name, ""))    /* if it already has a name, skip */
+    if (!strEqual(cave->name, ""))    // if it already has a name, skip
       continue;
 
     if (cave->intermission)
     {
-      /* intermission */
+      // intermission
       if (numbering)
-       g_snprintf(cave->name, sizeof(cave->name), _("Intermission %02d"), num);
+       snprintf(cave->name, sizeof(cave->name), _("Intermission %02d"), num);
       else
-       g_snprintf(cave->name, sizeof(cave->name), _("Intermission %d"), intermissionnum);
+       snprintf(cave->name, sizeof(cave->name), _("Intermission %d"), intermissionnum);
     } else {
       if (numbering)
-       g_snprintf(cave->name, sizeof(cave->name), _("Cave %02d"), num);
+       snprintf(cave->name, sizeof(cave->name), _("Cave %02d"), num);
       else
-       g_snprintf(cave->name, sizeof(cave->name), _("Cave %c"), 'A' - 1 + cavenum);
+       snprintf(cave->name, sizeof(cave->name), _("Cave %c"), 'A' - 1 + cavenum);
     }
 
     num++;
@@ -2526,15 +2569,15 @@ GList *gd_caveset_import_from_buffer (const guint8 *buf, gsize length)
       cavenum++;
   }
 
-  /* if the user requests, we make all caves selectable. intermissions not. */
+  // if the user requests, we make all caves selectable. intermissions not.
   if (gd_import_as_all_caves_selectable)
   {
     for (iter = caveset; iter != NULL; iter = iter->next)
     {
       GdCave *cave = (GdCave *)iter->data;
 
-      /* make selectable if not an intermission. */
-      /* also selectable, if it was selectable originally, for some reason. */
+      // make selectable if not an intermission.
+      // also selectable, if it was selectable originally, for some reason.
       cave->selectable = cave->selectable || !cave->intermission;
     }
   }
@@ -2542,8 +2585,7 @@ GList *gd_caveset_import_from_buffer (const guint8 *buf, gsize length)
   return caveset;
 }
 
-/* to be called at program start. */
-void
-gd_c64_import_init_tables(void)
+// to be called at program start.
+void gd_c64_import_init_tables(void)
 {
 }