News:

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

Main Menu

[SM] Changing Routines

Started by Odylg, October 12, 2015, 04:05:39 AM

Previous topic - Next topic

Odylg

A while back I posted an issue I was having with item collecting.
I had done some hex edits to remove the message boxes for picking up items while leaving save stations alone.
I found that if I grab an item, such as the missile in 7A107, and leave the room relatively quickly I would get temporarily stuck after the door transition, waiting for it to fade in. I tried changing the music in SMILE for each pickup. No "Item Get!" fanfare, delay still there. I was told the issue was with the message box routine still being active.
How do I make sure the rest of the routine doesn't stay active?
I was directed to
http://jathys.zophar.net/supermetroid/kejardon/messageboxes.txt
but I don't really understand it.
At least with hex editing i'm given the original bytes (or at least how many) and what to change them to, like:

$208EB  |  22 80 80 85 to EA EA EA EA

Simple enough. But then I look at something like this:
[spoiler]
$28080-$280F9
{
   PHP
   PHB
   PHX
   PHY
   PHK
   PLB
   STA $1C1F
   JSL $82BE17  ;  $13E17 IN ROM. Plays 'sounds' (80:9049, 90CB, 914D), actually stops all sounds.
   JSR $8143  ;  $28143 IN ROM. Layer 3 message box setup?
   JSR $81F3  ;  $281F3 IN ROM. Layer 3 clearing above and below message box
   JSR $8241  ;  $28241 IN ROM. Two subroutines depending on $1C1F. I'm guessing tiles and length, in that order.
   JSR $8574  ;  $28574 IN ROM. Adds a 2 frame delay, if I understand this right.
   JSR $844C  ;  $2844C IN ROM. 'Opens' the message box. This takes up several frames, during which nothing else runs.
   LDA $1C1F
   CMP #$001C

   BEQ BRANCH_ALPHA

   JSR $846D  ;  $2846D IN ROM. Code for while message box is open. Nothing else happens during this. (Wait for X time than any button usually, or wait for A or left/right/select on save)
   JSR $8589  ;  $28589 IN ROM. 'Closes' the message box. Takes several frames, nothing else happens.
   JSR $81F3  ;  $281F3 IN ROM. Layer 3 clearing, again
   JSR $861A  ;  $2861A IN ROM. Layer 3 message box cleanup.
   JSL $82BE2F  ;  $13E2F IN ROM. Resume speed boost and charge beam sounds, if necessary, and a few other sounds I'm unsure of.
   JSR $8574  ;  $28574 IN ROM. Another 2 frame pause.
   JSR $80FA  ;  $280FA IN ROM. If map station, go to pause screen. Else if 1C (ship save?) or 17 (save station save), LDA $05F9 (selected option)

BRANCH_GAMMA

   PLY
   PLX
   PLB
   PLP
   RTL

BRANCH_ALPHA

   JSR $846D  ;  $2846D IN ROM. Code for while message box is open. Nothing else happens during this. (Wait for X time than any button usually, or wait for A or left/right/select on save)
   JSR $8589  ;  $28589 IN ROM. 'Closes' the message box. Takes several frames, nothing else happens.
   LDA $05F9
   CMP #$0002

   BEQ BRANCH_BETA

   LDA #$0018
   STA $1C1F
   JSR $81F3  ;  $281F3 IN ROM. Layer 3 clearing, again
   JSR $8119  ;  $28119 IN ROM
   JSR $8241  ;  $28241 IN ROM
   JSR $8574  ;  $28574 IN ROM. Adds a 2 frame delay
   JSR $844C  ;  $2844C IN ROM. 'Opens' the message box. "Game Saved" in this case.
   JSR $846D  ;  $2846D IN ROM. Code for while message box is open. Nothing else happens during this.
   JSR $8589  ;  $28589 IN ROM. 'Closes' the message box. Takes several frames, nothing else happens.

BRANCH_BETA

   JSR $81F3  ;  $281F3 IN ROM. Layer 3 clearing, again
   JSR $861A  ;  $2861A IN ROM. Layer 3 message box cleanup.
   JSL $82BE2F  ;  $13E2F IN ROM. Resume speed boost and charge beam sounds, if necessary, and a few other sounds I'm unsure of.
   JSR $8574  ;  $28574 IN ROM. Adds a 2 frame delay
   JSR $80FA  ;  $280FA IN ROM. If map station, go to pause screen. Else if 1C (ship save?) or 17 (save station save), LDA $05F9 (selected option)

   BRA BRANCH_GAMMA

}
[/spoiler]
and I have no idea what to do.
Any help would be very much appreciated.

NotSamusAran

The thing you posted is assembler code, normally having .asm extension.  Just edit the assembler code in a text editor to your liking, then apply it to your ROM using an assember such as xkas (xkas = cross-knight assembler).  The assembler creates the actual hex codes itself from the asm commands.

To apply a patch in xkas:
xkas patch.asm game.smc

Then just find asm patches that are simple enough to tweak to your liking:

http://www.metroidconstruction.com/patches.php
http://www.metroidconstruction.com/patches-howto.php
http://www.metroidconstruction.com/patches-info.php

Odylg

#2
Nvm about what i just said about the hex edit. I forgot id posted the message box.txt.  Unfortunately, even though the message box doesn't show there's still a part of the routine running, causing a delay in room transition. So I do need ASM but I dunno how to make it for I am noob.

EDIT: I tried turning the txt file I posted into  ASM.  When applied I can't get past the Nintendo logo. Filenames are the same. I'm using unheadered, could that be why? Or is there something I'm supposed to tweak in the asm first?

Mettyk25jigsaw

Try this,

lorom

org $858080
{
   PHP
   PHB
   PHX
   PHY
   PHK
   PLB
   STA $1C1F
   JSL $82BE17  ;  $13E17 IN ROM. Plays 'sounds' (80:9049, 90CB, 914D), actually stops all sounds.
   JSR $8143  ;  $28143 IN ROM. Layer 3 message box setup?
   JSR $81F3  ;  $281F3 IN ROM. Layer 3 clearing above and below message box
   JSR $8241  ;  $28241 IN ROM. Two subroutines depending on $1C1F. I'm guessing tiles and length, in that order.
   JSR $8574  ;  $28574 IN ROM. Adds a 2 frame delay, if I understand this right.
   JSR $844C  ;  $2844C IN ROM. 'Opens' the message box. This takes up several frames, during which nothing else runs.
   LDA $1C1F
   CMP #$001C

   BEQ BRANCH_ALPHA

   JSR $846D  ;  $2846D IN ROM. Code for while message box is open. Nothing else happens during this. (Wait for X time than any button usually, or wait for A or left/right/select on save)
   JSR $8589  ;  $28589 IN ROM. 'Closes' the message box. Takes several frames, nothing else happens.
   JSR $81F3  ;  $281F3 IN ROM. Layer 3 clearing, again
   JSR $861A  ;  $2861A IN ROM. Layer 3 message box cleanup.
   JSL $82BE2F  ;  $13E2F IN ROM. Resume speed boost and charge beam sounds, if necessary, and a few other sounds I'm unsure of.
   JSR $8574  ;  $28574 IN ROM. Another 2 frame pause.
   JSR $80FA  ;  $280FA IN ROM. If map station, go to pause screen. Else if 1C (ship save?) or 17 (save station save), LDA $05F9 (selected option)

BRANCH_GAMMA:

   PLY
   PLX
   PLB
   PLP
   RTL

BRANCH_ALPHA:

   JSR $846D  ;  $2846D IN ROM. Code for while message box is open. Nothing else happens during this. (Wait for X time than any button usually, or wait for A or left/right/select on save)
   JSR $8589  ;  $28589 IN ROM. 'Closes' the message box. Takes several frames, nothing else happens.
   LDA $05F9
   CMP #$0002

   BEQ BRANCH_BETA

   LDA #$0018
   STA $1C1F
   JSR $81F3  ;  $281F3 IN ROM. Layer 3 clearing, again
   JSR $8119  ;  $28119 IN ROM
   JSR $8241  ;  $28241 IN ROM
   JSR $8574  ;  $28574 IN ROM. Adds a 2 frame delay
   JSR $844C  ;  $2844C IN ROM. 'Opens' the message box. "Game Saved" in this case.
   JSR $846D  ;  $2846D IN ROM. Code for while message box is open. Nothing else happens during this.
   JSR $8589  ;  $28589 IN ROM. 'Closes' the message box. Takes several frames, nothing else happens.

BRANCH_BETA:

   JSR $81F3  ;  $281F3 IN ROM. Layer 3 clearing, again
   JSR $861A  ;  $2861A IN ROM. Layer 3 message box cleanup.
   JSL $82BE2F  ;  $13E2F IN ROM. Resume speed boost and charge beam sounds, if necessary, and a few other sounds I'm unsure of.
   JSR $8574  ;  $28574 IN ROM. Adds a 2 frame delay
   JSR $80FA  ;  $280FA IN ROM. If map station, go to pause screen. Else if 1C (ship save?) or 17 (save station save), LDA $05F9 (selected option)

   BRA BRANCH_GAMMA

Odylg

Still no, sadly. Takes just as long as the video showed. Had it and a fresh ROM both named RoutineTest, dragged the ASM and dropped it onto xkas. This was an unheadered ROM of course. Also tried a fresh headered one and the game freezes going down the first elevator