The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Fan Games > Binary ROM Hacking > Binary Hack Research & Development
Reload this Page Code ASM Resource Thread

Notices
For all updates, view the main page.

Binary Hack Research & Development Got a well-founded knack with your binary Pokémon hacks? Love reverse-engineering them? For the traditional Pokémon ROM hacker, this is the spot for polling and gathering your ideas, and then implementing them! Share your hypothesis, get ideas from others, and collaborate to create!

Ad Content
Reply
 
Thread Tools
  #1201   Link to this post, but load the entire thread.  
Old June 17th, 2017 (4:38 PM). Edited June 18th, 2017 by Spherical Ice.
Spherical Ice's Avatar
Spherical Ice Spherical Ice is offline
 
Join Date: Nov 2007
Location: Leicester, UK
Age: 25
Posts: 5,251

[FR] EV-reducing Berries


Find 0x49C bytes of free space at a word-aligned address, and take note of it.
Set the EV-reducing berries' Type to Type 1 ("Out of battle").
Set the items' Field script pointers to the address you noted, plus 1.
Set the items' Battle script pointer to 0xA2239.
Assemble the following routine, changing 0xXXXXXX to the address you noted (not plus 1).
Open the generated .bin file, navigate to the location address, and select 0x49C bytes.
Copy the bytes and paste them in your ROM, at the same address.

Code:
.thumb

@ -- Change these
.equ start_address, 0x29B110
@ --

.equ rom, 0x08000000

.equ pokemon_length, 0x64

.equ req_species,           0x0B
.equ req_held_item,         0x0C
.equ req_hp_ev,             0x1A
.equ req_atk_ev,            0x1B
.equ req_def_ev,            0x1C
.equ req_spe_ev,            0x1D
.equ req_spatk_ev,          0x1E
.equ req_spdef_ev,          0x1F
.equ req_happiness,         0x20
.equ req_catch_location,    0x23
.equ req_pokeball,          0x26

.equ item_luxuryball,   0x0B
.equ item_pomegberry,   0x99
.equ item_kelpsyberry,  0x9A
.equ item_qualotberry,  0x9B
.equ item_hondewberry,  0x9C
.equ item_grepaberry,   0x9D
.equ item_tomatoberry,  0x9E
.equ item_soothebell,   0xB8

.org start_address, 0xFF
ev_berries:
    push {lr}
    lsl r0, r0, #0x18
    lsr r0, r0, #0x18
    ldr r2, item_function_ptr
    ldr r1, =(rom + dp05_ev_berries + 1)
    str r1, [r2]
    ldr r3, item_consume_maybe
    bl call_via_r3
    pop {r3}

call_via_r3:
    bx r3

.align 2
    item_consume_maybe:     .word 0x080A16D0|1
    .pool

dp05_ev_berries:
    push {r4-r7,lr}
    mov r7, r10
    mov r6, r9
    mov r5, r8
    push {r5-r7}
    sub sp, sp, #0xC
    str r1, [sp, #0]
    lsl r0, r0, #0x18
    lsr r0, r0, #0x18
    mov r10, r0

get_selected_pokemon:
    ldr r4, brm
    ldrb r1, [r4, #9]
    mov r0, #pokemon_length
    mul r1, r0
    ldr r0, party_player
    add r5, r1, r0

determine_berry:
    ldr r0, var_800E
    ldrh r0, [r0]
    lsl r0, r0, #0x10
    lsr r0, r0, #0x10
    sub r0, #(item_pomegberry - 1)
    mov r7, r0

get_ev_req: 
    mov r0, r5
    mov r1, r7
    ldr r3, =(rom + get_ev_req_from_berry_id + 1)
    bl call_via_r3
    lsl r0, r0, #0x18
    lsr r0, r0, #0x18
    cmp r0, #0
    beq no_effect
    mov r6, r0

happiness_before:
    mov r0, r5
    mov r1, #req_happiness
    ldr r3, get_attr
    bl call_via_r3
    lsl r0, r0, #0x10
    lsr r0, r0, #0x10
    ldr r1, var_8000
    strh r0, [r1]

ev_value_before:
    mov r0, r5
    mov r1, r6
    mov r2, #0
    ldr r3, get_attr
    bl call_via_r3
    lsl r0, r0, #0x10
    lsr r0, r0, #0x10
    ldr r1, var_8001
    strh r0, [r1]

use_berry:
    mov r0, r5
    mov r1, r6
    ldr r3, =(rom + use_ev_berry + 1)
    bl call_via_r3
    lsl r0, r0, #0x18
    lsr r4, r0, #0x18

ev_after:
    mov r0, r5
    mov r1, r6
    mov r2, #0
    ldr r3, get_attr
    bl call_via_r3
    lsl r0, r0, #0x10
    lsr r0, r0, #0x10
    mov r8, r0

happiness_after:
    mov r0, r5
    mov r1, #req_happiness
    ldr r3, get_attr
    bl call_via_r3
    lsl r0, r0, #0x10
    lsr r0, r0, #0x10
    mov r9, r0

branch_for_effectiveness:
    cmp r4, #0
    bne no_effect
    ldr r0, var_8000
    ldrh r0, [r0]
    cmp r0, r9
    bne effect
    ldr r1, var_8001
    ldrh r1, [r1]
    cmp r1, r8
    bne effect

no_effect:
    ldr r1, item_effectiveness
    mov r0, #0
    strb r0, [r1]
    mov r0, #5
    ldr r3, audio_play
    bl call_via_r3
    ldr r0, no_effect_str
    mov r1, #1
    ldr r3, item_menu_string
    bl call_via_r3
    mov r0, #2
    ldr r3, bgid_mark_for_sync
    bl call_via_r3
    ldr r1, tasks
    mov r2, r10
    lsl r0, r2, #2
    add r0, r10
    lsl r0, r0, #3
    add r0, r0, r1
    ldr r1, [sp]
    str r1, [r0]
    b end
 
effect:
    mov r0, r10
    ldr r3, item_use_animation
    bl call_via_r3
    ldr r1, item_function_ptr
    ldr r0, =(rom + berry_use + 1)
    str r0, [r1]
  
end:
    add sp, sp, #0xC
    pop {r3-r5}
    mov r8, r3
    mov r9, r4
    mov r10, r5
    pop {r4-r7}
    pop {r0}
    bx r0

.align 2
    item_function_ptr:      .word 0x03005E98
    .pool

berry_use:
    push {r4-r7,lr}
    lsl r0, r0, #0x18
    lsr r5, r0, #0x18
    ldr r1, item_effectiveness
    mov r0, #1
    strb r0, [r1]

sound_fx:
    mov r0, #1
    ldr r3, audio_play
    bl call_via_r3

remove_item:
    ldr r0, var_800E
    ldrh r0, [r0]
    mov r1, #1
    ldr r3, bag_remove_item
    bl call_via_r3

get_selected_pokemon_again:
    ldr r4, brm
    ldrb r1, [r4, #9]
    mov r0, #pokemon_length
    mul r1, r0
    ldr r0, party_player
    add r4, r1, r0

determine_berry_again:
    ldr r0, var_800E
    ldrh r0, [r0]
    lsl r0, r0, #0x10
    lsr r0, r0, #0x10
    sub r0, #(item_pomegberry - 1)
    mov r7, r0

get_ev_req_again: 
    mov r0, r4
    mov r1, r7
    ldr r3, =(rom + get_ev_req_from_berry_id + 1)
    bl call_via_r3
    lsl r0, r0, #0x18
    lsr r1, r0, #0x18

ev_after_again:
    mov r0, r4
    mov r2, #0
    ldr r3, get_attr
    bl call_via_r3
    lsl r0, r0, #0x10
    lsr r0, r0, #0x10
    mov r8, r0

happiness_after_again:
    mov r0, r4
    mov r1, #req_happiness
    ldr r3, get_attr
    bl call_via_r3
    lsl r0, r0, #0x10
    lsr r0, r0, #0x10
    mov r9, r0

buffer_pkmn_nick_to_buffer2:
    ldr r1, fcode_buffer2
    mov r0, r4
    ldr r3, buffer_pkmn_nick
    bl call_via_r3

buffer_stat_name_to_buffer3:
    ldr r1, fcode_buffer3
    mov r0, r7
    ldr r3, =(rom + buffer_stat_name + 1)
    bl call_via_r3

branch_for_string:
    ldr r0, var_8000
    ldrh r0, [r0]
    cmp r0, r9
    beq happiness_at_max
    ldr r0, var_8001
    ldrh r0, [r0]
    cmp r0, r8
    beq ev_at_0

happiness_not_at_max_ev_above_0:
    ldr r0, displayed_string
    ldr r1, =(rom + happiness_not_at_max_ev_above_0_str)
    ldr r3, fdecoder
    bl call_via_r3
    b load_displayed_string

ev_at_0:
    ldr r0, displayed_string
    ldr r1, =(rom + happiness_up_ev_cant_fall_str)
    ldr r3, fdecoder
    bl call_via_r3
    b load_displayed_string

happiness_at_max:
    ldr r0, displayed_string
    ldr r1, =(rom + adore_ev_down_str)
    ldr r3, fdecoder
    bl call_via_r3

load_displayed_string:
    ldr r0, displayed_string

print_item_message:
    mov r1, #1
    ldr r3, item_menu_string
    bl call_via_r3
    mov r0, #2
    ldr r3, bgid_mark_for_sync
    bl call_via_r3
    ldr r1, tasks
    mov r2, r5
    lsl r0, r2, #2
    add r0, r0, r5
    lsl r0, r0, #3
    add r0, r0, r1
    ldr r1, item_menu_callback
    str r1, [r0]
    pop {r4-r7}
    pop {r0}
    bx r0

.align 2
get_ev_req_from_berry_id:
    push {r4-r7,lr}
    mov r4, r0
    lsl r1, r1, #0x18
    lsr r1, r1, #0x18
    lsl r1, r1, #2
    ldr r0, =(rom + ev_switch_table)
    add r0, r0, r1
    ldr r0, [r0]
    mov pc, r0 @ switch jump

.align 2
ev_switch_table:
    .word (rom + ev_switch_default)
    .word (rom + case_ev_hp)
    .word (rom + case_ev_atk)
    .word (rom + case_ev_def)
    .word (rom + case_ev_spatk)
    .word (rom + case_ev_spdef)
    .word (rom + case_ev_spe)

.align 2
ev_switch_default:
case_ev_hp:
    mov r0, #req_hp_ev
    b return_ev_req

case_ev_atk:
    mov r0, #req_atk_ev
    b return_ev_req

case_ev_def:
    mov r0, #req_def_ev
    b return_ev_req

case_ev_spe:
    mov r0, #req_spe_ev
    b return_ev_req

case_ev_spatk:
    mov r0, #req_spatk_ev
    b return_ev_req

case_ev_spdef:
    mov r0, #req_spdef_ev
    b return_ev_req

ev_return_0:
    mov r0, #0

return_ev_req:
    pop {r4-r7}
    pop {r1}
    bx r1

.align 2
buffer_stat_name:
    push {lr}
    mov r2, r1
    lsl r0, r0, #0x18
    lsr r0, r0, #0x18
    cmp r0, #6
    bgt return_stat_name
    ldr r1, =(rom + stat_name_switch_table)
    lsl r0, r0, #2
    add r0, r0, r1
    ldr r0, [r0]
    mov pc, r0 @ switch jump

stat_name_switch_table:
    .word (rom + stat_name_default)
    .word (rom + case_hp_name)
    .word (rom + case_atk_name)
    .word (rom + case_def_name)
    .word (rom + case_spatk_name)
    .word (rom + case_spdef_name)
    .word (rom + case_spe_name)

stat_name_default:
case_hp_name:
    ldr r1, hp_name_str
    b break_stat_name_switch

case_atk_name:
    ldr r1, atk_name_str
    b break_stat_name_switch

case_def_name:
    ldr r1, def_name_str
    b break_stat_name_switch

case_spe_name:
    ldr r1, spe_name_str
    b break_stat_name_switch

case_spatk_name:
    ldr r1, spatk_name_str
    b break_stat_name_switch

case_spdef_name:
    ldr r1, spdef_name_str

break_stat_name_switch:
    mov r0, r2
    ldr r3, strcpy_xFF_terminated
    bl call_via_r3

return_stat_name:
    pop {r0}
    bx r0

.align 2
use_ev_berry:
    push {r4-r7,lr}
    mov r7, r10
    mov r6, r9
    mov r5, r8
    push {r5-r7}
    lsl r1, r1, #0x18
    lsr r1, r1, #0x18
    mov r8, r0
    mov r7, r1

get_relevant_ev_value:
    mov r0, r8
    mov r1, r7
    mov r2, #0
    ldr r3, get_attr
    bl call_via_r3
    lsl r0, r0, #0x10
    lsr r0, r0, #0x10

check_ev:
    cmp r0, #0
    ble set_ev_unchanged_flag

subtract_ev:
    mov r1, r0
    sub r0, #10
    cmp r0, r1
    blo set_ev
    mov r0, #0

set_ev:
    mov r2, sp
    strh r0, [r2]
    mov r0, r8
    mov r1, r7
    ldr r3, set_attr
    bl call_via_r3

recalc_stats:
    mov r0, r8
    ldr r3, recalculate_stats
    bl call_via_r3
    b get_happiness_value

set_ev_unchanged_flag:
    mov r6, #1

get_happiness_value:
    mov r0, r8
    mov r1, #req_happiness
    mov r2, #0
    ldr r3, get_attr
    bl call_via_r3

check_happiness:
    cmp r0, #255
    beq check_if_should_return_1
    cmp r0, #199
    bgt add_two_happiness
    cmp r0, #99
    bgt add_five_happiness

add_ten_happiness:
    mov r6, #10
    b remember_new_happiness

add_five_happiness:
    mov r6, #5
    b remember_new_happiness

add_two_happiness:
    mov r6, #2

remember_new_happiness:
    add r5, r6, r0

luxuryball_check:
    mov r0, r8
    mov r1, #req_pokeball
    mov r2, #0
    ldr r3, get_attr
    bl call_via_r3
    cmp r0, #item_luxuryball
    bne metlocation_check

luxuryball_bonus:
    add r5, #1
    add r6, #1

metlocation_check:
    mov r0, r8
    mov r1, #req_catch_location
    mov r2, #0
    ldr r3, get_attr
    bl call_via_r3
    mov r4, r0
    ldr r3, sav1_map_get_name
    bl call_via_r3
    lsl r0, r0, #0x18
    lsr r0, r0, #0x18
    cmp r4, r0
    bne soothebell_check

metlocation_bonus:
    add r5, #1
    add r6, #1

soothebell_check:
    mov r0, r8
    mov r1, #req_held_item
    mov r2, #0
    ldr r3, get_attr
    bl call_via_r3
    lsl r0, r0, #0x10
    lsr r0, r0, #0x10
    mov r1, #item_soothebell
    cmp r0, r1
    bne add_happiness

soothebell_bonus:
    lsr r0, r6, #1
    add r5, r0

add_happiness:
    mov r0, r5
    cmp r0, #255
    ble set_happiness
    mov r0, #255

set_happiness:
    mov r2, sp
    strh r0, [r2]
    mov r0, r8
    mov r1, #req_happiness
    ldr r3, set_attr
    bl call_via_r3

return_0:
    mov r0, #0
    b finish_using_ev_berry

check_if_should_return_1:
    cmp r5, #1
    bne return_0

return_1:
    mov r0, #1

finish_using_ev_berry:
    pop {r3-r5}
    mov r8, r3
    mov r9, r4
    mov r10, r5
    pop {r4-r7}
    pop {r1}
    bx r1

happiness_not_at_max_ev_above_0_str:
    .byte 0xFD, 0x02, 0x00, 0xE8, 0xE9, 0xE6, 0xE2, 0xD9, 0xD8, 0x00, 0xDA, 0xE6, 0xDD, 0xD9, 0xE2, 0xD8, 0xE0, 0xED, 0xAD, 0xFE, 0xCE, 0xDC, 0xD9, 0x00, 0xD6, 0xD5, 0xE7, 0xD9, 0x00, 0xFD, 0x03, 0x00, 0xDA, 0xD9, 0xE0, 0xE0, 0xAB, 0xFC, 0x09, 0xFF
    @ "[PKMN] turned friendly.[NEWLINE]The base [STAT] fell![WAITKEYPRESS]"

happiness_up_ev_cant_fall_str:
    .byte 0xFD, 0x02, 0x00, 0xE8, 0xE9, 0xE6, 0xE2, 0xD9, 0xD8, 0x00, 0xDA, 0xE6, 0xDD, 0xD9, 0xE2, 0xD8, 0xE0, 0xED, 0xAD, 0xFE, 0xCE, 0xDC, 0xD9, 0x00, 0xD6, 0xD5, 0xE7, 0xD9, 0x00, 0xFD, 0x03, 0x00, 0xD7, 0xD5, 0xE2, 0xB4, 0xE8, 0x00, 0xDA, 0xD5, 0xE0, 0xE0, 0xAB, 0xFC, 0x09, 0xFF
    @ "[PKMN] turned friendly.[NEWLINE]The base [STAT] can't fall![WAITKEYPRESS]"

adore_ev_down_str:
    .byte 0xFD, 0x02, 0x00, 0xD5, 0xD8, 0xE3, 0xE6, 0xD9, 0xE7, 0x00, 0xED, 0xE3, 0xE9, 0xAB, 0xFE, 0xCE, 0xDC, 0xD9, 0x00, 0xD6, 0xD5, 0xE7, 0xD9, 0x00, 0xFD, 0x03, 0x00, 0xDA, 0xD9, 0xE0, 0xE0, 0xAB, 0xFC, 0x09, 0xFF
    @ "[PKMN] adores you![NEWLINE]The base [STAT] fell![WAITKEYPRESS]"

.align 2
    fcode_buffer2:          .word 0x02021CD0
    fcode_buffer3:          .word 0x02021CF0
    displayed_string:       .word 0x02021D18
    party_player:           .word 0x02024284
    var_8000:               .word 0x020370B8
    var_8001:               .word 0x020370BA
    var_800E:               .word 0x0203AD30
    brm:                    .word 0x0203B0A0
    item_effectiveness:     .word 0x0203B0C0

    tasks:                  .word 0x03005090

    strcpy_xFF_terminated:  .word 0x08008D84|1
    fdecoder:               .word 0x08008FCC|1
    recalculate_stats:      .word 0x0803E47C|1
    get_attr:               .word 0x0803FBE8|1
    set_attr:               .word 0x0804037C|1
    sav1_map_get_name:      .word 0x08056260|1
    audio_play:             .word 0x080722CC|1
    bag_remove_item:        .word 0x0809A1D8|1
    bgid_mark_for_sync:     .word 0x080F67A4|1
    buffer_pkmn_nick:       .word 0x081202E0|1
    item_menu_string:       .word 0x081202F8|1
    item_use_animation:     .word 0x08124DC0|1
    item_menu_callback:     .word 0x081255BC|1
    hp_name_str:            .word 0x084169C2 @ "HP"
    spatk_name_str:         .word 0x084169C5 @ "SP. ATK"
    spdef_name_str:         .word 0x084169CD @ "SP. DEF"
    atk_name_str:           .word 0x08417674 @ "ATTACK"
    def_name_str:           .word 0x0841767B @ "DEFENSE"
    spe_name_str:           .word 0x0841768D @ "SPEED"
    no_effect_str:          .word 0x084169DC @ "It won't have any effect."

The Soothe Bell multiplier acts as it does in Generation IV and onwards (meaning it will also multiply bonuses from the met location and Luxury Ball).

This will introduce the Pomeg Glitch; see tkim's post here on how to fix it.
Attached Files
File Type: asm ev_berries.asm‎ (13.4 KB, 31 views) (Save to Dropbox)
__________________
Reply With Quote
  #1202   Link to this post, but load the entire thread.  
Old June 17th, 2017 (5:08 PM). Edited June 17th, 2017 by Spherical Ice.
tkim's Avatar
tkim tkim is offline
 
Join Date: May 2011
Posts: 232
Quote:
Originally Posted by Spherical Ice View Post

[FR] EV-reducing Berries

Can't wait to try this out! Thanks!

I have two questions though. Can I assume that the luxury ball mentioned in the routine affects the happiness the berries give out? Does the routine also check if the player is at the same location as the berry user's met location and if the berry user is holding a soothe bell at the time (unless Emerald's behaves otherwise)? Here's where my questions are based from: https://bulbapedia.bulbagarden.net/wiki/Friendship#Boosting_friendship
Sorry if I'm overwhelming you.
Reply With Quote
  #1203   Link to this post, but load the entire thread.  
Old June 17th, 2017 (5:42 PM).
Spherical Ice's Avatar
Spherical Ice Spherical Ice is offline
 
Join Date: Nov 2007
Location: Leicester, UK
Age: 25
Posts: 5,251
Quote:
Originally Posted by tkim View Post
Can't wait to try this out! Thanks!

I have two questions though. Can I assume that the luxury ball mentioned in the routine affects the happiness the berries give out? Does the routine also check if the player is at the same location as the berry user's met location and if the berry user is holding a soothe bell at the time (unless Emerald's behaves otherwise)? Here's where my questions are based from: https://bulbapedia.bulbagarden.net/wiki/Friendship#Boosting_friendship
Sorry if I'm overwhelming you.
Ah, I forgot about those bonuses. I've updated the routine to consider both, and used the Gen IV+ method of the Soothe Bell. Thanks for bringing that to my attention!
__________________
Reply With Quote
  #1204   Link to this post, but load the entire thread.  
Old June 17th, 2017 (6:21 PM). Edited June 17th, 2017 by tkim.
tkim's Avatar
tkim tkim is offline
 
Join Date: May 2011
Posts: 232
Quote:
Originally Posted by Spherical Ice View Post
Ah, I forgot about those bonuses. I've updated the routine to consider both, and used the Gen IV+ method of the Soothe Bell. Thanks for bringing that to my attention!
If I wanted to use the Gen III method of the Soothe Bell, can I just rearrange the soothebell check/bonus and change the 'b' conditions to come before the other checks?

edit: here's what I did: is this okay, or do I have to change registers too?
Code:
remember_new_happiness:
    add r5, r5, r0

soothebell_check:
    mov r0, r8
    mov r1, #req_held_item
    mov r2, #0
    ldr r3, get_attr
    bl call_via_r3
    lsl r0, r0, #0x10
    lsr r0, r0, #0x10
    mov r1, #item_soothebell
    cmp r0, r1
    bne luxuryball_check

soothebell_bonus:
    lsr r0, r5, #1
    add r5, r0

luxuryball_check:
    mov r0, r8
    mov r1, #req_pokeball
    mov r2, #0
    ldr r3, get_attr
    bl call_via_r3
    cmp r0, #item_luxuryball
    bne metlocation_check

luxuryball_bonus:
    add r5, #1

metlocation_check:
    mov r0, r8
    mov r1, #req_catch_location
    mov r2, #0
    ldr r3, get_attr
    bl call_via_r3
    mov r4, r0
    ldr r3, sav1_map_get_name
    bl call_via_r3
    lsl r0, r0, #0x18
    lsr r0, r0, #0x18
    cmp r4, r0
    bne add_happiness

metlocation_bonus:
    add r5, #1

add_happiness:
    mov r0, r5
    cmp r0, #255
    ble set_happiness
    mov r0, #255
Reply With Quote
  #1205   Link to this post, but load the entire thread.  
Old June 17th, 2017 (6:34 PM).
Spherical Ice's Avatar
Spherical Ice Spherical Ice is offline
 
Join Date: Nov 2007
Location: Leicester, UK
Age: 25
Posts: 5,251
Quote:
Originally Posted by tkim View Post
If I wanted to use the Gen III method of the Soothe Bell, can I just rearrange the soothebell check/bonus and change the 'b' conditions to come before the other checks?

edit: here's what I did: is this okay, or do I have to change registers too?
Yeah, that should work. The registers shouldn't need changing as far as I can tell. Best way to know is to test yourself and have a script that buffers the Pokémon's friendship so you can test; that's what I did.
__________________
Reply With Quote
  #1206   Link to this post, but load the entire thread.  
Old June 17th, 2017 (8:09 PM). Edited June 17th, 2017 by tkim.
tkim's Avatar
tkim tkim is offline
 
Join Date: May 2011
Posts: 232
Quote:
Originally Posted by Spherical Ice View Post
Yeah, that should work. The registers shouldn't need changing as far as I can tell. Best way to know is to test yourself and have a script that buffers the Pokémon's friendship so you can test; that's what I did.
I tested your routine on a pokemon that had 70 base happiness to start with, holding a soothe bell without factoring met location/luxury ball and its happiness grew by 50 (10 from berry and 40 from halving 80), making it 120 base happiness, instead of 85 ( 70 + 10 +5).

You could probably use r6 for the add_ten/five/two_happiness and also 'add r6, #1' for met location bonus/luxury ball bonus.

edit: here's a fix for ease!
Code:
add_ten_happiness:
    mov r6, #10
    b remember_new_happiness

add_five_happiness:
    mov r6, #5
    b remember_new_happiness

add_two_happiness:
    mov r6, #2

remember_new_happiness:
    add r5, r6, r0

luxuryball_check:
    mov r0, r8
    mov r1, #req_pokeball
    mov r2, #0
    ldr r3, get_attr
    bl call_via_r3
    cmp r0, #item_luxuryball
    bne metlocation_check

luxuryball_bonus:
    add r5, #1
    add r6, #1

metlocation_check:
    mov r0, r8
    mov r1, #req_catch_location
    mov r2, #0
    ldr r3, get_attr
    bl call_via_r3
    mov r4, r0
    ldr r3, sav1_map_get_name
    bl call_via_r3
    lsl r0, r0, #0x18
    lsr r0, r0, #0x18
    cmp r4, r0
    bne soothebell_check

metlocation_bonus:
    add r5, #1
    add r6, #1

soothebell_check:
    mov r0, r8
    mov r1, #req_held_item
    mov r2, #0
    ldr r3, get_attr
    bl call_via_r3
    lsl r0, r0, #0x10
    lsr r0, r0, #0x10
    mov r1, #item_soothebell
    cmp r0, r1
    bne add_happiness

soothebell_bonus:
    lsr r0, r6, #1
    add r5, r0
If you use this, the new length will be 0x49C bytes
Reply With Quote
  #1207   Link to this post, but load the entire thread.  
Old June 18th, 2017 (3:43 AM).
Spherical Ice's Avatar
Spherical Ice Spherical Ice is offline
 
Join Date: Nov 2007
Location: Leicester, UK
Age: 25
Posts: 5,251
Quote:
Originally Posted by tkim View Post
I tested your routine on a pokemon that had 70 base happiness to start with, holding a soothe bell without factoring met location/luxury ball and its happiness grew by 50 (10 from berry and 40 from halving 80), making it 120 base happiness, instead of 85 ( 70 + 10 +5).

You could probably use r6 for the add_ten/five/two_happiness and also 'add r6, #1' for met location bonus/luxury ball bonus.

edit: here's a fix for ease!

If you use this, the new length will be 0x49C bytes
Ah, of course. That's what I get for doing ASM at 3am lmao. Fixed the original post, thanks again.
__________________
Reply With Quote
  #1208   Link to this post, but load the entire thread.  
Old June 18th, 2017 (11:03 AM). Edited June 18th, 2017 by tkim.
tkim's Avatar
tkim tkim is offline
 
Join Date: May 2011
Posts: 232
Spherical Ice' [FR] EV-reducing Berries does in fact bring back the Pomeg Glitch. If you want to fix this, go to offset 0x3E742 and make the following change:

00 29 04 D1 -> 02 29 04 DC

Credits to HackMew: https://www.pokecommunity.com/showthread.php?t=207217
Note: Despite what Wichu said about Pomeg no longer being usable on Shedinja in that thread- I've tested it and it works. I'm also not aware if this change affects anything else during gameplay, so if anybody else could chime in...
Reply With Quote
  #1209   Link to this post, but load the entire thread.  
Old July 4th, 2017 (11:14 PM).
Rohink's Avatar
Rohink Rohink is offline
 
Join Date: Apr 2017
Location: Hm... maybe somewhere in the world
Gender: Male
Nature: Bold
Posts: 4
I wonder if it was possible to make pc accessible from start menu in fire
Reply With Quote
  #1210   Link to this post, but load the entire thread.  
Old July 8th, 2017 (5:07 PM).
ghoulslash's Avatar
ghoulslash ghoulslash is offline
 
Join Date: Mar 2016
Gender: Male
Posts: 238
Toggle Oak Text in Trainerbattle 0x9 [FR]

Building off of another post in the Quick Research and Development thread about trainerbattle 0x9, turns out that changing the reserved byte from 0x3 to 0x0 in trainerbattle 0x9 removes the text, but also causes you to white out instead of continue with the script if you lose.

This routine hijacks the trainerbattle command to use variable 0x8000 to toggle Oak's text on or off, while keeping the same functionality of continuing the script even if you lose the battle. I mentioned this in my linked post, but 0x1 is also written to variable 0x800D if you lose, allowing you to branch the script based on your battle result.

Here is the code/insertion instructions:
Code:
.text
.align 2
.thumb
.thumb_func

@At 08080478: 00 48 00 47 XX XX XX 08

main:
	ldr r0, =(0x020370B8)			@variable 0x8000
	ldrb r0, [r0]
	cmp r0, #0x1
	beq NoText
	ldr r0, =(0x080803D8 +1)
	bl linker
	mov r1, #0x3
	and r1, r0
	cmp r1, #0x0
	beq NoText
	ldr r0, =(0x08080484 +1)		@jump back to original routine
	bx r0
	
NoText:
	ldr r0, =(0x0808048C +1)
	bx r0

linker:
	bx r0
	
.align 2
To use:
Code:
setvar 0x8000 0x1
trainerbattle 0x9 0x(ID) 0x3 @lose @win
Let me know if there are any bugs.
Reply With Quote
  #1211   Link to this post, but load the entire thread.  
Old July 11th, 2017 (9:55 AM). Edited August 15th, 2017 by AkameTheBulbasaur.
AkameTheBulbasaur's Avatar
AkameTheBulbasaur AkameTheBulbasaur is offline
Akame Marukawa of Iyotono
 
Join Date: May 2013
Location: A place :D
Age: 25
Gender: Male
Nature: Docile
Posts: 408
I fixed the issue of Squeetz's Synchronize routine and FBI's Shiny Generator routine conflicting.

Squeetz's routine works by taking the Synchronize Pokemon's nature and setting that BEFORE the PID is generated. Turns out, FBI's Shiny Generator routine is activated afterwards, and completely redoes the PID generation, essentially making Squeetz's routine never actually come into effect.

To use both, you can use this combination of both their routines in one. I tested it in my game and it works for all four of these scenarios

1. Not Shiny and no Synchronize Pokemon
2. Not Shiny with a Synchronize Pokemon
3. Shiny and no Synchronize Pokemon
4. Shiny with a Synchronize Pokemon

It might not be super efficient, because it loops a lot, but I couldn't find a better way to do it and still get the desired result.

Spoiler:
/*Insert 00 48 00 47 XX XX XX 08 at 0x3DB00*/
/*Also insert 00 00 02 E0 at 0x3DAF6*/
.text
.align 2
.thumb
.thumb_func


Main:
/*Checks if 0x8003 = 1*/
/*If false it goes back to normal*/
ldr r0, .Var8003
ldrb r0, [r0]
cmp r0, #0x1
bne Return

SetBackToZero:
/*Sets 0x8003 back to 0*/
push {r4-r7}
ldr r0, .Var8003
mov r1, #0x0
strb r1, [r0]

SynchronizeCheck:
/*Checks for first Pokemon's ability*/
bl GetAbility
cmp r1, #0x1C
beq Synchronize
b SetPID

Synchronize:
/*Gets first Pokemon's nature*/
ldr r0, .FirstPoke
mov r1, #0x0
mov r2, #0x0
bl Decrypt
bl GetNature
lsl r0, r0, #0x18
lsr r5, r0, #0x18

GenPID:
/*Generates a new bottom half of PID*/
/*Puts it together with stored top half*/
/*Checks to see if it matches nature*/
bl GeneratePID
mov r4, r0
bl GetNature
lsl r0, r0, #0x18
lsr r0, r0, #0x18
cmp r0, r5
beq GenerateC
b GenPID

SetPID:
/*Generates a PID for the Pokemon*/
bl GeneratePID
mov r4, r0

GenerateC:
/*This generates a random number between 0 and 8*/
/*This number will be used as C*/
bl RNG
lsr r0, r0, #0x8
cmp r0, #0x7
bgt GenerateC
mov r3, r0

FirstXOR:
/*XORs the TID and SID*/
ldr r0, .SaveBlockC
ldr r0, [r0]
mov r1, #0xA
add r1, r1, r0 /*Gets Trainer ID*/
ldrh r1,[r1]
mov r2, #0xC
add r0, r0, r2 /*Gets Secret ID*/
ldrh r0, [r0]
eor r0, r0, r1 /*A = TID xor SID*/
eor r3, r3, r0 /*B = C xor A*/

SecondXOR:
/*This XORs PID1 and PID2*/
/*PID1 = first half of PID*/
lsl r4, r4, #0x10
lsr r4, r4, #0x10 /*r4 = PID2*/
eor r3, r3, r4 /*PID1 = PID2 xor B*/

ConcatenateR4R3:
/*Concatenate means 'to link together'*/
/*This puts PID1 and PID2 together*/
lsl r3, r3, #0x10
orr r3, r3, r4 /*PID for Shiny Pokemon*/
bl GetAbility
cmp r1, #0x1C
beq CheckNatureAgain
b PrepareEnd

CheckNatureAgain:
/*Basically loops through the whole process again*/
/*Until it finds a PID that gives the right nature*/
/*And is Shiny as well*/
mov r6, r3
mov r0, r3
bl GetNature
lsl r0, r0, #0x18
lsr r0, r0, #0x18
cmp r0, r5
bne GenPID
mov r3, r6

PrepareEnd:
pop {r4-r7}
str r3, [SP, #0x14]
b End

Return:
bl GetAbility
cmp r1, #0x1C
bne NoCrash
ldr r0, .FirstPoke
mov r1, #0x0
mov r2, #0x0
bl Decrypt
bl GetNature
lsl r0, r0, #0x18
lsr r5, r0, #0x18

PIDLoop:
bl GeneratePID
mov r4, r0
bl GetNature
lsl r0, r0, #0x18
lsr r0, r0, #0x18
cmp r5, r0
bne PIDLoop
b Old

NoCrash:
bl GeneratePID
mov r4, r0

Old:
str r4, [sp, #0x14]

End:
ldr r0, =(0x803DB14 +1)
bx r0

RNG:
ldr r6, .RNGRoutine
bx r6

GeneratePID:
push {r4, lr}
bl HalfPID
mov r4, r0
bl HalfPID2
lsl r4, r4, #0x10
lsr r4, r4, #0x10
lsl r0, r0, #0x10
orr r4, r0
mov r0, r4
pop {r4, pc}

GetAbility:
push {r3-r4, lr}
ldr r0, .FirstPoke
mov r1, #0x2E
mov r2, #0x0
bl Decrypt
mov r4, r0
ldr r0, .FirstPoke
mov r1, #0xB
mov r2, #0x0
bl Decrypt
ldr r2, .Stats
ldr r2, [r2]
mov r1, #0x1C
mul r0, r1
add r2, r0, r2
cmp r4, #0x0
beq Ability0
ldrb r1, [r2, #0x17]
pop {r3-r4, pc}

Ability0:
ldrb r1, [r2, #0x16]
pop {r3-r4, pc}

GetNature:
ldr r3, .Nature
bx r3

Decrypt:
ldr r3, .Decrypter
bx r3

HalfPID:
ldr r4, .PID
bx r4

HalfPID2:
ldr r3, .PID
bx r3

Divide:
ldr r7, .Divider
bx r7

.align 2
.Var8003: .word 0x020370BE
.Var8000: .word 0x020370B8
.RNGRoutine: .word 0x0898ADC9 /*Offset of RNG routine +1*/
.SaveBlockC: .word 0x0300500C
.Divider: .word 0x081E4019
.PID: .word 0x08044EC9
.Decrypter: .word 0x0803FBE9
.FirstPoke: .word 0x02024284
.Stats: .word 0x080001BC
.Nature: .word 0x08042EB5


This replaces the Shiny Generator routine, so branch to it at 0x3DB00. You can get rid of the branch at the old Synchronize location since that's not being used.

If you use this, be sure to credit both FBI and Squeetz for their original routines. I don't want to take any credit for their hard work. I just merged the two preexisting codes.

A note, this particular routine makes Synchronize activate 100% of the time. Squeetz's routine had a 50% chance. If you want that still, you can add some sort of RNG/compare thing. There's already an RNG in the routine, so this shouldn't be too hard to do (I hope. I've never tried it).

This also makes Synchronize work with Eggs (I also think, because it did for me, but I hatched the egg immediately after getting it, and I forget when natures are determined.)
__________________
"The human sacrificed himself, to save the Pokemon. I pitted them against each other, but not until they set aside their differences did I see the true power they all share deep inside. I see now that the circumstances of one's birth are irrelevant; it is what you do with the gift of life that determines who you are." -Mewtwo
Reply With Quote
  #1212   Link to this post, but load the entire thread.  
Old July 14th, 2017 (8:51 AM).
Megax Rocker's Avatar
Megax Rocker Megax Rocker is offline
 
Join Date: Jan 2016
Posts: 112
Quote:
Originally Posted by FBI View Post

Inheriting IVs from parents (via Destiny Knot, in the daycare)



How to insert:

Before doing anything, look at the code. There are two comments that say:
@masterball lol. Change to item you want :D
@Parent2 has masterball :D
At those lines, change the line to "cmp r0, #0xDestinyKnotItemID" and
"cmp r3, #0xDestinyKnotItemID" respectively.

Once you're done that, compile and insert into free space.
Spoiler:

Code:
.text
.align 2
.thumb
.thumb_func

main:
	push {r3, r6}
	mov r6, lr
	mov r0, r5
	mov r1, #0xC
	ldr r2, =(0x803FD44 +1)
	bl linker
	mov r3, r0
	mov r0, r5
	add r0, r0, #0x8C
	mov r1, #0xC
	ldr r2, =(0x803FD44 +1)
	bl linker
	cmp r0, #0x1 @masterball lol. Change to item you want :D
	beq inherit
	cmp r3, #0x1 @Parent2 has masterball :D
	beq inherit

end:
	mov lr, r6
	pop {r3, r6}
	mov r0, SP
	mov r1, r5
	ldr r3, = (0x8045AC0 +1)
	bl linkerTwo
	ldr r0, =(0x8046100+1)
	bx r0

inherit:
	mov r3, #0x5
	bl generateRand
	ldrh r3, [r3]
	push {r4, r7}
	mov r4, #0x27
	add r4, r4, r3 @uninherited stat
	mov r7, #0x0

loop:
	cmp r7, #0x6
	beq prepareEnd
	cmp r7, r4
	beq next
	mov r3, #0x1
	bl generateRand @get a random parent's specified IV
	mov r0, r3
	ldrh r0, [r0]
	mov r1, #0x8C
	mul r0, r0, r1
	add r0, r0, r5
	mov r1, #0x27
	add r1, r1, r7
	ldr r2, =(0x803FBE8 +1)
	bl linker
	ldr r2, = (0x20370D0) @set IV to child
	strh r0, [r2]
	mov r1, #0x27
	add r1, r1, r7
	mov r0, SP
	ldr r3, =(0x804037C +1)
	bl linkerTwo	
next:
	add r7, r7, #0x1
	b loop
	 
prepareEnd:
	mov r0, SP
	ldr r3, =(0x803E47C +1) @calc stats
	bl linker
	pop {r4, r7}
	b end

generateRand:
	ldr r2, =(0x8044EC8 +1) @get a random between 0 - r3 (r3 = HW)
	bl linker
	lsl r0, r0, #0x10
	lsr r0, r0, #0x10
	mov r1, r3
	ldr r3, =(0x81E4684 +1)
	bl linkerTwo
	ldr r3, = 0x20370D0 @could just move it to r3 I suppose
	strh r0, [r3]
	bx lr
		

linker:
	bx r2

linkerTwo:
	bx r3


.align 2


Here's a compiled version:
Code:
48 B4 76 46 28 1C 0C 21 26 4A 00 F0 49 F8 03 1C 28 1C 8C 30 0C 21 23 4A 00 F0 42 F8 01 28 0A D0 01 2B 08 D0 B6 46 48 BC 68 46 29 1C 1E 4B 00 F0 38 F8 1E 48 00 47 05 23 00 F0 26 F8 1B 88 90 B4 27 24 E4 18 00 27 06 2F 18 D0 A7 42 14 D0 01 23 00 F0 1A F8 18 1C 00 88 8C 21 48 43 40 19 27 21 C9 19 13 4A 00 F0 1C F8 12 4A 10 80 27 21 C9 19 68 46 11 4B 00 F0 15 F8 01 37 E4 E7 68 46 0F 4B 00 F0 0E F8 90 BC CD E7 0D 4A 00 F0 09 F8 00 04 00 0C 19 1C 0B 4B 00 F0 04 F8 06 4B 18 80 70 47 10 47 18 47 45 FD 03 08 C1 5A 04 08 01 61 04 08 E9 FB 03 08 D0 70 03 02 7D 03 04 08 7D E4 03 08 C9 4E 04 08 85 46 1E 08
Now go to 0x460F8 and insert the following:
Code:
 00 48 00 47 XX XX XX 08
Where XX XX XX is the pointer in reverse hex +1 of the routine you just compiled.


How it works:
When the egg is generated, we check both parents to see if their holding an item matching the item we're looking for. If they are, the egg inherits 5/6 IVs from their parents. Each parent has a 50% chance to pass down one of their IVs.

There is no usage section, because the rest is done automagically when you have two compatible Pokemon in the daycare and they make an egg :)

Also, sorry for the double post, I wanted a fresh post for the first page :P
I want to edit this routine so it doesn't check for an item to be held for it to activate, basically I want Pokemon to inherit IV all the time.

What should I do?
Reply With Quote
  #1213   Link to this post, but load the entire thread.  
Old July 14th, 2017 (8:49 PM).
Aiolia.leo's Avatar
Aiolia.leo Aiolia.leo is offline
 
Join Date: Feb 2013
Location: Ecruteak City
Gender: Other
Nature: Lonely
Posts: 38
Quote:
Originally Posted by tkim View Post
Spherical Ice' [FR] EV-reducing Berries does in fact bring back the Pomeg Glitch. If you want to fix this, go to offset 0x3E742 and make the following change:

00 29 04 D1 -> 02 29 04 DC

Credits to HackMew: https://www.pokecommunity.com/showthread.php?t=207217
Note: Despite what Wichu said about Pomeg no longer being usable on Shedinja in that thread- I've tested it and it works. I'm also not aware if this change affects anything else during gameplay, so if anybody else could chime in...
Is this actually accurate? Cuz AFAIK HackMew's fix is for Emerald, not Fire Red roms.
Reply With Quote
  #1214   Link to this post, but load the entire thread.  
Old July 14th, 2017 (9:01 PM).
Blah's Avatar
Blah Blah is offline
Free supporter
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,924
Quote:
Originally Posted by Megax Rocker View Post
I want to edit this routine so it doesn't check for an item to be held for it to activate, basically I want Pokemon to inherit IV all the time.

What should I do?
Code:
	cmp r0, #0x1 @masterball lol. Change to item you want :D
	beq inherit
	cmp r3, #0x1 @Parent2 has masterball :D
	beq inherit
to
Code:
b inherit
disclaimer: I'm not sure if this routine works/how it works anymore.
__________________
...
Reply With Quote
  #1215   Link to this post, but load the entire thread.  
Old July 14th, 2017 (10:17 PM).
tkim's Avatar
tkim tkim is offline
 
Join Date: May 2011
Posts: 232
Quote:
Originally Posted by Aiolia.leo View Post
Is this actually accurate? Cuz AFAIK HackMew's fix is for Emerald, not Fire Red roms.
The offset I posted is for FR and like I mentioned, I have tested it.
Reply With Quote
  #1216   Link to this post, but load the entire thread.  
Old July 15th, 2017 (7:35 AM). Edited July 16th, 2017 by chestertagat.
chestertagat's Avatar
chestertagat chestertagat is offline
Dumbest Person in the World.
 
Join Date: Dec 2012
Location: Philippines
Age: 25
Gender: Male
Nature: Adamant
Posts: 63
I don't know if anyone here has already posted this one,
But i'm sure someone researched this and used it in their hack. (BTW It's Glazed if you don't know)
Credits to: TheCreatorofGlazed for the wonderful Idea, BluRose for the Initialization and Touched Sensei for everything else.

Here it is:

[FR] Text Display Input Routine
Basically what this do is get an input from user via naming_function and stores it somewhere in the ram then compare it to some string you can define.

Note: I'm not GOOD at ASM so don't judge me if i said something wrong or explained something wrong. Please point it out instead . It's just that those ones who I asked to help me are very GOOOOOOOOOOOOD at ASM.
Routine:
Spoiler:
Code:
.text
.align 2

main:
        push {r4, lr}
        sub sp, #8 
        mov r0, #0x4              @Type: 0-4 , 4=rival 3=Pokemon
        ldr r1, fcode_buffer
        mov r2, #0
        mov r3, #0
        mov r4, #0
        str r4, [sp]
        adr r4, continue
		add r4, #1
        str r4, [sp, #4]
        ldr r4, display_text
        bl call_via_r4
        add sp, #8
        pop {r4, pc}

.align 2
display_text: .word 0x0809d954|1


continue:
        push {r4, lr}
        ldr r0,fcode_buffer
        ldr r1, real_password
        ldr r1, [r1]
		ldr r4, strcomp
        bl call_via_r4
        cmp r0, #0
        beq matched
        mov r0, #0
        b return

matched:
        mov r0, #1

return:
		ldr r1, var_800D
        strh r0, [r1]
        ldr r4, =0x080568E0|1
        bl call_via_r4
        pop {r4, pc}

call_via_r4:
        bx r4

.align 2
strcomp:      .word 0x08008E28|1
fcode_buffer: .word 0x02021CE0
real_password:.word 0x03000EB0+0x64
var_800D:     .word 0x020370D0

Instruction:
Spoiler:

You can define your password by putting :
loadpointer 0 @password
before the callasm. (note: you can't set your password more than the max Characters in the Input or else it will fail)
#org @password
= yourpass (yes you treat it like a msgstring and also remember the note above)
and what does this do if the input matches your password?
it sets var 0x800D to 1
and if not ViceVersa
and also. instead of defining the password on your script , you can point it out at any address in the rom as long as it's a string that is not more than the max input char.
you can do that by changing the label real_password to the address of your password.

That's it .
and another one , You can also change the "Rival's Name" text or "PKMN name" if you found out how to do that . It'll be really helpful :)
This Routine can be used for many things not just for Password System. You can use it to name People in your game , It's up to you.

and also feel free to ask what is what :D
__________________
My Tool:
Dumb Pokemon ROM Editor
Reply With Quote
  #1217   Link to this post, but load the entire thread.  
Old July 15th, 2017 (12:36 PM). Edited July 16th, 2017 by BluRose.
BluRose BluRose is offline
blu rass
 
Join Date: Apr 2014
Location: michigan tech
Age: 22
Gender: Male
Nature: Timid
Posts: 812
final edit:
if you want to implement this, stay with this post, i babble a lot. good luck

EDIT2: reeeeeee that's hacky af but ok that should work lol. unspoilered post and spoilered previous edit

Spoiler:
EDIT: i was told by discord that he had it complete so i guess i'll just spoiler this post
good job dude~


Quote:
Originally Posted by chestertagat View Post
I don't know if anyone here has already posted this one,
But i'm sure someone researched this and used it in their hack. (BTW It's Glazed if you don't know)
Credits to: TheCreatorofGlazed for the wonderful Idea, BluRose for the Initialization and Touched Sensei for everything else.

Here it is:

[FR] Text Display Input Routine
Basically what this do is get an input from user via naming_function and stores it somewhere in the ram then compare it to some string you can define.

Note: I'm not GOOD at ASM so don't judge me if i said something wrong or explained something wrong. Please point it out instead . It's just that those ones who I asked to help me are very GOOOOOOOOOOOOD at ASM.
Routine:
Spoiler:
Code:
.text
.align 2

main:
        push {r4, lr}
        sub sp, #8 
        mov r0, #0x4              @set this to 0x1 or 0x2 for Pokemon_nicknaming and 0x4 for rival (if you change it to Rival im not sure if it will require additional args)
        ldr r1, fcode_buffer
        mov r2, #0
        mov r3, #0
        mov r4, #0
        str r4, [sp]
        adr r4, continue
		add r4, #1
        str r4, [sp, #4]
        ldr r4, display_text
        bl call_via_r4
        add sp, #8
        pop {r4, pc}

.align 2
display_text: .word 0x0809d954|1


continue:
        push {r4, lr}
        ldr r0,fcode_buffer
        ldr r1, real_password
        ldr r1, [r1]
		ldr r4, strcomp
        bl call_via_r4
        cmp r0, #0
        beq matched
        mov r0, #0
        b return

matched:
        mov r0, #1

return:
		ldr r1, var_800D
        strh r0, [r1]
        ldr r4, =0x080568E0|1
        bl call_via_r4
        pop {r4, pc}

call_via_r4:
        bx r4

.align 2
strcomp:      .word 0x08008E28|1
fcode_buffer: .word 0x02021CE0
real_password:.word 0x03000EB0+0x64
var_800D:     .word 0x020370D0

Instruction:
Spoiler:

You can define your password by putting :
loadpointer 0 @password
before the callasm. (note: you can't set your password more than the max Characters in the Input or else it will fail)
#org @password
= yourpass (yes you treat it like a msgstring and also remember the note above)
and what does this do if the input matches your password?
it sets var 0x800D to 1
and if not ViceVersa
and also. instead of defining the password on your script , you can point it out at any address in the rom as long as it's a string that is not more than the max input char.
you can do that by changing the label real_password to the address of your password.

That's it .
and another one , You can also change the "Rival's Name" text or "PKMN name" if you found out how to do that . It'll be really helpful :)
This Routine can be used for many things not just for Password System. You can use it to name People in your game , It's up to you.

and also feel free to ask what is what :D
hi
quick correction
Spoiler:
Code:
        mov r0, #0x4              @set this to 0x1 or 0x2 for Pokemon_nicknaming and 0x4 for rival (if you change it to Rival im not sure if it will require additional args)
00 is player
01 is for box naming
02 is for pokémon
03 is literally 02, maybe used for hatching?
04 is the rival


and now, adding on to it

note: i've not actually gotten the following to work satisfactorily, even when just copying a previous entry directly onto the new one, so i'm considering this incomplete but usable

okay so basically we're going to repoint the table at x3E248C which has 5 pointers. there's exactly one pointer to this table, should be at x9DB58

add a new pointer to at least 12 bytes of free space (not hexadecimal). in these bytes, you're going to put some data.
now, the sequence goes like this:
1 byte - ida lists this as "pre-filled," meaning you could fill in things automatically? neat, no idea how that would work, though
1 byte - length of entry. max is 13 (0D)
1 byte - image index
1 byte - gender icon shown - 00 no, 01 yes
1 byte - this one seems to change what it looks like when the naming screen is accessed, but it always looks like this anyways

3 unknown bytes
4 bytes - pointer to what the text for the prompt should be (i.e. "YOUR NAME?" "RIVAL's NAME?")

* image index can be one of the following values
00 - nothing shows on the shadow thing
01 - player character, probably changes depending on gender
02 - the pc icon, used for renaming boxes (what i use for the password purpose)
03 - pokémon icon (because no pokémon is loaded in r2, we get the question mark)
04 - gary overworld
05 and above reset the game

and so we go for what i put to simulate the password
00 0A 02 00 01 00 00 00 XX XX XX 08
which means it is not pre-filled, the password is ten characters long, the icon used is the one for the pc, there is no gender icon, the "access screen" is 01, and the text for the prompt is located at 08XXXXXX.

and now for the problem which you all may have caught earlier

there's no text, leaving this large blank white space. the pointer i mentioned earlier doesn't seem to affect anything. i even took the rival's entry and pasted it over exactly, and... well, here's the results:

however, editing earlier entries works just finely


so, um, yeah. happy hacking~

EDIT3: when 0xFB (celebi index) is in r2, we get this when image is set to 03

can't figure out other two registers though so uh ahaha

HOPEFULLY final edit:

okay! so now we're going to do this rather hackily but it should work (has worked for my testing).

change the bytes at x47614, x9FD1A, xCC038, and xCC112 from 03 to 02. this makes it so that we can use 03 for our purposes. hatching eggs uses 03, but i'm able to nickname hatched pokémon just finely with 02.
so, x3E248C, the table. repoint x3E2498 to some freespace. at this freespace, fill out your entry:
00 for unfilled, length of entry up to 0D, 03 for loading the pokémon icon, 00 for no gender icon, 01 00 00 00, and then a pointer to ANY byte that is JUST FF. my entry looks like this:
Code:
00 0D 03 00 01 00 00 00 D0 00 00 08
and now the weird part. the pokémon names each have a limit of 10 bytes, right? well, yes, but this routine loads until a FF shows up. so, what we can do is use two pokémon names to have our own custom message!
so, i put BF C8 CE BF CC 00 CA BB CD CD D1 C9 CC BE AD FF (ENTER PASSWORD.) at x2469B4, which is the start of the name of the pokémon index 0xFC, or the empty one right after celebi.
and so we edit the beginning of the routine:
Code:
        mov r0, #0x3              @Type: 0-4 , 4=rival 3=Pokemon
        ldr r1, fcode_buffer
        mov r2, #0xFC             @or whichever pokémon you desire that has your custom icon and message, have to edit the routine a bit if over FF
        mov r3, #0
        mov r4, #0
honestly i'm ashamed that i spent so much time on figuring out this horrible method

and now the product:

i changed the icon to a blue ralts to show customizability. but there you have it i guess, certainly a subpar solution but it does the job. a better way would probably have been to point the prompt of a vanilla routine to somewhere in the ram, but that doesn't permit the custom icons.
__________________
heyo check out my github:

BluRosie
highlights:
battle engine for heartgold
various feature branches in heart gold (fairy type, odd egg, mud slopes)

i'm a big part of the development team of pokemon firegold! all the code that i develop for that hack is also on my github

also on discord: BluRose#0412
Reply With Quote
  #1218   Link to this post, but load the entire thread.  
Old July 15th, 2017 (3:28 PM). Edited July 16th, 2017 by chestertagat.
chestertagat's Avatar
chestertagat chestertagat is offline
Dumbest Person in the World.
 
Join Date: Dec 2012
Location: Philippines
Age: 25
Gender: Male
Nature: Adamant
Posts: 63
Quote:
Originally Posted by BluRose View Post
hi
quick correction
Spoiler:
Code:
        mov r0, #0x4              @set this to 0x1 or 0x2 for Pokemon_nicknaming and 0x4 for rival (if you change it to Rival im not sure if it will require additional args)
00 is player
01 is for box naming
02 is for pokémon
03 is literally 02, maybe used for hatching?
04 is the rival


and now, adding on to it

note: i've not actually gotten the following to work satisfactorily, even when just copying a previous entry directly onto the new one, so i'm considering this incomplete but usable

okay so basically we're going to repoint the table at x3E248C which has 5 pointers. there's exactly one pointer to this table, should be at x9DB58

add a new pointer to at least 12 bytes of free space (not hexadecimal). in these bytes, you're going to put some data.
now, the sequence goes like this:
1 byte - ida lists this as "pre-filled," meaning you could fill in things automatically? neat, no idea how that would work, though
1 byte - length of entry. max is 13 (0D)
1 byte - image index
1 byte - gender icon shown - 00 no, 01 yes
1 byte - this one seems to change what it looks like when the naming screen is accessed, but it always looks like this anyways

3 unknown bytes
4 bytes - pointer to what the text for the prompt should be (i.e. "YOUR NAME?" "RIVAL's NAME?")

* image index can be one of the following values
00 - nothing shows on the shadow thing
01 - player character, probably changes depending on gender
02 - the pc icon, used for renaming boxes (what i use for the password purpose)
03 - pokémon icon (because no pokémon is loaded, it is the question mark)
04 - gary overworld
05 and above reset the game

and so we go for what i put to simulate the password
00 0A 02 00 01 00 00 00 XX XX XX 08
which means it is not pre-filled, the password is ten characters long, the icon used is the one for the pc, there is no gender icon, the "access screen" is 01, and the text for the prompt is located at 08XXXXXX.

and now for the problem which you all may have caught earlier

there's no text, leaving this large blank white space. the pointer i mentioned earlier doesn't seem to affect anything. i even took the rival's entry and pasted it over exactly, and... well, here's the results:

however, editing earlier entries works just finely


so, um, yeah. happy hacking~
WTH did you just do? now it's complete :D (Not ,yet :P)
Just wanna add something ,if you wan't to modify the icon and change it to something custom.
Actually you can, How? Change the type to 03, (Pokemon encounter)
now rememeber that it Writes there the Species name and Icon? well , you just need to add your Custom icon and put it somewhere (You add new pokemon actually, Let's you change the icon and Title) .
But to be able to choose Pokemon number you need to put a MOV r2, #thePokemonIndexHere.
That means that argument3 actually becomes the Pokemon Specie number.
You can check out the other Arguments to the funcetion here's what i know:
r0 - type ()
r1 - Pointer to the address you want store the inputted string. in the routine.
r2 - the PokemonIndexNumber

Edit: Not yet complete actually, By choosing 0x3 as type (Pokemon) you can customize the Icon but the Title will Show + nickname at the end of the Custom Title (Pokemon Name)
__________________
My Tool:
Dumb Pokemon ROM Editor
Reply With Quote
  #1219   Link to this post, but load the entire thread.  
Old July 18th, 2017 (11:19 PM).
shanem7 shanem7 is offline
 
Join Date: Mar 2013
Gender: Male
Posts: 44
I have a request:

Can someone help me make wild Pokemon jump at the start of a battle just like how they do on the status screen (Fire Red)? Like how when you view a Pokemon on the status screen in Fire Red they shift/jump slightly up and down. Thanks.
Reply With Quote
  #1220   Link to this post, but load the entire thread.  
Old July 20th, 2017 (6:05 AM).
Lunos's Avatar
Lunos Lunos is offline
Random Uruguayan User
 
Join Date: Oct 2008
Location: Montevideo (Uruguay)
Gender: Male
Nature: Lonely
Posts: 3,000
Quote:
Originally Posted by shanem7 View Post
I have a request:

Can someone help me make wild Pokemon jump at the start of a battle just like how they do on the status screen (Fire Red)? Like how when you view a Pokemon on the status screen in Fire Red they shift/jump slightly up and down. Thanks.
altariaking's "Animated Sprites in Ruby and FireRed" might be what you're looking for.
__________________
Reply With Quote
  #1221   Link to this post, but load the entire thread.  
Old July 20th, 2017 (11:26 AM).
shanem7 shanem7 is offline
 
Join Date: Mar 2013
Gender: Male
Posts: 44
Quote:
Originally Posted by Lunos View Post
altariaking's "Animated Sprites in Ruby and FireRed" might be what you're looking for.
Hmm. It's really not. I'm not looking to animate the sprites but merely to make them 'jump' such as when viewing them from Fire Red's status screen. The code's already there it just needs to be adapted or changed for when there's a battle to make it happen like that. It should be easy enough to do, I just don't know enough ARM, so I posted here hoping to get some help since this doesn't seem to have been done, yet. Thank you for trying, though.
Reply With Quote
  #1222   Link to this post, but load the entire thread.  
Old July 21st, 2017 (3:34 PM). Edited July 21st, 2017 by 12ab.
12ab 12ab is offline
 
Join Date: Jan 2015
Gender: Male
Nature: Quiet
Posts: 8
Quote:
Originally Posted by FBI View Post
Yeah, I can fix my OP to have the Emerald version of the routines too (if you provide them :P).


1) I don't know why it's reseting, I haven't tried Darthatron's method and I don't have another method :x
2) This is a text edit. Look for the text string in the ROM and change it.

Player Backsprite swapping



So basically, it just sets your backsprite to another backsprite.

How to insert:

Compile into free space the following routine:
Spoiler:

Code:
.text
.align 2
.thumb
.thumb_func

main:
	push {r0-r2, lr}
	ldr r0, .Player
	ldr r0, [r0]
	add r0, r0, #0x8
	ldrb r1, [r0]
	ldr r2, .Save
	strb r1, [r2]
	ldr r1, .Var
	ldrb r1, [r1]
	strb r1, [r0]	
	pop {r0-r2, pc}


.align 2
.Player:
	.word 0x300500C
.Var:
	.word 0x20370B8 @0x8000
.Save:
	.word 0x203C231 @save location for current value
Here is a compiled version:
Code:
07 B5 05 48 00 68 08 30 01 78 05 4A 11 70 03 49 09 78 01 70 07 BD C0 46 0C 50 00 03 B8 70 03 02 31 C2 03 02


Usage:

In a script insert:
setvar 0x8000 0x[backsprite number]
callasm 0x[routine +1]

Here is a list of possible backsprite numbers:
Code:
0x0 - Male Hero
0x1 - Female Hero
0x2 - Brendon
0x3 - May
0x4 - Teachy TV guy
0x5 - Old man
Greater than 0x5 - game crash :3
Before using this routine there are a few things you should know about it. There is a limit of 6 possible backsprite swaps including: Male Hero, Female Hero, Brendon, May, Teachy TV guy, Old man.
If you need to have more than 6, then figure that out yourself. Otherwise I would just edit over the existing ones rather than inserting new ones.

The second thing you need to know is that this routine works by changing the Player's gender byte. You need to set it back to normal after you're done with the event, or it will reflect in the overworld in the form of a nice buggy player char.

However, you cannot use the checkgender scripting command to figure this out, because we overwrote that byte. So luckily for you, I already thought of that and decided to write the player's backsprite to RAM offset 0x203C231.

So to set it back, use this after the end of your event:
Code:
copybyte 0x20370B8 0x203C231 '@will put the player's old gender byte in 0x8000
callasm 0x[routine +1]
That's it. Here's a nice video:
If this is possible is it also possible for not only the back sprite but the front sprite used for the trainer card and the overworld sprites simultaneously? I was thinking of having the trainer in Emerald be able to change their clothes to the ones from Ruby and Sapphire if the player wanted.
Reply With Quote
  #1223   Link to this post, but load the entire thread.  
Old July 21st, 2017 (9:55 PM).
Blah's Avatar
Blah Blah is offline
Free supporter
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,924
Quote:
Originally Posted by 12ab View Post
If this is possible is it also possible for not only the back sprite but the front sprite used for the trainer card and the overworld sprites simultaneously? I was thinking of having the trainer in Emerald be able to change their clothes to the ones from Ruby and Sapphire if the player wanted.
The algorithm of changing gender to change the backsprite is fundamentally flawed. But I suppose you can write a small hook to change the front sprite too. Anyways this is years old and I have no intention of updating, much less for Emerald.
__________________
...
Reply With Quote
  #1224   Link to this post, but load the entire thread.  
Old July 27th, 2017 (6:38 AM).
Foxes's Avatar
Foxes Foxes is offline
 
Join Date: Sep 2015
Gender: Male
Posts: 59
Quote:
Originally Posted by Spherical Ice View Post

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.



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!
Sorry for being dumb, but how do I actually implement this into the game?
Reply With Quote
  #1225   Link to this post, but load the entire thread.  
Old July 27th, 2017 (6:54 AM).
Sakib66's Avatar
Sakib66 Sakib66 is offline
 
Join Date: Jan 2017
Gender: Male
Nature: Adamant
Posts: 196
Quote:
Originally Posted by Gameskiller01 View Post
Sorry for being dumb, but how do I actually implement this into the game?
use TL's quick enhancer tool
Reply With Quote
Reply

Quick Reply

Join the conversation!

Create an account to post a reply in this thread, participate in other discussions, and more!

Create a PokéCommunity Account
Ad Content

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 8:46 AM.