MM2Random icon indicating copy to clipboard operation
MM2Random copied to clipboard

Leaf shield checks for 3 ammo, regardless of actual consumption

Open warmCabin opened this issue 4 years ago • 3 comments

Example seed: WCABIN (v0.5.0)

In this seed, Leaf Shield consumes 1 ammo, but it can't be used with 2 or less. This is a residual check from the vanilla game, where Leaf Shield takes 3 ammo.

warmCabin avatar Mar 08 '20 02:03 warmCabin

Looks like this check is at 0F:DAF2, or $03DB02 in the ROM file.

>0F:DAF2:A5 9E     LDA $009E = #$0E
 0F:DAF4:E9 03     SBC #$03 ; Need to change this to whatever the actual consumption is
 0F:DAF6:90 10     BCC no_shield_for_you

Just need to add a patch to 0F:DAF5, or $03DB05 in the ROM file.

warmCabin avatar Oct 03 '20 03:10 warmCabin

I see, so there is another value containing the ammo cost that I missed, which is checked against to see if you run out of ammo. Is there a separate address for this for each weapon type? Is 0F:DAF5 only for Leaf Shield?

duckfist avatar Oct 16 '20 22:10 duckfist

Most weapons' energy usages evenly divides 28, with these exceptions:

  • Leaf Shield uses 3
  • Atomic Fire uses 6 and 10

In Rockman 2, it looks like the Atomic Fire check is done at 0F:DD7C:

 0F:DD7C:B9 41 DE  LDA $DE41,Y @ $DE42 = #$01
>0F:DD7F:C5 9C     CMP $009C = #$02

At 0F:D4E2, you can see the sequence 01, 06, 0A, which makes sense.

Some of the even divisors do check if you have enough ammo:

  • Crash Bomber checks if you have at least 4.

Others are prone to an underflow bug if you somehow have less than enough ammo:

  • Air Shooter
  • Item 1

The rest either tick down by 1 or are fractional, so this check is not applicable:

  • Bubble Lead
  • Quick Boomerang
  • Time Stopper
  • Metal Blade
  • Item 2
  • Item 3

warmCabin avatar Oct 30 '20 05:10 warmCabin