#define SPRING_ROLL /* spring rolling off round things continues to roll */
#define ACID_ROLL /* rolling objects go into acid rather than remove it */
+#define ACID_PLAYER /* player gets killed by acid, but without explosion */
-#define USE_CHANGED_ACID_STUFF
-
-#define RANDOM_RAW (seed = seed << 31 | seed >> 1)
-#define RANDOM(x) (RANDOM_RAW & (x - 1))
+#define RANDOM(x) ((seed = seed << 31 | seed >> 1) % x)
static short **cave, **next, **boom;
static unsigned int seed;
[Xamoeba_8] = 1
};
+static byte is_android_blank[GAME_TILE_MAX] =
+{
+ [Xblank] = 1,
+ [Xsplash_e] = 1,
+ [Xsplash_w] = 1,
+ [Xfake_acid_1] = 1,
+ [Xfake_acid_2] = 1,
+ [Xfake_acid_3] = 1,
+ [Xfake_acid_4] = 1,
+ [Xfake_acid_5] = 1,
+ [Xfake_acid_6] = 1,
+ [Xfake_acid_7] = 1,
+ [Xfake_acid_8] = 1
+};
+
static const byte is_android_walkable[GAME_TILE_MAX] =
{
[Xblank] = 1,
boom[x][y+1] = lev.eater_array[lev.eater_pos][7];
boom[x+1][y+1] = lev.eater_array[lev.eater_pos][8];
- lev.eater_pos = (lev.eater_pos + 1) & 7;
+ lev.eater_pos = (lev.eater_pos + 1) % 8;
#if PLAY_ELEMENT_SOUND
play_element_sound(x, y, SOUND_boom, Xeater_n);
Lboom_eater(x, y);
}
+static void Lboom_cave_new(int x, int y, int element)
+{
+ if (game_em.use_old_explosions)
+ return;
+
+ cave[x][y] = element;
+}
+
+static void Lboom_next_new(int x, int y, int element)
+{
+ if (game_em.use_old_explosions)
+ return;
+
+ next[x][y] = element;
+}
+
+static void Lpush_element_old(int x, int y, int element)
+{
+ if (!game_em.use_old_push_elements)
+ return;
+
+ cave[x][y] = element;
+ next[x][y] = element;
+}
+
static boolean player_killed(struct PLAYER *ply)
{
int x = ply->x;
switch (cave[x][y])
{
-#ifdef USE_CHANGED_ACID_STUFF
+#ifdef ACID_PLAYER
case Xacid_1:
case Xacid_2:
case Xacid_3:
case Xsplash_w:
cave[x][y] = Zplayer;
next[x][y] = Zplayer;
+ // FALL THROUGH
+
case Xfake_acid_1:
case Xfake_acid_2:
case Xfake_acid_3:
ply->y = y;
break;
-#ifdef USE_CHANGED_ACID_STUFF
case Xacid_1:
case Xacid_2:
case Xacid_3:
case Xacid_6:
case Xacid_7:
case Xacid_8:
+#ifdef ACID_PLAYER
if (cave[x+1][y-1] == Xblank)
cave[x+1][y-1] = Xsplash_e;
if (cave[x-1][y-1] == Xblank)
cave[x-1][y-1] = Xsplash_w;
play_element_sound(x, y, SOUND_acid, Xacid_1);
+ // FALL THROUGH
#endif
-
case Xboom_android:
case Xboom_1:
case Xbug_1_n:
case Xtank_2_e:
case Xtank_2_s:
case Xtank_2_w:
-
-#ifndef USE_CHANGED_ACID_STUFF
- case Xacid_1:
- case Xacid_2:
- case Xacid_3:
- case Xacid_4:
- case Xacid_5:
- case Xacid_6:
- case Xacid_7:
- case Xacid_8:
-#endif
ply->anim = PLY_walk_n + anim;
ply->x = x;
ply->y = y;
}
}
+ /* check for wrap-around movement */
+ if (ply->x < lev.left ||
+ ply->x > lev.right - 1)
+ play_element_sound(oldx, oldy, SOUND_door, Xdoor_1);
+
return result;
}
if (lev.android_clone_cnt == 0)
{
- if (!is_blank[cave[x-1][y-1]] &&
- !is_blank[cave[x][y-1]] &&
- !is_blank[cave[x+1][y-1]] &&
- !is_blank[cave[x-1][y]] &&
- !is_blank[cave[x+1][y]] &&
- !is_blank[cave[x-1][y+1]] &&
- !is_blank[cave[x][y+1]] &&
- !is_blank[cave[x+1][y+1]])
+ if (!is_android_blank[cave[x-1][y-1]] &&
+ !is_android_blank[cave[x][y-1]] &&
+ !is_android_blank[cave[x+1][y-1]] &&
+ !is_android_blank[cave[x-1][y]] &&
+ !is_android_blank[cave[x+1][y]] &&
+ !is_android_blank[cave[x-1][y+1]] &&
+ !is_android_blank[cave[x][y+1]] &&
+ !is_android_blank[cave[x+1][y+1]])
goto android_move;
switch (RANDOM(8))
/* randomly find a direction to move */
case 0: /* S,NE,W,NW,SE,E,SW,N */
- if (is_blank[cave[x][y+1]]) goto android_s;
- if (is_blank[cave[x+1][y-1]]) goto android_ne;
- if (is_blank[cave[x-1][y]]) goto android_w;
- if (is_blank[cave[x-1][y-1]]) goto android_nw;
- if (is_blank[cave[x+1][y+1]]) goto android_se;
- if (is_blank[cave[x+1][y]]) goto android_e;
- if (is_blank[cave[x-1][y+1]]) goto android_sw;
- if (is_blank[cave[x][y-1]]) goto android_n;
+ if (is_android_blank[cave[x][y+1]]) goto android_s;
+ if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
+ if (is_android_blank[cave[x-1][y]]) goto android_w;
+ if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
+ if (is_android_blank[cave[x+1][y+1]]) goto android_se;
+ if (is_android_blank[cave[x+1][y]]) goto android_e;
+ if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
+ if (is_android_blank[cave[x][y-1]]) goto android_n;
goto android_move;
case 1: /* NW,SE,N,S,NE,SW,E,W */
- if (is_blank[cave[x-1][y-1]]) goto android_nw;
- if (is_blank[cave[x+1][y+1]]) goto android_se;
- if (is_blank[cave[x][y-1]]) goto android_n;
- if (is_blank[cave[x][y+1]]) goto android_s;
- if (is_blank[cave[x+1][y-1]]) goto android_ne;
- if (is_blank[cave[x-1][y+1]]) goto android_sw;
- if (is_blank[cave[x+1][y]]) goto android_e;
- if (is_blank[cave[x-1][y]]) goto android_w;
+ if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
+ if (is_android_blank[cave[x+1][y+1]]) goto android_se;
+ if (is_android_blank[cave[x][y-1]]) goto android_n;
+ if (is_android_blank[cave[x][y+1]]) goto android_s;
+ if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
+ if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
+ if (is_android_blank[cave[x+1][y]]) goto android_e;
+ if (is_android_blank[cave[x-1][y]]) goto android_w;
goto android_move;
case 2: /* SW,E,S,W,N,NW,SE,NE */
- if (is_blank[cave[x-1][y+1]]) goto android_sw;
- if (is_blank[cave[x+1][y]]) goto android_e;
- if (is_blank[cave[x][y+1]]) goto android_s;
- if (is_blank[cave[x-1][y]]) goto android_w;
- if (is_blank[cave[x][y-1]]) goto android_n;
- if (is_blank[cave[x-1][y-1]]) goto android_nw;
- if (is_blank[cave[x+1][y+1]]) goto android_se;
- if (is_blank[cave[x+1][y-1]]) goto android_ne;
+ if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
+ if (is_android_blank[cave[x+1][y]]) goto android_e;
+ if (is_android_blank[cave[x][y+1]]) goto android_s;
+ if (is_android_blank[cave[x-1][y]]) goto android_w;
+ if (is_android_blank[cave[x][y-1]]) goto android_n;
+ if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
+ if (is_android_blank[cave[x+1][y+1]]) goto android_se;
+ if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
goto android_move;
case 3: /* N,SE,NE,E,W,S,NW,SW */
- if (is_blank[cave[x][y-1]]) goto android_n;
- if (is_blank[cave[x+1][y+1]]) goto android_se;
- if (is_blank[cave[x+1][y-1]]) goto android_ne;
- if (is_blank[cave[x+1][y]]) goto android_e;
- if (is_blank[cave[x-1][y]]) goto android_w;
- if (is_blank[cave[x][y+1]]) goto android_s;
- if (is_blank[cave[x-1][y-1]]) goto android_nw;
- if (is_blank[cave[x-1][y+1]]) goto android_sw;
+ if (is_android_blank[cave[x][y-1]]) goto android_n;
+ if (is_android_blank[cave[x+1][y+1]]) goto android_se;
+ if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
+ if (is_android_blank[cave[x+1][y]]) goto android_e;
+ if (is_android_blank[cave[x-1][y]]) goto android_w;
+ if (is_android_blank[cave[x][y+1]]) goto android_s;
+ if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
+ if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
goto android_move;
case 4: /* SE,NW,E,NE,SW,W,N,S */
- if (is_blank[cave[x+1][y+1]]) goto android_se;
- if (is_blank[cave[x-1][y-1]]) goto android_nw;
- if (is_blank[cave[x+1][y]]) goto android_e;
- if (is_blank[cave[x+1][y-1]]) goto android_ne;
- if (is_blank[cave[x-1][y+1]]) goto android_sw;
- if (is_blank[cave[x-1][y]]) goto android_w;
- if (is_blank[cave[x][y-1]]) goto android_n;
- if (is_blank[cave[x][y+1]]) goto android_s;
+ if (is_android_blank[cave[x+1][y+1]]) goto android_se;
+ if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
+ if (is_android_blank[cave[x+1][y]]) goto android_e;
+ if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
+ if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
+ if (is_android_blank[cave[x-1][y]]) goto android_w;
+ if (is_android_blank[cave[x][y-1]]) goto android_n;
+ if (is_android_blank[cave[x][y+1]]) goto android_s;
goto android_move;
case 5: /* NE,W,SE,SW,S,N,E,NW */
- if (is_blank[cave[x+1][y-1]]) goto android_ne;
- if (is_blank[cave[x-1][y]]) goto android_w;
- if (is_blank[cave[x+1][y+1]]) goto android_se;
- if (is_blank[cave[x-1][y+1]]) goto android_sw;
- if (is_blank[cave[x][y+1]]) goto android_s;
- if (is_blank[cave[x][y-1]]) goto android_n;
- if (is_blank[cave[x+1][y]]) goto android_e;
- if (is_blank[cave[x-1][y-1]]) goto android_nw;
+ if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
+ if (is_android_blank[cave[x-1][y]]) goto android_w;
+ if (is_android_blank[cave[x+1][y+1]]) goto android_se;
+ if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
+ if (is_android_blank[cave[x][y+1]]) goto android_s;
+ if (is_android_blank[cave[x][y-1]]) goto android_n;
+ if (is_android_blank[cave[x+1][y]]) goto android_e;
+ if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
goto android_move;
case 6: /* E,N,SW,S,NW,NE,SE,W */
- if (is_blank[cave[x+1][y]]) goto android_e;
- if (is_blank[cave[x][y-1]]) goto android_n;
- if (is_blank[cave[x-1][y+1]]) goto android_sw;
- if (is_blank[cave[x][y+1]]) goto android_s;
- if (is_blank[cave[x-1][y-1]]) goto android_nw;
- if (is_blank[cave[x+1][y-1]]) goto android_ne;
- if (is_blank[cave[x+1][y+1]]) goto android_se;
- if (is_blank[cave[x-1][y]]) goto android_w;
+ if (is_android_blank[cave[x+1][y]]) goto android_e;
+ if (is_android_blank[cave[x][y-1]]) goto android_n;
+ if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
+ if (is_android_blank[cave[x][y+1]]) goto android_s;
+ if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
+ if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
+ if (is_android_blank[cave[x+1][y+1]]) goto android_se;
+ if (is_android_blank[cave[x-1][y]]) goto android_w;
goto android_move;
case 7: /* W,SW,NW,N,E,SE,NE,S */
- if (is_blank[cave[x-1][y]]) goto android_w;
- if (is_blank[cave[x-1][y+1]]) goto android_sw;
- if (is_blank[cave[x-1][y-1]]) goto android_nw;
- if (is_blank[cave[x][y-1]]) goto android_n;
- if (is_blank[cave[x+1][y]]) goto android_e;
- if (is_blank[cave[x+1][y+1]]) goto android_se;
- if (is_blank[cave[x+1][y-1]]) goto android_ne;
- if (is_blank[cave[x][y+1]]) goto android_s;
+ if (is_android_blank[cave[x-1][y]]) goto android_w;
+ if (is_android_blank[cave[x-1][y+1]]) goto android_sw;
+ if (is_android_blank[cave[x-1][y-1]]) goto android_nw;
+ if (is_android_blank[cave[x][y-1]]) goto android_n;
+ if (is_android_blank[cave[x+1][y]]) goto android_e;
+ if (is_android_blank[cave[x+1][y+1]]) goto android_se;
+ if (is_android_blank[cave[x+1][y-1]]) goto android_ne;
+ if (is_android_blank[cave[x][y+1]]) goto android_s;
goto android_move;
}
}
case Xeater_s:
case Xeater_w:
cave[x][y] = Ystone_sB;
- next[x][y] = Xblank;
+ Lboom_next_new(x, y, Xblank);
cave[x][y+1] = Yeater_stone;
next[x][y+1] = Zeater;
Lboom_eater_old(x, y+1);
case Xalien:
case Xalien_pause:
cave[x][y] = Ystone_sB;
- next[x][y] = Xblank;
+ Lboom_next_new(x, y, Xblank);
cave[x][y+1] = Yalien_stone;
next[x][y+1] = Ztank;
Lboom_tank_old(x, y+1);
case Xbug_2_s:
case Xbug_2_w:
cave[x][y] = Ystone_sB;
- next[x][y] = Xblank;
+ Lboom_next_new(x, y, Xblank);
cave[x][y+1] = Ybug_stone;
next[x][y+1] = Zbug;
Lboom_bug_old(x, y+1);
case Xtank_2_s:
case Xtank_2_w:
cave[x][y] = Ystone_sB;
- next[x][y] = Xblank;
+ Lboom_next_new(x, y, Xblank);
cave[x][y+1] = Ytank_stone;
next[x][y+1] = Ztank;
Lboom_tank_old(x, y+1);
case Xbomb:
case Xbomb_pause:
- cave[x][y] = Xstone;
- next[x][y] = Xstone;
+ Lboom_cave_new(x, y, Xstone);
+ Lboom_next_new(x, y, Xstone);
cave[x][y+1] = Ybomb_blank;
next[x][y+1] = Ztank;
Lboom_tank_old(x, y+1);
switch (cave[x+1][y])
{
+ case Zplayer:
+ if (!game_em.use_old_push_elements)
+ break;
case Zborder:
case Zbug:
case Ztank:
case Xboom_tank:
case Xboom_android:
case Xboom_1:
+ Lpush_element_old(x, y, Xemerald);
return;
#ifdef ACID_ROLL
case Xacid_6:
case Xacid_7:
case Xacid_8:
+ if (game_em.use_old_push_into_acid)
+ break;
if (cave[x+2][y-1] == Xblank)
cave[x+2][y-1] = Xsplash_e;
if (cave[x][y-1] == Xblank)
switch (cave[x-1][y])
{
+ case Zplayer:
+ if (!game_em.use_old_push_elements)
+ break;
case Zborder:
case Zbug:
case Ztank:
case Xboom_tank:
case Xboom_android:
case Xboom_1:
+ Lpush_element_old(x, y, Xemerald);
return;
#ifdef ACID_ROLL
case Xacid_6:
case Xacid_7:
case Xacid_8:
+ if (game_em.use_old_push_into_acid)
+ break;
if (cave[x][y-1] == Xblank)
cave[x][y-1] = Xsplash_e;
if (cave[x-2][y-1] == Xblank)
switch (cave[x+1][y])
{
+ case Zplayer:
+ if (!game_em.use_old_push_elements)
+ break;
case Zborder:
case Zbug:
case Ztank:
case Xboom_tank:
case Xboom_android:
case Xboom_1:
+ Lpush_element_old(x, y, Xdiamond);
return;
#ifdef ACID_ROLL
case Xacid_6:
case Xacid_7:
case Xacid_8:
+ if (game_em.use_old_push_into_acid)
+ break;
if (cave[x+2][y-1] == Xblank)
cave[x+2][y-1] = Xsplash_e;
if (cave[x][y-1] == Xblank)
switch (cave[x-1][y])
{
+ case Zplayer:
+ if (!game_em.use_old_push_elements)
+ break;
case Zborder:
case Zbug:
case Ztank:
case Xboom_tank:
case Xboom_android:
case Xboom_1:
+ Lpush_element_old(x, y, Xdiamond);
return;
#ifdef ACID_ROLL
case Xacid_6:
case Xacid_7:
case Xacid_8:
+ if (game_em.use_old_push_into_acid)
+ break;
if (cave[x][y-1] == Xblank)
cave[x][y-1] = Xsplash_e;
if (cave[x-2][y-1] == Xblank)
switch (cave[x+1][y])
{
+ case Zplayer:
+ if (!game_em.use_old_push_elements)
+ break;
case Zborder:
case Zbug:
case Ztank:
case Xboom_tank:
case Xboom_android:
case Xboom_1:
+ Lpush_element_old(x, y, Xstone);
return;
#ifdef ACID_ROLL
case Xacid_6:
case Xacid_7:
case Xacid_8:
+ if (game_em.use_old_push_into_acid)
+ break;
if (cave[x+2][y-1] == Xblank)
cave[x+2][y-1] = Xsplash_e;
if (cave[x][y-1] == Xblank)
switch (cave[x-1][y])
{
+ case Zplayer:
+ if (!game_em.use_old_push_elements)
+ break;
case Zborder:
case Zbug:
case Ztank:
case Xboom_tank:
case Xboom_android:
case Xboom_1:
+ Lpush_element_old(x, y, Xstone);
return;
#ifdef ACID_ROLL
case Xacid_6:
case Xacid_7:
case Xacid_8:
+ if (game_em.use_old_push_into_acid)
+ break;
if (cave[x][y-1] == Xblank)
cave[x][y-1] = Xsplash_e;
if (cave[x-2][y-1] == Xblank)
switch (cave[x+1][y])
{
+ case Zplayer:
+ if (!game_em.use_old_push_elements)
+ break;
case Zborder:
case Zbug:
case Ztank:
case Xboom_tank:
case Xboom_android:
case Xboom_1:
+ Lpush_element_old(x, y, Xbomb);
return;
#ifdef ACID_ROLL
case Xacid_6:
case Xacid_7:
case Xacid_8:
+ if (game_em.use_old_push_into_acid)
+ break;
if (cave[x+2][y-1] == Xblank)
cave[x+2][y-1] = Xsplash_e;
if (cave[x][y-1] == Xblank)
switch (cave[x-1][y])
{
+ case Zplayer:
+ if (!game_em.use_old_push_elements)
+ break;
case Zborder:
case Zbug:
case Ztank:
case Xboom_tank:
case Xboom_android:
case Xboom_1:
+ Lpush_element_old(x, y, Xbomb);
return;
#ifdef ACID_ROLL
case Xacid_6:
case Xacid_7:
case Xacid_8:
+ if (game_em.use_old_push_into_acid)
+ break;
if (cave[x][y-1] == Xblank)
cave[x][y-1] = Xsplash_e;
if (cave[x-2][y-1] == Xblank)
switch (cave[x+1][y])
{
+ case Zplayer:
+ if (!game_em.use_old_push_elements)
+ break;
case Zborder:
case Zbug:
case Ztank:
case Xboom_tank:
case Xboom_android:
case Xboom_1:
+ Lpush_element_old(x, y, Xnut);
return;
#ifdef ACID_ROLL
case Xacid_6:
case Xacid_7:
case Xacid_8:
+ if (game_em.use_old_push_into_acid)
+ break;
if (cave[x+2][y-1] == Xblank)
cave[x+2][y-1] = Xsplash_e;
if (cave[x][y-1] == Xblank)
switch (cave[x-1][y])
{
+ case Zplayer:
+ if (!game_em.use_old_push_elements)
+ break;
case Zborder:
case Zbug:
case Ztank:
case Xboom_tank:
case Xboom_android:
case Xboom_1:
+ Lpush_element_old(x, y, Xnut);
return;
#ifdef ACID_ROLL
case Xacid_6:
case Xacid_7:
case Xacid_8:
+ if (game_em.use_old_push_into_acid)
+ break;
if (cave[x][y-1] == Xblank)
cave[x][y-1] = Xsplash_e;
if (cave[x-2][y-1] == Xblank)
switch (cave[x+1][y])
{
+ case Zplayer:
+ if (!game_em.use_old_push_elements)
+ break;
case Zborder:
case Zbug:
case Ztank:
case Xboom_tank:
case Xboom_android:
case Xboom_1:
+ Lpush_element_old(x, y, Xspring);
return;
#ifdef ACID_ROLL
case Xacid_6:
case Xacid_7:
case Xacid_8:
+ if (game_em.use_old_push_into_acid)
+ break;
if (cave[x+2][y-1] == Xblank)
cave[x+2][y-1] = Xsplash_e;
if (cave[x][y-1] == Xblank)
switch (cave[x-1][y])
{
+ case Zplayer:
+ if (!game_em.use_old_push_elements)
+ break;
case Zborder:
case Zbug:
case Ztank:
case Xboom_tank:
case Xboom_android:
case Xboom_1:
+ Lpush_element_old(x, y, Xspring);
return;
#ifdef ACID_ROLL
case Xacid_6:
case Xacid_7:
case Xacid_8:
+ if (game_em.use_old_push_into_acid)
+ break;
if (cave[x][y-1] == Xblank)
cave[x][y-1] = Xsplash_e;
if (cave[x-2][y-1] == Xblank)
next[x][y] = cave[x][y];
}
+void logic_init(void)
+{
+ int splash_is_blank = !game_em.use_old_android;
+
+ is_android_blank[Xsplash_e] = splash_is_blank;
+ is_android_blank[Xsplash_w] = splash_is_blank;
+}
+
void logic(void)
{
if (frame == 0)