warmCabin

mm2 snap to ladder routine

Aug 15th, 2021 (edited)
1,607
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -:
  2.  0E:87AE: 60        RTS ----------------------
  3. snap_to_ladder:
  4. ; Return if neither up nor down are pressed
  5.  0E:87AF: A5 23     LDA p1_buttons_held
  6.  0E:87B1: 29 30     AND #$30
  7.  0E:87B3: F0 F9     BEQ -
  8. ; Certain flag/button combos mean we can return early.
  9. ; Not quite sure what they mean yet.
  10. ; $11 = pressing up and atop ladder.
  11. ;  But if you're also pressing down...
  12.  0E:87B5: 05 35     ORA ladder_flags
  13.  0E:87B7: C9 11     CMP #$11
  14.  0E:87B9: F0 F3     BEQ -
  15.  0E:87BB: C9 2E     CMP #$2E
  16.  0E:87BD: F0 EF     BEQ -
  17. ; Set x pixel to middle of the nearest tile.
  18. ; That is, round down, then add 8.
  19.  0E:87BF: AD 60 04  LDA x_pixel[0]
  20.  0E:87C2: 85 2E     STA temp_x
  21.  0E:87C4: 29 F0     AND #$F0
  22.  0E:87C6: 09 08     ORA #$08
  23.  0E:87C8: 38        SEC
  24.  0E:87C9: 8D 60 04  STA x_pixel[0]
  25. ; Check which way the ladder snapped Mega Man
  26.  0E:87CC: E5 2E     SBC temp_x
  27.  0E:87CE: 90 08     BCC +
  28.  0E:87D0: 85 00     STA $00
  29.  0E:87D2: 20 F5 8D  JSR ladder_scroll_adjustment_right
  30.  0E:87D5: 4C E2 87  JMP ++
  31. +:
  32. ; Manual twos complement
  33.  0E:87D8: 49 FF     EOR #$FF
  34.  0E:87DA: 18        CLC
  35.  0E:87DB: 69 01     ADC #$01
  36.  0E:87DD: 85 00     STA $00
  37.  0E:87DF: 20 65 8E  JSR ladder_scroll_adjustment_left
  38. ++:
  39. ; Make Mega Man face the opposide direction.
  40. ; It's a feature!!
  41. ; Where does the ladder fidget or B holding glitch live?
  42.  0E:87E2: AD 20 04  LDA sprite_flags[0]
  43.  0E:87E5: 49 40     EOR #$40
  44.  0E:87E7: 8D 20 04  STA sprite_flags[0]
  45.  0E:87EA: 20 A5 D3  JSR update_anim_index?
  46. ; Ditch a return address and do ladder physics
  47.  0E:87ED: 68        PLA
  48.  0E:87EE: 68        PLA
  49.  0E:87EF: 4C BC 86  JMP ladder_physics
  50.  
Add Comment
Please, Sign In to add comment