mirror of
https://github.com/pret/pmd-red.git
synced 2026-06-16 21:50:21 -05:00
More work on item related functions (#44)
* decompile sub_8091290 * decompile sub_80912c8 * rename functions / struct field * more names * decompile 80913A0 * decompile GetItemMove * decompile sub_80913E0 * rename function * decompile CanSellItem function * rename inventory struct * add some item check functions * fix renaming stuff * this file shouldnt have been here * forgot merge conflict * decompile more item functions * rename some stuff * fix HM/TM naming * Update src/code_801AFA4.c Use enum value for USED_TM * Fix incorrect value * decompile sub_80915F4 * decompile HasGummiItem * decompiled another function and renamed stuff * decompile 2 smaller functions * more functions * more decompiling and renaming * redo change that was undone in the merge
This commit is contained in:
parent
2104c4f762
commit
da7b30612f
78
README.md
78
README.md
|
|
@ -1,39 +1,39 @@
|
|||
# Pokémon Mystery Dungeon: Red Rescue Team
|
||||
|
||||
[](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
|
||||
|
||||
[](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
|
||||
|
|
|
|||
|
|
@ -969,7 +969,7 @@ _0801BDD2:
|
|||
ldr r4, _0801BE08
|
||||
ldr r0, [r4]
|
||||
adds r0, 0x20
|
||||
bl sub_80917B8
|
||||
bl MoveToStorage
|
||||
ldr r0, [r4]
|
||||
ldr r0, [r0, 0x24]
|
||||
bl ShiftItemsDownFrom
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ _08048852:
|
|||
movs r0, 0x1
|
||||
b _08048862
|
||||
.align 2, 0
|
||||
_08048858: .4byte gUnknown_810A580
|
||||
_08048858: .4byte gTypeGummiIQBoost
|
||||
_0804885C: .4byte gUnknown_810A808
|
||||
_08048860:
|
||||
movs r0, 0
|
||||
|
|
|
|||
|
|
@ -7271,7 +7271,7 @@ sub_80227B8:
|
|||
adds r1, r5, 0
|
||||
movs r2, 0x6
|
||||
bl sub_808D9AC
|
||||
bl sub_809177C
|
||||
bl HasGummiItem
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
beq _08022818
|
||||
|
|
@ -7921,7 +7921,7 @@ sub_8022D2C:
|
|||
adds r0, r2, 0
|
||||
adds r0, 0x52
|
||||
ldrb r0, [r0]
|
||||
bl sub_8091764
|
||||
bl IsGummiItem
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
bne _08022D74
|
||||
|
|
@ -8194,7 +8194,7 @@ _08022F68:
|
|||
ldrb r1, [r1]
|
||||
adds r3, 0x44
|
||||
movs r2, 0
|
||||
bl sub_80915F4
|
||||
bl GetGummiItemStatBoost
|
||||
ldr r1, [r4]
|
||||
adds r0, r1, 0
|
||||
adds r0, 0x20
|
||||
|
|
@ -15029,7 +15029,7 @@ _080265B4:
|
|||
adds r2, r3
|
||||
movs r0, 0xA
|
||||
str r0, [r2]
|
||||
bl sub_809177C
|
||||
bl HasGummiItem
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
bne _080265EC
|
||||
|
|
|
|||
430
asm/items_1.s
430
asm/items_1.s
|
|
@ -5,432 +5,6 @@
|
|||
|
||||
.text
|
||||
|
||||
thumb_func_start sub_80915F4
|
||||
sub_80915F4:
|
||||
push {r4-r7,lr}
|
||||
mov r7, r8
|
||||
push {r7}
|
||||
adds r6, r0, 0
|
||||
adds r7, r3, 0
|
||||
lsls r1, 24
|
||||
lsrs r5, r1, 24
|
||||
lsls r2, 24
|
||||
lsrs r2, 24
|
||||
mov r8, r2
|
||||
ldr r0, _080916B8
|
||||
strh r0, [r7]
|
||||
movs r0, 0
|
||||
strh r0, [r7, 0x2]
|
||||
adds r0, r5, 0
|
||||
bl sub_8091764
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
bne _0809161E
|
||||
b _08091756
|
||||
_0809161E:
|
||||
movs r1, 0x8
|
||||
ldrsh r0, [r6, r1]
|
||||
movs r1, 0
|
||||
bl GetPokemonType
|
||||
adds r4, r0, 0
|
||||
lsls r4, 24
|
||||
lsrs r4, 24
|
||||
movs r2, 0x8
|
||||
ldrsh r0, [r6, r2]
|
||||
movs r1, 0x1
|
||||
bl GetPokemonType
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
adds r2, r5, 0
|
||||
subs r2, 0x55
|
||||
ldr r5, _080916BC
|
||||
lsls r2, 1
|
||||
lsls r1, r4, 3
|
||||
adds r1, r4
|
||||
lsls r1, 2
|
||||
adds r1, r2, r1
|
||||
adds r1, r5
|
||||
movs r4, 0
|
||||
ldrsh r3, [r1, r4]
|
||||
lsls r1, r0, 3
|
||||
adds r1, r0
|
||||
lsls r1, 2
|
||||
adds r2, r1
|
||||
adds r2, r5
|
||||
movs r1, 0
|
||||
ldrsh r0, [r2, r1]
|
||||
movs r2, 0x14
|
||||
ldrsh r1, [r6, r2]
|
||||
adds r3, r0
|
||||
ldrh r4, [r6, 0x14]
|
||||
adds r3, r4
|
||||
strh r3, [r6, 0x14]
|
||||
movs r2, 0x14
|
||||
ldrsh r0, [r6, r2]
|
||||
subs r1, r0, r1
|
||||
lsls r3, 16
|
||||
cmp r3, 0
|
||||
bgt _0809167C
|
||||
movs r0, 0x1
|
||||
strh r0, [r6, 0x14]
|
||||
_0809167C:
|
||||
movs r4, 0x14
|
||||
ldrsh r0, [r6, r4]
|
||||
ldr r2, _080916C0
|
||||
cmp r0, r2
|
||||
ble _08091688
|
||||
strh r2, [r6, 0x14]
|
||||
_08091688:
|
||||
movs r0, 0
|
||||
cmp r1, 0x8
|
||||
bgt _0809169C
|
||||
movs r0, 0x1
|
||||
cmp r1, 0x4
|
||||
bgt _0809169C
|
||||
movs r0, 0x3
|
||||
cmp r1, 0x2
|
||||
ble _0809169C
|
||||
movs r0, 0x2
|
||||
_0809169C:
|
||||
strh r0, [r7]
|
||||
mov r1, r8
|
||||
cmp r1, 0
|
||||
bne _08091756
|
||||
cmp r0, 0
|
||||
bne _080916C4
|
||||
movs r0, 0x10
|
||||
bl RandomCapped
|
||||
cmp r0, 0xA
|
||||
bne _080916C4
|
||||
movs r0, 0xF
|
||||
b _080916D2
|
||||
.align 2, 0
|
||||
_080916B8: .4byte 0x0000ffff
|
||||
_080916BC: .4byte gUnknown_810A580
|
||||
_080916C0: .4byte 0x000003e7
|
||||
_080916C4:
|
||||
movs r0, 0x4
|
||||
bl RandomCapped
|
||||
ldr r1, _080916EC
|
||||
lsls r0, 1
|
||||
adds r0, r1
|
||||
ldrh r0, [r0]
|
||||
_080916D2:
|
||||
strh r0, [r7, 0x2]
|
||||
ldrh r1, [r7, 0x2]
|
||||
movs r0, 0x1
|
||||
ands r0, r1
|
||||
cmp r0, 0
|
||||
beq _080916F6
|
||||
ldrb r0, [r6, 0x18]
|
||||
cmp r0, 0xFE
|
||||
bhi _080916F0
|
||||
adds r0, 0x1
|
||||
strb r0, [r6, 0x18]
|
||||
b _080916F6
|
||||
.align 2, 0
|
||||
_080916EC: .4byte gUnknown_81097E0
|
||||
_080916F0:
|
||||
ldr r0, _0809170C
|
||||
ands r0, r1
|
||||
strh r0, [r7, 0x2]
|
||||
_080916F6:
|
||||
ldrh r1, [r7, 0x2]
|
||||
movs r0, 0x2
|
||||
ands r0, r1
|
||||
cmp r0, 0
|
||||
beq _08091716
|
||||
ldrb r0, [r6, 0x19]
|
||||
cmp r0, 0xFE
|
||||
bhi _08091710
|
||||
adds r0, 0x1
|
||||
strb r0, [r6, 0x19]
|
||||
b _08091716
|
||||
.align 2, 0
|
||||
_0809170C: .4byte 0x0000fffe
|
||||
_08091710:
|
||||
ldr r0, _0809172C
|
||||
ands r0, r1
|
||||
strh r0, [r7, 0x2]
|
||||
_08091716:
|
||||
ldrh r1, [r7, 0x2]
|
||||
movs r0, 0x4
|
||||
ands r0, r1
|
||||
cmp r0, 0
|
||||
beq _08091736
|
||||
ldrb r0, [r6, 0x1A]
|
||||
cmp r0, 0xFE
|
||||
bhi _08091730
|
||||
adds r0, 0x1
|
||||
strb r0, [r6, 0x1A]
|
||||
b _08091736
|
||||
.align 2, 0
|
||||
_0809172C: .4byte 0x0000fffd
|
||||
_08091730:
|
||||
ldr r0, _0809174C
|
||||
ands r0, r1
|
||||
strh r0, [r7, 0x2]
|
||||
_08091736:
|
||||
ldrh r1, [r7, 0x2]
|
||||
movs r0, 0x8
|
||||
ands r0, r1
|
||||
cmp r0, 0
|
||||
beq _08091756
|
||||
ldrb r0, [r6, 0x1B]
|
||||
cmp r0, 0xFE
|
||||
bhi _08091750
|
||||
adds r0, 0x1
|
||||
strb r0, [r6, 0x1B]
|
||||
b _08091756
|
||||
.align 2, 0
|
||||
_0809174C: .4byte 0x0000fffb
|
||||
_08091750:
|
||||
ldr r0, _08091760
|
||||
ands r0, r1
|
||||
strh r0, [r7, 0x2]
|
||||
_08091756:
|
||||
pop {r3}
|
||||
mov r8, r3
|
||||
pop {r4-r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.align 2, 0
|
||||
_08091760: .4byte 0x0000fff7
|
||||
thumb_func_end sub_80915F4
|
||||
|
||||
thumb_func_start sub_8091764
|
||||
sub_8091764:
|
||||
push {lr}
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
cmp r0, 0x55
|
||||
bls _08091776
|
||||
cmp r0, 0x66
|
||||
bhi _08091776
|
||||
movs r0, 0x1
|
||||
b _08091778
|
||||
_08091776:
|
||||
movs r0, 0
|
||||
_08091778:
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_8091764
|
||||
|
||||
thumb_func_start sub_809177C
|
||||
sub_809177C:
|
||||
push {r4,lr}
|
||||
movs r4, 0
|
||||
_08091780:
|
||||
lsls r1, r4, 2
|
||||
ldr r0, _080917A4
|
||||
ldr r0, [r0]
|
||||
adds r2, r1, r0
|
||||
ldrb r1, [r2]
|
||||
movs r0, 0x1
|
||||
ands r0, r1
|
||||
cmp r0, 0
|
||||
beq _080917A8
|
||||
ldrb r0, [r2, 0x2]
|
||||
bl sub_8091764
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
beq _080917A8
|
||||
movs r0, 0x1
|
||||
b _080917B0
|
||||
.align 2, 0
|
||||
_080917A4: .4byte gTeamInventory_203B460
|
||||
_080917A8:
|
||||
adds r4, 0x1
|
||||
cmp r4, 0x13
|
||||
ble _08091780
|
||||
movs r0, 0
|
||||
_080917B0:
|
||||
pop {r4}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_809177C
|
||||
|
||||
thumb_func_start sub_80917B8
|
||||
sub_80917B8:
|
||||
push {r4,lr}
|
||||
adds r4, r0, 0
|
||||
ldrb r0, [r4, 0x2]
|
||||
bl IsThrowableItem
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
beq _080917E0
|
||||
ldr r2, _080917DC
|
||||
ldr r1, [r2]
|
||||
ldrb r0, [r4, 0x2]
|
||||
lsls r0, 1
|
||||
adds r1, 0x50
|
||||
adds r1, r0
|
||||
ldrh r0, [r1]
|
||||
ldrb r3, [r4, 0x1]
|
||||
adds r0, r3
|
||||
b _080917F0
|
||||
.align 2, 0
|
||||
_080917DC: .4byte gTeamInventory_203B460
|
||||
_080917E0:
|
||||
ldr r2, _0809180C
|
||||
ldr r1, [r2]
|
||||
ldrb r0, [r4, 0x2]
|
||||
lsls r0, 1
|
||||
adds r1, 0x50
|
||||
adds r1, r0
|
||||
ldrh r0, [r1]
|
||||
adds r0, 0x1
|
||||
_080917F0:
|
||||
strh r0, [r1]
|
||||
ldr r0, [r2]
|
||||
ldrb r1, [r4, 0x2]
|
||||
lsls r1, 1
|
||||
adds r0, 0x50
|
||||
adds r2, r0, r1
|
||||
ldrh r0, [r2]
|
||||
ldr r1, _08091810
|
||||
cmp r0, r1
|
||||
bls _08091806
|
||||
strh r1, [r2]
|
||||
_08091806:
|
||||
pop {r4}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.align 2, 0
|
||||
_0809180C: .4byte gTeamInventory_203B460
|
||||
_08091810: .4byte 0x000003e7
|
||||
thumb_func_end sub_80917B8
|
||||
|
||||
thumb_func_start sub_8091814
|
||||
sub_8091814:
|
||||
push {lr}
|
||||
movs r3, 0
|
||||
ldr r0, _0809183C
|
||||
ldr r0, [r0]
|
||||
movs r2, 0x8C
|
||||
lsls r2, 2
|
||||
adds r1, r0, r2
|
||||
movs r2, 0x7
|
||||
_08091824:
|
||||
ldrb r0, [r1]
|
||||
cmp r0, 0
|
||||
beq _0809182C
|
||||
adds r3, 0x1
|
||||
_0809182C:
|
||||
adds r1, 0x4
|
||||
subs r2, 0x1
|
||||
cmp r2, 0
|
||||
bge _08091824
|
||||
adds r0, r3, 0
|
||||
pop {r1}
|
||||
bx r1
|
||||
.align 2, 0
|
||||
_0809183C: .4byte gTeamInventory_203B460
|
||||
thumb_func_end sub_8091814
|
||||
|
||||
thumb_func_start sub_8091840
|
||||
sub_8091840:
|
||||
lsls r0, 24
|
||||
ldr r1, _08091858
|
||||
lsrs r0, 22
|
||||
movs r2, 0x8C
|
||||
lsls r2, 2
|
||||
adds r0, r2
|
||||
ldr r1, [r1]
|
||||
adds r1, r0
|
||||
movs r0, 0
|
||||
strb r0, [r1]
|
||||
strb r0, [r1, 0x1]
|
||||
bx lr
|
||||
.align 2, 0
|
||||
_08091858: .4byte gTeamInventory_203B460
|
||||
thumb_func_end sub_8091840
|
||||
|
||||
thumb_func_start sub_809185C
|
||||
sub_809185C:
|
||||
lsls r0, 24
|
||||
ldr r1, _08091870
|
||||
lsrs r0, 22
|
||||
movs r2, 0x8C
|
||||
lsls r2, 2
|
||||
adds r0, r2
|
||||
ldr r1, [r1]
|
||||
adds r1, r0
|
||||
adds r0, r1, 0
|
||||
bx lr
|
||||
.align 2, 0
|
||||
_08091870: .4byte gTeamInventory_203B460
|
||||
thumb_func_end sub_809185C
|
||||
|
||||
thumb_func_start sub_8091874
|
||||
sub_8091874:
|
||||
push {r4-r7,lr}
|
||||
movs r2, 0
|
||||
movs r4, 0
|
||||
ldr r7, _08091884
|
||||
movs r6, 0x8C
|
||||
lsls r6, 2
|
||||
movs r3, 0
|
||||
b _080918A0
|
||||
.align 2, 0
|
||||
_08091884: .4byte gTeamInventory_203B460
|
||||
_08091888:
|
||||
cmp r2, r4
|
||||
ble _0809189A
|
||||
ldr r0, [r7]
|
||||
lsls r1, r4, 2
|
||||
adds r0, r6
|
||||
adds r1, r0, r1
|
||||
adds r0, r3
|
||||
ldr r0, [r0]
|
||||
str r0, [r1]
|
||||
_0809189A:
|
||||
adds r3, 0x4
|
||||
adds r2, 0x1
|
||||
adds r4, 0x1
|
||||
_080918A0:
|
||||
cmp r2, 0x7
|
||||
bgt _080918CA
|
||||
ldr r0, [r7]
|
||||
adds r0, r3
|
||||
adds r0, r6
|
||||
ldrb r0, [r0]
|
||||
cmp r0, 0
|
||||
bne _080918CA
|
||||
ldr r5, _080918E8
|
||||
movs r1, 0x8C
|
||||
lsls r1, 2
|
||||
_080918B6:
|
||||
adds r3, 0x4
|
||||
adds r2, 0x1
|
||||
cmp r2, 0x7
|
||||
bgt _080918CA
|
||||
ldr r0, [r5]
|
||||
adds r0, r3
|
||||
adds r0, r1
|
||||
ldrb r0, [r0]
|
||||
cmp r0, 0
|
||||
beq _080918B6
|
||||
_080918CA:
|
||||
cmp r2, 0x8
|
||||
bne _08091888
|
||||
cmp r4, 0x7
|
||||
bgt _080918E0
|
||||
_080918D2:
|
||||
lsls r0, r4, 24
|
||||
lsrs r0, 24
|
||||
bl sub_8091840
|
||||
adds r4, 0x1
|
||||
cmp r4, 0x7
|
||||
ble _080918D2
|
||||
_080918E0:
|
||||
pop {r4-r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.align 2, 0
|
||||
_080918E8: .4byte gTeamInventory_203B460
|
||||
thumb_func_end sub_8091874
|
||||
|
||||
thumb_func_start sub_80918EC
|
||||
sub_80918EC:
|
||||
push {r4-r7,lr}
|
||||
|
|
@ -530,7 +104,7 @@ sub_8091980:
|
|||
_0809199C:
|
||||
lsls r0, r5, 24
|
||||
lsrs r0, 24
|
||||
bl sub_8091840
|
||||
bl xxx_init_unk230_substruct
|
||||
adds r5, 0x1
|
||||
cmp r5, 0x7
|
||||
ble _0809199C
|
||||
|
|
@ -1432,4 +1006,4 @@ _08092038: .4byte gTeamInventory_203B460
|
|||
_0809203C: .4byte gRecruitedPokemonRef
|
||||
thumb_func_end sub_8091FB4
|
||||
|
||||
.align 2,0
|
||||
.align 2,0
|
||||
|
|
@ -404,7 +404,7 @@ _080178F4:
|
|||
ldr r4, _08017914
|
||||
ldr r0, [r4]
|
||||
adds r0, 0xC
|
||||
bl sub_80917B8
|
||||
bl MoveToStorage
|
||||
ldr r0, [r4]
|
||||
ldr r0, [r0, 0x10]
|
||||
bl ShiftItemsDownFrom
|
||||
|
|
@ -520,7 +520,7 @@ _080179D2:
|
|||
lsls r4, r5, 2
|
||||
ldr r0, [r6]
|
||||
adds r0, r4
|
||||
bl sub_80917B8
|
||||
bl MoveToStorage
|
||||
ldr r0, [r6]
|
||||
adds r0, r4
|
||||
strb r7, [r0, 0x2]
|
||||
|
|
|
|||
|
|
@ -465,7 +465,7 @@ _0801864A:
|
|||
lsls r4, r5, 2
|
||||
ldr r0, [r6]
|
||||
adds r0, r4
|
||||
bl sub_80917B8
|
||||
bl MoveToStorage
|
||||
ldr r0, [r6]
|
||||
adds r0, r4
|
||||
strb r7, [r0, 0x2]
|
||||
|
|
@ -849,7 +849,7 @@ _08018978: .4byte gUnknown_203B20C
|
|||
_0801897C:
|
||||
ldr r0, [r4]
|
||||
adds r0, 0x8
|
||||
bl sub_80917B8
|
||||
bl MoveToStorage
|
||||
ldr r0, [r4]
|
||||
ldr r0, [r0, 0xC]
|
||||
bl ShiftItemsDownFrom
|
||||
|
|
|
|||
|
|
@ -1228,8 +1228,8 @@ _08019874:
|
|||
ldr r0, [r4]
|
||||
adds r0, 0x20
|
||||
ldrb r0, [r0]
|
||||
bl sub_8091840
|
||||
bl sub_8091874
|
||||
bl xxx_init_unk230_substruct
|
||||
bl xxx_fill_unk230_gaps
|
||||
b _080198C8
|
||||
.align 2, 0
|
||||
_080198A8: .4byte gUnknown_203B210
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
sub_8019E40:
|
||||
push {r4-r6,lr}
|
||||
adds r6, r0, 0
|
||||
bl sub_8091814
|
||||
bl xxx_count_inv_unk230
|
||||
cmp r0, 0
|
||||
beq _08019ED4
|
||||
ldr r5, _08019EC8
|
||||
|
|
@ -50,7 +50,7 @@ sub_8019E40:
|
|||
movs r2, 0x1
|
||||
bl sub_800641C
|
||||
ldr r4, [r5]
|
||||
bl sub_8091814
|
||||
bl xxx_count_inv_unk230
|
||||
adds r1, r0, 0
|
||||
adds r0, r4, 0
|
||||
movs r2, 0xA
|
||||
|
|
@ -212,7 +212,7 @@ sub_8019FCC:
|
|||
movs r1, 0
|
||||
movs r2, 0
|
||||
bl sub_800641C
|
||||
bl sub_8091814
|
||||
bl xxx_count_inv_unk230
|
||||
adds r1, r0, 0
|
||||
ldr r0, [r5]
|
||||
strh r1, [r0, 0x22]
|
||||
|
|
@ -1727,7 +1727,7 @@ _0801AC50:
|
|||
adds r1, r4, 0
|
||||
bl sub_8090E14
|
||||
ldrb r0, [r4, 0x2]
|
||||
bl sub_8091764
|
||||
bl IsGummiItem
|
||||
lsls r0, 24
|
||||
lsrs r5, r0, 24
|
||||
cmp r5, 0
|
||||
|
|
|
|||
|
|
@ -8101,13 +8101,13 @@ gUnknown_81097C5: @ 81097C5
|
|||
@ replacing .incbin "baserom.gba", 0x001097c5, 0x1b
|
||||
.byte 0x9f, 0x83, 0xa0, 0x83, 0xa1, 0x83, 0xa2, 0x83, 0xa3, 0x83, 0xa4, 0x83, 0xa5, 0x83, 0xa6, 0x83, 0xa7, 0x83, 0xa8, 0x00, 0x00, 0x00, 0x00, 0xc4, 0x97, 0x10, 0x08
|
||||
|
||||
.global gUnknown_81097E0
|
||||
gUnknown_81097E0: @ 81097E0
|
||||
.global gGummiStatBoostLUT
|
||||
gGummiStatBoostLUT: @ 81097E0
|
||||
@ replacing .incbin "baserom.gba", 0x001097e0, 0x8
|
||||
.byte 0x01, 0x00
|
||||
.byte 0x02, 0x00
|
||||
.byte 0x04, 0x00
|
||||
.byte 0x08, 0x00
|
||||
.2byte 0x0001
|
||||
.2byte 0x0002
|
||||
.2byte 0x0004
|
||||
.2byte 0x0008
|
||||
|
||||
.global gUnknown_81097E8
|
||||
gUnknown_81097E8: @ 81097E8
|
||||
|
|
@ -8331,8 +8331,10 @@ gUnknown_810A3F0: @ 810A3F0 (money related according to PMDe
|
|||
@ LUT for money item stack size -> money amount
|
||||
.incbin "baserom.gba", 0x10A3F0, 0x190
|
||||
|
||||
.global gUnknown_810A580
|
||||
gUnknown_810A580: @ 810A580
|
||||
.global gTypeGummiIQBoost
|
||||
gTypeGummiIQBoost: @ 810A580
|
||||
// s16[0x12][NUMBER_OF_GUMMIS = 18]
|
||||
// relates [type][gummi tyep] -> iq boost amount
|
||||
.incbin "baserom.gba", 0x10A580, 0x288
|
||||
|
||||
.global gUnknown_810A808
|
||||
|
|
|
|||
|
|
@ -35,6 +35,12 @@ struct ItemSlot_ALT
|
|||
u8 unk2;
|
||||
};
|
||||
|
||||
struct unkStruct_80915F4
|
||||
{
|
||||
u16 unk0;
|
||||
u16 unk2;
|
||||
};
|
||||
|
||||
enum ItemType
|
||||
{
|
||||
ITEM_TYPE_THROWABLE,
|
||||
|
|
@ -311,8 +317,12 @@ enum ItemID {
|
|||
ITEM_ID_G_MACHINE_6,
|
||||
ITEM_ID_G_MACHINE_7,
|
||||
ITEM_ID_G_MACHINE_8,
|
||||
NUMBER_OF_ITEM_IDS
|
||||
};
|
||||
|
||||
#define NUMBER_OF_GUMMIS 18
|
||||
#define INVENTORY_SIZE 20
|
||||
|
||||
void LoadItemParameters(void);
|
||||
struct TeamInventory *GetMoneyItemsInfo(void);
|
||||
void InitializeMoneyItems(void);
|
||||
|
|
@ -336,5 +346,7 @@ void ConvertMoneyItemToMoney();
|
|||
void AddToTeamMoney(s32 amount);
|
||||
u32 GetMoneyValue(struct ItemSlot* slot);
|
||||
u16 GetItemMove(u8 index);
|
||||
bool8 IsGummiItem(u8);
|
||||
void xxx_init_unk230_substruct(u8);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ struct PokemonStruct
|
|||
u8 fillD[0x10 - 0xD];
|
||||
u8 unk10;
|
||||
u8 fill11[0x14 - 0x11];
|
||||
u16 unk14;
|
||||
/* 0x14 */ u16 IQ;
|
||||
/* 0x16 */ u16 pokeHP; // HP
|
||||
/* 0x18 */ u8 pokeAtt; // attack
|
||||
/* 0x19 */ u8 pokeSPAtt; // sp attack
|
||||
|
|
@ -144,7 +144,7 @@ u8 GetUnk12(s16 index);
|
|||
s16 GetPokemonEvolveFrom(s16 index);
|
||||
u16 GetPokemonAttSpatt(s16 index, u32 r1);
|
||||
u16 GetPokemonDefSpdef(s16 index, u32 r1);
|
||||
u8 GetPokemonType(s32 index, u32 typeIndex);;
|
||||
u8 GetPokemonType(s32 index, u32 typeIndex);
|
||||
u8 GetPokemonAbility(s16 index, u32 abilityIndex);
|
||||
s16 GetDexInternalNo(s16 index, u32 r1);
|
||||
s16 GetBaseRecruit(s16 index);
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ struct subStruct_203B460
|
|||
|
||||
struct TeamInventory
|
||||
{
|
||||
struct ItemSlot teamItems[20];
|
||||
u16 unk50[0xF0];
|
||||
struct ItemSlot teamItems[INVENTORY_SIZE];
|
||||
u16 teamStorage[NUMBER_OF_ITEM_IDS];
|
||||
struct subStruct_203B460 unk230[8]; // this is probably actually the same struct as ItemSlot_ALT (see sub_80919FC)
|
||||
struct subStruct_203B460 unk250[4]; // TODO: idk if this is identical struct or not.. Ghidra says sizes are same
|
||||
/* 0x260 */ s32 teamMoney;
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ void sub_803A5A0(void)
|
|||
gUnknown_203B3F0->unkAC = 3;
|
||||
gUnknown_203B3F0->unkA4 = 0;
|
||||
gUnknown_203B3F0->unkA8 = 0x3e7;
|
||||
gUnknown_203B3F0->unkA0 = gTeamInventory_203B460->unk50[gUnknown_203B3F0->itemIndex];
|
||||
gUnknown_203B3F0->unkA0 = gTeamInventory_203B460->teamStorage[gUnknown_203B3F0->itemIndex];
|
||||
gUnknown_203B3F0->unkB0 = 1;
|
||||
gUnknown_203B3F0->unkB4 = &gUnknown_203B3F0->unkD8[1];
|
||||
gUnknown_203B3F0->unkB8 = 0x2C;
|
||||
|
|
@ -300,7 +300,7 @@ void sub_803A810(void)
|
|||
switch(sub_8013BBC(&gUnknown_203B3F0->unk9C))
|
||||
{
|
||||
case 3:
|
||||
gTeamInventory_203B460->unk50[gUnknown_203B3F0->itemIndex] = gUnknown_203B3F0->unk9C;
|
||||
gTeamInventory_203B460->teamStorage[gUnknown_203B3F0->itemIndex] = gUnknown_203B3F0->unk9C;
|
||||
// Fallthrough needed to match
|
||||
case 2:
|
||||
sub_803A504(1);
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ void sub_8034F88(void)
|
|||
temp2 = sub_8095228(gUnknown_203B33C->unk218);
|
||||
if(gUnknown_203B33C->unk41C.itemIndex != 0)
|
||||
temp2->unk20 = gUnknown_203B33C->unk41C;
|
||||
gTeamInventory_203B460->unk50[gUnknown_203B33C->unk41C.itemIndex]--;
|
||||
gTeamInventory_203B460->teamStorage[gUnknown_203B33C->unk41C.itemIndex]--;
|
||||
sub_80338C4(0x75);
|
||||
break;
|
||||
case 7:
|
||||
|
|
|
|||
13
src/items.c
13
src/items.c
|
|
@ -3,16 +3,17 @@
|
|||
#include "item.h"
|
||||
#include "team_inventory.h"
|
||||
#include "random.h"
|
||||
#include "pokemon.h"
|
||||
|
||||
extern struct TeamInventory *gTeamInventory_203B460;
|
||||
extern struct TeamInventory gUnknown_20389A8;
|
||||
extern struct FileArchive gSystemFileArchive;
|
||||
extern const char gUnknown_8109764;
|
||||
extern u16 *gGummiStatBoostLUT;
|
||||
|
||||
EWRAM_DATA struct OpenedFile *gItemParametersFile;
|
||||
EWRAM_DATA struct Item *gItemParametersData;
|
||||
|
||||
extern void sub_8091840(u8);
|
||||
extern u8 GetItemType(u8);
|
||||
extern u32 GetItemUnkThrow(u8, u32);
|
||||
extern bool8 CanSellItem(u8);
|
||||
|
|
@ -34,19 +35,19 @@ void InitializeMoneyItems(void)
|
|||
{
|
||||
s32 i;
|
||||
|
||||
for(i = 0; i < 20; i++)
|
||||
for(i = 0; i < INVENTORY_SIZE; i++)
|
||||
{
|
||||
gTeamInventory_203B460->teamItems[i].unk0 = 0;
|
||||
}
|
||||
|
||||
for(i = 0; i < 0xF0; i++)
|
||||
{
|
||||
gTeamInventory_203B460->unk50[i] = 0;
|
||||
gTeamInventory_203B460->teamStorage[i] = 0;
|
||||
}
|
||||
|
||||
for(i = 0; i < 8; i++)
|
||||
{
|
||||
sub_8091840(i);
|
||||
xxx_init_unk230_substruct(i);
|
||||
}
|
||||
gTeamInventory_203B460->teamMoney = 0;
|
||||
gTeamInventory_203B460->teamSavings = 0;
|
||||
|
|
@ -58,7 +59,7 @@ s32 GetNumberOfFilledInventorySlots(void)
|
|||
s32 count;
|
||||
|
||||
count = 0;
|
||||
for(i = 0; i < 20; i++)
|
||||
for(i = 0; i < INVENTORY_SIZE; i++)
|
||||
{
|
||||
if ((gTeamInventory_203B460->teamItems[i].unk0 & 1) != 0) {
|
||||
count++;
|
||||
|
|
@ -293,4 +294,4 @@ void sub_8090DC4(void* param_1,u8 itemIndex,u32 param_3)
|
|||
sub_8090A8C(&unkItem,itemIndex,0);
|
||||
unkItem.numItems = 1;
|
||||
sub_8090F58(param_1,acStack104,&unkItem,param_3);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
327
src/items_1.c
327
src/items_1.c
|
|
@ -1,6 +1,7 @@
|
|||
#include "global.h"
|
||||
#include "item.h"
|
||||
#include "team_inventory.h"
|
||||
#include "random.h"
|
||||
#include "pokemon.h"
|
||||
#include "subStruct_203B240.h"
|
||||
|
||||
|
|
@ -25,6 +26,71 @@ extern u8* gPtrTypeText; // ptr to "Type\0"
|
|||
extern u8* gPtrPPD0Text; // ptr to "PP $d0 \0"
|
||||
extern u32 gUnknown_810A3F0[100];
|
||||
extern struct unkStruct_203B45C *gRecruitedPokemonRef;
|
||||
extern s16 gTypeGummiIQBoost[0x12][NUMBER_OF_GUMMIS];
|
||||
extern u16 gGummiStatBoostLUT;
|
||||
|
||||
|
||||
// s32 sub_8090FEC(s32 a1, u8* a2, u8 a3)
|
||||
// {
|
||||
// s32 i, j;
|
||||
// s32 cond = 0;
|
||||
|
||||
// j = 0;
|
||||
// for (i = 0; i < 4; i++) {
|
||||
// s32 div = 0;
|
||||
// s32 next = i + 1;
|
||||
// register s32* unk_temp asm("r0");
|
||||
|
||||
// register UNUSED size_t unk_offs asm("r3") = i << 2;
|
||||
// unk_temp = (s32*)0x81097B0;
|
||||
// next = i + 1;
|
||||
// if (a1 >= unk_temp[i]) {
|
||||
// register s32 *temp_81097B0 asm("r2") = (s32*)0x81097B0;
|
||||
// u32 _i = i;
|
||||
// s32 diff;
|
||||
// do {
|
||||
// // correct other than register usage
|
||||
// diff = temp_81097B0[_i];
|
||||
// a1 -= diff;
|
||||
// div++;
|
||||
// } while (a1 >= diff);
|
||||
// }
|
||||
|
||||
// if (div > 9) {
|
||||
// div = 9;
|
||||
// }
|
||||
// // /correct
|
||||
|
||||
// if (!div && !cond) {
|
||||
// if (a3) {
|
||||
// *a2++ = 96;
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// u8 temp;
|
||||
// if (div) {
|
||||
// u32 offs;
|
||||
|
||||
// cond = 1;
|
||||
// offs = 2 * div;
|
||||
// *a2++ = ((u8*)0x81097C4)[offs];
|
||||
// temp = ((u8*)0x81097C5)[offs];
|
||||
// }
|
||||
// else {
|
||||
// *a2++ = ((u8*)0x81097C4)[0];
|
||||
// temp = ((u8*)0x81097C5)[0];
|
||||
// }
|
||||
|
||||
// *a2++ = temp;
|
||||
// j++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// *a2++ = ((u8*)0x81097C4)[2 * a1];
|
||||
// *a2++ = ((u8*)0x81097C5)[2 * a1];
|
||||
// *a2 = 0;
|
||||
// return j + 1;
|
||||
// }
|
||||
|
||||
void FillInventoryGaps()
|
||||
{
|
||||
|
|
@ -34,27 +100,27 @@ void FillInventoryGaps()
|
|||
|
||||
do {
|
||||
// effectively just a while loop
|
||||
if ((slot_checking < 20) && !(slot_checking[gTeamInventory_203B460->teamItems].unk0 & 1)) {
|
||||
// find next empty slot
|
||||
do {
|
||||
slot_checking++;
|
||||
} while ((slot_checking < 20) && !(slot_checking[gTeamInventory_203B460->teamItems].unk0 & 1));
|
||||
if ((slot_checking < INVENTORY_SIZE) && !(slot_checking[gTeamInventory_203B460->teamItems].unk0 & 1)) {
|
||||
// find next empty slot
|
||||
do {
|
||||
slot_checking++;
|
||||
} while ((slot_checking < INVENTORY_SIZE) && !(slot_checking[gTeamInventory_203B460->teamItems].unk0 & 1));
|
||||
}
|
||||
|
||||
if (slot_checking == 20) {
|
||||
break;
|
||||
if (slot_checking == INVENTORY_SIZE) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (slot_checking > last_filled) {
|
||||
// shift it down
|
||||
gTeamInventory_203B460->teamItems[last_filled] = gTeamInventory_203B460->teamItems[slot_checking];
|
||||
// shift it down
|
||||
gTeamInventory_203B460->teamItems[last_filled] = gTeamInventory_203B460->teamItems[slot_checking];
|
||||
}
|
||||
slot_checking++;
|
||||
last_filled++;
|
||||
} while (1);
|
||||
|
||||
// clear out the rest of the slots
|
||||
for (; last_filled < 20; last_filled++) {
|
||||
for (; last_filled < INVENTORY_SIZE; last_filled++) {
|
||||
struct ItemSlot *slot;
|
||||
#ifdef NONMATCHING
|
||||
slot = &gTeamInventory_203B460->teamItems[last_filled];
|
||||
|
|
@ -70,9 +136,10 @@ void FillInventoryGaps()
|
|||
}
|
||||
}
|
||||
|
||||
s32 FindItemInInventory(u8 itemIndex) {
|
||||
s32 FindItemInInventory(u8 itemIndex)
|
||||
{
|
||||
s32 i;
|
||||
for (i = 0; i < 20; i++) {
|
||||
for (i = 0; i < INVENTORY_SIZE; i++) {
|
||||
if ((gTeamInventory_203B460->teamItems[i].unk0 & 1) && (gTeamInventory_203B460->teamItems[i].itemIndex == itemIndex)) {
|
||||
return i;
|
||||
}
|
||||
|
|
@ -85,7 +152,7 @@ s32 GetItemCountInInventory(u8 _itemIndex)
|
|||
#ifdef NONMATCHING
|
||||
s32 count = 0;
|
||||
s32 i;
|
||||
for (i = 0; i < 20; i++) {
|
||||
for (i = 0; i < INVENTORY_SIZE; i++) {
|
||||
if ((gTeamInventory_203B460->teamItems[i].unk0 & 1) && (gTeamInventory_203B460->teamItems[i].itemIndex == _itemIndex)) {
|
||||
count++;
|
||||
}
|
||||
|
|
@ -114,42 +181,20 @@ s32 GetItemCountInInventory(u8 _itemIndex)
|
|||
|
||||
s32 GetItemPossessionCount(u8 itemIndex)
|
||||
{
|
||||
#ifdef NONMATCHING
|
||||
s32 item_count = GetItemCountInInventory(itemIndex);
|
||||
s32 i = 0;
|
||||
|
||||
struct unkStruct_203B45C *_gRecruitedPokemonRef = gRecruitedPokemonRef;
|
||||
for (i = 0; i < NUM_SPECIES; i++) {
|
||||
struct PokemonStruct* pokemon = &_gRecruitedPokemonRef->pokemon[i];
|
||||
if ((pokemon->unk0 & 1)
|
||||
&& ((pokemon->unk0 >> 1) & 1)
|
||||
&& (pokemon->itemIndexHeld != ITEM_ID_NOTHING)
|
||||
&& (pokemon->itemIndexHeld == itemIndex)) {
|
||||
item_count++;
|
||||
}
|
||||
}
|
||||
return item_count;
|
||||
#else
|
||||
// hacky stuff again to fix order of operands in & at bottom bit
|
||||
s32 item_count = GetItemCountInInventory(itemIndex);
|
||||
s32 i = 0;
|
||||
|
||||
struct unkStruct_203B45C *_gRecruitedPokemonRef = gRecruitedPokemonRef;
|
||||
register s32 one_mask asm("r6") = 1;
|
||||
for (i = 0; i < NUM_SPECIES; i++) {
|
||||
struct PokemonStruct* pokemon = &_gRecruitedPokemonRef->pokemon[i];
|
||||
register int bottom_bit asm("r0") = one_mask;
|
||||
bottom_bit &= pokemon->unk0;
|
||||
|
||||
if (bottom_bit
|
||||
&& ((pokemon->unk0 >> 1) & one_mask)
|
||||
&& (pokemon->itemIndexHeld != ITEM_ID_NOTHING)
|
||||
&& (pokemon->itemIndexHeld == itemIndex)) {
|
||||
struct PokemonStruct* pokemon = &_gRecruitedPokemonRef->pokemon[i];
|
||||
if ((1 & pokemon->unk0)
|
||||
&& ((pokemon->unk0 >> 1) % 2)
|
||||
&& (pokemon->itemIndexHeld != ITEM_ID_NOTHING)
|
||||
&& (pokemon->itemIndexHeld == itemIndex)) {
|
||||
item_count++;
|
||||
}
|
||||
}
|
||||
return item_count;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ShiftItemsDownFrom(s32 start)
|
||||
|
|
@ -188,7 +233,7 @@ bool8 AddItemToInventory(const struct ItemSlot* slot)
|
|||
s32 i;
|
||||
|
||||
// try to add item to inventory, return 1 if failed
|
||||
for (i = 0; i < 20; i++) {
|
||||
for (i = 0; i < INVENTORY_SIZE; i++) {
|
||||
UNUSED struct ItemSlot* current = &gTeamInventory_203B460->teamItems[i];
|
||||
if (!(i[gTeamInventory_203B460->teamItems].unk0 & 1)) {
|
||||
gTeamInventory_203B460->teamItems[i] = *slot;
|
||||
|
|
@ -198,7 +243,6 @@ bool8 AddItemToInventory(const struct ItemSlot* slot)
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void ConvertMoneyItemToMoney()
|
||||
{
|
||||
s32 i = 0;
|
||||
|
|
@ -217,7 +261,7 @@ void ConvertMoneyItemToMoney()
|
|||
current_slot->numItems = 0;
|
||||
current_slot->unk0 = 0;
|
||||
}
|
||||
} while (++i < 20);
|
||||
} while (++i < INVENTORY_SIZE);
|
||||
FillInventoryGaps();
|
||||
|
||||
i = 0;
|
||||
|
|
@ -233,7 +277,7 @@ void ConvertMoneyItemToMoney()
|
|||
s32 j;
|
||||
|
||||
// find next lowest
|
||||
for (j = next; j < 20; j++) {
|
||||
for (j = next; j < INVENTORY_SIZE; j++) {
|
||||
UNUSED size_t offs = offsetof(struct TeamInventory, teamItems[j]);
|
||||
if ((j[gTeamInventory_203B460->teamItems].unk0 & 1) && (lowest_order > GetItemOrder(gTeamInventory_203B460->teamItems[j].itemIndex))) {
|
||||
lowest_index = j;
|
||||
|
|
@ -248,7 +292,7 @@ void ConvertMoneyItemToMoney()
|
|||
gTeamInventory_203B460->teamItems[lowest_index] = current;
|
||||
}
|
||||
}
|
||||
} while (++i < 20);
|
||||
} while (++i < INVENTORY_SIZE);
|
||||
FillInventoryGaps();
|
||||
}
|
||||
|
||||
|
|
@ -410,4 +454,197 @@ u32 GetMoneyValue(struct ItemSlot* slot)
|
|||
u32 GetMoneyValue2(struct ItemSlot* slot)
|
||||
{
|
||||
return gUnknown_810A3F0[slot->numItems];
|
||||
}
|
||||
|
||||
void GetGummiItemStatBoost(struct PokemonStruct* pokemon, u8 itemIndex, u8 a3, struct unkStruct_80915F4* a4)
|
||||
{
|
||||
// item stat buff?
|
||||
s8 result;
|
||||
|
||||
a4->unk0 = (u16)-1;
|
||||
a4->unk2 = 0;
|
||||
result = IsGummiItem(itemIndex);
|
||||
if (result) {
|
||||
u8 pokemon_type_0 = GetPokemonType(pokemon->speciesNum, 0);
|
||||
u8 pokemon_type_1 = GetPokemonType(pokemon->speciesNum, 1);
|
||||
u32 gummi_index = itemIndex - ITEM_ID_WHITE_GUMMI + 1;
|
||||
s32 value0;
|
||||
s32 value1;
|
||||
s32 diff;
|
||||
u16 boost_amount;
|
||||
|
||||
value0 = gTypeGummiIQBoost[pokemon_type_0][gummi_index];
|
||||
value1 = gTypeGummiIQBoost[pokemon_type_1][gummi_index];
|
||||
diff = (s16)pokemon->IQ;
|
||||
|
||||
pokemon->IQ += value0 + value1;
|
||||
diff = (s16)pokemon->IQ - diff;
|
||||
if ((s16)pokemon->IQ <= 0) {
|
||||
pokemon->IQ = 1;
|
||||
}
|
||||
if ((s16)pokemon->IQ > 999) {
|
||||
pokemon->IQ = 999;
|
||||
}
|
||||
|
||||
boost_amount = 0;
|
||||
if (diff <= 8) {
|
||||
boost_amount = 1;
|
||||
if (diff <= 4) {
|
||||
boost_amount = 3;
|
||||
if (diff > 2) {
|
||||
boost_amount = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
a4->unk0 = boost_amount;
|
||||
if (!a3) {
|
||||
u16 boost_flags;
|
||||
if (!boost_amount && RandomCapped(16) == 10) {
|
||||
// supa gummi (all stats boost)
|
||||
boost_flags = 0xf;
|
||||
}
|
||||
else {
|
||||
s32 random_index = RandomCapped(4);
|
||||
u16* table = &gGummiStatBoostLUT;
|
||||
boost_flags = table[random_index];
|
||||
}
|
||||
|
||||
a4->unk2 = boost_flags;
|
||||
boost_flags = a4->unk2;
|
||||
if (a4->unk2 & 1) {
|
||||
if (pokemon->pokeAtt < 0xffu) {
|
||||
pokemon->pokeAtt++;
|
||||
}
|
||||
else {
|
||||
// fix operand order
|
||||
u16 unk2 = a4->unk2;
|
||||
unk2 &= ~1;
|
||||
a4->unk2 &= unk2;
|
||||
}
|
||||
}
|
||||
if (a4->unk2 & 2) {
|
||||
if (pokemon->pokeSPAtt < 0xffu) {
|
||||
pokemon->pokeSPAtt++;
|
||||
}
|
||||
else {
|
||||
a4->unk2 &= ~2;
|
||||
}
|
||||
}
|
||||
if (a4->unk2 & 4) {
|
||||
if (pokemon->pokeDef < 0xffu) {
|
||||
pokemon->pokeDef++;
|
||||
}
|
||||
else {
|
||||
a4->unk2 &= ~4;
|
||||
}
|
||||
}
|
||||
if (a4->unk2 & 8) {
|
||||
if (pokemon->pokeSPDef < 0xffu) {
|
||||
pokemon->pokeSPDef++;
|
||||
}
|
||||
else {
|
||||
a4->unk2 &= ~8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool8 IsGummiItem(u8 itemIndex)
|
||||
{
|
||||
if (itemIndex < ITEM_ID_WHITE_GUMMI) {
|
||||
return 0;
|
||||
}
|
||||
if (itemIndex > ITEM_ID_SILVER_GUMMI) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool8 HasGummiItem()
|
||||
{
|
||||
s32 i;
|
||||
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 0;
|
||||
}
|
||||
|
||||
void MoveToStorage(struct ItemSlot* slot)
|
||||
{
|
||||
if (IsThrowableItem(slot->itemIndex)) {
|
||||
gTeamInventory_203B460->teamStorage[slot->itemIndex] += slot->numItems;
|
||||
}
|
||||
else {
|
||||
gTeamInventory_203B460->teamStorage[slot->itemIndex]++;
|
||||
}
|
||||
|
||||
if (gTeamInventory_203B460->teamStorage[slot->itemIndex] > 999) {
|
||||
gTeamInventory_203B460->teamStorage[slot->itemIndex] = 999;
|
||||
}
|
||||
}
|
||||
|
||||
s32 xxx_count_inv_unk230()
|
||||
{
|
||||
s32 i;
|
||||
s32 counter = 0;
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (gTeamInventory_203B460->unk230[i].unk0) {
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
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->unk0 = 0;
|
||||
unk230->unk1 = 0;
|
||||
}
|
||||
|
||||
struct subStruct_203B460* sub_809185C(u8 i)
|
||||
{
|
||||
return &gTeamInventory_203B460->unk230[i & 0xff];
|
||||
}
|
||||
|
||||
void xxx_fill_unk230_gaps()
|
||||
{
|
||||
// fill unk230 gaps
|
||||
// basically the same as FillInventoryGaps
|
||||
s32 slot_checking = 0;
|
||||
s32 last_filled = 0;
|
||||
|
||||
do {
|
||||
// effectively just a while loop
|
||||
if ((slot_checking < 8) && !gTeamInventory_203B460->unk230[slot_checking].unk0) {
|
||||
do {
|
||||
// find next empty slot
|
||||
slot_checking++;
|
||||
} while ((slot_checking < 8) && !gTeamInventory_203B460->unk230[slot_checking].unk0);
|
||||
}
|
||||
|
||||
if (slot_checking == 8) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (slot_checking > last_filled) {
|
||||
// shift it down
|
||||
gTeamInventory_203B460->unk230[last_filled] = gTeamInventory_203B460->unk230[slot_checking];
|
||||
}
|
||||
slot_checking++;
|
||||
last_filled++;
|
||||
} while (1);
|
||||
|
||||
// clear out the rest of the slots
|
||||
for (; last_filled < 8; last_filled++) {
|
||||
xxx_init_unk230_substruct(last_filled);
|
||||
}
|
||||
}
|
||||
|
|
@ -444,10 +444,10 @@ void sub_8018100(void)
|
|||
case 12:
|
||||
gUnknown_203B20C->unkD0 = 2;
|
||||
gUnknown_203B20C->unkC8 = 1;
|
||||
if(gTeamInventory_203B460->unk50[gUnknown_203B20C->unk8.itemIndex] > 99)
|
||||
if(gTeamInventory_203B460->teamStorage[gUnknown_203B20C->unk8.itemIndex] > 99)
|
||||
gUnknown_203B20C->unkCC = 99;
|
||||
else
|
||||
gUnknown_203B20C->unkCC = gTeamInventory_203B460->unk50[gUnknown_203B20C->unk8.itemIndex];
|
||||
gUnknown_203B20C->unkCC = gTeamInventory_203B460->teamStorage[gUnknown_203B20C->unk8.itemIndex];
|
||||
gUnknown_203B20C->unkC4 = gUnknown_203B20C->unkCC;
|
||||
gUnknown_203B20C->unkD4 = 1;
|
||||
gUnknown_203B20C->unkD8 = &gUnknown_203B20C->unkF0[1];
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ extern struct TeamInventory *gTeamInventory_203B460;
|
|||
|
||||
extern u32 GetStackSellPrice(struct ItemSlot *);
|
||||
extern bool8 CanSellItem(u8);
|
||||
extern u32 sub_8091814(void);
|
||||
extern u32 xxx_count_inv_unk230(void);
|
||||
extern u32 sub_8091A48(void);
|
||||
extern s32 sub_80144A4(s32 *);
|
||||
void UpdateKecleonStoreState(u32);
|
||||
|
|
@ -168,7 +168,7 @@ void sub_8019D68(void)
|
|||
u32 sub_8019D8C(void)
|
||||
{
|
||||
if(gUnknown_203B210->unk4)
|
||||
return sub_8091814();
|
||||
return xxx_count_inv_unk230();
|
||||
else
|
||||
return sub_8091A48();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -378,7 +378,7 @@ void sub_80371B8(void)
|
|||
if ((((gUnknown_203B35C->unk4 != 0) &&(gUnknown_203B35C->unk0 == 0)) &&
|
||||
(pbVar2 = sub_8035D94(), pbVar2->unk0 != 0)) && (pbVar2->unk4 != 0)) {
|
||||
// We received something..
|
||||
gTeamInventory_203B460->unk50[pbVar2->unk0] += pbVar2->unk4;
|
||||
gTeamInventory_203B460->teamStorage[pbVar2->unk0] += pbVar2->unk4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -351,9 +351,9 @@ void TradeItem_SendItemConfirm(void)
|
|||
case 5:
|
||||
sub_801CBB8();
|
||||
// Used temp var to get correct statements
|
||||
load = gTeamInventory_203B460->unk50[gTradeItemsMenu->itemToSend.itemIndex];
|
||||
load = gTeamInventory_203B460->teamStorage[gTradeItemsMenu->itemToSend.itemIndex];
|
||||
load -= gTradeItemsMenu->numItemsToSend;
|
||||
gTeamInventory_203B460->unk50[gTradeItemsMenu->itemToSend.itemIndex] = load;
|
||||
gTeamInventory_203B460->teamStorage[gTradeItemsMenu->itemToSend.itemIndex] = load;
|
||||
SetTradeItemMenu(TRADE_ITEMS_PREPARE_TRADE_SAVING);
|
||||
PrepareSavePakWrite(SPECIES_NONE);
|
||||
break;
|
||||
|
|
@ -450,9 +450,9 @@ void TradeItem_AddItem(void)
|
|||
{
|
||||
// Use temp var to get correct statements
|
||||
u16 load;
|
||||
load = gTeamInventory_203B460->unk50[gTradeItemsMenu->sentItem.itemIndex];
|
||||
load = gTeamInventory_203B460->teamStorage[gTradeItemsMenu->sentItem.itemIndex];
|
||||
load += gTradeItemsMenu->sentItem.numItems;
|
||||
gTeamInventory_203B460->unk50[gTradeItemsMenu->sentItem.itemIndex] = load;
|
||||
gTeamInventory_203B460->teamStorage[gTradeItemsMenu->sentItem.itemIndex] = load;
|
||||
}
|
||||
|
||||
void sub_80369FC(void)
|
||||
|
|
@ -1082,7 +1082,7 @@ void sub_8036F30(void)
|
|||
void sub_8036F74(void)
|
||||
{
|
||||
sub_8006518(gTradeItemsMenu->unk184);
|
||||
sub_8036ECC(2, gTeamInventory_203B460->unk50[gTradeItemsMenu->itemToSend.itemIndex]);
|
||||
sub_8036ECC(2, gTeamInventory_203B460->teamStorage[gTradeItemsMenu->itemToSend.itemIndex]);
|
||||
sub_801CCD8();
|
||||
sub_8035CF4(&gTradeItemsMenu->unk44, 3, 0);
|
||||
sub_8036F30();
|
||||
|
|
|
|||
|
|
@ -2007,7 +2007,7 @@ void sub_802A798(void)
|
|||
{
|
||||
return_var->unk20 = gUnknown_203B2C4->unk41C;
|
||||
}
|
||||
gTeamInventory_203B460->unk50[gUnknown_203B2C4->unk41C.itemIndex]--;
|
||||
gTeamInventory_203B460->teamStorage[gUnknown_203B2C4->unk41C.itemIndex]--;
|
||||
sub_802B2BC(0x29);
|
||||
break;
|
||||
case 8:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user