News:

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

Main Menu

[SM] Merging Hacks

Started by Daggoth, September 13, 2017, 04:17:39 PM

Previous topic - Next topic

Daggoth

I have been toying with ASM's and learning a decent amount, but I am hitting a wall while trying to merge two patches I want to use for my project.

I have been playing around with JAM's Long Beam item v1.04 patch to get very short range beam shots:
http://old.metroidconstruction.com/IPS/JAMLongBeamV1.04.rar

I also really like the physics and controls in the GBA Style patch, and intend to use it as a baseline - here is the link for that one:
https://www.romhacking.net/hacks/3211/

I have been able to get these two to "work" together by first applying the GBA Patch, then adjusting the values in LongBeamTweak.asm, applying the ASM to the LongBeam.ips, then patching the already patched (GBA Patch) rom with the LongBeam IPS. It seems to work fine, until you reach the first elevator in Criteria which doesn't work, just makes Samus duck when pressing down on it.

I did some investigating, and I am guessing that is because of a conflict in Free space usage:
87A00..87A5E seems to be used by both ips patches. It is movable, and I have tried doing that through adjustments in the LongBeamTweak.asm prior to patching the LongBeam.ips but have had no luck so far.

The only thing I need from the LongBeam.ips is the shot distance reduction - I don't intend to use the Long Beam Item which comes as part of JAM's patch. Can someone please help me to modify these beam distance values without breaking the game while using the GBA Style patch as a base? Thanks very much for any assistance you can offer!

Mentlegen

Maybe use xkas to apply both patches on a clean rom and make sure to move the data elsewhere with a hex editor?

PHOSPHOTiDYL

There's two CMP #$FFC0 & two CMP #$0140.
Non-beam projectiles run this too, so you'll want long beam.

;//[check projectile boundaries]
$90B16A AE DE 0D    LDX $0DDE  [$7E:0DDE] ;//<current projectile index>
$90B16D BD 64 0B    LDA $0B64,x[$7E:0B64] ;//<projectile pixel x-pos>
$90B170 38          SEC
$90B171 ED 11 09    SBC $0911  [$7E:0911] ;//<screen pixel x-pos>
$90B174 C9 C0 FF    CMP #$FFC0
$90B177 30 05       BMI $05    [$B17E] ;//[clean up projectile]
$90B179 C9 40 01    CMP #$0140
$90B17C 30 06       BMI $06    [$B184]

$90B17E 22 B7 AD 90 JSL $90ADB7[$90:ADB7] ;//[clean up projectile]
$90B182 38          SEC
$90B183 60          RTS

$90B184 BD 78 0B    LDA $0B78,x[$7E:0B78] ;//<projectile pixel y-pos>
$90B187 38          SEC
$90B188 ED 15 09    SBC $0915  [$7E:0915] ;//<screen pixel y-pos
$90B18B C9 C0 FF    CMP #$FFC0
$90B18E 30 EE       BMI $EE    [$B17E] ;//[clean up projectile]
$90B190 C9 40 01    CMP #$0140
$90B193 10 E9       BPL $E9    [$B17E] ;//[clean up projectile]
$90B195 18          CLC
$90B196 60          RTS


So for long beam, @ 082F32 & 083123 is 20 00 FA, which points to $90FA00.
Copy the bytes @ 087A00 after applying longbeam.ips & longbeamtweak.asm, save them somewhere.
Apply your other patch, paste the long beam bytes somewhere else, & change those two pointers to your new location.

Those two pointers are pointing to the routine posted above, long beam makes things easier & adds different values for charged & uncharged.
If you don't want to use the item itself, remove the first eight bytes of the bytes you copied, which is the item check.
Nop them or change the pointers to save some space.

Daggoth

Wow, this just made my week PHOSPHO! I finally got down that dang elevator!

It works, so I'm assuming I got it right. Just as a double check though - I moved the code from 087A00 to 087B90, and changed those bits in 082F32 & 083123 to 20 90 FB. The part that confuses me a bit is the 7, or 87 becoming F in the bits. Can you explain that part?

Either way, now I have the gameplay solidified and can move on to level design.

PHOSPHOTiDYL

If you're talking about the first eight bits, it's the item check for collecting the long beam plm.
LDA equippeditems : CMP longbeambit : BNE lastthreebitsofroutinewhichisvanillajmptocodepostedabove.

If you're just using this to change the beam firing distance, you can delete the last three bits of the routine as well.
You're basically rewriting the code posted above & giving just the beam projectiles its own values, charged & uncharged.
If you have long beam equipped, it'd JMP $B16A, which is vanilla to the routine posted, the last three bits.
If you don't have it equipped, it goes through the routine you moved.