summaryrefslogtreecommitdiff
path: root/asm/shedinja/black2_shedinja.asm
blob: 6a63d685e0b0a17ac539089cfe68a7deeed2778e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
    .nds
    .thumb
    .open "pkmnblack2_ovl284", "pkmnblack2_ovl284_shedinja", 0x021E30E0

    NEW_INDEX_TO_SHEDINJA_SUBR_HOOK equ 0x021E488E
    OLD_INDEX_TO_SHEDINJA_SUBR_CONTINUED equ 0x021E48B6

    SET_POKEMON_SPECIES equ 0x0201C7B4
    SET_POKEMON_ATTRIBUTE equ 0x0201CD1C

    ITCM_SRC_START equ 0x0209D740
    ITCM_DEST_START equ 0x01FF8000
    ITCM_OLD_SIZE equ 0x1560 ; Originally 0x13A0, but this occurs after the 0x1C0 sized music patch

    NEW_INDEX_TO_SHEDINJA_SUBR equ ITCM_SRC_START + ITCM_OLD_SIZE
    NEW_INDEX_TO_SHEDINJA_SUBR_ITCM equ ITCM_DEST_START + ITCM_OLD_SIZE
    BL_OFFSET equ (NEW_INDEX_TO_SHEDINJA_SUBR) - (NEW_INDEX_TO_SHEDINJA_SUBR_ITCM)

    ; Hook that jumps to our new subroutine
    .org NEW_INDEX_TO_SHEDINJA_SUBR_HOOK
    mov     r0, r4
    bl      org() + 6
    b       OLD_INDEX_TO_SHEDINJA_SUBR_CONTINUED
    ldr     r2,=#(NEW_INDEX_TO_SHEDINJA_SUBR_ITCM + 1)
    bx      r2
    .pool

    .close

    .open "pkmnblack2.bin", "pkmnblack2_shedinja.bin", 0x02004000
    ; New subroutine. This is passed a pointer to the Pokemon data struct in r0; it is responsible
    ; for setting the species and first few attributes of the newly-generated Shedinja. Most of this
    ; code is copied from the original game, but it has been modified for easier modification of the
    ; species ID (it was generated via some silly left shift in the original code).
    .org NEW_INDEX_TO_SHEDINJA_SUBR
    .area 48

    push    { r4, lr }
    mov     r4, r0                             ; Save pointer to Pokemon data to r4 so it can be used again after calling functions
    ldr     r1,=#0x124                         ; Shedinja
    bl      BL_OFFSET + SET_POKEMON_SPECIES
    mov     r0, r4
    mov     r1, #0x98                          ; Attribute key for which ball the Pokemon is caught in
    mov     r2, #0x4                           ; Poke Ball
    bl      BL_OFFSET + SET_POKEMON_ATTRIBUTE
    mov     r0, r4
    mov     r1, #0x6                           ; Attribute key for the Pokemon's held item
    mov     r2, #0x0                           ; No item
    bl      BL_OFFSET + SET_POKEMON_ATTRIBUTE
    mov     r0, r4
    mov     r1, #0xB                           ; Attribute key for the Pokemon's mark
    mov     r2, #0x0                           ; No mark
    bl      BL_OFFSET + SET_POKEMON_ATTRIBUTE
    pop     { r4, pc }
    .pool
    .endarea

    .close