The PokéCommunity Forums

The PokéCommunity Forums (https://www.pokecommunity.com/index.php)
-   Binary Hack Research & Development (https://www.pokecommunity.com/forumdisplay.php?f=195)
-   -   Code ASM Resource Thread (https://www.pokecommunity.com/showthread.php?t=339153)

Lance32497 January 30th, 2015 2:56 PM

Quote:

Originally Posted by FBI agent (Post 8600229)
I'm pretty sure that's how it works ingame already. The ability bit doesn't change when a Pokemon evolves in FR. 90% sure.



Yeah, that's exactly how it would be done. Though these kind of evolutions, which can happen at any time are harder to handle in game. We would have to do the checks kinda frequently. The question becomes, how frequent? Well actually not frequent at all. Just two checks in both scenarios. Pokemon reaches max happiness and Pokemon receives item. So if I was coding this I'd make two different breaks at the Happiness adder, and a second at the give item part.

Was that the information you were looking for? Or did you want me to do one for you?

Since you gave the detailed info, it is both, actually, all I know is to make it happens, we must combine Trade holding item and Happiness, and this is a request lol, since you are now accepting again, but you can use Kearnseyboy6's routines to compare, I think

AkimotoBubble February 8th, 2015 7:32 AM

oh it is great and why not have Emerald ASM code?

daniilS February 8th, 2015 7:39 AM

Quote:

Originally Posted by AkimotoBubble (Post 8611147)
oh it is great and why not have Emerald ASM code?

FBI likes being silly so he hates Emerald :P. I do believe some routines on here are for Em though, and you can always port the others yourself.

RichterSnipes February 13th, 2015 10:04 PM

I'd like to report an issue with the code pertaining to the Infinte TM Usage implementation for FireRed. If you teach a TM to a Pokémon with less than four known moves and watch the entire TM learning animation, the TM will be removed from your TM Case.

I actually would have never noticed that this happened had someone else not pointed it out to me. Everything else works wonders!

Blah February 15th, 2015 6:20 PM

Quote:

Originally Posted by hihohilton (Post 8598344)
What i mean is that say in your hack you had given bulbasaur overgrow and effect spore but you wanted a special gift one with chlorophyll well would it be possible to do that and by carried by evolution i mean if said bulbasaur was to evolve it would still have chlorophyll

I know what you're talking about, but abilities are done wierdly so they don't allow themselves to be easily changed/edited to any arbitrary ability. Abilities in FireRed are derrived from the PID and is represented by a single bit. If that bit is ON then the Pokemon gets it's second ability otherwise it gets it's first ability as defined in the Pokemon table. My ability swapper hack simply just inverses the bit, however you're restricted here. Since the ability is stored as a single bit, there is no way for us to calculate which ability to give, because it simply only has two possible states. You can't really expand this because the bit is stored in the Pokemon data structure in RAM which doesn't have very much free space. While I probably can find a little bit of space inbetween the 0x0 padding of values, these bytes are probably better used for things like a Pokerus feature.

Quote:

Originally Posted by Lance32497 (Post 8598475)
I googled it so I dont know if it has been done, I have watched a youtube vid about changing player OW in FireRed but the uploader didnt give the code, could you find that out?

You'll see my version...soon.

Quote:

Originally Posted by RichterSnipes (Post 8618101)
I'd like to report an issue with the code pertaining to the Infinte TM Usage implementation for FireRed. If you teach a TM to a Pokémon with less than four known moves and watch the entire TM learning animation, the TM will be removed from your TM Case.

I actually would have never noticed that this happened had someone else not pointed it out to me. Everything else works wonders!

Thanks for reporting it, I'll look into the cause!

For everyone using these routines:
If you find any bugs in anything please do report them. Make sure that the bugs are caused by the code and not insertions errors on your part though, ty.

Blah February 15th, 2015 6:45 PM

Changing the Player's Overworld ingame



Intro:

I recently made this routine, it's kind of limited in the sense that you can only be change to 30 different overworlds (excluding the special version of the default characters). While it is limited, I don't really think that that's a problem (you'd probably only be OWs swapping to 2-3 different OWs the entire game anyways, so unless you wanted to player to play as more than 30 characters, this routine will work just fine for you). It's also a little "smaller" in comparison to JPAN's 6 seperate routines which he used (though in his favor, I don't think his limits the amount like mine). I blame the table, it's weird. Actually the whole overworld loading thing is weird..it's done in like 9 places lol.

I should also note that if the OW you're changing to doesn't have a running frame, things are going to look weird when you try to run~

How to insert:

Compile into free space the following routine:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

@hook from 0805CA4C via r0

main:
        @flag check
checkFlag:
        mov r0, #0xFF
        lsl r0, r0, #0x2
        add r0, r0, #0xA @0x3FC + 0xA = @406
        ldr r2, =(0x806E6D0 +1)
        push {r1, r3}
        bl linker
        pop {r1, r3}
        cmp r0, #0x1
        bne noCrash

setOW:
        ldr r0, =(0x20370B8)
        ldrb r0, [r0]
        cmp r0, #0xFF
        beq noCrash
        mov r3, r0

noCrash:
        mov r8, r3
        lsl r4, r4, #0x10
        lsr r4, r4, #0x10
        lsl r5, r5, #0x10
        ldr r0, =(0x805CA54 +1)
        bx r0

linker:
        bx r2

.align 2


Here's a compiled version:
Code:

FF 20 80 00 0A 30 09 4A 0A B4 00 F0 0E F8 0A BC 01 28 04 D1 06 48 00 78 FF 28 00 D0 03 1C 98 46 24 04 24 0C 2D 04 03 48 00 47 10 47 D1 E6 06 08 B8 70 03 02 55 CA 05 08




Now navigate to 0x5CA4C and insert the following byte changes:
Code:

00 48 00 47 XX XX XX 08


Where XX XX XX is where you inserted this routine +1.


Usage:

The routine requires two conditions to toggle.
1) Flag 0x406 is set
2) Var 0x8000 is not 0xFF

As you may have guessed you need to set variable 0x8000 to a value which matches the overworld you want the player to transform into. Please note that for the effect to happen, you need to warp first.
Here's a list of values and their corresponding sprite to the left:
Spoiler:

Code:

0 - male hero
1 - female hero
3 - female hero bike
4 - male hero run
5 - female hero run
6 - male hero vs-seeker
7 - female hero vs-seeker
8 - male hero fishing
9 - female hero fishing
12 - Brendon
13 - May
26 - Male + Female hero Vs seeker on bike
28 - Random guy (A-MAP ID 25)
29 - Little boy
44 - Gem sign thing (buggy)
48 - Spearow
52 - Old man 1 (A-MAP ID 33)
80 - Jogging girl
83 - Blonde dude (A-MAP ID 26)
84 - Fat guy
88 - Old man 2 (A-MAP ID 88)
92 - Scroll backpack thing (buggy)
93 - Team rocket male
104 - Meowth
112 - Chansey
116 - Slowbro
124 - Snorlax
125 - Fisherman
166 - Kid tuber (male)
170 - Old man 3 (A-MAP ID 30)
176 - Green girl (A-MAP ID 40)
213 - Red dress lady
214 - Old lady
228 - Deoxys (I think this one is normal)
245 - Misty
250 - Hey champ in the making guy
251 - Ghost Girl



While no particular value will cause a crash, I've excluded values which are "repeated" OWs. If you experience bugs, use it in conjunction with the backsprite hack I made. If you still have bugs, report them here!

Sounak February 15th, 2015 8:14 PM

Can you please describe how to make my hunger idea possible?

Blah February 15th, 2015 8:55 PM

Quote:

Originally Posted by Sounak (Post 8620386)
Can you please describe how to make my hunger idea possible?

I did, in your thread. It involved using some RAM to keep track of hunger levels and PID. Other than that, there's no real way to do it easily. http://www.pokecommunity.com/showpost.php?p=8619691&postcount=2

Edwearth February 17th, 2015 3:40 PM

Is it possible to make an effect like Absorb, but which the percentage of recover HP can be chosen?
I have a little idea on how to do this but i think the animation will not work.

El Diabeetus February 18th, 2015 1:59 PM

Is it possible to make a different track play for a last Pokémon like the Gym Leaders in Black and White/cut the HP sound off after a few beeps like X/Y? Or if Characteristic / colored text for +/- stats due to ability?

I know I ask a lot of questions, but, these are things I wonder if it's possible to do.

BLAx501! February 19th, 2015 12:21 AM

Hey FBI, it's been a looooooooong time I don't post anything here xD. Well. I've been thinking about something I couldn't solve and since I think it may be ASM-Related, I summon you :P

I was wondering if it is possible to change from one map to another (like a warp or something) and keep the music that you started playing on the previous map.

Mickey` February 19th, 2015 1:43 AM

If the music is the same on both maps, the music won't change.

BLAx501! February 19th, 2015 4:23 AM

Quote:

Originally Posted by Mickey` (Post 8624360)
If the music is the same on both maps, the music won't change.

Of course, what I was meant to say is when the maps have different songs...

metapod23 February 19th, 2015 7:40 AM

I'm interested in inserting a Focus Sash that is reusable in Fire Red. What I mean by that is that the Focus Sash, rather than being consumed like berries, will stay held by the Pokémon, but will only activate if the user has all of its available HP. I don't like that it is a one use item lol. The Focus Band in Fire Red does the same thing, and you can change it so it always activates, but it would need to be changed to check the user's current HP with its current maximum HP.

I don't really care if it replaces Focus Band in the game, because I find it to be relatively useless as an item due to its unreliability.

Thanks in advance for anyone willing to help!

Blah February 19th, 2015 8:17 AM

Quote:

Originally Posted by Edwearth (Post 8622535)
Is it possible to make an effect like Absorb, but which the percentage of recover HP can be chosen?
I have a little idea on how to do this but i think the animation will not work.

Quote:

Originally Posted by SSJ4 Furanki (Post 8623719)
Is it possible to make a different track play for a last Pokémon like the Gym Leaders in Black and White/cut the HP sound off after a few beeps like X/Y? Or if Characteristic / colored text for +/- stats due to ability?

I know I ask a lot of questions, but, these are things I wonder if it's possible to do.

Quote:

Originally Posted by metapod23 (Post 8624589)
I'm interested in inserting a Focus Sash that is reusable in Fire Red. What I mean by that is that the Focus Sash, rather than being consumed like berries, will stay held by the Pokémon, but will only activate if the user has all of its available HP. I don't like that it is a one use item lol. The Focus Band in Fire Red does the same thing, and you can change it so it always activates, but it would need to be changed to check the user's current HP with its current maximum HP.

I don't really care if it replaces Focus Band in the game, because I find it to be relatively useless as an item due to its unreliability.

Thanks in advance for anyone willing to help!

Hi, I specifically don't do graphical ASM or battle related things. Hopefully someone will hop in and help you three out. I can tell you everything you've asked for in indeed doable. You just need to find someone willing :)


Quote:

Originally Posted by BLAxTOISE (Post 8624322)
Hey FBI, it's been a looooooooong time I don't post anything here xD. Well. I've been thinking about something I couldn't solve and since I think it may be ASM-Related, I summon you :P

I was wondering if it is possible to change from one map to another (like a warp or something) and keep the music that you started playing on the previous map.

Hey, it is ASM related, but fairly easy to do if I'm thinking about it right. I'll look into it.

For the bug where the TM gets consumed upon use after the animation:

Insert: 00 00 00 00 at 0x124F78

I'll update my TM post with this information too.

El Diabeetus February 19th, 2015 12:47 PM

Quote:

Originally Posted by FBI agent (Post 8624628)
Hi, I specifically don't do graphical ASM or battle related things. Hopefully someone will hop in and help you three out. I can tell you everything you've asked for in indeed doable. You just need to find someone willing :)




Hey, it is ASM related, but fairly easy to do if I'm thinking about it right. I'll look into it.

For the bug where the TM gets consumed upon use after the animation:

Insert: 00 00 00 00 at 0x124F78

I'll update my TM post with this information too.

Very nice! Is it supposed to be 4 sets of 00 though? I went to that offset and they already were those numbers.

Blah February 19th, 2015 1:17 PM

Quote:

Originally Posted by SSJ4 Furanki (Post 8624958)
Very nice! Is it supposed to be 4 sets of 00 though? I went to that offset and they already were those numbers.

Yup the link to the deletion function takes 4 bytes. We null out the 4 bytes by doing lsl r0, r0, #0x0. I.e the zeros.

El Diabeetus February 19th, 2015 1:29 PM

Quote:

Originally Posted by FBI agent (Post 8625003)
Yup the link to the deletion function takes 4 bytes. We null out the 4 bytes by doing lsl r0, r0, #0x0. I.e the zeros.

Huh, alrighty. Not complaining then.

Lance32497 February 21st, 2015 9:59 PM

How about fixing The "Your foe's weakness" thingy after I send out my desired pokemon?

I always encounter that text string although my Pokemon isn't my foe's weakness

Dionen February 22nd, 2015 11:15 AM

Fire Red gives you one trainer card with 8 gym badges, but some hacks have more than 8 gyms/travels to different regions. Is it possible to create more than one sets of badges? and maybe changing the trainer card backdrop/tileset with it. playing as a different person, stealing badges, there are many possibilities of events with it. It can be easily done with key-items, but come on, it's not the same thing. Well, just an idea. ^_^
All badges are only in one image, so a swapping routine would deal with that, I suppose. The rest of it can be handled via scripts

eMMe97 February 22nd, 2015 2:59 PM

Hello dude! (sorry for my english but i'm italian :S)
For many days (ehm...months xD) I try to create a new pokemon menù (the menù that appeared when you press "start"), to change the classical pokémon menù, and I want to change text with pictures (for example the picture of pokédex, or a ball for pokémon etc), and replace menù in the left of the game (however the upper side is ok, but the menù must be in horizontal in this case).
Can you help me please?

HungLikeATauros February 24th, 2015 9:35 PM

Quote:

Originally Posted by FBI agent (Post 8547374)

Adjusting Shiny encounter chance




How to insert:

Before compiling the routine look at the last line. There is a .word 0x8[RANDOM +1]. Change the content after the 0x8 to be a pointer to where you inserted RANDOM +1.

Once you've done that, look for the line that says "mov r0, #0x1 @item ID". Change 0x1 to the Item ID for your Shiny charm item. If you don't have one implemented, delete these lines:
Code:

        mov r0, #0x1 @item ID
        mov r1, #0x1
        ldr r2, =(0x8099F40 +1)
        bl linker
        cmp r0, #0x0
        beq normal
        mov r0, #0xA
        lsl r0, r0, #0x7
        add r0, r0, #0x55 @1/1365 chance with shiny charm
        b calcChance


After you've done that, compile and insert the following routine into free space:

Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

main:
        push {r0-r3}
        mov r0, #0x1 @item ID
        mov r1, #0x1
        ldr r2, =(0x8099F40 +1)
        bl linker
        cmp r0, #0x0
        beq normal
        mov r0, #0xA
        lsl r0, r0, #0x7
        add r0, r0, #0x55 @1/1365 chance with shiny charm
        b calcChance

normal:
        mov r0, #0x20
        lsl r0, r0, #0x7 @1/4096 chance normally

calcChance:
        ldr r1, =(0x20370B8)
        strh r0, [r1]
        ldr r2, .random
        bl linker
        cmp r0, #0xFF
        bne end
        ldr r1, =(0x20370BC)
        strh r0, [r1]
        ldr r1, =(0x20370B8)
        mov r0, #0x0
        strh r0, [r1]

end:
        pop {r0-r3}
        sub SP, SP, #0x20
        mov r7, r0
        ldr r4, [SP, #0x40]
        ldr r4, [SP, #0x48]
        mov r5, #0xE
        ldr r6, =(0x803DAD8 +1)
        bx r6

linker:
        bx r2

.align 2

.random:
        .word 0x8[RANDOM +1]




Now navigate to 0x3DACE and insert the following byte changes:
Code:

00 00 00 4F 38 47 XX XX XX 08


Where XX XX XX is the reverse hex pointer +1 to where you inserted this routine.


Usage:

It's Automagic, also happens to give the shiny chance to Pokemon in wild, trainer Pokemon, given Pokemon ect.

Right now encounter chance is 1/4096 without shiny charm, and 1/1356 with it.

Figured I'd ask you in the thread instead of on your profile. I've got the two prerequisites inserted but I can't seem to get this code to compile. I'm getting this error message every time:
Quote:

ShinyCharm.asm: 9 : Error: invalid immediate: 279 is out of range
This is my script:
Spoiler:
.text
.align 2
.thumb
.thumb_func


main:
push {r0-r3}
mov r0, #0x117 @item ID
mov r1, #0x1
ldr r2, =(0x8099F40 +1)
bl linker
cmp r0, #0x0
beq normal
mov r0, #0xA
lsl r0, r0, #0x7
add r0, r0, #0x55 @1/1365 chance with shiny charm
b calcChance

normal:
mov r0, #0x20
lsl r0, r0, #0x7 @1/4096 chance normally

calcChance:
ldr r1, =(0x20370B8)
strh r0, [r1]
ldr r2, .random
bl linker
cmp r0, #0xFF
bne end
ldr r1, =(0x20370BC)
strh r0, [r1]
ldr r1, =(0x20370B8)
mov r0, #0x0
strh r0, [r1]

end:
pop {r0-r3}
sub SP, SP, #0x20
mov r7, r0
ldr r4, [SP, #0x40]
ldr r4, [SP, #0x48]
mov r5, #0xE
ldr r6, =(0x803DAD8 +1)
bx r6

linker:
bx r2


.align 2

.random:
.word 0x874B7A4 +1


Any idea why?

Blah February 24th, 2015 9:56 PM

Quote:

Originally Posted by HungLikeATauros (Post 8632648)
Figured I'd ask you in the thread instead of on your profile. I've got the two prerequisites inserted but I can't seem to get this code to compile. I'm getting this error message every time:


This is my script:
Spoiler:
.text
.align 2
.thumb
.thumb_func


main:
push {r0-r3}
mov r0, #0x117 @item ID
mov r1, #0x1
ldr r2, =(0x8099F40 +1)
bl linker
cmp r0, #0x0
beq normal
mov r0, #0xA
lsl r0, r0, #0x7
add r0, r0, #0x55 @1/1365 chance with shiny charm
b calcChance

normal:
mov r0, #0x20
lsl r0, r0, #0x7 @1/4096 chance normally

calcChance:
ldr r1, =(0x20370B8)
strh r0, [r1]
ldr r2, .random
bl linker
cmp r0, #0xFF
bne end
ldr r1, =(0x20370BC)
strh r0, [r1]
ldr r1, =(0x20370B8)
mov r0, #0x0
strh r0, [r1]

end:
pop {r0-r3}
sub SP, SP, #0x20
mov r7, r0
ldr r4, [SP, #0x40]
ldr r4, [SP, #0x48]
mov r5, #0xE
ldr r6, =(0x803DAD8 +1)
bx r6

linker:
bx r2


.align 2

.random:
.word 0x874B7A4 +1


Any idea why?

mov r0, #0x117 @item ID

Mov can only load upto 0xFF. From there you need to derrive the number. Take a look at my second beginner tutorial to see how that problem is fixed. Here's the solution:

Code:

mov r0, #0xFF
add r0, #0x18



HungLikeATauros February 24th, 2015 11:46 PM

Quote:

Originally Posted by FBI agent (Post 8632657)
mov r0, #0x117 @item ID

Mov can only load upto 0xFF. From there you need to derrive the number. Take a look at my second beginner tutorial to see how that problem is fixed. Here's the solution:

Code:

mov r0, #0xFF
add r0, #0x18



So replace the item ID line with those two lines, correct? I did that and I'm not encountering any shinys after running around for over an hour with the item. For testing purposes I changed it to a 1/1 chance and I'm still not finding any.

Blah February 25th, 2015 5:37 AM

Quote:

Originally Posted by HungLikeATauros (Post 8632736)
So replace the item ID line with those two lines, correct? I did that and I'm not encountering any shinys after running around for over an hour with the item. For testing purposes I changed it to a 1/1 chance and I'm still not finding any.

You need the random number routine and the shiny generator routine I made. The three of them work in conjunction to make this effect happen. I know it works, because my test ROM is only shinies :x


All times are GMT -8. The time now is 8:46 AM.


Like our Facebook Page Follow us on Twitter © 2002 - 2018 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2016 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.

Acknowledgements
Use of PokéCommunity Assets
vB Optimise by DragonByte Technologies Ltd © 2023.