Merge pull request #394 from DizzyEggg/code_803C1D0

decompile code_803C1D0
This commit is contained in:
Seth Barberee
2025-05-16 13:58:14 -07:00
committed by GitHub
6 changed files with 184 additions and 391 deletions

View File

@@ -1,382 +0,0 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start sub_803C3E0
sub_803C3E0:
push {r4-r7,lr}
mov r7, r8
push {r7}
sub sp, 0x54
adds r7, r0, 0
movs r6, 0
ldr r5, _0803C42C
movs r4, 0
mov r8, sp
_0803C3F2:
movs r1, 0
ldrsh r0, [r5, r1]
bl sub_803C110
lsls r0, 24
cmp r0, 0
beq _0803C41A
movs r1, 0x2
ldrsh r0, [r5, r1]
bl sub_803C110
lsls r0, 24
cmp r0, 0
beq _0803C41A
mov r0, r8
adds r0, 0x4
mov r8, r0
subs r0, 0x4
stm r0!, {r4}
adds r6, 0x1
_0803C41A:
adds r5, 0x8
adds r4, 0x1
cmp r4, 0x14
ble _0803C3F2
ldr r5, _0803C42C
cmp r6, 0
bne _0803C430
movs r0, 0
b _0803C44E
.align 2, 0
_0803C42C: .4byte gUnknown_80E9920
_0803C430:
adds r0, r6, 0
bl RandInt
lsls r0, 2
add r0, sp
ldr r4, [r0]
lsls r0, r4, 3
adds r5, r0, r5
ldrh r0, [r5]
strh r0, [r7, 0xC]
ldrh r0, [r5, 0x2]
strh r0, [r7, 0xE]
movs r0, 0x7
strb r0, [r7, 0x2]
movs r0, 0x1
_0803C44E:
add sp, 0x54
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_803C3E0
thumb_func_start sub_803C45C
sub_803C45C:
push {r4-r7,lr}
mov r7, r8
push {r7}
sub sp, 0xB4
adds r7, r0, 0
movs r6, 0
ldr r5, _0803C4CC
movs r4, 0
mov r8, sp
_0803C46E:
movs r1, 0
ldrsh r0, [r5, r1]
bl sub_803C110
lsls r0, 24
cmp r0, 0
beq _0803C496
movs r1, 0x2
ldrsh r0, [r5, r1]
bl sub_803C110
lsls r0, 24
cmp r0, 0
beq _0803C496
mov r0, r8
adds r0, 0x4
mov r8, r0
subs r0, 0x4
stm r0!, {r4}
adds r6, 0x1
_0803C496:
adds r5, 0xC
adds r4, 0x1
cmp r4, 0x2C
ble _0803C46E
ldr r5, _0803C4CC
cmp r6, 0
beq _0803C4E0
adds r0, r6, 0
bl RandInt
lsls r0, 2
add r0, sp
ldr r4, [r0]
lsls r0, r4, 1
adds r0, r4
lsls r0, 2
adds r5, r0, r5
bl Rand32Bit
movs r1, 0x10
ands r1, r0
cmp r1, 0
beq _0803C4D0
ldrh r0, [r5]
strh r0, [r7, 0xC]
ldrh r0, [r5, 0x2]
b _0803C4D6
.align 2, 0
_0803C4CC: .4byte gUnknown_80E9F8C
_0803C4D0:
ldrh r0, [r5, 0x2]
strh r0, [r7, 0xC]
ldrh r0, [r5]
_0803C4D6:
strh r0, [r7, 0xE]
movs r0, 0x8
strb r0, [r7, 0x2]
movs r0, 0x1
b _0803C4E2
_0803C4E0:
movs r0, 0
_0803C4E2:
add sp, 0xB4
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_803C45C
thumb_func_start sub_803C4F0
sub_803C4F0:
push {r4-r7,lr}
mov r7, r8
push {r7}
sub sp, 0x18
adds r7, r0, 0
movs r6, 0
ldr r5, _0803C55C
movs r4, 0
mov r8, sp
_0803C502:
movs r1, 0
ldrsh r0, [r5, r1]
bl sub_803C110
lsls r0, 24
cmp r0, 0
beq _0803C52A
movs r1, 0x2
ldrsh r0, [r5, r1]
bl sub_803C110
lsls r0, 24
cmp r0, 0
beq _0803C52A
mov r0, r8
adds r0, 0x4
mov r8, r0
subs r0, 0x4
stm r0!, {r4}
adds r6, 0x1
_0803C52A:
adds r5, 0x4
adds r4, 0x1
cmp r4, 0x5
ble _0803C502
ldr r5, _0803C55C
cmp r6, 0
beq _0803C570
adds r0, r6, 0
bl RandInt
lsls r0, 2
add r0, sp
ldr r4, [r0]
lsls r0, r4, 2
adds r5, r0, r5
bl Rand32Bit
movs r1, 0x10
ands r1, r0
cmp r1, 0
beq _0803C560
ldrh r0, [r5]
strh r0, [r7, 0xC]
ldrh r0, [r5, 0x2]
b _0803C566
.align 2, 0
_0803C55C: .4byte gUnknown_80E8168
_0803C560:
ldrh r0, [r5, 0x2]
strh r0, [r7, 0xC]
ldrh r0, [r5]
_0803C566:
strh r0, [r7, 0xE]
movs r0, 0x9
strb r0, [r7, 0x2]
movs r0, 0x1
b _0803C572
_0803C570:
movs r0, 0
_0803C572:
add sp, 0x18
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_803C4F0
thumb_func_start sub_803C580
sub_803C580:
push {r4-r7,lr}
mov r7, r8
push {r7}
sub sp, 0x54
adds r6, r0, 0
movs r7, 0
ldr r5, _0803C5D8
movs r0, 0x6
bl sub_80023E4
lsls r0, 24
cmp r0, 0
beq _0803C5D2
movs r4, 0
mov r8, sp
_0803C59E:
movs r1, 0
ldrsh r0, [r5, r1]
bl sub_803C110
lsls r0, 24
cmp r0, 0
beq _0803C5C6
ldrb r0, [r6, 0x4]
ldrb r1, [r5, 0x2]
bl xxx_bit_lut_lookup_8091E50
lsls r0, 24
cmp r0, 0
beq _0803C5C6
mov r0, r8
adds r0, 0x4
mov r8, r0
subs r0, 0x4
stm r0!, {r4}
adds r7, 0x1
_0803C5C6:
adds r5, 0x4
adds r4, 0x1
cmp r4, 0x14
ble _0803C59E
cmp r7, 0
bne _0803C5DC
_0803C5D2:
movs r0, 0
b _0803C600
.align 2, 0
_0803C5D8: .4byte gUnknown_80E8180
_0803C5DC:
adds r0, r7, 0
bl RandInt
lsls r0, 2
add r0, sp
ldr r4, [r0]
lsls r1, r4, 2
ldr r0, _0803C60C
adds r5, r1, r0
ldrh r0, [r5]
strh r0, [r6, 0xC]
ldrh r0, [r5]
strh r0, [r6, 0xE]
ldrb r0, [r5, 0x2]
strb r0, [r6, 0x10]
movs r0, 0x5
strb r0, [r6, 0x2]
movs r0, 0x1
_0803C600:
add sp, 0x54
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r1}
bx r1
.align 2, 0
_0803C60C: .4byte gUnknown_80E8180
thumb_func_end sub_803C580
thumb_func_start sub_803C610
sub_803C610:
push {r4-r7,lr}
mov r7, r8
push {r7}
ldr r4, _0803C660
add sp, r4
adds r6, r0, 0
movs r7, 0
ldr r4, _0803C664
movs r5, 0
mov r8, sp
_0803C624:
movs r1, 0
ldrsh r0, [r4, r1]
bl sub_803C110
lsls r0, 24
cmp r0, 0
beq _0803C64C
ldrb r0, [r6, 0x4]
ldrb r1, [r4, 0x2]
bl xxx_bit_lut_lookup_8091E50
lsls r0, 24
cmp r0, 0
beq _0803C64C
mov r0, r8
adds r0, 0x4
mov r8, r0
subs r0, 0x4
stm r0!, {r5}
adds r7, 0x1
_0803C64C:
adds r4, 0x4
adds r5, 0x1
ldr r0, _0803C668
cmp r5, r0
ble _0803C624
cmp r7, 0
bne _0803C66C
movs r0, 0
b _0803C690
.align 2, 0
_0803C660: .4byte 0xfffff9f8
_0803C664: .4byte gUnknown_80E81D4
_0803C668: .4byte 0x00000181
_0803C66C:
adds r0, r7, 0
bl RandInt
lsls r0, 2
add r0, sp
ldr r5, [r0]
lsls r1, r5, 2
ldr r0, _0803C6A0
adds r4, r1, r0
ldrh r0, [r4]
strh r0, [r6, 0xC]
ldrh r0, [r4]
strh r0, [r6, 0xE]
ldrb r0, [r4, 0x2]
strb r0, [r6, 0x10]
movs r0, 0x6
strb r0, [r6, 0x2]
movs r0, 0x1
_0803C690:
movs r3, 0xC1
lsls r3, 3
add sp, r3
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r1}
bx r1
.align 2, 0
_0803C6A0: .4byte gUnknown_80E81D4
thumb_func_end sub_803C610
.align 2,0

View File

@@ -38,4 +38,7 @@ void sub_803B6B0(s32 x, s32 y, u8 index, u32);
bool8 sub_803C0DC(s16 species);
bool8 sub_803C110(s16 index);
extern const unkStruct_80E9920 gUnknown_80E9920[21];
extern const unkStruct_80E9F8C gUnknown_80E9F8C[45];
#endif // POKEMON_MAIL_H

View File

@@ -1,6 +1,22 @@
#ifndef POKEMON_MAIL_PRE_H
#define POKEMON_MAIL_PRE_H
struct PokemonPair
{
s16 speciesA;
s16 speciesB;
};
struct PokemonItem
{
s16 species;
u8 itemId;
};
extern const struct PokemonPair gUnknown_80E8168[6];
extern const struct PokemonItem gUnknown_80E8180[21];
extern const struct PokemonItem gUnknown_80E81D4[386];
extern const s16 gUnknown_80E80E0[35];
extern const s16 gUnknown_80E8126[33];
extern const u8 gMankeyMission[];
@@ -35,4 +51,4 @@ extern const u8 gDifficultyText[];
extern const u8 gRewardText[];
extern const u8 gUnknown_80E8B7C[];
#endif // POKEMON_MAIL_PRE_H
#endif // POKEMON_MAIL_PRE_H

View File

@@ -191,7 +191,6 @@ SECTIONS {
asm/code_803B050.o(.text);
src/pokemon_mail.o(.text);
src/code_803C1B4.o(.text);
asm/code_803C1D0.o(.text);
src/personality_test1.o(.text);
src/personality_test2.o(.text);
src/code_803D0D8.o(.text);

View File

@@ -26,7 +26,7 @@ u8 sub_803C1D0(struct DungeonLocation *dungeon, u8 missionType)
s32 a = sub_803C1B4(dungeon, missionType);
a /= 2;
if ((u8)a >= 7) {
a = 6;
a = 6;
return a;
}
return a;
@@ -51,7 +51,7 @@ void sub_803C21C(WonderMail *param_1, unkStruct_802F204 *param_2)
uVar2 = sub_803C1D0(&param_1->unk4.dungeon,param_1->missionType);
param_2->moneyReward = 0;
for(index = 0; index < MAX_ITEM_REWARDS; index++)
for(index = 0; index < MAX_ITEM_REWARDS; index++)
{
param_2->itemRewards[index] = ITEM_NOTHING;
}
@@ -116,11 +116,12 @@ void sub_803C21C(WonderMail *param_1, unkStruct_802F204 *param_2)
param_2->teamRankPtsReward = GetDungeonTeamRankPts(&param_1->unk4.dungeon,param_1->missionType);
}
void sub_803C37C(DungeonLocation *location, u8 r1, u8 *itemReward) {
void sub_803C37C(DungeonLocation *location, u8 r1, u8 *itemReward)
{
s32 r7;
bool8 flag;
u8 r4;
r7 = sub_803C1B4(location, r1);
sub_8090910(location, r7);
@@ -135,3 +136,159 @@ void sub_803C37C(DungeonLocation *location, u8 r1, u8 *itemReward) {
*itemReward = r4;
}
// TODO: Figure out if this is the right file
#include "random.h"
#include "pokemon_mail.h"
#include "pokemon_mail_pre.h"
bool8 sub_803C3E0(WonderMail *mail)
{
const unkStruct_80E9920 *ptr;
s32 counter, id;
s32 stack[ARRAY_COUNT(gUnknown_80E9920)];
counter = 0;
for (ptr = gUnknown_80E9920, id = 0; id < ARRAY_COUNT_INT(gUnknown_80E9920); ptr++, id++) {
if (sub_803C110(ptr->parentSpecies) && sub_803C110(ptr->childSpecies)) {
stack[counter++] = id;
}
}
if (counter != 0) {
id = stack[RandInt(counter)];
ptr = &gUnknown_80E9920[id];
mail->clientSpecies = ptr->parentSpecies;
mail->targetSpecies = ptr->childSpecies;
mail->unk2 = 7;
return TRUE;
}
return FALSE;
}
bool8 sub_803C45C(WonderMail *mail)
{
s32 counter, id;
s32 stack[ARRAY_COUNT(gUnknown_80E9F8C)];
const unkStruct_80E9F8C *ptr;
counter = 0;
ptr = &gUnknown_80E9F8C[0];
for (id = 0; id < ARRAY_COUNT_INT(gUnknown_80E9F8C); ptr++, id++) {
if (sub_803C110(ptr->speciesA) && sub_803C110(ptr->speciesB)) {
stack[counter++] = id;
}
}
if (counter != 0) {
id = stack[RandInt(counter)];
ptr = &gUnknown_80E9F8C[id];
if ((Rand32Bit() & 0x10)) {
mail->clientSpecies = ptr->speciesA;
mail->targetSpecies = ptr->speciesB;
}
else {
mail->clientSpecies = ptr->speciesB;
mail->targetSpecies = ptr->speciesA;
}
mail->unk2 = 8;
return TRUE;
}
return FALSE;
}
bool8 sub_803C4F0(WonderMail *mail)
{
s32 counter, id;
s32 stack[ARRAY_COUNT(gUnknown_80E8168)];
const struct PokemonPair *ptr;
counter = 0;
ptr = &gUnknown_80E8168[0];
for (id = 0; id < ARRAY_COUNT_INT(gUnknown_80E8168); ptr++, id++) {
if (sub_803C110(ptr->speciesA) && sub_803C110(ptr->speciesB)) {
stack[counter++] = id;
}
}
if (counter != 0) {
id = stack[RandInt(counter)];
ptr = &gUnknown_80E8168[id];
if ((Rand32Bit() & 0x10)) {
mail->clientSpecies = ptr->speciesA;
mail->targetSpecies = ptr->speciesB;
}
else {
mail->clientSpecies = ptr->speciesB;
mail->targetSpecies = ptr->speciesA;
}
mail->unk2 = 9;
return TRUE;
}
return FALSE;
}
bool8 sub_803C580(WonderMail *param_1)
{
s32 counter, id;
s32 array[ARRAY_COUNT(gUnknown_80E8180)];
const struct PokemonItem *ptr;
counter = 0;
ptr = gUnknown_80E8180;
if (!sub_80023E4(6))
return FALSE;
for (id = 0; id < ARRAY_COUNT_INT(gUnknown_80E8180); ptr++, id++) {
if (sub_803C110(ptr->species) && xxx_bit_lut_lookup_8091E50(param_1->unk4.dungeon.id, ptr->itemId)) {
array[counter++] = id;
}
}
if (counter != 0) {
id = array[RandInt(counter)];
ptr = &gUnknown_80E8180[id];
param_1->clientSpecies = ptr->species;
param_1->targetSpecies = ptr->species;
param_1->targetItem = ptr->itemId;
param_1->unk2 = 5;
return TRUE;
}
return FALSE;
}
bool8 sub_803C610(WonderMail *param_1)
{
s32 counter, id;
s32 array[ARRAY_COUNT(gUnknown_80E81D4)];
const struct PokemonItem *ptr;
counter = 0;
ptr = gUnknown_80E81D4;
for (id = 0; id < ARRAY_COUNT_INT(gUnknown_80E81D4); ptr++, id++) {
if (sub_803C110(ptr->species) && xxx_bit_lut_lookup_8091E50(param_1->unk4.dungeon.id, ptr->itemId)) {
array[counter++] = id;
}
}
if (counter != 0) {
id = array[RandInt(counter)];
ptr = &gUnknown_80E81D4[id];
param_1->clientSpecies = ptr->species;
param_1->targetSpecies = ptr->species;
param_1->targetItem = ptr->itemId;
param_1->unk2 = 6;
return TRUE;
}
return FALSE;
}

View File

@@ -95,7 +95,7 @@ const s16 gUnknown_80E8126[33] = {
MONSTER_NONE
};
const s16 gUnknown_80E8168[6][2] = {
const struct PokemonPair gUnknown_80E8168[6] = {
{ MONSTER_NIDORAN_M, MONSTER_NIDORAN_F },
{ MONSTER_NIDORINO, MONSTER_NIDORINA },
{ MONSTER_NIDOKING, MONSTER_NIDOQUEEN },
@@ -104,7 +104,7 @@ const s16 gUnknown_80E8168[6][2] = {
{ MONSTER_MINUN, MONSTER_PLUSLE }
};
const s16 gUnknown_80E8180[21][2] = {
const struct PokemonItem gUnknown_80E8180[21] = {
{ MONSTER_GLOOM, ITEM_LEAF_STONE },
{ MONSTER_WEEPINBELL, ITEM_LEAF_STONE },
{ MONSTER_EXEGGCUTE, ITEM_LEAF_STONE },
@@ -129,7 +129,7 @@ const s16 gUnknown_80E8180[21][2] = {
};
// List of preferred gummis
const s16 gUnknown_80E81D4[386][2] = {
const struct PokemonItem gUnknown_80E81D4[386] = {
{ MONSTER_EKANS, ITEM_PINK_GUMMI },
{ MONSTER_ARBOK, ITEM_PINK_GUMMI },
{ MONSTER_ARMALDO, ITEM_GRAY_GUMMI },