Skip to content

Commit

Permalink
Fix dragon random movement and 1.x slime speeds.
Browse files Browse the repository at this point in the history
  • Loading branch information
AliceLR committed Dec 20, 2023
1 parent f7eff5b commit 04236b5
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 12 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ USERS
FWRITE_APPEND) is now stored in save files. This fixes a bug
where the output file would be reopened in the wrong mode (ab)
when reloading a saved game.
+ Fixed dragon random movement behavior. A compatibility check
has been added for 2.80 to 2.92 non-random dragon movement.
+ save_slots is now enabled by default for consoles. (Spectere)
+ editor_show_thing_toggles is now enabled by default.
- board_editor_hide_help and robot_editor_hide_help are no
Expand Down
28 changes: 18 additions & 10 deletions src/game_update_board.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "idarray.h"
#include "idput.h"
#include "robot.h"
#include "world.h"
#include "util.h"

#include "audio/sfx.h"
Expand Down Expand Up @@ -468,7 +469,6 @@ void update_board(context *ctx)
}
break;
}
// Cw/Ccw

case CW_ROTATE:
case CCW_ROTATE:
Expand Down Expand Up @@ -787,21 +787,25 @@ void update_board(context *ctx)
{
if(!slow_down)
{
// This is pretty weird, but I have to go by the ASM for now
int spread_speed = current_param & 0x03;
int current_cycle = (current_param & 0x3C) >> 2;

spread_speed |= spread_speed << 1;
int current_cycle = (current_param & 0x3C) >> 2;

// This was changed from speed*5 some time between 2.04 and 2.07.
// Despite MegaZeux 2.x having changed the speed setting range
// from 1-4 to 1-8, this setting has always been two bits.
// BUG: The newer behavior seems to be a broken attempt at speed*3.
if(mzx_world->version >= V251)
spread_speed |= spread_speed << 1;
else
spread_speed |= spread_speed << 2;

if(spread_speed == current_cycle)
{
int new_x, new_y;
current_color = level_color[level_offset];
// Clear cycle
// BUG: This leaves the lowest cycle count bit set, which can't
// be fixed right now (compatibility). Seems like Alexis planned
// to extend the speed range in 2.00 but didn't fully implement
// it; the param dialog has the "wrong" bound too...
// BUG: This leaves the lowest cycle count bit set.
// This bug exists even in MegaZeux 1.x.
current_param &= 0xC7;

// Put slimes all around
Expand Down Expand Up @@ -838,6 +842,7 @@ void update_board(context *ctx)
else
{
// Increase cycle
// BUG: corrupting overflow.
level_param[level_offset] = current_param + 4;
}
}
Expand Down Expand Up @@ -951,6 +956,9 @@ void update_board(context *ctx)
level_param[level_offset] = current_param & 0xE7;

// One out of 8 moves is random
// This was broken in the port for a long time.
if(mzx_world->version < VERSION_PORT || mzx_world->version >= V293)
rval = Random(8);

if(!(rval & 0x07))
{
Expand Down Expand Up @@ -1496,7 +1504,7 @@ void update_board(context *ctx)
level_param[level_offset] = 0x20;
}

level_id[level_offset] = 38;
level_id[level_offset] = (char)EXPLOSION;
play_sfx(mzx_world, SFX_EXPLOSION);
}
else
Expand Down
4 changes: 2 additions & 2 deletions src/legacy_rasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2968,10 +2968,10 @@ boolean legacy_convert_v1_program(char **_dest, int *_dest_len,
if(!dest)
return false;

dest[0] = 0xff;
dest[1] = 0;
*_dest = dest;
*_dest_len = 2;
*_dest[0] = 0xff;
*_dest[1] = 0;
*_cur_prog_line = 0;
return true;
}
Expand Down
Binary file added testworlds/1.00/008 slimeblob.mzx
Binary file not shown.
3 changes: 3 additions & 0 deletions testworlds/1.00/008 slimeblob.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Title: Slime Spread Speed Test
Author: Alice Rowan
Desc: Test MegaZeux 1.x slime spread speeds 1-4 and '5-8', including bugs.
Binary file added testworlds/2.51/013 slimeblob.mzx
Binary file not shown.
3 changes: 3 additions & 0 deletions testworlds/2.51/013 slimeblob.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Title: Slime Spread Speed Test
Author: Alice Rowan
Desc: Test MegaZeux 2.x slime spread speeds 1-4 and '5-8', including bugs. This test does NOT work prior to 2.07, as older versions use 1.x slime speeds.
Binary file added testworlds/2.93/008 Dragon Random.mzx
Binary file not shown.

0 comments on commit 04236b5

Please sign in to comment.