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)

Blah April 10th, 2015 7:00 PM

Quote:

Originally Posted by Percy (Post 8700745)
This should help you!
if it doesn't work, sorry!

Wild Pokemon custom moves routine works for give Pokemon too. Actually it works for every Pokemon generated, so it's just poorly named on my part. Should've called it "custom move generator" or something similar :c

chrunch April 10th, 2015 10:36 PM

Not sure if you're still taking these, but I have a small request: a way to force set mode that can be toggled on/off. Would be very useful for battle frontier type places.

HungLikeATauros April 11th, 2015 6:59 AM

Quote:

Originally Posted by FBI agent (Post 8700906)
Wild Pokemon custom moves routine works for give Pokemon too. Actually it works for every Pokemon generated, so it's just poorly named on my part. Should've called it "custom move generator" or something similar :c

Yo schmohawk I asked you a question.

robinjea April 11th, 2015 1:11 PM

Quote:

Originally Posted by HungLikeATauros (Post 8692590)
I can't seem to get the BattleByMove compiled. I'm getting an error message saying "bad instruction 'main'"at line 6, and also one at line 47 "junk at end of line, first unrecognized character is 0"

Any idea why it would say this?

Quote:

Originally Posted by HungLikeATauros (Post 8701571)
Yo schmohawk I asked you a question.

Please use this one from the post for the routine itself.

Quote:

Originally Posted by FBI agent (Post 8527650)

Battle Modes!


Battle Routine By Move:



This routine will run, on average four times per turn. Once you select your move, once you use your move, once the opponents uses their move and at the end of the aftermath. This makes the routine a perfect branching place for an Oak-tutorial like battle.

How to insert:
Look at the routine below. The last line .table has an incomplete pointer. It says 0x[pointer to routine table]. Find enough free space (takes 4 byte per routine) in your ROM and set the pointer for .table to that. You do not add +1 to the pointer, nor is it in reverse hex. Once you've fixed the pointer, compile the routine into free space. The last pointer in the routine NEEDS to be 00 00 00 00.


Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

main:
    push {r0-r4}
    mov r0, #0xBF @flag to check divided by 4
    lsl r0, r0, #0x2
    ldr r1, =(0x806E6D0 +1)
    bl linker
    cmp r0, #0x0
    beq noCrash
    ldr r4, .table

loop:
    ldr r1, [r4]
    cmp r1, #0x0 @check table entry is null
    beq noCrash
    bl linker @call table routine
    add r4, r4, #0x4 @get next table routine
    b loop

noCrash:
    pop {r0-r4}
    lsl r0, r0, #0x18
    lsr r0, r0, #0x18
    mov r10, r0
    lsl r1, r1, #0x10
    lsr r1, r1, #0x10
    ldr r2, =(0x2022874)
    ldr r0, =(0x800E2EA +1)
    bx r0

linker:
    bx r1

.align 2

.table:
    .word 0x[pointer to routine table] @THIS IS FREE SPACE IF IT'S YOUR FIRST TIME USING THIS ROUTINE




Now navigate to 0xE2E0 and insert the byte changes:
Code:

00 4D 28 47 XX  XX XX 08


Where XX XX XX is the reverse hex pointer to your routine +1.



Usage:
The routine is toggled by flag 0x2FC. Activate the flag to toggle routines called by this routine. To add routines into the list of called routines, navigate to the pointer of freespace you made .table point to. Insert into that table pointers in reverse hex +1 to wherever you compiled the addon routines make sure they have the 0x8 prefix. The structure of the table should be: [routine pointer in reverse hex +1 (4 bytes)] for each pointer in the table. I.e if I put the addon at 0x740000, the pointer would read 01 00 74 08.


mamamama April 11th, 2015 5:40 PM

How easy/difficult would it be to implement the blue and red texts on nature-boosted/weakened stats? The feature from Heart Gold/Soul Silver that makes it easier to tell what the Pokemon's nature actually does.

azurile13 April 14th, 2015 12:35 PM

This thread is pretty amazing, especially the compiled versions for those of us who can't compile! Thanks to everyone who has contributed, in particular FBI Agent for obvious reasons.

I have two ideas for fire red that, although I know are longshots, would be very powerful features.

1) Dynamic trainer battle. In case I'm using that word incorrectly, what I mean is that instead of using the trainer table, there is one special slot in the game for which you can call an asm command that fills that slot with trainer information, you battle them like a normal battle, then that information clears out again. Maybe a variable for things like trainer class and AI. The biggest part, of course, would be six variables that the script uses to read off of a giant table of 80 byte each Pokemon. This single feature, along with semi random calls, would be a huge step in building a Battle Tower from the ground floor up. And even a Battle Factory/Battle Dome for anyone who cares.

2) This is even more of a long shot, but I'm curious. How many places does the game read nature, ability, and gender? Currently, all 3 are linked to personality value, making it tricky to alter one without possibly affecting the others. What if that weren't the case? Say we have a Pokemon with personality value [1234][5678].

What if instead of the current system, the game reads the 567 to determine nature. 16x16x16 = 4096. That isn't perfectly divisible by 25, but you could just make 4 of the 5 useless natures like Hardy/Quirky sliiightly less common and I don't think anyone would lose any sleep.

Gender value can range from 0 to 255, so just take two from the personality value and it works out fine.

Finally, abilities. With one or more of the remaining parts of the personality value, you could get rid of the current even/odd determiner, which would allow for third abilities.

Overall, wild and trainer Pokemon would still be just as random, so nothing would be needed to overhaul their random number calls, but it would be significantly easier to customize Pokemon for events and breeding changes.

There are obviously other features to personality value, ranging from things some people care about like shiny pokemon to things almost no one cares about like the dots on Spinda or Wurmple.

Sooo
1) Dynamic trainers
2) Completely reworking how the game reads personalities, gender, and abilities.
Or am I just in fantasy land? :)

Touched April 15th, 2015 2:14 AM

Sorry for the pedantism, but this really bothers me. Can we stop using "compiler", "compiled", etc. to refer to the process of assembly being converted into machine code? It's a assembly, so it's assembled by an assembler. Compiling has come to refer to higher level languages such as C. FBI, please use the right terminology in the OP at least :(

Now to be helpful so I can't be deleted :x

Quote:

Originally Posted by azurile13 (Post 8707353)
This thread is pretty amazing, especially the compiled versions for those of us who can't compile! Thanks to everyone who has contributed, in particular FBI Agent for obvious reasons.

I have two ideas for fire red that, although I know are longshots, would be very powerful features.

1) Dynamic trainer battle. In case I'm using that word incorrectly, what I mean is that instead of using the trainer table, there is one special slot in the game for which you can call an asm command that fills that slot with trainer information, you battle them like a normal battle, then that information clears out again. Maybe a variable for things like trainer class and AI. The biggest part, of course, would be six variables that the script uses to read off of a giant table of 80 byte each Pokemon. This single feature, along with semi random calls, would be a huge step in building a Battle Tower from the ground floor up. And even a Battle Factory/Battle Dome for anyone who cares.

2) This is even more of a long shot, but I'm curious. How many places does the game read nature, ability, and gender? Currently, all 3 are linked to personality value, making it tricky to alter one without possibly affecting the others. What if that weren't the case? Say we have a Pokemon with personality value [1234][5678].

What if instead of the current system, the game reads the 567 to determine nature. 16x16x16 = 4096. That isn't perfectly divisible by 25, but you could just make 4 of the 5 useless natures like Hardy/Quirky sliiightly less common and I don't think anyone would lose any sleep.

Gender value can range from 0 to 255, so just take two from the personality value and it works out fine.

Finally, abilities. With one or more of the remaining parts of the personality value, you could get rid of the current even/odd determiner, which would allow for third abilities.

Overall, wild and trainer Pokemon would still be just as random, so nothing would be needed to overhaul their random number calls, but it would be significantly easier to customize Pokemon for events and breeding changes.

There are obviously other features to personality value, ranging from things some people care about like shiny pokemon to things almost no one cares about like the dots on Spinda or Wurmple.

Sooo
1) Dynamic trainers
2) Completely reworking how the game reads personalities, gender, and abilities.
Or am I just in fantasy land? :)

1) shouldn't be so bad. You'd probably have to modify the trainerbattle command though
2) The "useless" natures round out the pairing. There is a nature for each combination of stats. The useless ones are basically the same stat being increased and decreased. I'm not so sure how changing that would affect balance. Currently, all places in the game that read these values are controlled by a single function call. Changing how it reads the personality value to calculate these things shouldn't be too complex, however, making it not read from the PID would be far more complicated. As for abilities, I did at one point make a hack that allowed a third ability. It just overrode the ability bit - I did meaning changing basically all the battle code however, so it conflicted with a large number of ability hacks.

azurile13 April 15th, 2015 12:48 PM

Quote:

Originally Posted by Touched (Post 8708196)
2) The "useless" natures round out the pairing. There is a nature for each combination of stats. The useless ones are basically the same stat being increased and decreased. I'm not so sure how changing that would affect balance. Currently, all places in the game that read these values are controlled by a single function call. Changing how it reads the personality value to calculate these things shouldn't be too complex, however, making it not read from the PID would be far more complicated. As for abilities, I did at one point make a hack that allowed a third ability. It just overrode the ability bit - I did meaning changing basically all the battle code however, so it conflicted with a large number of ability hacks.

One of us doesn't understand what the other is trying to say. What I was trying to suggest was using three specific hex numbers from the PID to determine nature, rather than the last two in decimal form of the PID, which is harder to control. So you would have 4096 possibilities, but you wouldn't be eliminating a nature by any means. For example, 0x0 to 0xC7 inclusive is Hardy, 0xC8 to 018F inclusive is Lonely, 0x190 to 0x257 inclusive is Brave, all the way up to 0xF37 to 0xFFF inclusive is Quirky. It could be rearranged in a different way, but the point being that four neutral natures aren't done away with. Rather, they appear at a frequency of 199/4096 rather than 200/4096. And this isn't a locked idea. It was just an example of attempting to get rid of the connection that nature has to other things that the PID is used to decide.

As far as the other things, it is great to hear that they may be reasonable, especially the trainer one!

Touched April 15th, 2015 12:52 PM

Quote:

Originally Posted by azurile13 (Post 8708974)
One of us doesn't understand what the other is trying to say. What I was trying to suggest was using three specific hex numbers from the PID to determine nature, rather than the last two in decimal form of the PID, which is harder to control. So you would have 4096 possibilities, but you wouldn't be eliminating a nature by any means. For example, 0x0 to 0xC7 inclusive is Hardy, 0xC8 to 018F inclusive is Lonely, 0x190 to 0x257 inclusive is Brave, all the way up to 0xF37 to 0xFFF inclusive is Quirky. It could be rearranged in a different way, but the point being that four neutral natures aren't done away with. Rather, they appear at a frequency of 199/4096 rather than 200/4096. And this isn't a locked idea. It was just an example of attempting to get rid of the connection that nature has to other things that the PID is used to decide.

As far as the other things, it is great to hear that they may be reasonable, especially the trainer one!

Well, as long as you use the PID for the new calculation, I can't see why it shouldn't be easy to change. But I see what you're saying about easier to control. Right now if you want to force nature you have to keep generating new PIDs until it has the nature you want - this can take a lot of time if you need other criteria that are also PID controlled.

kleenexfeu April 17th, 2015 11:59 AM

Hi, I was battling some trainer in battle frontier and an idea just popped in my head.
In the said Battle Frontier, we have possibility to record our last battle.
Then I thought : what about make an event like the hero walk in the hack, an event comes "oh the good guys is fighting the bad guy !!".
Here is the idea, using the Battle Frontier routine to make the player can be spectator of the fight.
Good idea/bad idea ? Doable ?

C me April 20th, 2015 2:41 AM

Would it be possible to make a routine for new targeting methods in battle?

There seems to be space for it in the list. I would like one for targeting youself and your ally (like accupressure) and one that only targets your ally(heal pulse).

This is for Emerald btw.
Thanks

kleenexfeu April 20th, 2015 12:49 PM

Quote:

Originally Posted by Darthatron (Post 7202888)
Here are some hacks that I have made for people. I hope you enjoy them. I have attempted to explain how they work as well, for those who want to learn. :)

Run a script from an items "Use" command or from registering it from select...

Spoiler:
First of all, follow DavidJCobb's Item Creation Tutorial, until the part where it attempts to add scripts, to actually create a new item. But change the "Type" combobox to #2 in the Item Manager. JPANs engine is not required!

Next step is to put this (assmelbed) code somewhere:
Code:

10 B5 04 1C 78 46 13 30 0C 49 08 60 20 1C 0C 49 00 F0 10 F8 10 BC 01 BC 00 47 10 B5 04 1C 0A 48 05 49 00 F0 07 F8 20 1C 06 49 00 F0 03 F8 10 BC 01 BC 00 47 08 47 C0 46 E5 9A 06 08 98 99 03 02 3D 10 0A 08 09 75 07 08 XX XX XX 08


Where XXXXXX is the location of your script reversed. 800300 would be 00 03 80, for example.

By entering this hex somewhere in the ROM and putting it's offset+1 in the "Field Usage" box in the Item Manager, you can call any script by using the item from the bag or by select. :) Say I put the routine at 800000 in the ROM, the Field Usage box would be 08800001.
Here's the unassembled code:
Spoiler:
Code:

.text
.align 2
.thumb
.thumb_func
.global Hax

setup:
        push {r4, lr}
        mov r4, r0
        mov r0, pc
        add r0, #0x13
        ldr r1, .unk_02039998
        str r0, [r1]
        mov r0, r4
        ldr r1, .sub_080A103C
        bl bx_r1
        pop {r4}
        pop {r0}
        bx r0

main:
        push {r4, lr}
        mov r4, r0
        ldr r0, .ScriptToCall
        ldr r1, .CallScript
        bl bx_r1
        mov r0, r4
        ldr r1, .del_c3_from_linked_list
        bl bx_r1
        pop {r4}
        pop {r0}
        bx r0

.align 2
bx_r1:
        bx r1

.align 2
.CallScript:
        .word 0x08069AE4+1
.unk_02039998:
        .word 0x02039998
.sub_080A103C:
        .word 0x080A103C+1
.del_c3_from_linked_list:
        .word 0x08077508+1
.ScriptToCall:
        .word 0x08800300


More to come as I can be bothered.

EDIT: Also feel free to ask about/request stuff here. I may not do all requests, but I'll try my best. :)

Quote:

Originally Posted by Phenom2122 (Post 8316351)
Hey guys, after finding my brain and a new Hex Editor that supports wildcard searches, I figured out the offsets for Emerald. Thanks to @Darthatron for the original ASM and thanks to absolutely nobody for helping me find those offsets. :)
Even though I couldn't get it to compile for some reason, I will post the modified code here:
Spoiler:
Code:

.text
.align 2
.thumb
.thumb_func
.global Hax

setup:
        push {r4, lr}
        mov r4, r0
        mov r0, pc
        add r0, #0x13
        ldr r1, .unk_0203A0F4
        str r0, [r1]
        mov r0, r4
        ldr r1, .sub_080FD0DC
        bl bx_r1
        pop {r4}
        pop {r0}
        bx r0

main:
        push {r4, lr}
        mov r4, r0
        ldr r0, .ScriptToCall
        ldr r1, .CallScript
        bl bx_r1
        mov r0, r4
        ldr r1, .del_c3_from_linked_list
        bl bx_r1
        pop {r4}
        pop {r0}
        bx r0

.align 2
bx_r1:
        bx r1

.align 2
.CallScript:
        .word 0x08098EF8+1
.unk_0203A0F4:
        .word 0x0203A0F4
.sub_080FD0DC:
        .word 0x080FD0DC+1
.del_c3_from_linked_list:
        .word 0x080A909C+1
.ScriptToCall:
        .word 0x08800300




And here is the compiled code, modified with the correct Emerald offsets:
Spoiler:
Code:

10 B5 04 1C 78 46 13 30 0C 49 08 60 20 1C 0C 49 00 F0 10 F8 10 BC 01 BC 00 47 10 B5 04 1C 0A 48 05 49 00 F0 07 F8 20 1C 06 49 00 F0 03 F8 10 BC 01 BC 00 47 08 47 C0 46 F9 8E 09 08 F4 A0 03 02 DD D0 0F 08 9D 90 0A 08 XX XX XX 08




I just did a quick test with a Littleroot Town signboard item called 'Dog'. Everything seems to be a-ok. Time for sleep.

Hi, I saw this in an old thread. It's awesome ! Sadly, neither of the compiled nor the decompiled routines work for emerald. Can't compile the decompiled and the compiled one make my screen goes black. Someone could fix it ?

Ok nevermind, the compiled one works :) I guess it could be in the OP then
EDIT the disassembled, there were 2 offset unchanged, corrected now :) (Thank's Touched x))

So, it would be cool if we can create a routine that make a pokemon unable to hold an item. This way we can transform Arceus, Giratina or whatever with an item and the transformed form wouldn't be able to hold an item to avoid to make them overpowered

Red John April 21st, 2015 3:01 AM

I am sorry if I am asking something too specificbut I need them for a reason.
First, could you make it so that whenever you whiteout you Dont go back to a PC but a routine runs and everything after that is handled by it? I found some offsets, but trying to hack it causes a reset.

Joexv April 21st, 2015 1:45 PM

Egg Group Dispaly Routine
This is a simple routine that allows you to in game display the egg groups of a pokemon.

Usage:
Insert into freespace, then in a script set variable 0x8000 to the species number of desired pokemon, the call the routine +1.

Stores results into 0x8000 and 0x8001. use a buffernumber command to display them.

Code:
Spoiler:
Code:

.text
.align 2
.thumb
.thumb_func

main:
        push {r0-r3, lr}
        ldr r2, =(var)
        ldrh r0, [r2]
        mov r1, #0x1C
        mul r0, r0, r1
        ldr r1, =(BaseStats +0x14)
        add r0, r0, r1
        ldrb r1, [r0, #0x1]
        ldrb r0, [r0]
        ldr r3, =(var1)
        strb r0, [r2]
        strb r1, [r3]
        pop {r0-r3, pc}

.align 2

@Emerald
var:
.word 0x20270B8
var1:
.word 0x20270Ba
BaseStats:
.word 0x83203cc

@Fire red
var:
.word 0x20370B8
var1:
.word 0x20370BA
BaseStats:
.word 0x8254784




Compiled
EM
Code:

0F B5 09 4A 10 88 1C 21 48 43 08 49 40 18 41 78 00 78 07 4B 10 70 19 70 0F BD C0 46 B8 70 02 02 BA 70 02 02 CC 03 32 08 1C 00 00 00 38 00 00 00 20 00 00 00


FR
Code:

0F B5 09 4A 10 88 1C 21 48 43 08 49 40 18 41 78 00 78 07 4B 10 70 19 70 0F BD C0 46 B8 70 03 02 BA 70 03 02 84 47 25 08 1C 00 00 00 38 00 00 00 20 00 00 00


Thanks to Fbi Agent and Touched for the help!
Also thanks to Fbi Agent for cleaning my messy routine

MadHacker151 April 24th, 2015 6:36 AM

Hi, I dont know if this is still an active thread or not but..

Is it possible to make a trainer or gym leader have more than 6 pokemon, for example a team of 7? Like 7 pokeballs with 7 pokemon.. I don't know if thats possible or not but it would d really cool..
Thanks

PurpleOrange April 25th, 2015 7:27 AM

Two possible routines that would be useful:
1. Checking the specific map you're in (e.g. the ice room of shoal cave, the player's bedroom, etc.)
2. Checking the type of map you're in (e.g. underground, inside, etc.)
this is for emerald btw

azurile13 April 25th, 2015 9:15 PM

Alright, I realize this may be a dumb question, but I'm having a lot of difficulty understanding the asm of your Pokemon Storage found here: http://www.pokecommunity.com/showthread.php?p=8517719#8517719

I'm trying to understand where exactly the Pokemon is being moved to so that if I wanted a second daycare, I wouldn't need to double store all of their data when they are deposited. All I want to know: if I copied the exact hex from that post and inserted it, what would be the offsets of stored pokemon 1 and offset of stored pokemon 2?

leyn09 April 28th, 2015 4:46 AM

Is there a possibility to make sitrus berry work like on the later generations (increases 25% hp). If there is anyone knows how, please help me. Thanks!:D

PokéMew April 28th, 2015 3:15 PM

Quote:

Originally Posted by leyn09 (Post 8727097)
Is there a possibility to make sitrus berry work like on the later generations (increases 25% hp). If there is anyone knows how, please help me. Thanks!:D

I dunno if this thread is still active anymore even :L

Telemetius April 30th, 2015 6:27 AM

Hi FBI, nice work so far!

I was wondering if it is possible to show the flying animation (the pokeball, the jump, the flying bird) for a certain charachter in the map who is not the hero/heroine..

eMMe97 May 7th, 2015 2:04 AM

I have a request...is it possible to save game without the menù? For example: an ow ask me "would you like to save the game?".
Thanks FBI ;)

Touched May 7th, 2015 3:06 AM

Quote:

Originally Posted by eMMe97 (Post 8739845)
I have a request...is it possible to save game without the menù? For example: an ow ask me "would you like to save the game?".
Thanks FBI ;)

Pretty sure there are specials for this. Check trade centre scripts

robinjea May 7th, 2015 3:36 AM

Bad news for you, it's not FBI. :D

Quote:

Originally Posted by Telemetius (Post 8730274)
Hi FBI, nice work so far!

I was wondering if it is possible to show the flying animation (the pokeball, the jump, the flying bird) for a certain charachter in the map who is not the hero/heroine..

This one, I'm pretty sure this is done via scripting. Just a little doanimation thingy. Search for FR Script Animations I guess. :)

Quote:

Originally Posted by eMMe97 (Post 8739845)
I have a request...is it possible to save game without the menù? For example: an ow ask me "would you like to save the game?".
Thanks FBI http://www.pokecommunity.com/images/templates/smilies/cerulean/11.%20wink.gif

IIRC and AFAIK, this is also done via scripting. :D


On a side note, what could have happened to FBI? He's not too active in this thread anymore. Hope to see him soon. :)

eMMe97 May 7th, 2015 6:30 AM

Quote:

Originally Posted by Touched (Post 8739925)
Pretty sure there are specials for this. Check trade centre scripts

I found the special but is only a pop up, when i click yes...nothing, the script restart with "would you like to save the game?".

Touched May 7th, 2015 10:28 AM

Quote:

Originally Posted by eMMe97 (Post 8740142)
I found the special but is only a pop up, when i click yes...nothing, the script restart with "would you like to save the game?".

Either there are multiple specials or your script is incorrect. Try copying the logic of the trade script.


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.