mirror of
https://github.com/pret/pmd-red.git
synced 2026-09-07 16:45:39 -05:00
decomp another func and document a little more
This commit is contained in:
@@ -5,142 +5,6 @@
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start sub_8045CB0
|
||||
sub_8045CB0:
|
||||
push {r4-r7,lr}
|
||||
mov r7, r10
|
||||
mov r6, r9
|
||||
mov r5, r8
|
||||
push {r5-r7}
|
||||
sub sp, 0x8
|
||||
movs r0, 0x38
|
||||
bl DungeonRandInt
|
||||
adds r5, r0, 0
|
||||
movs r0, 0x20
|
||||
bl DungeonRandInt
|
||||
adds r6, r0, 0
|
||||
ldr r0, _08045D34
|
||||
ldr r0, [r0]
|
||||
ldr r1, _08045D38
|
||||
adds r0, r1
|
||||
movs r1, 0
|
||||
strh r1, [r0]
|
||||
movs r0, 0
|
||||
_08045CDA:
|
||||
adds r6, 0x1
|
||||
cmp r6, 0x20
|
||||
bne _08045CE2
|
||||
movs r6, 0
|
||||
_08045CE2:
|
||||
adds r0, 0x1
|
||||
mov r10, r0
|
||||
movs r3, 0x2
|
||||
mov r9, r3
|
||||
movs r0, 0x37
|
||||
mov r8, r0
|
||||
_08045CEE:
|
||||
adds r5, 0x1
|
||||
cmp r5, 0x38
|
||||
bne _08045CF6
|
||||
movs r5, 0
|
||||
_08045CF6:
|
||||
adds r0, r5, 0
|
||||
adds r1, r6, 0
|
||||
bl GetTile
|
||||
adds r2, r0, 0
|
||||
ldrh r0, [r2]
|
||||
movs r3, 0x80
|
||||
lsls r3, 2
|
||||
adds r1, r3, 0
|
||||
ands r0, r1
|
||||
cmp r0, 0
|
||||
bne _08045D92
|
||||
ldrh r1, [r2, 0x4]
|
||||
mov r0, r9
|
||||
ands r0, r1
|
||||
cmp r0, 0
|
||||
beq _08045D92
|
||||
movs r7, 0
|
||||
lsls r0, r5, 16
|
||||
lsls r1, r6, 16
|
||||
lsrs r0, 16
|
||||
orrs r0, r1
|
||||
str r0, [sp, 0x4]
|
||||
ldrh r1, [r2]
|
||||
movs r0, 0x20
|
||||
ands r0, r1
|
||||
cmp r0, 0
|
||||
beq _08045D3C
|
||||
movs r7, 0x1
|
||||
movs r0, 0x1
|
||||
b _08045D58
|
||||
.align 2, 0
|
||||
_08045D34: .4byte gDungeon
|
||||
_08045D38: .4byte 0x00003904
|
||||
_08045D3C:
|
||||
movs r0, 0x3
|
||||
ands r0, r1
|
||||
cmp r0, 0
|
||||
bne _08045D48
|
||||
movs r0, 0x3
|
||||
b _08045D58
|
||||
_08045D48:
|
||||
movs r0, 0x40
|
||||
ands r0, r1
|
||||
lsls r0, 16
|
||||
lsrs r0, 16
|
||||
negs r0, r0
|
||||
asrs r0, 31
|
||||
mov r1, r9
|
||||
ands r0, r1
|
||||
_08045D58:
|
||||
bl sub_803D73C
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
adds r4, r0, 0
|
||||
bl CanSellItem
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
bne _08045D6E
|
||||
movs r7, 0
|
||||
_08045D6E:
|
||||
mov r0, sp
|
||||
adds r1, r4, 0
|
||||
movs r2, 0
|
||||
bl sub_8045C28
|
||||
cmp r7, 0
|
||||
beq _08045D88
|
||||
mov r0, sp
|
||||
ldrb r1, [r0]
|
||||
mov r0, r9
|
||||
orrs r0, r1
|
||||
mov r1, sp
|
||||
strb r0, [r1]
|
||||
_08045D88:
|
||||
add r0, sp, 0x4
|
||||
mov r1, sp
|
||||
movs r2, 0x1
|
||||
bl sub_80460F8
|
||||
_08045D92:
|
||||
movs r3, 0x1
|
||||
negs r3, r3
|
||||
add r8, r3
|
||||
mov r0, r8
|
||||
cmp r0, 0
|
||||
bge _08045CEE
|
||||
mov r0, r10
|
||||
cmp r0, 0x1F
|
||||
ble _08045CDA
|
||||
add sp, 0x8
|
||||
pop {r3-r5}
|
||||
mov r8, r3
|
||||
mov r9, r4
|
||||
mov r10, r5
|
||||
pop {r4-r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end sub_8045CB0
|
||||
|
||||
thumb_func_start sub_8045DB4
|
||||
sub_8045DB4:
|
||||
push {r4-r7,lr}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include "global.h"
|
||||
#include "constants/item.h"
|
||||
#include "dungeon_global_data.h"
|
||||
#include "dungeon_map_access.h"
|
||||
#include "dungeon_util.h"
|
||||
#include "dungeon_random.h"
|
||||
#include "item.h"
|
||||
#include "map.h"
|
||||
|
||||
extern u8 *gUnknown_80FE6F4[];
|
||||
extern struct unkStruct_8090F58 gUnknown_80F699C;
|
||||
@@ -16,6 +18,8 @@ extern void GetTrapName(u8 *, u8);
|
||||
extern bool8 IsNotSpecialItem(u8 id);
|
||||
void sub_8045BF8(u8 *, struct Item *);
|
||||
void sub_8046CE4(void *param_1,u32 param_2);
|
||||
extern u32 sub_803D73C(u32);
|
||||
void sub_80460F8(struct Position *, struct Item *, u32);
|
||||
|
||||
void sub_8045ACC(void)
|
||||
{
|
||||
@@ -128,3 +132,69 @@ _store:
|
||||
sub_8046CE4(Item, total);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_8045CB0(void)
|
||||
{
|
||||
bool8 shopFlag;
|
||||
u8 itemID;
|
||||
u32 x;
|
||||
int y;
|
||||
int yCounter;
|
||||
struct Tile *tile;
|
||||
u32 uVar5;
|
||||
int xCounter;
|
||||
struct Item item;
|
||||
struct Position pos;
|
||||
u32 flag;
|
||||
|
||||
x = DungeonRandInt(DUNGEON_MAX_SIZE_X);
|
||||
y = DungeonRandInt(DUNGEON_MAX_SIZE_Y);
|
||||
gDungeon->unk3904 = 0;
|
||||
for(yCounter = 0; yCounter < DUNGEON_MAX_SIZE_Y; yCounter++)
|
||||
{
|
||||
y++;
|
||||
if (y == DUNGEON_MAX_SIZE_Y) {
|
||||
y = 0;
|
||||
}
|
||||
|
||||
for(xCounter = 0; xCounter < DUNGEON_MAX_SIZE_X; xCounter++)
|
||||
{
|
||||
x++;
|
||||
flag = ITEM_FLAG_IN_SHOP;
|
||||
if (x == DUNGEON_MAX_SIZE_X) {
|
||||
x = 0;
|
||||
}
|
||||
tile = GetTile(x,y);
|
||||
|
||||
if (((tile->terrainType & TERRAIN_TYPE_STAIRS) == 0) && ((tile->unk4 & 2) != 0)) {
|
||||
shopFlag = FALSE;
|
||||
pos.x = x;
|
||||
pos.y = y;
|
||||
|
||||
if (tile->terrainType & TERRAIN_TYPE_SHOP) {
|
||||
shopFlag = TRUE;
|
||||
uVar5 = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((tile->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY)) == 0) {
|
||||
uVar5 = 3;
|
||||
}
|
||||
else {
|
||||
// TODO: Ternary?
|
||||
uVar5 = -(tile->terrainType & TERRAIN_TYPE_IN_MONSTER_HOUSE) >> 0x1f & 2;
|
||||
}
|
||||
}
|
||||
itemID = sub_803D73C(uVar5);
|
||||
if (!CanSellItem(itemID)) {
|
||||
shopFlag = 0;
|
||||
}
|
||||
sub_8045C28(&item,itemID,0);
|
||||
if (shopFlag) {
|
||||
item.flags |= flag;
|
||||
}
|
||||
sub_80460F8(&pos,&item,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1380,7 +1380,7 @@ bool8 sub_805AD54(struct Entity * pokemon, struct Entity * target, struct Move *
|
||||
targetEntity = possibleTargets[index];
|
||||
if ((((EntityExists(targetEntity)) && (pokemon != targetEntity)) &&
|
||||
(CanTarget(pokemon,targetEntity,FALSE,FALSE) == TARGET_CAPABILITY_CANNOT_ATTACK)) &&
|
||||
(targetEntity->info->clientType != ENTITY_MONSTER)) {
|
||||
(targetEntity->info->clientType != CLIENT_TYPE_CLIENT)) {
|
||||
if (!sub_805AD54_sub(targetEntity)) {
|
||||
sub_807D148(pokemon,targetEntity,2,&target->pos);
|
||||
flag = TRUE;
|
||||
|
||||
@@ -932,7 +932,7 @@ bool8 TransferOrbAction(struct Entity *pokemon, struct Entity * target)
|
||||
targetID = entityInfo->id;
|
||||
oldID = entityInfo->id;
|
||||
SetMessageArgument(gAvailablePokemonNames,target,0);
|
||||
if (entityInfo->clientType != 0) {
|
||||
if (entityInfo->clientType != CLIENT_TYPE_NONE) {
|
||||
sub_80522F4(pokemon,target,*gUnknown_80FD450);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ extern void sub_8035CF4(struct MenuStruct *, u32, u32);
|
||||
extern void SetMenuItems(struct MenuStruct *, struct UnkTextStruct2 *, u32, struct UnkTextStruct2 *, struct MenuItem *, u32, u32, u32);
|
||||
extern void sub_80384D0();
|
||||
|
||||
void sub_80382E4(s32 param_1)
|
||||
void sub_80382E4(s32 currMenu)
|
||||
{
|
||||
s32 index;
|
||||
|
||||
@@ -49,7 +49,7 @@ void sub_80382E4(s32 param_1)
|
||||
}
|
||||
ResetUnusedInputStruct();
|
||||
sub_800641C(gUnknown_203B360->unk148,1,1);
|
||||
if (param_1 == 0x25) {
|
||||
if (currMenu == 0x25) {
|
||||
// Caution!
|
||||
// The storage space is empty!
|
||||
// Please check again.
|
||||
@@ -57,7 +57,7 @@ void sub_80382E4(s32 param_1)
|
||||
0,4,0);
|
||||
}
|
||||
sub_8035CF4(gUnknown_203B360->unk8,0,1);
|
||||
gUnknown_203B360->currMenu = param_1;
|
||||
gUnknown_203B360->currMenu = currMenu;
|
||||
gUnknown_203B360->unk4 = 0;
|
||||
sub_8038440();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user