News:

Don't forget to visit the main site! There's lots of helpful docs, patches, and more!

Main Menu

Force-cancel grapple beam

Started by adamf, November 20, 2016, 06:32:24 PM

Previous topic - Next topic

adamf

I have this prospective patch for enabling Samus to collect items using the grapple beam:

[spoiler]lorom
org $94A851
   DW pickup ; hijack grapple beam H-collision w/ crumble

org $94B400
pickup:
   LDA $0DC4
   TAX
   LDA $7F6402,X
   AND #$00FF ; isolate our own BTS
   CMP #$0045
   BEQ collect
   SEC        ; solid
   RTS
collect:
   PHA        ; save BTS
   ; non-working attempt to set "stop beam" state:
   LDA #$C856
   STA $0D32
   ; non-working attempt to cancel sound only:
   STZ $0DC0
   ; no difference: 7, 5, 0
   ; APU crash: $45
   LDA #$0007
   JSL $809021

   PLA
   ASL A
   TAX
   JMP $90DA  ; pick up item

[/spoiler]

It picks up the item fine, but it continues the grapple beam sounds after the message box closes. It's especially ridiculous when collecting a suit, because it continues to make noise until Samus moves out of elevator pose.

I've worked on this all afternoon and I haven't made any progress. Any ideas on what to try next? I've just got no idea what I'm doing wrong.

Smiley

LDA #$0002 : JSL $809021 ;Clear sounds from library 1


adamf

#2
Thanks, I didn't realize $0002 was not specifically for canceling charge beam.

It turned out not to help my patch, because PLM code, but I'll get that figured out.  Thanks anyway!

edit: maybe I should add, the ROM later resets $0D32 to #$C856, which appears to be not "force-cancel" so much as "leave grapple running, but don't draw the graphics". And that's what the game is using to restart the sound (for instance, pausing/unpausing stops/restarts it).

I think there's light at the end of the tunnel. What I've found so far is, C856 is actually "force-cancel grapple" but it doesn't get invoked until the main game loop/state runs (after leaving elevator pose.) In the meantime, sound is restarted after closing the message box if $0D32 is not #$C4F0 (not firing), and the suit animation doesn't think to run/clear it.  Research is continuing on the best path to fix this.

adamf

As noted, suit flash code sets grapple to force-cancel and enters the elevator pose. But the elevator pose never runs grapple code. This is a sensible optimization, considering that Samus can't be grappling from the elevator pose... but other code treats only $C4F0 as "off."  That makes it possible to jump, fire grapple beam, land on the Gravity Suit pickup before the shot completes, and have an electric suit.

This patch just makes it rather easier to trigger (grab the suit with grapple, then it's running by definition.)

I still haven't figured out a good way around this, and it's chewing up a lot of time, so I declared it out-of-scope for v1, and launched the stupid patch on my github.