Complete Gulpin Shop

This commit is contained in:
Kermalis 2023-07-15 13:49:36 -04:00
parent b2b62e9705
commit 1159ba9a3e
6 changed files with 228 additions and 488 deletions

View File

@ -1,392 +0,0 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start sub_801EA28
sub_801EA28:
push {r4,r5,lr}
sub sp, 0x14
ldr r1, _0801EA44
ldr r0, [r1]
ldr r0, [r0, 0x4]
adds r4, r1, 0
cmp r0, 0x4
bls _0801EA3A
b _0801EBB8
_0801EA3A:
lsls r0, 2
ldr r1, _0801EA48
adds r0, r1
ldr r0, [r0]
mov pc, r0
.align 2, 0
_0801EA44: .4byte gUnknown_203B26C
_0801EA48: .4byte _0801EA4C
.align 2, 0
_0801EA4C:
.4byte _0801EA60
.4byte _0801EA80
.4byte _0801EA8A
.4byte _0801EAB4
.4byte _0801EACA
_0801EA60:
ldr r0, [r4]
movs r2, 0xC
ldrsh r1, [r0, r2]
ldr r2, [r0, 0x10]
ldr r0, _0801EA7C
str r0, [sp]
movs r0, 0
str r0, [sp, 0x4]
movs r0, 0x2
movs r3, 0
bl sub_801EE10
b _0801EBB8
.align 2, 0
_0801EA7C: .4byte gUnknown_80DC164
_0801EA80:
movs r0, 0x1
movs r1, 0
bl sub_801F1B0
b _0801EBB8
_0801EA8A:
movs r0, 0
bl sub_801F280
ldr r0, _0801EAB0
ldr r2, [r0]
adds r0, r2, 0
adds r0, 0x78
adds r1, r2, 0
adds r1, 0x28
adds r3, r2, 0
adds r3, 0x68
ldr r2, [r2, 0x24]
str r2, [sp]
movs r2, 0x2
str r2, [sp, 0x4]
movs r2, 0
bl sub_8012D60
b _0801EBB8
.align 2, 0
_0801EAB0: .4byte gUnknown_203B26C
_0801EAB4:
ldr r2, [r4]
ldr r0, [r2, 0x20]
ldr r1, [r2, 0x10]
adds r2, 0x14
bl GetLinkedSequence
ldr r0, [r4]
adds r0, 0x14
bl sub_801F808
b _0801EBB8
_0801EACA:
bl sub_801EC7C
ldr r4, _0801EAF8
ldr r5, _0801EAFC
ldr r0, [r5]
ldrh r1, [r0, 0x1C]
adds r0, r4, 0
bl sub_8092C84
adds r4, 0x50
ldr r0, [r5]
ldrh r1, [r0, 0x1E]
adds r0, r4, 0
bl sub_8092C84
ldr r2, [r5]
ldr r3, [r2]
cmp r3, 0x1
bls _0801EB00
cmp r3, 0x2
beq _0801EB68
b _0801EBB8
.align 2, 0
_0801EAF8: .4byte gAvailablePokemonNames
_0801EAFC: .4byte gUnknown_203B26C
_0801EB00:
ldrb r4, [r2, 0xE]
cmp r4, 0
beq _0801EB38
ldr r1, _0801EB34
movs r0, 0x64
muls r0, r3
adds r1, 0x30
adds r0, r1
ldr r0, [r0]
adds r3, r2, 0
adds r3, 0x28
adds r1, r2, 0
adds r1, 0x68
str r1, [sp]
movs r1, 0x4
str r1, [sp, 0x4]
movs r1, 0
str r1, [sp, 0x8]
movs r4, 0x94
lsls r4, 1
adds r1, r2, r4
ldr r1, [r1]
str r1, [sp, 0xC]
movs r1, 0xC
b _0801EB86
.align 2, 0
_0801EB34: .4byte gGulpinDialogue
_0801EB38:
ldr r1, _0801EB64
movs r0, 0x64
muls r0, r3
adds r1, 0x2C
adds r0, r1
ldr r0, [r0]
adds r3, r2, 0
adds r3, 0x28
adds r1, r2, 0
adds r1, 0x68
str r1, [sp]
movs r1, 0x4
str r1, [sp, 0x4]
str r4, [sp, 0x8]
movs r4, 0x94
lsls r4, 1
adds r1, r2, r4
ldr r1, [r1]
str r1, [sp, 0xC]
movs r1, 0xC
b _0801EB86
.align 2, 0
_0801EB64: .4byte gGulpinDialogue
_0801EB68:
ldrb r4, [r2, 0xE]
cmp r4, 0
beq _0801EB98
ldr r0, _0801EB94
adds r3, r2, 0
adds r3, 0x28
adds r1, r2, 0
adds r1, 0x68
str r1, [sp]
movs r1, 0x4
str r1, [sp, 0x4]
movs r1, 0
str r1, [sp, 0x8]
str r1, [sp, 0xC]
movs r1, 0x20
_0801EB86:
str r1, [sp, 0x10]
movs r1, 0
movs r2, 0x5
bl sub_8014248
b _0801EBB8
.align 2, 0
_0801EB94: .4byte gUnknown_80DC1A0
_0801EB98:
ldr r0, _0801EBC0
adds r3, r2, 0
adds r3, 0x28
adds r1, r2, 0
adds r1, 0x68
str r1, [sp]
movs r1, 0x4
str r1, [sp, 0x4]
str r4, [sp, 0x8]
str r4, [sp, 0xC]
movs r1, 0x20
str r1, [sp, 0x10]
movs r1, 0
movs r2, 0x5
bl sub_8014248
_0801EBB8:
add sp, 0x14
pop {r4,r5}
pop {r0}
bx r0
.align 2, 0
_0801EBC0: .4byte gUnknown_80DC1FC
thumb_func_end sub_801EA28
thumb_func_start sub_801EBC4
sub_801EBC4:
push {r4,r5,lr}
movs r5, 0
ldr r4, _0801EC48
ldr r0, [r4]
adds r0, 0x68
movs r1, 0
movs r2, 0x10
bl MemoryFill16
ldr r1, [r4]
ldr r0, _0801EC4C
str r0, [r1, 0x28]
movs r0, 0x2
str r0, [r1, 0x2C]
ldrh r0, [r1, 0x1E]
ldr r1, [r1, 0x10]
bl IsAnyMoveLinked
lsls r0, 24
cmp r0, 0
beq _0801EBF6
ldr r0, [r4]
ldr r0, [r0, 0x20]
cmp r0, 0x3
ble _0801EBFE
_0801EBF6:
ldr r0, [r4]
adds r0, 0x68
movs r1, 0x1
strh r1, [r0]
_0801EBFE:
adds r5, 0x1
ldr r4, _0801EC48
ldr r0, [r4]
mov r12, r0
lsls r1, r5, 3
mov r3, r12
adds r3, 0x28
adds r2, r3, r1
ldr r0, _0801EC50
ldr r0, [r0]
str r0, [r2]
mov r2, r12
adds r2, 0x2C
adds r1, r2, r1
movs r0, 0x3
str r0, [r1]
adds r5, 0x1
lsls r1, r5, 3
adds r3, r1
movs r0, 0
str r0, [r3]
adds r2, r1
movs r0, 0x1
str r0, [r2]
movs r3, 0
cmp r3, r5
bge _0801EC76
mov r0, r12
adds r0, 0x68
ldrh r0, [r0]
cmp r0, 0
bne _0801EC54
mov r1, r12
ldr r0, [r1, 0x2C]
str r0, [r1, 0x24]
b _0801EC76
.align 2, 0
_0801EC48: .4byte gUnknown_203B26C
_0801EC4C: .4byte gUnknown_80DC230
_0801EC50: .4byte gUnknown_80D4970
_0801EC54:
adds r3, 0x1
cmp r3, r5
bge _0801EC76
ldr r2, [r4]
lsls r0, r3, 1
adds r1, r2, 0
adds r1, 0x68
adds r1, r0
ldrh r0, [r1]
cmp r0, 0
bne _0801EC54
lsls r0, r3, 3
adds r1, r2, 0
adds r1, 0x2C
adds r1, r0
ldr r0, [r1]
str r0, [r2, 0x24]
_0801EC76:
pop {r4,r5}
pop {r0}
bx r0
thumb_func_end sub_801EBC4
thumb_func_start sub_801EC7C
sub_801EC7C:
push {r4,lr}
ldr r4, _0801ECB0
ldr r0, [r4]
adds r0, 0x68
movs r1, 0
movs r2, 0x10
bl MemoryFill16
ldr r1, [r4]
movs r3, 0
ldr r0, _0801ECB4
ldr r0, [r0]
str r0, [r1, 0x28]
movs r0, 0x4
str r0, [r1, 0x2C]
movs r2, 0x1
ldr r0, _0801ECB8
ldr r0, [r0]
str r0, [r1, 0x30]
movs r0, 0x5
str r0, [r1, 0x34]
str r3, [r1, 0x38]
str r2, [r1, 0x3C]
pop {r4}
pop {r0}
bx r0
.align 2, 0
_0801ECB0: .4byte gUnknown_203B26C
_0801ECB4: .4byte gUnknown_80D4920
_0801ECB8: .4byte gUnknown_80D4928
thumb_func_end sub_801EC7C
thumb_func_start sub_801ECBC
sub_801ECBC:
push {lr}
movs r0, 0x1
bl sub_801EF38
cmp r0, 0x3
beq _0801ECD8
cmp r0, 0x3
bhi _0801ECD2
cmp r0, 0x2
beq _0801ED18
b _0801ED22
_0801ECD2:
cmp r0, 0x4
beq _0801ECF8
b _0801ED22
_0801ECD8:
bl sub_801F194
ldr r1, _0801ECF4
ldr r2, [r1]
str r0, [r2, 0x20]
ldr r1, [r2, 0x10]
lsls r0, 3
adds r1, r0
ldrh r0, [r1, 0x2]
strh r0, [r2, 0x1E]
movs r0, 0x2
bl UpdateGulpinShopState
b _0801ED22
.align 2, 0
_0801ECF4: .4byte gUnknown_203B26C
_0801ECF8:
bl sub_801F194
ldr r1, _0801ED14
ldr r2, [r1]
str r0, [r2, 0x20]
ldr r1, [r2, 0x10]
lsls r0, 3
adds r1, r0
ldrh r0, [r1, 0x2]
strh r0, [r2, 0x1E]
movs r0, 0x3
bl UpdateGulpinShopState
b _0801ED22
.align 2, 0
_0801ED14: .4byte gUnknown_203B26C
_0801ED18:
bl sub_801F214
movs r0, 0x6
bl UpdateGulpinShopState
_0801ED22:
pop {r0}
bx r0
thumb_func_end sub_801ECBC
.align 2,0

View File

@ -5,13 +5,12 @@ struct unkStruct_203B26C
{
// size: 0x18C
u32 unk0;
s32 state;
/* 0x4 */ s32 state;
u32 unk8;
s16 speciesNum; // species of chosen Pokemon
bool8 isNextMoveLinked;
struct Move * moves;
u32 unk14;
u32 unk18;
/* 0xC */ s16 speciesNum; // species of chosen Pokemon
/* 0xE */ bool8 isNextMoveLinked;
/* 0x10 */ struct Move * moves;
u16 unk14[4];
u16 unk1C;
u16 unk1E;
u32 unk20;
@ -22,7 +21,7 @@ struct unkStruct_203B26C
u8 fillC8[0x118 - 0xC8];
/* 0x118 */ struct OpenedFile *faceFile;
/* 0x11C */ u8 *faceData;
/* 0x120 */ u16 unk120;
u16 unk120;
u16 unk122;
u8 unk124;
u8 unk125;

View File

@ -31,6 +31,9 @@ bool8 FailsWhileMuzzled(u16 moveID);
bool8 IsSoundMove(struct Move *move);
bool8 DoesMoveCharge(u16 move);
bool8 IsAnyMoveLinked(int unused, struct Move* moves);
bool8 IsNextMoveLinked(int index, struct Move* moves);
void RemoveLinkSequenceFromMoves8(struct Move* moves, int index);
int GetLinkedSequence(int index, struct Move* moves, u16* sequenceMoveIDs);
void unk_CopyMoves4To8(struct Move* destMoves, struct Move* srcMoves);
void sub_8094060(struct Move* srcMoves, struct Move* destMoves);

View File

@ -116,8 +116,6 @@ SECTIONS {
src/options_menu.o(.text);
src/hints_menu.o(.text);
src/gulpin_shop.o(.text);
asm/gulpin_shop.o(.text);
src/gulpin_shop_1.o(.text);
src/code_801EE10.o(.text);
asm/code_801EE10.o(.text);
src/code_801EE10_mid.o(.text);

View File

@ -2,6 +2,7 @@
#include "file_system.h"
#include "pokemon.h"
#include "memory.h"
#include "moves.h"
#include "text.h"
#include "input.h"
#include "menu.h"
@ -11,15 +12,37 @@
extern struct unkStruct_203B26C *gUnknown_203B26C;
extern const struct UnkTextStruct2 gUnknown_80DC11C;
extern const struct UnkTextStruct2 gUnknown_80DC134;
extern const u8 *gUnknown_80D4920[];
extern const u8 *gUnknown_80D4928[];
extern const u8 *gUnknown_80D4970[];
extern const u8 *gUnknown_80DC164[];
extern const u8 gUnknown_80DC1A0[];
extern const u8 gUnknown_80DC1FC[];
extern const u8 gUnknown_80DC230[];
extern u8 gAvailablePokemonNames[0x50 * 2];
extern const u8 *gGulpinDialogue[2][25];
extern void UpdateGulpinShopState(u32);
extern void sub_801ECBC();
extern void sub_801ED28();
extern void sub_801EDA4();
extern void sub_801EDC0();
extern void sub_801E980();
extern void sub_801EA28();
extern void sub_801EBC4();
extern void sub_8014248(const u8 *, u32, u32, const struct MenuItem *, void *, u32, u32, struct OpenedFile **, u32);
extern u32 sub_80144A4(s32 *);
void sub_801EC7C(void);
void sub_801ECBC(void);
void sub_801ED28(void);
void sub_801EDA4(void);
void sub_801EDC0(void);
void sub_801E980(void);
void sub_801EA28(void);
void sub_801EBC4(void);
extern void sub_801EE10(u32, s16, struct Move *, u32, void *, u32);
extern u32 sub_801EF38(u32);
extern u32 sub_801F194(void);
extern void sub_801F1B0(u32, u32);
extern void sub_801F214(void);
extern void sub_801F280(u32);
extern void sub_801F808(u16 *);
extern u32 sub_801F890(void);
extern void sub_801F8D0(void);
extern void PlaySound(u32);
void UpdateGulpinShopState(u32);
u32 DisplayGulpinDialogueSprite(s32 param_1,s16 pokeSpecies,struct Move *param_3)
{
@ -126,3 +149,191 @@ void sub_801E980(void)
ResetUnusedInputStruct();
sub_800641C(gUnknown_203B26C->unk12C, 1, 1);
}
void sub_801EA28(void) {
switch(gUnknown_203B26C->state) {
case 0:
sub_801EE10(2, gUnknown_203B26C->speciesNum, gUnknown_203B26C->moves, 0, &gUnknown_80DC164, 0);
break;
case 1:
sub_801F1B0(1, 0);
break;
case 2:
sub_801F280(0);
sub_8012D60(&gUnknown_203B26C->unk78, gUnknown_203B26C->unk28, 0, gUnknown_203B26C->unk68, gUnknown_203B26C->unk24, 2);
break;
case 3:
GetLinkedSequence(gUnknown_203B26C->unk20, gUnknown_203B26C->moves, &gUnknown_203B26C->unk14[0]);
sub_801F808(&gUnknown_203B26C->unk14[0]);
break;
case 4:
sub_801EC7C();
sub_8092C84(gAvailablePokemonNames, gUnknown_203B26C->unk1C);
sub_8092C84(&gAvailablePokemonNames[0x50], gUnknown_203B26C->unk1E);
switch (gUnknown_203B26C->unk0) {
case 0:
case 1:
if (gUnknown_203B26C->isNextMoveLinked) {
sub_8014248(gGulpinDialogue[gUnknown_203B26C->unk0][12], 0, 5, &gUnknown_203B26C->unk28[0],
&gUnknown_203B26C->unk68, 4, 0, gUnknown_203B26C->unk128, 12); // Forget the move and any moves linked to it and learn?
}
else {
sub_8014248(gGulpinDialogue[gUnknown_203B26C->unk0][11], 0, 5, &gUnknown_203B26C->unk28[0],
&gUnknown_203B26C->unk68, 4, 0, gUnknown_203B26C->unk128, 12); // Forget the move and learn?
}
break;
case 2:
if (gUnknown_203B26C->isNextMoveLinked)
sub_8014248(gUnknown_80DC1A0, 0, 5, &gUnknown_203B26C->unk28[0],
&gUnknown_203B26C->unk68, 4, 0, NULL, 32);
else
sub_8014248(gUnknown_80DC1FC, 0, 5, &gUnknown_203B26C->unk28[0],
&gUnknown_203B26C->unk68, 4, 0, NULL, 32);
break;
}
break;
}
}
void sub_801EBC4(void) {
s32 which;
s32 i;
which = 0;
MemoryFill16(&gUnknown_203B26C->unk68[0], 0, sizeof(gUnknown_203B26C->unk68));
gUnknown_203B26C->unk28[which].text = gUnknown_80DC230; // "Forget"
gUnknown_203B26C->unk28[which].menuAction = 2;
if (!IsAnyMoveLinked(gUnknown_203B26C->unk1E, gUnknown_203B26C->moves)
|| (s32)gUnknown_203B26C->unk20 >= 4) {
gUnknown_203B26C->unk68[0] = 1;
}
which++;
gUnknown_203B26C->unk28[which].text = *gUnknown_80D4970; // "Info"
gUnknown_203B26C->unk28[which].menuAction = 3;
which++;
gUnknown_203B26C->unk28[which].text = NULL;
gUnknown_203B26C->unk28[which].menuAction = 1;
i = 0;
if (i < which) {
if (gUnknown_203B26C->unk68[0] == 0) {
gUnknown_203B26C->unk24 = gUnknown_203B26C->unk28[0].menuAction;
}
else {
while (i < which) {
if (gUnknown_203B26C->unk68[i] == 0) {
gUnknown_203B26C->unk24 = gUnknown_203B26C->unk28[i].menuAction;
break;
}
i++;
}
}
}
}
void sub_801EC7C(void) {
s32 which;
which = 0;
MemoryFill16(&gUnknown_203B26C->unk68[0], 0, sizeof(gUnknown_203B26C->unk68));
gUnknown_203B26C->unk28[which].text = *gUnknown_80D4920; // "Yes"
gUnknown_203B26C->unk28[which].menuAction = 4;
which++;
gUnknown_203B26C->unk28[which].text = *gUnknown_80D4928; // "No"
gUnknown_203B26C->unk28[which].menuAction = 5;
which++;
gUnknown_203B26C->unk28[which].text = NULL;
gUnknown_203B26C->unk28[which].menuAction = 1;
}
void sub_801ECBC(void)
{
switch (sub_801EF38(1)) {
case 3:
{
struct Move* move;
gUnknown_203B26C->unk20 = sub_801F194();
move = gUnknown_203B26C->moves;
move = &move[gUnknown_203B26C->unk20];
gUnknown_203B26C->unk1E = move->id;
UpdateGulpinShopState(2);
break;
}
case 4:
{
struct Move* move;
gUnknown_203B26C->unk20 = sub_801F194();
move = gUnknown_203B26C->moves;
move = &move[gUnknown_203B26C->unk20];
gUnknown_203B26C->unk1E = move->id;
UpdateGulpinShopState(3);
break;
}
case 2:
sub_801F214();
UpdateGulpinShopState(6);
break;
}
}
void sub_801ED28(void)
{
s32 menuAction;
menuAction = 0;
sub_801EF38(0);
if (sub_8012FD8(&gUnknown_203B26C->unk78) == 0)
sub_8013114(&gUnknown_203B26C->unk78, &menuAction);
switch(menuAction) {
case 1:
case 5:
UpdateGulpinShopState(1);
break;
case 2:
PlaySound(0x133);
gUnknown_203B26C->isNextMoveLinked = IsNextMoveLinked(gUnknown_203B26C->unk20, gUnknown_203B26C->moves);
UpdateGulpinShopState(4);
break;
case 3:
UpdateGulpinShopState(3);
break;
}
}
void sub_801EDA4(void)
{
switch (sub_801F890()) {
case 2:
case 3:
sub_801F8D0();
UpdateGulpinShopState(1);
break;
case 0:
case 1:
break;
}
}
void sub_801EDC0(void)
{
s32 temp;
if (sub_80144A4(&temp) == 0) {
switch (temp)
{
case 4:
sub_801F214();
RemoveLinkSequenceFromMoves8(gUnknown_203B26C->moves, gUnknown_203B26C->unk20);
gUnknown_203B26C->state = 5;
break;
case 1:
case 5:
UpdateGulpinShopState(1);
break;
}
}
}

View File

@ -1,79 +0,0 @@
#include "global.h"
#include "file_system.h"
#include "pokemon.h"
#include "memory.h"
#include "text.h"
#include "input.h"
#include "menu.h"
#include "gulpin_shop.h"
#include "menu_input.h"
extern struct unkStruct_203B26C *gUnknown_203B26C;
extern void UpdateGulpinShopState(u32);
extern void RemoveLinkSequenceFromMoves8(struct Move *, u32);
extern void sub_801F214(void);
extern s32 sub_80144A4(s32 *);
extern u32 sub_801F890(void);
extern void sub_801F8D0(void);
extern u8 IsNextMoveLinked(u32, struct Move *);
extern void PlaySound(u32);
extern u32 sub_801EF38(u32);
extern u32 sub_801F194(void);
void sub_801ED28(void)
{
s32 menuAction;
menuAction = 0;
sub_801EF38(0);
if(sub_8012FD8(&gUnknown_203B26C->unk78) == 0)
sub_8013114(&gUnknown_203B26C->unk78,&menuAction);
switch(menuAction)
{
case 1:
case 5:
UpdateGulpinShopState(1);
break;
case 2:
PlaySound(0x133);
gUnknown_203B26C->isNextMoveLinked = IsNextMoveLinked(gUnknown_203B26C->unk20, gUnknown_203B26C->moves);
UpdateGulpinShopState(4);
break;
case 3:
UpdateGulpinShopState(3);
}
}
void sub_801EDA4(void)
{
switch(sub_801F890())
{
case 2:
case 3:
sub_801F8D0();
UpdateGulpinShopState(1);
break;
case 0:
case 1:
break;
}
}
void sub_801EDC0(void)
{
s32 temp;
if(sub_80144A4(&temp) == 0){
switch(temp)
{
case 4:
sub_801F214();
RemoveLinkSequenceFromMoves8(gUnknown_203B26C->moves, gUnknown_203B26C->unk20);
gUnknown_203B26C->state = 5;
break;
case 1:
case 5:
UpdateGulpinShopState(1);
break;
}
}
}