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)

Lunos October 28th, 2018 6:52 PM

Quote:

Originally Posted by pokemontutorialTV (Post 9938338)
If I use the above routine, the price isnt calculated for non-TM shops correctly anymore. Do I something wrong?
Ok, I know know your routine does some mistakes with the registers. If you want a working soulution, also shorter than this, DM me.

Consider just sharing it here directly for everyone's benefit. Thank you.

ghoulslash November 6th, 2018 2:42 PM

[FR] Fully Flag-Dependent Start Menu

It's nothing fancy, but this code expands on FBI's routine to swap between start menus, shown here. It also keeps the safari zone start menu intact.

Every single start menu option (except Exit) is flag-dependent, so you can add or remove start menu options with simple flag setting/clearing.

Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func
.global start_menu
/*
insert 00 48 00 47 (xx+1) xx xx 08 at 6ed5c

*/

.equ offset, 0x08xxxxxx                @ insert location

/* change these */
.equ DEX_FLAG, 0x250
.equ POKE_FLAG, 0x251
.equ BAG_FLAG, 0x252
.equ PLAYER_FLAG, 0x253
.equ SAVE_FLAG, 0x254
.equ OPT_FLAG, 0x255
.equ EXIT_FLAG, 0x0  @ currently unused, so at least 1 option is shown

Main:
        bl check_safari_zone
        cmp r0, #0x1
        bne regular_menu
        ldr r0, =(0x0806ed86 +1)
        bx r0

regular_menu:
        push {r4-r5}
        mov r1, #0x0
        ldr r4, =(offset+table)

loop:
        lsl r0, r1, #0x2
        add r0, r0, r4
        mov r5, r0
        cmp r1, #0x6
        beq add_option        @ auto-add last option (exit)
        ldrh r0, [r5]        @ flag to check
        push {r1}
        bl check_flag
        pop {r1}
        cmp r0, #0x1
        bne loop_incr

add_option:
        ldrb r0, [r5, #0x2]                @ menu index
        lsl r0, r0, #0x18
        lsr r0, r0, #0x18
        push {r1}
        bl add_opt
        pop {r1}

loop_incr:
        cmp r1, #0x6        @ num opts
        beq exit
        add r1, #0x1
        b loop

exit:
        pop {r4-r5}
        pop {r0}
        bx r0

.align 2
table:
.hword DEX_FLAG
.byte 0
.byte 0
.hword POKE_FLAG
.byte 1
.byte 0
.hword BAG_FLAG
.byte 2
.byte 0
.hword PLAYER_FLAG
.byte 3
.byte 0
.hword SAVE_FLAG
.byte 4
.byte 0
.hword OPT_FLAG
.byte 5
.byte 0
.hword EXIT_FLAG
.byte 6
.byte 0

check_flag:
        ldr r2, =(0x0806e6d0 +1)
        bx r2

add_opt:
        ldr r2, =(0x0806ed94 +1)
        bx r2

check_safari_zone:
        ldr r0, =(0x080a0e90 +1)
        bx r0




for example, with the current definitions, setting flags 0x251, 0x253 would make the start menu be composed of only "Pokemon","[player]", and "Exit".

Skeli November 9th, 2018 1:00 PM

Quote:

Originally Posted by Petuuuhhh (Post 9946301)
Potions go into the Key Item slot when I use this? What am I doing wrong?

You need to delete your save file and start a new game. Or, implement this routine by Sagiri, and then you can just start a new game normally. If you used the saveblock routine from this post and you do implement Sagiri's routine, make sure that you change the first line in constants.s (from Sagiri's routine) to
Code:

.definelabel jpan_block, 0x0203C100


as that is where I started the saveblock in JPAN's routine.

Zeturic November 9th, 2018 5:07 PM

Since it got mentioned above, I figured I'd post this here.

It's been tweaked slightly so that it only uses armips, rather than the build system I use for my C stuff. All it really did for it was find free space automatically, and, while that's kind of useful, I feel it unnecessarily overcomplicated it.

In any case:

Clear JPAN Save Block During New Game [FR]

Fixes an oddity with JPAN's Save Block Recycle where the saved memory doesn't get zeroed upon starting a new game. Instead, it'll retain whatever it happened to be in the previous save file.

To be clear, this does not actually include JPAN's Save Block Recycle itself.

Zeturic November 10th, 2018 9:35 PM

Unhidden Power [FR]

This routine makes the game calculate and display the actual type of Hidden Power in battle and in status screens. If, for example, a Pokémon's Hidden Power type is Water, it will display as a Water-type move, just like Surf or any other Water-type move.

https://github.com/Sagiri/unhidden-power/blob/master/in-battle.png?raw=true https://github.com/Sagiri/unhidden-power/blob/master/status-screen.png?raw=true

Note that this only calculates and displays the type, not the base power.

Zeturic November 12th, 2018 5:15 PM

Evolve by Leveling Up While Holding An Item [FR]

Adds evolution methods to allow Pokémon to evolve by leveling up while holding a particular item. Also included are day and night variations for use with Happiny, Gligar, and Sneasel.

Other implementations of this evolution method have a subtle bug - they remove the item even if the player hits B to cancel the evolution. This avoids that.

Zeturic November 15th, 2018 1:14 AM

Summary Screen Wraps Around [FR]

Allows you to hit Up on the summary screen of the first Pokémon in the party to move to the last Pokémon in your party, and likewise hit Down on the last to move to the first. This change originated in XY and has become standard in all later games.

eMMe97 November 15th, 2018 8:39 AM

Are there news about this feature? (Trainer's Interrupting battles)
I see that Chacha Dinosaur imported it in Emerald, but for Fire Red?

Megax Rocker November 16th, 2018 6:45 AM

Did someone ever make a Pixie plate item effect?

Zeturic November 17th, 2018 4:27 PM

Hall of Fame Expanded Pokémon Fix [FR]

Fixes an issue where expanded Pokémon above index 0x1FF do not show up correctly in the Hall of Fame.

For example, 0x201 would normally show up as 0x1 (Bulbasaur). This is because the Hall of Fame data only allocated 9 bits to the species number, and 0x1FF is the largest number that can be stored in that space; larger numbers only have their lowest 9 bits stored.

pikachux2 November 19th, 2018 1:55 PM

I literally no nothing about Assembly in fire red, but is the limited number of flags in fire red really a problem? Is it not possible to make an ASM routine that can check the value of some offset after 800000 and return a pseudo Boolean value to the last result variable 0x800D (or any other for that matter)? This will probably be an easy yes or no for a lot of you, I was just curious.

hacanoc November 28th, 2018 3:48 PM

Quote:

Originally Posted by FBI (Post 8620314)

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!

Hi
I tried to apply this rutine but i got errors:
The change of the OW is lost after the player enter in a menu or enter in a battle.
I also inserted the rutine of swap BS, in that i get a problem with the change of the OW after a warp (the OW change to the Hero surfing or the hero in bike)

https://i.postimg.cc/1XDTPSvf/Error-OWGIF.gif

What can I do?

opakedragon December 23rd, 2018 10:16 PM

Quote:

Originally Posted by Lunos (Post 9800566)
Welp, it didn't work.
I compiled the routine and dropped it in the offset 71A250, wrote this script and once I checked it In-Game, this was the result.
https://i.imgur.com/yGrrQAK.png
Note: Just for the record, the savefile is right after defeating my Rival for the very first time, so there's no way for my Pokémon to have 76 points.

Dunno if you'll be able to fix it, but in any case thank you very much.

Would you be willing to reshare the script (the link is no longer working) in code tags? I am relatively new and trying to figure this stuff out.

ShinypikachuX January 7th, 2019 6:02 AM

how about in game rival naming

eMMe97 January 13th, 2019 3:09 AM

Does anyone know if this function (Steven battle for fire red) has been completed? They wrote that it would be enough to insert a line of code to make it complete, but unfortunately it seems that no one has chosen how to insert it.

Delta231 January 13th, 2019 5:00 AM

Quote:

Originally Posted by eMMe97 (Post 9967356)
Does anyone know if this function (Steven battle for fire red) has been completed? They wrote that it would be enough to insert a line of code to make it complete, but unfortunately it seems that no one has chosen how to insert it.

No this wasn't completed and I prefer to use Decompilations.

Blah January 17th, 2019 2:37 PM

Quote:

Originally Posted by eMMe97 (Post 9967356)
Does anyone know if this function (Steven battle for fire red) has been completed? They wrote that it would be enough to insert a line of code to make it complete, but unfortunately it seems that no one has chosen how to insert it.

This is done for the typical encounter battles (where you meet eyes with two trainers at once). What isn't done is a scripted double battle. That shouldn't be hard given the source code here. The caution is that it isn't thoroughly bug tested because CommHack never took off past the mapping (rip scripters).

eMMe97 January 18th, 2019 12:37 AM

Quote:

Originally Posted by FBI (Post 9968968)
This is done for the typical encounter battles (where you meet eyes with two trainers at once). What isn't done is a scripted double battle. That shouldn't be hard given the source code here. The caution is that it isn't thoroughly bug tested because CommHack never took off past the mapping (rip scripters).

I had misunderstood how it worked then, thanks for the clarification!
If I can help, I'll get along well with the fire red scripting :)

Lunos January 26th, 2019 4:23 PM

Quote:

Originally Posted by Spherical Ice (Post 9633537)

[FR] Complimentary Premier Ball for purchases of over 9 Poké Balls


I've used this many many times, I love this feature as silly it may sound.
Surprisingly though, I noticed just now that it seems to glitch the blue bar containing the different HMs descriptions inside the Pokémon Party menu. Could anyone confirm?
https://i.imgur.com/pdFcrC7.png

Steps that I did:
1) Inserted the text string in 0x456734
Code:

C3 B4 E0 E0 00 E8 DC E6 E3 EB 00 DD E2 00 D5 00 CA E6 D9 E1 DD D9 E6 00 BC D5 E0 E0 B8 00 E8 E3 E3 AD FC 09 FF


2) Copy and pasted the routine in a text file, then I modified the offset in L39 accordingly (0x08456734) and compiled.
The result was:
Code:

30 B5 00 06 04 0E A0 00 00 19 C0 00 15 49 45 18 15 48 C1 8D 03 20 08 40 00 28 1F D0 05 20 13 4B 00 F0 1F F8 0A 21 68 5A 04 28 13 D1 02 21 68 5A 09 28 0F DD 0C 20 01 21 0D 4B 00 F0 12 F8 00 06 00 0E 01 28 06 D1 0B 49 0B 4A 20 1C 0B 4B 00 F0 08 F8 03 E0 20 1C 08 4B 00 F0 03 F8 30 BC 01 BC 00 47 18 47 98 50 00 03 F0 30 00 03 CD 22 07 08 85 A0 09 08 34 67 45 08 99 BF 09 08 5D F7 13 08


3) Inserted the routine in 0x45675C

4) Went to 0x9BF64 and wrote: 5D 67 45 08

5) Saved and tested.

I'm certainly getting the extra Premier Ball if I purchase 10 Poké Balls. No issues there.
The thing is that if I grab a clean ROM and this is the only thing that I add to it, the issue with the blue bar happens :/

Subzero Eclipse January 27th, 2019 3:45 AM

Quote:

Originally Posted by Lunos (Post 9972584)
I've used this many many times, I love this feature as silly it may sound.
Surprisingly though, I noticed just now that it seems to glitch the blue bar containing the different HMs descriptions inside the Pokémon Party menu. Could anyone confirm?
https://i.imgur.com/pdFcrC7.png

Steps that I did:
1) Inserted the text string in 0x456734
Code:

C3 B4 E0 E0 00 E8 DC E6 E3 EB 00 DD E2 00 D5 00 CA E6 D9 E1 DD D9 E6 00 BC D5 E0 E0 B8 00 E8 E3 E3 AD FC 09 FF


2) Copy and pasted the routine in a text file, then I modified the offset in L39 accordingly (0x08456734) and compiled.
The result was:
Code:

30 B5 00 06 04 0E A0 00 00 19 C0 00 15 49 45 18 15 48 C1 8D 03 20 08 40 00 28 1F D0 05 20 13 4B 00 F0 1F F8 0A 21 68 5A 04 28 13 D1 02 21 68 5A 09 28 0F DD 0C 20 01 21 0D 4B 00 F0 12 F8 00 06 00 0E 01 28 06 D1 0B 49 0B 4A 20 1C 0B 4B 00 F0 08 F8 03 E0 20 1C 08 4B 00 F0 03 F8 30 BC 01 BC 00 47 18 47 98 50 00 03 F0 30 00 03 CD 22 07 08 85 A0 09 08 34 67 45 08 99 BF 09 08 5D F7 13 08


3) Inserted the routine in 0x45675C

4) Went to 0x9BF64 and wrote: 5D 67 45 08

5) Saved and tested.

I'm certainly getting the extra Premier Ball if I purchase 10 Poké Balls. No issues there.
The thing is that if I grab a clean ROM and this is the only thing that I add to it, the issue with the blue bar happens :/

Hey man, I have inserted this routine in my ROM hack as well and everything is fine on my end. I would guess that this thing happens because you have put the routine before 71A240: in the past I have tried to insert other routines in free space before it and I have had the same issue as you, but when I do put them over 71A240, no problem at all. Maybe you should try to insert it somewhere there and see what happens? Hope it helps.

Lunos January 27th, 2019 6:29 AM

Quote:

Originally Posted by Funny Valentine (Post 9972783)
Hey man, I have inserted this routine in my ROM hack as well and everything is fine on my end. I would guess that this thing happens because you have put the routine before 71A240: in the past I have tried to insert other routines in free space before it and I have had the same issue as you, but when I do put them over 71A240, no problem at all. Maybe you should try to insert it somewhere there and see what happens? Hope it helps.

I just tried it out, and now it's certainly working perfectly. That's kinda dissapointing though, but eh, I guess the free space before 71A240 could be used for something else like maps or scripts..?
Anyway, thank you :D!

EDIT:
Quote:

Originally Posted by FBI (Post 8514906)

Inheriting IVs from parents (via Destiny Knot, in the daycare)


I was testing this routine out just now, and I'm not entirely sure if it's working correctly.
It looks to me like the Eggs are inheriting 3 stats alone, when they should always inherit 5 stats :/
I've been doing tests using this routine and Jiangzhengwenjz's EV-IV Screen.

In my last attempt for example, the results of the Egg were:
-03 HP IVs. Charmander has 30 and Ditto 26.
-03 Atk IVs inherited from Charmander.
-22 Def IVs inherited from Charmander or Ditto (both have 22 Def IVs.)
-23 Spd IVs. Charmander has 31 and Ditto 25.
-19 SpAtk IVs. Charmander has 31 and Ditto 10.
-31 SpDef IVs inherited from Ditto.

If we assume that HP is the random stat in this spread, Spd and SpAtk are the issue here.
The Egg should have inherited Charmander's or Ditto's values in those stats after all, right?
Has anyone tested this yet?

ghoulslash February 5th, 2019 4:33 PM

[FR] Selection from PC Box

This hack allows the player to directly select a pokemon from the pc boxes by modifying the tasks associated with the withdraw function. It doesn't actually do anything with the selection except store relevant data, but this data can then be used in subsequent functions to modify relevant data.

Fortunately, I added in some new/updated specials to allow the user to swap pokemon between box and party for things like trading, nicknaming, and checking/setting pokeball types. Adding new specials for other data manipulation is easy enough, and I would be happy to add more if more ideas come to me.

Current Special Fixes Include:
Spoiler:

special 0x7 - get EVs of party/boxed pokemon
special 0x8 - get IVs of party/boxed pokemon
special 0xB - get pokeball ID of party/boxed pokemon
special 0xD - get happiness of party/boxed pokemon
special 0x13 - set happiness of party/boxed pokemon
special 0x14 - ste pokeball ID of party/boxed pokemon
special 0x1A - save/restore party pokemon data to/from free ram (default is 6th opponent slot)
special 0x1B - save/restore pokemon data to/from pc
special 0x7b - check nicknamed pokemon from party/box
special 0x7c - buffer party/boxed pokemon nickname
special 0x7d - check traded pokemon from party/box
special 0x9e - nickname pokemon from party/box


Here is the repository. The readme should do an adequate job of detailing the usage.

Here is a GIF of using this function with a wonder trade. (credit to sagiri for the dtan system)
https://i.imgur.com/zq6pr9c.gif

Delta231 February 5th, 2019 7:02 PM

Quote:

Originally Posted by ghoulslash (Post 9976338)
[FR] Selection from PC Box

This hack allows the player to directly select a pokemon from the pc boxes by modifying the tasks associated with the withdraw function. It doesn't actually do anything with the selection except store relevant data, but this data can then be used in subsequent functions to modify relevant data.

Fortunately, I added in some new/updated specials to allow the user to swap pokemon between box and party for things like trading, nicknaming, and checking/setting pokeball types. Adding new specials for other data manipulation is easy enough, and I would be happy to add more if more ideas come to me.

Here is the repository. The readme should do an adequate job of detailing the usage.

Here is a GIF of using this function with a wonder trade. (credit to sagiri for the dtan system)
https://i.imgur.com/zq6pr9c.gif

May I request to remove those .exe files in the repository as not everyone in this community uses Windows and you can just link to those utilities .

Bidoof February 9th, 2019 10:31 PM

Hello, I am interested in hacking the wild pokemon generator of Fire Red to influence the species in a similar manner as Static and Magnet Pull do in later games. I've searched many places, including this thread, but I have not found a routine for this. Does anyone know if this has been done before? If not, could you kindly give me advice on how to approach this problem? I am new to ASM but I have experience from other languages so I'm not a total beginner. I know how to compile and insert routines.

AkameTheBulbasaur February 12th, 2019 6:35 PM

It doesn't break flashcart compatibility if you're using the newest version, but it does mean you can't use Save Editors anymore, and you have to start a new save file. This may not be ideal for everyone (it wasn't for me), so here is the way to free up some RAM that gets saved.

To free up the RAM just do the following:

1. Put 28 E0 at 0x110F24
2. Put 04 20 at 0x11192A
3. Put 70 47 at 0x110AEC
4. Put 70 47 at 0x1123BC

This will free up about 8000 flags and 2900 vars (numbers are approximate). Full details are in this post below (ORIGINALLY BY JPAN SO THANK HIM)

https://www.pokecommunity.com/showpost.php?p=8795370&postcount=4

The RAM that I used to free up item space started at 0x2026840 and believe me it is plenty of space. What will happen is that you will lose any items currently in your bag after you switch over. So you'll need to deposit them/give them to PC Pokemon if you want to keep them (alternatively you can write a routine to move the data at the original item RAM over to the new one).

If you have a previous save file, your bag will be a bunch of junk because the save file wrote stuff in the RAM from the Previously On Your Quest thing. To fix that use this routine:

Spoiler:

.text
.align 2
.thumb
.thumb_func

Main:
push {r4-r5, lr}

ClearItems:
ldr r4, .RAMStart
mov r0, #0x0
Loop:
str r0, [r4]
add r4, r4, #0x4
ldr r5, .RAMEnd
cmp r4, r5
beq Return
b Loop

Return:
pop {r4-r5, pc}

.align 2
.RAMStart: .word 0xPLACE WHERE RAM STARTS
.RAMEnd: .word 0xPLACE WHERE RAM ENDS


This routine just makes everything in the RAM range go to zero (so your bag will then be empty and you can put all your items back in).

To use the above routine just insert it and then write an NPC using callasm and call the routine. Then just talk to the NPC you gave it to in-game, save and you'll be done. You can delete the routine and the script afterwards if you want to.


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.