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)

dearman4 July 19th, 2018 3:17 PM

Quote:

Originally Posted by FBI (Post 8509928)

Toggling Capturability of Pokemon



So it's quite likely that maybe you want a Pokemon to be uncapturable, and at the same time you don't want to diminish it's catch rate to 0 in your Pokemon editor. Or perhaps you used the "capture trainer Pokemon" hack and you don't want it to work for all trainers. No problem, this is the hack for you :P

Basically it checks if variable 0x8000 is 0x1 or not. If it's 0x1, then any Pokemon you encounter (trainer or wild, via script or natural encounter) will become uncapturable even with the master ball. Simply set 0x8000 back to normal for the original game mechanics.
Note: If you use this hack, to say make it so the player can only capture a certain trainer's Pokemon, you will need to set 0x8000 right before the encounter, and unset it after (which is quite simple)
Note2: This hack won't let you capture trainer Pokemon, you need to have the capture trainer Pokemon hack from last time to create that effect.

How to insert:

First compile the following ASM code and insert into free space:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

main:
        ldr r0, =(0x2022B4C)
        ldr r1, [r0]
        ldr r2, .VAR
        ldrb r2, [r2]
        cmp r2, #0x1
        beq uncatchable
        ldr r0, = (0x802D490 +1)
        bx r0

uncatchable:
        ldr r0, = (0x802D460 +1)
        bx r0

.align 2
.VAR:
        .word 0x020270B8 + (0x8000 * 2) @change to var of your choice if you want




Here is a compiled version:
Code:

05 48 01 68 03 4A 12 78 01 2A 01 D0 03 48 00 47 03 48 00 47 B8 70 03 02 4C 2B 02 02 91 D4 02 08 61 D4 02 08


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

01 48 00 47 00 00 XX XX XX 08


Where XX XX XX is the reverse hex pointer to where you inserted the above routine. That's it :)
EDIT: Add one to the pointer.

Here's a pesky Rattata:
http://i.imgur.com/JpL4im1.png
(Yes, the Pokeball animation is still there, this was taken after it.)

I tried this in Emerald and it didn't work, I added in the pointer as +1 of the offset of the compiled code and tried setting the variable in a static encounter script and by walking through a script event and neither worked, does this just not work in Emerald? If so, is there another way of doing this that I can try?

Lance Koijer 2.0 July 19th, 2018 8:39 PM

Quote:

Originally Posted by dearman4 (Post 9902602)
I tried this in Emerald and it didn't work, I added in the pointer as +1 of the offset of the compiled code and tried setting the variable in a static encounter script and by walking through a script event and neither worked, does this just not work in Emerald? If so, is there another way of doing this that I can try?

The code will not work in Emerald because it is an ASM for FireRed only, as far as I know.

dearman4 July 19th, 2018 8:41 PM

Quote:

Originally Posted by Lance Koijer 2.0 (Post 9902691)
The code will not work in Emerald because it is an ASM for FireRed only, as far as I know.

Do you know of anything comparable to this that works for emerald?

Lancekoijerwillborough July 19th, 2018 10:07 PM

Quote:

Originally Posted by dearman4 (Post 9902692)
Do you know of anything comparable to this that works for emerald?

TOGGLING CAPTURABILITY OF POKEMON: EM

Basically, it is a port of FBI's Toggling Capturability Routine available only on Fire Red to Emerald. This port makes a certain Pokemon uncapturable by just setting var 8000 to 0x1. This only works on Emerald .

How to insert:

First compile the following ASM code and insert into free space:
Spoiler:

.text
.align 2
.thumb
.thumb_func

main:
ldr r0, =(0x2022fec)
ldr r1, [r0]
ldr r2, .VAR
ldrb r2, [r2]
cmp r2, #0x1
beq uncatchable
ldr r0, =(0x805635c+1)
bx r0

uncatchable:
ldr r0, =(0x805632a+1)
bx r0

.align 2
.VAR:
.word 0x20375D8


Here is a compiled version:
Code:

05 48 01 68 03 4A 12 78 01 2A 01 D0 03 48 00 47 03 48 00 47 D8 75 03 02 EC 2F 02 02 5D 63 05 08 2B 63 05 08


Now navigate to 0x5631E and insert the following:

Code:

01 48 00 47 00 00 XX XX XX 08


Where XX+1 XX XX is the reverse hex pointer to where you inserted the above routine. That's it :)

NOTE: This only prints the text "The TRAINER blocked the ball! Don't be a Thief!". I suggest changing this to "The ball is Blocked! This Pokemon cannot be caught!"


Optional:
Insert the following in free-space location in your ROM:

AAAAAA:
Code:

CE DC D9 00 BC BB C6 C6 00 DD E7 00 D6 E0 E3 D7 DF D9 D8 AB FF


BBBBBB:
Code:

CE DC DD E7 00 CA E3 DF D9 E1 E3 E2 00 D7 D5 E2 E2 E3 E8 00 D6 D9 00 D7 D5 E9 DB DC E8 AB FF


In 0x5CC64C, insert the reverse pointer of AAAAAA (do not add 1)
In 0x5CC650, insert the reverse pointer of BBBBBB (do not add 1)


NOTE: This will replace the "The TRAINER blocked the BALL" and "Don't be a thief!" strings.

https://scontent.fmnl3-1.fna.fbcdn.net/v/t1.15752-9/37132326_1767827489951966_8381321768370962432_n.png?_nc_cat=0&oh=0f4777dd9ce48a5e35d1bf29c8576d81&oe=5BD64FEBhttps://scontent.fmnl3-1.fna.fbcdn.net/v/t1.15752-9/37565425_1767827499951965_3780329454006435840_n.png?_nc_cat=0&oh=705f5c32dfde7c10f019eba9b7ee7a18&oe=5BCEF31C


All credits goes to FBI.

dearman4 July 19th, 2018 10:52 PM

Quote:

Originally Posted by Lancekoijerwillborough (Post 9902740)
TOGGLING CAPTURABILITY OF POKEMON: EM

Basically, it is a port of FBI's Toggling Capturability Routine available only on Fire Red to Emerald. This port makes a certain Pokemon uncapturable by just setting var 8000 to 0x1. This only works on Emerald .

How to insert:

First compile the following ASM code and insert into free space:
Spoiler:

.text
.align 2
.thumb
.thumb_func

main:
ldr r0, =(0x2022fec)
ldr r1, [r0]
ldr r2, .VAR
ldrb r2, [r2]
cmp r2, #0x1
beq uncatchable
ldr r0, =(0x805635c+1)
bx r0

uncatchable:
ldr r0, =(0x805632a+1)
bx r0

.align 2
.VAR:
.word 0x20375D8


Here is a compiled version:
Code:

05 48 01 68 03 4A 12 78 01 2A 01 D0 03 48 00 47 03 48 00 47 D8 75 03 02 EC 2F 02 02 5D 63 05 08 2B 63 05 08


Now navigate to 0x5631E and insert the following:

Code:

01 48 00 47 00 00 XX XX XX 08


Where XX+1 XX XX is the reverse hex pointer to where you inserted the above routine. That's it :)

NOTE: This only prints the text "The TRAINER blocked the ball! Don't be a Thief!". I suggest changing this to "The ball is Blocked! This Pokemon cannot be caught!"

All credits goes to FBI.

Thanks a million! Will try it out when I get home :)
And sorry if this is a dumb question, but how do I change the message when the pokeball is blocked?

Lancekoijerwillborough July 20th, 2018 12:01 AM

Quote:

Originally Posted by dearman4 (Post 9902754)
Thanks a million! Will try it out when I get home :)
And sorry if this is a dumb question, but how do I change the message when the pokeball is blocked?

Insert the following in free-space location in your ROM:

AAAAAA:
Code:

CE DC D9 00 BC BB C6 C6 00 DD E7 00 D6 E0 E3 D7 DF D9 D8 AB FF


BBBBBB:
Code:

CE DC DD E7 00 CA E3 DF D9 E1 E3 E2 00 D7 D5 E2 E2 E3 E8 00 D6 D9 00 D7 D5 E9 DB DC E8 AB FF


In 0x5CC64C, insert the reverse pointer of AAAAAA (do not add 1)
In 0x5CC650, insert the reverse pointer of BBBBBB (do not add 1)


NOTE: This will replace the "The TRAINER blocked the BALL" and "Don't be a thief!" strings.
Welp, that's fine for me. The previous strings are kind of not friendly lol

https://scontent.fmnl3-1.fna.fbcdn.net/v/t1.15752-9/37132326_1767827489951966_8381321768370962432_n.png?_nc_cat=0&oh=0f4777dd9ce48a5e35d1bf29c8576d81&oe=5BD64FEBhttps://scontent.fmnl3-1.fna.fbcdn.net/v/t1.15752-9/37565425_1767827499951965_3780329454006435840_n.png?_nc_cat=0&oh=705f5c32dfde7c10f019eba9b7ee7a18&oe=5BCEF31C

UltimaSoul July 20th, 2018 7:53 PM

Quote:

Originally Posted by tkim (Post 9722274)
[FR] Volt Tackle port from EM:

If you have free space from 0x270670-0x270741 (0xD2 bytes), use the IPS patch I provide here. ...It's a long story, so I will expand on this when I get the time. Fully working, I promise. You're gonna love it.

edit: A bit of explanation now: I took a look at an Emerald disassembly and found the routine that calls to check if the egg at the Day-Care is a pichu and if either of the parents are holding a Light Ball. I ported that exact routine into FR, but I had to make a copy of the routine at sub_80460D4 as to include the pichu check. Then I had to make special 0xB8 call the new routine instead of sub_80460D4. Since I had made a copy of the routine I also had to make sure the new routine used all the same offsets as before, and therefore I placed the routine at 0x270670, which I happened to have free space. I wanted to place the routine at something like 0x760000 or higher, but the old offsets wouldn't work any more. Down below are the uncompiled stuff:

This routine (located at 0x270670 in my patch) is a copy of the routine at 0x0460D4 but now includes the pichu egg check (in orange):
Code:

sub_80460D4:                @ CODE XREF: sp0B8_daycare+Cp

var_18        = -0x18
var_14        = -0x14

        PUSH    {R4-R6,LR}
        SUB    SP, SP,    #0x6C
        ADD    R5, R0,    #0
        ADD    R6, SP,    #0x7C+var_18
        ADD    R1, R6,    #0
        BL    sub_8046000
        ADD    R4, SP,    #0x7C+var_14
        STRH    R0, [R4]
        ADD    R0, R4,    #0
        ADD    R1, R5,    #0
        BL    incense_effects
        LDRH    R1, [R4]
        MOV    R0, SP
        ADD    R2, R5,    #0
        BL    sub_8046208
        MOV    R0, SP
        ADD    R1, R5,    #0
        BL    sub_8045AC0
        LDRB    R0, [R6,#1]
        MOV    R2, #0x8C @ '?'
        ADD    R1, R0,    #0
        MUL    R1, R2
        ADD    R1, R5,    R1
        LDRB    R0, [R6]
        MUL    R2, R0
        ADD    R2, R5,    R2
        MOV    R0, SP
        BL    daycare_build_child_moveset
        ldrh r0, [r4]
        cmp r0, #0xAC
        bne _08070918
        mov r0, sp
        add r1, r5, #0
        bl sub_82706FC
_08070918:

        MOV    R2, SP
        ADD    R2, #0x6A @ 'j'
        MOV    R0, #1
        STRB    R0, [R2]
        MOV    R0, SP
        MOV    R1, #0x2D @ '-'
        BL    pokemon_setattr
        LDR    R0, off_804614C
        MOV    R1, #0xFA @ '?'
        LSL    R1, R1,    #1
        ADD    R0, R0,    R1
        MOV    R1, SP
        MOV    R2, #0x64 @ 'd'
        BL    memcpy
        BL    party_compaction
        BL    party_count_pokemon
        ADD    R0, R5,    #0
        BL    sub_8045F70
        ADD    SP, SP,    #0x6C
        POP    {R4-R6}
        POP    {R0}
        BX    R0
@ End of function sub_80460D4

@ ---------------------------------------------------------------------------
.align 2
off_804614C:    .long 0x2024284        @ DATA XREF: sub_80460D4+52r


This routine (located at 0x2706FC in my patch) handles the volt tackle inheriting:
Code:

sub_80707A4:
    push {r4-r6,lr}
    add r5, r0, #0
    add r4, r1, #0
    add r0, r4, #0
    mov r1, #0xC
    bl pokemon_getattr_encrypted
    add r6, r0, #0
    add r4, #0x8C
    add r0, r4, #0
    mov r1, #0xC
    bl pokemon_getattr_encrypted
    cmp r6, #0xCA
    beq _080707C6
    cmp r0, #0xCA
    bne _080707E2

_080707C6:
    mov r4, #0xAC
    lsl r4, r4, #0x1
    add r0, r5, #0
    add r1, r4, #0
    bl pokemon_moveset_pad_
    lsl r0, r0, #0x10
    ldr r1, =(0xffff0000)
    cmp r0, r1
    bne _080707E2
    add r0, r5, #0
    add r1, r4, #0
    bl sub_803EB94

_080707E2:
    pop {r4-r6}
    pop {r0}
    bx r0


This last one makes sure the old offsets work correctly from the new offsets:
Code:

.text
.align 2
.thumb
.thumb_func

.org 0x0462B8
bl 0x270670

.org 0x27067A
bl 0x046000

.org 0x270686
bl 0x045FA0

.org 0x270690
bl 0x046208

.org 0x270698
bl 0x045AC0

.org 0x2706AE
bl 0x045CD0

.org 0x2706BC
bl 0x2706FC

.org 0x2706CC
bl 0x04037C

.org 0x2706DC
bl 0x1E5E78

.org 0x2706E0
bl 0x0937DC

.org 0x2706E4
bl 0x040C3C

.org 0x2706EA
bl 0x045F70

.org 0x270706
bl 0x03FD44

.org 0x270712
bl 0x03FD44

.org 0x270726
bl 0x03E89C

.org 0x270736
bl 0x03EB94


If anybody has a better way of porting this, please post it here.
edit2: I could probably just use bx r3?

I improved this ASM so you only need to assemble it once and also it works in any free space occupied.

Just replace the offset at MyLoc with your desired free space and then copy paste the assembled code to 0x0462B0 and MyLoc as appropriate.

Code:

.thumb
.align

.equ MyLoc, 0x720000 @insert your location here
.equ RomAreaOffset,        0x8000000       

.org 0x0462B0, 0xFF
ldr  r3, clean_hook
bx  r3
.align 2
clean_hook: .word RomAreaOffset+hook_handle+1

.org MyLoc, 0xFF
hook_handle:
ldr r0, [r0]
mov r1, #0xBE
lsl r1, r1, #6
add r0, r0, r1
bl  sub_80460D4
ldr r3, return
bx  r3

.align 2
.pool

.align 2

sub_80460D4:
                PUSH    {R4-R6,LR}
        SUB    SP, SP,    #0x6C
        ADD    R5, R0,    #0
        ADD    R6, SP,    #0x64
        ADD    R1, R6,    #0
        ldr    r3, sub_8046000
                bl    call_external_function
        ADD    R4, SP,    #0x68
        STRH    R0, [R4]
        ADD    R0, R4,    #0
        ADD    R1, R5,    #0
                ldr  r3, incense_effects
        bl    call_external_function
        LDRH    R1, [R4]
        MOV    R0, SP
        ADD    R2, R5,    #0
        ldr  r3, sub_8046208
                bl    call_external_function
        MOV    R0, SP
        ADD    R1, R5,    #0
                ldr  r3, sub_8045AC0
        bl  call_external_function
        LDRB    R0, [R6,#1]
        MOV    R2, #0x8C @ '?'
        ADD    R1, R0,    #0
        MUL    R1, R2
        ADD    R1, R5,    R1
        LDRB    R0, [R6]
        MUL    R2, R0
        ADD    R2, R5,    R2
        MOV    R0, SP
        ldr  r3, daycare_build_child_moveset
                bl    call_external_function
        ldrh r0, [r4]
        cmp r0, #0xAC
        bne _08070918
        mov r0, sp
        add r1, r5, #0
        bl sub_80707A4

_08070918:
        MOV    R2, SP
        ADD    R2, #0x6A @ 'j'
        MOV    R0, #1
        STRB    R0, [R2]
        MOV    R0, SP
        MOV    R1, #0x2D @ '-'
        ldr    r3, pokemon_setattr
                bl    call_external_function
        LDR    R0, off_804614C
        MOV    R1, #0xFA @ '?'
        LSL    R1, R1,    #1
        ADD    R0, R0,    R1
        MOV    R1, SP
        MOV    R2, #0x64 @ 'd'
        ldr  r3, memcpy
                bl  call_external_function
        ldr  r3, party_compaction
                bl  call_external_function
        ldr  r3, party_count_pokemon
                bl  call_external_function
        ADD    R0, R5,    #0
        ldr    r3, sub_8045F70
                bl    call_external_function
        ADD    SP, SP,    #0x6C
        POP    {R4-R6}
        POP    {R0}
        BX    R0

.align 2
.pool

.align 2

sub_80707A4:
    push {r4-r6,lr}
    add r5, r0, #0
    add r4, r1, #0
    add r0, r4, #0
    mov r1, #0xC
    ldr r3, pokemon_getattr_encrypted
        bl call_external_function
    add r6, r0, #0
    add r4, #0x8C
    add r0, r4, #0
    mov r1, #0xC
    ldr r3, pokemon_getattr_encrypted
        bl call_external_function
    cmp r6, #0xCA
    beq _080707C6
    cmp r0, #0xCA
    bne _080707E2

_080707C6:
    mov r4, #0xAC
    lsl r4, r4, #0x1
    add r0, r5, #0
    add r1, r4, #0
        ldr r3, pokemon_moveset_pad_
    bl call_external_function
    lsl r0, r0, #0x10
    ldr r1, =(0xffff0000)
    cmp r0, r1
    bne _080707E2
    add r0, r5, #0
    add r1, r4, #0
    ldr r0, sub_803EB94
        bl call_external_function_r0

_080707E2:
    pop {r4-r6}
    pop {r0}
    bx r0

.align 2
.pool

.align 2

call_external_function:
bx r3

.align 2

call_external_function_r0:
bx r0

.align 2
return: .word 0x80462BC + 1
sub_8046000: .word 0x8046000 + 1
incense_effects: .word 0x8045FA0 + 1
sub_8046208: .word 0x8046208 + 1
sub_8045AC0: .word 0x8045AC0 + 1
daycare_build_child_moveset: .word 0x8045CD0 + 1
pokemon_setattr: .word 0x804037C + 1
memcpy: .word 0x81E5E78 + 1
party_compaction: .word 0x80937DC + 1
party_count_pokemon: .word 0x8040C3C + 1
sub_8045F70: .word 0x8045F70 + 1
off_804614C: .word 0x2024284
pokemon_getattr_encrypted: .word 0x0803FD44 + 1
pokemon_moveset_pad_: .word 0x0803E89C + 1
sub_803EB94: .word 0x0803EB94 + 1


Feel free to reply with questions or suggestions for improvements.

dearman4 July 20th, 2018 9:34 PM

Quote:

Originally Posted by jiangzhengwenjzw (Post 9229108)
Misc:

A EV-IV Display Screen


RENEWAL:
Spoiler:
The new version is here (no difference, but codes will be automatically inserted into the ROM):
FIRERED:
https://github.com/jiangzhengwenjz/EV-IV-Screen
EMERALD:
https://github.com/jiangzhengwenjz/EV-IV-Screen-EM
Read Readme.md to know how to compile.

Quick Preview:
http://i869.photobucket.com/albums/ab256/jiangzhengwenjz/q_zpshnquzant.gifhttps://i.imgur.com/18HjHg0.png

OLD CONTENT:
Spoiler:
Quick Preview:
http://i869.photobucket.com/albums/ab256/jiangzhengwenjz/q_zpshnquzant.gif
Download:
https://github.com/jiangzhengwenjz/EV-IV-Screen/tree/c1b303e17788f21e1a663204f9db59ffdcfc2a2d
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



SO I have tried to install Devkit and any time I try the make command, I get errors and the program crashes, I would love to use this but without the ability to get the code for it inserted into the ROM I can't use it, does anyone have the compiled hex code for this?

Super Versekr Dark August 19th, 2018 8:27 AM

Excuse me, can you put Ruby's routines here?

BrittneySpearsMom August 19th, 2018 4:09 PM

Forgive me for not contributing, but I had to ask.

At the risk of being totally unhelpful to the thread: does anyone know of working routines for attack boosting Gems (Normal Gem, Flying Gem, etc., etc.) for either FireRed or Emerald? I've seen a certain Japanese hack of FireRed has gotten them to work and it looks like Pokemon Clover either has implemented them already or is planning to offer them eventually.

Skeli August 23rd, 2018 2:13 PM

The bag expansion for Fire Red has been completely revamped and should work now:
https://www.pokecommunity.com/showthread.php?p=9743323#9743323

tkim August 25th, 2018 5:30 PM

Quote:

Originally Posted by Pokemon_XY (Post 9010564)

Time Box triggered along with the Start Menu


Preview: (Click to see the GIF animation)
Attachment 77173
The routines are only for FR. I haven't found any bugs in it. However, the CPU will run much more instructions so that it will be a bit (really?) slower when you open the 'pokemon', 'bag'..... menus.
1) Insert the RTC routine via the tool 'DNS'.
2) Insert these routines and do the byte changes:
Routine I:
Spoiler:
byte changes:
Code:

0x6F09C - 00 48 00 47 XX+1 XX XX 08
change all the 0x8750000 in the routine to the insert offset of the routine.
change all the 0x8750001 in the routine to the insert offset + 1 of the routine.


routine:
Code:

.thumb
bl box_func
ldr r1, =0x20370FF
ldrb r0, [r1]
add r0, #1
strb r0, [r1]
mov r0, #0
add sp, sp, #0xC
pop {r4, pc}
.ltorg

box_func:
push {r4, lr}
ldr r4, =0x2037101
ldr r0, =(0x8750000 + rbox_config)
ldr r3, =0x8003ce5
bl call_r3
strb r0, [r4]
ldr r3, =0x8003fa1
bl call_r3
ldrb r0, [r4]
mov r1, #0
ldr r3, =0x80F6F1D
bl call_r3
bl print_string
ldr r0, =(0x8750001 + print_string)
mov r1, #2
ldr r3, =0x807741D
bl call_r3
ldr r1, =0x20370C0
strh r0, [r1]
pop {r4, pc}
.ltorg

print_string:
push {r4-r7, lr}
sub sp, sp, #0xC
ldr r0, =0x2021cd0
add r7, r0, #0
ldr r1, =0x300553c
ldrb r5, [r1, #7] @minute
ldrb r6, [r1, #8] @second
ldrb r1, [r1, #6] @hour
mov r2, #1
mov r3, #2
ldr r4, =0x8008E79
bl call_r4
bl go_padding
ldr r0, =0x2021CF0
add r7, r0, #0
add r1, r5, #0
mov r2, #1
mov r3, #2
ldr r4, =0x8008e79
bl call_r4
bl go_padding
ldr r0, =0x2021d04
add r7, r0, #0
add r1, r6, #0
mov r2, #1
mov r3, #2
ldr r4, =0x8008e79
bl call_r4
bl go_padding
ldr r5, =0x2021D18
ldr r1, =(0x8750000 + string)
add r0, r5, #0
ldr r3, =0x8008FCD
bl call_r3
ldr r0, =0x2037101
ldrb r0, [r0]
mov r1, #3
str r1, [sp]
mov r1, #0xff
str r1, [sp, #4]
mov r1, #0
str r1, [sp, #8]
mov r1, #2
add r2, r5, #0
mov r3, #4
ldr r4, =0x8002C49
bl call_r4
ldr r0, =0x2037101
ldrb r0, [r0]
mov r1, #2
ldr r3, =0x8003F21
bl call_r3
add sp, sp, #0xC
pop {r4-r7, pc}
.ltorg

go_padding:
push {lr}
ldrb r0, [r7]
cmp r0, #0
bne back
mov r0, #0xa1
strb r0, [r7]
back:
pop {pc}

call_r3:
bx r3

call_r4:
bx r4

.align 2
rbox_config:
.byte 0x0 @bg_id
.byte 0x1 @x
.byte 0x1 @y
.byte 0xa @width
.byte 0x2 @height
.byte 0xf
.hword 0x8 @tileset_ofs
.word 0x8419f76 @pixels

.align 2
string:
.byte 0xce, 0xdd, 0xe1, 0xd9, 0xf0, 0xfd, 0x2, 0xf0, 0xfd, 0x3, 0xf0, 0xfd, 0x4, 0xff



Routine II:
Spoiler:
byte changes:
Code:

0x6EF1E - 00 00 00 49 08 47 YY+1 YY YY 08


routine:
Code:

.thumb
cmp r0, #1
beq safari
ldr r0, =0x20370C0
ldrh r0, [r0]
ldr r3, =0x8077509
bl call_r3

safari:
ldr r4, =0x02037101
ldrb r0, [r4]
mov r1, #0
ldr r3, =0x806ef29

call_r3:
bx r3



Routine III:
Spoiler:
byte changes:
Code:

0x6f4e8 - 00 48 00 47 ZZ+1 ZZ ZZ 08


routine:
Code:

.thumb
push {lr}
ldr r0, =0x20370c0
ldrh r0, [r0]
ldr r3, =0x8077509
bl call_r3
ldr r1, =0x20370F0
ldr r0, =0x806f5a5
str r0, [r1]
mov r0, #0
pop {pc}
call_r3:
bx r3



I've modified 'Routine I' of Pokemon_XY's Time Box to exclude displaying seconds, which in turn decreases the lag when viewing the Start Menu. I've also fixed a bug in his routine where the Time Box would display when the step-counter is displayed while in the Safari Zone. Provided down below is a 24-hour format and a 12-hour format. Choose one of them instead of Pokemon_XY's 'Routine I' if you wish.

24-hour format (use instead of 'Routine I'):
Spoiler:
Code:

@ 0x6F09C - 00 48 00 47 XX+1 XX XX 08
@ change all the 0x8950000 in the routine to the insert offset of the routine.
@ change all the 0x8950001 in the routine to the insert offset + 1 of the routine.


Code:

.thumb
mov r0, #0x80
lsl r0, r0, #4
bl flag_check
lsl r0, r0, #0x18
lsr r0, r0, #0x18
cmp r0, #0x1
beq safari
bl box_func

safari:
ldr r1, =0x20370FF
ldrb r0, [r1]
add r0, #1
strb r0, [r1]
mov r0, #0
add sp, sp, #0xC
pop {r4, pc}
.ltorg

box_func:
push {r4, lr}
ldr r4, =0x2037101
ldr r0, =(0x8950000 + rbox_config)
ldr r3, =0x8003ce5
bl call_r3
strb r0, [r4]
ldr r3, =0x8003fa1
bl call_r3
ldrb r0, [r4]
mov r1, #0
ldr r3, =0x80F6F1D
bl call_r3
bl print_string
ldr r0, =(0x8950001 + print_string)
mov r1, #2
ldr r3, =0x807741D
bl call_r3
ldr r1, =0x20370C0
strh r0, [r1]
pop {r4, pc}
.ltorg

print_string:
push {r4-r7, lr}
sub sp, sp, #0xC
ldr r0, =0x2021cd0
add r7, r0, #0
ldr r1, =0x300553c
ldrb r5, [r1, #7] @minute
ldrb r1, [r1, #6] @hour
mov r2, #1
mov r3, #2
ldr r4, =0x8008E79
bl call_r4
bl go_padding
ldr r0, =0x2021CF0
add r7, r0, #0
add r1, r5, #0
mov r2, #1
mov r3, #2
ldr r4, =0x8008e79
bl call_r4
bl go_padding
ldr r5, =0x2021D18
ldr r1, =(0x8950000 + string)
add r0, r5, #0
ldr r3, =0x8008FCD
bl call_r3
ldr r0, =0x2037101
ldrb r0, [r0]
mov r1, #3
str r1, [sp]
mov r1, #0xff
str r1, [sp, #4]
mov r1, #0
str r1, [sp, #8]
mov r1, #2
add r2, r5, #0
mov r3, #4
ldr r4, =0x8002C49
bl call_r4
ldr r0, =0x2037101
ldrb r0, [r0]
mov r1, #2
ldr r3, =0x8003F21
bl call_r3
add sp, sp, #0xC
pop {r4-r7, pc}
.ltorg

go_padding:
push {lr}
ldrb r0, [r7]
cmp r0, #0
bne back
mov r0, #0xa1
strb r0, [r7]
back:
pop {pc}

call_r3:
bx r3

call_r4:
bx r4

flag_check:
ldr r1, =0x0806E6D1
bx r1

.align 2
rbox_config:
.byte 0x0 @bg_id
.byte 0x1 @x
.byte 0x1 @y
.byte 0x5 @width
.byte 0x2 @height
.byte 0xf
.hword 0x8 @tileset_ofs
.word 0x8419f76 @pixels

.align 2
string:
.byte 0xfd, 0x2, 0xf0, 0xfd, 0x3, 0xff




12-hour format (use instead of 'Routine I'):
Spoiler:
Code:

@ 0x6F09C - 00 48 00 47 XX+1 XX XX 08
@ change all the 0x8950000 in the routine to the insert offset of the routine.
@ change all the 0x8950001 in the routine to the insert offset + 1 of the routine.


Code:

.thumb
mov r0, #0x80
lsl r0, r0, #4
bl flag_check
lsl r0, r0, #0x18
lsr r0, r0, #0x18
cmp r0, #0x1
beq safari
bl box_func

safari:
ldr r1, =0x20370FF
ldrb r0, [r1]
add r0, #1
strb r0, [r1]
mov r0, #0
add sp, sp, #0xC
pop {r4, pc}
.ltorg

box_func:
push {r4, lr}
ldr r4, =0x2037101
ldr r0, =(0x8950000 + rbox_config)
ldr r3, =0x8003ce5
bl call_r3
strb r0, [r4]
ldr r3, =0x8003fa1
bl call_r3
ldrb r0, [r4]
mov r1, #0
ldr r3, =0x80F6F1D
bl call_r3
bl print_string
ldr r0, =(0x8950001 + print_string)
mov r1, #2
ldr r3, =0x807741D
bl call_r3
ldr r1, =0x20370C0
strh r0, [r1]
pop {r4, pc}
.ltorg

print_string:
push {r4-r7, lr}
sub sp, sp, #0xC
ldr r0, =0x2021cd0
add r7, r0, #0
ldr r1, =0x300553c
ldrb r5, [r1, #7] @minute
ldrb r6, [r1, #6] @hour
add r1, r6, #0
cmp r1, #0xC
bhi usat
cmp r1, #0x0
beq zero

continue:
mov r2, #1
mov r3, #2
ldr r4, =0x8008E79
bl call_r4
bl go_padding
ldr r0, =0x2021CF0
add r7, r0, #0
add r1, r5, #0
mov r2, #1
mov r3, #2
ldr r4, =0x8008e79
bl call_r4
bl go_padding
ldr r5, =0x2021D18
cmp r6, #0xB
bhi night
ldr r1, =(0x8950000 + day)

goon:
add r0, r5, #0
ldr r3, =0x8008FCD
bl call_r3
ldr r0, =0x2037101
ldrb r0, [r0]
mov r1, #3
str r1, [sp]
mov r1, #0xff
str r1, [sp, #4]
mov r1, #0
str r1, [sp, #8]
mov r1, #2
add r2, r5, #0
mov r3, #4
ldr r4, =0x8002C49
bl call_r4
ldr r0, =0x2037101
ldrb r0, [r0]
mov r1, #2
ldr r3, =0x8003F21
bl call_r3
add sp, sp, #0xC
pop {r4-r7, pc}
.ltorg

go_padding:
push {lr}
ldrb r0, [r7]
cmp r0, #0
bne back
mov r0, #0xa1
strb r0, [r7]
back:
pop {pc}

call_r3:
bx r3

call_r4:
bx r4

flag_check:
ldr r1, =0x0806E6D1
bx r1

usat:
sub r1, r1, #0xC
b continue

zero:
add r1, r1, #0xc
b continue

night:
ldr r1, =(0x8950000 + nite)
b goon

.align 2
rbox_config:
.byte 0x0 @bg_id
.byte 0x1 @x
.byte 0x1 @y
.byte 0x7 @width
.byte 0x2 @height
.byte 0xf
.hword 0x8 @tileset_ofs
.word 0x8419f76 @pixels

.align 2
day:
.byte 0xfd, 0x2, 0xf0, 0xfd, 0x3, 0x0, 0xBB, 0xc7, 0xff
nite:
.byte 0xfd, 0x2, 0xf0, 0xfd, 0x3, 0x0, 0xCA, 0xc7, 0xff



AkameTheBulbasaur September 2nd, 2018 7:49 PM


This involves four routines and a bunch of scripting.

Notes Before We Begin

• You will need 25 vars that you will not use for anything else. I used vars 0x408F through 0x40A8, and the routines posted below reflect that. If you wish to change them, you'll need to figure out the RAM addresses for those vars on your own.
• 24 of those vars are for the moves of your party. 1 is set when the Metronome Battle starts for reasons I will get into later.
• These vars need to be permanent vars (so not 0x8000 whatever) because they need to be accessed even if the game is turned off and on.

Routine 1: Clear RAM

What this does is clear out (sets to zero) all the vars which will contain the moves. This just make sure that you have a blank slate for the next routine.
Spoiler:
.text
.align 2
.thumb
.thumb_func

Main:
push {r4-r5, lr}

ClearItems:
ldr r4, .RAMStart
mov r0, #0x0
Loop:
strh r0, [r4]
add r4, r4, #0x2
ldr r5, .RAMEnd
cmp r4, r5
bgt Return
b Loop

Return:
pop {r4-r5, pc}

.align 2
.RAMStart: .word 0x0202664A
.RAMEnd: .word 0x02026678


Routine 2: Store Party's Moves


This routine takes all the moves of your Party Pokemon and stores them one at a time in the vars I mentioned before. If the Pokemon doesn't have a move in that slot, it will just set the var to zero by default.
Spoiler:
.text
.align 2
.thumb
.thumb_func

Main:
push {r4-r7, lr}
mov r4, #0x0 /*Party Slot*/
mov r5, #0x0 /*Slot Counter*/
mov r6, #0x0 /*Move Counter*/
mov r7, #0x0 /*Var Counter*/

GetMoveLoop:
ldr r0, .FirstPoke
mov r1, #0x64
mul r1, r4
add r0, r0, r1
push {r0}
mov r1, #0xB
mov r2, #0x0
bl Decrypt
mov r1, r0
pop {r0}
cmp r1, #0x0
beq End
mov r1, #0xD
add r1, r1, r6
mov r2, #0x0
bl Decrypt
ldr r1, .VarStart
add r1, r1, r7
strh r0, [r1]

LoopCheck:
add r5, r5, #0x1
cmp r5, #0x4
beq CheckSlot
add r7, r7, #0x2
add r6, r6, #0x1
b GetMoveLoop

CheckSlot:
cmp r4, #0x5
beq End
add r4, r4, #0x1
mov r6, #0x0
mov r5, #0x0
add r7, r7, #0x2
b GetMoveLoop

End:
pop {r4-r7, pc}

Decrypt:
ldr r3, .Decrypt
bx r3

.align 2
.VarStart: .word 0x0202664A
.FirstPoke: .word 0x02024284
.Decrypt: .word 0x0803FBE9


Routine 3: Replace Moves With Metronome

This routine is fairly self-explanatory. It replaces all of your Pokemon's move with four of Metronome. Note that this does not change the PP, so the PP of Metronome will still be the same as whatever move it replaced. This is easily fixed during the scripting (which will come soon).
Spoiler:
.text
.align 2
.thumb
.thumb_func

Main:
push {r4-r7, lr}
mov r4, #0x0 /*Party Slot*/
mov r5, #0x0 /*Slot Counter*/
mov r6, #0x0 /*Move Counter*/
mov r7, #0x0 /*Var Counter*/

GetMoveLoop:
ldr r0, .FirstPoke
mov r1, #0x64
mul r1, r4
add r0, r0, r1
push {r0}
mov r1, #0xB
mov r2, #0x0
bl Decrypt
mov r1, r0
pop {r0}
cmp r1, #0x0
beq End
mov r1, #0xD
add r1, r1, r6
mov r2, #0x76
push {r2}
mov r2, sp
bl Encrypt
pop {r2}

LoopCheck:
add r5, r5, #0x1
cmp r5, #0x4
beq CheckSlot
add r7, r7, #0x2
add r6, r6, #0x1
b GetMoveLoop

CheckSlot:
cmp r4, #0x5
beq End
add r4, r4, #0x1
mov r6, #0x0
mov r5, #0x0
add r7, r7, #0x2
b GetMoveLoop

End:
pop {r4-r7, pc}

Encrypt:
ldr r3, .Encrypt
bx r3

Decrypt:
ldr r3, .Decrypt
bx r3

.align 2
.Encrypt: .word 0x0804037D
.VarStart: .word 0x0202664A
.FirstPoke: .word 0x02024284
.Decrypt: .word 0x0803FBE9


Routine 4: Restore Party's Moves

This last routine takes the moves in the vars and gives them back to the Pokemon they originally belonged to.
Spoiler:
.text
.align 2
.thumb
.thumb_func

Main:
push {r4-r7, lr}
mov r4, #0x0 /*Party Slot*/
mov r5, #0x0 /*Slot Counter*/
mov r6, #0x0 /*Move Counter*/
mov r7, #0x0 /*Var Counter*/

GetMoveLoop:
ldr r0, .FirstPoke
mov r1, #0x64
mul r1, r4
add r0, r0, r1
push {r0}
mov r1, #0xB
mov r2, #0x0
bl Decrypt
mov r1, r0
pop {r0}
cmp r1, #0x0
beq End
mov r1, #0xD
add r1, r1, r6
ldr r2, .VarStart
add r2, r2, r7
ldrh r2, [r2]
push {r2}
mov r2, sp
bl Encrypt
pop {r2}

LoopCheck:
add r5, r5, #0x1
cmp r5, #0x4
beq CheckSlot
add r7, r7, #0x2
add r6, r6, #0x1
b GetMoveLoop

CheckSlot:
cmp r4, #0x5
beq End
add r4, r4, #0x1
mov r6, #0x0
mov r5, #0x0
add r7, r7, #0x2
b GetMoveLoop

End:
pop {r4-r7, pc}

Encrypt:
ldr r3, .Encrypt
bx r3

Decrypt:
ldr r3, .Decrypt
bx r3

.align 2
.Encrypt: .word 0x0804037D
.VarStart: .word 0x0202664A
.FirstPoke: .word 0x02024284
.Decrypt: .word 0x0803FBE9


Putting it all Together


I will assume that the initiator of the Metronome battle will be a person event or something like that.

In your script, you will want to call the first three routines in order. Then script the battle, and then afterwards call the fourth routine and then the first again.

Syntax:
callasm OFFSET OF R1
callasm OFFSET OF R2
callasm OFFSET OF R3
special HEAL_POKEMON 'This fixes the PP issue from before
setvar SOME VAR 0xFF'
trainerbattle 0x3 0xNUM 0x0 @DefeatMsg
callasm OFFSET OF R4
callasm OFFSET OF R1
special HEAL_POKEMON
setvar SOME VAR 0x0


Let's explain a few things. You'll want to use specifically "trainerbattle" type 3. This makes the script continue after you defeat the trainer, which we want so that you can get your original moves back after you win.

But what about if you lose? This is what the SOME VAR is about. Before you start the battle, you'll want to set whichever var you chose to something not zero. I picked 0xFF just because.
If you win, this var gets set back to zero. But if you lose then the var is still the non-zero value.

So you will need to include this map script at every possible healing location the player could get sent back to.

Spoiler:
#dyn 0x740000
#org @Start
compare SOME VAR 0xFF
if true jump @RestoreMoves
release
end

#org @RestoreMoves
callasm OFFSET OF R4
callasm OFFSET OF R1
release
end


This checks if you initiated but did not complete the Metronome Battle (via the var) and if you that is true then it replaces your moves. If you lost the battle then it will do this during the normal White Out script.

What I recommend is using JPAN's SetHealingPlace hack to set the healing place to be the map where you find the NPC who starts the battle. That way you only need to have this map script on that specific map instead of having to put it everywhere.

Another important thing you will probably need is the routine to disable experience gain with a flag! I forgot where it was, but I believe it’s in this thread. You need this to prevent your Pokémon leveling up and learning a new move.

This would not only ruin the Metronome battle, but they wouldn’t even keep the move after the battle was over and everything got replaced back.

Example Script

Here I will just include the script I used in my game, just to get an idea of how the scripting part is supposed to go down.

Spoiler:
#dyn 0x740000
#org @Start
lock
faceplayer
message @Hello
callstd MSG_YESNO
compare LASTRESULT YES
if true jump @StoreMoves
message @Bye
release
end

#org @StoreMoves
callasm 0x8DB1E3D
callasm 0x8DB2C01
jump @SetHealingPlace

#org @SetHealingPlace
sethealingplace 0x1
setvar 0x405A 0x0C01
setvar 0x405B 0x6
setvar 0x405C 0x8
setvar 0x8004 0x1
setvar 0x4053 0x100
setvar 0x40F7 0x8
jump @ReplaceMoves

#org @ReplaceMoves
callasm 0x8DB47D9
special HEAL_POKEMON
setvar 0x40A8 0xFF
jump @StartBattle

#org @StartBattle
message @LetsGo
callstd MSG_SIGN
countpokemon
compare LASTRESULT 0x1
if true jump @OneMon
compare LASTRESULT 0x2
if true jump @TwoMon
compare LASTRESULT 0x3
if true jump @ThreeMon
compare LASTRESULT 0x4
if true jump @FourMon
compare LASTRESULT 0x5
if true jump @FiveMon
trainerbattle 0x3 0x1C1 0x0 @Defeat
jump @AfterBattle

#org @FiveMon
trainerbattle 0x3 0x1C2 0x0 @Defeat
jump @AfterBattle

#org @FourMon
trainerbattle 0x3 0x1C3 0x0 @Defeat
jump @AfterBattle

#org @ThreeMon
trainerbattle 0x3 0x1C4 0x0 @Defeat
jump @AfterBattle

#org @TwoMon
trainerbattle 0x3 0x1C5 0x0 @Defeat
jump @AfterBattle

#org @OneMon
trainerbattle 0x3 0x1C6 0x0 @Defeat
jump @AfterBattle

#org @AfterBattle
setflag 0x25C
settrainerflag 0x1C1
settrainerflag 0x1C2
settrainerflag 0x1C3
settrainerflag 0x1C4
settrainerflag 0x1C5
settrainerflag 0x1C6
message @Fun
callstd MSG_SIGN
jump @PutMovesBack

#org @PutMovesBack
callasm 0x8DB629D
callasm 0x8DB1E3D
special HEAL_POKEMON
setvar 0x40A8 0x0
release
end

#org @Hello
= Anna Marukawa: Wanna see a trick?\pI can temporarily change any\nPokemon's attacks to be anything\lat all!\pWell, not exactly. I can only\nchange them to Metronome.\pBut Metronome can be any attack,\nso there!\pAnyway, my idea is we can have a\nbattle where the only move either\lof us can use is Metronome!\pWouldn't that be fun? Want to try\nit out?

#org @Bye
= Oh, okay.\nMaybe another time then!

#org @Defeat
= Wow! That was great!

#org @LetsGo
= Okay!\pI changed all the moves and healed\nyour team.\pTo the Battle Dimension we go!

#org @Fun
= Wow! Wow!\pThat was so much fun!\pHere, let's give your Pokemon\ntheir real moves back.\pCome over soon so we can do that\nagain!

Koople September 11th, 2018 12:47 PM

Side Quest Menu [FR]

This hack converts the PC item storage menu into a side quest menu, or task list, etc.

Here is the repository, the compilation instructions are included in the readme. You will need to define your own parameters/ram in src/headers/defs.asm and create your own tables of string pointers for all of the quest names, descriptions, item images, and quest details. I kept the item image part to allow hackers to include items that might be symbolic of their quest, eg. a scroll or key or pokeball.

To use in a script (XSE)
Code:

writebytetooffset 0x1 <your questflag ram in src/headers/defs.asm>
fadescreen 0x1
callasm 0x80EBCD9
waitstate


Enjoy! And please let me know of any bugs.

Delta231 September 13th, 2018 6:47 AM

Quote:

Originally Posted by Koople (Post 9924710)
Side Quest Menu [FR]

This hack converts the PC item storage menu into a side quest menu, or task list, etc.

Here is the repository, the compilation instructions are included in the readme. You will need to define your own parameters/ram in src/headers/defs.asm and create your own tables of string pointers for all of the quest names, descriptions, item images, and quest details. I kept the item image part to allow hackers to include items that might be symbolic of their quest, eg. a scroll or key or pokeball.

To use in a script (XSE)
Code:

writebytetooffset 0x1 <your questflag ram in src/headers/defs.asm>
fadescreen 0x1
callasm 0x80EBCD9
waitstate


Here is a slightly outdated example GIF (it is just missing the item images in the box), but it gets the point across.

Enjoy! And please let me know of any bugs.

Nice work but you may wanna remove .exe and dll files as not everyone uses Windows.

Delta231 September 13th, 2018 6:49 AM

Quote:

Originally Posted by Super Versekr Dark (Post 9915420)
Excuse me, can you put Ruby's routines here?

Yes, you are allowed to put routines for Ruby as well.

Squeetz September 16th, 2018 6:19 AM

[FR] Multi-directional jump tiles
This is an expanded-upon version of Invert's routine on the Wahack forums (https://wahackforo.com/t-40642/fr-asm-salto-en-cualquier-direccion) So credit goes to them for the original.
Made this for the purpose of creating a multiple-height jumping puzzle which was something Invert's routine was lacking, so thought I might as well share it.

Code:

.thumb

.global AnyDirectionJumptile
.equ rom, 0x08000001
.equ offset, 0xXXXXXX

/*
Behavior bytes:
0x7F = able to jump in any direction over tile (only on height 0x0 & 0x10)
0x7E = able to jump up and down over tile
0x7D = able to jump left and right over tile
*/

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
hooks:
.org 0x59AF6
        cmp r0, #0x7D
        beq 0x59B02

.org 0x59B0A
        cmp r0, #0x7D
        beq 0x59B16

.org 0x59B1E
        cmp r0, #0x7E
        beq 0x59B2A

.org 0x59B32
        cmp r0, #0x7E
        beq 0x59B3E

.org 0x6812C
        bx r2

.org 0x68144
        .word main + rom

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

.org offset
main:
        cmp r0, #0x7F        @behavior byte
        beq CheckJump
        ldr r2, =(0x083A705C)
        lsl r1, r4, #0x2
        ldr r3, =(0x0806812E|1)
        bx r3

CheckJump:
        bl CanPlayerJump
        cmp r0, #0x0
        beq CantJump
CanJump:
        ldr r0, =(0x08068148|1)
        bx r0

CantJump:
        ldr r0, =(0x0806813E|1)
        bx r0

CanPlayerJump:
        ldr r1, npc_states
        ldrb r0, [r1, #0xB]                @player height
        mov r1, #0xF
        and r0, r1                        @lower 4 bits are height
        cmp r0, #0x4                        @movement permission 0x10
        beq TheyCan
        cmp r0, #0x0                        @movement permission 0x0
        beq TheyCan
TheyCant:
        mov r0, #0x0
        bx lr

TheyCan:
        mov r0, #0x1
        bx lr

.align 2
        npc_states:                .word 0x02036E38



Koople September 17th, 2018 10:58 AM

Evolution Moves [FR]

Adds the feature of learning moves when you evolve, regardless of the level. Currently, only compatable if you have expanded your moves above 511 (jambo learnsets). May make it compatable with old learnsets if there is a desire.

Here is the repository. Update config.ini with your learnset table location and a free ram address byte (does not need to be in the save block hack. Example free space starts at 0203e000 if you've removed the help system, I believe)

I've only done prelimenary testing, so there may be bugs.

hjk321 October 6th, 2018 5:28 AM

Quote:

Originally Posted by Koople (Post 9924710)
Side Quest Menu [FR]

This hack converts the PC item storage menu into a side quest menu, or task list, etc.

Here is the repository, the compilation instructions are included in the readme. You will need to define your own parameters/ram in src/headers/defs.asm and create your own tables of string pointers for all of the quest names, descriptions, item images, and quest details. I kept the item image part to allow hackers to include items that might be symbolic of their quest, eg. a scroll or key or pokeball.

To use in a script (XSE)
Code:

writebytetooffset 0x1 <your questflag ram in src/headers/defs.asm>
fadescreen 0x1
callasm 0x80EBCD9
waitstate


Here is a slightly outdated example GIF (it is just missing the item images in the box), but it gets the point across.

Enjoy! And please let me know of any bugs.

Hello,

I'm having a hard time understanding an aspect of your system, mainly the flags. So if you have 256 quests (the max, still kinda a small number), does that mean you need 512 flags? Consecutive flags, at that? So quest #1 would be flag 0x200, and that would go all the 0x2FF, leaving me with literally no other safe flags for the entire game, or to complete the other 256 flags eaten by the routine? Looks like I might have to dabble in expanding safe flags, unless I'm missing something obvious here.

Edit: Couldn't I just set the "flag" offsets to some unused RAM? Probably not, since it wouldn't be covered by the save block. And how do I convert the flag number to a RAM location?

Thanks, hjk321

Nice routine though!

Koople October 7th, 2018 10:32 AM

Quote:

Originally Posted by hjk321 (Post 9933627)
Hello,

I'm having a hard time understanding an aspect of your system, mainly the flags. So if you have 256 quests (the max, still kinda a small number), does that mean you need 512 flags? Consecutive flags, at that? So quest #1 would be flag 0x200, and that would go all the 0x2FF, leaving me with literally no other safe flags for the entire game, or to complete the other 256 flags eaten by the routine? Looks like I might have to dabble in expanding safe flags, unless I'm missing something obvious here.

Edit: Couldn't I just set the "flag" offsets to some unused RAM? Probably not, since it wouldn't be covered by the save block. And how do I convert the flag number to a RAM location?

Thanks, hjk321

Nice routine though!

I kept the instructions somewhat vague to allow different users to utilize the system the way they like, though you're right that I could have been a bit more verbose.

The system is set up so that you will need two flags for each quest: one to 'activate' the quest, which just means you have unlocked it and the quest name will show up in the menu and you can activate it and whatnot. The second will indicate that the quest is completed, in which case the 'Done' text will appear next to the quest name.

It is currently written so that the activation flags (to show the quest names) are in order, and the completion flags are also in order, but can start from a different initial flag. This was done to prevent the use of two separate tables, but can easily be changed.

256 quests seems like a pretty high number of quests for a rom hack though. And that is not necessarily the limit, the active quest ram can easily be expanded to a halfword value.

I would recommend expanding the safe number of flags with JPANs save block hack; this way you can unlock thousands more safe flags and this system won't be as limiting.

I'm not entirely sure why you would want to use RAM instead of flags; that would end up just taking up much more space unless you edit the routine to check for specific bits in the ram, which is then the same functionality as a flag.

I hope this helps.

hjk321 October 8th, 2018 11:38 AM

Quote:

Originally Posted by Koople (Post 9934044)
It is currently written so that the activation flags (to show the quest names) are in order, and the completion flags are also in order, but can start from a different initial flag. This was done to prevent the use of two separate tables, but can easily be changed.
I hope this helps.

Literally everything about your routine is great... except every quest is ???????? whether the flags are set or not! in the defs file I've tried RAM pointers (0x0203C001) I've tried repointed flag numbers (0x909) and I've tried raw flag numbers (0x2109) and no matter what the quests do not show up!

As an experiment I have 15 quests and I set some flags At the index. Index starts at 0203C001, have also tried 0x909 and 0x2109 in defs.asm. Here is proof I have flags set in that area...
https://cdn.pbrd.co/images/HHxEbja.png
and yet all 15 quests are unshowable. What am I doing wrong?

I only made minor edits to some text variables, as well as linking to external tables rather than making a table in the actual asm. I didn't edit anything significant.

Koople October 9th, 2018 8:40 AM

Quote:

Originally Posted by hjk321 (Post 9934365)
Literally everything about your routine is great... except every quest is ???????? whether the flags are set or not! in the defs file I've tried RAM pointers (0x0203C001) I've tried repointed flag numbers (0x909) and I've tried raw flag numbers (0x2109) and no matter what the quests do not show up!

As an experiment I have 15 quests and I set some flags At the index. Index starts at 0203C001, have also tried 0x909 and 0x2109 in defs.asm. Here is proof I have flags set in that area...
https://cdn.pbrd.co/images/HHxEbja.png
and yet all 15 quests are unshowable. What am I doing wrong?

I only made minor edits to some text variables, as well as linking to external tables rather than making a table in the actual asm. I didn't edit anything significant.

Can you share your code so I can better understand what you are trying to do? Let's do this via discord or personal message to keep this thread clean. :)

Banjo-Fella October 10th, 2018 4:59 AM

Hi ASMaties! I'm new to hacking and I'm not sure how to go about this… would it be okay if I requested some help modifying the way EV-increasing items (HP Up, Protein, Iron, etc.) work in Emerald?

The default behaviour adds +10 EVs, but it has no effect when the EV is >=100. I want to remove that restriction so you can keep using EV items and max out an EV at 252, allowing players to EV train quickly and painlessly.

Any help would be much appreciated!

ghoulslash October 13th, 2018 8:38 AM

Quote:

Originally Posted by Koople (Post 9926980)
Evolution Moves [FR]

I found a bug in this code where a pokemon learning a move from any other way would be asked to learn moves it already knows and will be asked to learn a move even when their movesets are not full.

I rewrote the moveset loop by just calling a custom function rather than editing the main learn_move function at 0803ea88, and it appears to work fine.

Spoiler:

Code:

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

Main:
        ldrb r1, [r5, #0x10]
        mov r0, r9
        bl MoveChecks
        ldr r6, =(0x080ceddc +1)
        bx r6

MoveChecks:
        push {r4-r7, lr}
        mov r7, r10
        mov r6, r9
        mov r5, r8
        push {r5-r7}
        sub sp, #0x4
        mov r8, r0                @ r8 = start of poke data (02024284 + 64*ind)
        lsl r4, r1, #0x18
        lsr r4, r4, #0x18
        mov r0, #0x0
        str r0, [sp]
        mov r0, r8
        mov r1, #0xb
        mov r2, #0x0
        bl GetAttr
        lsl r0, r0, #0x10
        lsr r0, r0, #0x10
        mov r9, r0                @ r9 = species
        mov r0, r8
        mov r1, #0x38
        mov r2, #0x0
        bl GetAttr
        lsl r0, r0, #0x10
        lsr r0, r0, #0x10
        mov r10, r0                @ r10 = poke level
        ldr r0, =(0x0000ffff)
        mov r12, r0
        cmp r4, #0x0
        beq GetLearnset
        mov r1, sp
        ldrb r1, [r1]
        ldr r4, =(0x02024028)
        strb r1, [r4]

GetLearnset:
        ldr r3, .MovesetTable
        mov r1, r9
        lsl r4, r1, #0x2
        add r5, r4, r3
        ldr r5, [r5]        @ species learnset offset start
        ldr r6, =(0x02024028)
        mov r4, r10

LearnsetLoop:
        ldrb r0, [r6]
        lsl r1, r0, #0x1
        add r0, r0, r1
        add r3, r0, r5
        ldrb r1, [r3, #0x2]
        cmp r1, #0xFF
        beq EndofLearnset
        cmp r1, #0x0
        bne CompareLevels

CheckEvolved:
        ldr r0, .EvolveFlag
        ldrb r0, [r0]
        cmp r0, #0x0
        bne LearnMove        @ pokemon has evolved & found evo move

CompareLevels:
        ldrb r0, [r6]
        add r0, #0x1
        strb r0, [r6]        @ pos += 1
        cmp r1, r4
        bne LearnsetLoop

LearnMove:
        ldrb r0, [r6]
        add r0, #0x1
        strb r0, [r6]        @ pos += 1
        ldrb r0, [r3, #0x1]
        lsl r0, r0, #0x8
        ldrb r1, [r3]
        orr r0, r1
        ldr r2, =(0x02024022)
        strh r0, [r2]
        mov r0, r8        @ poke data struct in ram
        ldrh r1, [r2]        @ move to learn
        bl MovesetPad
        lsl r0, r0, #0x10
        lsr r0, r0, #0x10
        str r0, [sp]

EndofLearnset:
        ldr r0, [sp]
        add sp, #0x4
        pop {r3-r5}
        mov r8, r3
        mov r9, r4
        mov r10, r5
        pop {r4-r7}
        pop {r1}
        bx r1

GetAttr:
        ldr r3, =(0x0803fbe8 +1)
        bx r3

MovesetPad:
        ldr r2, =(0x0803e89c +1)
        bx r2

.align 2
.EvolveFlag:        .word 0x02xxxxxx  @ from the config.ini
.MovesetTable:        .word 0x0825d7b4




If you implemented the original routines, be sure to replace the bytes at 3eaa4.

Skeli October 13th, 2018 10:12 PM

Only Buy 1 TM From Shops [FR]

If you've decided to make your TMs reusable in Fire Red, this routine will remove the option to buy more than one of each from shops. Credits to azurile13 for the first part (Main) of the code.The only thing that needs changing is the line ".equ offset".
Code:

.thumb
.global AlreadyOwnTM

.equ rom, 0x8000000
.equ offset, 0x893960 @CHANGE THIS LINE

.org 0x9BC3C, 0xFF
        ldr r1, .Pointer1
        bx r1
.Pointer1: .word Main + rom + 1

.org 0x9BC7C, 0xFF
        ldr r0, .Pointer2
        bx r0
.Pointer2: .word OnlyBuyOne + rom + 1

.org 0x9BEBC, 0xFF
        ldr r1, .Pointer3
        bx r1
.Pointer3: .word AddItem + rom + 1

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

.org offset, 0xFF
Main:
        lsr r4, r0, #0x10
        mov r0, r4
        ldr r2, .GetItemPocket
        bl Jump
        cmp r0, #0x4
        bne Return
        mov r0, r4
        mov r1, #0x1
        ldr r2, .CheckItem
        bl Jump
        cmp r0, #0x0
        bne AlreadyOwn

Return:
        mov r0, r4
        ldr r1, =0x809BC45
        bx r1

AlreadyOwn:
        ldr r1, .AlreadyHaveTMString
        ldr r2, =0x809BC67
        bx r2

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

OnlyBuyOne:
        ldr r1, .FCodeBuffer2
        mov r0, r4
        ldr r2, .ItemID_Copy_Name
        bl Jump
        mov r0, r4
        ldr r2, .GetItemPocket
        bl Jump
        cmp r0, #0x4
        bne Return2

GetPrice:
        mov r0, r4
        ldr r2, .GetMarketPrice
        bl Jump
        mov r1, r0
        ldr r0, .FCodeBuffer2
        add r0, #0x20
        mov r2, #0x3
        mov r3, #0x8
        bl Hex2Dec
        ldr r1, .NewYouWantString
        ldr r2, =0x809BE91
        ldr r3, =0x809BC89
        bx r3

Return2:
        ldr r1, =0x809BC85
        bx r1

Hex2Dec:
        ldr r4, =0x8008E79
        bx r4

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

AddItem:
        ldr r2, .GetItemPocket
        bl Jump
        cmp r0, #0x4
        bne Return3
        mov r0, #0x1
        strh r1, [r4, #0x2]

Return3:
        ldrh r0, [r4, #0xA]
        ldrh r1, [r4, #0x2]
        ldr r2, .Bag_Add_Item
        bl Jump
        lsl r0, #0x18
        ldr r2, =0x809BEC5
Jump:
        bx r2

.align 2
.FCodeBuffer2: .word 0x2021CD0
.GetItemPocket: .word 0x809A9D9
.CheckItem: .word 0x8099F41
.ItemID_Copy_Name: .word 0x8099E91
.GetMarketPrice: .word 0x809A901
.Bag_Add_Item: .word 0x809A085
.AlreadyHaveTMString: .word STRING1 + rom
.NewYouWantString: .word STRING2 + rom

STRING1: .byte 0xD3, 0xE3, 0xE9, 0x00, 0xD5, 0xE0, 0xE6, 0xD9, 0xD5, 0xD8, 0xED, 0x00, 0xE3, 0xEB, 0xE2, 0x00, 0xE8, 0xDC, 0xD5, 0xE8, 0x00, 0xCE, 0xC7, 0xAD, 0xFC, 0x09, 0xFF
STRING2: .byte 0xFD, 0x02, 0xB8, 0xFE, 0xCE, 0xDC, 0xD5, 0xE8, 0x00, 0xEB, 0xDD, 0xE0, 0xE0, 0x00, 0xD6, 0xD9, 0x00, 0xB7, 0xFD, 0x03, 0xAD, 0x00, 0xC9, 0xDF, 0xD5, 0xED, 0xAC, 0xFF




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.