From eb7d17e173c3a8cc907333ae48f943062d7fbfad Mon Sep 17 00:00:00 2001 From: Skeli Date: Tue, 3 Dec 2019 14:50:55 +0200 Subject: [PATCH] Fix Caught Pokemon Pokedex Crash --- assembly/hooks.s | 22 ++++++++++++++++++++++ bytereplacement | 4 ++-- hooks | 1 + special_inserts.asm | 24 ++++++++++++------------ src/updated_code.c | 5 +++++ 5 files changed, 42 insertions(+), 14 deletions(-) diff --git a/assembly/hooks.s b/assembly/hooks.s index cc596ae..fd0915d 100644 --- a/assembly/hooks.s +++ b/assembly/hooks.s @@ -1,6 +1,28 @@ .thumb .align 2 +@0x81025E8 with r0 +PokedexMemoryAllocationHook: + ldr r0, [r5] + strb r4, [r0] + bl IsInBattle + cmp r0, #0x0 + bne RegularPokedexMemoryAlloc + ldr r0, .ExpandedPokedexSize + b PokedexMemoryAllocReturn + +RegularPokedexMemoryAlloc: + ldr r0, .RegularPokedexSize + +PokedexMemoryAllocReturn: + ldr r1, =0x81025F0 | 1 + bx r1 + +.align 2 +.RegularPokedexSize: .word 0xC10 +.ExpandedPokedexSize: .word 999 * 8 + +.pool @0x8103530 with r1 PrepareDexListViewsHook: cmp r0, #0x0 diff --git a/bytereplacement b/bytereplacement index f2af309..f8c6d38 100644 --- a/bytereplacement +++ b/bytereplacement @@ -22,8 +22,8 @@ 080971DA C0 46 #Update Pokedex -081025EC FA -081025EE 40 01 +#081025EC FA +#081025EE 40 01 08104B00 C0 46 08104B02 C0 46 08104B16 C0 46 diff --git a/hooks b/hooks index 2e3b4a8..57125cd 100644 --- a/hooks +++ b/hooks @@ -10,6 +10,7 @@ GetEggMoves 8045C28 2 CreateMonSprite_PicBoxHook 808398C 1 GenderedMonIconHook 8096E38 2 GetIconSpecies 8096F5C 2 +PokedexMemoryAllocationHook 81025E8 0 PrepareDexListViewsHook 8103530 1 AlphabeticalDexHook 8103684 1 AlternateDexEntriesHook 8105CBC 0 diff --git a/special_inserts.asm b/special_inserts.asm index e2a64a7..dc34aa7 100644 --- a/special_inserts.asm +++ b/special_inserts.asm @@ -6,8 +6,8 @@ .equ EVOS_PER_MON, 16 .equ NUM_DEX_ENTRIES, 809 -.equ SEEN_DEX_FLAGS, 0x203C700 -.equ CAUGHT_DEX_FLAGS, (SEEN_DEX_FLAGS + (NUM_DEX_ENTRIES / 8) + 1) +@;.equ SEEN_DEX_FLAGS, 0x202583C +@;.equ CAUGHT_DEX_FLAGS, (SEEN_DEX_FLAGS + (NUM_DEX_ENTRIES / 8) + 1) @@Fix Num Evolutions@@ .org 0x4598A, 0xFF @@ -35,8 +35,8 @@ add r3, #EVOS_PER_MON * 8 mov r1, #0x0 mov r2, #(NUM_DEX_ENTRIES / 8) + 1 -.org 0x549D0, 0xFF -.word SEEN_DEX_FLAGS +@;.org 0x549D0, 0xFF +@;.word SEEN_DEX_FLAGS @@Fix Dex Views@@ .org 0x88EA4, 0xFF @Pokedex Count @@ -51,17 +51,17 @@ add r3, #EVOS_PER_MON * 8 .org 0x103920, 0xFF @General .word NUM_DEX_ENTRIES - 1 -.org 0x104B10, 0xFF -.word SEEN_DEX_FLAGS +@;.org 0x104B10, 0xFF +@;.word SEEN_DEX_FLAGS -.org 0x104B5C, 0xFF -.word CAUGHT_DEX_FLAGS +@;.org 0x104B5C, 0xFF +@;.word CAUGHT_DEX_FLAGS -.org 0x104B94, 0xFF -.word SEEN_DEX_FLAGS +@;.org 0x104B94, 0xFF +@;.word SEEN_DEX_FLAGS -.org 0x104BB8, 0xFF -.word CAUGHT_DEX_FLAGS +@;.org 0x104BB8, 0xFF +@;.word CAUGHT_DEX_FLAGS .org 0x104C28, 0xFF .word NUM_DEX_ENTRIES - 1 diff --git a/src/updated_code.c b/src/updated_code.c index a931006..eb4e2bd 100644 --- a/src/updated_code.c +++ b/src/updated_code.c @@ -172,3 +172,8 @@ u16 GetIconSpecies(u16 species, u32 personality) return result; } + +bool8 IsInBattle(void) +{ + return gMain.inBattle; +}