summaryrefslogtreecommitdiff
path: root/asm/shedinja
diff options
context:
space:
mode:
authortom-overton <tom.overton@outlook.com>2022-12-22 22:37:02 -0800
committerRafael Marçalo <raroma09@gmail.com>2023-01-03 14:41:30 +0000
commit175ec21f7b5983a3bb472953c2119af9e3b69f39 (patch)
tree9feb7e4b044446ae855642762ced02dae234a4d9 /asm/shedinja
parentf5880a1039828686ff0d7d0bf8fac304044f9b62 (diff)
Gen 5: Fix Shedinja evo crashing on Bizhawk/real hardware
Diffstat (limited to 'asm/shedinja')
-rw-r--r--asm/shedinja/black2_shedinja.asm58
-rw-r--r--asm/shedinja/black_shedinja.asm58
-rw-r--r--asm/shedinja/white2_shedinja.asm58
-rw-r--r--asm/shedinja/white_shedinja.asm58
4 files changed, 232 insertions, 0 deletions
diff --git a/asm/shedinja/black2_shedinja.asm b/asm/shedinja/black2_shedinja.asm
new file mode 100644
index 0000000..6a63d68
--- /dev/null
+++ b/asm/shedinja/black2_shedinja.asm
@@ -0,0 +1,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 \ No newline at end of file
diff --git a/asm/shedinja/black_shedinja.asm b/asm/shedinja/black_shedinja.asm
new file mode 100644
index 0000000..818e2ad
--- /dev/null
+++ b/asm/shedinja/black_shedinja.asm
@@ -0,0 +1,58 @@
+ .nds
+ .thumb
+ .open "pkmnblack_ovl195", "pkmnblack_ovl195_shedinja", 0x02203FA0
+
+ NEW_INDEX_TO_SHEDINJA_SUBR_HOOK equ 0x0220573E
+ OLD_INDEX_TO_SHEDINJA_SUBR_CONTINUED equ 0x02205766
+
+ SET_POKEMON_SPECIES equ 0x020178D8
+ SET_POKEMON_ATTRIBUTE equ 0x02017E40
+
+ ITCM_SRC_START equ 0x020A9E80
+ ITCM_DEST_START equ 0x01FF8000
+ ITCM_OLD_SIZE equ 0x91C ; Originally 0x820, but this occurs after the 0xFC 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 "pkmnblack.bin", "pkmnblack_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 \ No newline at end of file
diff --git a/asm/shedinja/white2_shedinja.asm b/asm/shedinja/white2_shedinja.asm
new file mode 100644
index 0000000..3f937ce
--- /dev/null
+++ b/asm/shedinja/white2_shedinja.asm
@@ -0,0 +1,58 @@
+ .nds
+ .thumb
+ .open "pkmnwhite2_ovl284", "pkmnwhite2_ovl284_shedinja", 0x021E3120
+
+ NEW_INDEX_TO_SHEDINJA_SUBR_HOOK equ 0x021E48CE
+ OLD_INDEX_TO_SHEDINJA_SUBR_CONTINUED equ 0x021E48F6
+
+ SET_POKEMON_SPECIES equ 0x0201C7E0
+ SET_POKEMON_ATTRIBUTE equ 0x0201CD48
+
+ ITCM_SRC_START equ 0x0209D780
+ 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 "pkmnwhite2.bin", "pkmnwhite2_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 \ No newline at end of file
diff --git a/asm/shedinja/white_shedinja.asm b/asm/shedinja/white_shedinja.asm
new file mode 100644
index 0000000..336cabe
--- /dev/null
+++ b/asm/shedinja/white_shedinja.asm
@@ -0,0 +1,58 @@
+ .nds
+ .thumb
+ .open "pkmnwhite_ovl195", "pkmnwhite_ovl195_shedinja", 0x02203FC0
+
+ NEW_INDEX_TO_SHEDINJA_SUBR_HOOK equ 0x0220575E
+ OLD_INDEX_TO_SHEDINJA_SUBR_CONTINUED equ 0x02205786
+
+ SET_POKEMON_SPECIES equ 0x020178F4
+ SET_POKEMON_ATTRIBUTE equ 0x02017E5C
+
+ ITCM_SRC_START equ 0x020A9EA0
+ ITCM_DEST_START equ 0x01FF8000
+ ITCM_OLD_SIZE equ 0x91C ; Originally 0x820, but this occurs after the 0xFC 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 "pkmnwhite.bin", "pkmnwhite_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 \ No newline at end of file