Code ASM Resource Thread Page 65

Started by esperance September 19th, 2014 3:13 PM
  • 445794 views
  • 1604 replies
Age 28
Male
Brazil
Seen 7 Hours Ago
Posted 5 Days Ago
123 posts
4.2 Years
Summary Screen Wrap-Around


First of all, I would like to thank Zeturic for creating the original routine for this. My routine is different from theirs, and I have extended it a bit, which is why I am posting this here.

Anyway, this patch modifies the summary screens in both the Party Menu and in the PC so that if you are on the first Pokemon and you go upwards, you will loop around to the last Pokemon (and vice versa). Ordinarily, in this circumstance, nothing would happen.

(Download)

This folder contains the patch itself, and the two routines that comprise it. There were two functions which were replaced, and both of the new functions were shorter than the originals (hence why this could be turned into a patch).

This patch will skip over Eggs when scrolling while in the Party or PC, but if you want to see the Egg's summary (to see how long it will take to hatch), you can select their summary individually.
If you have more than one Egg in the party and move up or down (if the next slot is an egg), the game freezes.
I SUPPORT HEX MANIAC ADVANCE!
CHECK IT OUT!!!

Pokémon: Fire Red Extended
Hack rom made by me. 😀

Marinebeast

violet phantom in disguise

they/them & it/its
Midwest US
Seen 1 Week Ago
Posted 3 Weeks Ago
10 posts
40 Days
Here's a quick question!

I used the Ability Capsule script by Spherical Ice to create an Ability Capsule item, and it worked great-- but I'm making this for a romhack where almost all of the Pokemon have two abilities, so making an infinite-use key item that runs this script for a Pokemon would be preferable.

What edits would I need to make to the script (or post-compiled hexadecimal) in order to change this? I would imagine it's similar to the scripts that alter TMs or make other reusable key items, but at the moment I'm not confident with ASM script or trying to find the specific hex bytes that need to be altered.

Thanks so much in advance. This thread's incredibly helpful and I appreciate all the excellent content being shared here!

AkameTheBulbasaur

Akame Marukawa of Iyotono

Age 25
Male
A place :D
Seen July 9th, 2022
Posted July 9th, 2022
404 posts
9.2 Years
If you have more than one Egg in the party and move up or down (if the next slot is an egg), the game freezes.
Great catch!

I fixed the problem now. I updated the download. All you need to do is reapply the patch and it should be fixed now.

Turns out that the Party routine was not updating the counter correctly when there was an Egg, creating an infinite loop which soft-locked the game.

Not anymore though! I tried it with two Eggs (it should work for more than two as well, hopefully).

Here's a quick question!

I used the Ability Capsule script by Spherical Ice to create an Ability Capsule item, and it worked great-- but I'm making this for a romhack where almost all of the Pokemon have two abilities, so making an infinite-use key item that runs this script for a Pokemon would be preferable.

What edits would I need to make to the script (or post-compiled hexadecimal) in order to change this? I would imagine it's similar to the scripts that alter TMs or make other reusable key items, but at the moment I'm not confident with ASM script or trying to find the specific hex bytes that need to be altered.

Thanks so much in advance. This thread's incredibly helpful and I appreciate all the excellent content being shared here!
As it turns out, you are in luck. I did this exact same thing in my game. The way you do it is very simple.

First, you write out an NPC script which has the Item's effect. You will want to write it in such a way that it does not remove the item after the script is over. Remember where you inserted it.

Next, you can use this routine by Darthatron to allow an item to run a script when you "use" it. Replace the "08AABBCC" with the address of your NPC Script (do not add one). Also, make sure to put the address where you will insert this routine after the ".equ ROM, 0x08" part (so if you put it at 0xAABBCC you would have ".equ ROM, 0x08AABBCC").

Spoiler:
.text
.align 2
.thumb
.thumb_func
.global RunScriptFromItem

/*
---------------------------------------------------------
This routine was made originally by Darthatron with mild
syntax edits from me.

The purpose of this routine is to allow the user to run
an NPC Script when using an Item from the bag.

First, we do some sort of setting up. We put the address
of the second half of the routine into 0x02039998. Then
we BL to 0x080A103C. This somehow allows us to eventually
run the second part of the routine.

The second part of the routine allows us to run the NPC
script itself. We give it the address, and then it runs
the script.
---------------------------------------------------------
*/

.equ ROM, 0x8

SetUp:
push {r4, lr}
mov r4, r0
ldr r0, .SecondPart
ldr r1, .CodeToRun
str r0, [r1]
mov r0, r4
bl CallFunction
pop {r4}
pop {r0}
bx r0

Main:
push {r4, lr}
mov r4, r0
ldr r0, .ScriptToCall
bl CallNPCScript
mov r0, r4
bl CallRoutine
pop {r4}
pop {r0}
bx r0

CallFunction:
ldr r1, .Function
bx r1

CallNPCScript:
ldr r1, .CallNPCScript
bx r1

CallRoutine:
ldr r1, .Routine
bx r1

.align 2
.CallNPCScript: .word 0x08069AE5
.CodeToRun: .word 0x02039998
.Function: .word 0x080A103D
.SecondPart: .word Main+ROM+1
.Routine: .word 0x08077509
.ScriptToCall: .word 0x08AABBCC


Finally, in the Item Editor, I believe there is an option to allow the item to run a routine when used. You set the address of that routine to the address of Darthatron's routine. Then you only need to set the Item to be a Key Item in the editor, and you should be done.
"The human sacrificed himself, to save the Pokemon. I pitted them against each other, but not until they set aside their differences did I see the true power they all share deep inside. I see now that the circumstances of one's birth are irrelevant; it is what you do with the gift of life that determines who you are." -Mewtwo
Age 28
Male
Brazil
Seen 7 Hours Ago
Posted 5 Days Ago
123 posts
4.2 Years
Great catch!

I fixed the problem now. I updated the download. All you need to do is reapply the patch and it should be fixed now.

Turns out that the Party routine was not updating the counter correctly when there was an Egg, creating an infinite loop which soft-locked the game.

Not anymore though! I tried it with two Eggs (it should work for more than two as well, hopefully).
Thanks!!!
I SUPPORT HEX MANIAC ADVANCE!
CHECK IT OUT!!!

Pokémon: Fire Red Extended
Hack rom made by me. 😀

Marinebeast

violet phantom in disguise

they/them & it/its
Midwest US
Seen 1 Week Ago
Posted 3 Weeks Ago
10 posts
40 Days
Thank you Akame for the pointers! That pointer script works great and should help a lot in the future when I can't run something directly from an item.

I did notice, previously in the thread, there was mention of Everstone nature-passing functionality being ported to FireRed, but I'm not sure if it was posted.
Was this ever done/is there a script for it anywhere? I know there's the CFRU standalone item pack out there that has the Everstone update in it, but it writes to an offset that's unfortunately already very full in the hack I'm shining up.