Comment

Comment by whoopdedo

Look at the subroutine `EnemyMoveGetMaxRowBot` starting at line #9353. On #9414 the data row pointer is set to the enemy's current row. On #9441 it checks if the column to the left is a pole. On #9516 it checks if the column to the right is a pole. Now notice that on #9461 the row pointer is moved to the row below so it can check for a walkable tile (brick or ladder). When the right-side check is done after a left-side check the row pointer will be on the wrong row.

Here it is in C (from my own notes)

    SetCurrentRow1(y);
    if (CURROW1[x] != 0) {
        if (x != 0) {
            if (CURROW1[x-1] == 4) {
                TargetY = y;
                if (y >= PlayerY)
                    return y;
            } else {
                SetCurrentRow1(y+1);
                if (CURROW1[x-1] == 1 || CURROW1[x-1] == 2 || CURROW1[x-1] == 3) {
                    TargetY = y;
                    if (y >= PlayerY)
                        return y;
                }
            }
        }
        if (x < 27) {
            if (CURROW1[x+1] == 4) {
                TargetY = y;
                if (y >= PlayerY)
                    return y;
            } else {
                SetCurrentRow1(y+1);
                if (CURROW1[x+1] == 1 || CURROW1[x+1] == 2 || CURROW1[x+1] == 3) {
                    TargetY = y;
                    if (y >= PlayerY)
                        return y;
                }
            }
        }
    }
The bug can be seen on level 29 if you stand on the left set of blocks that has a single gold in it. The enemies will get stuck on the second ladder which has a pole on the right side.

The Apple II, Atari 8-bit, Commodore 64, and naturally the VIC-20 versions of the game have this bug since they were all made by Broderbund. But interestingly so does the Hudson Soft NES port. The later Macintosh version, which is otherwise a direct port of the Apple II code, fixed it. The IBM-PC version didn't have this bug because it was rewritten with the memory layout column-ordered instead of row-ordered. But then introduced a similar bug by subtracting when it should be adding.

(edit: I hadn't checked until just now but I'm amused to find that Lode Runner Legacy from 2017 preserved this bug in the classic game mode.)

parent whoopdedo 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton