minor code cleanup

This commit is contained in:
Seth Barberee 2021-07-12 17:50:19 -05:00
parent da7b30612f
commit a65d358927
6 changed files with 751 additions and 770 deletions

View File

@ -1,39 +1,39 @@
# Pokémon Mystery Dungeon: Red Rescue Team
[![build](https://github.com/pret/pmd-red/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/pret/pmd-red/actions/workflows/build.yml)
This is a disassembly of Pokémon Mystery Dungeon: Red Rescue Team.
It builds the following rom:
* pmd_red.gba `sha1: 9f4cfc5b5f4859d17169a485462e977c7aac2b89`
To set up the repository, see [INSTALL.md](INSTALL.md).
## See also
* Disassembly of [**Pokémon Red/Blue**][pokered]
* Disassembly of [**Pokémon Yellow**][pokeyellow]
* Disassembly of [**Pokémon Gold**][pokegold]
* Disassembly of [**Pokémon Crystal**][pokecrystal]
* Disassembly of [**Pokémon Pinball**][pokepinball]
* Disassembly of [**Pokémon TCG**][poketcg]
* Disassembly of [**Pokémon Fire Red**/**Leaf Green**][pokefirered]
* Disassembly of [**Pokémon Ruby/Sapphire**][pokeruby]
* Disassembly of [**Pokémon Emerald**][pokeemerald]
* Disassembly of [**Pokémon Diamond/Pearl**][pokediamond]
* Discord: [**pret**][Discord]
* irc: **irc.freenode.net** [**#pret**][irc]
[pokered]: https://github.com/pret/pokered
[pokeyellow]: https://github.com/pret/pokeyellow
[pokegold]: https://github.com/pret/pokegold
[pokecrystal]: https://github.com/pret/pokecrystal
[pokepinball]: https://github.com/pret/pokepinball
[poketcg]: https://github.com/pret/poketcg
[pokefirered]: https://github.com/pret/pokefirered
[pokeruby]: https://github.com/pret/pokeruby
[pokeemerald]: https://github.com/pret/pokeemerald
[pokediamond]: https://github.com/pret/pokediamond
[Discord]: https://discord.gg/d5dubZ3
[irc]: https://kiwiirc.com/client/irc.freenode.net/?#pret
# Pokémon Mystery Dungeon: Red Rescue Team
[![build](https://github.com/pret/pmd-red/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/pret/pmd-red/actions/workflows/build.yml)
This is a disassembly of Pokémon Mystery Dungeon: Red Rescue Team.
It builds the following rom:
* pmd_red.gba `sha1: 9f4cfc5b5f4859d17169a485462e977c7aac2b89`
To set up the repository, see [INSTALL.md](INSTALL.md).
## See also
* Disassembly of [**Pokémon Red/Blue**][pokered]
* Disassembly of [**Pokémon Yellow**][pokeyellow]
* Disassembly of [**Pokémon Gold**][pokegold]
* Disassembly of [**Pokémon Crystal**][pokecrystal]
* Disassembly of [**Pokémon Pinball**][pokepinball]
* Disassembly of [**Pokémon TCG**][poketcg]
* Disassembly of [**Pokémon Fire Red**/**Leaf Green**][pokefirered]
* Disassembly of [**Pokémon Ruby/Sapphire**][pokeruby]
* Disassembly of [**Pokémon Emerald**][pokeemerald]
* Disassembly of [**Pokémon Diamond/Pearl**][pokediamond]
* Discord: [**pret**][Discord]
* irc: **irc.freenode.net** [**#pret**][irc]
[pokered]: https://github.com/pret/pokered
[pokeyellow]: https://github.com/pret/pokeyellow
[pokegold]: https://github.com/pret/pokegold
[pokecrystal]: https://github.com/pret/pokecrystal
[pokepinball]: https://github.com/pret/pokepinball
[poketcg]: https://github.com/pret/poketcg
[pokefirered]: https://github.com/pret/pokefirered
[pokeruby]: https://github.com/pret/pokeruby
[pokeemerald]: https://github.com/pret/pokeemerald
[pokediamond]: https://github.com/pret/pokediamond
[Discord]: https://discord.gg/d5dubZ3
[irc]: https://kiwiirc.com/client/irc.freenode.net/?#pret

View File

@ -1,2 +1,2 @@
**/pokemon_found.inc
**/floor_id.inc
**/pokemon_found.inc
**/floor_id.inc

View File

@ -18,7 +18,7 @@ struct PokemonStruct
u8 fillD[0x10 - 0xD];
u8 unk10;
u8 fill11[0x14 - 0x11];
/* 0x14 */ u16 IQ;
/* 0x14 */ s16 IQ;
/* 0x16 */ u16 pokeHP; // HP
/* 0x18 */ u8 pokeAtt; // attack
/* 0x19 */ u8 pokeSPAtt; // sp attack

View File

@ -70,12 +70,10 @@ s32 GetNumberOfFilledInventorySlots(void)
bool8 IsThrowableItem(u8 itemIndex)
{
if ((GetItemType(itemIndex) != ITEM_TYPE_THROWABLE) && (GetItemType(itemIndex) != ITEM_TYPE_ROCK)) {
if ((GetItemType(itemIndex) != ITEM_TYPE_THROWABLE) && (GetItemType(itemIndex) != ITEM_TYPE_ROCK))
return FALSE;
}
else {
else
return TRUE;
}
}
void sub_8090A8C(struct ItemSlot *param_1,u8 itemIndex,u8 param_3)
@ -91,17 +89,14 @@ void sub_8090A8C(struct ItemSlot *param_1,u8 itemIndex,u8 param_3)
uVar4 = GetItemUnkThrow(itemIndex,1);
param_1->numItems = RandomRange(uVar3,uVar4);
}
else {
if (GetItemType(itemIndex) == ITEM_TYPE_MONEY) {
param_1->numItems = 1;
}
else {
param_1->numItems = 0;
}
}
if (param_3 != 0) {
else if (GetItemType(itemIndex) == ITEM_TYPE_MONEY)
param_1->numItems = 1;
else
param_1->numItems = 0;
if (param_3 != 0)
param_1->unk0 |= 8;
}
}
else {
param_1->unk0 = 0;
@ -121,14 +116,11 @@ void sub_8090B08(struct ItemSlot_ALT *param_1,u8 itemIndex)
uVar2 = GetItemUnkThrow(itemIndex,0);
uVar3 = GetItemUnkThrow(itemIndex,1);
param_1->numItems = RandomRange(uVar2,uVar3);
} else {
if (GetItemType(itemIndex) == ITEM_TYPE_MONEY) {
}
else if (GetItemType(itemIndex) == ITEM_TYPE_MONEY)
param_1->numItems = 1;
}
else {
else
param_1->numItems = 0;
}
}
}
else {
param_1->itemIndex = 0;
@ -146,20 +138,11 @@ void sub_8090B64(struct ItemSlot *param_1, struct ItemSlot_ALT *param_2)
param_1->itemIndex = param_2->itemIndex;
r6 = IsThrowableItem(param_1->itemIndex);
if(r6 != 0 || GetItemType(param_1->itemIndex) == ITEM_TYPE_MONEY)
{
param_1->numItems = param_2->numItems;
}
else if(param_1->itemIndex == ITEM_ID_USED_TM)
param_1->numItems = param_2->numItems;
else
{
if(param_1->itemIndex == ITEM_ID_USED_TM)
{
param_1->numItems = param_2->numItems;
}
else
{
param_1->numItems = r6;
}
}
param_1->numItems = 0;
}
else
{

View File

@ -237,10 +237,10 @@ bool8 AddItemToInventory(const struct ItemSlot* slot)
UNUSED struct ItemSlot* current = &gTeamInventory_203B460->teamItems[i];
if (!(i[gTeamInventory_203B460->teamItems].unk0 & 1)) {
gTeamInventory_203B460->teamItems[i] = *slot;
return 0;
return FALSE;
}
}
return 1;
return TRUE;
}
void ConvertMoneyItemToMoney()
@ -314,7 +314,7 @@ void AddToTeamMoney(s32 amount)
u16 GetItemMove(u8 index)
{
return gItemParametersData[index & 0xff].move;
return gItemParametersData[index].move;
}
u32 sub_80913E0(struct ItemSlot* slot, u32 a2, struct subStruct_203B240 ** a3)
@ -324,7 +324,7 @@ u32 sub_80913E0(struct ItemSlot* slot, u32 a2, struct subStruct_203B240 ** a3)
GetItemDescription(slot->itemIndex);
sub_8090DC4(buffer88, slot->itemIndex, 0);
if (slot->itemIndex == ITEM_ID_USED_TM) {
// empty HM
// empty TM
sub_8090DC4(&gUnknown_202DE58, (u8)(slot->numItems + 125), 0);
}
sub_80073B8(a2);
@ -367,83 +367,83 @@ bool8 CanSellItem(u32 id)
&& (id != ITEM_ID_MUSIC_BOX)
&& (GetItemSellPrice(id_))
&& (GetItemBuyPrice(id_))) {
return 1;
return TRUE;
}
return 0;
return FALSE;
}
bool8 IsNotMoneyOrUsedTMItem(u8 id)
{
if (id == ITEM_ID_NOTHING) {
return 0;
return FALSE;
}
else if (id == ITEM_ID_POKE) {
return 0;
return FALSE;
}
else if (id == ITEM_ID_USED_TM) {
return 0;
return FALSE;
}
return 1;
return TRUE;
}
bool8 IsNotSpecialItem(u8 id)
{
if (id == ITEM_ID_NOTHING) {
return 0;
return FALSE;
}
else if (id == ITEM_ID_POKE) {
return 0;
return FALSE;
}
else if (id == ITEM_ID_ROCK_PART) {
return 0;
return FALSE;
}
else if (id == ITEM_ID_ICE_PART) {
return 0;
return FALSE;
}
else if (id == ITEM_ID_STEEL_PART) {
return 0;
return FALSE;
}
else if (id == ITEM_ID_MUSIC_BOX) {
return 0;
return FALSE;
}
return 1;
return TRUE;
}
bool8 IsEdibleItem(u8 id)
{
if (!((GetItemType(id) == ITEM_TYPE_BERRY_SEED) || (GetItemType(id) == ITEM_TYPE_APPLE_GUMMI))) {
return 0;
return FALSE;
}
return 1;
return TRUE;
}
bool8 IsHMItem(u8 id)
{
if (id == ITEM_ID_CUT) {
return 1;
return TRUE;
}
else if (id == ITEM_ID_FLY) {
return 1;
return TRUE;
}
else if (id == ITEM_ID_SURF) {
return 1;
return TRUE;
}
else if (id == ITEM_ID_STRENGTH) {
return 1;
return TRUE;
}
else if (id == ITEM_ID_FLASH) {
return 1;
return TRUE;
}
else if (id == ITEM_ID_ROCK_SMASH) {
return 1;
return TRUE;
}
else if (id == ITEM_ID_WATERFALL) {
return 1;
return TRUE;
}
else if (id == ITEM_ID_DIVE) {
return 1;
return TRUE;
}
return 0;
return FALSE;
}
u32 GetMoneyValue(struct ItemSlot* slot)
@ -475,14 +475,14 @@ void GetGummiItemStatBoost(struct PokemonStruct* pokemon, u8 itemIndex, u8 a3, s
value0 = gTypeGummiIQBoost[pokemon_type_0][gummi_index];
value1 = gTypeGummiIQBoost[pokemon_type_1][gummi_index];
diff = (s16)pokemon->IQ;
diff = pokemon->IQ;
pokemon->IQ += value0 + value1;
diff = (s16)pokemon->IQ - diff;
if ((s16)pokemon->IQ <= 0) {
diff = pokemon->IQ - diff;
if (pokemon->IQ <= 0) {
pokemon->IQ = 1;
}
if ((s16)pokemon->IQ > 999) {
if (pokemon->IQ > 999) {
pokemon->IQ = 999;
}
@ -512,7 +512,7 @@ void GetGummiItemStatBoost(struct PokemonStruct* pokemon, u8 itemIndex, u8 a3, s
a4->unk2 = boost_flags;
boost_flags = a4->unk2;
if (a4->unk2 & 1) {
if (pokemon->pokeAtt < 0xffu) {
if (pokemon->pokeAtt < 255) {
pokemon->pokeAtt++;
}
else {
@ -523,7 +523,7 @@ void GetGummiItemStatBoost(struct PokemonStruct* pokemon, u8 itemIndex, u8 a3, s
}
}
if (a4->unk2 & 2) {
if (pokemon->pokeSPAtt < 0xffu) {
if (pokemon->pokeSPAtt < 255) {
pokemon->pokeSPAtt++;
}
else {
@ -531,7 +531,7 @@ void GetGummiItemStatBoost(struct PokemonStruct* pokemon, u8 itemIndex, u8 a3, s
}
}
if (a4->unk2 & 4) {
if (pokemon->pokeDef < 0xffu) {
if (pokemon->pokeDef < 255) {
pokemon->pokeDef++;
}
else {
@ -539,7 +539,7 @@ void GetGummiItemStatBoost(struct PokemonStruct* pokemon, u8 itemIndex, u8 a3, s
}
}
if (a4->unk2 & 8) {
if (pokemon->pokeSPDef < 0xffu) {
if (pokemon->pokeSPDef < 255) {
pokemon->pokeSPDef++;
}
else {
@ -553,12 +553,12 @@ void GetGummiItemStatBoost(struct PokemonStruct* pokemon, u8 itemIndex, u8 a3, s
bool8 IsGummiItem(u8 itemIndex)
{
if (itemIndex < ITEM_ID_WHITE_GUMMI) {
return 0;
return FALSE;
}
if (itemIndex > ITEM_ID_SILVER_GUMMI) {
return 0;
return FALSE;
}
return 1;
return TRUE;
}
bool8 HasGummiItem()
@ -567,10 +567,10 @@ bool8 HasGummiItem()
for (i = 0; i < INVENTORY_SIZE; i++) {
UNUSED size_t offs = offsetof(struct TeamInventory, teamItems[i]);
if ((i[gTeamInventory_203B460->teamItems].unk0 & 1) && IsGummiItem(i[gTeamInventory_203B460->teamItems].itemIndex)) {
return 1;
return TRUE;
}
}
return 0;
return FALSE;
}
void MoveToStorage(struct ItemSlot* slot)
@ -603,16 +603,14 @@ void xxx_init_unk230_substruct(u8 i)
{
struct subStruct_203B460* unk230;
// the masking makes it seem like there should be an item ID passed, but
// that would go horribly out of bounds...
unk230 = &gTeamInventory_203B460->unk230[i & 0xff];
unk230 = &gTeamInventory_203B460->unk230[i];
unk230->unk0 = 0;
unk230->unk1 = 0;
}
struct subStruct_203B460* sub_809185C(u8 i)
{
return &gTeamInventory_203B460->unk230[i & 0xff];
return &gTeamInventory_203B460->unk230[i];
}
void xxx_fill_unk230_gaps()
@ -647,4 +645,4 @@ void xxx_fill_unk230_gaps()
for (; last_filled < 8; last_filled++) {
xxx_init_unk230_substruct(last_filled);
}
}
}

File diff suppressed because it is too large Load Diff