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)

GoGoJJTech April 19th, 2016 1:28 PM

Quote:

Originally Posted by BLAx501! (Post 9209559)
I'm not sure if it's done yet or not, but... Would it be possible to have a routine that acts like a warp but enables you to choose bank, map and possition via variables instead of fixed parameters like the actual commando on XSE (and similar)

The normal warp commands parse the variables for X and Y coords. Just get it to do the same for the first three parameters instead of just taking them as they are.

Ayonn- April 20th, 2016 5:23 AM

I have two questions:
Did anyone try to increase the storage capacity of the PC in Fire Red ?

Is there a ASM routine for fire red to randomize Wild pokemon and the Trainers pokemon ?

mamamama April 21st, 2016 6:11 AM

Quote:

Originally Posted by DoesntKnowHowToPlay (Post 9043968)
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:

Code:

cmp r0, #0x7
beq StandardStone
cmp r0, #0x14 #UPDATE THIS
beq MaleStone
cmp r0, #0x15 #UPDATE THIS



1. Are 0x14/0x15 supposed to be the index-numbers of the evolved or the un-evolved Pokemon? (ie Snorunt or Frosslass?)
2. I can't compile with Pokemon above 255 (FF). Is there a way around this?

Thanks!

BluRose April 21st, 2016 9:55 AM

Quote:

Originally Posted by mamamama (Post 9211357)
1. Are 0x14/0x15 supposed to be the index-numbers of the evolved or the un-evolved Pokemon? (ie Snorunt or Frosslass?)
2. I can't compile with Pokemon above 255 (FF). Is there a way around this?

Thanks!

0x14 and 0x15 are going to be the index numbers of the evolution method (Male Stone and Female Stone, respectively). For example, the original Stone evolution method is index 0x07.

EDIT: At least, it looks like it, haha...

Zero.4 April 27th, 2016 4:14 AM

Hey there FBI, I want to know if you know about a routine for the bonguri trees in FR, or if you have created one, thanks in advance

jiangzhengwenjzw May 6th, 2016 4:13 AM

Misc:

Evolution via Callasm in FR


Spoiler:
I will show you the GIF result of the hack:
http://i869.photobucket.com/albums/ab256/jiangzhengwenjz/Untitled_zpsklaexwbz.gif
Firstly, we just insert a function at 0xYYYYYY:
Code:

.thumb
push {r4, lr}
ldr r0, =0x300537C
ldr r1, =0x80568E1
str r1, [r0]
ldr r0, =0x020370C0
ldrh r1, [r0, #2]
mov r2, #1
ldrh r3, [r0, #0x10]
ldr r4, =0x80cdda9
bl bx_r4
pop {r4, pc}
bx_r4: bx r4


After that we should insert another function at 0xZZZZZZ:
Code:

.thumb
push {r4, lr}
mov r4, #0
loop:
ldr r0, =0x02024284
mov r1, #0x64
mul r1, r4
add r0, r0, r1
mov r1, #0xb
ldr r2, =0x803FBE9
bl bx_r2
ldr r1, =0x20370C0
ldrh r2, [r1]
cmp r0, r2
beq have_pre
add r4, #1
cmp r4, #6
bne loop

no_pokemon:
mov r4, #0xFF
b back

increment:
add r4, #1
cmp r4, #6
beq no_pokemon
b loop

have_pre:
ldr r0, =0x2024284
mov r1, #0x64
mul r1, r4
add r0, r0, r1
mov r1, #0x2d
ldr r2, =0x803FBE9
bl bx_r2
ldr r1, =0x20370C0
cmp r0, #1
beq increment

back:
strh r4, [r1, #0x10]
pop {r4, pc}
bx_r2:
bx r2


To use it via a script:
Code:

#org @start
lock
faceplayer
setvar 0x8004 0x4 //the species number of pokemon you want it to evolve(here's chamander)
setvar 0x8005 0x2 //the species number of pokemon after evolution(here's ivysaur)
callasm 0x8ZZZZZZ+1 //check the slot number of the pokemon
compare 0x800D 0xFF //check if the pokemon exists in the player's party
if1 1 @no_that_pokemon
callasm 0x8YYYYYY+1 //evolution
waitstate
//setweather 3 //you can define other events after waitstate
//doweather
release
end

//---------------
#org @no_that_pokemon
msgbox @message_string 6 //"You don't have that pokemon. "
release
end

//---------
// Strings
//---------
#org @message_string
= You don't have that pokemon.


Note: Only the first pokemon in your party with the species number in 0x8004 will evolve. I think that's better.

A EV-IV Display Screen


FIRERED:
Link Removed!
EMERALD:
Link Removed!
I'm surprised that this one was abused in this forum. These repos were written when I was a complete noob for the sake of practice and I really feel ashamed. Pls, don't use them. If you really need them, go ahead to my github account and they're still available.

Quick Preview:
http://i869.photobucket.com/albums/ab256/jiangzhengwenjz/q_zpshnquzant.gifhttps://i.imgur.com/18HjHg0.png
OLD CONTENT (Outdated):
Spoiler:
Quick Preview:
http://i869.photobucket.com/albums/ab256/jiangzhengwenjz/q_zpshnquzant.gif
Download:
LINK REMOVED
Usage:
1. Make sure that you have Devkitarm and GNU make/cygwin installed.
2. Download this repo and create a new folder called "build".
3. Assign the free space you want to use in linker.lsc.
4. Open your cmd prompt and type in make. Then press enter.
5. Now main.bin should be generated. Paste it to the offset specified in step3.
6. Write a script to test (You should callasm to the offset of insertion + 0x79).
Code:

Example:
lock
faceplayer
callasm 0x8800079 //I inserted the code at 0x8800000
msgbox 0x8FD0013 0x2 //"It's nice, huh?"
releaseall
end



80x80 mugshots


Spoiler:
Intro:
In Ruby, many hackers uses the BG0 to make mugshots. However, the same way that simply writing tileset, tilemap and palette to the RAM won't work for FR & EM as it will be cleared by the MSGBOX.

However, there's still a way to do it, which requires the knowledge of "rboxes". I've figured out some simple usage of the related functions, so I will show you my work:
http://i869.photobucket.com/albums/ab256/jiangzhengwenjz/1636%20-%20Pokemon%20-%20Fire%20Red%20Version_zpsryxoq5ye.png

The most ****ing thing should be that only 1 BG palette for FR can be used, which is the palette for the money box (the box with thinner border). Therefore, it will only be able to launch 1 mugshot at a time and you can't use it with the money box!

How to use:
The routines are provided at the bottom.
1. Change 0x8900000 in mugshot_make.asm to free space, which is ended in 0,4,8,c. It will be the location of our custom table.
2. Compile the 2 routines and insert them to some free space (Not the table location in step 1)
3. Get/draw some 80x80 mugshots, here's 2 examples:
http://i.imgur.com/8Z0ppvU.pnghttp://i.imgur.com/5bRm9Vg.png
They should be indexed to 16 colors.
4. Open your UNLZ-GBA and insert your images and palettes.
Note: the image and the palette should all be LZ77 compressed, which means that you should insert them by using "export image" and "export palette" in UNLZ-GBA. Aparrently they should all be inserted at some free space.
5. Build the table at the offset in step 1, whose format should be [image0 pointer][image0 pal pointer][image1 pointer][image1 pal pointer][image2 pointer][image2 pal pointer]...................
It can load up to 65536 images in algorithm, which means that it's enough.
6. Test time! use
setvar 0x8004 [image index in the table]
setvar 0x8005 [0 or 1] // 0 = left, 1 = right
callasm 0x8[mugshot_make.asm+1]
to launch the mugshot and
callasm 0x8[mugshot_del.asm+1] to delete it.

An example:
I insert the 2 images at 0xFA0000, 0xFA09CC and the 2 palettes at 0xFA09A4, 0xFA1484. Then the table should be:
Code:

00 00 FA 08 A4 09 FA 08 CC 09 FA 08 84 14 FA 08


The script:
Code:

//---------------
#org 0xF00000
lock
setvar 0x8004 0x0 //image0
setvar 0x8005 0x1 //right side
callasm 0x8800001 //mugshot_make.asm+1
msgbox 0x8F00030 0x6
callasm 0x8800089 //mugshot_del.asm+1
release
end

#org 0xF00030
= ABCD.


The routines:
mugshot_make.asm:
Code:

/*
Note: both image and palette should be LZ77 compressed!
Table format: [image pointer][pal pointer]..........
*/
.equiv table_location, 0x8900000
.thumb
push {r4-r5, lr}
sub sp, sp, #0x18
ldr r0, =0x20370C0
ldrh r0, [r0, #2]
mov r1, #0
mov r2, #0x14
mul r2, r0
mov r3, #4
mov r0, #10
str r0, [sp]
str r0, [sp, #4]
mov r0, #0xD
str r0, [sp, #8]
mov r0, #0x40
str r0, [sp, #0xC]
add r0, sp, #0x10
ldr r4, =0x810FE51
bl bx_r4
add r0, sp, #0x10
ldr r4, =0x8003CE5
bl bx_r4
ldr r4, =0x2039990
strb r0, [r4]
ldr r4, =0x8003FA1
bl bx_r4
ldr r0, =0x20370C0
ldrh r0, [r0]
ldr r1, =table_location
lsl r0, r0, #3
add r0, r0, r1
ldr r5, [r0, #4]
ldr r0, [r0]
ldr r1, =0x6008800
swi 0x12
mov r0, r5
mov r1, #0xd0
mov r2, #0x20
ldr r4, =0x80703A9
bl bx_r4
mov r0, #0
ldr r4, =0x80020BD
bl bx_r4
add sp, sp, #0x18
pop {r4-r5, pc}

bx_r4: bx r4


mugshot_del.asm:
Code:

.thumb
push {r4, lr}
ldr r4, =0x2039990
ldrb r4, [r4]
mov r1, #0
mov r0, r4
ldr r3, =0x810F4D9
bl bx_r3
mov r0, r4
mov r1, #2
ldr r3, =0x8003F21
bl bx_r3
mov r0, r4
ldr r3, =0x8003E3D
bl bx_r3
pop {r4, pc}

bx_r3: bx r3



Some new movement bytes (including a patch)


Spoiler:
The patch will write new data to the offset 0xF80000, so make sure that area of your hack has not been used yet. Here's the download link:
http://www.mediafire.com/download/hfb2s47jq3k4oow/movements.ips

I haven't tested much on this hack, so it may have some bugs but you can modify it on your own as I've released the source code at the bottom.

The new bytes are:
Code:

0xAA - move up backwards (very slow)
0xAB - move down backwards (very slow)
0xAC - move right backwards (very slow)
0xAD - move left backwards (very slow)
0xAE - move up backwards (slow)
0xAF - move down backwards (slow)
0xB0 - move right backwards (slow)
0xB1 - move left backwards (slow)
0xB2 - move up backwards (normal)
0xB3 - move down backwards (normal)
0xB4 - move right backwards (normal)
0xB5 - move left backwards (normal)
0xB6 - move up backwards (fast)
0xB7 - move down backwards (fast)
0xB8 - move right backwards (fast)
0xB9 - move left backwards (fast)
0xBA - jump up backwards (2 squares)
0xBB - jump down backwards (2 squares)
0xBC - jump right backwards (2 squares)
0xBD - jump left backwards (2 squares)
0xBE - jump up backwards (1 square)
0xBF - jump down backwards (1 square)
0xC0 - jump right backwards (1 square)
0xC1 - jump left backwards (1 square)
0xC2 - face down and move left-down (normal)
0xC3 - face up and move left-up (normal)
0xC4 - face left and move left-down (normal)
0xC5 - face right and move right-down (normal)
0xC6 - face down and move right-down (normal)
0xC7 - face up and move right-up (normal)
0xC8 - face left and move left-up (normal)
0xC9 - face right and move right-up (normal)


Here's a picture including all the bytes above in a script:
http://i869.photobucket.com/albums/ab256/jiangzhengwenjz/1_zps4xafcixu.gif

The diagonal ones (0xc2~0xc9) can be used in some kind of stairs, as [MENTION=26643]Invert[/MENTION] asked of me about that kind of stairs.

Some people may be interested in the source code, so I will put it here:
Code:

.equ ins_ofs, 0x8F802A8
.thumb
.align 2
table_expansion:
.word ins_ofs+walk_ldmu, ins_ofs+walk_lumd, ins_ofs+walk_llmr, ins_ofs+walk_lrml
.word ins_ofs+go_ldmu, ins_ofs+go_lumd, ins_ofs+go_llmr, ins_ofs+go_lrml
.word ins_ofs+pulse_ldmu, ins_ofs+pulse_lumd, ins_ofs+pulse_llmr, ins_ofs+pulse_lrml
.word ins_ofs+run_ldmu, ins_ofs+run_lumd, ins_ofs+run_llmr, ins_ofs+run_lrml
.word ins_ofs+jump_2sq_ldmu, ins_ofs+jump_2sq_lumd, ins_ofs+jump_2sq_llmr, ins_ofs+jump_2sq_lrml
.word ins_ofs+jump_1sq_ldmu, ins_ofs+jump_1sq_lumd, ins_ofs+jump_1sq_llmr, ins_ofs+jump_1sq_lrml
.word ins_ofs+pulse_15, ins_ofs+pulse_27, ins_ofs+pulse_35, ins_ofs+pulse_46
.word ins_ofs+pulse_16, ins_ofs+pulse_28, ins_ofs+pulse_37, ins_ofs+pulse_48

walk_ldmu: .word ins_ofs+walk_ldmu_func+1, ins_ofs+an_walk_dn_2+1, 0x8067935
walk_lumd: .word ins_ofs+walk_lumd_func+1, ins_ofs+an_walk_dn_2+1, 0x8067935
walk_llmr: .word ins_ofs+walk_llmr_func+1, ins_ofs+an_walk_dn_2+1, 0x8067935
walk_lrml: .word ins_ofs+walk_lrml_func+1, ins_ofs+an_walk_dn_2+1, 0x8067935

go_ldmu: .word ins_ofs+go_ldmu_func+1, ins_ofs+an_go_dn_2+1, 0x8067935
go_lumd: .word ins_ofs+go_lumd_func+1, ins_ofs+an_go_dn_2+1, 0x8067935
go_llmr: .word ins_ofs+go_llmr_func+1, ins_ofs+an_go_dn_2+1, 0x8067935
go_lrml: .word ins_ofs+go_lrml_func+1, ins_ofs+an_go_dn_2+1, 0x8067935

pulse_ldmu: .word ins_ofs+pulse_ldmu_func+1, ins_ofs+an_pulse_dn_2+1, 0x8067935
pulse_lumd: .word ins_ofs+pulse_lumd_func+1, ins_ofs+an_pulse_dn_2+1, 0x8067935
pulse_llmr: .word ins_ofs+pulse_llmr_func+1, ins_ofs+an_pulse_dn_2+1, 0x8067935
pulse_lrml: .word ins_ofs+pulse_lrml_func+1, ins_ofs+an_pulse_dn_2+1, 0x8067935

run_ldmu: .word ins_ofs+run_ldmu_func+1, ins_ofs+an_run_dn_2+1, 0x8067935
run_lumd: .word ins_ofs+run_lumd_func+1, ins_ofs+an_run_dn_2+1, 0x8067935
run_llmr: .word ins_ofs+run_llmr_func+1, ins_ofs+an_run_dn_2+1, 0x8067935
run_lrml: .word ins_ofs+run_lrml_func+1, ins_ofs+an_run_dn_2+1, 0x8067935

jump_2sq_ldmu: .word ins_ofs+jump_2sq_ldmu_func+1, ins_ofs+an_jump_2sq_dn_2+1, 0x8067935
jump_2sq_lumd: .word ins_ofs+jump_2sq_lumd_func+1, ins_ofs+an_jump_2sq_dn_2+1, 0x8067935
jump_2sq_llmr: .word ins_ofs+jump_2sq_llmr_func+1, ins_ofs+an_jump_2sq_dn_2+1, 0x8067935
jump_2sq_lrml: .word ins_ofs+jump_2sq_lrml_func+1, ins_ofs+an_jump_2sq_dn_2+1, 0x8067935

jump_1sq_ldmu: .word ins_ofs+jump_1sq_ldmu_func+1, ins_ofs+an_jump_1sq_dn_2+1, 0x8067935
jump_1sq_lumd: .word ins_ofs+jump_1sq_lumd_func+1, ins_ofs+an_jump_1sq_dn_2+1, 0x8067935
jump_1sq_llmr: .word ins_ofs+jump_1sq_llmr_func+1, ins_ofs+an_jump_1sq_dn_2+1, 0x8067935
jump_1sq_lrml: .word ins_ofs+jump_1sq_lrml_func+1, ins_ofs+an_jump_1sq_dn_2+1, 0x8067935

pulse_15: .word ins_ofs+pulse_15_func+1, ins_ofs+pulse15_func_2+1, 0x8067935
pulse_27: .word ins_ofs+pulse_27_func+1, ins_ofs+pulse15_func_2+1, 0x8067935
pulse_35: .word ins_ofs+pulse_35_func+1, ins_ofs+pulse15_func_2+1, 0x8067935
pulse_46: .word ins_ofs+pulse_46_func+1, ins_ofs+pulse15_func_2+1, 0x8067935
pulse_16: .word ins_ofs+pulse_16_func+1, ins_ofs+pulse16_func_2+1, 0x8067935
pulse_28: .word ins_ofs+pulse_28_func+1, ins_ofs+pulse16_func_2+1, 0x8067935
pulse_37: .word ins_ofs+pulse_37_func+1, ins_ofs+pulse16_func_2+1, 0x8067935
pulse_48: .word ins_ofs+pulse_48_func+1, ins_ofs+pulse16_func_2+1, 0x8067935

pulse_15_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #1
mov r3, #0
bl an_run_any_f
mov r0, r4
mov r1, r5
bl pulse15_func_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_27_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #2
mov r3, #0
bl an_run_any_f
mov r0, r4
mov r1, r5
bl pulse15_func_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_35_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #3
mov r3, #0
bl an_run_any_f
mov r0, r4
mov r1, r5
bl pulse15_func_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_46_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #4
mov r3, #0
bl an_run_any_f
mov r0, r4
mov r1, r5
bl pulse15_func_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_16_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #1
mov r3, #0
bl an_run_any_g
mov r0, r4
mov r1, r5
bl pulse16_func_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_28_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #2
mov r3, #0
bl an_run_any_g
mov r0, r4
mov r1, r5
bl pulse16_func_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_37_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #3
mov r3, #0
bl an_run_any_g
mov r0, r4
mov r1, r5
bl pulse16_func_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_48_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #4
mov r3, #0
bl an_run_any_g
mov r0, r4
mov r1, r5
bl pulse16_func_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse15_func_2:
push {r4, lr}
mov r4, r1
bl sub_8064788_f
ldr r1, =0x8064D65
bx r1
.ltorg

pulse16_func_2:
push {r4, lr}
mov r4, r1
bl sub_8064788_g
ldr r1, =0x8064D65
bx r1
.ltorg

sub_8064788_f:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r0, r5
bl obj_npc_ministep_f
ldr r1, =0x8064795
bx r1
.ltorg

sub_8064788_g:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r0, r5
bl obj_npc_ministep_g
ldr r1, =0x8064795
bx r1
.ltorg

obj_npc_ministep_f:
push {r4, r5, lr}
mov r4, r0
ldr r5, =0x83a71b0
mov r0, #0x36
ldrsh r2, [r4, r0]
lsl r0, r2, #1
add r0, r0, r5
mov r3, #0x38
ldrsh r1, [r4, r3]
mov r3, #0
ldrsh r0, [r0, r3]
cmp r1, r0
bge loc_8068BB4_f
ldr r1, =0x83A719C
lsl r0, r2, #2
add r0, r0, r1
mov r1, #0x38
ldrsh r2, [r4, r1]
ldr r0, [r0]
lsl r2, r2, #2
add r2, r2, r0
ldrh r1, [r4, #0x34]
lsl r1, r1, #0x18
lsr r1, r1, #0x18
ldr r0, =ins_ofs+custom_table
sub r1, #1
lsl r1, r1, #1
ldrsh r1, [r0, r1]
ldr r2, [r2]
mov r0, r4
bl bx_r2
ldr r0, =0x8068B8D
bx r0

loc_8068BB4_f:
mov r0, #0
pop {r4, r5, pc}
.ltorg

obj_npc_ministep_g:
push {r4, r5, lr}
mov r4, r0
ldr r5, =0x83a71b0
mov r0, #0x36
ldrsh r2, [r4, r0]
lsl r0, r2, #1
add r0, r0, r5
mov r3, #0x38
ldrsh r1, [r4, r3]
mov r3, #0
ldrsh r0, [r0, r3]
cmp r1, r0
bge loc_8068BB4_g
ldr r1, =0x83A719C
lsl r0, r2, #2
add r0, r0, r1
mov r1, #0x38
ldrsh r2, [r4, r1]
ldr r0, [r0]
lsl r2, r2, #2
add r2, r2, r0
ldrh r1, [r4, #0x34]
lsl r1, r1, #0x18
lsr r1, r1, #0x18
ldr r0, =ins_ofs+custom_table
add r1, #3
lsl r1, r1, #1
ldrsh r1, [r0, r1]
ldr r2, [r2]
mov r0, r4
bl bx_r2
ldr r0, =0x8068B8D
bx r0

loc_8068BB4_g:
mov r0, #0
pop {r4, r5, pc}
.ltorg

an_run_any_f:
push {r4-r7, lr}
mov r7, r8
push {r7}
sub sp, sp, #0x14
mov r5, r0
mov r8, r1
mov r4, r3
lsl r2, r2, #0x18
lsr r2, r2, #0x18
lsl r4, r4, #0x18
lsr r4, r4, #0x18
mov r1, sp
ldr r0, =0x83a6884
ldmia r0!, {r3, r6, r7}
stmia r1!, {r3, r6, r7}
ldmia r0!, {r3, r6}
stmia r1!, {r3, r6}
mov r0, r5
mov r1, r8
mov r3, r4
bl npc_apply_direction_f
ldr r7, =0x8064729
bx r7
.ltorg

npc_apply_direction_f:
push {r4-r6, lr}
mov r6, r9
mov r5, r8
push {r5, r6}
sub sp, sp, #4
mov r8, r0
mov r9, r1
mov r4, r2
mov r6, r3
lsl r4, r4, #0x18
lsr r4, r4, #0x18
lsl r6, r6, #0x18
lsr r6, r6, #0x18
ldrh r1, [r0, #0x10]
mov r0, sp
strh r1, [r0, #0]
mov r1, r8
ldrh r0, [r1, #0x12]
mov r5, sp
add r5, #2
strh r0, [r5]
mov r0, r8
mov r1, r4
ldr r3, =0x805FBDD
bl bx_r3
ldr r1, =ins_ofs+custom_table
sub r2, r4, #1
lsl r2, r2, #1
ldrsh r0, [r1, r2]
ldr r1, =0x80646AD
bx r1
.ltorg

an_run_any_g:
push {r4-r7, lr}
mov r7, r8
push {r7}
sub sp, sp, #0x14
mov r5, r0
mov r8, r1
mov r4, r3
lsl r2, r2, #0x18
lsr r2, r2, #0x18
lsl r4, r4, #0x18
lsr r4, r4, #0x18
mov r1, sp
ldr r0, =0x83a6884
ldmia r0!, {r3, r6, r7}
stmia r1!, {r3, r6, r7}
ldmia r0!, {r3, r6}
stmia r1!, {r3, r6}
mov r0, r5
mov r1, r8
mov r3, r4
bl npc_apply_direction_g
ldr r7, =0x8064729
bx r7
.ltorg

npc_apply_direction_g:
push {r4-r6, lr}
mov r6, r9
mov r5, r8
push {r5, r6}
sub sp, sp, #4
mov r8, r0
mov r9, r1
mov r4, r2
mov r6, r3
lsl r4, r4, #0x18
lsr r4, r4, #0x18
lsl r6, r6, #0x18
lsr r6, r6, #0x18
ldrh r1, [r0, #0x10]
mov r0, sp
strh r1, [r0, #0]
mov r1, r8
ldrh r0, [r1, #0x12]
mov r5, sp
add r5, #2
strh r0, [r5]
mov r0, r8
mov r1, r4
ldr r3, =0x805FBDD
bl bx_r3
ldr r1, =ins_ofs+custom_table
add r2, r4, #3
lsl r2, r2, #1
ldrsh r0, [r1, r2]
ldr r1, =0x80646AD
bx r1
.ltorg

.align 2
custom_table: .hword 5, 7, 5, 6, 6, 8, 7, 8

jump_1sq_ldmu_func:
push {r4, r5, lr}
sub sp, sp, #4
mov r4, r0
mov r5, r1
mov r0, #2
str r0, [sp]
mov r0, r4
mov r2, #1
mov r3, #1
bl maybe_shadow_1
mov r0, r4
mov r1, r5
bl an_jump_1sq_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
add sp, sp, #4
pop {r4, r5, pc}
.ltorg

jump_1sq_lumd_func:
push {r4, r5, lr}
sub sp, sp, #4
mov r4, r0
mov r5, r1
mov r0, #2
str r0, [sp]
mov r0, r4
mov r2, #2
mov r3, #1
bl maybe_shadow_1
mov r0, r4
mov r1, r5
bl an_jump_1sq_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
add sp, sp, #4
pop {r4, r5, pc}
.ltorg

jump_1sq_llmr_func:
push {r4, r5, lr}
sub sp, sp, #4
mov r4, r0
mov r5, r1
mov r0, #2
str r0, [sp]
mov r0, r4
mov r2, #3
mov r3, #1
bl maybe_shadow_1
mov r0, r4
mov r1, r5
bl an_jump_1sq_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
add sp, sp, #4
pop {r4, r5, pc}
.ltorg

jump_1sq_lrml_func:
push {r4, r5, lr}
sub sp, sp, #4
mov r4, r0
mov r5, r1
mov r0, #2
str r0, [sp]
mov r0, r4
mov r2, #4
mov r3, #1
bl maybe_shadow_1
mov r0, r4
mov r1, r5
bl an_jump_1sq_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
add sp, sp, #4
pop {r4, r5, pc}
.ltorg

an_jump_1sq_dn_2:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
bl sub_8065028
ldr r1, =0x8066493
bx r1
.ltorg

jump_2sq_ldmu_func:
push {r4, r5, lr}
sub sp, sp, #4
mov r4, r0
mov r5, r1
mov r0, #0
str r0, [sp, #0]
mov r0, r4
mov r2, #1
mov r3, #2
bl maybe_shadow_1
mov r0, r4
mov r1, r5
bl an_jump_2sq_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
add sp, sp, #4
pop {r4, r5, pc}
.ltorg

jump_2sq_lumd_func:
push {r4, r5, lr}
sub sp, sp, #4
mov r4, r0
mov r5, r1
mov r0, #0
str r0, [sp, #0]
mov r0, r4
mov r2, #2
mov r3, #2
bl maybe_shadow_1
mov r0, r4
mov r1, r5
bl an_jump_2sq_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
add sp, sp, #4
pop {r4, r5, pc}
.ltorg

jump_2sq_llmr_func:
push {r4, r5, lr}
sub sp, sp, #4
mov r4, r0
mov r5, r1
mov r0, #0
str r0, [sp, #0]
mov r0, r4
mov r2, #3
mov r3, #2
bl maybe_shadow_1
mov r0, r4
mov r1, r5
bl an_jump_2sq_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
add sp, sp, #4
pop {r4, r5, pc}
.ltorg

jump_2sq_lrml_func:
push {r4, r5, lr}
sub sp, sp, #4
mov r4, r0
mov r5, r1
mov r0, #0
str r0, [sp, #0]
mov r0, r4
mov r2, #4
mov r3, #2
bl maybe_shadow_1
mov r0, r4
mov r1, r5
bl an_jump_2sq_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
add sp, sp, #4
pop {r4, r5, pc}
.ltorg

maybe_shadow_1:
push {r4, r5, lr}
sub sp, sp, #4
mov r4, r0
mov r5, r1
ldr r0, [sp, #0x10]
lsl r2, r2, #0x18
lsr r2, r2, #0x18
lsl r3, r3, #0x18
lsr r3, r3, #0x18
lsl r0, r0, #0x18
lsr r0, r0, #0x18
str r0, [sp]
mov r0, r4
bl sub_8064E3C
ldr r0, =0x8064f17
bx r0
.ltorg

sub_8064E3C:
push {r4-r7, lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, sp, #0x10
mov r7, r0
mov r10, r1
mov r4, r2
mov r8, r3
ldr r0, [sp, #0x30]
lsl r4, r4, #0x18
lsr r4, r4, #0x18
mov r1, r8
lsl r1, r1, #0x18
lsr r1, r1, #0x18
mov r8, r1
lsl r0, r0, #0x18
lsr r0, r0, #0x18
mov r9, r0
ldr r1, =0x83a6958
add r0, sp, #4
mov r2, #6
ldr r3, =0x81E5E79
bl bx_r3
add r5, sp, #0xc
mov r0, #0
strh r0, [r5]
mov r6, r13
add r6, #0xe
strh r0, [r6]
mov r0, r7
mov r1, r4
ldr r3, =0x805FBDD
bl bx_r3
mov r1, r8
lsl r0, r1, #1
add r0, sp
add r0, #4
mov r1, #0
ldrsh r3, [r0, r1]
str r3, [sp, #0]
sub r0, r4, #1
mov r1, #1
eor r0, r1
add r0, #1
ldr r1, =0x8064E93
bx r1
.ltorg

an_jump_2sq_dn_2:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
bl sub_8065028
ldr r1, =0x80650DF
bx r1
.ltorg

sub_8065028:
push {lr}
bl sub_8065000
ldr r1, =0x806502F
bx r1
.ltorg

sub_8065000:
push {lr}
ldr r2, =ins_ofs+sub_8068D3C+1
bl sub_8064F3C
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {pc}
.ltorg

sub_8068D3C:
push {r4-r6, lr}
sub sp, sp, #0xc
mov r4, r0
ldr r1, =0x83a71f8
mov r0, sp
mov r2, #6
ldr r3, =0x81E5E79
bl bx_r3
add r5, sp, #8
ldr r1, =0x83a71fe
mov r0, r5
mov r2, #3
ldr r3, =0x81E5E79
bl bx_r3
mov r6, #0
mov r1, #0x36
ldrsh r0, [r4, r1]
cmp r0, #0
beq loc_8068D6E
ldrh r1, [r4, #0x34]
lsl r1, r1, #0x18
lsr r1, r1, #0x18
sub r1, #1
mov r0, #1
eor r1, r0
add r1, #1
ldr r0, =0x8068D69
bx r0
loc_8068D6E:
ldr r0, =0x8068D6F
bx r0
.ltorg

sub_8064F3C:
push {r4-r7, lr}
mov r7, r8
push {r7}
sub sp, sp, #0x10
mov r6, r0
mov r7, r1
mov r4, r2
ldr r1, =0x83a695e
add r0, sp, #4
mov r2, #6
ldr r3, =0x81E5E79
bl bx_r3
mov r0, r7
bl bx_r4
lsl r0, r0, #0x18
lsr r0, r0, #0x18
mov r8, r0
cmp r0, #1
bne loc_8064FCC
mov r1, #0x36
ldrsh r0, [r7, r1]
lsl r0, r0, #1
add r0, sp
add r0, #4
mov r2, #0
ldrsh r0, [r0, r2]
cmp r0, #0
beq loc_8064FCC
add r4, sp, #0xc
mov r0, #0
strh r0, [r4]
mov r5, r13
add r5, #0xe
strh r0, [r5]
ldrb r0, [r6, #0x18]
lsr r0, r0, #4
sub r0, #1
mov r1, #1
eor r0, r1
add r0, #1
ldr r1, =0x8064F87
bx r1

loc_8064FCC:
ldr r1, =0x8064fcd
bx r1
.ltorg

run_ldmu_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #1
mov r3, #1
bl an_run_any
mov r0, r4
mov r1, r5
bl an_run_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

run_lumd_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #2
mov r3, #1
bl an_run_any
mov r0, r4
mov r1, r5
bl an_run_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

run_llmr_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #3
mov r3, #1
bl an_run_any
mov r0, r4
mov r1, r5
bl an_run_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

run_lrml_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #4
mov r3, #1
bl an_run_any
mov r0, r4
mov r1, r5
bl an_run_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

an_run_dn_2:
push {r4, lr}
mov r4, r1
bl sub_8064788
ldr r1, =0x80652F5
bx r1
.ltorg

pulse_ldmu_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #1
mov r3, #0
bl an_run_any
mov r0, r4
mov r1, r5
bl an_pulse_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_lumd_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #2
mov r3, #0
bl an_run_any
mov r0, r4
mov r1, r5
bl an_pulse_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_llmr_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #3
mov r3, #0
bl an_run_any
mov r0, r4
mov r1, r5
bl an_pulse_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_lrml_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #4
mov r3, #0
bl an_run_any
mov r0, r4
mov r1, r5
bl an_pulse_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

an_run_any:
push {r4-r7, lr}
mov r7, r8
push {r7}
sub sp, sp, #0x14
mov r5, r0
mov r8, r1
mov r4, r3
lsl r2, r2, #0x18
lsr r2, r2, #0x18
lsl r4, r4, #0x18
lsr r4, r4, #0x18
mov r1, sp
ldr r0, =0x83a6884
ldmia r0!, {r3, r6, r7}
stmia r1!, {r3, r6, r7}
ldmia r0!, {r3, r6}
stmia r1!, {r3, r6}
mov r0, r5
mov r1, r8
mov r3, r4
bl npc_apply_direction
ldr r7, =0x8064729
bx r7
.ltorg

npc_apply_direction:
push {r4-r6, lr}
mov r6, r9
mov r5, r8
push {r5, r6}
sub sp, sp, #4
mov r8, r0
mov r9, r1
mov r4, r2
mov r6, r3
lsl r4, r4, #0x18
lsr r4, r4, #0x18
lsl r6, r6, #0x18
lsr r6, r6, #0x18
ldrh r1, [r0, #0x10]
mov r0, sp
strh r1, [r0, #0]
mov r1, r8
ldrh r0, [r1, #0x12]
mov r5, sp
add r5, #2
strh r0, [r5]
mov r0, r8
mov r1, r4
ldr r3, =0x805FBDD
bl bx_r3
sub r0, r4, #1
mov r1, #1
eor r0, r1
add r0, #1
ldr r1, =0x80646AD
bx r1
.ltorg

an_pulse_dn_2:
push {r4, lr}
mov r4, r1
bl sub_8064788
ldr r1, =0x8064D65
bx r1
.ltorg

sub_8064788:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r0, r5
bl obj_npc_ministep
ldr r1, =0x8064795
bx r1
.ltorg

obj_npc_ministep:
push {r4, r5, lr}
mov r4, r0
ldr r5, =0x83a71b0
mov r0, #0x36
ldrsh r2, [r4, r0]
lsl r0, r2, #1
add r0, r0, r5
mov r3, #0x38
ldrsh r1, [r4, r3]
mov r3, #0
ldrsh r0, [r0, r3]
cmp r1, r0
bge loc_8068BB4
ldr r1, =0x83A719C
lsl r0, r2, #2
add r0, r0, r1
mov r1, #0x38
ldrsh r2, [r4, r1]
ldr r0, [r0]
lsl r2, r2, #2
add r2, r2, r0
ldrh r1, [r4, #0x34]
lsl r1, r1, #0x18
lsr r1, r1, #0x18
sub r1, #1
mov r0, #1
eor r1, r0
add r1, #1
ldr r2, [r2]
mov r0, r4
bl bx_r2
ldr r0, =0x8068B8D
bx r0

loc_8068BB4:
mov r0, #0
pop {r4, r5, pc}
.ltorg

go_ldmu_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #1
bl an_go_any_1
mov r0, r4
mov r1, r5
bl an_go_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

go_lumd_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #2
bl an_go_any_1
mov r0, r4
mov r1, r5
bl an_go_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

go_llmr_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #3
bl an_go_any_1
mov r0, r4
mov r1, r5
bl an_go_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

go_lrml_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #4
bl an_go_any_1
mov r0, r4
mov r1, r5
bl an_go_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

an_go_any_1:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
lsl r2, r2, #0x18
lsr r2, r2, #0x18
bl sub_8064B68
ldr r0, =0x8064be7
bx r0
.ltorg

sub_8064B68:
push {r4-r6, lr}
mov r6, r8
push {r6}
sub sp, sp, #4
mov r6, r0
mov r8, r1
lsl r5, r2, #0x18
lsr r5, r5, #0x18
ldrh r1, [r6, #0x10]
mov r0, sp
strh r1, [r0, #0]
ldrh r0, [r6, #0x12]
mov r4, sp
add r4, #2
strh r0, [r4]
mov r0, r6
mov r1, r5
ldr r3, =0x805FBDD
bl bx_r3
sub r0, r5, #1
mov r1, #1
eor r0, r1
add r0, #1
mov r1, sp
ldr r2, =0x8064b93
bx r2
.ltorg

an_go_dn_2:
push {r4, lr}
mov r4, r1
bl sub_8064C04
ldr r1, =0x8064ca5
bx r1
.ltorg

sub_8064C04:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r0, r5
bl sub_8068C18
ldr r1, =0x8064c11
bx r1
.ltorg

sub_8068C18:
push {r4, lr}
mov r4, r0
ldrh r0, [r4, #0x36]
add r0, #1
strh r0, [r4, #0x36]
lsl r0, r0, #0x10
asr r0, r0, #0x10
cmp r0, #2
bgt loc_8068C3E
ldrh r1, [r4, #0x34]
lsl r1, r1, #0x18
lsr r1, r1, #0x18
sub r1, #1
mov r0, #1
eor r1, r0
add r1, #1
ldr r0, =0x8068c31
bx r0
loc_8068C3E:
ldr r0, =0x8068C3F
bx r0
.ltorg

walk_ldmu_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #1
bl an_walk_any_1
mov r0, r4
mov r1, r5
bl an_walk_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

walk_lumd_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #2
bl an_walk_any_1
mov r0, r4
mov r1, r5
bl an_walk_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

walk_llmr_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #3
bl an_walk_any_1
mov r0, r4
mov r1, r5
bl an_walk_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

walk_lrml_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #4
bl an_walk_any_1
mov r0, r4
mov r1, r5
bl an_walk_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

an_walk_dn_2:
push {r4, lr}
mov r4, r1
bl an_walk_any_2
lsl r0, r0, #0x18
cmp r0, #0
beq loc_8064aa0
mov r0, #2
strh r0, [r4, #0x32]
mov r0, #1

loc_8064aa0:
pop {r4, pc}
.ltorg

an_walk_any_1:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
lsl r2, r2, #0x18
lsr r2, r2, #0x18
bl sub_80647C0
ldrb r0, [r4, #0x18]
lsl r0, r0, #0x1c
lsr r0, r0, #0x1c
ldr r3, =0x8063441
bl bx_r3
mov r2, r0
lsl r2, r2, #0x18
lsr r2, r2, #0x18
mov r0, r4
mov r1, r5
ldr r3, =0x8063555
bl bx_r3
pop {r4, r5, pc}
.ltorg

sub_80647C0:
push {r4-r6, lr}
mov r6, r8
push {r6}
sub sp, sp, #4
mov r6, r0
mov r8, r1
lsl r5, r2, #0x18
lsr r5, r5, #0x18
ldrh r1, [r6, #0x10]
mov r0, sp
strh r1, [r0, #0]
ldrh r0, [r6, #0x12]
mov r4, sp
add r4, #2
strh r0, [r4]
mov r0, r6
mov r1, r5
ldr r3, =0x805FBDD
bl bx_r3
sub r0, r5, #1
mov r1, #1
eor r0, r1
add r0, #1
mov r1, sp
mov r2, r4
ldr r3, =0x80647ED
bx r3
.ltorg

an_walk_any_2:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r0, r5
bl sub_8068BCC
ldr r1, =0x8064869
bx r1
.ltorg

sub_8068BCC:
push {r4, lr}
mov r4, r0
ldrh r1, [r4, #0x36]
mov r0, #1
and r0, r1
cmp r0, #0
bne loc_8068bec
ldrh r1, [r4, #0x34]
sub r1, #1
mov r0, #1
eor r1, r0
add r1, #1
mov r0, r4
ldr r3, =0x8068be3
bx r3

loc_8068bec:
ldr r0, =0x8068bed
bx r0
.ltorg

bx_r3: bx r3
bx_r2: bx r2
bx_r4: bx r4


How to insert if you don't like the offset 0xF80000 and don't want to use the patch:
1. Repoint the table at 0x3A65BC (3 pointers totally)
2. Change the 0x8F802A8 at the first line to the insert offset of the table + 0x2a8.
3. Compile it and insert it at the insert offset of the table + 0x2a8.
4. Write a script to test.


Credits:
Back~, Invert, Knizz

azurile13 May 6th, 2016 12:08 PM

Quote:

Originally Posted by jiangzhengwenjzw (Post 9229108)
stuff

What. You created customized (and interactive) graphics, repurposed a messagebox, and made custom movements, but started the post with a routine that calls evolution? x_x I almost didn't read the rest. Very cool, of course, but you totally buried the lead.

Substitute Doll May 6th, 2016 4:30 PM

how about a routine when you have 0 pokemon, it acts like a safari battle.

jiangzhengwenjzw May 6th, 2016 5:12 PM

Quote:

Originally Posted by azurile13 (Post 9229677)
What. You created customized (and interactive) graphics, repurposed a messagebox, and made custom movements, but started the post with a routine that calls evolution? x_x I almost didn't read the rest. Very cool, of course, but you totally buried the lead.

TBH, the first one may be not cool, but should be the most difficult one to figure it out (at least for me).

azurile13 May 6th, 2016 6:18 PM

Quote:

Originally Posted by jiangzhengwenjzw (Post 9229897)
TBH, the first one may be not cool, but should be the most difficult one to figure it out (at least for me).

Ah, that's interesting. I would expect the graphical stuff to be significantly harder, but I don't have experience with it, so I guess I wouldn't really know. Graphical hacking seems to be largely untapped with most hackers here, so maybe it is seen as more complicated than it really is. Anyways, sorry for going a bit off topic. Cool hax :D

BluRose May 6th, 2016 7:34 PM

Quote:

Originally Posted by azurile13 (Post 9229677)
What. You created customized (and interactive) graphics, repurposed a messagebox, and made custom movements, but started the post with a routine that calls evolution? x_x I almost didn't read the rest. Very cool, of course, but you totally buried the lead.

It's one of the reasons I still go to WaH; he's had all of them done for a while and has been posting over there. Almost surprised he didn't bring over his Trainer Card modifications (albeit incomplete) and his EV/IV Display Screen...
I also go there to type in Spanish because I need to improve it, but... oh well.

Zeturic May 10th, 2016 6:06 PM

As part of fixing this, I realized that it could be done simply by changing the target of a branch-link instruction, and it requires no free space at all. As such, I decided to post in Quick R&D instead (which is where it probably should have been in the first place).

Link.

jiangzhengwenjzw May 10th, 2016 9:03 PM

Quote:

Originally Posted by Sagiri (Post 9235905)
Incidentally, if anyone knows a built-in asm routine to count Pokemon (and not eggs), please let me know. If one exists, this could be rewritten to only use a couple of bytes.

Special 0x84, or the function at 0x808C13C.
Code:

/*This is directly copied from knizz's idb
and I haven't set the function type,
so the return value type is not shown as u8*/

int sp084_party_count_pokemon_no_egg()
{
    int v0; // [email protected]
    int v1; // [email protected]

    v0 = 0;
    v1 = 0;
    do
    {
        if ( pokemon_getattr(&party_player[v0].base, req_species) )
        {
            if ( !pokemon_getattr(&party_player[v0].base, req_is_egg) )
                v1 = (v1 + 1) & 0xFFFF;
        }
        v0 = (v0 + 1) & 0xFFFF;
    }
    while ( (unsigned int)v0 <= 5 );
    return (unsigned __int8)v1;
}



Zeturic May 11th, 2016 7:10 AM

Quote:

Originally Posted by jiangzhengwenjzw (Post 9236130)
Special 0x84, or the function at 0x808C13C.
Code:

/*This is directly copied from knizz's idb
and I haven't set the function type,
so the return value type is not shown as u8*/

int sp084_party_count_pokemon_no_egg()
{
    int v0; // [email protected]
    int v1; // [email protected]

    v0 = 0;
    v1 = 0;
    do
    {
        if ( pokemon_getattr(&party_player[v0].base, req_species) )
        {
            if ( !pokemon_getattr(&party_player[v0].base, req_is_egg) )
                v1 = (v1 + 1) & 0xFFFF;
        }
        v0 = (v0 + 1) & 0xFFFF;
    }
    while ( (unsigned int)v0 <= 5 );
    return (unsigned __int8)v1;
}



Nice. Thank you, I'll update my routine when I get the chance.

Lance32497 May 15th, 2016 1:22 AM

Quote:

Originally Posted by jiangzhengwenjzw (Post 9229108)
Misc:

Evolution via Callasm in FR


Spoiler:
I will show you the GIF result of the hack:
http://i869.photobucket.com/albums/ab256/jiangzhengwenjz/Untitled_zpsklaexwbz.gif
Firstly, we just insert a function at 0xYYYYYY:
Code:

.thumb
push {r4, lr}
ldr r0, =0x300537C
ldr r1, =0x80568E1
str r1, [r0]
ldr r0, =0x020370C0
ldrh r1, [r0, #2]
mov r2, #1
ldrh r3, [r0, #0x10]
ldr r4, =0x80cdda9
bl bx_r4
pop {r4, pc}
bx_r4: bx r4


After that we should insert another function at 0xZZZZZZ:
Code:

.thumb
push {r4, lr}
mov r4, #0
loop:
ldr r0, =0x02024284
mov r1, #0x64
mul r1, r4
add r0, r0, r1
mov r1, #0xb
ldr r2, =0x803FBE9
bl bx_r2
ldr r1, =0x20370C0
ldrh r2, [r1]
cmp r0, r2
beq have_pre
add r4, #1
cmp r4, #6
bne loop

no_pokemon:
mov r4, #0xFF
b back

increment:
add r4, #1
cmp r4, #6
beq no_pokemon
b loop

have_pre:
ldr r0, =0x2024284
mov r1, #0x64
mul r1, r4
add r0, r0, r1
mov r1, #0x2d
ldr r2, =0x803FBE9
bl bx_r2
ldr r1, =0x20370C0
cmp r0, #1
beq increment

back:
strh r4, [r1, #0x10]
pop {r4, pc}
bx_r2:
bx r2


To use it via a script:
Code:

#org @start
lock
faceplayer
setvar 0x8004 0x4 //the species number of pokemon you want it to evolve(here's chamander)
setvar 0x8005 0x2 //the species number of pokemon after evolution(here's ivysaur)
callasm 0x8ZZZZZZ+1 //check the slot number of the pokemon
compare 0x800D 0xFF //check if the pokemon exists in the player's party
if1 1 @no_that_pokemon
callasm 0x8YYYYYY+1 //evolution
waitstate
//setweather 3 //you can define other events after waitstate
//doweather
release
end

//---------------
#org @no_that_pokemon
msgbox @message_string 6 //"You don't have that pokemon. "
release
end

//---------
// Strings
//---------
#org @message_string
= You don't have that pokemon.


Note: Only the first pokemon in your party with the species number in 0x8004 will evolve. I think that's better.

A EV-IV Display Screen


Spoiler:
Quick Preview:
http://i869.photobucket.com/albums/ab256/jiangzhengwenjz/q_zpshnquzant.gif
Download:
https://github.com/jiangzhengwenjz/EV-IV-Screen
Usage:
1. Make sure that you have Devkitarm and GNU make/cygwin installed.
2. Download this repo and create a new folder called "build".
3. Assign the free space you want to use in linker.lsc.
4. Open your cmd prompt and type in make. Then press enter.
5. Now main.bin should be generated. Paste it to the offset specified in step3.
6. Write a script to test (You should callasm to the offset of insertion + 0x79).
Code:

Example:
lock
faceplayer
callasm 0x8800079 //I inserted the code at 0x8800000
msgbox 0x8FD0013 0x2 //"It's nice, huh?"
releaseall
end



80x80 mugshots


Spoiler:
Intro:
In Ruby, many hackers uses the BG0 to make mugshots. However, the same way that simply writing tileset, tilemap and palette to the RAM won't work for FR & EM as it will be cleared by the MSGBOX.

However, there's still a way to do it, which requires the knowledge of "rboxes". I've figured out some simple usage of the related functions, so I will show you my work:
http://i869.photobucket.com/albums/ab256/jiangzhengwenjz/1636%20-%20Pokemon%20-%20Fire%20Red%20Version_zpsryxoq5ye.png

The most ****ing thing should be that only 1 BG palette for FR can be used, which is the palette for the money box (the box with thinner border). Therefore, it will only be able to launch 1 mugshot at a time and you can't use it with the money box!

How to use:
The routines are provided at the bottom.
1. Change 0x8900000 in mugshot_make.asm to free space, which is ended in 0,4,8,c. It will be the location of our custom table.
2. Compile the 2 routines and insert them to some free space (Not the table location in step 1)
3. Get/draw some 80x80 mugshots, here's 2 examples:
http://i.imgur.com/8Z0ppvU.pnghttp://i.imgur.com/5bRm9Vg.png
They should be indexed to 16 colors.
4. Open your UNLZ-GBA and insert your images and palettes.
Note: the image and the palette should all be LZ77 compressed, which means that you should insert them by using "export image" and "export palette" in UNLZ-GBA. Aparrently they should all be inserted at some free space.
5. Build the table at the offset in step 1, whose format should be [image0 pointer][image0 pal pointer][image1 pointer][image1 pal pointer][image2 pointer][image2 pal pointer]...................
It can load up to 65536 images in algorithm, which means that it's enough.
6. Test time! use
setvar 0x8004 [image index in the table]
setvar 0x8005 [0 or 1] // 0 = left, 1 = right
callasm 0x8[mugshot_make.asm+1]
to launch the mugshot and
callasm 0x8[mugshot_del.asm+1] to delete it.

An example:
I insert the 2 images at 0xFA0000, 0xFA09CC and the 2 palettes at 0xFA09A4, 0xFA1484. Then the table should be:
Code:

00 00 FA 08 A4 09 FA 08 CC 09 FA 08 84 14 FA 08


The script:
Code:

//---------------
#org 0xF00000
lock
setvar 0x8004 0x0 //image0
setvar 0x8005 0x1 //right side
callasm 0x8800001 //mugshot_make.asm+1
msgbox 0x8F00030 0x6
callasm 0x8800089 //mugshot_del.asm+1
release
end

#org 0xF00030
= ABCD.


The routines:
mugshot_make.asm:
Code:

/*
Note: both image and palette should be LZ77 compressed!
Table format: [image pointer][pal pointer]..........
*/
.equiv table_location, 0x8900000
.thumb
push {r4-r5, lr}
sub sp, sp, #0x18
ldr r0, =0x20370C0
ldrh r0, [r0, #2]
mov r1, #0
mov r2, #0x14
mul r2, r0
mov r3, #4
mov r0, #10
str r0, [sp]
str r0, [sp, #4]
mov r0, #0xD
str r0, [sp, #8]
mov r0, #0x40
str r0, [sp, #0xC]
add r0, sp, #0x10
ldr r4, =0x810FE51
bl bx_r4
add r0, sp, #0x10
ldr r4, =0x8003CE5
bl bx_r4
ldr r4, =0x2039990
strb r0, [r4]
ldr r4, =0x8003FA1
bl bx_r4
ldr r0, =0x20370C0
ldrh r0, [r0]
ldr r1, =table_location
lsl r0, r0, #3
add r0, r0, r1
ldr r5, [r0, #4]
ldr r0, [r0]
ldr r1, =0x6008800
swi 0x12
mov r0, r5
mov r1, #0xd0
mov r2, #0x20
ldr r4, =0x80703A9
bl bx_r4
mov r0, #0
ldr r4, =0x80020BD
bl bx_r4
add sp, sp, #0x18
pop {r4-r5, pc}

bx_r4: bx r4


mugshot_del.asm:
Code:

.thumb
push {r4, lr}
ldr r4, =0x2039990
ldrb r4, [r4]
mov r1, #0
mov r0, r4
ldr r3, =0x810F4D9
bl bx_r3
mov r0, r4
mov r1, #2
ldr r3, =0x8003F21
bl bx_r3
mov r0, r4
ldr r3, =0x8003E3D
bl bx_r3
pop {r4, pc}

bx_r3: bx r3



Some new movement bytes (including a patch)


Spoiler:
The patch will write new data to the offset 0xF80000, so make sure that area of your hack has not been used yet. Here's the download link:
http://www.mediafire.com/download/hfb2s47jq3k4oow/movements.ips

I haven't tested much on this hack, so it may have some bugs but you can modify it on your own as I've released the source code at the bottom.

The new bytes are:
Code:

0xAA - move up backwards (very slow)
0xAB - move down backwards (very slow)
0xAC - move right backwards (very slow)
0xAD - move left backwards (very slow)
0xAE - move up backwards (slow)
0xAF - move down backwards (slow)
0xB0 - move right backwards (slow)
0xB1 - move left backwards (slow)
0xB2 - move up backwards (normal)
0xB3 - move down backwards (normal)
0xB4 - move right backwards (normal)
0xB5 - move left backwards (normal)
0xB6 - move up backwards (fast)
0xB7 - move down backwards (fast)
0xB8 - move right backwards (fast)
0xB9 - move left backwards (fast)
0xBA - jump up backwards (2 squares)
0xBB - jump down backwards (2 squares)
0xBC - jump right backwards (2 squares)
0xBD - jump left backwards (2 squares)
0xBE - jump up backwards (1 square)
0xBF - jump down backwards (1 square)
0xC0 - jump right backwards (1 square)
0xC1 - jump left backwards (1 square)
0xC2 - face down and move left-down (normal)
0xC3 - face up and move left-up (normal)
0xC4 - face left and move left-down (normal)
0xC5 - face right and move right-down (normal)
0xC6 - face down and move right-down (normal)
0xC7 - face up and move right-up (normal)
0xC8 - face left and move left-up (normal)
0xC9 - face right and move right-up (normal)


Here's a picture including all the bytes above in a script:
http://i869.photobucket.com/albums/ab256/jiangzhengwenjz/1_zps4xafcixu.gif

The diagonal ones (0xc2~0xc9) can be used in some kind of stairs, as [MENTION=26643]Invert[/MENTION] asked of me about that kind of stairs.

Some people may be interested in the source code, so I will put it here:
Code:

.equ ins_ofs, 0x8F802A8
.thumb
.align 2
table_expansion:
.word ins_ofs+walk_ldmu, ins_ofs+walk_lumd, ins_ofs+walk_llmr, ins_ofs+walk_lrml
.word ins_ofs+go_ldmu, ins_ofs+go_lumd, ins_ofs+go_llmr, ins_ofs+go_lrml
.word ins_ofs+pulse_ldmu, ins_ofs+pulse_lumd, ins_ofs+pulse_llmr, ins_ofs+pulse_lrml
.word ins_ofs+run_ldmu, ins_ofs+run_lumd, ins_ofs+run_llmr, ins_ofs+run_lrml
.word ins_ofs+jump_2sq_ldmu, ins_ofs+jump_2sq_lumd, ins_ofs+jump_2sq_llmr, ins_ofs+jump_2sq_lrml
.word ins_ofs+jump_1sq_ldmu, ins_ofs+jump_1sq_lumd, ins_ofs+jump_1sq_llmr, ins_ofs+jump_1sq_lrml
.word ins_ofs+pulse_15, ins_ofs+pulse_27, ins_ofs+pulse_35, ins_ofs+pulse_46
.word ins_ofs+pulse_16, ins_ofs+pulse_28, ins_ofs+pulse_37, ins_ofs+pulse_48

walk_ldmu: .word ins_ofs+walk_ldmu_func+1, ins_ofs+an_walk_dn_2+1, 0x8067935
walk_lumd: .word ins_ofs+walk_lumd_func+1, ins_ofs+an_walk_dn_2+1, 0x8067935
walk_llmr: .word ins_ofs+walk_llmr_func+1, ins_ofs+an_walk_dn_2+1, 0x8067935
walk_lrml: .word ins_ofs+walk_lrml_func+1, ins_ofs+an_walk_dn_2+1, 0x8067935

go_ldmu: .word ins_ofs+go_ldmu_func+1, ins_ofs+an_go_dn_2+1, 0x8067935
go_lumd: .word ins_ofs+go_lumd_func+1, ins_ofs+an_go_dn_2+1, 0x8067935
go_llmr: .word ins_ofs+go_llmr_func+1, ins_ofs+an_go_dn_2+1, 0x8067935
go_lrml: .word ins_ofs+go_lrml_func+1, ins_ofs+an_go_dn_2+1, 0x8067935

pulse_ldmu: .word ins_ofs+pulse_ldmu_func+1, ins_ofs+an_pulse_dn_2+1, 0x8067935
pulse_lumd: .word ins_ofs+pulse_lumd_func+1, ins_ofs+an_pulse_dn_2+1, 0x8067935
pulse_llmr: .word ins_ofs+pulse_llmr_func+1, ins_ofs+an_pulse_dn_2+1, 0x8067935
pulse_lrml: .word ins_ofs+pulse_lrml_func+1, ins_ofs+an_pulse_dn_2+1, 0x8067935

run_ldmu: .word ins_ofs+run_ldmu_func+1, ins_ofs+an_run_dn_2+1, 0x8067935
run_lumd: .word ins_ofs+run_lumd_func+1, ins_ofs+an_run_dn_2+1, 0x8067935
run_llmr: .word ins_ofs+run_llmr_func+1, ins_ofs+an_run_dn_2+1, 0x8067935
run_lrml: .word ins_ofs+run_lrml_func+1, ins_ofs+an_run_dn_2+1, 0x8067935

jump_2sq_ldmu: .word ins_ofs+jump_2sq_ldmu_func+1, ins_ofs+an_jump_2sq_dn_2+1, 0x8067935
jump_2sq_lumd: .word ins_ofs+jump_2sq_lumd_func+1, ins_ofs+an_jump_2sq_dn_2+1, 0x8067935
jump_2sq_llmr: .word ins_ofs+jump_2sq_llmr_func+1, ins_ofs+an_jump_2sq_dn_2+1, 0x8067935
jump_2sq_lrml: .word ins_ofs+jump_2sq_lrml_func+1, ins_ofs+an_jump_2sq_dn_2+1, 0x8067935

jump_1sq_ldmu: .word ins_ofs+jump_1sq_ldmu_func+1, ins_ofs+an_jump_1sq_dn_2+1, 0x8067935
jump_1sq_lumd: .word ins_ofs+jump_1sq_lumd_func+1, ins_ofs+an_jump_1sq_dn_2+1, 0x8067935
jump_1sq_llmr: .word ins_ofs+jump_1sq_llmr_func+1, ins_ofs+an_jump_1sq_dn_2+1, 0x8067935
jump_1sq_lrml: .word ins_ofs+jump_1sq_lrml_func+1, ins_ofs+an_jump_1sq_dn_2+1, 0x8067935

pulse_15: .word ins_ofs+pulse_15_func+1, ins_ofs+pulse15_func_2+1, 0x8067935
pulse_27: .word ins_ofs+pulse_27_func+1, ins_ofs+pulse15_func_2+1, 0x8067935
pulse_35: .word ins_ofs+pulse_35_func+1, ins_ofs+pulse15_func_2+1, 0x8067935
pulse_46: .word ins_ofs+pulse_46_func+1, ins_ofs+pulse15_func_2+1, 0x8067935
pulse_16: .word ins_ofs+pulse_16_func+1, ins_ofs+pulse16_func_2+1, 0x8067935
pulse_28: .word ins_ofs+pulse_28_func+1, ins_ofs+pulse16_func_2+1, 0x8067935
pulse_37: .word ins_ofs+pulse_37_func+1, ins_ofs+pulse16_func_2+1, 0x8067935
pulse_48: .word ins_ofs+pulse_48_func+1, ins_ofs+pulse16_func_2+1, 0x8067935

pulse_15_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #1
mov r3, #0
bl an_run_any_f
mov r0, r4
mov r1, r5
bl pulse15_func_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_27_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #2
mov r3, #0
bl an_run_any_f
mov r0, r4
mov r1, r5
bl pulse15_func_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_35_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #3
mov r3, #0
bl an_run_any_f
mov r0, r4
mov r1, r5
bl pulse15_func_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_46_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #4
mov r3, #0
bl an_run_any_f
mov r0, r4
mov r1, r5
bl pulse15_func_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_16_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #1
mov r3, #0
bl an_run_any_g
mov r0, r4
mov r1, r5
bl pulse16_func_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_28_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #2
mov r3, #0
bl an_run_any_g
mov r0, r4
mov r1, r5
bl pulse16_func_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_37_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #3
mov r3, #0
bl an_run_any_g
mov r0, r4
mov r1, r5
bl pulse16_func_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_48_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #4
mov r3, #0
bl an_run_any_g
mov r0, r4
mov r1, r5
bl pulse16_func_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse15_func_2:
push {r4, lr}
mov r4, r1
bl sub_8064788_f
ldr r1, =0x8064D65
bx r1
.ltorg

pulse16_func_2:
push {r4, lr}
mov r4, r1
bl sub_8064788_g
ldr r1, =0x8064D65
bx r1
.ltorg

sub_8064788_f:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r0, r5
bl obj_npc_ministep_f
ldr r1, =0x8064795
bx r1
.ltorg

sub_8064788_g:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r0, r5
bl obj_npc_ministep_g
ldr r1, =0x8064795
bx r1
.ltorg

obj_npc_ministep_f:
push {r4, r5, lr}
mov r4, r0
ldr r5, =0x83a71b0
mov r0, #0x36
ldrsh r2, [r4, r0]
lsl r0, r2, #1
add r0, r0, r5
mov r3, #0x38
ldrsh r1, [r4, r3]
mov r3, #0
ldrsh r0, [r0, r3]
cmp r1, r0
bge loc_8068BB4_f
ldr r1, =0x83A719C
lsl r0, r2, #2
add r0, r0, r1
mov r1, #0x38
ldrsh r2, [r4, r1]
ldr r0, [r0]
lsl r2, r2, #2
add r2, r2, r0
ldrh r1, [r4, #0x34]
lsl r1, r1, #0x18
lsr r1, r1, #0x18
ldr r0, =ins_ofs+custom_table
sub r1, #1
lsl r1, r1, #1
ldrsh r1, [r0, r1]
ldr r2, [r2]
mov r0, r4
bl bx_r2
ldr r0, =0x8068B8D
bx r0

loc_8068BB4_f:
mov r0, #0
pop {r4, r5, pc}
.ltorg

obj_npc_ministep_g:
push {r4, r5, lr}
mov r4, r0
ldr r5, =0x83a71b0
mov r0, #0x36
ldrsh r2, [r4, r0]
lsl r0, r2, #1
add r0, r0, r5
mov r3, #0x38
ldrsh r1, [r4, r3]
mov r3, #0
ldrsh r0, [r0, r3]
cmp r1, r0
bge loc_8068BB4_g
ldr r1, =0x83A719C
lsl r0, r2, #2
add r0, r0, r1
mov r1, #0x38
ldrsh r2, [r4, r1]
ldr r0, [r0]
lsl r2, r2, #2
add r2, r2, r0
ldrh r1, [r4, #0x34]
lsl r1, r1, #0x18
lsr r1, r1, #0x18
ldr r0, =ins_ofs+custom_table
add r1, #3
lsl r1, r1, #1
ldrsh r1, [r0, r1]
ldr r2, [r2]
mov r0, r4
bl bx_r2
ldr r0, =0x8068B8D
bx r0

loc_8068BB4_g:
mov r0, #0
pop {r4, r5, pc}
.ltorg

an_run_any_f:
push {r4-r7, lr}
mov r7, r8
push {r7}
sub sp, sp, #0x14
mov r5, r0
mov r8, r1
mov r4, r3
lsl r2, r2, #0x18
lsr r2, r2, #0x18
lsl r4, r4, #0x18
lsr r4, r4, #0x18
mov r1, sp
ldr r0, =0x83a6884
ldmia r0!, {r3, r6, r7}
stmia r1!, {r3, r6, r7}
ldmia r0!, {r3, r6}
stmia r1!, {r3, r6}
mov r0, r5
mov r1, r8
mov r3, r4
bl npc_apply_direction_f
ldr r7, =0x8064729
bx r7
.ltorg

npc_apply_direction_f:
push {r4-r6, lr}
mov r6, r9
mov r5, r8
push {r5, r6}
sub sp, sp, #4
mov r8, r0
mov r9, r1
mov r4, r2
mov r6, r3
lsl r4, r4, #0x18
lsr r4, r4, #0x18
lsl r6, r6, #0x18
lsr r6, r6, #0x18
ldrh r1, [r0, #0x10]
mov r0, sp
strh r1, [r0, #0]
mov r1, r8
ldrh r0, [r1, #0x12]
mov r5, sp
add r5, #2
strh r0, [r5]
mov r0, r8
mov r1, r4
ldr r3, =0x805FBDD
bl bx_r3
ldr r1, =ins_ofs+custom_table
sub r2, r4, #1
lsl r2, r2, #1
ldrsh r0, [r1, r2]
ldr r1, =0x80646AD
bx r1
.ltorg

an_run_any_g:
push {r4-r7, lr}
mov r7, r8
push {r7}
sub sp, sp, #0x14
mov r5, r0
mov r8, r1
mov r4, r3
lsl r2, r2, #0x18
lsr r2, r2, #0x18
lsl r4, r4, #0x18
lsr r4, r4, #0x18
mov r1, sp
ldr r0, =0x83a6884
ldmia r0!, {r3, r6, r7}
stmia r1!, {r3, r6, r7}
ldmia r0!, {r3, r6}
stmia r1!, {r3, r6}
mov r0, r5
mov r1, r8
mov r3, r4
bl npc_apply_direction_g
ldr r7, =0x8064729
bx r7
.ltorg

npc_apply_direction_g:
push {r4-r6, lr}
mov r6, r9
mov r5, r8
push {r5, r6}
sub sp, sp, #4
mov r8, r0
mov r9, r1
mov r4, r2
mov r6, r3
lsl r4, r4, #0x18
lsr r4, r4, #0x18
lsl r6, r6, #0x18
lsr r6, r6, #0x18
ldrh r1, [r0, #0x10]
mov r0, sp
strh r1, [r0, #0]
mov r1, r8
ldrh r0, [r1, #0x12]
mov r5, sp
add r5, #2
strh r0, [r5]
mov r0, r8
mov r1, r4
ldr r3, =0x805FBDD
bl bx_r3
ldr r1, =ins_ofs+custom_table
add r2, r4, #3
lsl r2, r2, #1
ldrsh r0, [r1, r2]
ldr r1, =0x80646AD
bx r1
.ltorg

.align 2
custom_table: .hword 5, 7, 5, 6, 6, 8, 7, 8

jump_1sq_ldmu_func:
push {r4, r5, lr}
sub sp, sp, #4
mov r4, r0
mov r5, r1
mov r0, #2
str r0, [sp]
mov r0, r4
mov r2, #1
mov r3, #1
bl maybe_shadow_1
mov r0, r4
mov r1, r5
bl an_jump_1sq_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
add sp, sp, #4
pop {r4, r5, pc}
.ltorg

jump_1sq_lumd_func:
push {r4, r5, lr}
sub sp, sp, #4
mov r4, r0
mov r5, r1
mov r0, #2
str r0, [sp]
mov r0, r4
mov r2, #2
mov r3, #1
bl maybe_shadow_1
mov r0, r4
mov r1, r5
bl an_jump_1sq_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
add sp, sp, #4
pop {r4, r5, pc}
.ltorg

jump_1sq_llmr_func:
push {r4, r5, lr}
sub sp, sp, #4
mov r4, r0
mov r5, r1
mov r0, #2
str r0, [sp]
mov r0, r4
mov r2, #3
mov r3, #1
bl maybe_shadow_1
mov r0, r4
mov r1, r5
bl an_jump_1sq_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
add sp, sp, #4
pop {r4, r5, pc}
.ltorg

jump_1sq_lrml_func:
push {r4, r5, lr}
sub sp, sp, #4
mov r4, r0
mov r5, r1
mov r0, #2
str r0, [sp]
mov r0, r4
mov r2, #4
mov r3, #1
bl maybe_shadow_1
mov r0, r4
mov r1, r5
bl an_jump_1sq_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
add sp, sp, #4
pop {r4, r5, pc}
.ltorg

an_jump_1sq_dn_2:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
bl sub_8065028
ldr r1, =0x8066493
bx r1
.ltorg

jump_2sq_ldmu_func:
push {r4, r5, lr}
sub sp, sp, #4
mov r4, r0
mov r5, r1
mov r0, #0
str r0, [sp, #0]
mov r0, r4
mov r2, #1
mov r3, #2
bl maybe_shadow_1
mov r0, r4
mov r1, r5
bl an_jump_2sq_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
add sp, sp, #4
pop {r4, r5, pc}
.ltorg

jump_2sq_lumd_func:
push {r4, r5, lr}
sub sp, sp, #4
mov r4, r0
mov r5, r1
mov r0, #0
str r0, [sp, #0]
mov r0, r4
mov r2, #2
mov r3, #2
bl maybe_shadow_1
mov r0, r4
mov r1, r5
bl an_jump_2sq_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
add sp, sp, #4
pop {r4, r5, pc}
.ltorg

jump_2sq_llmr_func:
push {r4, r5, lr}
sub sp, sp, #4
mov r4, r0
mov r5, r1
mov r0, #0
str r0, [sp, #0]
mov r0, r4
mov r2, #3
mov r3, #2
bl maybe_shadow_1
mov r0, r4
mov r1, r5
bl an_jump_2sq_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
add sp, sp, #4
pop {r4, r5, pc}
.ltorg

jump_2sq_lrml_func:
push {r4, r5, lr}
sub sp, sp, #4
mov r4, r0
mov r5, r1
mov r0, #0
str r0, [sp, #0]
mov r0, r4
mov r2, #4
mov r3, #2
bl maybe_shadow_1
mov r0, r4
mov r1, r5
bl an_jump_2sq_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
add sp, sp, #4
pop {r4, r5, pc}
.ltorg

maybe_shadow_1:
push {r4, r5, lr}
sub sp, sp, #4
mov r4, r0
mov r5, r1
ldr r0, [sp, #0x10]
lsl r2, r2, #0x18
lsr r2, r2, #0x18
lsl r3, r3, #0x18
lsr r3, r3, #0x18
lsl r0, r0, #0x18
lsr r0, r0, #0x18
str r0, [sp]
mov r0, r4
bl sub_8064E3C
ldr r0, =0x8064f17
bx r0
.ltorg

sub_8064E3C:
push {r4-r7, lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, sp, #0x10
mov r7, r0
mov r10, r1
mov r4, r2
mov r8, r3
ldr r0, [sp, #0x30]
lsl r4, r4, #0x18
lsr r4, r4, #0x18
mov r1, r8
lsl r1, r1, #0x18
lsr r1, r1, #0x18
mov r8, r1
lsl r0, r0, #0x18
lsr r0, r0, #0x18
mov r9, r0
ldr r1, =0x83a6958
add r0, sp, #4
mov r2, #6
ldr r3, =0x81E5E79
bl bx_r3
add r5, sp, #0xc
mov r0, #0
strh r0, [r5]
mov r6, r13
add r6, #0xe
strh r0, [r6]
mov r0, r7
mov r1, r4
ldr r3, =0x805FBDD
bl bx_r3
mov r1, r8
lsl r0, r1, #1
add r0, sp
add r0, #4
mov r1, #0
ldrsh r3, [r0, r1]
str r3, [sp, #0]
sub r0, r4, #1
mov r1, #1
eor r0, r1
add r0, #1
ldr r1, =0x8064E93
bx r1
.ltorg

an_jump_2sq_dn_2:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
bl sub_8065028
ldr r1, =0x80650DF
bx r1
.ltorg

sub_8065028:
push {lr}
bl sub_8065000
ldr r1, =0x806502F
bx r1
.ltorg

sub_8065000:
push {lr}
ldr r2, =ins_ofs+sub_8068D3C+1
bl sub_8064F3C
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {pc}
.ltorg

sub_8068D3C:
push {r4-r6, lr}
sub sp, sp, #0xc
mov r4, r0
ldr r1, =0x83a71f8
mov r0, sp
mov r2, #6
ldr r3, =0x81E5E79
bl bx_r3
add r5, sp, #8
ldr r1, =0x83a71fe
mov r0, r5
mov r2, #3
ldr r3, =0x81E5E79
bl bx_r3
mov r6, #0
mov r1, #0x36
ldrsh r0, [r4, r1]
cmp r0, #0
beq loc_8068D6E
ldrh r1, [r4, #0x34]
lsl r1, r1, #0x18
lsr r1, r1, #0x18
sub r1, #1
mov r0, #1
eor r1, r0
add r1, #1
ldr r0, =0x8068D69
bx r0
loc_8068D6E:
ldr r0, =0x8068D6F
bx r0
.ltorg

sub_8064F3C:
push {r4-r7, lr}
mov r7, r8
push {r7}
sub sp, sp, #0x10
mov r6, r0
mov r7, r1
mov r4, r2
ldr r1, =0x83a695e
add r0, sp, #4
mov r2, #6
ldr r3, =0x81E5E79
bl bx_r3
mov r0, r7
bl bx_r4
lsl r0, r0, #0x18
lsr r0, r0, #0x18
mov r8, r0
cmp r0, #1
bne loc_8064FCC
mov r1, #0x36
ldrsh r0, [r7, r1]
lsl r0, r0, #1
add r0, sp
add r0, #4
mov r2, #0
ldrsh r0, [r0, r2]
cmp r0, #0
beq loc_8064FCC
add r4, sp, #0xc
mov r0, #0
strh r0, [r4]
mov r5, r13
add r5, #0xe
strh r0, [r5]
ldrb r0, [r6, #0x18]
lsr r0, r0, #4
sub r0, #1
mov r1, #1
eor r0, r1
add r0, #1
ldr r1, =0x8064F87
bx r1

loc_8064FCC:
ldr r1, =0x8064fcd
bx r1
.ltorg

run_ldmu_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #1
mov r3, #1
bl an_run_any
mov r0, r4
mov r1, r5
bl an_run_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

run_lumd_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #2
mov r3, #1
bl an_run_any
mov r0, r4
mov r1, r5
bl an_run_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

run_llmr_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #3
mov r3, #1
bl an_run_any
mov r0, r4
mov r1, r5
bl an_run_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

run_lrml_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #4
mov r3, #1
bl an_run_any
mov r0, r4
mov r1, r5
bl an_run_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

an_run_dn_2:
push {r4, lr}
mov r4, r1
bl sub_8064788
ldr r1, =0x80652F5
bx r1
.ltorg

pulse_ldmu_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #1
mov r3, #0
bl an_run_any
mov r0, r4
mov r1, r5
bl an_pulse_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_lumd_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #2
mov r3, #0
bl an_run_any
mov r0, r4
mov r1, r5
bl an_pulse_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_llmr_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #3
mov r3, #0
bl an_run_any
mov r0, r4
mov r1, r5
bl an_pulse_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

pulse_lrml_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #4
mov r3, #0
bl an_run_any
mov r0, r4
mov r1, r5
bl an_pulse_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

an_run_any:
push {r4-r7, lr}
mov r7, r8
push {r7}
sub sp, sp, #0x14
mov r5, r0
mov r8, r1
mov r4, r3
lsl r2, r2, #0x18
lsr r2, r2, #0x18
lsl r4, r4, #0x18
lsr r4, r4, #0x18
mov r1, sp
ldr r0, =0x83a6884
ldmia r0!, {r3, r6, r7}
stmia r1!, {r3, r6, r7}
ldmia r0!, {r3, r6}
stmia r1!, {r3, r6}
mov r0, r5
mov r1, r8
mov r3, r4
bl npc_apply_direction
ldr r7, =0x8064729
bx r7
.ltorg

npc_apply_direction:
push {r4-r6, lr}
mov r6, r9
mov r5, r8
push {r5, r6}
sub sp, sp, #4
mov r8, r0
mov r9, r1
mov r4, r2
mov r6, r3
lsl r4, r4, #0x18
lsr r4, r4, #0x18
lsl r6, r6, #0x18
lsr r6, r6, #0x18
ldrh r1, [r0, #0x10]
mov r0, sp
strh r1, [r0, #0]
mov r1, r8
ldrh r0, [r1, #0x12]
mov r5, sp
add r5, #2
strh r0, [r5]
mov r0, r8
mov r1, r4
ldr r3, =0x805FBDD
bl bx_r3
sub r0, r4, #1
mov r1, #1
eor r0, r1
add r0, #1
ldr r1, =0x80646AD
bx r1
.ltorg

an_pulse_dn_2:
push {r4, lr}
mov r4, r1
bl sub_8064788
ldr r1, =0x8064D65
bx r1
.ltorg

sub_8064788:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r0, r5
bl obj_npc_ministep
ldr r1, =0x8064795
bx r1
.ltorg

obj_npc_ministep:
push {r4, r5, lr}
mov r4, r0
ldr r5, =0x83a71b0
mov r0, #0x36
ldrsh r2, [r4, r0]
lsl r0, r2, #1
add r0, r0, r5
mov r3, #0x38
ldrsh r1, [r4, r3]
mov r3, #0
ldrsh r0, [r0, r3]
cmp r1, r0
bge loc_8068BB4
ldr r1, =0x83A719C
lsl r0, r2, #2
add r0, r0, r1
mov r1, #0x38
ldrsh r2, [r4, r1]
ldr r0, [r0]
lsl r2, r2, #2
add r2, r2, r0
ldrh r1, [r4, #0x34]
lsl r1, r1, #0x18
lsr r1, r1, #0x18
sub r1, #1
mov r0, #1
eor r1, r0
add r1, #1
ldr r2, [r2]
mov r0, r4
bl bx_r2
ldr r0, =0x8068B8D
bx r0

loc_8068BB4:
mov r0, #0
pop {r4, r5, pc}
.ltorg

go_ldmu_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #1
bl an_go_any_1
mov r0, r4
mov r1, r5
bl an_go_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

go_lumd_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #2
bl an_go_any_1
mov r0, r4
mov r1, r5
bl an_go_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

go_llmr_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #3
bl an_go_any_1
mov r0, r4
mov r1, r5
bl an_go_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

go_lrml_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #4
bl an_go_any_1
mov r0, r4
mov r1, r5
bl an_go_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

an_go_any_1:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
lsl r2, r2, #0x18
lsr r2, r2, #0x18
bl sub_8064B68
ldr r0, =0x8064be7
bx r0
.ltorg

sub_8064B68:
push {r4-r6, lr}
mov r6, r8
push {r6}
sub sp, sp, #4
mov r6, r0
mov r8, r1
lsl r5, r2, #0x18
lsr r5, r5, #0x18
ldrh r1, [r6, #0x10]
mov r0, sp
strh r1, [r0, #0]
ldrh r0, [r6, #0x12]
mov r4, sp
add r4, #2
strh r0, [r4]
mov r0, r6
mov r1, r5
ldr r3, =0x805FBDD
bl bx_r3
sub r0, r5, #1
mov r1, #1
eor r0, r1
add r0, #1
mov r1, sp
ldr r2, =0x8064b93
bx r2
.ltorg

an_go_dn_2:
push {r4, lr}
mov r4, r1
bl sub_8064C04
ldr r1, =0x8064ca5
bx r1
.ltorg

sub_8064C04:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r0, r5
bl sub_8068C18
ldr r1, =0x8064c11
bx r1
.ltorg

sub_8068C18:
push {r4, lr}
mov r4, r0
ldrh r0, [r4, #0x36]
add r0, #1
strh r0, [r4, #0x36]
lsl r0, r0, #0x10
asr r0, r0, #0x10
cmp r0, #2
bgt loc_8068C3E
ldrh r1, [r4, #0x34]
lsl r1, r1, #0x18
lsr r1, r1, #0x18
sub r1, #1
mov r0, #1
eor r1, r0
add r1, #1
ldr r0, =0x8068c31
bx r0
loc_8068C3E:
ldr r0, =0x8068C3F
bx r0
.ltorg

walk_ldmu_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #1
bl an_walk_any_1
mov r0, r4
mov r1, r5
bl an_walk_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

walk_lumd_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #2
bl an_walk_any_1
mov r0, r4
mov r1, r5
bl an_walk_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

walk_llmr_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #3
bl an_walk_any_1
mov r0, r4
mov r1, r5
bl an_walk_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

walk_lrml_func:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r2, #4
bl an_walk_any_1
mov r0, r4
mov r1, r5
bl an_walk_dn_2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r4, r5, pc}
.ltorg

an_walk_dn_2:
push {r4, lr}
mov r4, r1
bl an_walk_any_2
lsl r0, r0, #0x18
cmp r0, #0
beq loc_8064aa0
mov r0, #2
strh r0, [r4, #0x32]
mov r0, #1

loc_8064aa0:
pop {r4, pc}
.ltorg

an_walk_any_1:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
lsl r2, r2, #0x18
lsr r2, r2, #0x18
bl sub_80647C0
ldrb r0, [r4, #0x18]
lsl r0, r0, #0x1c
lsr r0, r0, #0x1c
ldr r3, =0x8063441
bl bx_r3
mov r2, r0
lsl r2, r2, #0x18
lsr r2, r2, #0x18
mov r0, r4
mov r1, r5
ldr r3, =0x8063555
bl bx_r3
pop {r4, r5, pc}
.ltorg

sub_80647C0:
push {r4-r6, lr}
mov r6, r8
push {r6}
sub sp, sp, #4
mov r6, r0
mov r8, r1
lsl r5, r2, #0x18
lsr r5, r5, #0x18
ldrh r1, [r6, #0x10]
mov r0, sp
strh r1, [r0, #0]
ldrh r0, [r6, #0x12]
mov r4, sp
add r4, #2
strh r0, [r4]
mov r0, r6
mov r1, r5
ldr r3, =0x805FBDD
bl bx_r3
sub r0, r5, #1
mov r1, #1
eor r0, r1
add r0, #1
mov r1, sp
mov r2, r4
ldr r3, =0x80647ED
bx r3
.ltorg

an_walk_any_2:
push {r4, r5, lr}
mov r4, r0
mov r5, r1
mov r0, r5
bl sub_8068BCC
ldr r1, =0x8064869
bx r1
.ltorg

sub_8068BCC:
push {r4, lr}
mov r4, r0
ldrh r1, [r4, #0x36]
mov r0, #1
and r0, r1
cmp r0, #0
bne loc_8068bec
ldrh r1, [r4, #0x34]
sub r1, #1
mov r0, #1
eor r1, r0
add r1, #1
mov r0, r4
ldr r3, =0x8068be3
bx r3

loc_8068bec:
ldr r0, =0x8068bed
bx r0
.ltorg

bx_r3: bx r3
bx_r2: bx r2
bx_r4: bx r4


How to insert if you don't like the offset 0xF80000 and don't want to use the patch:
1. Repoint the table at 0x3A65BC (3 pointers totally)
2. Change the 0x8F802A8 at the first line to the insert offset of the table + 0x2a8.
3. Compile it and insert it at the insert offset of the table + 0x2a8.
4. Write a script to test.


Credits:
Back~, Invert, Knizz

These are very helpful, but the first routine, for me must be edited. Instead of the first pokemon in your party, why not party slot? Correct me if I'm wrong, code for specific party slot is easier than index number of Pokemon. It would be helpful for special 0x9F.

jiangzhengwenjzw May 15th, 2016 5:51 AM

Quote:

Originally Posted by Lance32497 (Post 9243157)
These are very helpful, but the first routine, for me must be edited. Instead of the first pokemon in your party, why not party slot? Correct me if I'm wrong, code for specific party slot is easier than index number of Pokemon. It would be helpful for special 0x9F.

Why do you think that it's the first pokemon? The function will search the pokemon with specified species in your party and get the first pokemon of that species in your party. For the special 0x9F, I haven't researched the special functions at that time (now i have one but in chinese so i don't publish it) so I just wrote a custom one.

Lance32497 May 15th, 2016 6:44 AM

Quote:

Originally Posted by jiangzhengwenjzw (Post 9243421)
Why do you think that it's the first pokemon? The function will search the pokemon with specified species in your party and get the first pokemon of that species in your party. For the special 0x9F, I haven't researched the special functions at that time (now i have one but in chinese so i don't publish it) so I just wrote a custom one.

yeah, the bolded one is the good way to describe what I'm talking about.

jiangzhengwenjzw May 15th, 2016 7:00 AM

Quote:

Originally Posted by Lance32497 (Post 9243506)
yeah, the bolded one is the good way to describe what I'm talking about.

I really don't understand what you mean.....
I think it's exactly what I did and described in my post.

BluRose May 15th, 2016 9:05 AM

Quote:

Originally Posted by jiangzhengwenjzw (Post 9243537)
I really don't understand what you mean.....
I think it's exactly what I did and described in my post.

I think he's asking to use Party Slot in 0x8004 instead of Species Index.
A problem arises: Your party slots aren't exactly set in stone, and you might evolve the wrong Pokémon... I don't get how it would help with Special 0x9F? Granted, I don't really know what it does...

jiangzhengwenjzw May 15th, 2016 3:55 PM

Quote:

Originally Posted by BluRose (Post 9243765)
I think he's asking to use Party Slot in 0x8004 instead of Species Index.
A problem arises: Your party slots aren't exactly set in stone, and you might evolve the wrong Pokémon... I don't get how it would help with Special 0x9F? Granted, I don't really know what it does...

Yes, I also don't know how to use a party slot as a parameter by a scripter as we always don't know what's the player's pokemon. Special 0x9F is a pokemon selection screen, but who knows what the player will do? If I use it, i must decrypt its species as well.

Psyinide May 15th, 2016 5:30 PM

Quote:

Originally Posted by FBI (Post 8519915)
Hmm, I've been asked to do this before and it's quite the common request. However, it's so easy and straight forward, I'm always left wondering why people don't do it themselves. Then I remember, even if it's easy for me, I guess it's not as easy if you don't know what to do :P

Trainer Capture toggle by Pokeball



What this does right now, if check if the thrown Pokeball is a masterball. If it is, allow capture. If it's not a masterball then the normal "trainer has blocked the ball" will occur. To change which ball toggles the capture look at my comments in the code and change 0x1 - masterball to something else of your choice.
Spoiler:

Taken from XSE:
#define ITEM_MASTERBALL 0x1
#define ITEM_ULTRABALL 0x2
#define ITEM_GREATBALL 0x3
#define ITEM_POKEBALL 0x4
#define ITEM_SAFARIBALL 0x5
#define ITEM_NETBALL 0x6
#define ITEM_DIVEBALL 0x7
#define ITEM_NESTBALL 0x8
#define ITEM_REPEATBALL 0x9
#define ITEM_TIMERBALL 0xA
#define ITEM_LUXURYBALL 0xB
#define ITEM_PREMIERBALL 0xC


How to insert:
Compile and insert the following routine into freespace:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

main:
        ldr r0, .Ball
        ldrb r0, [r0]
        cmp r0, #0x1 @masterball
        beq capture
        mov r0, #0x0
        mov r1, #0x5
        ldr r3, =(0x800E194 +1)
        bl linker
        ldr r0, =(0x802D4A0 +1)
        bx r0

capture:
        ldr r0, =(0x802D4B4 +1)
        bx r0

linker:
        bx r3

.align 2

.Ball:
        .word 0x2023D68


Here is a compiled version:
Code:

06 48 00 78 01 28 06 D0 00 20 05 21 04 4B 00 F0 04 F8 04 48 00 47 04 48 00 47 18 47 68 3D 02 02 95 E1 00 08 A1 D4 02 08 B5 D4 02 08




Now navigate to 0x2D498 and insert the following:
Code:

00 48 00 47 XX XX XX 08


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

Usage:
No usage! It's all done with the power of ASMAGIX!

Works great. I've set my script up to also check flag 0x203, if it's set stealing is disabled. I found that I need this ability because capturing a trainer's Pokemon ends the trainer battle immediately. This is my first ASM attempt, apologizes if I made any mistakes. The code works properly in my testing.

Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

main:
        push {r1-r3}
        ldr r0, .Ball
        ldrb r0, [r0]
        cmp r0, #0x1 @masterball
        beq checkflag
        b nocap

checkflag:
    mov r0, #0xFF
    lsl r0, r0, #0x1
    add r0, r0, #0x5
    ldr r3, =(0x806E6D0 +1)
    bl linker
    cmp r0, #0x0
    beq capture

nocap:
        pop {r1-r3}
        mov r0, #0x0
        mov r1, #0x5
        ldr r3, =(0x800E194 +1)
        bl linker
        ldr r0, =(0x802D4A0 +1)
        bx r0

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

linker:
        bx r3

.align 2

.Ball:
        .word 0x2023D68




Compiled version below. Swap out the XX with the Pokeball item number, 01 for a Masterball.

Spoiler:

Code:

0eb4 0c48 0078 XX28 00d0 07e0 ff20 4000
0530 094b 00f0 0df8 0028 07d0 0ebc 0020
0521 064b 00f0 05f8 0548 0047 0ebc 0548
0047 1847 683d 0202 d1e6 0608 95e1 0008
a1d4 0208 b5d4 0208



Lance32497 May 15th, 2016 11:43 PM

Quote:

Originally Posted by jiangzhengwenjzw (Post 9244442)
Yes, I also don't know how to use a party slot as a parameter by a scripter as we always don't know what's the player's pokemon. Special 0x9F is a pokemon selection screen, but who knows what the player will do? If I use it, i must decrypt its species as well.

The reason, for me, why Party slot number and not species index number, is to work well with Special 0x9F. What if the hacker wants to evolve a charmander on the third slot, and not the first slot? It would be very useful, and about specie decryption, JPAN has a routine (don't get it wrong) that decrypts pokemon, identifying specie index number is not a hard way to do via scripting, cuz JPAN has that routine.

jiangzhengwenjzw May 16th, 2016 2:54 AM

Quote:

Originally Posted by Lance32497 (Post 9244819)
The reason, for me, why Party slot number and not species index number, is to work well with Special 0x9F. What if the hacker wants to evolve a charmander on the third slot, and not the first slot? It would be very useful, and about specie decryption, JPAN has a routine (don't get it wrong) that decrypts pokemon, identifying specie index number is not a hard way to do via scripting, cuz JPAN has that routine.

I don't use JPAN's engine so I don't know what his engine includes though.
My routine will evolve the first pokemon of a specified species in your team. For example, I search for ho-oh in the player's team and get that it's in the second slot, then the routine will evolve it. Therefore it can achieve the goal.
If you insist that choosing a pokemon and then checking if the selected pokemon is of specified species, you can ask someone else to enhance it as it's very very simple. For me, I think it's not bad so I don't want to touch the routines again.

GoGoJJTech May 16th, 2016 3:20 AM

Are you guys really unaware of the Pokémon decryption routines already in the games?

Lance32497 May 16th, 2016 5:29 AM

Quote:

Originally Posted by GoGoJJTech (Post 9244938)
Are you guys really unaware of the Pokémon decryption routines already in the games?

yup, is there any? Tell us please

Joexv May 16th, 2016 7:54 AM

Quote:

Originally Posted by Lance32497 (Post 9245040)
yup, is there any? Tell us please

Go look through basically any routine on this website that deals with Pokemon. Besides if this is so easy to do why don't you do it yourself? What you're asking for is indeed easy to accomplish, but I'm fairly certain that just using the Selector Special then running another routine(that's already made mind you) to check the species.

BLAx501! May 22nd, 2016 11:31 AM

Quote:

Originally Posted by Touched (Post 8981803)

Instant NPC sprite switch


This is related to the last hack, but can be more useful for a less permanent change. It can also work on other NPCs. Callasm as usual with the NPC person number in 0x8000 (same ID you use with applymovement - and 0xFF for the player) and the target sprite (the sprite index you'd use in advance map) in 0x8001.

Code untested.

Spoiler:

Code:

        .align 2
        .thumb

instant_npc_frame_switch:
        push {r4-r6, lr}
        sub sp, #4

        ldr r4, variables

        @@ Determine npc state id from person id
        ldr r0, saveblock1_mapdata
        ldr r0, [r0]
        ldrb r0, [r4]                @ person/local ID from var 0x8000
        ldrb r1, [r0, #5]        @ current map
        ldrb r2, [r0, #4]        @ current bank
        mov r3, sp
        ldr r5, npc_id_by_local_id_and_map_ret_success
        bl call_via_r5
        cmp r0, #0                @ failure check
        bne instant_npc_frame_switch_return

        @@ Get npc_state
        mov r0, sp
        ldrb r1, [r0]                @ npc_id
        lsl r0, r1, #3                @ npc_states + 0x24 * npc_id
        add r0, r1
        lsl r0, #2
        ldr r1, npc_states
        add r6, r0, r1

        @@ Change Sprite
        mov r0, r6                @ npc_state
        ldrb r1, [r4, #2]        @ sprite index from var 0x8001
        ldr r5, npc_change_sprite
        bl call_via_r5

        @@ Update direction to prevent graphical artifacts
        mov r0, r6
        ldrb r1, [r0, #0x18]        @ npc direction
        lsr r1, #4
        ldr r5, npc_turn
        bl npc_turn

instant_npc_frame_switch_return:
        add sp, #4
        pop {r4-r6, pc}

call_via_r5:
        bx r5

        .align 2
variables: .word 0x020370B8        @ script var 0x8000
saveblock1_mapdata: .word 0x03005008
npc_states: .word 0x02036E38
npc_change_sprite: .word 0x081507BC + 1
npc_turn: .word 0x0805F218 + 1
npc_id_by_local_id_and_map_ret_success:        .word 0x0805DF84 + 1



It would be cool if someone could test these and write example scripts. I am too lazy.

Hmm, I've tried it, but it gives me this error on VBA-M

https://i.gyazo.com/60e123fe763231fb38ee12fd115923ed.png

And freezes the game. Any ideas??

EDIT: Simple test script to change Players OW

Code:

#dynamic 0x800000
#org @start
setvar 0x8000 0xFF
setvar 0x8001 0x18
callasm 0x8800001
end


EDIT2: The error above happens when trying to change the player OW as I said. When trying to change a NPC it just does nothing but doesn't freezes.

azurile13 May 22nd, 2016 12:28 PM

Quote:

Originally Posted by BLAx501! (Post 9253106)
Hmm, I've tried it, but it gives me this error on VBA-M

https://i.gyazo.com/60e123fe763231fb38ee12fd115923ed.png

And freezes the game. Any ideas??

EDIT: Simple test script to change Players OW

Code:

#dynamic 0x800000
#org @start
setvar 0x8000 0xFF
setvar 0x8001 0x18
callasm 0x8800001
end


EDIT2: The error above happens when trying to change the player OW as I said. When trying to change a NPC it just does nothing but doesn't freezes.

Don't know what specifically the problem is, but I do immediately notice at least one:

ldr r5, npc_turn
bl npc_turn

instead of

ldr r5, npc_turn
bl call_via_r5

BLAx501! May 22nd, 2016 12:42 PM

Quote:

Originally Posted by azurile13 (Post 9253190)
Don't know what specifically the problem is, but I do immediately notice at least one:

ldr r5, npc_turn
bl npc_turn

instead of

ldr r5, npc_turn
bl call_via_r5

Yup, you were right :D

I can now change player's OW, but NPC doesn't seem to work :/

Should Touched or Spherical Ice edit that post to add this little change??

azurile13 May 22nd, 2016 1:39 PM

Quote:

Originally Posted by BLAx501! (Post 9253207)
Yup, you were right :D

I can now change player's OW, but NPC doesn't seem to work :/

Should Touched or Spherical Ice edit that post to add this little change??

http://imgur.com/a/nKQXA
Sad times.

To be honest tho - although it would be nice to have that fixed, if mods had to fix every error in every post on this site, their workload would never end :D

garrett June 9th, 2016 8:52 PM

Hey, are there any tutorials on-site where I can learn how to ASM?

Substitute Doll June 10th, 2016 4:14 AM

Quote:

Originally Posted by garrett (Post 9279487)
Hey, are there any tutorials on-site where I can learn how to ASM?

Here: http://www.pokecommunity.com/showthread.php?t=343871

Starfall321 June 10th, 2016 7:27 PM

I found that how frustration when playing some Emerald hack with bad egg/event corruption caused by usage of unsafe flag/var.
IDK if anyone had already port Jambo's routine to Emerald because I can't find any relevant post ATM.

Emerald safe variables hack
Spoiler:

@Goto 0x9d650, change the code here to 00 48 00 47 [asm location +1 reverse pointer]
@Goto 0x9D664, change the bytes here to 00 00
@Usable range :0x4000-0x40FF,0x5000-0x51FF,0x8000 - 0x8016
@credit to Jambo51 for his awesome routine for Fire Red.
.align 2

VAR4000_40FF:
mov r0, #0x40
lsl r0, r0, #0x8
cmp r1, r0
blt exit

mov r0, #0x41
lsl r0, r0, #0x8
cmp r1, r0
blt normal

VAR5000_5200:
mov r0, #0x50
lsl r0, r0, #0x8
cmp r1, r0
blt exit

lsl r0, r1, #0x10
cmp r0, #0x0
blt alt

mov r0, #0x52
lsl r0, r0, #0x8
cmp r1, r0
bge exit

MEMORY_LOCATION:
mov r0, #0x50
lsl r0, r0, #0x8
sub r1, r1, r0
lsl r1, r1, #0x1
ldr r0, =0x0203db00 @save block location, 1 var cost 2 bytes so you will need 0x400 bytes here.
add r0, r0, r1


exit2: pop {r1}
bx r1

exit: mov r0, #0x0
b exit2

normal: ldr r0, =0x0809D67C+1
bx r0
alt: ldr r0, =0x0809D664+1
bx r0



Emerald safe flag hack
Spoiler:

@Goto 0x9d702, change the code here to, 0000 0048 0047 [asm location +1 reverse pointer]
@Credit to Jambo51 for original routine
@Not sure how flags >0x1900 working, technically it should not work but I never do massive test.
@In case you want to be safe, just never set a flag >0x1900.
@New safe flag range :0x900-0x18FF, you can still using 0x0-0x900 range.

.align 2
FLAG900_1900:
mov r0, #0x9
lsl r0, r0, #0x8
cmp r2, r0
blt normal
mov r0, #0x19
lsl r0, r0, #0x8
cmp r2, r0
bge noget

mov r0, #0x9
lsl r0, r0, #0x8
sub r2, r2, r0
lsr r1, r2, #3
ldr r0, =0x0203df00 @save block location, a total of 0x1000 flags cost 0x200 bytes here
exit: add r0, r0, r1
pop {r1}
bx r1

normal: ldr r0, =0x03005d8c
ldr r0, [r0, #0]

there: lsr r1, r1, #0x13
ldr r2, =0x1270
add r1, r1, r2
b exit

noget: add r0, r2, #0x0
b there


Pls tell me if any bug found.

GoGoJJTech June 20th, 2016 6:33 PM

Quote:

Originally Posted by BigPensausage
<deleted post>

Someone offered to pay for it (and then I'd release it) but they never paid and I never learned how to use Github. Tough world :(
Hey, I have an idea!
You can do it!

Joexv June 20th, 2016 9:44 PM

Quote:

Originally Posted by BigPensausage
<deleted post>

Woah when did I become a veteran???

Edit: Also if we're so unhelpful then how did I get a helping hand emblem?

Blah June 21st, 2016 6:32 AM

Quote:

Originally Posted by BigPensausage
<deleted post>

Nah, Spherical Ice isn't that kind of person. I had received the emblem from him long before interacting with him.

It seems like this daily dose of drama stems from the response to where/how to use the encryption functions in the game. Like Joexv and GoGo had pointed out, there is a built-in Pokemon decrypter/encrypter function which you can use to retrieve and set certain aspects of a Pokemon. Since they failed to site any sources or further readings, you can check the documentation here out: http://www.romhack.me/database/23/fire-red-commonly-used-asm-rom-offsets/

The first two are the ones that Lance and friends are interested in. If you're looking for applications of these functions, there are many inside this very thread. Just take a look at the first post and choose a routine dealing with Pokemon, which you'd like to inspect. Finally, if further problems arise, the ASM help thread is in the beginner's lounge.

Please guys, lets not be so hateful to eachother. Also gogo's not a veteran, she's a nab :^)

pokefreak890 June 21st, 2016 9:27 PM

Thanks GOGOJJTECH for crediting me ;) but you didn't have to put it that way but it's fine we are all cool here at the end of the day :)

i0Bjhansen0 July 6th, 2016 10:47 PM

I know the ability thread is for existing abilities so I'm posting this here. I want to make new abilities that are similar to Torrent, Blaze, Overgrow, and Swarm, that use other types, mainly ones I've made. Now, I don't know ASM, and don't have a clue where to start.

But could someone please... (for Fire Red)
1. Provide an offset to change to hook a new routine off of to make a new ability.
2. Provide something similar to the original "power up" ability that has notes to what can be changed.
3. And provide a bit of code to allow the routine to return to the original routine.

So, for instance.
Spoiler:
this may not even be remotely close to actual asm. just me trying to be less obscure.
[Start routine]
(code needed to start)
insert XX XX XX (As many times necessary) YY(+1 if necessary) YY YY (offset) XX XX at 0xXXXXXX

.main
check health
if <33% goto .abilitycheck
if not goto .return

.abilitycheck
check ability
if Torrent goto .powerupwater
if Blaze goto .powerupfire
if Overgrow goto .powerupgrass
if Swarm goto .powerupbug
if (new ability) goto .powerup(new type)
if not goto .return

.powerupwater
check movetype
if notwater goto .return
increase power
goto .return

.powerupfire
checkmovetype
if notfire goto .return
increase power
goto .return

.powerupgrass
checkmovetype
if notgrass goto .return
increase power
goto .return

.powerupbug
checkmovetype
if notbug goto .return
increase power
goto .return

.powerup(new type)
checkmovetype
if not(new type) goto .return
increase power
goto .return

.return
(code to return back to the original routine)

(any other remaining code to tie up loose ends or whatnot)

Hopefully someone with the knowledge can understand what I typed. This is ability stuff but the ability resource thread is for gen 4-6 abilities, not custom ones. But this is ASM so here it is.

Le pug July 30th, 2016 11:45 PM

Spoiler:
Quote:

Originally Posted by FBI (Post 8520099)
I think he wants to set a default name while skipping the intro. If you skip the intro via ASM, the default name is left as 0s aka blank.

Setting a static name to the player



Well, this is beyond simple, lol. I'll keep my post the same format though, because first post :3

How to insert:

Before you begin to insert the routine, there are a few steps. Firstly player names are limited to 8 characters with the eighth character = 0xFF.
Convert the static name you want from ascii to hex. For OP, he wanted Jesse and James which convert into:
C4 D9 E7 E7 D9 FF FF FF - Jesse
C4 D5 E1 D9 E7 FF FF FF -James
Note that if all eight bytes don't get used, you should pad them with "FF" in your hex editor.
Now insert the 8 byte names into some free space in your ROM via hex editor and write down the pointers.

Now copy the following routine into a text editor:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

main:
        push {r0-r2, lr}
        ldr r0, .Name
        ldr r0, [r0]
        add r1, r0, #0x1
        ldrb r1, [r1]
        cmp r1, #0x1 @girl
        beq Girl
        ldr r1, .CustomNameBoy
        ldr r2, [r1]
        add r1, r1, #0x4
        ldr r1, [r1]
        str r2, [r0]
        add r0, r0, #0x4
        str r1, [r0]
        pop {r0-r2, pc}

Girl:
        ldr r1, .CustomNameGirl
        ldr r2, [r1]
        add r1, r1, #0x4
        ldr r1, [r1]
        str r2, [r0]
        add r0, r0, #0x4
        str r1, [r0]
        pop {r0-r2, pc}

.align 2
.Name:
        .word 0x300500C

.CustomNameBoy:
        .word [email protected] to boy name

.CustomNameGirl:
        .word [email protected] to girl name




You'll notice that I have the lines:
Code:

.CustomNameBoy:
        .word [email protected] to boy name

.CustomNameGirl:
        .word [email protected] to girl name


Change the [email protected] text to 0x[offset you inserted]. No need to add one.
After you've done that compile and insert into free space.

Usage:
You must callasm to the routine, and depending on the Player's gender it will set their name. To have their name inserted before the player starts playing the game, create a level script which calls this routine. If you don't know how, ask in a relevant thread (not here).



@FBI: 1) any way to pull up the naming routine for the player after the intro has been skipped so that players can name themselves later in the game? 2) can this be done for emerald? I have the research here that allows you to skip the birch intro if that helps with a starting point: http://www.pokecommunity.com/showpost.php?p=8444249&postcount=590

Spoiler:
Quote:

Originally Posted by FBI (Post 8525480)
He says I can post it, so I will now :)


Hi, this is a matter of tracking the routine that does the saving and calling it. While I don't know where it is, perhaps you can track it down if I tell you that the routine called when you hit save in the start menu is 0x6F4E8. Happy hacking!


That's the plan, if you have any routines which you would like to see, feel free to request them here.

Swapping between two possible start menus



Basically this routine will allow the player to have two different start menus. The start menu shown is dependent on a flag being set. The second one will not have a "Save" option.

How to insert:

Compile and insert into free space the following routine:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func
main:
        mov r0, #0x94 @flag 0x250 divided by 4 (change if you want)
        lsl r0, #0x2
        ldr r1, =(0x806E6D0 +1)
        bl linker
        cmp r0, #0x0
        bne showMine

end:
        mov r0, #0x1
        ldr r1, =(0x806ED70 +1)
        bx r1

showMine:
        mov r0, #0x82
        lsl r0, r0, #0x4
        add r0, r0, #0x9
        ldr r1, =(0x806E6D0 +1)
        bl linker
        cmp r0, #0x0
        beq noDex
        mov r0, #0x0
        ldr r1, =(0x806ED94 +1)
        bl linker

noDex:
        mov r0, #0x82
        lsl r0, r0, #0x4
        add r0, r0, #0x8
        ldr r1, =(0x806E6D0 +1)
        bl linker
        cmp r0, #0x0
        beq noMon
        mov r0, #0x1
        ldr r1, =(0x806ED94 +1)
        bl linker

noMon:
        mov r0, #0x2
        ldr r1, =(0x806ED94 +1)
        bl linker
        mov r0, #0x3
        ldr r1, =(0x806ED94 +1)
        bl linker
        mov r0, #0x5
        ldr r1, =(0x806ED94 +1)
        bl linker
        mov r0, #0x6
        ldr r1, =(0x806ED94 +1)
        bl linker
        pop {r0}
        bx r0

linker2:
        bx r0

linker:
        bx r1

.align 2




Navigate to 0x6ED5C and insert the following byte changes:
Code:

00 48 00 47 XX XX XX 08


Where XX XX XX is the pointer (plus 1) in reverse hex to where you inserted the routine.
Navigate to 0x6EE42 and change 08 to 00.

Usage:
setflag 0x250 = show menu without save
clearflag 0x250 = show menu with save

That's it. It's toggled internally depending on the flag's state.



@FBI: this has been done by shinyquagsire for me before for emerald however I can not for the life of me figure out the magic he did. I do have previous commands associated to what he did if it helps, but if this could be done for emerald and also like how it was done, set a flag to give the player the battle frontier bag and allow me to clear flags and make the menu have certain things only (i.e. disabling the use of the bag) that'd be great. Here is the previous research: http://www.pokecommunity.com/showthread.php?p=8450458#post8450458


Spoiler:
Quote:

Originally Posted by Spherical Ice (Post 9045136)

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:

Code:

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.

Code:

.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





@Spice: this is a great feature and I am wondering why it isn't a built-in command already. Anyways, I was wondering if you could translate this into emerald? There are always work arounds for this such as a flags for each item (which is a horrible way to go about it) but it'd be easier to just count them and that's be great.

~~~~

As usual, I'd be willing to donate to the cause and if either of you need motivation, I'm here to support you helping myself and others and that is why I'm willing to donate. Thanks for any help.

Spherical Ice July 31st, 2016 12:58 AM

Quote:

Originally Posted by Le pug (Post 9344996)
@Spice: this is a great feature and I am wondering why it isn't a built-in command already. Anyways, I was wondering if you could translate this into emerald? There are always work arounds for this such as a flags for each item (which is a horrible way to go about it) but it'd be easier to just count them and that's be great.

[EM] checkitem hack to store quantity in 0x8008


This is untested, but it should work based on the offsets I've changed. Let me know if something's up with it.

As usual, the dummy script should look something like this:

Code:

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.

Code:

.thumb

@ 00 4A 10 47 XX+1 XX XX XX at 080D6794

lsl r0,r0,#0x10
lsr r0,r0,#0x10
ldr r2, =(0x020375E8) @ RAM location of 0x8008 (I think)
strh r0, [r2]
ldr r2, =(0x080D6764+1)
cmp r0, r5
bcs branch
ldr r2, =(0x080D6778+1)

branch:
bx r2



Le pug July 31st, 2016 2:32 AM

Quote:

Originally Posted by Spherical Ice (Post 9345055)
Spoiler:

[EM] checkitem hack to store quantity in 0x8008


This is untested, but it should work based on the offsets I've changed. Let me know if something's up with it.

As usual, the dummy script should look something like this:

Code:

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.

Code:

.thumb

@ 00 4A 10 47 XX+1 XX XX XX at 080D6794

lsl r0,r0,#0x10
lsr r0,r0,#0x10
ldr r2, =(0x020375E8) @ RAM location of 0x8008 (I think)
strh r0, [r2]
ldr r2, =(0x080D6764+1)
cmp r0, r5
bcs branch
ldr r2, =(0x080D6778+1)

branch:
bx r2



Two questions: 1) to apply the routine, do I have alter or insert it at any specific point because I'm confused as to how I'd apply it. I am assuming I'd insert it anywhere and then just callasm to that location but not sure if that meets the intent

2) not sure if I'm getting the test script correct, seeing as you're using a different scripting program than I. For XSE, if you use checkitem, you have to do a compare LASTRESULT command i.e:

Spoiler:
Code:

#org @event
lock
checkitem 68 0x1
compare LASTRESULT 0x0
if 0x1 goto @none
callasm 0x08F61EC1 <-- where I just randomly put the routine
buffernumber 0x0 0x8008
msgbox @string1 0x6
release
end

#org @none
msgbox @dont 0x6
release
end

#org @dont
= dont have any

#org @string1
= You have [buffer1] rare candy




The game ends up saying I have 7873 rare candy instead of 1.

Spherical Ice July 31st, 2016 7:03 AM

Quote:

Originally Posted by Le pug (Post 9345121)
Two questions: 1) to apply the routine, do I have alter or insert it at any specific point because I'm confused as to how I'd apply it. I am assuming I'd insert it anywhere and then just callasm to that location but not sure if that meets the intent

2) not sure if I'm getting the test script correct, seeing as you're using a different scripting program than I. For XSE, if you use checkitem, you have to do a compare LASTRESULT command i.e:

Spoiler:
Code:

#org @event
lock
checkitem 68 0x1
compare LASTRESULT 0x0
if 0x1 goto @none
callasm 0x08F61EC1 <-- where I just randomly put the routine
buffernumber 0x0 0x8008
msgbox @string1 0x6
release
end

#org @none
msgbox @dont 0x6
release
end

#org @dont
= dont have any

#org @string1
= You have [buffer1] rare candy




The game ends up saying I have 7873 rare candy instead of 1.

This sort of answers both questions, but you just need to assemble the routine and insert it at a random location like you've done, and then you go to the location commented on the routine, 0xD6794, and write the following bytes: 00 4A 10 47 XX+1 XX XX XX

So, for the offset you gave, you would write 00 4A 10 47 C1 1E F6 08. As for the script itself, inserting the routine where I said should modify how the checkitem command works, so callasm is not required. checkitem also doesn't require a LASTRESULT check as it already returns 0 or 1 to the place which 'if' checks, anyway. So, in short, you just need to remove the callasm and compare lines and it should work properly (once you've also done the byte changes).

If the routine does have problems following this I won't be able to help as I don't have access to my computer - this post was from my phone (which explains if there are any typos lmao).

MF50 July 31st, 2016 8:21 AM

Quote:

Originally Posted by KDS (Post 8533356)
Updated light ball to raise Pikachu's attack:

Spoiler:

At 3F020: 00 49 08 47 XX XX XX 08 00 00 00 00 00 00 00 00 00 00

Code:

.text
.align 2
.thumb
.thumb_func

mov r3, r10
cmp r3, #0x2d
beq ball
cmp r3, #0x41
bne noboost

ldrh r0, [r6, #0x0]
sub r0, #0x68
lsl r0, r0, #0x10
lsr r0, r0, #0x10
cmp r0, #0x1
bhi noboost
ldr r1, return1
bx r1

ball:
ldrh r0, [r6, #0x0]
cmp r0, #0x19
bne noboost
ldr r1, return1
bx r1

noboost:
ldr r1, return2
bx r1

.align 2
return1: .word 0x0803F033
return2: .word 0x0803F037



It's possible to have this feature in Emerald, too?
Maybe by adapting the above routine (changing offsets)?

Trainer 781 July 31st, 2016 8:58 AM

Quote:

Originally Posted by MF50 (Post 9345400)
It's possible to have this feature in Emerald, too?
Maybe by adapting the above routine (changing offsets)?

It is already done by kleenexfeu in this thread. You can navigate to that post via the first page of this thread.

MF50 July 31st, 2016 9:25 AM

Quote:

Originally Posted by KDS (Post 9345440)
It is already done by kleenexfeu in this thread. You can navigate to that post via the first page of this thread.

In the first page there's nothing related to Emerald, but I found this post in another thread:

http://www.pokecommunity.com/showpost.php?p=8756677&postcount=682

I think it's the right one.

--------------------------------------------------------------------------------------

EDIT: I have also another little problem.

I succesfully managed to implement this in Fire Red (non-US version)

Spoiler:

Quote:

Originally Posted by Spherical Ice (Post 9043890)

Nature-affected stats colouring routines [FR]:


CLICK FOR EMERALD

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

Attack:
Code:

.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:
Code:

.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:
Code:

.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:
Code:

.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:
Code:

.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:
Code:

.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.

http://i.imgur.com/8IfVLeT.pnghttp://i.imgur.com/ltTHc6K.png

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!



However I can't make it work in Leaf Green. I corrected all 0x08__ offsets but the game crashes when I view the Pokémon stats page.
I didn't touch 0x02__ offsets, need to correct them also?

ShantyTown July 31st, 2016 7:05 PM

Feebas Fishing Tiles in Fire Red

I'm learning arm/thumb, and I thought implementing the Feebas tiles mechanic from R/S/E for Fire Red would be a good exercise. Everything is documented at the top of this routine. You just need to follow the instructions. The Feebas tile locations are determined by your trainer id and secret id, so they don't ever change.

The code below will set Feebas fishing tiles in the pond in the middle of Celadon City. A trainer id/secret id pair of 0xf61cf69b results in the following tiles being "Feebas tiles", with a 75% encounter rate:

http://i.imgur.com/kTogKRq.png

Code:

@ Feebas Routine
@ by ShantyTown
@
@ You'll need to do 2 steps to insert this Feebas routine into your ROM.
@ 1. Compile and insert this file into the ROM, and remember its ROM address.
@ 2. Overwrite the 8 bytes at address 0x82b64 with these 8 bytes:
@    00 4A 97 46 XX XX XX XX
@    (Replace "XX XX XX XX" with the ROM address of the routine you inserted in the first step.)
@
@    For example, if you inserted it at ROM address 0x800480, it would look like this:
@    00 4A 97 46 80 04 80 08
@
@ This routine enables 1-8 fishing tiles in a single map to contain Feebas. (Defaults to 6 tiles)
@ To customize this for your ROM, make changes to the constants at the bottom of this file:
@    You must define a rectanglular sub-area of the map where Feebas can appear.
@      For example, for the pond in Celadon City, we would define the sides of the rectangular area as
@              Left  side of rectangle = 0x18
@              Right  side of rectangle = 0x1d
@              Top    side of rectangle = 0x15
@              Bottom side of rectangle = 0x17
@
@ NOTE: If the rectangle's area is larger than 255 tiles, then some of the bottom tiles won't be able to contin Feebas.
@

.text
.align 2
.thumb
.thumb_func

main:
        @ Push registers that were pushed in the original routine.
        push    {r4-r6, lr}

        @ Check if current map is Feebas's map.
        ldr  r3, =(0x2031DBC) @ Address of current map id
        ldrh r3, [r3]        @ r3 = current map id
        ldr r2, =(MAP_ID)    @ r2 = Map Id for Feebas tiles
        cmp r3, r2            @ compare the current map id with Feebas's map id
        bne done              @ jump to "done" if they weren't equal

        push {r0-r2}

        @ Get the player's tile coordinates.
        ldr  r0, =(0x3005008)
        ldr  r2, [r0]        @ r2 = pointer to player's X/Y coordinates
        ldrh r0, [r2]        @ r0 = player's X coordinate
        ldrh r1, [r2, #0x02]  @ r1 = player's Y coordinate

        @ Get the player's facing direction.
        ldr  r2, =(0x2036e58)
        ldrb r2, [r2]  @ r2 = player's facing direction (1 = down, 2 = up, 3 = left, 4 = right)

        @ Get the fishing tile coordinates by getting the tile coordinates in front of the player.
        cmp r2, #0x1
        beq facingDown
        cmp r2, #0x2
        beq facingUp
        cmp r2, #0x3
        beq facingLeft
        b facingRight

gotFishingTileCoords:
        @ At this point, r0 = X, r1 = Y
        bl checkFeebasTile
        cmp r0, #0x0  @ If r0 != 0, then it's a Feebas tile
        beq notFeebas

        @ Set encounter rate.
        ldr r0, .genRandom
        bl linker
        mov r1, #0xff
        and r0, r1
        cmp r0, #ENCOUNTER_RATE
        bgt notFeebas

        pop {r5-r7} @ pop off garbage to get the stack in a good state

        @ Load Feebas id and level.
        ldr r0, =(POKEMON_ID)    @ Load Feebas id into r0
        ldr r1, =(POKEMON_LEVEL)  @ Load level 20 into r1
        ldr r2, =(0x0)            @ Load the fishing data slot(???) into r2

        @ Jump back to original routine where it has calculated the pokemon species and level.
        ldr r3, =0x08082b8e
        mov pc, r3

facingDown:
        @ Add 1 to the player's y coordinate.
        add r1, #0x1
        b gotFishingTileCoords

facingUp:
        @ Subtract 1 from the player's y coordinate.
        sub r1, #0x1
        b gotFishingTileCoords

facingLeft:
        @ Subtract 1 from the player's x coordinate.
        sub r0, #0x1
        b gotFishingTileCoords

facingRight:
        @ Add 1 to the player's x coordinate.
        add r0, #0x1
        b gotFishingTileCoords

checkFeebasTile:
        @ Check if the given tile coordinates are a Feebas tile
        @ r0 = X, r1 = Y
        @ return: r0 != 0x0 if it's a Feebas tile
        @
        @ Algorithm:
        @    Define a rectangular area with width w and height h
        @    This area is an array of length w * h
        @
        @    Check if the fishing tile is inside the rectangle.  Else return.
        @    Convert the fishing tile coordinates to an index within this array.
        @    Take the secret id/trainer id and combine nybbles to form 8-bit values by sliding to the left.
        @    For each of those values 'v':
        @        If v % (w * h) == array index:
        @            It's a Feebas tile
        @
        push {lr}

        @ Is the fishing tile in the Feebas rectangle?
        cmp r0, #RECT_LEFT
        bmi notFeebasTile
        cmp r0, #RECT_RIGHT
        bgt notFeebasTile
        cmp r1, #RECT_TOP
        bmi notFeebasTile
        cmp r1, #RECT_BOTTOM
        bgt notFeebasTile

        @ Convert tile coordinates to the array index.
        sub r0, r0, #RECT_LEFT
        sub r1, r1, #RECT_TOP
        mov r2, #(RECT_RIGHT - RECT_LEFT + 1)  @ width of rectangle
        mul r1, r1, r2
        add r0, r0, r1    @ r0 = array index for rectangular area

        ldr r1, =(0x0300500C)
        ldr r1, [r1]
        add r1, r1, #0xa
        ldrh r5, [r1]          @ Need to load trainer id and secret id separately because they aren't word-aligned
        mov r6, r5
        add r1, r1, #0x2
        ldrh r6, [r1]
        lsl r5, r5, #0x10
        add r1, r5, r6          @ Load the secret id and trainer id into r1

        mov r2, #((RECT_RIGHT - RECT_LEFT + 1) * (RECT_BOTTOM - RECT_TOP + 1))  @ Rectangle's area
        mov r3, #NUM_TILES

        mov r5, #0xff

checkSlot:
        sub r3, r3, #0x1  @ Decrement the counter
        bmi notFeebasTile  @ Return if the counter hit zero.

        mov r4, r1
        and r4, r5        @ Load lower 8 bits of r1 into r4.
        lsr r1, r1, #0x4  @ Shift r1 4 bits to the right, so a new 8-bit value will be used
                          @ in the next loop iteration.

modulus:
        @ Perform r4 % r2
        sub r4, r4, r2
        bmi modulusDone
        b modulus

modulusDone:
        add r4, r4, r2  @ Make the result positive.
        cmp r4, r0
        bne checkSlot

exitCheckFeebasTile:
        ldr r0, =(0x1)
        pop {pc}

notFeebasTile:
        ldr r0, =(0x0)
        pop {pc}

notFeebas:
        pop {r0-r2}
done:
        @ Code that was replaced by the hook in the original routine
        mov    r6, r0
        lsl    r0, r1, #0x18
        lsr    r0, r0, #0x18

        @ Jump back to the original routine after the hook
        ldr r2, =0x08082b6c
        mov pc, r2

linker:
        bx r0

.align 2

.genRandom:
        .word 0x08044ec8 + 1

@ Customizable Constants
.set MAP_ID,      0x0603  @ [ID][Bank] (Default CELADON CITY)
.set RECT_LEFT,      0x18  @ X coordinate of left side of rectangle
.set RECT_RIGHT,    0x1d  @ X coordinate of right side of rectangle
.set RECT_TOP,      0x15  @ Y coordinate of top side of rectangle
.set RECT_BOTTOM,    0x17  @ Y coordinate of bottom side of rectangle
.set NUM_TILES,      0x06  @ Number of Feebas tiles (must be between 1 and 8)
.set POKEMON_ID,    0x148  @ Pokemon Id (Feebas)
.set POKEMON_LEVEL,  0x0f  @ Wild Pokemon level (15)
.set ENCOUNTER_RATE, 0xc0  @ This number is divided by 0xFF to get the encounter rate (0xc0 / 0xff = 75% encounter rate)



MF50 August 2nd, 2016 8:16 AM

Quote:

Originally Posted by MF50 (Post 9345475)
However I can't make it work in Leaf Green.

Nevermind, I just solved the above problem. ^^

ShantyTown August 2nd, 2016 8:29 AM

Quote:

Originally Posted by MF50 (Post 9348593)
Nevermind, I just solved the above problem. ^^

Did it require different offsets for the hook and return? If so, could you let me know what they were so I can add it to my post?

MF50 August 2nd, 2016 11:57 AM

Quote:

Originally Posted by ShantyTown (Post 9348672)
Did it require different offsets for the hook and return? If so, could you let me know what they were so I can add it to my post?

Oh, I was referring to my previous post, about "Nature-affected stats colouring routines". I didn't fix correctly two offsets. :)

ShantyTown August 2nd, 2016 12:12 PM

Quote:

Originally Posted by MF50 (Post 9349041)
Oh, I was referring to my previous post, about "Nature-affected stats colouring routines". I didn't fix correctly two offsets. :)

Oh, my mistake! I thought you quoted my post for some reason.

SpanishAdam August 2nd, 2016 1:43 PM

How would I implement Sky Battle restrictions in Pokemon Emerald? Restrictions are not quite as simple as 'only flying', since levitating pokemon are allowed and some flying types (like Doduo) wouldn't be allowed due to their inability to fly.

Can I request a script that would cater for this, or at least something as close as possible?

Thanks

BluRose August 2nd, 2016 5:13 PM

Quote:

Originally Posted by SpanishAdam (Post 9349178)
How would I implement Sky Battle restrictions in Pokemon Emerald? Restrictions are not quite as simple as 'only flying', since levitating pokemon are allowed and some flying types (like Doduo) wouldn't be allowed due to their inability to fly.

Can I request a script that would cater for this, or at least something as close as possible?

Thanks

Wanna port something?
You should also probably experiment with what the Abilities actually are. FBI didn't put it in his list, but it's in there.

Lance32497 August 12th, 2016 5:04 PM

Hello guys, this is some of my requests.

Allowing variables to be used in wildbattle
•I know this is kinda specific but may serve usefullness in hacking. Can anybody hack the wildbattle command in FireRed so you can use values stored in variable can be used as a specie number. It may be useful to have a random wild battle.

editing and adding button functions in overworld
•Is there a way, well there's really a way, to add button functions on FireRed Rom? Like the AB Button, or any other button that can be added onthe emulator. Or, edit the existing button like select, which loads the registered item, start which accesses menu, or etc.

thedarkdragon11 August 12th, 2016 6:27 PM

Hello! May I request something?

An item that will mimic Eon Flute into FR/EM (teleportation item)
So I have this idea of a fake "Soaring in the sky" for Gen. 3 games... For the Eon Flute, it will be like the OW Fly animation but with a twist... Once you use the item, it will load the Fly animation with Mega [email protected] sprite and then teleport it into a certain coordinate in a specific map... The map will serve as the fake sky... The coordinates will be based from the map name where the item is used... The player will then be in the Surf mode (or any custom OW) once landed...

Disable Menu and registered item access in a certain map name for FR/EM
This is in line with my idea of a fake "Soaring in the sky"... It will disable the Menu and registered item access in a certain map name (for my idea, it will be in the Sky map)...

Only if they're possible... Thanks a lot!

ElijahCabugao August 13th, 2016 12:14 AM

Quote:

Originally Posted by KDS (Post 8548413)

#org @start
call @func
end2

#org @func
playanimation 0x1 0x7 0x0
setword 0x203C020 0x08TTTTTT
printstring 0x184
waitmessage 0x40
orword 0x2023DD0 0x100
graphicalhpupdate 0x1
datahpupdate 0x1
return

How to insert this battlescript or what tool do I use?... Xse wont let me insert this...

robinjea August 13th, 2016 1:43 AM

Quote:

Originally Posted by ElijahCabugao (Post 9365829)
How to insert this battlescript or what tool do I use?... Xse wont let me insert this...

You use Jambo51's Battle Script Pro. It's around here somewhere. Too lazy to search it myself. :P

Zeta Sukuna August 13th, 2016 7:48 AM

I do have a request, though I don't know how simple it will be.

Basically, something for Emerald that allows you to do class-based trainer music. Much like Jambo's 'class-based trainer music' ASM for Fire Red, I suppose.

ElijahCabugao August 13th, 2016 4:15 PM

Quote:

Originally Posted by BlackWhiteRobin (Post 9365877)
You use Jambo51's Battle Script Pro. It's around here somewhere. Too lazy to search it myself. :P

Ooh thanks for the response:)... I have already that tool but I cant make it work because
it says there are no commands~_~...

RichterSnipes August 18th, 2016 5:03 PM

Would it be possible for someone to update the first post? It hasn't been touched in over half a year, and some really interesting stuff has been posted here since then.

Also, I think there's an issue with this routine:
Quote:

Originally Posted by FBI (Post 8510724)

Party Item Checker:


I wasn't able to get it to work with Hoenn Pokémon. Whether I use their index number or National Dex number (both in hex), the routine fails with them. All Pokémon with an index value up to 0xFF - Kanto and Johto Pokémon, in other words - work just fine.

azurile13 August 18th, 2016 6:38 PM

Quote:

Originally Posted by RichterSnipes (Post 9373265)
Would it be possible for someone to update the first post? It hasn't been touched in over half a year, and some really interesting stuff has been posted here since then.

Also, I think there's an issue with this routine:

I wasn't able to get it to work with Hoenn Pokémon. Whether I use their index number or National Dex number (both in hex), the routine fails with them. All Pokémon with an index value up to 0xFF - Kanto and Johto Pokémon, in other words - work just fine.

It looks like its because
Code:

found:
        ldr r2, .MON
        strb r5, [r2]
        pop {r0-r6, pc}

none:
        ldr r0, .MON
        mov r1, #0x6
        strb r1, [r0]
        pop {r0-r6, pc}


Kanto and Johto work by the fact that setting their var by script also clears the upper byte. But for anything beyond 255, you have it set to 1 or higher for the upper part of the halfword. Just change them to store a halfword instead.

esperance August 20th, 2016 5:03 PM

Quote:

Originally Posted by RichterSnipes (Post 9373265)
Would it be possible for someone to update the first post? It hasn't been touched in over half a year, and some really interesting stuff has been posted here since then.

Thread should be updated now. :)

RichterSnipes August 21st, 2016 11:25 AM

Quote:

Originally Posted by Lost (Post 9375851)
Thread should be updated now. :)

Thank you so much! :)

I personally can't imagine how annoying/time consuming it must be to comb through tons of posts to find things to add to the first post and organize them appropriately.
Quote:

Originally Posted by azurile13 (Post 9373372)
It looks like its because
Code:

found:
        ldr r2, .MON
        strb r5, [r2]
        pop {r0-r6, pc}

none:
        ldr r0, .MON
        mov r1, #0x6
        strb r1, [r0]
        pop {r0-r6, pc}


Kanto and Johto work by the fact that setting their var by script also clears the upper byte. But for anything beyond 255, you have it set to 1 or higher for the upper part of the halfword. Just change them to store a halfword instead.

Huh. Reading through the code it makes it seem like those two commands end up storing the party position instead of Pokémon species. It'd only need a byte for the former. Or maybe I'm still not getting how all these things behave with one another.

Regardless, it works. Thanks!

azurile13 August 21st, 2016 12:27 PM

Quote:

Originally Posted by RichterSnipes (Post 9376508)
Thank you so much! :)

I personally can't imagine how annoying/time consuming it must be to comb through tons of posts to find things to add to the first post and organize them appropriately.

Huh. Reading through the code it makes it seem like those two commands end up storing the party position instead of Pokémon species. It'd only need a byte for the former. Or maybe I'm still not getting how all these things behave with one another.

Regardless, it works. Thanks!

Oh, you’re right on that, it is storing the party position. What I mean is that variables take up two bytes. So when you do

setvar 0x8000 VENUSAUR
The address of var8000 looks like 0x03 0x00 (flipped because little endian).

Then when you write the return, the var correctly has 0x00 as the upper byte.
But if you have something like

setvar 0x8000 TREECKO
The address of var8000 looks like 0x15 0x01 (because treecko is 0x115).

Then when you store the party slot only as a byte, the 0x1 is still there.
So when you use something like compare to check the var in a script, it ends up being 0x100 more than the party slot. When dealing with vars in asm, its good practice to load and store halfwords (unless there’s some specific reason not to).

Lunos August 21st, 2016 4:44 PM

Quote:

Originally Posted by KDS (Post 8533356)
Updated light ball to raise Pikachu's attack:

Spoiler:

At 3F020: 00 49 08 47 XX XX XX 08 00 00 00 00 00 00 00 00 00 00

Code:

.text
.align 2
.thumb
.thumb_func

mov r3, r10
cmp r3, #0x2d
beq ball
cmp r3, #0x41
bne noboost

ldrh r0, [r6, #0x0]
sub r0, #0x68
lsl r0, r0, #0x10
lsr r0, r0, #0x10
cmp r0, #0x1
bhi noboost
ldr r1, return1
bx r1

ball:
ldrh r0, [r6, #0x0]
cmp r0, #0x19
bne noboost
ldr r1, return1
bx r1

noboost:
ldr r1, return2
bx r1

.align 2
return1: .word 0x0803F033
return2: .word 0x0803F037



Tried it and whenever a Pokémon uses a Physical Attack, the game instantly freezes right there.
This is a FR USA v1.0 Routine, right?
Also, it does replace the way that the native Light Ball works giving it this new effect at the same time, right?

Because I already checked and I'm sure I didn't failed in any step, what I did basically was:

1) Copying the routine into a clean .txt and converting it to .bin, which ended up like this:
Code:

53 46 2D 2B 09 D0 41 2B 0C D1 30 88 68 38 00 04 00 0C 01 28 06 D8 04 49 08 47 30 88 19 28 01 D1 01 49 08 47 01 49 08 47 33 F0 03 08 37 F0 03 08


I pasted it on 456750.

2) Then I went to 3F020 and typed: 00 49 08 47 50 67 45 08 00 00 00 00 00 00 00 00 00 00
Tried the new ROM, and got surprised by the battle freezing when my Lv5 Pikachu with a Light Ball equipped frozened the game in the moment he tried to use "Slam" on a Wild Pidgey. In another try also noticed that another Wild Pidgey's Tackle could freeze the game too.

BluRose August 21st, 2016 5:44 PM

Quote:

Originally Posted by Lunos (Post 9376908)
Spoiler:
Tried it and whenever a Pokémon uses a Physical Attack, the game instantly freezes right there.
This is a FR USA v1.0 Routine, right?
Also, it does replace the way that the native Light Ball works giving it this new effect at the same time, right?

Because I already checked and I'm sure I didn't failed in any step, what I did basically was:

1) Copying the routine into a clean .txt and converting it to .bin, which ended up like this:
Code:

53 46 2D 2B 09 D0 41 2B 0C D1 30 88 68 38 00 04 00 0C 01 28 06 D8 04 49 08 47 30 88 19 28 01 D1 01 49 08 47 01 49 08 47 33 F0 03 08 37 F0 03 08


I pasted it on 456750.

2) Then I went to 3F020 and typed: 00 49 08 47 50 67 45 08 00 00 00 00 00 00 00 00 00 00
Tried the new ROM, and got surprised by the battle freezing when my Lv5 Pikachu with a Light Ball equipped frozened the game in the moment he tried to use "Slam" on a Wild Pidgey. In another try also noticed that another Wild Pidgey's Tackle could freeze the game too.

hi, by the way!
you forgot/didn't +1 for THUMB mode
3F020 = 00 49 08 47 51 67 45 08 00 00 00 00 00 00 00 00 00 00

Froosty September 4th, 2016 1:52 AM

Quote:

Originally Posted by DoesntKnowHowToPlay (Post 9043968)
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:

Code:

.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.


cmp r0, #0x7
beq StandardStone
cmp r0, #0x14 #UPDATE THIS
beq MaleStone
cmp r0, #0x15 #UPDATE THIS
beq FemaleStone


what do i update the underlined codes to??
are they the item index number or what else?
pls answer me!
need it for my hack!

thanks in advance :D

----------------------------check my hack progress--------------------------------
http://www.pokecommunity.com/album.php?albumid=10098

DoesntKnowHowToPlay September 5th, 2016 7:16 AM

evolution type number

DarkPsychic September 6th, 2016 9:08 AM

Would anyone happen to have JPANs custom input routine?

If not, then if I may make a request.
Trying to get a number/character input menu for custom keypad passwords ect...
If possible it would be much appreciated ^_^

BLAx501! September 6th, 2016 10:46 AM

Quote:

Originally Posted by DarkPsychic (Post 9397536)
Would anyone happen to have JPANs custom input routine?

If not, then if I may make a request.
Trying to get a number/character input menu for custom keypad passwords ect...
If possible it would be much appreciated ^_^

Found it somewhere around my computer. I never found out how to use this correctly (despite the readme file with the explanation) so that's all up to you xD

DarkPsychic September 7th, 2016 6:57 PM

Quote:

Originally Posted by BLAx501! (Post 9397682)
Found it somewhere around my computer. I never found out how to use this correctly (despite the readme file with the explanation) so that's all up to you xD

Nice!
That would be amazing if you could pm it to me...
I think I should be able to manage ^_^

BLAx501! September 8th, 2016 8:28 AM

Quote:

Originally Posted by DarkPsychic (Post 9399612)
Nice!
That would be amazing if you could pm it to me...
I think I should be able to manage ^_^

I'm stupid and I forgot to paste the download link xDDD
Here you are: http://www.mediafire.com/download/pt18qmw8k78pmco/number_box.zip

I'll take another look to it tonight anyways :p

DarkPsychic September 8th, 2016 6:59 PM

Quote:

Originally Posted by BLAx501! (Post 9400284)
I'm stupid and I forgot to paste the download link xDDD
Here you are: http://www.mediafire.com/download/pt18qmw8k78pmco/number_box.zip

I'll take another look to it tonight anyways :p


Sweet!!!
Thank you very much ^_^

It works like a charm, just when you insert it go to your pointer(0x800000) + 0x164 and at that offset insert
your pointer(0x800000) + 0x0179 = 0x800179 in reverse hex = 79 01 80.

Then just create a XSE script and make sure lockall comes before the callasm.
While callasm is followed by waitstate then just make sure to releaseall at the end...

Thanks again though been looking for this for a bit now.

Froosty September 8th, 2016 11:41 PM

Quote:

Originally Posted by jiangzhengwenjzw (Post 8964135)
All the codes are now on github and the auto-insertion is completed via armips.
https://github.com/jiangzhengwenjz/Double_wild_battle

Old post:
Spoiler:
I'm here again and here's some information about double wild battle in BPRE. The system is not yet perfect, but I don't have time to improve it so I decided to release the code. Please credit Jambo51 because some of the codes are ripped from his FR649. However, iirr, Karatekid552 has released the ASM codes in FR649 on github, so I think it's not inappropriate to post them here. These routines will make it possible to have "double wild battle" in "grass battles".
Bugs fixed:
1. Loading only 1
2. Capture animation
3. Audio error
4. Captured data
5. pokedex things
6. can't flee
7. nickname issues

Wild Double Battle in BPRE


Now the main bugs are all fixed and here's a picture of what we can do now. (I don't use an English ROM, sorry.)
http://i869.photobucket.com/albums/ab256/jiangzhengwenjz/Untitled_zpsj3bd633m.gif
The byte changes are in the comments of the routines, so please read carefully.
Spoiler:
Code:

.thumb
/*0x82a26 -  04 49 08 47
0x82a38 - XX+1 XX XX 08
0x7F760 - 00 00*/

str r0, [sp]
ldr r0, .opponent_slot
add r1, r4, #0
add r2, r6, #0
mov r3, #0x20
ldr r4, .pokemon_make_3
bl linker_4
mov r1, #0
mov r2, #0

loop_1:
mov r4, #0x64
ldr r0, .party_slot
add r0, #0x56
mul r4, r1
add r0, r0, r4
ldrh r0, [r0]
cmp r0, #0
bne add_1

increment:
add r1, #1
cmp r1, #6
bne loop_1
cmp r2, #2
blt back_1
ldr r1, .offset
ldr r2, .save_block_1
ldr r2, [r2]
ldrb r3, [r2, #4] @bank
lsl r3, r3, #2
add r1, r1, r3
ldr r1, [r1]
ldrb r3, [r2, #5] @map
lsl r3, r3, #2
add r1, r1, r3
ldr r1, [r1]
ldr r1, [r1]
ldr r3, [r1, #0x10]
ldr r2, .tileset_table
cmp r3, r2
bne back_1
bl get_block_id
mov r2, #0

loop_2:
mov r1, pc
add r1, #0x92
lsl r3, r2, #2
add r1, r1, r3
ldrh r3, [r1]
cmp r0, r3
beq calculation
ldr r1, .end
cmp r1, r3
beq back_1
add r2, #1
b loop_2

add_1:
add r2, #1
b increment

back_1:
mov r0, #0
ldr r1, .battle_flag
str r0, [r1]

back_2:
add sp, sp, #0x10
pop {r4-r6, pc}

get_block_id:
push {lr}
ldr r0, .npc_state
ldrh r1, [r0, #0x12] @Y
ldrh r0, [r0, #0x10] @X
ldr r4, .getter
bl linker_4
pop {pc}

calculation:
ldrb r4, [r1, #2]
cmp r4, #0x63
bhi doubletwo
bl random
mov r1, #0x64
bl mod_func

doublethree:
add r1, r4, #0
cmp r0, r1
bge back_1

double:
mov r0, #1
ldr r1, .battle_flag
str r0, [r1]
ldr r4, .rand_grass
bl linker_4
ldr r1, [r7, #4]
lsl r0, r0, #2
add r0, r0, r1
ldrh r4, [r0, #2]
ldr r1, .generate
bl linker_1
add r6, r0, #0
bl random
mov r1, #0x19
bl mod_func
str r0, [sp]
ldr r0, .opponent_slot
add r0, #0x64
add r1, r4, #0
add r2, r6, #0
mov r3, #0x20
ldr r4, .pokemon_make_3
bl linker_4
b back_2

doubletwo:
mov r0, #0
b doublethree

mod_func:
ldr r3, .mod_addr
bx r3

random:
ldr r2, .rand
bx r2

linker_1:
bx r1

linker_4:
bx r4

.word 0x0005000A
.word 0x0005000B
.word 0x0005000C
.word 0x0005000D
.hword 0xFEFE

.align 2
.opponent_slot: .word 0x0202402C
.pokemon_make_3: .word 0x0803DD99
.party_slot: .word 0x02024284
.battle_flag: .word 0x02022B4C
.offset: .word 0x083526A8
.save_block_1: .word 0x03005008
.tileset_table: .word 0x082D4A94
.npc_state: .word 0x02036E38
.getter: .word 0x08058E49
.end: .word 0x0000FEFE
.mod_addr: .word 0x081E4685
.rand: .word 0x08044EC9
.rand_grass: .word 0x0808274D
.generate: .word 0x080828F9


Code:

.thumb
.align 2
/*0x16824 - 00 48 00 47 JJ+1 JJ JJ 08*/
cmp r3, #5
beq .L_1
mov r0, #1
and r3, r0
cmp r3, #0
bne .L_0

.L_1:
ldr r0, =0x801682D
bx r0

.L_0:
ldr r0, =0x801682D
add r0, #0x42
bx r0


Code:

.thumb
/*Change all 1D 1E 0A 08 to the pointer (+1) to this routine, and please do the change before inserting the routine!!!!!!!!!!!!!!!!!!*/
ldr r1, .battle_flag
ldr r1, [r1]
cmp r1, #5
bne normal
ldr r1, .struct
mov r2, #0x58
lsl r2, r2, #1
add r2, r1, r2
ldrh r1, [r1, #0x28]
ldrh r2, [r2, #0x28]
mul r1, r2
cmp r1, #0
bne two_mon
normal:
ldr r1, .pokeball
bx r1
two_mon:
push {r4, lr}
mov r0, #0
mov r1, #2
ldr r2, .string_shown
ldr r3, .bag_print
ldr r4, .texter
bl jump
pop {r4, pc}
jump:
bx r4

.align 2
.battle_flag: .word 0x2022B4C
.pokeball:  .word 0x80A1E1D
.struct: .word 0x2023C3C
.bag_print: .word 0x810a1f9
.texter: .word 0x08108E71
.string_shown: .word 0x08[text offset]


Please change [text offset] to a piece of text data. The text should be like "There're 2 on the opponent side and i can't lock on the target".
Code:

.thumb
.align 2
/*21d46 - 00 47
21d94 - ZZ+1 ZZ ZZ 08*/
ldr r0, =0x2022b4c
ldr r0, [r0]
cmp r0, #5
beq double

audio:
ldr r0, =0x137
ldr r1, =0x80722A1
bl jump
ldr r1, =0x8021D4B

jump:
bx r1

double:
ldr r0, =0x2023C3C
mov r1, #0x58
lsl r1, r1, #1
add r1, r0, r1
ldrh r0, [r0, #0x28]
ldrh r1, [r1, #0x28]
add r0, r0, r1
cmp r0, #0
beq audio
ldr r1, =0x8021D4B
add r1, #8
bx r1


Code:

.thumb
.align 2
/*0x2D44C - 30 47
0x2D480 - MM+1 MM MM 08
0x2D812 - 00 00
0x2D858 - 00 00
0x2D8A6 - 00 00
0x2D8F4 - 01 1C
0x2DF36 - 08 1C
0x2DE58 - 00 00
0x2DE84 - 00 00
0x2DEA4 - 00 00
0x2DEC2 - 04 1C
0x2D874 - 6C 3D 02 02
0x2D94C - 6C 3D 02 02
0x2DF64 - 6C 3D 02 02
0x2DF04 - 6C 3D 02 02*/
ldr r6, =0x2022b4c
ldr r6, [r6]
cmp r6, #5
bne normal
ldr r6, =0x2023C3C
ldrh r6, [r6, #0x28]
cmp r6, #0
bne case_1

case_2:
mov r0, #3
b back

case_1:
mov r0, #1
b back

normal:
mov r1, #1
eor r0, r1

back:
ldr r6, =0x2023D6C
ldr r1, =0x802d451
bx r1


Code:

.thumb
.align 2
/*0x2d95c - 00 48 00 47 NN+1 NN NN 08*/
push {r4, r5, lr}
ldr r4, =0x0202402C
ldr r0, =0x02023D6C
ldrb r0, [r0]
lsr r0, r0, #1
mov r1, #0x64
mul r0, r1
add r0, r0, r4
add r4, r0, #0
mov r1, #0xb
ldr r2, =0x0802D965
bx r2


Code:

.thumb
.align 2
/*0x2d9de - 00 47
0x2da00 - UU+1 UU UU 08*/
ldr r0, =0x0202402C
ldr r1, =0x02023D6C
ldrb r1, [r1]
lsr r1, r1, #1
mov r2, #0x64
mul r1, r2
add r0, r1, r0
mov r1, #0xb
ldr r2, =0x0802D9E1
bx r2


Code:

.thumb
.align 2
/*0xEF5F8 - 10 47
0xEF680 - QQ+1 QQ QQ 08*/
ldr r2, =0x02037F1B
ldr r0, =0x02022B4C
ldr r0, [r0]
cmp r0, #5
bne normal
ldr r0, =0x02023C3C
mov r1, #0x58
lsl r1, r1, #1
add r1, r0, r1
ldrh r1, [r1, #0x28]
cmp r1, #0
beq normal
mov r1, #3
strb r1, [r2]

normal:
mov r8, r2
ldr r0, =0x080EF5FB
bx r0




After inserting the first routine, there will be a table in this format: 0A 00 05 00 0B 00 05 00 0C 00 05 00...... (The table is in the first routine and you can search for it)
The "05" is the rate of double battle in grass battles, which means 5% and you can change that on your own.
A, B, C, D are the ID of the 4 grass tile blocks and it's compatible with the clean BPRE 1.0 ROM.

As for now, there should still be some bugs like the fact that the name of captured is not shown right, but I won't do it now because I'm busy with my univ life. :)


Its actually great.
I havent tried it yet but surely will add it to my upcoming hack.
By the way one question, Inserting these routines and making changes to the pointer listed in the routines will automatically activate the double battle or there is something else I need to do?
pls answer.
thanks in advance :)

Froosty September 8th, 2016 11:48 PM

Quote:

Originally Posted by DoesntKnowHowToPlay (Post 9395872)
evolution type number

Sorry I didnt knew that you had replied to me!
BY the way "evolution type number"
"There are already existing upto 15"
it means if I have already added two new methods "male(level up)(16) and female(17)(level up)"
and If I want to make male and female evolve with stones then i should add 18 and 19 in those places ??

thanks for your previous reply and hope you wil again make a reply.
Thanks in advance. :)



EDIT:
Also Dawn stone only does the gender evolution thing, and I dont find any statement of dawn stone, can you tell me how it works with dawn stone :)
What exactly I am asking is will only dawn stone work with gender evolution or any other stone also???

BLAx501! September 9th, 2016 2:53 AM

Quote:

Originally Posted by DarkPsychic (Post 9400910)
It works like a charm, just when you insert it go to your pointer(0x800000) + 0x164 and at that offset insert
your pointer(0x800000) + 0x0179 = 0x800179 in reverse hex = 79 01 80.

I knew that but I guess I messed up with something since when buffering the number to display it on a textbox, it showed up the cursor too :/

Mystery Man September 10th, 2016 12:45 PM

There are a lot of things I like in JPAN's hacked engine. Unfortunately, it's only for Firered, and now that I am hacking Emerald, I have attempted to make something similar to it so myself and other people can access Emerald's decryptor and encryptor pretty easily via scripting. Here are my first public ASM routines, if you will.

Emerald Pokemon Decryptor
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func
.global decryptor

main:
    push {r0-r4, lr}
    ldr r0, var_8004        @slot number should be in var_8004
    ldrh r0, [r0]
    mov r1, #0x64
    mul r1, r1, r0
    ldr r0, partypoke
    add r0, r1, r0        @slot loaded

decrypt:
    ldr r1, var_8000        @load var_8000
    ldrh r1, [r1]
    ldr r2, poke_decrypt
    bl linker
    ldr r1, var_8001
    strh r0, [r1]            @store result into var_8001
    pop {r0-r4, pc}

linker:
    bx r2

.align 2
var_8000:    .word 0x20375D8
var_8001:    .word 0x20375DA
var_8004:    .word 0x20375E0
partypoke:    .word 0x20244EC
poke_decrypt:    .word 0x806A518 + 1


Var 0x8000 - what specifically do you want to decrypt? IVs? EVs?
Var 0x8004 - slot of Pokemon that you want to decrypt

Returns value at 0x8001.

What you can decrypt (thanks to Jambo51 for the list):
Spoiler:
0x00 - Pokémon ID
0x01 - Trainer IDs
0x02 - Nickname Max Length 10 (r6 should be the nickname's address)
0x03 - Font / Language
0x04 - Sanity
0x05 - Sanity
0x06 - Sanity
0x07 - OT Name Max Length 7
0x08 - Marks
0x09 - Checksum
0x0A - Filler
0x0B - Species
0x0C - Held Item
0x0D - Attack 1
0x0E - Attack 2
0x0F - Attack 3
0x10 - Attack 4
0x11 - PP 1
0x12 - PP 2
0x13 - PP 3
0x14 - PP 4
0x15 - PP Bonuses
0x16 - Coolness
0x17 - Beauty
0x18 - Cuteness
0x19 - Exp. Points
0x1A - HP EV
0x1B - Attack EV
0x1C - Defence EV
0x1D - Speed EV
0x1E - Sp. Attack EV
0x1F - Sp. Defence EV
0x20 - Happiness
0x21 - Smartness
0x22 - Pokérus Status
0x23 - Catch Location
0x24 - Catch Level
0x25 - Game of Origin
0x26 - Poke Ball
0x27 - HP IV
0x28 - Attack IV
0x29 - Defence IV
0x2A - Speed IV
0x2B - Sp. Attack IV
0x2C - Sp. Defence IV
0x2D - IsEgg
0x2E - Ability Bit
0x2F - Toughness
0x30 - Sheen
0x31 - Trainer Gender
0x32 -
0x33 -
0x34 -
0x35 -
0x36 -
0x37 - Status Ailment
0x38 - Level
0x39 - Current HP
0x3A - Total HP
0x3B - Attack
0x3C - Defence
0x3D - Speed
0x3E - Sp. Attack
0x3F - Sp. Defence
0x40 -
0x41 - Species
Of course, it will not work with everything. Some data requires more specialized routines, but it should work fine for most.

Sample #1 - return species number:
Spoiler:
...
setvar 0x8004 0x0 @slot number. 0x0 means the very first Pokemon in your party.
setvar 0x8000 0xB @refer to the list above. 0xB = species
callasm 0x8[the location of the routine + 1]
buffernumber 0x0 0x8001 @the routine returns the value at var 0x8001
...


Sample #2 - return Attack IV:
Spoiler:
...
setvar 0x8004 0x0 @slot number. 0x0 means the very first Pokemon in your party.
setvar 0x8000 0x28 @refer to the list above. 0x28 = Attack IV
callasm 0x8[the location of the routine + 1]
buffernumber 0x0 0x8001 @the routine returns the value at var 0x8001
...


Sample #3 - return happiness level:
Spoiler:
...
setvar 0x8004 0x0 @slot number. 0x0 means the very first Pokemon in your party.
setvar 0x8000 0x20 @refer to the list above. 0x20 = happiness level
callasm 0x8[the location of the routine + 1]
buffernumber 0x0 0x8001 @the routine returns the value at var 0x8001
...



Emerald Pokemon Encryptor:
Spoiler:
To simplify this for everybody, I've made it into two separate routines. If you do not plan on decreasing something, but do have plans to increase, no need to insert the subtraction routine. Now, this is more dangerous to use than the decryptor because there are no limits in the routines that will stop you from going below zero or above the max. You can add these limits by scripting.

Adding:
Spoiler:
Code:

.text
.align 2
.thumb
.thumb_func
.global encryptor_add

main:
    push {r0-r4, lr}
    ldr r0, var_8004        @slot
    ldrh r0, [r0]
    mov r1, #0x64
    mul r1, r1, r0
    ldr r0, partypoke
    add r0, r1, r0        @slot loaded

loadvars:
    ldr r1, var_8000        @index
    ldrh r1, [r1]
    ldr r2, var_8001        @value from decryptor
    ldrh r2, [r2]
    ldr r3, var_8002        @amount to increase
    ldrh r3, [r3]

add:
    add r4, r3, r2

encrypt:
    ldr r2, var_800D
    strh r4, [r2]
    ldr r3, poke_encrypt    @r0 = slot, r1 = index, r2 = new value
    bl linker

recalculate:
    ldr r3, =(0x8068D0C+1) @Pokemon stat calculator
    bl linker
    pop {r0-r4, pc}

linker:
    bx r3

.align 2
var_8000:    .word 0x20375D8
var_8001:    .word 0x20375DA
var_8002:    .word 0x20375DC
var_8004:    .word 0x20375E0
var_800D:    .word 0x20375F0
partypoke:    .word 0x20244EC
poke_encrypt:    .word 0x806ACAC + 1




Subtraction:
Spoiler:
Code:

.text
.align 2
.thumb
.thumb_func
.global encryptor_add

main:
    push {r0-r4, lr}
    ldr r0, var_8004        @slot
    ldrh r0, [r0]
    mov r1, #0x64
    mul r1, r1, r0
    ldr r0, partypoke
    add r0, r1, r0        @slot loaded

loadvars:
    ldr r1, var_8000        @index
    ldrh r1, [r1]
    ldr r2, var_8001        @value from decryptor
    ldrh r2, [r2]
    ldr r3, var_8002        @amount to increase
    ldrh r3, [r3]

sub:
    sub r4, r2, r3

encrypt:
    ldr r2, var_800D
    strh r4, [r2]
    ldr r3, poke_encrypt    @r0 = slot, r1 = index, r2 = new value
    bl linker

recalculate:
    ldr r3, =(0x8068D0C+1) @Pokemon stat calculator
    bl linker
    pop {r0-r4, pc}

linker:
    bx r3

.align 2
var_8000:    .word 0x20375D8
var_8001:    .word 0x20375DA
var_8002:    .word 0x20375DC
var_8004:    .word 0x20375E0
var_800D:    .word 0x20375F0
partypoke:    .word 0x20244EC
poke_encrypt:    .word 0x806ACAC + 1



Var 0x8000 - what to encrypt from the same list.
Var 0x8001 - the value the decryptor returns if you used it previously. Can be 0 in case you just want to set.
Var 0x8002 - amount to decrease/increase/set
Var 0x8004 - Slot of Pokemon you want to check.

If you set 0x8001 to 0, no addition or subtraction will be done. It just encrypts/sets the number you have on 0x8002. So if you are encrypting species, let's say, Mudkip, and want to change your Pokemon to, say, Voltorb, set var 0x8001 to 0 and var 0x8002 to 100 or 0x64 (its species number).

Sample #1 Changing the Pokemon in slot 1 to Voltorb:
Spoiler:

...
special 0xA2 @this special makes the player choose a Pokemon and returns slot number to 0x8004
waitstate
compare 0x8004 0x5 @check if player selected a Pokemon.
if 0x2 goto @no_poke_selected
setvar 0x8000 0xB @refer to the list above. 0xB = species
setvar 0x8001 0x0 @be sure 0x8001 is 0 if you just want to set it to a different species number.
setvar 0x8002 0x64 @Voltorb's species number.
callasm 0x8[the location of the routine + 1]
...

Sample #2 Make a Pokemon have 31 IVs in HP:
Spoiler:
...
setvar 0x8004 0x0 @slot number. 0x0 means the very first Pokemon in your party.
setvar 0x8000 0x27 @refer to the list above. 0x27 = HP IV
setvar 0x8001 0x0 @be sure 0x8001 is 0 if you just want to set.
setvar 0x8002 31 @number to set to.
callasm 0x8[the location of the routine + 1]
...


Sample #3 Add HP IVs
Spoiler:
...
setvar 0x8004 0x0 @slot number. 0x0 means the very first Pokemon in your party.
setvar 0x8000 0x27 @refer to the list above. 0x27 = HP IV
callasm 0x8[the location of the decryptor] @decryptor stores the Pokemon's HP IV into 0x8001
compare 0x8001 31 @check what the decryptor returned, skip if already maxed.
if 0x1 goto @maxed_out_already
setvar 0x8002 1 @add 1 IV
@set number to the amount you want to add.
callasm 0x8[the location of the routine + 1] @encrypt
...



I do have a few more ASM routines that appear to work correctly, but obviously, I am an ASM neophyte, so before posting the other ones, I would like to become more adept at doing these sorts of things to ensure my routines will give people the least amount of problems possible. I am posting this under the assumption that nobody else has publicized a routine like this for Emerald, so if somebody else has already done it before the time this has been posted, let me know so I can delete this post.

BluRose September 10th, 2016 2:36 PM

Quote:

Originally Posted by Bsantosh909 (Post 9401108)
Its actually great.
I havent tried it yet but surely will add it to my upcoming hack.
By the way one question, Inserting these routines and making changes to the pointer listed in the routines will automatically activate the double battle or there is something else I need to do?
pls answer.
thanks in advance :)

hiya!
old post routines:
Spoiler:
if you're talking about the routines under "old post," then there will be a table
it's 0A 00 05 00 0B 00 05 00 0C 00 05 00 0D 00 05 00
each entry is four bytes
0A 00 05 00
0A - tile id
00 - nothing afaik
05 - percentage of a wild double battle happening
00 - nothing

for the new routines in the github link, i believe it's about a 50% chance (the last time i had it explained to me it was ahaha)

EDIT: well, i guess i'll ask something
can someone make fbi's set static party level routine only work if the pokémon is above the level indicated and/or for a certain slot only? either would work, but preferably for a certain slot~

Froosty September 10th, 2016 8:30 PM

Quote:

Originally Posted by BluRose (Post 9403163)
hiya!
old post routines:
Spoiler:
if you're talking about the routines under "old post," then there will be a table
it's 0A 00 05 00 0B 00 05 00 0C 00 05 00 0D 00 05 00
each entry is four bytes
0A 00 05 00
0A - tile id
00 - nothing afaik
05 - percentage of a wild double battle happening
00 - nothing

for the new routines in the github link, i believe it's about a 50% chance (the last time i had it explained to me it was ahaha)

EDIT: well, i guess i'll ask something
can someone make fbi's set static party level routine only work if the pokémon is above the level indicated and/or for a certain slot only? either would work, but preferably for a certain slot~

Thanks for reply and one more thing,
Will the old routice work nicely??
I mean no major bugs??
If there are ani major or minor bugs pls state if you know :)

BluRose September 10th, 2016 8:44 PM

Quote:

Originally Posted by Bsantosh909 (Post 9403451)
Thanks for reply and one more thing,
Will the old routice work nicely??
I mean no major bugs??
If there are ani major or minor bugs pls state if you know :)

so there are a few things, but nothing that crashes/freezes/stops gameplay
if you catch the pokémon on the left, it displays the one on the right's name and the sprite after catching. it's fine when nicknamed and all that, though. the one on the right is also the only one faded when the battle starts
you can select run for each pokémon (twice)
you can use poké balls twice, but only when there is one pokémon
when a pokémon faints, it asks if you'd like to switch right away. this is how it generally works, BUT when you have no pokémon to switch to, it still asks but then continues the battle regardles of choice.

EDIT: probaby more i just haven't encountered them ahaha

Froosty September 10th, 2016 9:26 PM

1 Attachment(s)
Quote:

Originally Posted by BluRose (Post 9403460)
so there are a few things, but nothing that crashes/freezes/stops gameplay
if you catch the on the left, it displays the one on the right's name and the sprite after catching. it's fine when nicknamed and all that, though. the one on the right is also the only one faded when the battle starts
you can select run for each (twice)
you can use poké balls twice, but only when there is one
when a faints, it asks if you'd like to switch right away. this is how it generally works, BUT when you have no to switch to, it still asks but then continues the battle regardles of choice.

EDIT: probaby more i just haven't encountered them ahaha

So these are only the minor bugs that wont affect the gameplay!
Thanks most probably i will use it :)


EDIT2: result in attachment, it is really awesome

Froosty September 11th, 2016 8:46 PM

Quote:

.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
can you pls tell me whats the pointer I should include in the highlighted position.
When i search for 00 07 0a 00 I get too many result so pls help me! :(

Lance32497 September 11th, 2016 11:48 PM

Quote:

Originally Posted by The_learner (Post 9405055)
can you pls tell me whats the pointer I should include in the highlighted position.
When i search for 00 07 0a 00 I get too many result so pls help me! :(

You're doing it right, you just insert the location of those bytes.

Froosty September 12th, 2016 12:00 AM

Quote:

Originally Posted by Lance32497 (Post 9405194)
You're doing it right, you just insert the location of those bytes.

sorry but its the thing I am trying to tell!!
there are so many of these bytes,
which exact location do I use????

Lance32497 September 12th, 2016 7:03 AM

Quote:

Originally Posted by The_learner (Post 9405200)
sorry but its the thing I am trying to tell!!
there are so many of these bytes,
which exact location do I use????

Use any of those.

Froosty September 12th, 2016 7:05 AM

Quote:

Originally Posted by Lance32497 (Post 9405721)
Use any of those.

Thanks for reply, I will check it and inform you if its not working :)

Wildchild September 15th, 2016 5:07 PM

Hi! I'm new to PC and started to get a look at ASM hacking. I implemented the sitrus berry update for fire red but when I use the berry in the overworld it heals my pokemon for 50% HP instead of 25%. Is something wrong with the code or am I missing something?

jiangzhengwenjzw September 16th, 2016 1:11 AM

Quote:

Originally Posted by The_learner (Post 9401108)
Its actually great.
I havent tried it yet but surely will add it to my upcoming hack.
By the way one question, Inserting these routines and making changes to the pointer listed in the routines will automatically activate the double battle or there is something else I need to do?
pls answer.
thanks in advance :)

It's automatic. BTW the codes were just updated 3 days ago in order to fix other bugs.

Froosty September 16th, 2016 1:35 AM

Quote:

Originally Posted by jiangzhengwenjzw (Post 9411560)
It's automatic. BTW the codes were just updated 3 days ago in order to fix other bugs.

Oh its great!
By the way what are the bug fixed in the latest code!
.
I have also found one minir bug!
This double battle isnt much compatible with day and night!
Some colour issues(i.e constant shifitng between day and night automatically in random way)

jiangzhengwenjzw September 16th, 2016 4:32 AM

Quote:

Originally Posted by The_learner (Post 9411573)
Oh its great!
By the way what are the bug fixed in the latest code!
.
I have also found one minir bug!
This double battle isnt much compatible with day and night!
Some colour issues(i.e constant shifitng between day and night automatically in random way)

In the latest version, the second pokemon's turn will be skipped if you use "run" or throw a pokeball.
For the color issue, I don't know what it is. I just changed the original codes which make 1 pokemon fade to the one making 2 pokemons fade in double wild battle, which is the only part related to color. (I don't use D&N in my hack, as I think it's really not beautiful :/)

Froosty September 16th, 2016 4:46 AM

Quote:

Originally Posted by jiangzhengwenjzw (Post 9411656)
In the latest version, the second pokemon's turn will be skipped if you use "run" or throw a pokeball.
For the color issue, I don't know what it is. I just changed the original codes which make 1 pokemon fade to the one making 2 pokemons fade in double wild battle, which is the only part related to color. (I don't use D&N in my hack, as I think it's really not beautiful :/)

Have you changed this update in the github only or also in the old post (asm codes)
Because I am currenly using your asm codes :)

jiangzhengwenjzw September 16th, 2016 5:48 AM

Quote:

Originally Posted by The_learner (Post 9411675)
Have you changed this update in the github only or also in the old post (asm codes)
Because I am currenly using your asm codes :)

On github only. The old post is veeeery old, please don't use it

DarkPsychic September 16th, 2016 3:39 PM

Has anyone else tried this EV-Reducing Berries ?

I keep trying it but to no avail I just can't seem to get it to work.

I assemble the routine and place it at 0x7900B0, then edit the given script to;
XSEscript:
Code:

#dynamic 0x740000
'----Main----
#org @start
special 0x9F                            ///Choose Pokemon from Party & store it on var 0x8004
waitstate
bufferpartypokemon 0x0 0x8004
setvar 0x800D 0x1A                  ///EV-stat 0x1A = HP
setvar 0x8000 0xA                    ///EV-stat amount to subtract 0xA = 10
callasm 0x87900B1                  ///EV-Reducing Berries ASM(pointer + 1)
compare 0x800D 0xFF            ///Compare last result to 255
if 0x1 goto @snippetFail
buffernumber 0x1 0x800F
msgbox @stringDecrese 0x6
removeitem 0x99 0x1              ///Item 0x99 = Pomeg Berry
release
end

'---------------
#org @snippetFail
msgbox @stringFail 0x6
release
end

'---------
' Strings
'---------
#org @stringDecrese
= [buffer1] lost [buffer2]\nHP EVs!

#org @stringFail
= It would have no effect!



Is there something I'm doing wrong or is there a better way to do this?

I'm merely trying to recreate the Pomeg Berry from Emerald in Fire Red...
Not to mention EV-Reducing Berries are rather useful when EV training...

Also since I'm here I was wondering what gltiches from the first gen could be simulated with asm in Fire Red?

Would like to make a working MissingNo that will check the players name and base its form off of the characters in the certain spots like in Blue and Red. Would be cool to have the item duplication glitch as well but one step at a time...

The reason I ask is because I'm trying to make a Glitch/Error Version...
Keeping their sporadic nature but making them contained and fun to play with...
GlitchQuests are rather fun when they work and do some crazy stuffs>_< hahaha.

Anyway thanks for the time and any advice given...

Froosty September 16th, 2016 10:59 PM

Quote:

Originally Posted by jiangzhengwenjzw (Post 9411798)
On github only. The old post is veeeery old, please don't use it

I lately tried using the github codes but I am having some problem with make.gnu so I have already uninstalled those.
so i will still be using the old post!
It is still an amazing feature for me :)

NewDenverCity September 19th, 2016 10:00 AM

SPEEDING UP FIRERED
All this does is make the turbo button on VBA work faster.
Emerald solution is found here. That's also the source of my implementation of this.
Code:

.thumb

.org 0x890
main:
        push {lr}
        ldr r2, super_bits
        ldrh r3, [r2]
        mov r0, #1
        bic r3, r0
        strh r3, [r2]
loop_label:
        swi #2
        ldrh r3, [r2]
        tst r3, r0
        beq loop_label
        pop {pc}

.align 2
super_bits: .word 0x0300310C



Deokishisu September 19th, 2016 2:11 PM

Spoiler:
Quote:

Originally Posted by NewDenverCity (Post 9416548)
SPEEDING UP FIRERED
All this does is make the turbo button on VBA work faster.
Emerald solution is found here. That's also the source of my implementation of this.
Code:

.thumb

.org 0x890
main:
    push {lr}
    ldr r2, super_bits
    ldrh r3, [r2]
    mov r0, #1
    bic r3, r0
    strh r3, [r2]
loop_label:
    swi #2
    ldrh r3, [r2]
    tst r3, r0
    beq loop_label
    pop {pc}

.align 2
super_bits: .word 0x0300310C





What is this modifying? Is it making some big looping function more efficient?

esperance September 19th, 2016 5:49 PM

Quote:

Originally Posted by Deokishisu (Post 9416894)
What is this modifying? Is it making some big looping function more efficient?

I believe it modifies the "wait for interrupt" main loop for the entire game.

NewDenverCity September 19th, 2016 6:37 PM

Quote:

Originally Posted by Deokishisu (Post 9416894)
What is this modifying? Is it making some big looping function more efficient?

Lost is correct, it just edits the function that waits for the interrupt. There's a lot in there that can be left out, and this increases the functionality of it.

Lunos September 22nd, 2016 7:46 AM

Just wanted to ask, did someone thought about a routine that lets you choose a Pokémon from your team and then check its EVs, IVs, or both? And I mean as in exact numbers instead of vague phrases like in the DS Games xD
(I don't really feel like asking the creator of a certain HackROM to share his work because I don't want to be disrespectful towards him in any way, and taking into account that people can just request routines in this thread, welp.. there's that)

Squeetz September 22nd, 2016 10:15 PM

Quote:

Originally Posted by Lunos (Post 9421144)
Just wanted to ask, did someone thought about a routine that lets you choose a Pokémon from your team and then check its EVs, IVs, or both?

Well, there's this, which is pretty dang sexy: http://www.pokecommunity.com/showpost.php?p=9229108 (The EV-IV display screen)

Lunos September 23rd, 2016 3:58 AM

Quote:

Originally Posted by Squeetz (Post 9422217)
Well, there's this, which is pretty dang sexy: http://www.pokecommunity.com/showpost.php?p=9229108 (The EV-IV display screen)

Yeah, saw it, I was thinking about something more simple-looking xD ..
Mainly a textbox saying "Your Pokemon IVs are X X X X X X", for example.


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.