Code ASM Resource Thread Page 33

Started by esperance September 19th, 2014 3:13 PM
  • 517119 views
  • 1616 replies
Seen January 7th, 2017
Posted August 6th, 2016
58 posts
8.1 Years
  • Wild Pokemon Custom Moves •The reason why it needs to be edited because there are times that var 8000 is used in an event plus the wild battle thing, it automatically sets pokemon move whatever value is stored in that var. It would be good if it can be toggleabe by flag or var.
http://www.pokecommunity.com/showpost.php?p=8942634&postcount=739

Lance32497

LanceKoijer of Pokemon_Addicts

Male
Criscanto town-Ginoa Region xD
Seen August 13th, 2017
Posted January 1st, 2017
792 posts
9.1 Years
thanks, gonna try tis' one
This signature has been disabled.
Scrollbar appears
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.

Spherical Ice

Age 25
Leicester, UK
Seen 38 Minutes Ago
Posted February 20th, 2022
5,251 posts
15.9 Years

Nature-affected stats colouring routines [FR]:


CLICK FOR EMERALD

This is probably the least efficient way to do this, but it works.

Attack:
.thumb
@ 00 49 08 47 XX XX XX XX at x137134

ldr r1, [r2]
ldrb r2,[r1,#4]
add r2,#0x32
lsl r2,r2,#0x18
lsr r2,r2,#0x18
push {r0-r3}
ldr r0, =(0x0203B140)
ldr r0, [r0]
ldr r2, =(0x3290)
add r0, r0, r2
mov r1, #0
bl decryptbranch
bl getnaturebranch
cmp r0, #1 @ Lonely
beq red
cmp r0, #2 @ Brave
beq red
cmp r0, #3 @ Adamant
beq red
cmp r0, #4 @ Naughty
beq red
cmp r0, #5 @ Bold
beq blue
cmp r0, #10 @ Timid
beq blue
cmp r0, #15 @ Modest
beq blue
cmp r0, #20 @ Calm
beq blue

black:
ldr r6, blackfont
b end

red:
ldr r6, redfont
b end

blue:
ldr r6, bluefont

end:
pop {r0-r3}
ldr r1, =(0x0813713c+1)
bx r1

decryptbranch:
ldr r2, =(0x0803FBE8+1)
bx r2

getnaturebranch:
ldr r2, =(0x08042EB4+1)
bx r2

.align 2
blackfont: .word 0x08463FA4 @ In a vanilla FR ROM, this contains: 00 0E 0A 00
redfont: .word 0x08RRRRRR @ ROM location that contains: 00 01 0A 00
bluefont: .word 0x08BBBBBB @ ROM location that contains: 00 07 0A 00
Defense:
.thumb
@ 00 49 08 47 XX XX XX XX at x137158

ldr r1, [r2]
ldrb r2,[r1,#6]
add r2,#0x32
lsl r2,r2,#0x18
lsr r2,r2,#0x18
push {r0-r3}
ldr r0, =(0x0203B140)
ldr r0, [r0]
ldr r2, =(0x3290)
add r0, r0, r2
mov r1, #0
bl decryptbranch
bl getnaturebranch
cmp r0, #1 @ Lonely
beq blue
cmp r0, #5 @ Nold
beq red
cmp r0, #7 @ Relaxed
beq red
cmp r0, #8 @ Impish
beq red
cmp r0, #9 @ Lax
beq red
cmp r0, #11 @ Hasty
beq blue
cmp r0, #16 @ Mild
beq blue
cmp r0, #21 @ Gentle
beq blue

black:
ldr r6, blackfont
b end

red:
ldr r6, redfont
b end

blue:
ldr r6, bluefont

end:
pop {r0-r3}
ldr r1, =(0x08137162+1)
bx r1

decryptbranch:
ldr r2, =(0x0803FBE8+1)
bx r2

getnaturebranch:
ldr r2, =(0x08042EB4+1)
bx r2

.align 2
blackfont: .word 0x08463FA4 @ In a vanilla FR ROM, this contains: 00 0E 0A 00
redfont: .word 0x08RRRRRR @ ROM location that contains: 00 01 0A 00
bluefont: .word 0x08BBBBBB @ ROM location that contains: 00 07 0A 00
Special Attack:
.thumb
@ 00 49 08 47 XX XX XX XX at x13717C

mov r2,r8
ldr r1, [r2]
ldrb r2,[r1,#8]
add r2,#0x32
lsl r2,r2,#0x18
lsr r2,r2,#0x18
push {r0-r3}
ldr r0, =(0x0203B140)
ldr r0, [r0]
ldr r2, =(0x3290)
add r0, r0, r2
mov r1, #0
bl decryptbranch
bl getnaturebranch
cmp r0, #3 @ Adamant
beq blue
cmp r0, #8 @ Impish
beq blue
cmp r0, #13 @ Jolly
beq blue
cmp r0, #15 @ Modest
beq red
cmp r0, #16 @ Mild
beq red
cmp r0, #17 @ Quiet
beq red
cmp r0, #19 @ Rash
beq red
cmp r0, #23 @ Careful
beq blue

black:
ldr r6, blackfont
b end

red:
ldr r6, redfont
b end

blue:
ldr r6, bluefont

end:
pop {r0-r3}
ldr r1, =(0x08137188+1)
bx r1

decryptbranch:
ldr r2, =(0x0803FBE8+1)
bx r2

getnaturebranch:
ldr r2, =(0x08042EB4+1)
bx r2

.align 2
blackfont: .word 0x08463FA4 @ In a vanilla FR ROM, this contains: 00 0E 0A 00
redfont: .word 0x08RRRRRR @ ROM location that contains: 00 01 0A 00
bluefont: .word 0x08BBBBBB @ ROM location that contains: 00 07 0A 00
Special Defense:
.thumb
@ 00 49 08 47 XX XX XX XX at x1371A4

ldr r1, [r2]
ldrb r2,[r1,#0xA]
add r2,#0x32
lsl r2,r2,#0x18
lsr r2,r2,#0x18
push {r0-r3}
ldr r0, =(0x0203B140)
ldr r0, [r0]
ldr r2, =(0x3290)
add r0, r0, r2
mov r1, #0
bl decryptbranch
bl getnaturebranch
cmp r0, #4 @ Naughty
beq blue
cmp r0, #9 @ Lax
beq blue
cmp r0, #14 @ Naive
beq blue
cmp r0, #19 @ Rash
beq blue
cmp r0, #20 @ Calm
beq red
cmp r0, #21 @ Gentle
beq red
cmp r0, #22 @ Sassy
beq red
cmp r0, #23 @ Careful
beq red

black:
ldr r6, blackfont
b end

red:
ldr r6, redfont
b end

blue:
ldr r6, bluefont

end:
pop {r0-r3}
ldr r1, =(0x081371AE+1)
bx r1

decryptbranch:
ldr r2, =(0x0803FBE8+1)
bx r2

getnaturebranch:
ldr r2, =(0x08042EB4+1)
bx r2

.align 2
blackfont: .word 0x08463FA4 @ In a vanilla FR ROM, this contains: 00 0E 0A 00
redfont: .word 0x08RRRRRR @ ROM location that contains: 00 01 0A 00
bluefont: .word 0x08BBBBBB @ ROM location that contains: 00 07 0A 00
Speed:
.thumb
@ 00 49 08 47 XX XX XX XX at x1371C8

mov r2,r8
ldr r1, [r2]
ldrb r2,[r1,#0xC]
add r2,#0x32
lsl r2,r2,#0x18
lsr r2,r2,#0x18
push {r0-r3}
ldr r0, =(0x0203B140)
ldr r0, [r0]
ldr r2, =(0x3290)
add r0, r0, r2
mov r1, #0
bl decryptbranch
bl getnaturebranch
cmp r0, #2 @ Brave
beq blue
cmp r0, #7 @ Relaxed
beq blue
cmp r0, #10 @ Timid
beq red
cmp r0, #11 @ Hasty
beq red
cmp r0, #13 @ Jolly
beq red
cmp r0, #14 @ Naive
beq red
cmp r0, #17 @ Quiet
beq blue
cmp r0, #22 @ Sassy
beq blue

black:
ldr r6, blackfont
b end

red:
ldr r6, redfont
b end

blue:
ldr r6, bluefont

end:
pop {r0-r3}
ldr r1, =(0x081371d4+1)
bx r1

decryptbranch:
ldr r2, =(0x0803FBE8+1)
bx r2

getnaturebranch:
ldr r2, =(0x08042EB4+1)
bx r2

.align 2
blackfont: .word 0x08463FA4 @ In a vanilla FR ROM, this contains: 00 0E 0A 00
redfont: .word 0x08RRRRRR @ ROM location that contains: 00 01 0A 00
bluefont: .word 0x08BBBBBB @ ROM location that contains: 00 07 0A 00
Reverting the font colour back to black:
.thumb
@ 00 49 08 47 XX XX XX XX at 081371F0

ldr r1, [r2]
ldrb r2,[r1,#0xE]
add r2,#0xF
lsl r2,r2,#0x18
lsr r2,r2,#0x18
ldr r6, blackfont
ldr r1, =(0x081371FA+1)
bx r1

.align 2
blackfont: .word 0x08463FA4 @ In a vanilla FR ROM, this contains: 00 0E 0A 00
where XX XX XX XX is the location of each routine +1.

This colours the stat increased by the Pokémon's nature red, and the stat that is decreased blue.



Edit: Updated 23/12/2015, the old routines had a few errors that I forgot to update after making changes to my ROM. I've also confirmed what bluefont should be in a vanilla ROM. Enjoy!

DoesntKnowHowToPlay

Tiny Umbrella with Lots and Lots of Good

Seen February 18th, 2023
Posted February 3rd, 2023
264 posts
11.7 Years
I've noticed significant demand for working Dawn Stone evolutions, specifically ones that require the mon to be a specific gender. My bad if this is already posted somewhere but here y'all go:

.org 0x4318e
lsl r0, r0, #0x0
ldr r2, .MethodAddr
bx r2

.MethodAddr: .word 0x085B2521 #UPDATE THIS TO MAIN FUNCTION OFFSET+1


.org 0x5B2520 #UPDATE THIS TO MOST CONVENIENT FREE SPACE IN YOUR HACK
cmp r0, #0x7
beq StandardStone
cmp r0, #0x14 #UPDATE THIS
beq MaleStone
cmp r0, #0x15 #UPDATE THIS
beq FemaleStone
b NoEvo

MaleStone:
push {r1-r3}
mov r0, r7
mov r1, r8
ldr r1, [r1, #0x0]
bl DetermineGender
pop {r1-r3}
cmp r0, #0x0
beq StandardStone
b NoEvo


FemaleStone:
push {r1-r3}
mov r0, r7
mov r1, r8
ldr r1, [r1, #0x0]
bl DetermineGender
pop {r1-r3}
cmp r0, #0xFE
beq StandardStone
b NoEvo


StandardStone:
ldrh r0, [r1, #0x2]
cmp r0, r9
beq Finish

NoEvo:
ldr r2, .NoEvoReturn
bx r2

DetermineGender:
ldr r2, .DetermineGenderFunc
bx r2

Finish:
ldr r2, .EvoReturn
bx r2

.NoEvoReturn: .word 0x08043199
.EvoReturn: .word 0x0804317d
.DetermineGenderFunc: .word 0x0803f78d
Change the values in the lines marked UPDATE THIS to the indexes of male stone evos and female stone evos. Leave their entries blank in the general evolution table; stone evolutions function differently from level-up evolutions.

Spherical Ice

Age 25
Leicester, UK
Seen 38 Minutes Ago
Posted February 20th, 2022
5,251 posts
15.9 Years

checkitem hack to store quantity in 0x8008


This is probably a relatively esoteric hack, but I found a use for it so I might as well share it. When using the checkitem command, it will now buffer the quantity of said item into the variable 0x8008, and then behaves as usual for the regular usage of the command.

The reason I made this was to do something like the following dummy script:

checkitem ITEM_BLUESHARD 0x1
if B_< goto @none
buffernumber 0x0 0x8008
msgbox @string1 0x6
...

#org @string1
= You have [buffer1] Blue Shards.
It will always buffer to 0x8008, but you can change the RAM loc in the routine if you want it to be some other variable.

.thumb

@ 00 4A 10 47 XX+1 XX XX XX at 08099f88

lsl r0,r0,#0x10
lsr r0,r0,#0x10
ldr r2, =(0x020370C8) @ RAM location of 0x8008
strh r0, [r2]
ldr r2, =(0x08099f58+1)
cmp r0, r5
bcs branch
ldr r2, =(0x08099f90+1)

branch:
bx r2

Shogun

I'll be back

Male
France
Seen June 8th, 2022
Posted June 9th, 2021
527 posts
9.8 Years

Nature-affected stats colouring routines [FR]:


This is probably the least efficient way to do this, but it works.

Attack:
.thumb
@ 00 49 08 47 XX XX XX XX at x137134

ldr r1, [r2]
ldrb r2,[r1,#4]
add r2,#0x32
lsl r2,r2,#0x18
lsr r2,r2,#0x18
push {r0-r3}
ldr r0, =(0x0203B140)
ldr r0, [r0]
ldr r2, =(0x3290)
add r0, r0, r2
mov r1, #0
bl decryptbranch
bl getnaturebranch
cmp r0, #1 @ Lonely
beq red
cmp r0, #2 @ Brave
beq red
cmp r0, #3 @ Adamant
beq red
cmp r0, #4 @ Naughty
beq red
cmp r0, #5 @ Bold
beq blue
cmp r0, #10 @ Timid
beq blue
cmp r0, #15 @ Modest
beq blue
cmp r0, #20 @ Calm
beq blue

black:
ldr r6, blackfont
b end

red:
ldr r6, redfont
b end

blue:
ldr r6, bluefont

end:
pop {r0-r3}
ldr r1, =(0x0813713c+1)
bx r1

decryptbranch:
ldr r2, =(0x0803FBE8+1)
bx r2

getnaturebranch:
ldr r2, =(0x08042EB4+1)
bx r2

.align 2
blackfont: .word 0x08463FA4 @ In a vanilla FR ROM, this contains: 00 0E 0A 00
redfont: .word 0x08RRRRRR @ ROM location that contains: 00 01 0A 00
bluefont: .word 0x08BBBBBB @ ROM location that contains: 00 07 0A 00
Defense:
.thumb
@ 00 49 08 47 XX XX XX XX at x137158

ldr r1, [r2]
ldrb r2,[r1,#6]
add r2,#0x32
lsl r2,r2,#0x18
lsr r2,r2,#0x18
push {r0-r3}
ldr r0, =(0x0203B140)
ldr r0, [r0]
ldr r2, =(0x3290)
add r0, r0, r2
mov r1, #0
bl decryptbranch
bl getnaturebranch
cmp r0, #1 @ Lonely
beq blue
cmp r0, #5 @ Nold
beq red
cmp r0, #7 @ Relaxed
beq red
cmp r0, #8 @ Impish
beq red
cmp r0, #9 @ Lax
beq red
cmp r0, #11 @ Hasty
beq blue
cmp r0, #16 @ Mild
beq blue
cmp r0, #21 @ Gentle
beq blue

black:
ldr r6, blackfont
b end

red:
ldr r6, redfont
b end

blue:
ldr r6, bluefont

end:
pop {r0-r3}
ldr r1, =(0x08137162+1)
bx r1

decryptbranch:
ldr r2, =(0x0803FBE8+1)
bx r2

getnaturebranch:
ldr r2, =(0x08042EB4+1)
bx r2

.align 2
blackfont: .word 0x08463FA4 @ In a vanilla FR ROM, this contains: 00 0E 0A 00
redfont: .word 0x08RRRRRR @ ROM location that contains: 00 01 0A 00
bluefont: .word 0x08BBBBBB @ ROM location that contains: 00 07 0A 00
Special Attack:
.thumb
@ 00 49 08 47 XX XX XX XX at x13717C

mov r2,r8
ldr r1, [r2]
ldrb r2,[r1,#8]
add r2,#0x32
lsl r2,r2,#0x18
lsr r2,r2,#0x18
push {r0-r3}
ldr r0, =(0x0203B140)
ldr r0, [r0]
ldr r2, =(0x3290)
add r0, r0, r2
mov r1, #0
bl decryptbranch
bl getnaturebranch
cmp r0, #3 @ Adamant
beq blue
cmp r0, #8 @ Impish
beq blue
cmp r0, #13 @ Jolly
beq blue
cmp r0, #15 @ Modest
beq red
cmp r0, #16 @ Mild
beq red
cmp r0, #17 @ Quiet
beq red
cmp r0, #19 @ Rash
beq red
cmp r0, #23 @ Careful
beq blue

black:
ldr r6, blackfont
b end

red:
ldr r6, redfont
b end

blue:
ldr r6, bluefont

end:
pop {r0-r3}
ldr r1, =(0x08137188+1)
bx r1

decryptbranch:
ldr r2, =(0x0803FBE8+1)
bx r2

getnaturebranch:
ldr r2, =(0x08042EB4+1)
bx r2

.align 2
blackfont: .word 0x08463FA4 @ In a vanilla FR ROM, this contains: 00 0E 0A 00
redfont: .word 0x08RRRRRR @ ROM location that contains: 00 01 0A 00
bluefont: .word 0x08BBBBBB @ ROM location that contains: 00 07 0A 00
Special Defense:
.thumb
@ 00 49 08 47 XX XX XX XX at x1371A4

ldr r1, [r2]
ldrb r2,[r1,#0xA]
add r2,#0x32
lsl r2,r2,#0x18
lsr r2,r2,#0x18
push {r0-r3}
ldr r0, =(0x0203B140)
ldr r0, [r0]
ldr r2, =(0x3290)
add r0, r0, r2
mov r1, #0
bl decryptbranch
bl getnaturebranch
cmp r0, #4 @ Naughty
beq blue
cmp r0, #9 @ Lax
beq blue
cmp r0, #14 @ Naive
beq blue
cmp r0, #19 @ Rash
beq blue
cmp r0, #20 @ Calm
beq red
cmp r0, #21 @ Gentle
beq red
cmp r0, #22 @ Sassy
beq red
cmp r0, #23 @ Careful
beq red

black:
ldr r6, blackfont
b end

red:
ldr r6, redfont
b end

blue:
ldr r6, bluefont

end:
pop {r0-r3}
ldr r1, =(0x081371AE+1)
bx r1

decryptbranch:
ldr r2, =(0x0803FBE8+1)
bx r2

getnaturebranch:
ldr r2, =(0x08042EB4+1)
bx r2

.align 2
blackfont: .word 0x08463FA4 @ In a vanilla FR ROM, this contains: 00 0E 0A 00
redfont: .word 0x08RRRRRR @ ROM location that contains: 00 01 0A 00
bluefont: .word 0x08BBBBBB @ ROM location that contains: 00 07 0A 00
Speed:
.thumb
@ 00 49 08 47 XX XX XX XX at x1371C8

mov r2,r8
ldr r1, [r2]
ldrb r2,[r1,#0xC]
add r2,#0x32
lsl r2,r2,#0x18
lsr r2,r2,#0x18
push {r0-r3}
ldr r0, =(0x0203B140)
ldr r0, [r0]
ldr r2, =(0x3290)
add r0, r0, r2
mov r1, #0
bl decryptbranch
bl getnaturebranch
cmp r0, #2 @ Brave
beq blue
cmp r0, #7 @ Relaxed
beq blue
cmp r0, #10 @ Timid
beq red
cmp r0, #11 @ Hasty
beq red
cmp r0, #13 @ Jolly
beq red
cmp r0, #14 @ Naive
beq red
cmp r0, #17 @ Quiet
beq blue
cmp r0, #22 @ Sassy
beq blue

black:
ldr r6, blackfont
b end

red:
ldr r6, redfont
b end

blue:
ldr r6, bluefont

end:
pop {r0-r3}
ldr r1, =(0x081371d4+1)
bx r1

decryptbranch:
ldr r2, =(0x0803FBE8+1)
bx r2

getnaturebranch:
ldr r2, =(0x08042EB4+1)
bx r2

.align 2
blackfont: .word 0x08463FA4 @ In a vanilla FR ROM, this contains: 00 0E 0A 00
redfont: .word 0x08RRRRRR @ ROM location that contains: 00 01 0A 00
bluefont: .word 0x08BBBBBB @ ROM location that contains: 00 07 0A 00
Reverting the font colour back to black:
.thumb
@ 00 49 08 47 XX XX XX XX at 081371F0

ldr r1, [r2]
ldrb r2,[r1,#0xE]
add r2,#0xF
lsl r2,r2,#0x18
lsr r2,r2,#0x18
ldr r6, blackfont
ldr r1, =(0x081371FA+1)
bx r1

.align 2
blackfont: .word 0x08463FA4 @ In a vanilla FR ROM, this contains: 00 0E 0A 00
where XX XX XX XX is the location of each routine +1.

This colours the stat increased by the Pokémon's nature red, and the stat that is decreased blue.



Edit: Updated 23/12/2015, the old routines had a few errors that I forgot to update after making changes to my ROM. I've also confirmed what bluefont should be in a vanilla ROM. Enjoy!

I don't know why but for me it doesn't works.
I've replaced the XX XX XX XX with the following pointers for each routines
Spoiler:
All these offsets are +1 offsets and same things for pointers

Attack : Offset CFAEC1 >>> pointer C1 AE CF 08

Defense : Offset CFAE41 >>> pointer 41 AE CF 08

Sp.atk : Offset CFADA1 >>> pointer A1 AD CF 08

Sp.Def : Offset CFAD21 >>> pointer 21 AD CF 08

Speed : Offset CFACA1 >>> pointer A1 AC CF 08

reverting font : Offset CFAE21 >>> pointer 21 AE CF 08


After that, I have replace the two last lines for each of them except for the last one (reverting font) with that :
Spoiler:
redfont: .word 0x0847C825 @ ROM location that contains: 00 01 0A 00
bluefont: .word 0x0834F840 @ ROM location that contains: 00 07 0A 00


I've test it with a calm bulbasaur but everything stay black. No blue colour or red colour.
Seen November 20th, 2016
Posted November 20th, 2016
417 posts
8.6 Years
I don't know why but for me it doesn't works.
I've replaced the XX XX XX XX with the following pointers for each routines
Spoiler:
All these offsets are +1 offsets and same things for pointers

Attack : Offset CFAEC1 >>> pointer C1 AE CF 08

Defense : Offset CFAE41 >>> pointer 41 AE CF 08

Sp.atk : Offset CFADA1 >>> pointer A1 AD CF 08

Sp.Def : Offset CFAD21 >>> pointer 21 AD CF 08

Speed : Offset CFACA1 >>> pointer A1 AC CF 08

reverting font : Offset CFAE21 >>> pointer 21 AE CF 08


After that, I have replace the two last lines for each of them except for the last one (reverting font) with that :
Spoiler:
redfont: .word 0x0847C825 @ ROM location that contains: 00 01 0A 00
bluefont: .word 0x0834F840 @ ROM location that contains: 00 07 0A 00


I've test it with a calm bulbasaur but everything stay black. No blue colour or red colour.
When trying to figure out a problem, always state what rom you are modding...
Aslo I can tell you that you didn't do +1 with your reverse Hex...
ergo "Attack : Offset CFAEC1 >>> pointer C1 AE CF 08" should look like
"Attack : Offset CFAEC1 >>> pointer C2 AE CF 08"
That isn't how it works either. The asm itself needs to be halfword aligned for the opcodes. The +1 is to branch in THUMB mode. Therefore, on top of the opcodes not being aligned, you'd be branching to 0x08CFAEC2 in ARM (which also makes no sense because ARM is four bytes per instruction). The problem is that the bin should be pasted at 0xCFAEC0.

Shogun

I'll be back

Male
France
Seen June 8th, 2022
Posted June 9th, 2021
527 posts
9.8 Years
That isn't how it works either. The asm itself needs to be halfword aligned for the opcodes. The +1 is to branch in THUMB mode. Therefore, on top of the opcodes not being aligned, you'd be branching to 0x08CFAEC2 in ARM (which also makes no sense because ARM is four bytes per instruction). The problem is that the bin should be pasted at 0xCFAEC0.
No. I've found my error. It was in the line about the redfont and the bluefont offsets but now here is the result

Lance32497

LanceKoijer of Pokemon_Addicts

Male
Criscanto town-Ginoa Region xD
Seen August 13th, 2017
Posted January 1st, 2017
792 posts
9.1 Years
Guys, I really really need this routine, I know it wouldn't be hard for you, I got a bug on my rom and I made a lot of changes in that. The bug is the TM and HM, it doesn't really work properly.

So my request is a routine that checks if that pokemon can learn a certain move, var 8004 fpr the Pokemon Specie and var 8005 for the move to check, then that routine will check the table of learnable moves of that Pokèmon.
This signature has been disabled.
Scrollbar appears
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
Seen November 20th, 2016
Posted November 20th, 2016
417 posts
8.6 Years
Guys, I really really need this routine, I know it wouldn't be hard for you, I got a bug on my rom and I made a lot of changes in that. The bug is the TM and HM, it doesn't really work properly.

So my request is a routine that checks if that pokemon can learn a certain move, var 8004 fpr the Pokemon Specie and var 8005 for the move to check, then that routine will check the table of learnable moves of that Pokèmon.
I'd say fixing the TM bag would be the better option, but
	ldr r3, var8004
	ldrh r0, [r3, #0x0]
	lsl r0, r0, #0x3 @assuming length of tm compatibility is still 8 bytes
	ldr r1, tm_compatibility
	add r0, r1
	ldrh r2, [r3, #0x2]	@var8005
	lsr r1, r2, #0x3 @I assume “move” is tm number, not the actual move index?
	ldrb r0, [r0, r1]
	lsl r2, r2, #0x1D
	lsr r2, r2, #0x1D
	lsr r0, r0, r2
	lsl r0, r0, #0x1F
	lsr r0, r0, #0x1F
	strh r0, [r3, 0x0]	@store back in var8004, or wherever
	bx lr
.align
var8004:		.word 0x Donotknowoffsetoffthetopofmyhead
tm_compatibility:	.word 0x WhereverYouPutIt

Lance32497

LanceKoijer of Pokemon_Addicts

Male
Criscanto town-Ginoa Region xD
Seen August 13th, 2017
Posted January 1st, 2017
792 posts
9.1 Years
I'd say fixing the TM bag would be the better option, but
	ldr r3, var8004
	ldrh r0, [r3, #0x0]
	lsl r0, r0, #0x3 @assuming length of tm compatibility is still 8 bytes
	ldr r1, tm_compatibility
	add r0, r1
	ldrh r2, [r3, #0x2]	@var8005
	lsr r1, r2, #0x3 @I assume “move” is tm number, not the actual move index?
	ldrb r0, [r0, r1]
	lsl r2, r2, #0x1D
	lsr r2, r2, #0x1D
	lsr r0, r0, r2
	lsl r0, r0, #0x1F
	lsr r0, r0, #0x1F
	strh r0, [r3, 0x0]	@store back in var8004, or wherever
	bx lr
.align
var8004:		.word 0x Donotknowoffsetoffthetopofmyhead
tm_compatibility:	.word 0x WhereverYouPutIt
Thank you very much, this is helpful indeed. Anyway I expanded the number of TM so do I have to change some values there? And
var 8004 is the Pokèmon number and Var 8005 is the TM Number, let's say TM32, it would be 20, then, in var 8004, it will state whether it's 1,l earnable or 0, not learnable
This signature has been disabled.
Scrollbar appears
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
Seen November 20th, 2016
Posted November 20th, 2016
417 posts
8.6 Years
Thank you very much, this is helpful indeed. Anyway I expanded the number of TM so do I have to change some values there? And
var 8004 is the Pokèmon number and Var 8005 is the TM Number, let's say TM32, it would be 20, then, in var 8004, it will state whether it's 1,l earnable or 0, not learnable
I'm guessing that you meant to say "TM32, it would be 0x20" which would be almost correct. TM indexing starts at zero, so the index for TM01 is 0x00, TM02 is 0x01, ..., TM32 is 0x1F (31 decimal). The answer to the TM expansion depends on exactly what your TM compatibility table looks like, specifically how long an entry is for a species. In the regular game, the table is 8 bytes long (64 bits) so I used the instruction
lsl r0, r0, #0x3 @assuming length of tm compatibility is still 8 bytes
Because that shift is multiplying species index by eight.
As for var8004 at the end of routine, yes. After the routine, var8004 will contain 0 for incompatible and 1 for compatible.

Lance32497

LanceKoijer of Pokemon_Addicts

Male
Criscanto town-Ginoa Region xD
Seen August 13th, 2017
Posted January 1st, 2017
792 posts
9.1 Years
I'm guessing that you meant to say "TM32, it would be 0x20" which would be almost correct. TM indexing starts at zero, so the index for TM01 is 0x00, TM02 is 0x01, ..., TM32 is 0x1F (31 decimal). The answer to the TM expansion depends on exactly what your TM compatibility table looks like, specifically how long an entry is for a species. In the regular game, the table is 8 bytes long (64 bits) so I used the instruction
lsl r0, r0, #0x3 @assuming length of tm compatibility is still 8 bytes
Because that shift is multiplying species index by eight.
As for var8004 at the end of routine, yes. After the routine, var8004 will contain 0 for incompatible and 1 for compatible.
The new compatibility contains 16 bytes, (128 bits) soI'll make it
lsl r0, r0, #0x4
I got it now, thanks a lot.
This signature has been disabled.
Scrollbar appears
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.

Lance32497

LanceKoijer of Pokemon_Addicts

Male
Criscanto town-Ginoa Region xD
Seen August 13th, 2017
Posted January 1st, 2017
792 posts
9.1 Years
Could anyone port the Ability Switching to Emerald? Unless I missed it somewhere...
http://www.pokecommunity.com/showpost.php?p=8533505&postcount=278
I haven't tested it yet

Ability switching: EMERALD



Very simple, it turned out to not have to adjust the PID.

How to insert:

Just compile the following routine into free space:

Spoiler:

.text
.align 2
.thumb
.thumb_func


main:
	push {r0-r4, lr}
	ldr r1, =(0x20270C0) @var 0x8004
	ldrb r1, [r1]
	mov r2, #0x64
	mul r1, r1, r2
	ldr r0, =(0x2024190)
	add r0, r0, r1 @slot
	mov r4, r0 @save slot
	mov r1, #0x2E
	ldr r3, =(0x806a518 +1)
	bl linker
	cmp r0, #0x1
	beq setZero
	mov r0, #0x1
	b setNew

setZero:
	mov r0, #0x0
	
setNew:
	lsl r0, r0, #0x18
	lsr r0, r0, #0x18
	ldr r2, =(0x20270D0) @set inverse
	strb r0, [r2]
	mov r0, r4
	mov r1, #0x2E
	ldr r3, =(0x8008b44 +1)
	bl linker
	pop {r0-r4, pc}

linker:
	bx r3

.align 2


Usage:

Set in variable 0x8004 the slot number of the Pokemon who's ability you want to swap. Note that Pokemon with only 1 ability won't have their abilities swapped.
This signature has been disabled.
Scrollbar appears
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
Male
Seen July 18th, 2016
Posted January 14th, 2016
199 posts
12 Years
I haven't tested it yet

Ability switching: EMERALD



Very simple, it turned out to not have to adjust the PID.

How to insert:

Just compile the following routine into free space:

Spoiler:

.text
.align 2
.thumb
.thumb_func


main:
	push {r0-r4, lr}
	ldr r1, =(0x20270C0) @var 0x8004
	ldrb r1, [r1]
	mov r2, #0x64
	mul r1, r1, r2
	ldr r0, =(0x2024190)
	add r0, r0, r1 @slot
	mov r4, r0 @save slot
	mov r1, #0x2E
	ldr r3, =(0x806a518 +1)
	bl linker
	cmp r0, #0x1
	beq setZero
	mov r0, #0x1
	b setNew

setZero:
	mov r0, #0x0
	
setNew:
	lsl r0, r0, #0x18
	lsr r0, r0, #0x18
	ldr r2, =(0x20270D0) @set inverse
	strb r0, [r2]
	mov r0, r4
	mov r1, #0x2E
	ldr r3, =(0x8008b44 +1)
	bl linker
	pop {r0-r4, pc}

linker:
	bx r3

.align 2


Usage:

Set in variable 0x8004 the slot number of the Pokemon who's ability you want to swap. Note that Pokemon with only 1 ability won't have their abilities swapped.
Tried it with a dual ability Pokemon and didn't change.
=\ Any ideas?

Lance32497

LanceKoijer of Pokemon_Addicts

Male
Criscanto town-Ginoa Region xD
Seen August 13th, 2017
Posted January 1st, 2017
792 posts
9.1 Years
Tried it with a dual ability Pokemon and didn't change.
=\ Any ideas?
I'll try to look at that, perhaps one of the addresses is incorrect.

I'd say fixing the TM bag would be the better option, but
	ldr r3, var8004
	ldrh r0, [r3, #0x0]
	lsl r0, r0, #0x3 @assuming length of tm compatibility is still 8 bytes
	ldr r1, tm_compatibility
	add r0, r1
	ldrh r2, [r3, #0x2]	@var8005
	lsr r1, r2, #0x3 @I assume “move” is tm number, not the actual move index?
	ldrb r0, [r0, r1]
	lsl r2, r2, #0x1D
	lsr r2, r2, #0x1D
	lsr r0, r0, r2
	lsl r0, r0, #0x1F
	lsr r0, r0, #0x1F
	strh r0, [r3, 0x0]	@store back in var8004, or wherever
	bx lr
.align
var8004:		.word 0x Donotknowoffsetoffthetopofmyhead
tm_compatibility:	.word 0x WhereverYouPutIt
Tried this one, but it doesn't work correctly, I modified the routine because it doesn't compile to my compiler
Spoiler:

.align 2
.thumb

main:
	ldr r3, var8004
	ldrh r0, [r3, #0x0]
	lsl r0, r0, #0x4 @assuming length of tm compatibility is still 8 bytes
	ldr r1, tm_compatibility
	add r0, r1
	ldrh r2, [r3, #0x2]	@var8005
	lsr r1, r2, #0x3 @I assume “move” is tm number, not the actual move index?
	ldrb r0, [r0, r1]
	lsl r2, r2, #0x1D
	lsr r2, r2, #0x1D
	lsr r0, r0, r2
	lsl r0, r0, #0x1F
	lsr r0, r0, #0x1F
	strh r0, [r3, 0x0]	@store back in var8004, or wherever
	bx lr

.align 2

var8004:		.word 0x20370C0
tm_compatibility:	.word 0x9859940


I changed that to 4 since I had expanded the TM and HM, then, this is my script:
Spoiler:

'---------------
#org 0x8213AD
setvar 0x8004 0x14E
setvar 0x8005 0x1F
callasm 0x9921521
compare 0x8004 0x0
if 0x1 goto 0x88213D1
msgbox 0x88213E0 MSG_NORMAL '"yes"
end

'---------------
#org 0x8213D1
msgbox 0x88213DB MSG_NORMAL '"no"
end


'---------
' Strings
'---------
#org 0x8213E0
= yes

#org 0x8213DB
= no

Var 8004 being the index number of Flygon
and Var 8005 being the TM index which is TM 32 Double Team, it always jumps to YES even though I unchecked it.
This signature has been disabled.
Scrollbar appears
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
Seen November 20th, 2016
Posted November 20th, 2016
417 posts
8.6 Years
I'll try to look at that, perhaps one of the addresses is incorrect.



Tried this one, but it doesn't work correctly, I modified the routine because it doesn't compile to my compiler
Spoiler:

.align 2
.thumb

main:
	ldr r3, var8004
	ldrh r0, [r3, #0x0]
	lsl r0, r0, #0x4 @assuming length of tm compatibility is still 8 bytes
	ldr r1, tm_compatibility
	add r0, r1
	ldrh r2, [r3, #0x2]	@var8005
	lsr r1, r2, #0x3 @I assume “move” is tm number, not the actual move index?
	ldrb r0, [r0, r1]
	lsl r2, r2, #0x1D
	lsr r2, r2, #0x1D
	lsr r0, r0, r2
	lsl r0, r0, #0x1F
	lsr r0, r0, #0x1F
	strh r0, [r3, 0x0]	@store back in var8004, or wherever
	bx lr

.align 2

var8004:		.word 0x20370C0
tm_compatibility:	.word 0x9859940


I changed that to 4 since I had expanded the TM and HM, then, this is my script:
Spoiler:

'---------------
#org 0x8213AD
setvar 0x8004 0x14E
setvar 0x8005 0x1F
callasm 0x9921521
compare 0x8004 0x0
if 0x1 goto 0x88213D1
msgbox 0x88213E0 MSG_NORMAL '"yes"
end

'---------------
#org 0x8213D1
msgbox 0x88213DB MSG_NORMAL '"no"
end


'---------
' Strings
'---------
#org 0x8213E0
= yes

#org 0x8213DB
= no

Var 8004 being the index number of Flygon
and Var 8005 being the TM index which is TM 32 Double Team, it always jumps to YES even though I unchecked it.
Wait, I don't even see what you changed with my routine besides putting actual numbers in the literal pool.
Also, you saying you "unchecked it" makes me think you were modifying compatibility with a tool. But I don't think any tools currently out even support expanding TMs. You most likely had to expand the table by hand. Did you actually change the length of the compatibility table from 8 bytes per pokemon to 16 bytes?

Lance32497

LanceKoijer of Pokemon_Addicts

Male
Criscanto town-Ginoa Region xD
Seen August 13th, 2017
Posted January 1st, 2017
792 posts
9.1 Years
Wait, I don't even see what you changed with my routine besides putting actual numbers in the literal pool.
Also, you saying you "unchecked it" makes me think you were modifying compatibility with a tool. But I don't think any tools currently out even support expanding TMs. You most likely had to expand the table by hand. Did you actually change the length of the compatibility table from 8 bytes per pokemon to 16 bytes?
I made lsl r0, r0, #0x3 to lsl r0, r0, #0x4, and about the tool that supports expansion of TM, D&D Editor of Dark Zeta does that
This signature has been disabled.
Scrollbar appears
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
Seen November 20th, 2016
Posted January 12th, 2016
7 posts
8.2 Years
I have tried all weekend and I cant get it. If anyone has the time, Id like some help with the following:
ASM script to check and see if a Pokemon has any moves left in the Pokemon Relearner.

Things I know:
Special 0xDB pulls up a selection to select a pokemon
0x8005 stores 0 if the pokemon has no moves to learn (From Two Island Move relearner)

Not that great at finding code with breakpoints... So i need some help to intercept the above so that when I call the ASM script it will take in the party position and output if there is a move or not. (Basically special DB without thee selection screen + Waitstate)

Thanks
Male
Antarctica
Seen April 1st, 2020
Posted September 26th, 2017
326 posts
9.5 Years
I have tried all weekend and I cant get it. If anyone has the time, Id like some help with the following:
ASM script to check and see if a Pokemon has any moves left in the Pokemon Relearner.

Things I know:
Special 0xDB pulls up a selection to select a pokemon
0x8005 stores 0 if the pokemon has no moves to learn (From Two Island Move relearner)

Not that great at finding code with breakpoints... So i need some help to intercept the above so that when I call the ASM script it will take in the party position and output if there is a move or not. (Basically special DB without thee selection screen + Waitstate)

Thanks
I'm not sure why you'd want this, as without special 0xDB you'd always be searching the first pokemon in your party. On top of that, you'd probably end up storing the results back into a var anyway. If the special and 0x8005 works, why fix something that's not broken?
Seen November 20th, 2016
Posted January 12th, 2016
7 posts
8.2 Years
Well it's not broken but its inconvenient. I have the party position of the pokemon already from previous code, but then to ask the user to select the pokemon in question again is redundant.

Maybe I did a poor job in explaining. What I am after is to mimic the above special 0xDB but skip the selection screen and instead input the variable for party position. I can do most of the work. Just need help locating where the code is located in the ROM. Then I can make a hook & catch.