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)

rojse February 27th, 2017 11:35 AM

Hello. I'm interested in an edit that makes Emerald generate all IVs of all encountered Pokemon at 31. What's the best way to go about this?

linobigatti March 3rd, 2017 9:35 AM

I want to know how it would be to create mysterious gifts

ItsFrickenMe March 11th, 2017 7:58 PM

Quote:

Originally Posted by FBI (Post 8533235)

Roaming Pokemon!


So if I want to use this in Emerald...is it simply a matter of changing offsets? Would the ASM part be the same?

DizzyEgg March 12th, 2017 1:34 AM

Quote:

Originally Posted by ItsFrickenMe (Post 9592046)
So if I want to use this in Emerald...is it simply a matter of changing offsets? Would the ASM part be the same?

No, you can't just port things from one game to another. Also, roaming mechanics already exist in Emerald.

Squeetz March 12th, 2017 6:40 AM

I'm practicing ASM and made a fun little routine for Firered (with some help from Spherical Ice) that counts the amount of Rare Candies the player has used.
If you want to punish your players for cheating by hacking in candies, then this might be of use to you.

Spoiler:
.thumb

main:
ldr r4, variable
mov r0, r4
ldr r2, var_load
bl branch_by_r2
lsl r0, #0x10
lsr r0, #0x10
ldr r1, =(0xFFFF) @if var limit reached, goto end
cmp r0, r1
beq end
mov r1, r0
add r1, #0x1
mov r0, r4
ldr r2, var_set
bl branch_by_r2
end:
ldr r1, tasks
mov r2, r8
lsl r0, r2, #0x2
add r0, r8
lsl r0, #0x3
add r0, r0, r1
ldr r1, sub_81264C8
str r1, [r0]
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0


branch_by_r2:
bx r2

.align 2
variable: .word 0x4050 @change to variable of choice
var_load: .word 0x0806E568 +1
var_set: .word 0x0806E584 +1
tasks: .word 0x03005090
sub_81264C8: .word 0x081264C8 +1


After inserting this in a word-aligned offset, go to 0x1263F6 and place:
Code:

01 49 08 47 C0 46 XX XX XX 08


Where XX is the pointer to the routine, +1.

This routine will automatically add 1 to the variable you chose each time the player uses a rare candy.
How you handle the variable in a script is all up to you!

ItsFrickenMe March 12th, 2017 7:14 AM

Quote:

Originally Posted by DizzyEgg (Post 9592195)
Also, roaming mechanics already exist in Emerald.

Roaming mechanics already exist in Firered too, so why is this ASM needed at all?

ItsFrickenMe March 14th, 2017 9:39 AM

Quote:

Originally Posted by DizzyEgg (Post 9592195)
No, you can't just port things from one game to another. Also, roaming mechanics already exist in Emerald.

Answer me. Now.

DizzyEgg March 14th, 2017 9:44 AM

Quote:

Originally Posted by ItsFrickenMe (Post 9593626)
Answer me. Now.

Answer what?

ItsFrickenMe March 14th, 2017 9:45 AM

Quote:

Originally Posted by DizzyEgg (Post 9593633)
Answer what?

Why is it relevant that roaming mechanics are already in Emerald, when they're also already in FR?

DizzyEgg March 14th, 2017 9:51 AM

Quote:

Originally Posted by ItsFrickenMe (Post 9593634)
Why is it relevant that roaming mechanics are already in Emerald, when they're also already in FR?

You're right, you could modify or use the already existing system. That's what I would probably do.
I guess FBI made his own to have better control over it and to make it compatible with his swarming system.

mbcn10ww March 16th, 2017 4:55 AM

There is a way to call a script with ASM? I want to make something like this:
If a flag is set do something, if not set show a message.

What's the command I use on a routine to make it work?

BLAx501! March 16th, 2017 12:29 PM

Quote:

Originally Posted by mbcn10ww (Post 9594585)
There is a way to call a script with ASM? I want to make something like this:
If a flag is set do something, if not set show a message.

What's the command I use on a routine to make it work?

Well, you could manage that by simply using scripts, but if you insist on using ASM:

Code:

.text
.align 2
.thumb
.thumb_func

main:
        push {r0-r1, lr}
        ldr r0, .SCRIPT_ADDRESS
        ldr r1, =(0x8069AE4 +1)
        bl linkerTwo
        pop {r0-r1, pc}

linkerTwo:
        bx r1

.align 2

.SCRIPT_ADDRESS:
        .word 0x8[script_location +1]


FBI made this routine as a reply to something I asked some time ago on the ASM Help Thread. You just have to compile it, modifying the code to add your script location, insert the code on an aligned offset (is it said that way? xDD) and then callasm the routine offset + 1 as usual.

Hope this helps :D

mbcn10ww March 16th, 2017 1:40 PM

Quote:

Originally Posted by BLAx501! (Post 9594743)
Well, you could manage that by simply using scripts, but if you insist on using ASM:

Code:

.text
.align 2
.thumb
.thumb_func

main:
        push {r0-r1, lr}
        ldr r0, .SCRIPT_ADDRESS
        ldr r1, =(0x8069AE4 +1)
        bl linkerTwo
        pop {r0-r1, pc}

linkerTwo:
        bx r1

.align 2

.SCRIPT_ADDRESS:
        .word 0x8[script_location +1]


FBI made this routine as a reply to something I asked some time ago on the ASM Help Thread. You just have to compile it, modifying the code to add your script location, insert the code on an aligned offset (is it said that way? xDD) and then callasm the routine offset + 1 as usual.

Hope this helps :D

I know it can be done only with scripts, but it's needed to edit another routine I have, then it looks better than I wanted, thanks for the reply, I will test it soon as possible and I tell if it worked. ^^

EDIT: Haven't worked, I tested running it by another routine, I tested it by running from the START menu, but haven't worked.

tkim March 17th, 2017 10:35 PM

Quote:

Originally Posted by Squeetz (Post 9595301)
Pokémon Ruby and Sapphire introduced a feature where if you bought 10 or more Poké Balls in the Mart, you would get a free Premier Ball.
Sadly, this feature was removed in FRLG, and so I tried to port it the best I could.

First, insert this text somewhere using XSE or something and write down the offset of where you inserted it:
Code:

I'll throw in a Premier Ball, too.


After that, assemble this routine in a word-aligned offset (ends in 0, 4, 8 or C)
(But first, replace the XXXXXX with the offset of where you inserted the Premier Ball message):

Spoiler:

.thumb

main:
push {r4-r7, lr}
lsl r0, r0, #0x18
lsr r5, r0, #0x18
lsl r0, r5, #2
add r0, r0, r5
lsl r0, r0, #3
ldr r1, taskspriv
add r4, r0, r1
mov r0, #4
ldr r7, rboxid_tilemap_update
bl linkr7
ldrh r0, [r4, #0xA] @ItemID
ldrh r1, [r4, #2] @Amount
mov r6, r1
lsl r6, r6, #0x10
add r6, r0
ldr r7, bag_add_item
bl linkr7
lsl r0, r0, #0x18
lsr r0, r0, #0x18
cmp r0, #1
bne fullbag
ldr r1, hereyouare
ldr r2, sub_809BF0C
mov r0, r5
bl displaymsg
mov r0, r5
mov r0, r6
lsl r0, #0x10
lsr r0, #0x10
cmp r0, #0x4 @Pokeball ID
beq boughtball
next:
ldrh r0, [r4, #0xA]
ldrh r1, [r4, #2]
mov r2, #1
ldr r7, sub_809C09C
bl linkr7
b end

boughtball:
lsr r6, #0x10
mov r1, r6
cmp r1, #0x9 @if player bought over 9 pokeballs, attempt to add premierball
bhi tryadding
b next

tryadding:
mov r0, #0xC @premier ball ID
mov r1, #0x1 @amount of premier balls
ldr r7, bag_add_item
bl linkr7
lsl r0, r0, #0x18
lsr r0, r0, #0x18
cmp r0, #1
bne next @if no room for premier ball, skip to next
ldr r1, message
ldr r2, sub_809BF0C
mov r0, r5
bl displaymsg
b next

fullbag:
ldr r1, bagisfull
ldr r2, sub_809BF98
mov r0, r5
bl displaymsg
end:
pop {r4-r7}
pop {r0}
bx r0

displaymsg:
ldr r7, displayadress
linkr7:
bx r7

.align 2
taskspriv: .word 0x03005098
rboxid_tilemap_update: .word 0x08003FA0 +1
bag_add_item: .word 0x0809A084 +1
sub_809BF98: .word 0x0809BF98 +1
sub_809BF0C: .word 0x0809BF0C +1
sub_809C09C: .word 0x0809C09C +1
displayadress: .word 0x0813F75C +1
bagisfull: .word 0x08416861
hereyouare: .word 0x084167E7
message: .word 0x08XXXXXX


After inserting the routine, navigate to 0x3DF0B4 and put the pointer to it, +1. (If I inserted the routine at 0x725030 I would put 31 50 72 08)

And that's it!

Hi. The routine works well but The hereyouare message doesn't seem to appear if I do receive the PREMIER BALL. Instead it goes straight to the 'I'll throw in a PREMIER BALL, too.' I would like to see both messages appear, just as it does in R/S/E. Thanks for the routine!

tkim March 18th, 2017 11:40 AM

Quote:

Originally Posted by Squeetz (Post 9595301)
Pokémon Ruby and Sapphire introduced a feature where if you bought 10 or more Poké Balls in the Mart, you would get a free Premier Ball.
Sadly, this feature was removed in FRLG, and so I tried to port it the best I could.

First, insert this text somewhere using XSE or something and write down the offset of where you inserted it:
Code:

Here you are!\nI'll throw in a Premier Ball, too.



Not what I meant but whatever.

Squeetz March 18th, 2017 1:35 PM

Quote:

Originally Posted by tkim (Post 9595892)
Not what I meant but whatever.

Sorry then.
I'm still learning.

tkim March 18th, 2017 3:02 PM

Quote:

Originally Posted by Squeetz (Post 9595968)
Sorry then.
I'm still learning.

What I meant was, I would like to see the 'I'll throw in...' message following the hereyouare message. Instead of combining the text, I would like to see two separate messages. (without using \p from XSE either)

Something like this.... (I have no knowledge of ASM)
Code:

tryadding:
mov r0, #0xC @premier ball ID
mov r1, #0x1 @amount of premier balls
ldr r7, bag_add_item
bl linkr7
lsl r0, r0, #0x18
lsr r0, r0, #0x18
cmp r0, #1
bne next @if no room for premier ball, skip to next
ldr r1, hereyouare
ldr r2, sub_809BF0C
mov r0, r5
bl displaymsg
ldr r1, message
ldr r2, sub_809BF0C
mov r0, r5
bl displaymsg

b next



linobigatti March 23rd, 2017 9:20 AM

how can i manipulate the mysterious gift system in FR?

MWisBest March 23rd, 2017 6:07 PM

Quote:

Originally Posted by BluRose (Post 9569452)
REUSABLE BALLS IN EMERALD
gracias a familiawerneck
routine with byte changes
Spoiler:
Code:

.text
.align 2
.thumb

@ FE3AA - 00 21
@ 56818 - 00 48 00 47 XX+1 XX XX XX

main:
        bl deleteball
        mov r9, r4
        mov r10, r5                @ added because emerald
        pop {r4-r7}
        pop {r0}
        bx r0

deleteball:
        ldr r0, var_800E        @ last_used_item_maybe
        ldrh r0, [r0]
        mov r1, #1
        ldr r2, =(0x80D6AA5)
        bx r2

.align 2
var_800E: .word 0x0203CE7C



if y'all want to see specific equivalent addresses:
Spoiler:
Code:

[bpre]
2D924                - atkF0 - near end
9A1D8                - bag_remove_item
A1E30                - pokeball + 0x24
0203AD30        - var 800E

[bpee]
56818                - atkF0 - near end
D6AA4                - bag_remove_item
FE3AA                - pokeball + 0x26
0203CE7C        - last_used_item_maybe


have a nice day~

I fixed this so it doesn't delete the fishing rod in the safari zone, among other glitches. It'll now verify that the item is a ball of some kind before it deletes it.

The code looks strange. I'm guessing it could be improved somehow, but it works:
Code:

.text
.align 2
.thumb

@ FE3AA - 00 21
@ 56818 - 00 48 00 47 XX+1 XX XX XX

main:
        bl delete_item_if_pokeball
        b finish

deleteball:
        @ r0 already contains last_used_item.
        mov r1, #1
        ldr r2, .bag_remove_item
        bx r2

delete_item_if_pokeball:
        ldr r0, .last_used_item
        ldrh r0, [r0]
        @ checks that the item id is premier ball or lower
        cmp r0, #0xC
        bls deleteball
        @ support for custom pokeballs can be added like so:
        @ cmp r0, #CUSTOM_BALL_ID
        @ beq deleteball

finish:
        mov r9, r4
        mov r10, r5
        pop {r4-r7}
        pop {r0}
        bx r0

.align 2
.last_used_item:
        .word 0x0203CE7C
.bag_remove_item:
        .word 0x080D6AA4|1


EDIT: See here for a version that also makes safari balls reusable.

BluRose March 23rd, 2017 6:24 PM

Quote:

Originally Posted by MWisBest (Post 9599642)
I fixed this so it doesn't delete the fishing rod in the safari zone, among other glitches. It'll now verify that the item is a ball of some kind before it deletes it.

The code looks strange. I'm guessing it could be improved somehow, but it works:
Code:

.text
.align 2
.thumb

@ FE3AA - 00 21
@ 56818 - 00 48 00 47 XX+1 XX XX XX

main:
        bl delete_item_if_pokeball
        bl finish

deleteball:
        @ r0 already contains last_used_item.
        mov r1, #1
        ldr r2, .bag_remove_item
        bx r2

delete_item_if_pokeball:
        ldr r0, .last_used_item
        ldrh r0, [r0]
        @ checks that the item id is premier ball or lower
        cmp r0, #0xC
        bls deleteball
        @ support for custom pokeballs can be added like so:
        @ cmp r0, #CUSTOM_BALL_ID
        @ beq deleteball

finish:
        mov r9, r4
        mov r10, r5
        pop {r4-r7}
        pop {r0}
        bx r0

.align 2
.last_used_item:
        .word 0x0203CE7C
.bag_remove_item:
        .word 0x080D6AA4|1



oh xD
i guess i forgot to edit my post with what i had posted here and here
muchas gracias amigo~
i'll edit my old post and direct to your method as well x3

ghoulslash March 29th, 2017 4:48 AM

I hope this is the right place to ask, but I was wondering if anyone knows how to edit the following routines so that they don't end the script after completion? For example, use callasm 0x8XXXXXX and then continue with a msgbox, etc..

Naming the player from the overworld: callasm 0x809FC91


And Jambo's rival naming script:
Code:

.text
.align 2
.thumb
.thumb_func
.global rivalnamingingame

main:
        push {r0-r4,lr}
        ldr r0, place
        str r0, [sp, #0x4]
        ldr r1, ramlocation
        ldr r1, [r1, #0x0]
        ldr r0, standard
        add r1, r1, r0
        mov r0, #0x4
        mov r2, #0x0
        mov r3, #0x0
        bl place2
        ldr r1, ramlocation
        ldr r1, [r1, #0x0]
        ldr r0, standard
        add r1, r1, r0
        ldrb r0, [r1, #0x0]
        cmp r0, #0xFF
        beq failsafe
        cmp r0, #0x0
        beq failsafe

return:
        pop {r0-r4}
        pop {pc}

place2:
        ldr r4, actualroutine
        bx r4

failsafe:
        ldr r0, rivalname

loop:
        ldrb r2, [r0, #0x0]
        strb r2, [r1, #0x0]
        cmp r2, #0xFF
        beq return
        add r0, #0x1
        add r1, #0x1
        b loop

.align 2
place: .word 0x080568E1
ramlocation: .word 0x03005008
standard: .word 0x00003A4C
actualroutine: .word 0x0809D955
rivalname: .word 0x08FFFFFF                    @default name if left blank



jiangzhengwenjzw March 29th, 2017 6:04 AM

Quote:

Originally Posted by ghoulslash (Post 9604565)
I hope this is the right place to ask, but I was wondering if anyone knows how to edit the following routines so that they don't end the script after completion? For example, use callasm 0x8XXXXXX and then continue with a msgbox, etc..

Naming the player from the overworld: callasm 0x809FC91

Change the A9 at 0x9FCB4 to C5 and then try to callasm 0x809FC91. (i guess you should perform the 'lock' command again after the callasm)

MWisBest March 29th, 2017 12:48 PM

Quote:

Originally Posted by MWisBest (Post 9599642)
I fixed this so it doesn't delete the fishing rod in the safari zone, among other glitches. It'll now verify that the item is a ball of some kind before it deletes it.

The code looks strange. I'm guessing it could be improved somehow, but it works:
Spoiler:
Code:

.text
.align 2
.thumb

@ FE3AA - 00 21
@ 56818 - 00 48 00 47 XX+1 XX XX XX

main:
        bl delete_item_if_pokeball
        b finish

deleteball:
        @ r0 already contains last_used_item.
        mov r1, #1
        ldr r2, .bag_remove_item
        bx r2

delete_item_if_pokeball:
        ldr r0, .last_used_item
        ldrh r0, [r0]
        @ checks that the item id is premier ball or lower
        cmp r0, #0xC
        bls deleteball
        @ support for custom pokeballs can be added like so:
        @ cmp r0, #CUSTOM_BALL_ID
        @ beq deleteball

finish:
        mov r9, r4
        mov r10, r5
        pop {r4-r7}
        pop {r0}
        bx r0

.align 2
.last_used_item:
        .word 0x0203CE7C
.bag_remove_item:
        .word 0x080D6AA4|1



Made another improvement to the reusable pokeballs: safari balls can now be reused as well!

Code:

.text
.align 2
.thumb

@ FE3AA - 00 21
@ 56818 - 00 48 00 47 XX+1 XX XX XX
@ 3F008 - 02 E0 C0 46 C0 46 C0 46 ! NEW
@ Optional: change initial safari ball count?: FC0E6 - XX 20, XX = initial count

main:
        @ if safari ball counter is not 0, then that's what we need to delete
        ldr r1, .safari_ball_count
        ldrb r0, [r1]
        cmp r0, #0x0
        bne delete_safari_ball

        @ ...otherwise, delete the last used item (if it's a pokeball)
        ldr r0, .last_used_item
        ldrh r0, [r0]
        @ checks that the item id is premier ball or lower
        cmp r0, #0xC
        bls delete_ball_in_bag
        @ support for custom pokeballs can be added like so:
        @ cmp r0, #CUSTOM_BALL_ID
        @ beq delete_ball_in_bag

        b finish

delete_safari_ball:
        @ r0 already contains current safari ball count, and
        @ r1 already contains safari ball count memory address
        sub r0, #1
        strb r0, [r1]
        b finish

delete_ball_in_bag:
        @ r0 already contains last_used_item.
        mov r1, #1
        ldr r2, .bag_remove_item
        bl x_r2
        b finish

finish:
        mov r9, r4
        mov r10, r5
        pop {r4-r7}
        pop {r2}
x_r2:
        bx r2

.align 2
.last_used_item:
        .word 0x0203CE7C
.bag_remove_item:
        .word 0x080D6AA4|1
.safari_ball_count:
        .word 0x0203A04C



ghoulslash March 30th, 2017 3:59 AM

Quote:

Originally Posted by jiangzhengwenjzw (Post 9604607)
Change the A9 at 0x9FCB4 to C5 and then try to callasm 0x809FC91. (i guess you should perform the 'lock' command again after the callasm)

Thanks! Do you know how that change converts to assembly so I could try and do the same thing with the naming rival function?

jiangzhengwenjzw March 30th, 2017 4:44 AM

Quote:

Originally Posted by ghoulslash (Post 9605305)
Thanks! Do you know how that change converts to assembly so I could try and do the same thing with the naming rival function?

I guess the rival naming func is also built-in.

Change the A9 at 0x9FD54 to C5 and then try to callasm 0x809FD31. (It's from my old note in firered db, so i'm not sure whether it's correct or not...)


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.