field_follow_poke, 2

This commit is contained in:
PikalaxALT 2022-02-10 16:04:04 -05:00
parent 976f2af29d
commit 4f147aeee3
3 changed files with 66 additions and 116 deletions

View File

@ -12,119 +12,6 @@
.text
thumb_func_start FollowingPokemon_GetMapObject
FollowingPokemon_GetMapObject: ; 0x02069D68
add r0, #0xe4
ldr r0, [r0]
bx lr
.balign 4, 0
thumb_func_end FollowingPokemon_GetMapObject
thumb_func_start FollowingPokemon_GetSpriteID
FollowingPokemon_GetSpriteID: ; 0x02069D70
push {r3, r4, r5, r6, r7, lr}
add r5, r0, #0
add r6, r1, #0
add r7, r2, #0
cmp r5, #0
ble _02069D82
ldr r1, _02069DC0 ; =NATIONAL_DEX_COUNT
cmp r5, r1
ble _02069D88
_02069D82:
mov r4, #SPRITE_TSURE_POKE_BULBASAUR>>2
lsl r4, r4, #2
b _02069DBC
_02069D88:
bl SpeciesToOverworldModelIndexOffset
mov r1, #0x6b
lsl r1, r1, #2
add r4, r0, r1
add r0, r5, #0
bl OverworldModelLookupHasFemaleForme
cmp r0, #0
beq _02069DA4
cmp r7, #1
bne _02069DB2
add r4, r4, #1
b _02069DB2
_02069DA4:
add r0, r5, #0
bl OverworldModelLookupFormeCount
cmp r6, r0
ble _02069DB0
mov r6, #0
_02069DB0:
add r4, r4, r6
_02069DB2:
ldr r0, _02069DC4 ; =SPRITE_TSURE_POKE_ARCEUS_DARK
cmp r4, r0
ble _02069DBC
mov r4, #SPRITE_TSURE_POKE_BULBASAUR>>2
lsl r4, r4, #2
_02069DBC:
add r0, r4, #0
pop {r3, r4, r5, r6, r7, pc}
.balign 4, 0
_02069DC0: .word NATIONAL_DEX_COUNT
_02069DC4: .word SPRITE_TSURE_POKE_ARCEUS_DARK
thumb_func_end FollowingPokemon_GetSpriteID
thumb_func_start sub_02069DC8
sub_02069DC8: ; 0x02069DC8
push {r3, r4, r5, lr}
add r5, r0, #0
add r4, r1, #0
bl sub_0206A040
cmp r4, #0
beq _02069DE0
add r0, r5, #0
mov r1, #1
bl sub_02069DEC
pop {r3, r4, r5, pc}
_02069DE0:
add r0, r5, #0
mov r1, #0
bl sub_02069DEC
pop {r3, r4, r5, pc}
.balign 4, 0
thumb_func_end sub_02069DC8
thumb_func_start sub_02069DEC
sub_02069DEC: ; 0x02069DEC
push {r3, r4, r5, lr}
add r4, r1, #0
mov r1, #2
add r5, r0, #0
bl MapObject_GetParam
mov r1, #1
and r1, r0
asr r0, r0, #2
lsl r1, r1, #0x18
lsl r2, r0, #2
lsl r0, r4, #1
orr r0, r2
lsr r1, r1, #0x18
orr r1, r0
add r0, r5, #0
mov r2, #2
bl MapObject_SetParam
pop {r3, r4, r5, pc}
thumb_func_end sub_02069DEC
thumb_func_start sub_02069E14
sub_02069E14: ; 0x02069E14
push {r3, lr}
mov r1, #2
bl MapObject_GetParam
asr r1, r0, #1
mov r0, #1
and r0, r1
lsl r0, r0, #0x18
lsr r0, r0, #0x18
pop {r3, pc}
thumb_func_end sub_02069E14
thumb_func_start sub_02069E28
sub_02069E28: ; 0x02069E28
push {r3, r4, r5, lr}

View File

@ -7,5 +7,7 @@ LocalMapObject *GetMapObjectByID(LocalMapObject *arr, int id);
void sub_0205FC94(LocalMapObject *mapObject, int movement);
void MapObject_SetGfxID(LocalMapObject *mapObject, u32 spriteId);
void sub_0205F6AC(LocalMapObject *mapObject, int a1);
int MapObject_GetParam(LocalMapObject *mapObject, int which);
void MapObject_SetParam(LocalMapObject *mapObject, int value, int which);
#endif //POKEHEARTGOLD_FIELD_MAP_OBJECT_H

View File

@ -5,7 +5,10 @@
#include "field_map_object.h"
#include "constants/scrcmd.h"
BOOL sub_02069E14(LocalMapObject *mapObject);
LocalMapObject *FollowingPokemon_GetMapObject(FieldSystem *fsys);
u32 FollowingPokemon_GetSpriteID(int species, u16 forme, u32 gender);
void sub_02069DEC(LocalMapObject *mapObject, int a1);
u8 sub_02069E14(LocalMapObject *mapObject);
BOOL sub_02069FF4(int species, u32 mapno);
void sub_0206A040(LocalMapObject *mapObject, int a1);
void sub_0206A06C(FollowMon *followMon);
@ -14,8 +17,9 @@ LocalMapObject *CreateFollowingSpriteFieldObject(MapObjectMan *mapObjectMan, int
void FollowPokeFsysParamSet(FieldSystem *fsys, int species, u8 forme, BOOL shiny, u8 gender);
void FollowPokeMapObjectSetParams(LocalMapObject *mapObject, int species, u8 forme, BOOL shiny);
void sub_0206A288(struct FieldSystemUnk108 *a0, POKEMON *pokemon, u16 species, u32 personality);
LocalMapObject *FollowingPokemon_GetMapObject(FieldSystem *fsys);
u32 FollowingPokemon_GetSpriteID(u32 species, u16 forme, u32 gender);
int SpeciesToOverworldModelIndexOffset(int species);
int OverworldModelLookupHasFemaleForme(int species);
int OverworldModelLookupFormeCount(int species);
LocalMapObject *sub_020699F8(MapObjectMan *mapObjectMan, int x, int y, int direction, u32 mapno) {
FieldSystem *fsys;
@ -142,3 +146,60 @@ void sub_02069B74(MapObjectMan *mapObjectMan, u32 mapno) {
}
}
}
LocalMapObject *FollowingPokemon_GetMapObject(FieldSystem *fsys) {
return fsys->unkE4.mapObject;
}
u32 FollowingPokemon_GetSpriteID(int species, u16 forme, u32 gender) {
int ret;
if (species <= 0 || species > NATIONAL_DEX_COUNT) {
ret = SPRITE_TSURE_POKE_BULBASAUR;
} else {
ret = SPRITE_TSURE_POKE_BULBASAUR + SpeciesToOverworldModelIndexOffset(species);
if (OverworldModelLookupHasFemaleForme(species)) {
if (gender == MON_FEMALE) {
ret++;
}
} else {
if (forme > OverworldModelLookupFormeCount(species)) {
forme = 0;
}
ret += forme;
}
if (ret > SPRITE_TSURE_POKE_ARCEUS_DARK) {
ret = SPRITE_TSURE_POKE_BULBASAUR;
}
}
return ret;
}
void sub_02069DC8(LocalMapObject *mapObject, int a1) {
sub_0206A040(mapObject, a1);
if (a1) {
sub_02069DEC(mapObject, 1);
} else {
sub_02069DEC(mapObject, 0);
}
}
void sub_02069DEC(LocalMapObject *mapObject, int a1) {
int value;
u8 flag0;
u32 flag1;
u32 flag2;
value = MapObject_GetParam(mapObject, 2);
flag0 = value & 1;
flag1 = a1;
flag2 = value >> 2;
value = flag2 << 2;
value |= flag1 << 1;
value |= flag0 << 0;
MapObject_SetParam(mapObject, value, 2);
}
u8 sub_02069E14(LocalMapObject *mapObject) {
return (MapObject_GetParam(mapObject, 2) >> 1) & 1;
}