| Mega Man's cartridge ROM, counted by part of the game: each stretch of code or data goes to the part the disassembly's labels and comments say it serves, and the value sums the bytes of each part. | main.asm | Code notes |
Mega Man 2's sound engine entry and channel setup are Mega Man's, with two changes: _music_fade_in_out no longer ignores a new fade while one is running, and where Mega Man steps X with INX, four operands use an address plus 1 instead and one writes SQ1_SWEEP plus X. The engine starts at $8000 instead of $9000, so its jump and call addresses differ too. | audio/engine.asm L223–234audio/engine.asm L66–72audio/engine.asm L394–401audio/engine.asm L1–407 | Code |
Mega Man 2's per-frame channel update is Mega Man's, except that _break_frame and the end of _pitch_envelope_common address the next APU register as SQ1_SWEEP plus X, where Mega Man steps X with INX and writes SQ1_VOL plus X. The code sits $100A lower, so its jump and call addresses differ too. | audio/engine.asm L876–900audio/engine.asm L409–961 | Code |
| Mega Man 2's sound effect reader is Mega Man's, instruction for instruction and with the same RAM, moved $100C lower: only its jump and call addresses and the addresses in its command table differ. | audio/engine.asm L963–1164 | Code |
| Mega Man 2's song data reader is Mega Man's, instruction for instruction and with the same RAM, so the two games read the same note and command format. It sits $100C lower: only its jump and call addresses, its command table, and the address of the note table differ. | audio/engine.asm L1166–1633 | Code |
Mega Man 2's note length and pitch tables are Mega Man's but for one pitch: the period of the note the disassembly names nEb1 drops from $059E to $0594, about 12 cents higher (computed). The region also ends with 3 bytes of $FF filler instead of 7. | constants/audio.asm L117audio/engine.asm L1635–1755 | Code |
Mega Man 2's _joy is Mega Man's, line for line; only the two button bytes it writes moved in zero page, from $14 and $18 to $23 and $27. | home/joy.asm L1–22 | Code |
Mega Man 2's _object_tiles_update is the loop Mega Man enters at _init_object_tiles, which copies the tile buffer to CHR RAM, with its RAM at new addresses. Mega Man 2 drops the test in front of it and the _object_tiles_update_yellow_devil path, which writes two bytes at each of several PPU addresses, a row ($20) apart. | home/object_tiles.asm L1–54 | Code |
Mega Man 2's _scrolling_vertical follows Mega Man's _scrolling_up_down: the same name table and attribute address math and the same loop writing four 8x8 tiles per 16x16 quarter. Mega Man 2 computes the 32x32 block's address from the screen number, where Mega Man looks the screen up in a pointer table and checks _special_blockset_collision for a block the disassembly labels removed; some of its RAM moved too. The rest of each region is different code. | home/scrolling.asm L93–278home/scrolling.asm L152–186home/scrolling.asm L1–3 | Code |
Mega Man 2's _nmi_wait_0e and _nmi_wait_0d keep the steps of Mega Man's _nmi_wait: save the last buttons, wait for the NMI, call _joy, and mark the newly pressed buttons. The two differ only in the bank they map at the end, and each first calls _background_palette. Mega Man 2 drops the path for buttons the game forces and moves the water frame into _nmi_wait_water. | home/nmi_wait.asm L1–46 | Code |
Mega Man 2's death explosion takes its twelve pieces' x and y speeds and facing flags from five 12-byte tables identical to Mega Man's explosion tables. The code around them is new: Mega Man's _create_explosion_object sets up one piece per call, and Mega Man 2's _create_explosion loops over all twelve. | home/create_explosion.asm L1–100 | Code |
Both games' bank switch routines map a PRG bank at $8000, but Mega Man 2's is new code for a different board: Mega Man writes the bank number once, to its own byte of a bank table (the disassembly's uxrom_prg_bank), and Mega Man 2 writes it to MMC1 one bit at a time, then runs any sound an NMI put off during the switch. | home/bankswitch.asm L1–25 | Code |
| Both games' stage loops run a frame of play and wait for the NMI, but Mega Man 2's is new code: it calls its own routines in its own order, opens the menu on Start with no Select pause, and waits an extra frame now and then in water. Its region also starts the stage before the loop. | engine/stage_loop.asm L1–99 | Code |
| The last 16 screens of Metal Man's map, $1C to $2B (1,024 bytes), are byte for byte the last 16 of Mega Man's Cut Man and Wily stage 1 map: Cut Man's screens $0C to $0F and Wily stage 1's $10 to $1B. Metal Man's screens $18 to $1B repeat four of them, Wily stage 1's $18 to $1B. | stages/cutman_wily1/cutman_wily1_mapset.asm L161–319stages/cutman_wily1/cutman_wily1_screen_id.asm L1–45 | Code |
| Tiles 1 to 84 of Mega Man 2's title screen patterns (1,344 bytes) are byte for byte tiles 1 to 84 of Mega Man's. | stages.asm L157 | Code |
| Mega Man 2's six menu border tiles, the end of its common stage tiles, are Mega Man's six menu tiles, byte for byte. | stages.asm L20–21 | Code |
| Mega Man 2's five READY letter tiles have Mega Man's letter shapes, row for row, but in each tile's second bit plane instead of its first, so the letters draw in color 2 of their palette where Mega Man's draw in color 1. | stages.asm L21 | Code |
A fresh A press on the ground sets Mega Man's upward speed to $04.$DF, 4.87 px/frame. | engine/run_megaman.asm L157–162engine/run_megaman.asm L216–221 | Code |
Each airborne frame takes $40/256 = 0.25 px/frame off Mega Man's upward speed, and a fall is capped at 12 px/frame ($F4). | engine/objects_vertical.asm L96–110 | Code |
| On every rising frame with A not held, Mega Man's upward speed, if its whole part is 2 or more, drops to exactly 1 px/frame; the test follows the frame's vertical move. | engine/run_megaman.asm L88–109 | Code |
Off ice, Mega Man never accelerates. Each frame his animation picks a speed from special_object_xcoord_speed_table, 0 standing, 0.125 px/frame on the first step, 1.375 running, 0.5 sliding to a stop, 0 landing, and 0.5625 when hit; any other animation, such as the jump, moves at 1.3125 with a direction held and 0 without. | engine/ice_tsa.asm L1–22engine/ice_tsa.asm L146–166data/special_xcoord_speed_table.asm L1–12home/write_special_object_xcoord_speed.asm L22–29 | Code |
A hit sets zmegaman_invincibility_time to 111 ($6F); while it is nonzero no contact damages Mega Man, and the stage loop counts it down by 1 on each pass that runs the enemies. | engine/check_megaman_damaged.asm L123–131engine/check_megaman_damaged.asm L18–19engine/stage_loop.asm L41–52 | Code |
A hit faces Mega Man against the enemy's facing and puts him in the hit animation ($12), which sets his upward speed to 1.25 px/frame ($01.$40) once and pushes him backward, against his own facing, at 0.5625 px/frame ($90) under the usual gravity until the animation ends. | engine/check_megaman_damaged.asm L124–128engine/handle_special_megaman_objects.asm L1–64engine/ice_tsa.asm L151–163data/special_xcoord_speed_table.asm L12 | Code |
Mega Man 2 keeps Mega Man's jump and running numbers. Both take off at $04.$DF, subtract $40 of gravity a frame, cap a fall at $F4, cut a rise of 2 px/frame or more to 1 when A is up, and move at 0.125, 1.375, and 1.3125 px/frame stepping, running, and in the air. | engine/run_megaman.asm L216–221engine/objects_vertical.asm L97–103engine/run_megaman.asm L100–107data/special_xcoord_speed_table.asm L4–11 | Code |
Mega Man 2 keeps Mega Man's hit numbers too, 111 frames of invincibility ($6F) and a knockback of 1.25 px/frame up and 0.5625 back. | engine/check_megaman_damaged.asm L129–130engine/handle_special_megaman_objects.asm L64data/special_xcoord_speed_table.asm L12 | Code |
_objects_vertical_moving first moves Mega Man by his 8.8 fixed-point vertical speed, positive up (his Y, which runs down the screen, subtracts it), and then, on a frame that meets no floor or ceiling, takes gravity off the speed. | engine/objects_vertical.asm L131–138engine/objects_vertical.asm L96–118 | Code |
Mega Man's fall is capped at 12 px/frame ($F4). | engine/objects_vertical.asm L100–110 | Code |
| Mega Man's position is his center; the floor and ceiling are tested at x − 7 and x + 7, 12 px below or above it, and walls at x + 8 or x − 8, toward his facing, at 12 px and 4 px above and 11 px below it. Every animation he has on foot or in the air uses these offsets. | engine/objects_vertical.asm L26–45home/tsa_blockset.asm L116–143home/tsa_blockset.asm L1–24engine/objects_toward.asm L44–66home/object_collision_coord.asm L1–2home/object_collision_coord.asm L211–212 | Code |
_check_special_blockset_or_tsa_collision turns a test point into a tile: X / 32 and Y / 32 pick a 32 px block of the screen's map, bit 4 of Y and of X pick one of its four 16 px tiles, and the tile's top two bits give its kind through a per-stage table: background, block, and two of ladder, spike, ice, and water. | home/tsa_blockset.asm L216–265home/tsa_blockset.asm L288–290 | Code |
Each frame on foot or in the air, _run_megaman_on_stage moves Mega Man horizontally first, testing for a wall, then vertically, testing the floor under a fall or the ceiling over a rise, and only then checks for a jump or lands, runs, slides, or stands, so a frame's floor test uses that frame's new X. The one change made before the move is a Left or Right pressed fresh, which sets the first step's animation (ground-states). | engine/run_megaman.asm L67–96engine/objects_screen.asm L48–55 | Code |
Every frame that finds a floor under him sets Mega Man's vertical speed to $FF.$40, −0.75 px/frame, with no gravity after it, so each grounded frame's vertical move takes him 0.75 px down and tests x − 7 and x + 7 on the row under his feet; ground there puts him back on it with the Y fraction zeroed, and none starts a fall. | engine/objects_vertical.asm L65–86engine/run_megaman.asm L87–89 | Verified |
When a falling Mega Man's floor points find a block, _objects_vertical_moving sets his Y to the top of that 16 px tile less 12, which puts his feet on it, zeroes the Y fraction, and sets the speed to −0.75 px/frame (ground-check); so a fall of up to 12 px a frame always ends on the top of the tile it meets. | engine/objects_vertical.asm L65–78 | Verified |
| Mega Man first counts as airborne on the frame whose move takes both floor points off the ledge; that frame still moves him at the ground animation's speed, drops him 0.75 px, and leaves him falling at 1 px/frame in the jumping animation, so his feet are 0, 1, 3, 4, 6, 8, and 10 px below the ledge on the walk-off frame and the six after. | engine/run_megaman.asm L114–125engine/objects_vertical.asm L96–110engine/run_megaman.asm L223–227 | Verified |
Mega Man gets no grace window after leaving a ledge; _run_megaman_on_stage reads a fresh A press only on the branch where the frame's fall test found ground, either the map's floor or an object he stands on (_no_damage_collision). | engine/run_megaman.asm L114–125engine/run_megaman.asm L157–162 | Verified |
When the horizontal move puts the wall point ahead in a solid tile, _objects_rightward or _objects_leftward puts x + 8 on that tile's first column moving right, or x − 8 on the first column past it moving left, and keeps the X fraction of the move; his speed and animation are untouched, so he runs in place. | engine/objects_toward.asm L66–77engine/objects_toward.asm L147–162engine/objects_screen.asm L54–55 | Verified |
When a rising Mega Man's move puts a ceiling point, x − 7 or x + 7 at 12 px above his center, in a block, _objects_vertical_moving puts that point on the first row under the block's 16 px tile, zeroes the Y fraction, and sets his speed to −0.75 px/frame, the speed a landing gets; _run_megaman_on_stage then returns before the release test and before setting the jumping animation, and he falls from the next frame. Measured in Mesen at the start of Bomb Man's stage, under 16 px blocks that the probe adds to the stage's collision. | engine/objects_vertical.asm L41–63engine/run_megaman.asm L88–98 | Verified |
| No grounded frame tests the ceiling, since Mega Man's vertical speed on the ground is −0.75 px/frame (ground-check) and the vertical move tests only the floor at a negative speed; the jump press then sets the jump speed without testing the ceiling, so a press under a block still starts the jump, and the rise meets the block on a later frame. Measured in Mesen at the start of Bomb Man's stage, under a 16 px block the probe adds to the stage's collision. | engine/objects_vertical.asm L39–40engine/run_megaman.asm L216–221 | Verified |
Mega Man's animation is his state. A Left or Right pressed fresh, with neither held the frame before, starts the first step ($03) with its timer at 0, on the ground or in the air; each frame on the ground after the move, a held direction turns the step into the run ($06) once its timer reads $22, and lands a jump running; a direction let go turns a run into the slide to a stop ($0C, timer 1) and anything else into standing; with no direction this frame or the last, a jump lands into the landing animation ($0F, timer 1), and the slide and the landing end in standing when their timer wraps to 0. | engine/run_megaman.asm L50–65engine/run_megaman.asm L163–214home/nmi_wait.asm L1–5 | Code |
After Mega Man's frame, _object_frameset_timer advances his animation's timer from the frameset's first byte: the low nibble counts up to the byte's low nibble, then the high nibble moves to the next animation frame or wraps to 0 after the last. The first step shows 3 frames for 3 frames each; the press frame sets its timer to 0 and the ground check reads it before that frame's advance, so the check first finds $22 on the step's 9th frame; the slide shows 2 frames for 7 each (8 in the shooting pose), and the landing 2 frames for 2 each. | home/sprites.asm L292–324sprites/oam_frameset.asm L1–7sprites/oam_frameset.asm L26–30sprites/oam_frameset.asm L47–51sprites/oam_frameset.asm L68–72sprites/oam_frameset.asm L89–97sprites/oam_frameset.asm L110–114engine/stage_loop.asm L29–58 | Code |
| Measured from a standstill at the start of Bomb Man's stage, Mega Man's first step lasts 9 frames at 0.125 px/frame, and a released run slides 13 frames at 0.5 px/frame, 6.5 px in all, before he stands; a jump landed with nothing held shows the landing animation for 3 frames. | engine/run_megaman.asm L199–214home/sprites.asm L292–324 | Verified |
A buster shot sets aobject_timer to $1F, which shows Mega Man's shooting animations for 15 frames, counting the press frame; their framesets time the slide to a stop at 8 frames per animation frame instead of 7, so a shot fired shortly before or during the slide lengthens it. A Left or Right pressed fresh clears the pose. | engine/weapons.asm L633–652home/sprites.asm L49–55home/sprites.asm L103–114sprites/oam_frameset.asm L96–97engine/run_megaman.asm L56–60 | Code |
Each frame _change_direction faces Mega Man toward a held Left or Right before his speed is looked up and he moves, so he reverses at full speed with no skid; a reversal from one held direction to the other isn't a fresh press, so a run stays a run. | engine/change_direction.asm L1–10engine/run_megaman.asm L62–72 | Verified |
| A jump press returns before the animation changes, and the jumping animation is set only after the next frame's move, so the press frame and the one after both move at the ground animation's speed (two frames of 1.375 px/frame from a run, of 0.125 from a first step, and none from standing still); from the third frame the air speed applies. | engine/run_megaman.asm L216–227engine/run_megaman.asm L87–95 | Verified |
In the air the jumping animation isn't in the speed lookup's table, so each frame sets Mega Man's speed to 1.3125 px/frame ($01.$50) toward a held Left or Right and to 0 with neither; a direction pressed fresh in the air first sets the first step's animation, so that one frame moves 0.125 px/frame. | engine/ice_tsa.asm L1–14engine/run_megaman.asm L53–59 | Verified |
| Mega Man lands running, at 1.375 px/frame from the next frame with no first step, only if Left or Right is held on the landing frame itself; with the direction let go on that frame he lands standing, and with nothing held then or the frame before he lands into the landing animation, which moves no faster than standing. A direction pressed fresh on the landing frame starts the first step. | engine/run_megaman.asm L163–176engine/run_megaman.asm L199–211 | Verified |
Down changes nothing on open ground; _megaman_on_stage reads Up and Down only when a ladder tile is at hand. | engine/run_megaman.asm L19–30 | Verified |
| Mega Man's ordinary-floor movement differs from Mega Man 2's, measured in Mesen at the start of Bomb Man's stage and of Heat Man's. The first difference: holding Right from a standstill, Mega Man is still in his first step on the 8th frame, moving 0.125 px, where Mega Man 2 runs at 1.375. After it: a slide of 13 frames, not 8; two frames at the ground speed after a jump press, not one; a landing that runs only with a direction held on the landing frame, not the frame before; 0.125 px/frame on a fresh press in mid-air; −0.75 px/frame on the ground, not −0.25, so a walk-off and a ceiling hit fall faster; and a wall push that keeps the X fraction. | engine/run_megaman.asm L203–207sprites/oam_frameset.asm L89–90engine/run_megaman.asm L216–227engine/run_megaman.asm L163–165engine/run_megaman.asm L53–59engine/objects_vertical.asm L80–84engine/objects_screen.asm L54–55 | Verified |