Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Unlike Super Mario World, moving platforms in Mega Man 2 have absolutely no correlation with the background graphics.
- In fact, their movement is rather robust; if you move them around in a level editor, they'll often find their way back to the track
- and continue like nothing happened. In this document, we will explore how this path data is enocded and implemented.
- All addresses are for Rockman 2.
- == Path data ==
- Crashman path data: $9B43
- Wily 4 path data: $9BBB
- Path start pointers: $9B25
- Path lengths: $9B3C
- Path Number: Computed based on screen number.
- == Velocity vectors ==
- VY subpixel: $9B2C
- VY pixel: $9B30
- VX subpixel: $9B34
- VX pixel: None!
- Flags: $9B38 - used to set facing direction appropriately.
- == Misc. ==
- Sprite timers: $04E0
- Screen Numbers: $0440
- Platform subroutine: $9A79 (roughly)
- Path data is stored in pairs: target coord, next direction. The game can tell whether target is supposed to be X or Y based on direction.
- 0 = down
- 1 = left
- 2 = up
- 3 = right
- Compute the Path Number, then use that as an index into the length and start_pointer tables.
- Your start pointer is a pointer into either of the path data tables.
- The platform's sprite timer is its current path index, which is added to the start pointer to determine where the next piece of data comes from.
- This index increments by two each time, and the length is even. When index equals length, it goes back to 0.
- Path Numbers:
- Crashman: 0 - 2
- Wily 4: 3 - 6
- These numbers are computed based on the screen number. In Crash (stage == 7), it's screen number - 4. In Wily 4 (all other stages), it's screen number - 1B.
- So these things really can't exist outside of the seven screens they were meant to be in.
- The game checks if Path Number < 3, and looks at the Crashman path data. Otherwise it uses the Wily 4 Path data.
- Velocity vectors:
- Use the facing direction to index into the 4-byte velocity vector tables. They basically tell the platforms what's up. And left. And down. And right.
- You can adjust horizontal speeds to a maximum of (just under) 1 pixel per frame, and vertical speeds to a maximum of (just under) 128 pixels per frame.
- There is no VX pixel because that math is actually handled a bit differently.
- X speed is scalar, and added or subtracted from position based on the facing flag.
- Y speed is treated as signed, sort of. It's always added to your position.
- One thing to note is that the game checks for pixel equality at each path corner. So if you want your platforms to go faster than 1 pixel per frame,
- you might find that they fly off into oblivion. Luckily, the game resets subpixels at each corner, so if your path works once, it will continue to work forever.
- ==========
- What's interesting here is the path numbers are deliberately set not to overlap, but the path data still uses separate tables for the separate stages.
- It seems like you could unify the path data into one big table and save some trouble. However, this won't work. Let's count up how many turns each path makes
- in the vanilla game.
- Crash:
- 0: 4
- 1: 14
- 2: 42
- Total: 60
- Wily 4:
- 3: 34
- 4: 12
- 5: 24
- 6: 10
- Total: 80
- Total total: 140
- We need 280 bytes to store this information. So this idea of path data banks is NECESSARY.
- If you want to make this system extensible for custom levels, you might want even MORE banks.
- You could try to decouple the Path Number calculation from the stage number, but the data is packed pretty tight there. There's no room to spare
- between the path lengths and the Crashman path data. So you'd want to take this data and push it somewhere else.
- I don't know if sprites have metadata or if it's simply type, X, Y in the level data, but that would be a great place to store path number if possible.
- But without any significant rewrites, we have:
- 7 platforms in consecutive rooms across 2 stages with a maximum of 256 path segments.
- You can cheese the 2-stage limit by making sure the room numbers line up for the non-Wily 4 stages.
- e.g. Bubble has platforms in rooms 1 and 2, Wood has platforms in rooms 3 and 4. But that sounds confusing and stifling.
Advertisement
Add Comment
Please, Sign In to add comment