summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorProjectRevoTPP <projectrevotpp@hotmail.com>2018-01-17 00:29:25 -0500
committerProjectRevoTPP <projectrevotpp@hotmail.com>2018-01-17 00:29:25 -0500
commit3ab6bf09d8d6bb86e83033e8a7138d02e3917c55 (patch)
tree8e9950e0402d82818932b12320723b4ee6b9b401
parent31a322fdc589c381af6ec4b4c4781d28cb394cc1 (diff)
split out crash.c
-rw-r--r--include/matsuda_debug_menu.h1
-rw-r--r--include/pokedex.h2
-rw-r--r--ld_script.txt1
-rw-r--r--src/battle/battle_party_menu.c6
-rw-r--r--src/debug/crash.c55
-rw-r--r--src/debug/matsuda_debug_menu.c62
-rw-r--r--src/field/diploma.c2
-rw-r--r--src/field/item_use.c22
-rw-r--r--src/field/money.c2
-rw-r--r--src/pokemon/pokedex.c83
-rw-r--r--src/pokemon/pokemon_menu.c6
-rw-r--r--sym_common.txt2
12 files changed, 157 insertions, 87 deletions
diff --git a/include/matsuda_debug_menu.h b/include/matsuda_debug_menu.h
index 60f2dc48c..ad877a014 100644
--- a/include/matsuda_debug_menu.h
+++ b/include/matsuda_debug_menu.h
@@ -3,7 +3,6 @@
#define BIT(n) (1 << (n))
-void sub_80AB184(void);
void sub_80AA280(u8);
void sub_80AA5E8(u8);
void sub_80AA658(u8);
diff --git a/include/pokedex.h b/include/pokedex.h
index d8416889a..73877bead 100644
--- a/include/pokedex.h
+++ b/include/pokedex.h
@@ -23,6 +23,6 @@ s8 GetSetPokedexFlag(u16, u8);
u16 GetNationalPokedexCount(u8);
u16 GetHoennPokedexCount(u8);
bool8 CompletedHoennPokedex(void);
-u16 sub_8090FF4(void);
+bool16 CompletedNationalPokedex(void);
#endif // GUARD_POKEDEX_H
diff --git a/ld_script.txt b/ld_script.txt
index 3be3a6e56..82ba46b9c 100644
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -141,6 +141,7 @@ SECTIONS {
src/battle/battle_anim_80A7E7C.o(.text);
src/field/item.o(.text);
src/debug/matsuda_debug_menu.o(.text);
+ src/debug/crash.o(.text);
src/contest.o(.text);
src/field/shop.o(.text);
src/field/fldeff_escalator.o(.text);
diff --git a/src/battle/battle_party_menu.c b/src/battle/battle_party_menu.c
index 68a97c536..ed8cf4583 100644
--- a/src/battle/battle_party_menu.c
+++ b/src/battle/battle_party_menu.c
@@ -40,7 +40,7 @@ extern u8 gUnknown_0202E8F6;
extern u8 gUnknown_02038470[3];
extern u8 gUnknown_02038473;
extern u8 gUnknown_020384F0;
-extern void (*gUnknown_03004AE4)(); //don't know types yet
+extern void (*gPokemonItemUseCallback)(); //don't know types yet
extern struct PokemonStorage gPokemonStorage;
extern void nullsub_14();
@@ -466,7 +466,7 @@ void HandleBattlePartyMenu(u8 taskId)
{
if (gUnknown_02038473 == 3 && GetItemEffectType(gSpecialVar_ItemId) == 10)
{
- gUnknown_03004AE4(taskId, gSpecialVar_ItemId, Task_80952E4);
+ gPokemonItemUseCallback(taskId, gSpecialVar_ItemId, Task_80952E4);
return;
}
@@ -480,7 +480,7 @@ void HandleBattlePartyMenu(u8 taskId)
else
{
sub_806D5A4();
- gUnknown_03004AE4(taskId, gSpecialVar_ItemId, Task_80952E4);
+ gPokemonItemUseCallback(taskId, gSpecialVar_ItemId, Task_80952E4);
}
}
else
diff --git a/src/debug/crash.c b/src/debug/crash.c
new file mode 100644
index 000000000..702dbc32a
--- /dev/null
+++ b/src/debug/crash.c
@@ -0,0 +1,55 @@
+#include "global.h"
+#include "main.h"
+#include "task.h"
+#include "text.h"
+#include "palette.h"
+
+extern struct Window gUnknown_03004210;
+
+static void CB2_CrashIdle(void);
+
+// unused exception handler. Takes a string input describing the exception
+// and halts on a black screen. Used in German Debug Ruby.
+void Crash(u8 *text)
+{
+ u16 savedIme;
+
+ REG_BG0HOFS = 0;
+ REG_BG0VOFS = 0;
+ REG_BG1HOFS = 0;
+ REG_BG1VOFS = 0;
+ REG_BG2HOFS = 0;
+ REG_BG2VOFS = 0;
+ REG_BG3HOFS = 0;
+ REG_BG3VOFS = 0;
+ REG_WIN0H = 0;
+ REG_WIN0V = 0;
+ REG_WIN1H = 0;
+ REG_WIN1V = 0;
+ REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON;
+ savedIme = REG_IME;
+ REG_IME = 0;
+ REG_IE |= INTR_FLAG_VBLANK;
+ REG_IME = savedIme;
+ REG_DISPSTAT = 8;
+ ResetTasks();
+ ResetSpriteData();
+ SetMainCallback2(CB2_CrashIdle);
+ DmaFill32Large(3, 0, (void *)VRAM, 0x18000, 0x1000);
+ Text_LoadWindowTemplate(&gWindowTemplate_81E6FD8);
+ Text_InitWindowWithTemplate(&gUnknown_03004210, &gWindowTemplate_81E6FD8);
+ LoadFontDefaultPalette(&gWindowTemplate_81E6FD8);
+ Text_InitWindowAndPrintText(&gUnknown_03004210, text, 1, 9, 7);
+}
+
+static void CB2_CrashIdle(void)
+{
+ REG_BG0HOFS = 0;
+ REG_BG0VOFS = 0;
+ REG_BG1HOFS = 0;
+ REG_BG1VOFS = 0;
+ REG_BG2HOFS = 0;
+ REG_BG2VOFS = 0;
+ REG_BG3HOFS = 0;
+ REG_BG3VOFS = 0;
+}
diff --git a/src/debug/matsuda_debug_menu.c b/src/debug/matsuda_debug_menu.c
index 1da337b04..b879584dd 100644
--- a/src/debug/matsuda_debug_menu.c
+++ b/src/debug/matsuda_debug_menu.c
@@ -37,7 +37,7 @@ extern u16 gBattle_BG2_X;
extern u16 gBattle_BG2_Y;
extern u16 gBattle_BG3_X;
extern u16 gBattle_BG3_Y;
-extern struct Window gUnknown_03004210;
+
extern u8 (*gCallback_03004AE8)(void);
extern bool8 gReceivedRemoteLinkPlayers;
@@ -1032,63 +1032,3 @@ u8 MatsudaDebugMenu_SetArtMuseumItems(void)
CloseMenu();
return 1;
}
-
-void unref_sub_80AB084(u8 *text)
-{
- u16 savedIme;
- u8 *addr;
- size_t size;
-
- REG_BG0HOFS = 0;
- REG_BG0VOFS = 0;
- REG_BG1HOFS = 0;
- REG_BG1VOFS = 0;
- REG_BG2HOFS = 0;
- REG_BG2VOFS = 0;
- REG_BG3HOFS = 0;
- REG_BG3VOFS = 0;
- REG_WIN0H = 0;
- REG_WIN0V = 0;
- REG_WIN1H = 0;
- REG_WIN1V = 0;
- REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON;
-
- savedIme = REG_IME;
- REG_IME = 0;
- REG_IE |= INTR_FLAG_VBLANK;
- REG_IME = savedIme;
- REG_DISPSTAT = 8;
- ResetTasks();
- ResetSpriteData();
- SetMainCallback2(sub_80AB184);
-
- addr = (void *)VRAM;
- size = 0x18000;
- while (1)
- {
- DmaFill32(3, 0, addr, 0x1000);
- addr += 0x1000;
- size -= 0x1000;
- if (size <= 0x1000)
- {
- DmaFill32(3, 0, addr, size);
- break;
- }
- }
- Text_LoadWindowTemplate(&gWindowTemplate_81E6FD8);
- Text_InitWindowWithTemplate(&gUnknown_03004210, &gWindowTemplate_81E6FD8);
- LoadFontDefaultPalette(&gWindowTemplate_81E6FD8);
- Text_InitWindowAndPrintText(&gUnknown_03004210, text, 1, 9, 7);
-}
-
-void sub_80AB184(void)
-{
- REG_BG0HOFS = 0;
- REG_BG0VOFS = 0;
- REG_BG1HOFS = 0;
- REG_BG1VOFS = 0;
- REG_BG2HOFS = 0;
- REG_BG2VOFS = 0;
- REG_BG3HOFS = 0;
- REG_BG3VOFS = 0;
-}
diff --git a/src/field/diploma.c b/src/field/diploma.c
index 978eca7eb..b31fc7dec 100644
--- a/src/field/diploma.c
+++ b/src/field/diploma.c
@@ -125,7 +125,7 @@ static void Task_DiplomaFadeOut(u8 taskId)
static void DisplayDiplomaText(void)
{
- if (sub_8090FF4())
+ if (CompletedNationalPokedex())
{
REG_BG3HOFS = 256;
StringCopy(gStringVar1, gOtherText_NationalDex);
diff --git a/src/field/item_use.c b/src/field/item_use.c
index 9346cf42e..cdad3f840 100644
--- a/src/field/item_use.c
+++ b/src/field/item_use.c
@@ -40,7 +40,7 @@
extern void (*gFieldItemUseCallback)(u8);
extern void (*gFieldCallback)(void);
extern void (*gUnknown_0300485C)(void);
-extern void (*gUnknown_03004AE4)(u8, u16, TaskFunc);
+extern void (*gPokemonItemUseCallback)(u8, u16, TaskFunc);
extern u8 gUnknown_02038561;
extern u8 gLastFieldPokeMenuOpened;
@@ -832,7 +832,7 @@ void sub_80C9D98(u8 taskId)
void ItemUseOutOfBattle_Medicine(u8 taskId)
{
- gUnknown_03004AE4 = UseMedicine;
+ gPokemonItemUseCallback = UseMedicine;
sub_80C9D98(taskId);
}
@@ -850,26 +850,26 @@ void ItemUseOutOfBattle_SacredAsh(u8 taskId)
break;
}
}
- gUnknown_03004AE4 = sub_8070048;
+ gPokemonItemUseCallback = sub_8070048;
gUnknown_02038561 = 4;
ItemMenu_ConfirmNormalFade(taskId);
}
void ItemUseOutOfBattle_PPRecovery(u8 taskId)
{
- gUnknown_03004AE4 = DoPPRecoveryItemEffect;
+ gPokemonItemUseCallback = DoPPRecoveryItemEffect;
sub_80C9D98(taskId);
}
void ItemUseOutOfBattle_PPUp(u8 taskId)
{
- gUnknown_03004AE4 = DoPPUpItemEffect;
+ gPokemonItemUseCallback = DoPPUpItemEffect;
sub_80C9D98(taskId);
}
void ItemUseOutOfBattle_RareCandy(u8 taskId)
{
- gUnknown_03004AE4 = DoRareCandyItemEffect;
+ gPokemonItemUseCallback = DoRareCandyItemEffect;
sub_80C9D98(taskId);
}
@@ -908,7 +908,7 @@ void sub_80C9F80(u8 var)
void sub_80C9FC0(u8 var)
{
- gUnknown_03004AE4 = TeachMonTMMove;
+ gPokemonItemUseCallback = TeachMonTMMove;
sub_80C9D98(var);
}
@@ -1009,7 +1009,7 @@ void ItemUseOutOfBattle_EscapeRope(u8 taskId)
void ItemUseOutOfBattle_EvolutionStone(u8 var)
{
- gUnknown_03004AE4 = DoEvolutionStoneItemEffect;
+ gPokemonItemUseCallback = DoEvolutionStoneItemEffect;
sub_80C9D98(var);
}
@@ -1078,19 +1078,19 @@ void sub_80CA3C0(u8 taskId)
void ItemUseInBattle_Medicine(u8 var)
{
- gUnknown_03004AE4 = UseMedicine;
+ gPokemonItemUseCallback = UseMedicine;
sub_80CA3C0(var);
}
void unref_sub_80CA410(u8 var)
{
- gUnknown_03004AE4 = sub_8070048;
+ gPokemonItemUseCallback = sub_8070048;
sub_80CA3C0(var);
}
void ItemUseInBattle_PPRecovery(u8 var)
{
- gUnknown_03004AE4 = DoPPRecoveryItemEffect;
+ gPokemonItemUseCallback = DoPPRecoveryItemEffect;
sub_80CA3C0(var);
}
diff --git a/src/field/money.c b/src/field/money.c
index 6cd73f600..3b7268dbc 100644
--- a/src/field/money.c
+++ b/src/field/money.c
@@ -100,6 +100,8 @@ void GetMoneyAmountText(u8 *buffer, u32 amount, u8 arg2)
width = 7;
else if (amount > 99999)
width = 6;
+ // A special sprite is used for 10000 in the decoration
+ // shop, so be sure to account for this.
else if (amount > 10000)
width = 5;
else if (amount > 999)
diff --git a/src/pokemon/pokedex.c b/src/pokemon/pokedex.c
index 4fb6a4920..bdd136ff5 100644
--- a/src/pokemon/pokedex.c
+++ b/src/pokemon/pokedex.c
@@ -4121,28 +4121,101 @@ bool8 CompletedHoennPokedex(void)
return TRUE;
}
-u16 sub_8090FF4(void)
+bool16 CompletedNationalPokedex(void)
{
u16 i;
+ // BUG: This function indexes pokemon checks by 0, but adds
+ // 1 before passing to GetSetPokedexFlag. Normally, this is
+ // fine, because GetSetPokedexFlag subtracts by 1 to get the
+ // array index value, but since the array is 0 indexed
+ // starting with Bulbasaur, values passed actually means that
+ // dex entries 152 (Chikorita) and 252 (Treecko) are skipped.
+ // Because an earlier Hoenn Dex check prevented Treecko from
+ // being skippable, it means that Chikorita is not required
+ // to obtain the National Diploma. This was fixed in Emerald.
for (i = 0; i < 150; i++)
{
if (GetSetPokedexFlag(i + 1, 1) == 0)
- return 0;
+ return FALSE;
}
for (i = 152; i < 250; i++)
{
if (GetSetPokedexFlag(i + 1, 1) == 0)
- return 0;
+ return FALSE;
}
for (i = 252; i < 384; i++)
{
if (GetSetPokedexFlag(i + 1, 1) == 0)
- return 0;
+ return FALSE;
}
- return 1;
+ return TRUE;
}
+/*
+CompletedNationalPokedex:
+ push {r4, r5, lr}
+ mov r0, #0x0
+.L1236:
+ add r0, r0, #0x1
+ lsl r0, r0, #0x10
+ lsr r4, r0, #0x10
+ add r0, r4, #0
+ mov r1, #0x1
+ bl GetSetPokedexFlag
+ lsl r0, r0, #0x18
+ cmp r0, #0
+ beq .L1252 @cond_branch
+ add r0, r4, #0
+ cmp r0, #0x95
+ bls .L1236 @cond_branch
+ mov r0, #0x98
+.L1242:
+ add r0, r0, #0x1
+ lsl r0, r0, #0x10
+ lsr r4, r0, #0x10
+ add r0, r4, #0
+ mov r1, #0x1
+ bl GetSetPokedexFlag
+ lsl r0, r0, #0x18
+ cmp r0, #0
+ beq .L1252 @cond_branch
+ add r0, r4, #0
+ cmp r0, #0xf9
+ bls .L1242 @cond_branch
+ mov r0, #0xfc
+ ldr r5, .L1253
+.L1248:
+ add r0, r0, #0x1
+ lsl r0, r0, #0x10
+ lsr r4, r0, #0x10
+ add r0, r4, #0
+ mov r1, #0x1
+ bl GetSetPokedexFlag
+ lsl r0, r0, #0x18
+ cmp r0, #0
+ bne .L1247 @cond_branch
+.L1252:
+ mov r0, #0x0
+ b .L1251
+.L1254:
+ .align 2, 0
+.L1253:
+ .word 0x17f
+.L1247:
+ add r0, r4, #0
+ cmp r0, r5
+ bls .L1248 @cond_branch
+ mov r0, #0x1
+.L1251:
+ pop {r4, r5}
+ pop {r1}
+ bx r1
+.Lfe84:
+ .size CompletedNationalPokedex,.Lfe84-CompletedNationalPokedex
+ .align 2, 0
+*/
+
static void sub_8091060(u16 a)
{
if (!(a & 0x100))
diff --git a/src/pokemon/pokemon_menu.c b/src/pokemon/pokemon_menu.c
index 70234ac48..a41e197f2 100644
--- a/src/pokemon/pokemon_menu.c
+++ b/src/pokemon/pokemon_menu.c
@@ -51,7 +51,7 @@ extern u8 gUnknown_0202E8F5;
extern u8 gUnknown_0202E8F6;
extern u8 gUnknown_02038561;
extern u16 gUnknown_0202E8F8;
-extern void (*gUnknown_03004AE4)(u8 taskID, u16 itemID, TaskFunc func);
+extern void (*gPokemonItemUseCallback)(u8 taskID, u16 itemID, TaskFunc func);
extern TaskFunc gUnknown_03005CF0;
void sub_808A520(void);
@@ -1013,7 +1013,7 @@ void sub_808B0C0(u8 taskID)
{
sub_806D5A4();
if (gUnknown_02038561 == 0)
- gUnknown_03004AE4(taskID, gSpecialVar_ItemId, sub_808B224);
+ gPokemonItemUseCallback(taskID, gSpecialVar_ItemId, sub_808B224);
if (gUnknown_02038561 == 1)
{
PlaySE(SE_SELECT);
@@ -1042,7 +1042,7 @@ void sub_808B0C0(u8 taskID)
static void sub_808B1EC(u8 taskID)
{
if (!gPaletteFade.active)
- gUnknown_03004AE4(taskID, gSpecialVar_ItemId, sub_808B224);
+ gPokemonItemUseCallback(taskID, gSpecialVar_ItemId, sub_808B224);
}
static void sub_808B224(u8 taskID)
diff --git a/sym_common.txt b/sym_common.txt
index cfb1b6b13..a37aa05ff 100644
--- a/sym_common.txt
+++ b/sym_common.txt
@@ -127,7 +127,7 @@ gUnknown_03004828: @ 3004828
@ party_menu?
.align 2
-gUnknown_03004AE4: @ 3004AE4
+gPokemonItemUseCallback: @ 3004AE4
.space 0x4
.include "field/start_menu.o"