| Mega Man 2'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 staff roll lists six character designers, YASUKICHI, INAFKING, TOM PON, NAGINEKO, 2M03CM MAN, and A.K, and names A.K again as its planner. | screen/credit.asm L188–210screen/credit.asm L227–231 | Code |
| Mega Man 2's password is 9 dots on a 5 by 5 grid; the entry screen counts down from 9 as the player places dots with A and takes them back with B, and reads the password when the ninth is placed. | engine/password.asm L105–108engine/password.asm L162–189data/password/password_oam.asm L18–30 | Code |
| Mega Man 2's password holds the E-tank count and, for each of the 8 Robot Masters, whether he is beaten; a dot in the top row's first five cells gives 0-4 E-tanks, and each Robot Master has one "beaten" cell and one "not beaten" cell among the other 20, which also include 4 cells that mean nothing. | data/password/password.asm L1–11constants/flags.asm L30–46engine/show_password.asm L29–60 | Code |
| Mega Man 2 shifts the 20 boss cells by the E-tank count; table entry i goes to cell 5 + (E-tanks + i) mod 20, wrapping from the last cell back to the first cell of the second row, so the same bosses beaten give a different grid for each E-tank count. | engine/show_password.asm L33–57engine/password.asm L202–235 | Code |
| Mega Man 2 reads the E-tank count as the first dot in the top row's first four cells, or 4 if none of them holds one, without looking at the fifth; it then ORs each dotted cell's boss into a beaten byte or a not-beaten byte and accepts the password only if the two together cover all 8 bosses, else it writes PASSWORD ERROR ! and, after two waits of 125 frames, returns to the menu of START and PASSWORD. | engine/password.asm L189–273data/password/strings.asm L1–37 | Code |
| A correct Mega Man 2 password gives Mega Man the weapon of every boss in its beaten byte, Item 1 if Heat Man is beaten, Item 2 if Air Man is, and Item 3 if Flash Man is, plus its E-tank count; the password holds nothing else. | engine/password.asm L275–288constants/flags.asm L30–39 | Code |
lsmmega's disassembly builds this exact ROM; with the iNES header its header.asm writes in place of the NES 2.0 one, the ROM's SHA-1 is the build's. | header.asm L8–19README.md L5 | Verified |
In the standing, walking, running, and landing states, a fresh A press (zjoy1_pressed_bits) copies zjump_speed into Mega Man's vertical speed after the frame's move, so the press frame doesn't lift him. | engine/run_megaman.asm L94–103engine/run_megaman.asm L84–88home/nmi_wait.asm L13–17 | Code |
Mega Man's jump speed is $04.$DF, 4.87 px/frame upward, out of water ($05.$80 in water). | engine/check_object_horizontal_move.asm L181–185engine/tsa.asm L82–85 | Code |
Gravity takes $40/256 = 0.25 px/frame from Mega Man's upward speed each frame out of water ($1E/256 in water). | engine/check_object_horizontal_move.asm L175–176engine/check_object_vertical_move.asm L73–80 | Code |
_check_object_vertical_move first moves Mega Man by his 8.8 fixed-point speed, positive up, and then subtracts gravity. | engine/check_object_vertical_move.asm L12–19engine/check_object_vertical_move.asm L73–80 | Code |
Falling speed is capped at 12 px/frame ($F4). | engine/check_object_vertical_move.asm L81–87 | Code |
In the jumping state, with A not held, _run_megaman_jumping drops an upward speed of 2 px/frame or more to exactly 1 px/frame. | engine/run_megaman.asm L208–219 | Code |
| The release cut tests only the speed's whole byte, so it applies at 2 px/frame or more and leaves a slower rise alone. | engine/run_megaman.asm L211–215 | Code |
_run_megaman_jumping checks the release after the frame's move and gravity, so the capped speed first moves Mega Man on the next frame. | engine/run_megaman.asm L203–210 | Code |
| Gravity brings the 4.87 px/frame take-off under 2 px/frame on frame 13, so letting go of A after 12 frames changes nothing. | engine/run_megaman.asm L208–219 | Verified |
| Measured in the game, Mega Man's jump peaks at 8 px on frame 5 when A is tapped and at 50 px on frame 19 when it is held 12 frames or more, landing on frames 15 and 41. | engine/run_megaman.asm L160–223engine/check_object_vertical_move.asm L1–90 | Verified |
Each airborne frame, _run_megaman_jumping zeroes Mega Man's horizontal speed, then sets it to the jumping state's 1.3125 px/frame ($01.$50) toward a held Left or Right. | engine/run_megaman.asm L160–167engine/run_megaman.asm L197–199engine/turn_megaman.asm L222–246 | Code |
| Measured in the game, Mega Man moves 1.3125 px/frame in the air, turns around on the frame the other direction is pressed, and stops on the frame the d-pad is let go. | engine/run_megaman.asm L160–202engine/turn_megaman.asm L72–77engine/turn_megaman.asm L222–246 | Verified |
| Measured in the game, Mega Man first steps 0.125 px/frame for 7 frames, then runs at 1.375 px/frame. | engine/turn_megaman.asm L222–246 | Verified |
| Mega Man gets no grace window after leaving a ledge; a grounded state that finds no floor switches to the jumping state, which looks for a press only on the frame it lands. | engine/run_megaman.asm L86–92engine/run_megaman.asm L160–242 | Verified |
Mega Man's X is 8.8 fixed point, and his horizontal speed is an 8.8 magnitude that _check_object_horizontal_move adds or subtracts according to the right bit of ztoward. | engine/check_object_horizontal_move.asm L10–31engine/check_object_horizontal_move.asm L74–81 | Code |
Mega Man never accelerates; each frame his state's row of megaman_status_xcoord_speed_table sets the speed outright, 0 standing, 0.125 px/frame on the first step, 1.375 running, 1.3125 jumping, and 0.5 sliding to a stop. | engine/turn_megaman.asm L72–77engine/turn_megaman.asm L222–243engine/run_megaman.asm L401–412 | Code |
| A held direction moves standing Mega Man into the first-step state on the same frame; the step becomes a run when its animation reaches frame 1, a released run becomes a slide, and the slide stops at its animation's frame 2 or restarts the first step if a direction is pressed. | engine/run_megaman.asm L74–88engine/run_megaman.asm L109–133engine/run_megaman.asm L150–155engine/run_megaman.asm L244–267 | Code |
_turn_megaman faces Mega Man toward a held Left or Right at the start of every moving state's frame, and the move direction follows the facing that same frame, so he reverses at full speed with no skid. | engine/turn_megaman.asm L56–70engine/turn_megaman.asm L213–216 | Verified |
| Measured from a standstill in Heat Man's stage, Mega Man's first step lasts 7 frames, and a released run slides 8 frames at 0.5 px/frame, 4 px in all, before he stands. | engine/run_megaman.asm L125–129engine/run_megaman.asm L258–262engine/turn_megaman.asm L222–246engine/run_megaman.asm L401–410engine/run_megaman.asm L244–248engine/run_megaman.asm L150–155 | Verified |
Down changes nothing on open ground; of the walking states only _check_shoot_on_ladder reads Up and Down, and only when a ladder is at hand. | engine/turn_megaman.asm L13–22 | Verified |
| The jump check runs after the frame's move, so the press frame moves at the ground state's speed, and from the next frame the jumping state's 1.3125 px/frame (or nothing, with no direction held) replaces any run. | engine/run_megaman.asm L135–142engine/run_megaman.asm L94–103 | Verified |
| Mega Man lands into the running state if Left or Right was held on the frame before landing, at 1.375 px/frame from the next frame with no first step, and into the landing-stop state otherwise. | engine/run_megaman.asm L225–238home/nmi_wait.asm L1–3 | Verified |
| 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 at 12 px and 4 px above and 11 px below it. | engine/check_object_vertical_move.asm L47–56engine/check_object_vertical_move.asm L92–100engine/check_object_vertical_move.asm L212–213engine/check_object_horizontal_move.asm L32–35engine/check_object_horizontal_move.asm L198–199 | Code |
_tsa_collision turns a test point into a tile: X / 32 and Y / 32 pick a 32 px block of the stage map, bit 4 of X and of Y pick one of its four 16 px tiles, and the tile's top two bits give its kind, background, block, or one of a per-stage pair such as ladder and spike. | home/tsa_collision.asm L16–29home/tsa_collision.asm L49–70constants/tsa.asm L1–11engine/check_object_vertical_move.asm L188–190 | Code |
| Each of Mega Man's grounded and jumping states moves him horizontally first, testing for a wall, then vertically, testing the floor under a fall or the ceiling over a rise, and only then changes state or checks for a jump, so a frame's floor test uses that frame's new X. | engine/run_megaman.asm L135–142engine/run_megaman.asm L201–205engine/check_object_vertical_move.asm L45–56 | Code |
| On the ground Mega Man keeps a vertical speed of −0.25 px/frame, the gravity applied after each landing's reset, so every grounded frame's vertical move takes him 0.25 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 sends him to the jumping state. | engine/check_object_vertical_move.asm L92–109engine/check_object_vertical_move.asm L68–80engine/run_megaman.asm L84–90 | 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 state's speed, drops him 0.25 px, and leaves him in the jumping state falling at 0.5 px/frame, so his feet are 0, 0, 1, 2, 3, 5, and 7 px below the ledge on the walk-off frame and the six after. | engine/run_megaman.asm L139–148engine/check_object_vertical_move.asm L100–105 | Verified |
When the horizontal move puts the wall point ahead in a solid tile, _check_object_horizontal_move zeroes Mega Man's X fraction and pushes him back by the point's depth into the tile, so x + 8 ends on the wall's first column moving right and x − 8 on the first column past it moving left; his speed and state are untouched, so he runs in place. | engine/check_object_horizontal_move.asm L39–53engine/check_object_horizontal_move.asm L92–102engine/check_object_horizontal_move.asm L187–196 | Verified |
When a falling Mega Man's floor points find a block, _check_object_vertical_move subtracts (Y + 12) mod 16 from his Y, which puts his feet on that 16 px tile's top, zeroes the Y fraction and the vertical speed, then takes one step of gravity from the speed; so a fall of up to 12 px a frame always ends on the top of the tile it meets. | engine/check_object_vertical_move.asm L107–122 | Verified |
A pit has no floor of its own; once Mega Man's Y passes $E8 on the screen, _check_object_vertical_move asks for a downward scroll, and _check_scroll kills him where the stage doesn't scroll down. | engine/check_object_vertical_move.asm L37–43engine/check_scroll.asm L37–43 | Code |
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, _check_object_vertical_move zeroes his Y fraction and adds 16 − ((Y − 12) mod 16) to Y, which puts that point on the first row under the block's 16 px tile, then zeroes his speed and takes one step of gravity from it; he stays in the jumping state and falls from the next frame, starting at 0.25 px/frame. | engine/check_object_vertical_move.asm L47–71engine/check_object_vertical_move.asm L129–142engine/check_object_vertical_move.asm L212–213engine/run_megaman.asm L205–223 | Verified |
| No grounded state tests the ceiling, since each grounded frame leaves Mega Man's vertical speed at −0.25 px/frame (ground-check) and the vertical move tests only the floor at a negative speed; the jump press then sets the jump speed and the jumping state without a test, so a jump always starts under a ceiling, and the rise first meets it on a later frame. | engine/check_object_vertical_move.asm L68–80engine/check_object_vertical_move.asm L47–48engine/run_megaman.asm L84–88engine/run_megaman.asm L94–103 | Verified |
| Under a block 32 px above the floor, 8 px over his head, a standing jump meets the block on its second rising frame and lands on frame 11, with his feet 0, 5, 8, 8, 8, 7, 6, 5, 3, 1, and 0 px up on frames 1-11. | engine/check_object_vertical_move.asm L57–66 | Verified |
Mega Man 3 raises the take-off speed from Mega Man 2's $04.$DF (4.87 px/frame) to $04.$E5 (4.89) and keeps gravity at $40, but caps a fall at 7 px/frame ($F9) where Mega Man 2 allows 12 ($F4). | engine/check_object_horizontal_move.asm L175–185engine/check_object_vertical_move.asm L81–87 | Code |
On every rising frame without A held, Mega Man 3 sets the vertical speed to $FF.$C0, 0.25 px/frame downward, whatever the speed was, before the frame's move. Mega Man 2 only lowers a rise of 2 px/frame or more to 1, after the move. | engine/run_megaman.asm L208–219 | Code |
Mega Man 3 drops Mega Man 2's slow step speed but keeps a pause. Before each frame's state runs, the prelude sets the speed to $01.$4C (1.30 px/frame) unless he is sliding. From standing, a held direction moves him by it at once and starts the turning animation ($0D); while that animation is on its first frame the ground state doesn't move him, and once it advances he walks at the same 1.30. In the air a held direction moves him at 1.30 on every frame. | engine/turn_megaman.asm L222–243 | Code |
Mega Man 3 starts the invincibility after the knockback: when the hurt state ends it sets invincibility_timer to 60 ($3C), which the prelude counts down every frame. Mega Man 2 sets 111 at the moment of the hit. | home/megaman_hit.asm L11–12 | Code |
Mega Man 3 moves weapon costs into two tables indexed by weapon: weapon_cost, the units taken, and weapon_framerate, how many uses (or frames, for Rush Marine and Rush Jet) each take costs, counted on one shared counter. Needle Cannon costs 1 unit per 4 shots and Gemini Laser 2 per shot. Mega Man 2 writes the costs into the weapons' own routines, as its Air Shooter, Crash Bomber, and Metal Blade code shows. | home/weapons.asm L95–97home/weapons.asm L212–215home/weapons.asm L244–250 | Code |
Mega Man 3 indexes each weapon's 256-byte damage table by the target's main routine id, one table for regular enemies and bosses alike, where Mega Man 2 gives each weapon a separate 14-entry boss table. In the Spark Shock table the entry for routine id $C1 is 7, and $58 marks targets the shock freezes instead of damaging. That $C1 is Magnet Man is the disassembly's labeling, not checked here. | engine/weapons_bosses_damage.asm L388–392 | Code |
| Mega Man 3's ordinary-floor movement differs from Mega Man 2's from the first frame of a walk: Right held from a standstill moves him 1.30 px, then nothing for 5 frames, then 1.30 px a frame, where Mega Man 2 moves 0.125 px a frame for 7 frames, then 1.375. A jump differs from its press frame, which lifts him 4.89 px where Mega Man 2 lifts him 0. Letting go of A mid-rise starts the fall at once, where Mega Man 2 cuts a rise of 2 px/frame or more to 1, and falls cap at 7 px/frame instead of 12. He keeps Mega Man 2's gravity, floor and ceiling corners, and 16 px tiles, and adds the slide. | engine/run_megaman.asm L208–219engine/run_megaman.asm L84–88engine/check_object_vertical_move.asm L81–87 | Code |
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 L222–229audio/engine.asm L66–71audio/engine.asm L386–391audio/engine.asm L1–397 | 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 L866–888audio/engine.asm L399–949 | 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 L951–1152 | 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 L1154–1621 | 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 L1623–1743 | 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–22ram/ram.asm L35–39 | 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–14 | 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 L103–240home/scrolling.asm L161–168home/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–73 | 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–111 | 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–45 | 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/main.asm L110–248 | 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/metalman/metalman_mapset.asm L241–439 | 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. | miscellaneous.asm L49–52 | 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. | miscellaneous.asm L30 | 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. | miscellaneous.asm L31 | Code |
Mega Man 3's divide_8bit is Mega Man 2's _divide_mod with its zero-page operands one byte lower ($00-$03 for $01-$04). Its 16-bit division is Mega Man 2's _divide_fraction with its RAM moved and two changes: Mega Man 3 saves and restores X around the loop, and stores the low byte of each successful subtraction back in the remainder ($01), where Mega Man 2 writes it to $09, outside its shift chain. | home/divide.asm L1–69 | Code |
| Doc Robot's Air Man fight in Mega Man 3 uses Air Man's tornado tables from Mega Man 2 byte for byte (155 bytes): the five delays between rounds, then five patterns of six tornadoes each, with their Y and X speeds (whole and fraction) and how long each flies. | engine/bosses_ai.asm L522–558 | Code |
Mega Man 3's sprite CHR banks $00-$01, mapped at sprite tiles $00-$7F throughout play, start from Mega Man 2's first 128 sprite tiles (the disassembly's megaman_capsule_e_tank_bullet_mega_buster.chr): 84 of the 127 non-blank tiles are the same at the same numbers, the longest run tiles $20-$37 (384 bytes). | stages.asm L11 | Code |
| The first 32 tiles of 17 of Mega Man 3's sprite CHR banks ($08, $0A, $0C, $0F, $11, $13, $15, $1D, $20, $24, $26, $27, $2A, $2C, $2E, $32, and $3C) are Mega Man 2's sprite tiles $60-$7F, from the same set as Mega Man's own: 29 of the 32 are the same at the same numbers, the longest run tiles $0B-$1F (336 bytes). | stages.asm L11 | Code |
Mega Man 3's title screen background tiles (CHR banks $76-$77) are largely Mega Man 2's title set (title.chr, loaded at _load_title_chr), moved a few tile numbers: 102 of their 128 non-blank tiles appear in it, 96 different ones, in runs of up to 16 tiles (256 bytes). | miscellaneous.asm L51–52 | Code |
Mega Man 3's background CHR bank $66, mapped for Wily stage 6, holds 27 of the 31 non-blank tiles of Mega Man 2's third font set (the disassembly's font_3.chr), the longest aligned run 10 tiles (160 bytes). | miscellaneous.asm L48 | Code |
Mega Man 3's sprite CHR bank $3C holds 13 of the 23 non-blank tiles of Mega Man 2's set of Dr. Wily bowing down (the disassembly's dogeza.chr), six of them in a run (96 bytes). | miscellaneous.asm L24 | Code |
| Mega Man 3's sprite CHR bank $22 holds 17 tiles of Mega Man 2's boss sets, 9 from Wood Man's and 8 from Heat Man's, and bank $21 holds 4 of Crash Man's; the longest run is 9 of Wood Man's tiles (144 bytes). | stages.asm L196–200stages.asm L177 | Code |
Mega Man 3's check_new_enemies is the enemy half of Mega Man 2's _find_objects, instruction for instruction, with new RAM and table addresses: both take the screen's left and right edges, then on the side the screen moves toward spawn each placement that comes into range and on the other side move a second cursor past placements left behind. Mega Man 3 drops Mega Man 2's matching walk over a separate item list and the switch to the stage bank around it. The spawn routine each calls starts the same way, skipping a placement already in a slot and taking a free one, and then differs: Mega Man 2 fills the slot from per-type tables in its fixed bank, and Mega Man 3 skips a placement marked defeated and copies the type's properties from bank 0. | home/find_objects.asm L1–54home/find_objects.asm L97–131home/find_objects.asm L55–96home/find_objects.asm L174–200 | Code |
| Both games run their sound driver from the NMI, but Mega Man 3's is new code with a new layout. Mega Man 2 keeps the driver and its songs together in bank 12, queues up to 16 tracks, and works out a note's length as a table value times its channel's tempo byte. Mega Man 3 keeps the code in bank 22 and the data in bank 23, reading bank 24 for data addresses from $C000; it takes sound IDs from an eight-entry ring buffer in the fixed bank, and refuses a sound whose priority byte is lower than the one playing. | home/track_queue.asm L1–9audio/engine.asm L1598–1622 | Code |
Both games strobe the controllers and merge each port's two data bits, but Mega Man 3's routine is new code. Mega Man 2's _joy reads one pad after the other and leaves the newly pressed buttons to the frame wait that calls it; Mega Man 3's read_controllers reads both pads in one loop, works out the new presses itself, and clears the d-pad when opposite directions are held together. | home/joy.asm L1–22home/nmi_wait.asm L1–24 | Code |
| Both games flag a bank switch in progress and catch up on the frame's sound afterward if the NMI arrived during it, but Mega Man 3's switch is new code for a different board: Mega Man 2 maps one 16 KB bank at $8000 by writing its number to MMC1 one bit at a time, and Mega Man 3 writes two 8 KB banks, at $8000 and $A000, to the MMC3 as whole bytes. | home/bankswitch.asm L1–45 | Code |
| Both games' NMI handlers copy the sprites by DMA, write the queued screen and palette updates, set the scroll, and run the sound driver, but Mega Man 3's handler is new code. Mega Man 2's offsets the scroll for the Mecha Dragon and puts the sound off when the NMI interrupts a bank switch; Mega Man 3's also loads the MMC3's scanline counter for the frame's split-screen interrupt and picks the interrupt handler for the screen mode. | home/nmi.asm L1–134 | Code |
Both games run a stage a frame at a time in step with the NMI, but Mega Man 3's frame loop is new code built on a task scheduler. Mega Man 2's stage loop calls its routines in turn and then spins in _nmi_wait_0e until the NMI sets a flag, reading the pads after it. Mega Man 3 runs up to four tasks, each resumed from its own saved stack pointer; gameplay_frame_loop gives up the CPU for a frame through the scheduler, which reads the controllers only when it resumes task 0. | home/nmi_wait.asm L1–24engine/main.asm L210–248 | Code |
Both games move an object each frame by a speed with a fraction and change its Y speed by gravity, but Mega Man 3's movers are new code that Mega Man and the enemies share. Mega Man 2's enemy routine, left undecoded by its disassembly, checks the object's hits, moves it by its Y speed, subtracts gravity from that speed when a flag bit asks for it, moves it by its X speed in the way it faces, and removes it once it leaves the screen; walls and floors are a separate routine, and Mega Man moves with his own code. Mega Man 3's move_vertical_gravity and move_right_collide serve slot 0, the player, and every enemy alike, and run the tile check inside each move, snapping the object to the floor, ceiling, or wall it reaches. | home.asm L84–89engine/check_object_horizontal_move.asm L1–202 | Code |
Both games find the 32-pixel block at a point in the screen's layout and then its 16-pixel quarter, but Mega Man 3's tile check is new code with a new type format. Mega Man 2's _tsa_collision tests one point a call and takes its type from the quarter byte's top two bits, which a per-stage table remaps; Mega Man 3's check_tile_collision tests a list of points from a hitbox table in one call, clamps them to the screen, takes each type from the upper four bits of the tile's entry in a table at $BF00 in the stage bank, and ORs the types together. | home/tsa_collision.asm L1–141 | Code |
Both games' stage selects move a cursor over the bosses' portraits and start the chosen stage, but Mega Man 3's is new code. Mega Man 2's _stage_select blanks a beaten boss's portrait by writing empty tiles to the name table, and on a d-pad press calls _stage_select_set to move the cursor; Mega Man 3 keeps the cursor's column and row apart, moves each by a table offset and ignores a move off its 3 by 3 grid, redraws the six sprites of Mega Man's eyes in the center portrait for the cursor's position, and confirms on A as well as Start. | engine/stage_select.asm L1–100 | 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/check_object_horizontal_move.asm L175–185engine/check_object_vertical_move.asm L81–82engine/run_megaman.asm L208–217engine/turn_megaman.asm L222–243 | 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. | home/megaman_hit.asm L11–20 | Code |
| 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 L125–129engine/run_megaman.asm L258–262engine/run_megaman.asm L94–103engine/run_megaman.asm L230–237engine/run_megaman.asm L160–167engine/check_object_vertical_move.asm L68–80engine/check_object_horizontal_move.asm L39–43 | Verified |
On even frames _sprites writes Mega Man's object slots (0 to $0F), then the enemies' ($10 to $1F), then the energy meters; on odd frames it writes the meters first and the slots in reverse, $1F down to $10, then $0F down to 0, so objects that lose the 8-per-scanline race lose it only every other frame. | home/sprites.asm L12–38home/sprites.asm L43–62 | Code |
Mega Man 2 draws its energy meters as sprites, not a split screen; each meter is a column of 7 sprites from Y $18 down to $48, each showing 0-4 units, at X $10 for the weapon, $18 for life, and $28 for a boss. | home/sprites.asm L473–476home/sprites.asm L530–545home/sprites.asm L572–579 | Code |
Once a frame _background_palette counts up to a stage's frame byte and then copies the next 16-byte background palette set into the working palette, wrapping after the stage's set count; Heat Man's stage has 3 sets and a frame byte of 6, so its palette 3 rotates $36, $26, $16 one step every 7 frames. | home/background_palette.asm L1–32home/nmi_wait.asm L1–12stages/heatman_wily1/heatman_wily1_palette_init.asm L1–34constants/palettes.asm L1–55 | Code |
A hit sets zmegaman_invincibility_time to 111 ($6F); contact damage is skipped while it is nonzero, and it counts down by 1 each time Mega Man's sprite is processed, hiding him on alternate pairs of frames. | home/megaman_hit.asm L11–12home/object_hit.asm L34–35home/sprites.asm L277–289 | Code |
_megaman_hit sets Mega Man's upward speed to 1.25 px/frame ($01.$40) and his horizontal speed to 0.5625 ($90) once; the hit state then moves him against his facing under the usual gravity until his animation's upper timer returns to 0, and leaves to the jumping or standing state. | home/megaman_hit.asm L5–20engine/run_megaman.asm L52–72 | Code |
Each weapon has its own energy byte, filled to 28 ($1C) before a Robot Master stage or the first Wily stage but not before the later Wily stages; each weapon's routine takes its own cost, such as 2 per Air Shooter shot, 4 per Crash Bomber, and 1 per 4 Metal Blades counted on a shared counter. | engine/main.asm L73–89home/weapons.asm L94–97home/weapons.asm L205–215home/weapons.asm L240–250 | Code |
Each weapon has a 14-byte table with one damage value per boss, in the order of zcurrent_boss: 0 makes the boss immune, a negative value refills its health, and other values are subtracted, doubled when zdifficulty is 0. Metal Blade's byte for Metal Man is 14 ($0E), so 14 damage, or 28 when doubled, and 0 for Air Man and Quick Man; the Mega Buster's bytes for the Robot Masters are 1 or 2; Atomic Fire refills Heat Man. | data/weapons_bosses_damage_table.asm L1–9data/weapons_bosses_damage_table.asm L113–121engine/weapons_bosses_damage.asm L388–399engine/weapons_bosses_damage.asm L452–458engine/weapons_bosses_damage.asm L60–64 | Code |
| Mega Man 2 has no slide. A fresh A press in a grounded state always starts a jump; that code tests no other button. | engine/run_megaman.asm L94–103 | Code |
| Mega Man 2's Mega Buster has no charge. It fires only on the frame B goes down, with a free shot slot. | home/weapons.asm L20–30 | Code |