Difference between revisions of "Mighty Bomb Jack (NES)/Game Mechanics"
From SDA Knowledge Base
m (→"Hidden" game mechanics and counters (and RNG)) |
(→Movement mechanics) |
||
Line 37: | Line 37: | ||
(2) $3D9 = $3D9 + $3D8 + [Carry from (1)]<br /><br /> | (2) $3D9 = $3D9 + $3D8 + [Carry from (1)]<br /><br /> | ||
− | Holding up, neutral or down directly impacts the rate of change of $3E6. $3E7 is used to calculate an offset index for a look-up table. The value in the look-up table is then converted to a y-speed (written to $3D8). The rate of change of $3D6 also comes from a look-up table that is also determined by the value of $3E7 | + | $3E7 only depends on $3E6. Holding up, neutral or down directly impacts the rate of change of $3E6. $3E7 keeps track of where in the jump/fall Jack is, which the game uses to calculate a downward acceleration ("pseudo-gravity") to create an arc-like movement. When pressing A to jump, the value is reset to 0 and when it reaches 0x40, Jack is at the apex of the jump. As Jack begins to descend, $3E7 continues to increase until it caps at 0x80. $3E7 is used to calculate an offset index for a look-up table. The value in the look-up table is then converted to a y-speed (written to $3D8). The rate of change of $3D6 also comes from a look-up table that is also determined by the value of $3E7. The y-speed caps at 3.5 px/f. |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<br /><br /> | <br /><br /> | ||
Revision as of 06:19, 20 October 2024
Contents
General game description
You control Jack in his quest to save the royal family that has been trapped inside a pyramid by the evil Belzebut (yes, that's how it's spelled in the game). The game takes place inside (and in two levels even outside) a pyramid (see external resources for a link to a map of it). The game is divided into 17 "rounds" (levels would be more accurate - probably poor translation). Each round consists of several rooms making up a more or less regular, but sometimes branched, platforming stage (called "corridor" in the game), where you just have to reach the door at the end, and at the end is a "palace room". The palace room contains 24 bombs. To clear the round, you need to collect all 24 bombs and then reach the exit.
Endings
The last (17th) round is slightly different. Instead of another "palace room" at the end of the round, you're tasked to rescue the royal family and face Belzebut in the "royal rooms" before escaping the pyramid. There are four different endings. The ending depends on how many of the royal rooms that were solved. To unlock other royal rooms than the King's room, secret items (crystals and S-coins) need to be collected:
- Normal ending - none of the crystals were collected, the game ends after the King's room
- Queen's ending - one of the crystals were collected, Jack continues to the Queen's room after the King's room
- Princess' ending - both crystals were collected, but less than 5 S-coins, Jack continues to the Princess' room after the Queens's room
- "Best ending" - both crystals and 5 or more S-coins were collected, Jack continues to Belzebut's room after the Princess' room
Note: The better the ending, the more of the pyramid Jack destroys. However, the ending texts are all different (as opposed to more and more text being added to the normal ending text, like in e.g. Solomon's Key). It's still obvious what constitutes the "best" ending since there are no branching requirements for the different endings.
Version differences
There are several differences between the ntsc-u and ntsc-j versions. The difficulty of this game (without a walkthrough) is absolutely ludicrous. My guess is that someone tried to tone down the difficulty a notch or two before releasing the game in the US (it's still ridiculous though). Anyways, some items have been moved around, some blocks take more jumps to destroy in the Japanese version etc. For the best ending category, this means that it's meaningless to compare the two versions. For the normal ending, you have to make five block breaking jumps more in the j-version. These extra jumps also mean that an extra mighty coin is needed in the j-version. This equals roughly an additional 3 seconds or so (depending on how fast one is to break blocks). On the other hand, there is a chest in round 17 (room 17-2 to be more exact) that is visible in the j-version but not in the u-version. That room is roughly 1 second faster on the j-version. So overall, the u-version has a few seconds advantage over the j-version, but one should probably not compare the two versions down to the second.
Movement mechanics
x-movement
- $3D1/$3D3 - sub/main Jack's x-position on screen ($3C1/$3C2 - sub/main screen x-position when the level is scrolling)
- $3D0/$3D2 - sub/main x-speed
(1) $3D1 = $3D1 + $3D0
(2) $3D3 = $3D3 + $3D2 + [Carry from (1)]
Since the "sub" x-speed is constant, MBJ will alternate every frame between the speeds 1 pixel/frame and 2 px/f.
y-movement
- $3E6/$3E7 - sub/main "Acceleration index"
- $3D7/$3D9 - sub/main Jack's y-position on screen ($3C3/$3C4 - sub/main screen y-position when the level is scrolling)
- $3D6/$3D8 - sub/main y-speed
(1) $3D7 = $3D7 + $3D6
(2) $3D9 = $3D9 + $3D8 + [Carry from (1)]
$3E7 only depends on $3E6. Holding up, neutral or down directly impacts the rate of change of $3E6. $3E7 keeps track of where in the jump/fall Jack is, which the game uses to calculate a downward acceleration ("pseudo-gravity") to create an arc-like movement. When pressing A to jump, the value is reset to 0 and when it reaches 0x40, Jack is at the apex of the jump. As Jack begins to descend, $3E7 continues to increase until it caps at 0x80. $3E7 is used to calculate an offset index for a look-up table. The value in the look-up table is then converted to a y-speed (written to $3D8). The rate of change of $3D6 also comes from a look-up table that is also determined by the value of $3E7. The y-speed caps at 3.5 px/f.
"Hidden" game mechanics and counters (and RNG)
Counters (and RNG)
The game does not appear to have any RNG addresses or algorithms (but a deeper code analysis would be needed to understand seemingly random behavior in the game). Counters instead play a major role in creating randomness and item spawns:
- Bomb counter ($356) - Collecting a bomb increases the bomb counter by one or two. The first bomb in a room is always worth 1 bomb point. There is then a "next bomb" in the order, which gives 2 bomb points. In the palace rooms, the next bomb is the one that's lit. In the stages, it's not always easy to know which bomb is the next in order, but it usually follows the stage layout. Other than giving 2 bomb points, these bombs also give a different sound when collected. The bomb counter can be reset in three different ways:
- Complete a palace room
- Collect a P-ball (see the enemy section) and let its effect wear out before leaving the room (timer in $6B/$6A - 256+64 = 320f)
- Activate green Jack and let its effect wear out before leaving the room (timer in $6B/$6A - 256+64 = 320f)
Note 1: Any bombs collected while the P-effect or green Jack are active will not add to the bomb counter
Note 2: If Jack leaves the room before the timer has finished counting down (#2 and #3), the timer will be reset to 0, but the bomb counter will not
- A-counter ($00FA) - Increases every time A is pressed (regardless if it results in a jump or not) during gameplay (not during room transitions). It's never reset. This counter determines the enemy types (see the enemy section). The number of A-presses is also used to downgrade Jack after having used a mighty coin (see the item section).
- Coin counter ($0367) - Of less interest in a speedrun. Each collected coin (either found in chests or by transforming enemies after collecting a P-ball or upgrading to green Jack) adds one to the coin counter. See the item section for the purpose of coins (under E-ball).
Palace room warping
When the first bomb is collected in a palace room, the next bomb in the sequence of that room will be lit. If that lit bomb is collected as the last (24th) in that palace room, Jack will warp to the next palace room, skipping the corridor section.
Note 1: If Jack dies, he will start at the corridor before the palace room warping started
Note 2: This trick has no effect in palace room 16, since that's the last palace room
Items
The following items are of interest in a speedrun:
- Mighty coins - Found in chests (always in the same location). The coins are described in the manual, but the text contains several errors. Jack can hold up to 9 coins at a time (tracked in $03E2). Picking up a tenth coin sends him to the torture chamber (very bad). When using a mighty coin, the value in $03E1 increases to a set value (and then decreases by 1 every time A is pressed) and Jack gains different abilities:
- coin [Blue ($3E0 = 1)] $03E1 is set to 20 (decimal) and Jack can now open locked chests by jumping on them. Note that you can normally press A 20 times before reverting back to red Jack. However, if powered down from orange Jack, Jack will turn blue when $03E1 equals 19, meaning that he will turn red after pressing A 19 times in this case.
- coin [Orange ($3E0 = 2)] When using a coin as blue Jack, $03E1 is set to 30 (decimal), regardless of the previous value of $03E1. Orange Jack has the same effect as blue and he can now also open chests (both normal and locked) by running into them from the side (or jumping into them from below). Like for blue Jack, how long the effect lasts depends on if Jack was powered up from blue or powered down from green. If powered up, it lasts for 11 A presses. If powered down, it lasts for 10 presses.
- coin [Green ($3E0 = 3)] When using a coin as orange Jack, $03E1 is set to 35 (decimal), regardless of the previous value of $03E1. Same effect as orange, but S-coins can now be collected and all enemies turn into coins for a few seconds (same effect as collecting a P-ball). Jack turns back to orange after pressing A 6 times.
When Jack is green, mighty coins can't be used (not even to reset $03E1 to 35).
- Crystal balls - There are two crystal balls in the game. Both are found in special chambers, where you need to break some of the blocks surrounding them. Picking up one crystal will unlock the queen's room and collecting both will also unlock the princess' room. In order to get the best ending, you need to collect both.
- S-coins - Found in chests (always in the same location). There are in total 10 (?) of these coins. Collecting 5 of these will open up Belzebut's room at the end (only if both crystal balls have also been collected along the way). There is no point in collecting more than 5 S-coins (other than scoring points). Only green Jack can pick up S-coins (but there is no restriction on what form you need to be in to make it visible).
- Sphinx - Some doors are hidden or locked. The only way to open these is to find the corresponding sphinx (sometimes there are more than one sphinx in a room and each one corresponds to one door).
- P-ball - All enemies turn into coins for 320 frames. The P-ball is spawned when the bomb counter (see the section about counters) reaches 20. When the bomb counter reaches 20 during the stage, a jingle sound effect is played and the next opened chest will contain the P-ball (along with whatever it initially held). If it happens in a palace room, it will spawn in (or near?) the center of the room and start moving around diagonally.
- B-ball - Bonus points. Appears in a palace room when the score passes a multiple of 5000. The B-ball does not appear in the corridors or as a result of the points awarded from completing a round.
- E-ball - Extra life ($3E4). Found in secret locations, but can also be triggered by gold coins (tracked in $0367). You need to collect 40 coins or more. The next time the score passes a multiple of 5000 in a palace room, the E-ball will appear (instead of the B-ball).
- Bottle - Increases the timer ($A4, supported by $229 for changing from hex to dec). Should be avoided in a speedrun as it costs time counting down after the end of each level (6f per "tick").
Enemy behavior and manipulation
Mummies
This section describes mummies in the palace rooms. Mummies in the corridor sections probably behave similarly, but haven't been investigated.
RAM-addresses of interest
- $3D3/$3D9 - MBJ's x/y-position
- $35E - Mummy spawn timer (room)
- $6AA - Movement direction, item 0 ($6BA looks similar, but is the way the mummy is facing)
- $6AB/$6B1 - x/y, item 0
- $6BB - Drop timer, item 0
- $94/$92 - Temp variables, x/y-position of possible enemy spawn locations
- $C - Temp variable, sum of the absolute differences in x and y between MBJ's position and the left enemy spawn location (LESL), or written as a formula = Abs(MBJ_x - LESL_x) + Abs(MBJ_y - LESL_y)
- $E - Temp variable, sum of the absolute differences in x and y between MBJ's position and the right enemy spawn location (RESL), or written as a formula = Abs(MBJ_x - RESL_x) + Abs(MBJ_y - RESL_y)
Item addresses are separated by 0x1C, meaning e.g. the first 6 x-addresses are $6AB, $6C7, $6E3, $6FF, $71B and $737.
When the room starts, the mummy spawn timer starts ticking down every frame. When it has counted down, a mummy spawns. The timer is reset and the process starts over until there are four enemies. The base value of the timer is room-dependent. The later in the game, the shorter the delay to spawn mummies (with some exceptions - the delay seems to be at a minimum in palace rooms 12 and 13, 0x2F).
Note: when clearing a palace room, the progression in $3CC is updated. $3CC feeds into the timers' start values of the next rooms. By navigating through the pyramid in such a way that palace rooms are skipped, the timers will not be updated. However, once a palace room is cleared, $3CC is updated to its "correct" value again. This effect matters when e.g. routing the best ending category (in particular palace room 10).
There are two possible spawn locations ("left" and "right") in each room. The x-positions are room-dependent and probably related to how the platforms are placed in the individual rooms. The mummy spawns in the location that is the furthest away from MBJ in terms of "coordinate distance" (see description for $E and $C above). Note that these calculations can easily overflow, meaning the result is reversed (the enemy closest to MBJ spawns).
Once the mummy has spawned, the general rule is that it starts walking in the direction of MBJ (there are exceptions, see below). It walks back and forth on the platform until the drop timer has counted down. Next time it reaches an edge, it will drop down. If the mummy landed on another platform (and not the floor), the drop timer is reset and will start counting down again. Just like the spawn timer, the drop timers are room-dependent and mummies generally drop down faster as the game progresses.
Note: the movement direction address can be called from a second location in the code and revert the direction (meaning the mummy starts walking away from MBJ instead). The same piece of code can be called again, reverting back to the "normal" movement direction (so walking towards MBJ). This game mechanics has not been fully analyzed. However, player inputs can manipulate this. To study this effect, the following movie and instructions can be used (credits to 'SpaceColonizer'):
https://tasvideos.org/UserFiles/Info/638237798222671732
Truncate the movie at frame 17814. Mummy 1 goes right as expected.
Add left input up to frame 17830. Mummy 1 now starts going left, which is not the expected direction.
By playing around with the inputs, it's fairly easy to create more movement direction changes of the same kind.
Earlier on in the same room of the same movie, mummy 0 fell through a platform. This has not been investigated in detail either, but it's easy to see how small input changes can make the mummy stay on the platform instead.
Transformed enemies
The mummies transform into one of six enemy types when dropping to the floor (these are not the official names, but the official ones would probably be quite confusing to use):
0. Bat - Moves around diagonally without considering Jack's position.
1. Lobster - Fast moving enemy that homes in on Jack. Only moves diagonally. (in most situations, this is the most dangerous enemy)
2. Jellyfish - Every time it hits an obstacle, it moves in a straight line towards MBJ's position. It seems to have (at least) two speed components. The base speed seems to be determined when bouncing against an obstacle. The further away it was from MBJ, the more base speed it gets. It also changes the speed, but to a lesser extent, between obstacles. It speeds up if MBJ is further away and it slows down as it gets closer to MBJ. The detailed mechanics have not been analyzed.
3. Skull - Homes in on Jack horizontally, but cannot control its vertical movement. Moves diagonally.
4. Fireball - Homes in on Jack vertically, but cannot control its horizontal movement. Moves diagonally.
5. Bird - Slow moving enemy that homes in on Jack horizontally and vertically. It can't move diagonally.
The enemy type is determined three frames before the mummy starts transforming. The game then takes the A-counter (see the Counter section) and calculates the modulus of 6 of that value (= the remainder when dividing by 6). The numbers in front of the different enemy types indicate these values. It's very much possible to manipulate the enemy spawns in certain areas (and it can also save time speedrun). Since the value is never reset, it's however also difficult to know its value at any given point in time. The best way to find out the value is to watch which enemy that spawns at a certain point and then start counting the A-presses onward. This is luckily well suited for the speedrun mindset, with a pre-determined route which often allows for a constant number of A-presses between two given points. Needless to say, stretches of gliding in mid-air with rapid A-presses make this harder to control.
Important note: There is a discontinuity in the enemy type spawns as the A-counter loops. 255 gives a remainder of 3 when divided by 6, while 0 obviously gives a remainder of 0 when divided by 6. This means that two enemy types are jumped over in the cycle. A normal ending run will loop the counter near the end, while a best ending run will loop two or maybe even three times (depending on the category that is played). In the best ending route that is/will be described here in the kb, both times the counter loops occur close to sections of enemy manipulation and therefore need to be taken into account when planning the route.