From 0ca0ad1c63e49605d3a9dd28e5c40bca96a85710 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Mon, 12 Feb 2018 15:42:15 +0530 Subject: Decompile birch_pc.c --- src/birch_pc.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 src/birch_pc.c (limited to 'src') 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)); +} -- cgit v1.2.3 From d52a54e64f73cb1e24e18da106ea9b69307b4509 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Mon, 12 Feb 2018 16:15:51 +0530 Subject: Updating pokedex count function labels --- src/birch_pc.c | 8 ++++---- src/menu.c | 28 ++++++++++++++-------------- src/tv.c | 4 ++-- 3 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/birch_pc.c b/src/birch_pc.c index bc8095592..4b0025504 100644 --- a/src/birch_pc.c +++ b/src/birch_pc.c @@ -34,13 +34,13 @@ bool16 ScriptGetPokedexInfo(void) { if (gSpecialVar_0x8004 == 0) // is national dex not present? { - gSpecialVar_0x8005 = sub_80C0844(0); - gSpecialVar_0x8006 = sub_80C0844(1); + gSpecialVar_0x8005 = GetHoennPokedexCount(0); + gSpecialVar_0x8006 = GetHoennPokedexCount(1); } else { - gSpecialVar_0x8005 = pokedex_count(0); - gSpecialVar_0x8006 = pokedex_count(1); + gSpecialVar_0x8005 = GetNationalPokedexCount(0); + gSpecialVar_0x8006 = GetNationalPokedexCount(1); } return IsNationalPokedexEnabled(); diff --git a/src/menu.c b/src/menu.c index d06f950d3..b20ab5164 100644 --- a/src/menu.c +++ b/src/menu.c @@ -63,7 +63,7 @@ static EWRAM_DATA void *gUnknown_0203CDAC[0x20] = {NULL}; const u16 gUnknown_0860F074[] = INCBIN_U16("graphics/interface/860F074.gbapal"); static const u8 gUnknown_0860F094[] = { 8, 4, 1 }; -static const struct WindowTemplate gUnknown_0860F098[] = +static const struct WindowTemplate gUnknown_0860F098[] = { { 0x00, 0x02, 0x0F, 0x1B, 0x04, 0x0F, 0x194 }, DUMMY_WIN_TEMPLATE @@ -76,7 +76,7 @@ static const struct WindowTemplate gUnknown_0860F0A8 = const u16 gUnknown_0860F0B0[] = INCBIN_U16("graphics/interface/860F0B0.gbapal"); const u8 gUnknown_0860F0D0[] = { 15, 1, 2 }; -const struct SomeUnkStruct_60F0D4 gUnknown_0860F0D4[] = +const struct SomeUnkStruct_60F0D4 gUnknown_0860F0D4[] = { { 12, 12, 0x00 }, { 32, 12, 0x20 }, @@ -151,7 +151,7 @@ u16 sub_8197224(void) u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8 fgColor, u8 bgColor, u8 shadowColor) { struct TextSubPrinter printer; - + printer.current_text_offset = str; printer.windowId = windowId; printer.fontId = fontId; @@ -165,9 +165,9 @@ u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 speed, printer.fgColor = fgColor; printer.bgColor = bgColor; printer.shadowColor = shadowColor; - + gTextFlags.flag_1 = 0; - return AddTextPrinter(&printer, speed, callback); + return AddTextPrinter(&printer, speed, callback); } void AddTextPrinterForMessage(bool8 allowSkippingDelayWithButtonPress) @@ -234,7 +234,7 @@ void sub_819746C(u8 windowId, bool8 copyToVram) void DrawStandardFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) { int i; - + FillBgTilemapBufferRect(bg, STD_WINDOW_BASE_TILE_NUM + 0, tilemapLeft - 1, @@ -256,7 +256,7 @@ void DrawStandardFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height 1, 1, STD_WINDOW_PALETTE_NUM); - + for (i = tilemapTop; i < tilemapTop + height; i++) { FillBgTilemapBufferRect(bg, @@ -274,7 +274,7 @@ void DrawStandardFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height 1, STD_WINDOW_PALETTE_NUM); } - + FillBgTilemapBufferRect(bg, STD_WINDOW_BASE_TILE_NUM + 6, tilemapLeft - 1, @@ -1941,7 +1941,7 @@ void box_print(u8 windowId, u8 fontId, u8 left, u8 top, const u8 *color, s8 spee printer.fgColor = color[1]; printer.bgColor = color[0]; printer.shadowColor = color[2]; - + AddTextPrinter(&printer, speed, NULL); } @@ -1962,7 +1962,7 @@ void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 left, u8 top, u8 le printer.fgColor = color[1]; printer.bgColor = color[0]; printer.shadowColor = color[2]; - + AddTextPrinter(&printer, speed, NULL); } @@ -2373,14 +2373,14 @@ void sub_819A344(u8 a0, u8 *a1, u8 a2) s32 flagCount; u8 *endOfString; u8 *string = a1; - + *(string++) = EXT_CTRL_CODE_BEGIN; *(string++) = EXT_CTRL_CODE_COLOR; *(string++) = a2; *(string++) = EXT_CTRL_CODE_BEGIN; *(string++) = EXT_CTRL_CODE_SHADOW; *(string++) = a2 + 1; - + switch (a0) { case 0: @@ -2388,9 +2388,9 @@ void sub_819A344(u8 a0, u8 *a1, u8 a2) break; case 1: if (IsNationalPokedexEnabled()) - string = ConvertIntToDecimalStringN(string, pokedex_count(1), 0, 3); + string = ConvertIntToDecimalStringN(string, GetNationalPokedexCount(1), 0, 3); else - string = ConvertIntToDecimalStringN(string, sub_80C0844(1), 0, 3); + string = ConvertIntToDecimalStringN(string, GetHoennPokedexCount(1), 0, 3); *string = EOS; break; case 2: diff --git a/src/tv.c b/src/tv.c index fbe39fde0..b0dbc0dbc 100644 --- a/src/tv.c +++ b/src/tv.c @@ -1957,11 +1957,11 @@ void sub_80EDB44(void) show->rivalTrainer.badgeCount = nBadges; if (IsNationalPokedexEnabled()) { - show->rivalTrainer.dexCount = pokedex_count(0x01); + show->rivalTrainer.dexCount = GetNationalPokedexCount(0x01); } else { - show->rivalTrainer.dexCount = sub_80C0844(0x01); + show->rivalTrainer.dexCount = GetHoennPokedexCount(0x01); } show->rivalTrainer.location = gMapHeader.regionMapSectionId; show->rivalTrainer.mapDataId = gMapHeader.mapDataId; -- cgit v1.2.3 From 54922641af2712a8108c327ee3ce104c41a10a52 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Mon, 12 Feb 2018 16:44:04 +0530 Subject: Port smokescreen.s --- src/smokescreen.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/smokescreen.c (limited to 'src') diff --git a/src/smokescreen.c b/src/smokescreen.c new file mode 100644 index 000000000..4b0e5d759 --- /dev/null +++ b/src/smokescreen.c @@ -0,0 +1,73 @@ +#include "global.h" +#include "data2.h" +#include "decompress.h" +#include "sprite.h" +#include "util.h" + + +static void sub_8075370(struct Sprite *); + + +u8 sub_807521C(s16 x, s16 y, u8 a3) +{ + u8 mainSpriteId; + u8 spriteId1, spriteId2, spriteId3, spriteId4; + struct Sprite *mainSprite; + + if (GetSpriteTileStartByTag(gUnknown_0831C620.tag) == 0xFFFF) + { + LoadCompressedObjectPicUsingHeap(&gUnknown_0831C620); + LoadCompressedObjectPaletteUsingHeap(&gUnknown_0831C628); + } + + mainSpriteId = CreateInvisibleSpriteWithCallback(sub_8075370); + mainSprite = &gSprites[mainSpriteId]; + mainSprite->data[1] = a3; + + spriteId1 = CreateSprite(&gUnknown_0831C688, x - 16, y - 16, 2); + gSprites[spriteId1].data[0] = mainSpriteId; + mainSprite->data[0]++; + AnimateSprite(&gSprites[spriteId1]); + + spriteId2 = CreateSprite(&gUnknown_0831C688, x, y - 16, 2); + gSprites[spriteId2].data[0] = mainSpriteId; + mainSprite->data[0]++; + StartSpriteAnim(&gSprites[spriteId2], 1); + AnimateSprite(&gSprites[spriteId2]); + + spriteId3 = CreateSprite(&gUnknown_0831C688, x - 16, y, 2); + gSprites[spriteId3].data[0] = mainSpriteId; + mainSprite->data[0]++; + StartSpriteAnim(&gSprites[spriteId3], 2); + AnimateSprite(&gSprites[spriteId3]); + + spriteId4 = CreateSprite(&gUnknown_0831C688, x, y, 2); + gSprites[spriteId4].data[0] = mainSpriteId; + mainSprite->data[0]++; + StartSpriteAnim(&gSprites[spriteId4], 3); + AnimateSprite(&gSprites[spriteId4]); + + return mainSpriteId; +} + +static void sub_8075370(struct Sprite *sprite) +{ + if (!sprite->data[0]) + { + FreeSpriteTilesByTag(gUnknown_0831C620.tag); + FreeSpritePaletteByTag(gUnknown_0831C628.tag); + if (!sprite->data[1]) + DestroySprite(sprite); + else + sprite->callback = SpriteCallbackDummy; + } +} + +void sub_80753B4(struct Sprite *sprite) +{ + if (sprite->animEnded) + { + gSprites[sprite->data[0]].data[0]--; + DestroySprite(sprite); + } +} -- cgit v1.2.3 From 7b360b2e338e4f2a008374a0114367dadf728484 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Tue, 13 Feb 2018 09:16:38 +0530 Subject: Review fixes --- src/birch_pc.c | 23 +---------------------- src/smokescreen.c | 2 -- 2 files changed, 1 insertion(+), 24 deletions(-) (limited to 'src') diff --git a/src/birch_pc.c b/src/birch_pc.c index 4b0025504..a682d15d9 100644 --- a/src/birch_pc.c +++ b/src/birch_pc.c @@ -3,33 +3,12 @@ #include "field_message_box.h" #include "pokedex.h" #include "constants/species.h" +#include "text.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? diff --git a/src/smokescreen.c b/src/smokescreen.c index 4b0e5d759..9b37cd234 100644 --- a/src/smokescreen.c +++ b/src/smokescreen.c @@ -4,10 +4,8 @@ #include "sprite.h" #include "util.h" - static void sub_8075370(struct Sprite *); - u8 sub_807521C(s16 x, s16 y, u8 a3) { u8 mainSpriteId; -- cgit v1.2.3 From ae321d6e7c99b557cafd594eb945e7ca1a566ba8 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Tue, 13 Feb 2018 09:32:40 +0530 Subject: move to strings.h --- src/birch_pc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/birch_pc.c b/src/birch_pc.c index a682d15d9..0f44824f7 100644 --- a/src/birch_pc.c +++ b/src/birch_pc.c @@ -3,7 +3,7 @@ #include "field_message_box.h" #include "pokedex.h" #include "constants/species.h" -#include "text.h" +#include "strings.h" extern u16 gSpecialVar_0x8004; extern u16 gSpecialVar_0x8005; -- cgit v1.2.3