From 0ca0ad1c63e49605d3a9dd28e5c40bca96a85710 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Mon, 12 Feb 2018 15:42:15 +0530 Subject: [PATCH] Decompile birch_pc.c --- asm/birch_pc.s | 234 ----------------------------------- data/battle_frontier_1.s | 42 +++---- data/text/pokedex_rating.inc | 42 +++---- ld_script.txt | 2 +- src/birch_pc.c | 114 +++++++++++++++++ 5 files changed, 157 insertions(+), 277 deletions(-) delete mode 100644 asm/birch_pc.s create mode 100644 src/birch_pc.c diff --git a/asm/birch_pc.s b/asm/birch_pc.s deleted file mode 100644 index 6665d9beb..000000000 --- a/asm/birch_pc.s +++ /dev/null @@ -1,234 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start ScriptGetPokedexInfo -ScriptGetPokedexInfo: @ 8137A4C - push {lr} - ldr r0, =gSpecialVar_0x8004 - ldrh r0, [r0] - cmp r0, 0 - bne _08137A70 - movs r0, 0 - bl sub_80C0844 - ldr r1, =gSpecialVar_0x8005 - strh r0, [r1] - movs r0, 0x1 - bl sub_80C0844 - b _08137A80 - .pool -_08137A70: - movs r0, 0 - bl pokedex_count - ldr r1, =gSpecialVar_0x8005 - strh r0, [r1] - movs r0, 0x1 - bl pokedex_count -_08137A80: - ldr r1, =gSpecialVar_0x8006 - strh r0, [r1] - bl IsNationalPokedexEnabled - lsls r0, 16 - lsrs r0, 16 - pop {r1} - bx r1 - .pool - thumb_func_end ScriptGetPokedexInfo - - thumb_func_start GetPokedexRatingText -GetPokedexRatingText: @ 8137A98 - push {lr} - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x9 - bhi _08137AA4 - b _08137BFC -_08137AA4: - cmp r0, 0x13 - bhi _08137AB0 - ldr r0, =gUnknown_082A5DAB - b _08137C06 - .pool -_08137AB0: - cmp r0, 0x1D - bhi _08137ABC - ldr r0, =gUnknown_082A5DF1 - b _08137C06 - .pool -_08137ABC: - cmp r0, 0x27 - bhi _08137AC8 - ldr r0, =gUnknown_082A5E34 - b _08137C06 - .pool -_08137AC8: - cmp r0, 0x31 - bhi _08137AD4 - ldr r0, =gUnknown_082A5E83 - b _08137C06 - .pool -_08137AD4: - cmp r0, 0x3B - bhi _08137AE0 - ldr r0, =gUnknown_082A5EB9 - b _08137C06 - .pool -_08137AE0: - cmp r0, 0x45 - bhi _08137AEC - ldr r0, =gUnknown_082A5EF4 - b _08137C06 - .pool -_08137AEC: - cmp r0, 0x4F - bhi _08137AF8 - ldr r0, =gUnknown_082A5F39 - b _08137C06 - .pool -_08137AF8: - cmp r0, 0x59 - bhi _08137B04 - ldr r0, =gUnknown_082A5F82 - b _08137C06 - .pool -_08137B04: - cmp r0, 0x63 - bhi _08137B10 - ldr r0, =gUnknown_082A5FB9 - b _08137C06 - .pool -_08137B10: - cmp r0, 0x6D - bhi _08137B1C - ldr r0, =gUnknown_082A6018 - b _08137C06 - .pool -_08137B1C: - cmp r0, 0x77 - bhi _08137B28 - ldr r0, =gUnknown_082A6061 - b _08137C06 - .pool -_08137B28: - cmp r0, 0x81 - bhi _08137B34 - ldr r0, =gUnknown_082A609C - b _08137C06 - .pool -_08137B34: - cmp r0, 0x8B - bhi _08137B40 - ldr r0, =gUnknown_082A60D5 - b _08137C06 - .pool -_08137B40: - cmp r0, 0x95 - bhi _08137B4C - ldr r0, =gUnknown_082A6124 - b _08137C06 - .pool -_08137B4C: - cmp r0, 0x9F - bhi _08137B58 - ldr r0, =gUnknown_082A616F - b _08137C06 - .pool -_08137B58: - cmp r0, 0xA9 - bhi _08137B64 - ldr r0, =gUnknown_082A61D6 - b _08137C06 - .pool -_08137B64: - cmp r0, 0xB3 - bhi _08137B70 - ldr r0, =gUnknown_082A623A - b _08137C06 - .pool -_08137B70: - cmp r0, 0xBD - bhi _08137B7C - ldr r0, =gUnknown_082A6287 - b _08137C06 - .pool -_08137B7C: - cmp r0, 0xC7 - bls _08137BEA - cmp r0, 0xC8 - bne _08137BB8 - ldr r0, =0x00000199 - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - bl GetSetPokedexFlag - lsls r0, 24 - cmp r0, 0 - bne _08137BEA - movs r0, 0xCD - lsls r0, 1 - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - bl GetSetPokedexFlag - lsls r0, 24 - cmp r0, 0 - bne _08137BEA - b _08137C04 - .pool -_08137BB8: - cmp r0, 0xC9 - bne _08137BF8 - ldr r0, =0x00000199 - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - bl GetSetPokedexFlag - lsls r0, 24 - cmp r0, 0 - beq _08137C04 - movs r0, 0xCD - lsls r0, 1 - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - bl GetSetPokedexFlag - lsls r0, 24 - cmp r0, 0 - beq _08137C04 -_08137BEA: - ldr r0, =gUnknown_082A62C9 - b _08137C06 - .pool -_08137BF8: - cmp r0, 0xCA - beq _08137C04 -_08137BFC: - ldr r0, =gUnknown_082A5D6C - b _08137C06 - .pool -_08137C04: - ldr r0, =gUnknown_082A6312 -_08137C06: - pop {r1} - bx r1 - .pool - thumb_func_end GetPokedexRatingText - - thumb_func_start ShowPokedexRatingMessage -ShowPokedexRatingMessage: @ 8137C10 - push {lr} - ldr r0, =gSpecialVar_0x8004 - ldrh r0, [r0] - bl GetPokedexRatingText - bl ShowFieldMessage - pop {r0} - bx r0 - .pool - thumb_func_end ShowPokedexRatingMessage diff --git a/data/battle_frontier_1.s b/data/battle_frontier_1.s index 34e8df6d2..e2eb99505 100644 --- a/data/battle_frontier_1.s +++ b/data/battle_frontier_1.s @@ -1872,24 +1872,24 @@ gUnknown_0860F010:: @ 860F010 .2byte FLAG_BADGE08_GET gUnknown_0860F020:: @ 860F020 - .4byte gUnknown_082A5D6C - .4byte gUnknown_082A5DAB - .4byte gUnknown_082A5DF1 - .4byte gUnknown_082A5E34 - .4byte gUnknown_082A5E83 - .4byte gUnknown_082A5EB9 - .4byte gUnknown_082A5EF4 - .4byte gUnknown_082A5F39 - .4byte gUnknown_082A5F82 - .4byte gUnknown_082A5FB9 - .4byte gUnknown_082A6018 - .4byte gUnknown_082A6061 - .4byte gUnknown_082A609C - .4byte gUnknown_082A60D5 - .4byte gUnknown_082A6124 - .4byte gUnknown_082A616F - .4byte gUnknown_082A61D6 - .4byte gUnknown_082A623A - .4byte gUnknown_082A6287 - .4byte gUnknown_082A62C9 - .4byte gUnknown_082A6312 + .4byte gBirchDexRatingText_LessThan10 + .4byte gBirchDexRatingText_LessThan20 + .4byte gBirchDexRatingText_LessThan30 + .4byte gBirchDexRatingText_LessThan40 + .4byte gBirchDexRatingText_LessThan50 + .4byte gBirchDexRatingText_LessThan60 + .4byte gBirchDexRatingText_LessThan70 + .4byte gBirchDexRatingText_LessThan80 + .4byte gBirchDexRatingText_LessThan90 + .4byte gBirchDexRatingText_LessThan100 + .4byte gBirchDexRatingText_LessThan110 + .4byte gBirchDexRatingText_LessThan120 + .4byte gBirchDexRatingText_LessThan130 + .4byte gBirchDexRatingText_LessThan140 + .4byte gBirchDexRatingText_LessThan150 + .4byte gBirchDexRatingText_LessThan160 + .4byte gBirchDexRatingText_LessThan170 + .4byte gBirchDexRatingText_LessThan180 + .4byte gBirchDexRatingText_LessThan190 + .4byte gBirchDexRatingText_LessThan200 + .4byte gBirchDexRatingText_DexCompleted diff --git a/data/text/pokedex_rating.inc b/data/text/pokedex_rating.inc index 735488b37..666c90867 100644 --- a/data/text/pokedex_rating.inc +++ b/data/text/pokedex_rating.inc @@ -12,99 +12,99 @@ gUnknown_082A5D2C:: @ 82A5D2C .string "So, you’ve seen {STR_VAR_1} POKéMON,\n" .string "and you’ve caught {STR_VAR_2} POKéMON…$" -gUnknown_082A5D6C:: @ 82A5D6C +gBirchDexRatingText_LessThan10:: @ 82A5D6C .string "Go into grassy areas more and look\n" .string "for POKéMON more carefully.$" -gUnknown_082A5DAB:: @ 82A5DAB +gBirchDexRatingText_LessThan20:: @ 82A5DAB .string "I guess you’re getting the hang\n" .string "of it. But, it gets harder from here.$" -gUnknown_082A5DF1:: @ 82A5DF1 +gBirchDexRatingText_LessThan30:: @ 82A5DF1 .string "Some POKéMON only appear in\n" .string "certain areas.\l" .string "You must be persistent.$" -gUnknown_082A5E34:: @ 82A5E34 +gBirchDexRatingText_LessThan40:: @ 82A5E34 .string "Well, it could use more quantity,\n" .string "but this is looking more like\l" .string "a POKéDEX now.$" -gUnknown_082A5E83:: @ 82A5E83 +gBirchDexRatingText_LessThan50:: @ 82A5E83 .string "This is coming along pretty good.\n" .string "Keep up the effort.$" -gUnknown_082A5EB9:: @ 82A5EB9 +gBirchDexRatingText_LessThan60:: @ 82A5EB9 .string "Are you using any RODS?\n" .string "There are many POKéMON in the sea.$" -gUnknown_082A5EF4:: @ 82A5EF4 +gBirchDexRatingText_LessThan70:: @ 82A5EF4 .string "Instead of just catching POKéMON,\n" .string "how about making them evolve, too?$" -gUnknown_082A5F39:: @ 82A5F39 +gBirchDexRatingText_LessThan80:: @ 82A5F39 .string "This is going to be a fantastic\n" .string "POKéDEX.\l" .string "That’s the feeling I’m getting.$" -gUnknown_082A5F82:: @ 82A5F82 +gBirchDexRatingText_LessThan90:: @ 82A5F82 .string "You’ve collected this many…\n" .string "Your talent is remarkable!$" -gUnknown_082A5FB9:: @ 82A5FB9 +gBirchDexRatingText_LessThan100:: @ 82A5FB9 .string "Have you visited the SAFARI ZONE?\p" .string "I hear there are some POKéMON that\n" .string "can only be caught there.$" -gUnknown_082A6018:: @ 82A6018 +gBirchDexRatingText_LessThan110:: @ 82A6018 .string "You’ve finally reached\n" .string "the 100-kind mark.\p" .string "This is an impressive POKéDEX!$" -gUnknown_082A6061:: @ 82A6061 +gBirchDexRatingText_LessThan120:: @ 82A6061 .string "There might be POKéMON that can be\n" .string "found using ROCK SMASH.$" -gUnknown_082A609C:: @ 82A609C +gBirchDexRatingText_LessThan130:: @ 82A609C .string "You should get some more POKéMON\n" .string "by trading with others.$" -gUnknown_082A60D5:: @ 82A60D5 +gBirchDexRatingText_LessThan140:: @ 82A60D5 .string "I’ve heard of POKéMON that evolve\n" .string "when they come to fully love their\l" .string "TRAINERS.$" -gUnknown_082A6124:: @ 82A6124 +gBirchDexRatingText_LessThan150:: @ 82A6124 .string "I had no idea that there were so\n" .string "many POKéMON species in the HOENN\l" .string "region.$" -gUnknown_082A616F:: @ 82A616F +gBirchDexRatingText_LessThan160:: @ 82A616F .string "On occasion, some POKéMON appear\n" .string "in large numbers like outbreaks.\p" .string "Don’t miss opportunities like\n" .string "those.$" -gUnknown_082A61D6:: @ 82A61D6 +gBirchDexRatingText_LessThan170:: @ 82A61D6 .string "One can get a very good idea about\n" .string "the POKéMON of the HOENN region\l" .string "by looking through your POKéDEX.$" -gUnknown_082A623A:: @ 82A623A +gBirchDexRatingText_LessThan180:: @ 82A623A .string "I would say you already qualify as\n" .string "a POKéMON PROFESSOR, and a good\l" .string "one, too!$" -gUnknown_082A6287:: @ 82A6287 +gBirchDexRatingText_LessThan190:: @ 82A6287 .string "With a POKéDEX this complete,\n" .string "you’re a real professional at this!$" -gUnknown_082A62C9:: @ 82A62C9 +gBirchDexRatingText_LessThan200:: @ 82A62C9 .string "You’re very close to completing\n" .string "this POKéDEX.\l" .string "I can feel it in my bones!$" -gUnknown_082A6312:: @ 82A6312 +gBirchDexRatingText_DexCompleted:: @ 82A6312 .string "Congratulations!\n" .string "Your POKéDEX is complete!$" diff --git a/ld_script.txt b/ld_script.txt index 81911e574..bf52fc49f 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -183,7 +183,7 @@ SECTIONS { asm/fldeff_flash.o(.text); asm/post_battle_event_funcs.o(.text); src/time_events.o(.text); - asm/birch_pc.o(.text); + src/birch_pc.o(.text); src/hof_pc.o(.text); asm/field_specials.o(.text); asm/battle_records.o(.text); diff --git a/src/birch_pc.c b/src/birch_pc.c new file mode 100644 index 000000000..bc8095592 --- /dev/null +++ b/src/birch_pc.c @@ -0,0 +1,114 @@ +#include "global.h" +#include "event_data.h" +#include "field_message_box.h" +#include "pokedex.h" +#include "constants/species.h" + +extern u16 gSpecialVar_0x8004; +extern u16 gSpecialVar_0x8005; +extern u16 gSpecialVar_0x8006; + +extern const u8 gBirchDexRatingText_LessThan10[]; +extern const u8 gBirchDexRatingText_LessThan20[]; +extern const u8 gBirchDexRatingText_LessThan30[]; +extern const u8 gBirchDexRatingText_LessThan40[]; +extern const u8 gBirchDexRatingText_LessThan50[]; +extern const u8 gBirchDexRatingText_LessThan60[]; +extern const u8 gBirchDexRatingText_LessThan70[]; +extern const u8 gBirchDexRatingText_LessThan80[]; +extern const u8 gBirchDexRatingText_LessThan90[]; +extern const u8 gBirchDexRatingText_LessThan100[]; +extern const u8 gBirchDexRatingText_LessThan110[]; +extern const u8 gBirchDexRatingText_LessThan120[]; +extern const u8 gBirchDexRatingText_LessThan130[]; +extern const u8 gBirchDexRatingText_LessThan140[]; +extern const u8 gBirchDexRatingText_LessThan150[]; +extern const u8 gBirchDexRatingText_LessThan160[]; +extern const u8 gBirchDexRatingText_LessThan170[]; +extern const u8 gBirchDexRatingText_LessThan180[]; +extern const u8 gBirchDexRatingText_LessThan190[]; +extern const u8 gBirchDexRatingText_LessThan200[]; +extern const u8 gBirchDexRatingText_DexCompleted[]; + +bool16 ScriptGetPokedexInfo(void) +{ + if (gSpecialVar_0x8004 == 0) // is national dex not present? + { + gSpecialVar_0x8005 = sub_80C0844(0); + gSpecialVar_0x8006 = sub_80C0844(1); + } + else + { + gSpecialVar_0x8005 = pokedex_count(0); + gSpecialVar_0x8006 = pokedex_count(1); + } + + return IsNationalPokedexEnabled(); +} + +// This shows your Hoenn Pokedex rating and not your National Dex. +const u8 *GetPokedexRatingText(u16 count) +{ + if (count < 10) + return gBirchDexRatingText_LessThan10; + if (count < 20) + return gBirchDexRatingText_LessThan20; + if (count < 30) + return gBirchDexRatingText_LessThan30; + if (count < 40) + return gBirchDexRatingText_LessThan40; + if (count < 50) + return gBirchDexRatingText_LessThan50; + if (count < 60) + return gBirchDexRatingText_LessThan60; + if (count < 70) + return gBirchDexRatingText_LessThan70; + if (count < 80) + return gBirchDexRatingText_LessThan80; + if (count < 90) + return gBirchDexRatingText_LessThan90; + if (count < 100) + return gBirchDexRatingText_LessThan100; + if (count < 110) + return gBirchDexRatingText_LessThan110; + if (count < 120) + return gBirchDexRatingText_LessThan120; + if (count < 130) + return gBirchDexRatingText_LessThan130; + if (count < 140) + return gBirchDexRatingText_LessThan140; + if (count < 150) + return gBirchDexRatingText_LessThan150; + if (count < 160) + return gBirchDexRatingText_LessThan160; + if (count < 170) + return gBirchDexRatingText_LessThan170; + if (count < 180) + return gBirchDexRatingText_LessThan180; + if (count < 190) + return gBirchDexRatingText_LessThan190; + if (count < 200) + return gBirchDexRatingText_LessThan200; + if (count == 200) + { + if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_JIRACHI), 1) + || GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), 1)) // Jirachi or Deoxys is not counted towards the dex completion. If either of these flags are enabled, it means the actual count is less than 200. + return gBirchDexRatingText_LessThan200; + return gBirchDexRatingText_DexCompleted; + } + if (count == 201) + { + if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_JIRACHI), 1) + && GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), 1)) // If both of these flags are enabled, it means the actual count is less than 200. + return gBirchDexRatingText_LessThan200; + return gBirchDexRatingText_DexCompleted; + } + if (count == 202) + return gBirchDexRatingText_DexCompleted; // Hoenn dex is considered complete, even though the hoenn dex count is 210. + return gBirchDexRatingText_LessThan10; +} + +void ShowPokedexRatingMessage(void) +{ + ShowFieldMessage(GetPokedexRatingText(gSpecialVar_0x8004)); +}