dungeon_serializer.c

This commit is contained in:
Kermalis 2024-11-10 15:11:07 -05:00
parent ab90cf0500
commit fa08c0e691
50 changed files with 3602 additions and 4222 deletions

View File

@ -87,7 +87,7 @@ _0804540C:
strh r2, [r0, 0x2]
movs r0, 0
mov r1, r8
bl sub_8069F54
bl GetMonsterApparentID
ldr r1, [r4, 0x70]
strh r0, [r1, 0x4]
ldr r0, [r4, 0x70]
@ -95,7 +95,7 @@ _0804540C:
strb r5, [r0, 0x6]
movs r0, 0
mov r1, r8
bl sub_8069F54
bl GetMonsterApparentID
lsls r0, 16
asrs r0, 16
bl GetSpriteData
@ -280,7 +280,7 @@ _0804557A:
strh r2, [r0, 0x2]
movs r0, 0
mov r1, r8
bl sub_8069F54
bl GetMonsterApparentID
ldr r1, [r4, 0x70]
strh r0, [r1, 0x4]
ldr r0, [r4, 0x70]
@ -288,7 +288,7 @@ _0804557A:
strb r3, [r0, 0x6]
movs r0, 0
mov r1, r8
bl sub_8069F54
bl GetMonsterApparentID
lsls r0, 16
asrs r0, 16
bl GetSpriteData

View File

@ -3136,7 +3136,7 @@ sub_806BB6C:
str r6, [sp, 0xC]
movs r0, 0
adds r1, r4, 0
bl sub_8069F54
bl GetMonsterApparentID
lsls r0, 16
adds r1, r7, 0
adds r1, 0x22

View File

@ -421,7 +421,7 @@ _0807E9A4:
movs r0, 0x2
ldrsh r1, [r4, r0]
adds r0, r5, 0
bl sub_8069F54
bl GetMonsterApparentID
b _0807E9D8
.align 2, 0
_0807E9D0: .4byte 0xfffffe88

File diff suppressed because it is too large Load Diff

View File

@ -115,6 +115,7 @@
'”' = 7E 39 34
'•' = 95
@ 96, 97 are not hyphens, 'er', and 're' superscripts in kanji_a
INVALID_SEQUENCE_976C = 97 6C
'˜' = 98
'™' = 99
'š' = 9A
@ -229,17 +230,21 @@
'' = 82 60
'' = 82 61
'' = 82 62
'い' = 82 A2
'う' = 82 A4
'か' = 82 A9
'が' = 82 AA
'き' = 82 AB
'さ' = 82 B3
'し' = 82 B5
'す' = 82 B7
'な' = 82 C8
'に' = 82 C9
'も' = 82 CC
'' = 82 DC
'' = 82 DD
'' = 82 DC
'' = 82 DD
'の' = 82 E0
'や' = 82 E2
'よ' = 82 E6
'る' = 82 E9
'を' = 82 F0

View File

@ -812,5 +812,12 @@ gUnknown_80F51EC: @ 80F51EC
.global gUnknown_80F520C
gUnknown_80F520C: @ 80F520C
@ replacing .incbin "baserom.gba", 0x000f520c, 0x20
.byte 0x01, 0x00, 0x78, 0x01, 0x02, 0x00, 0x7a, 0x01, 0x01, 0x00, 0x78, 0x01, 0x01, 0x00, 0x78, 0x01, 0x03, 0x00, 0x7b, 0x01, 0x06, 0x00, 0x79, 0x01, 0x03, 0x00, 0x7b, 0x01, 0x06, 0x00, 0x79, 0x01
.byte 0x01, 0x00, 0x78, 0x01
.byte 0x02, 0x00, 0x7a, 0x01
.byte 0x01, 0x00, 0x78, 0x01
.byte 0x01, 0x00, 0x78, 0x01
.byte 0x03, 0x00, 0x7b, 0x01
.byte 0x06, 0x00, 0x79, 0x01
.byte 0x03, 0x00, 0x7b, 0x01
.byte 0x06, 0x00, 0x79, 0x01

View File

@ -465,7 +465,8 @@ gUnknown_80F683C: @ 80F683C
.global gUnknown_80F6850
gUnknown_80F6850: @ 80F6850
@ replacing .incbin "baserom.gba", 0xF6850, 0x10
.byte 0x9e, 0x01, 0xa1, 0x01, 0xa2, 0x01, 0xa3, 0x01, 0x70, 0x6b, 0x73, 0x64, 0x69, 0x72, 0x30, 0x00
.byte 0x9e, 0x01, 0xa1, 0x01, 0xa2, 0x01, 0xa3, 0x01
.byte 0x70, 0x6b, 0x73, 0x64, 0x69, 0x72, 0x30, 0x00
.global gSpeedTurns
gSpeedTurns: @ 80F6860

File diff suppressed because it is too large Load Diff

1523
data/data_8107224.s Normal file

File diff suppressed because it is too large Load Diff

View File

@ -275,7 +275,7 @@ MoveUseTextBide:
.global MoveNameBide2
MoveNameBide2:
.string "\0"
.string "\0"
.align 2,0
.global MoveDescriptionIsWatching
@ -285,7 +285,7 @@ MoveDescriptionIsWatching:
.global MoveNameIsWatching
MoveNameIsWatching:
.string "\0"
.string "\0"
.align 2,0
.global MoveUseTextRegularAttack

8
include/code_800F958.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef GUARD_CODE_800F958_H
#define GUARD_CODE_800F958_H
#include "structs/str_position.h"
void AddPokemonDungeonSprite(s32 id, s16 species, Position *pos, u32);
#endif // GUARD_CODE_800F958_H

View File

@ -4,6 +4,7 @@
#include "structs/dungeon_entity.h"
#include "structs/str_damage.h"
void sub_80420E8(Entity *pokemon, struct DamageStruct *dmgStruct);
void sub_80420E8(Entity *pokemon, DamageStruct *dmgStruct);
void sub_80421C0(Entity *pokemon, u16);
#endif
#endif // GUARD_CODE_8041AD0_H

View File

@ -5,4 +5,6 @@
void SetMessageArgument(u8 *buffer, Entity *entity, u32 param_3);
#endif // GUARD_CODE_8045A00_H
void sub_8045ACC(void);
#endif // GUARD_CODE_8045A00_H

View File

@ -1,14 +1,7 @@
#ifndef GUARD_CODE_8092334_H
#define GUARD_CODE_8092334_H
// size: 0x10
typedef struct DataSerializer
{
u8 *stream;
u8 *end; // exclusive end of the stream
u32 count; // Used to count bits between ReadBits functions, or count bytes between ReadBytes functions
u32 unkC; // Seems to be a temporary 32 bit storage
} DataSerializer;
#include "data_serializer.h"
void nullsub_102(DataSerializer *seri);
void ReadBits(DataSerializer *seri, void *dst, s32 numBits);

13
include/data_serializer.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef GUARD_DATA_SERIALIZER_H
#define GUARD_DATA_SERIALIZER_H
// size: 0x10
typedef struct DataSerializer
{
u8 *stream;
u8 *end; // Exclusive end of the stream
u32 count; // Used to count bits between ReadBits functions, or count bytes between ReadBytes functions
u32 unkC; // Seems to be a temporary 32 bit storage
} DataSerializer;
#endif // GUARD_DATA_SERIALIZER_H

View File

@ -10,6 +10,8 @@ typedef struct unkStruct_202F190
Tile *GetTile(s32 x, s32 y);
Tile *GetTileSafe(s32 x, s32 y);
void sub_8049ED4(void);
void sub_804AC20(Position *pos);
#endif
#endif // GUARD_DUNGEON_MAP_ACCESS_H

View File

@ -0,0 +1,11 @@
#ifndef GUARD_DUNGEON_SERIALIZER_H
#define GUARD_DUNGEON_SERIALIZER_H
#include "data_serializer.h"
void ReadDungeonState(u8 *buffer, u32 bufLen);
void SaveDungeonState(u8 *buffer, u32 bufLen);
void sub_8082B40(void);
#endif // GUARD_DUNGEON_SERIALIZER_H

View File

@ -36,7 +36,7 @@ void LoadMonsterParameters(void);
unkStruct_203B45C *GetRecruitedPokemon(void);
void InitializeRecruitedPokemon(void);
// These two need to be overridden in status_actions.c
// This needs to be overridden in status_actions.c
// Uncomment when fixed
//u8 GetBodySize(s16 index);

View File

@ -2,6 +2,7 @@
#define GUARD_DUNGEON_ENTITY_H
#include "constants/global.h"
#include "constants/dungeon_action.h"
#include "structs/str_position.h"
#include "sprite.h"
#include "structs/str_items.h"
@ -28,10 +29,11 @@
#define NUM_PICKED_IQ_SKILLS 3
// size: 0x8
typedef struct unkStruct_8044CC8
{
u8 actionUseIndex;
Position lastItemThrowPosition;
/* 0x0 */ u8 actionUseIndex;
/* 0x4 */ Position lastItemThrowPosition;
} unkStruct_8044CC8;
// size: 0x18
@ -46,18 +48,21 @@ typedef struct ActionContainer
/* 0x14 */ Position itemTargetPosition;
} ActionContainer;
// size: 0x4
typedef struct HiddenPower
{
/* 0x0 */ s16 hiddenPowerBasePower;
/* 0x2 */ u8 hiddenPowerType;
} HiddenPower;
// size: 0x4
typedef struct JoinedAt
{
/* 0x0 */ u8 joinedAt;
/* 0x1 */ u8 unk1;
} JoinedAt;
// size: 0x14
typedef struct AITarget
{
/* 0x0 */ u8 aiObjective;
@ -68,15 +73,16 @@ typedef struct AITarget
/* 0x8 */ struct Entity *aiTarget;
/* 0xC */ u32 unkC;
/* 0x10 */ Position aiTargetPos;
} AITarget;
// size: 0x4
typedef struct Sleep
{
/* 0x0 */ u8 sleep;
/* 0x1 */ u8 sleepTurns;
} Sleep;
// size: 0x4
typedef struct NonVolatile
{
/* 0x0 */ u8 nonVolatileStatus;
@ -85,6 +91,7 @@ typedef struct NonVolatile
/* 0x3 */ u8 unk4;
} NonVolatile;
// size: 0xC
typedef struct Immobilize
{
/* 0x0 */ u8 immobilizeStatus;
@ -93,12 +100,14 @@ typedef struct Immobilize
/* 0x9 */ u8 immobilizeStatusDamageCountdown;
} Immobilize;
// size: 0x4
typedef struct Volatile
{
/* 0x0 */ u8 volatileStatus;
/* 0x1 */ u8 volatileStatusTurns;
} Volatile;
// size: 0x4
typedef struct Charging
{
/* 0x0 */ u8 chargingStatus;
@ -106,60 +115,68 @@ typedef struct Charging
/* 0x2 */ u8 chargingStatusMoveIndex; // The position of the move in the Pokémon's moveset that triggered the status.
} Charging;
// size: 0x4
typedef struct Protection
{
/* 0x0 */ u8 protectionStatus;
/* 0x1 */ u8 protectionStatusTurns;
} Protection;
// size: 0x8
typedef struct Waiting
{
/* 0xC8 */ u8 waitingStatus;
/* 0xC9 */ bool8 enemyDecoy; // True if the Pokémon is a decoy and a wild Pokémon (i.e., not an allied Pokémon).
u8 unkCA;
/* 0xCB */ u8 waitingStatusTurns;
/* 0xCC */ u8 curseDamageCountdown;
/* 0x0 */ u8 waitingStatus;
/* 0x1 */ bool8 enemyDecoy; // True if the Pokémon is a decoy and a wild Pokémon (i.e., not an allied Pokémon).
/* 0x2 */ bool8 unk2;
/* 0x3 */ u8 waitingStatusTurns;
/* 0x4 */ u8 curseDamageCountdown;
} Waiting;
// size: 0xC
typedef struct Linked
{
/* 0xD0 */ u8 linkedStatus;
/* 0xD4 */ u32 unkD4;
/* 0xD8 */ u8 unkD8;
/* 0xD9 */ u8 linkedStatusTurns;
/* 0xDA */ u8 linkedStatusDamageCountdown;
/* 0x0 */ u8 linkedStatus;
/* 0x4 */ u32 unk4;
/* 0x8 */ u8 unk8;
/* 0x9 */ u8 linkedStatusTurns;
/* 0xA */ u8 linkedStatusDamageCountdown;
} Linked;
// size: 0x4
typedef struct MoveStatus
{
/* 0xDC */ u8 moveStatus;
/* 0xDD */ u8 moveStatusTurns;
/* 0x0 */ u8 moveStatus;
/* 0x0 */ u8 moveStatusTurns;
} MoveStatus;
// size: 0x4
typedef struct ItemStatus
{
/* 0xE0 */ u8 itemStatus;
/* 0x0 */ u8 itemStatus;
} ItemStatus;
// size: 0x4
typedef struct TransformStatus
{
/* 0xE4 */ u8 transformStatus;
/* 0xE5 */ u8 transformStatusTurns;
/* 0x0 */ u8 transformStatus;
/* 0x0 */ u8 transformStatusTurns;
} TransformStatus;
// size: 0x4
typedef struct EyesightStatus
{
/* 0xE8 */ u8 eyesightStatus;
/* 0xE9 */ u8 eyesightStatusTurns;
/* 0x0 */ u8 eyesightStatus;
/* 0x0 */ u8 eyesightStatusTurns;
} EyesightStatus;
// size: 0x4
typedef struct Muzzled
{
/* 0xEC */ bool8 muzzled;
/* 0xED */ u8 muzzledTurns;
/* 0x0 */ bool8 muzzled;
/* 0x1 */ u8 muzzledTurns;
} Muzzled;
// size: 0x1C
typedef struct Unk_Entity_x184
{
/* 0x184 - 0x0 */ Position previousTargetMovePosition1;
@ -169,12 +186,13 @@ typedef struct Unk_Entity_x184
/* 0x194 - 0x10*/ Position32 lastMoveIncrement;
/* 0x19C - 0x18 */ s16 walkAnimFramesLeft; // Set when the Pokémon starts moving, and counts down until the Pokémon's walk animation stops.
/* 0x19e - 0x1a */ u8 unk1A;
} Unk_Entity_x184 ;
} Unk_Entity_x184;
// size: 0x24
typedef struct Moves
{
/* 0x118 */ Move moves[MAX_MON_MOVES];
/* 0x138 */ u8 struggleMoveFlags;
/* 0x0 */ Move moves[MAX_MON_MOVES];
/* 0x20 */ u8 struggleMoveFlags;
} Moves;
// size: 0x208

View File

@ -1,7 +1,8 @@
#ifndef GUARD_STR_DAMAGE_H
#define GUARD_STR_DAMAGE_H
struct DamageStruct
// size: 0x10
typedef struct DamageStruct
{
s32 dmg;
s32 residualDmgType;
@ -10,6 +11,6 @@ struct DamageStruct
bool8 isCrit;
u8 unkE;
bool8 tookNoDamage;
};
} DamageStruct;
#endif
#endif // GUARD_STR_DAMAGE_H

View File

@ -24,17 +24,17 @@ typedef struct DungeonLocation
/* 0x1 */ u8 floor;
} DungeonLocation;
// size: 0x18
typedef struct Weather
{
/* 0xE264 */ u8 weather; // Uses the weather constants in weather.h.
u8 unkE265; // Uses the weather constants in weather.h
/* 0xE266 */ u8 weatherDamageCounter; // Timer for applying sandstorm/hail damage periodically.
/* 0xE267 */ u8 unkE267[8];
/* 0xE26F */ u8 naturalWeather[8]; // The weather at the start of the floor. If the weather changes, then expires, revert back to the starting weather.
/* 0xE277 */ u8 mudSportTurns;
/* 0xE278 */ u8 waterSportTurns;
/* 0xE279 */ bool8 nullifyWeather; // Air Lock and Cloud Nine toggle this to disable weather effects
/* 0x0 */ u8 weather; // Uses the weather constants in weather.h.
/* 0x1 */ u8 unkE265; // Uses the weather constants in weather.h
/* 0x2 */ u8 weatherDamageCounter; // Timer for applying sandstorm/hail damage periodically.
/* 0x3 */ u8 unkE267[8];
/* 0xB */ u8 naturalWeather[8]; // The weather at the start of the floor. If the weather changes, then expires, revert back to the starting weather.
/* 0x13 */ u8 mudSportTurns;
/* 0x14 */ u8 waterSportTurns;
/* 0x15 */ bool8 nullifyWeather; // Air Lock and Cloud Nine toggle this to disable weather effects
} Weather;
// size: 0x30
@ -66,6 +66,8 @@ typedef struct DungeonMusicPlayer
/* 0x0 */ u32 state;
/* 0x4 */ u32 fadeOutSpeed;
/* 0x8 */ u16 fadeInSpeed;
// dungeon_serializer.c refers to these 3 as s16, but they are almost always handled as u16
/* 0xA */ u16 songIndex;
/* 0xC */ u16 pastSongIndex;
/* 0xE */ u16 queuedSongIndex;
@ -85,15 +87,15 @@ typedef struct UnkDungeonGlobal_unk181E8_sub
u8 unk18208; // x20
/* 0x18209 */ u8 visibilityRange; // x21 Dungeon light level.
/* 0x1820A */ bool8 blinded; // x22 Blacks out the screen when the player has the Blinker status.
u8 unk1820B; // x23
u8 unk1820C; // x24
u8 unk1820D; // x25
u8 unk1820E; // x26
u8 unk1820F; // x27
bool8 unk1820B; // x23
bool8 unk1820C; // x24
bool8 unk1820D; // x25
bool8 unk1820E; // x26
bool8 unk1820F; // x27
/* 0x18210 */ bool8 hallucinating; // x28 Displays Substitute and flower sprites when the player has the Cross-Eyed status.
u8 unk18211; // x29
bool8 unk18211; // x29
u8 unk18212; // x2A
u8 unk18213; // x2B
bool8 unk18213; // x2B
u8 unk18214; // x2C
u8 unk18215; // x2D
u8 unk18216; // x2E
@ -281,6 +283,22 @@ typedef struct unkDungeon644
/* 0x55 */ u8 unk55;
} unkDungeon644;
// size: 0x10
typedef struct unkDungeonE240
{
/* 0x0 */ u32 unk0;
/* 0x4 */ u32 unk4;
/* 0x8 */ u32 unk8;
/* 0xC */ u32 unkC;
} unkDungeonE240;
// size: 0x4
typedef struct unkDungeonE260
{
/* 0x0 */ u16 unk0;
/* 0x2 */ u16 unk2;
} unkDungeonE260;
// size: 0x1CEDC
typedef struct Dungeon
{
@ -315,7 +333,7 @@ typedef struct Dungeon
/* 0x5C0 */ s32 unk5C0;
/* 0x5C4 */ struct unkStruct_Dungeon5C4_sub unk5C4[3];
/* 0x5F4 */ u8 faintStringBuffer[80];
unkDungeon644 unk644; // This data persists between save/reload. See sub_8080B90 and sub_8081C50
unkDungeon644 unk644;
EntityInfo unk69C[MAX_TEAM_MEMBERS];
EntityInfo unkEBC[DUNGEON_MAX_WILD_POKEMON_BODY_SIZE];
u8 fill2F3C[0x343C - 0x2F3C];
@ -331,17 +349,18 @@ typedef struct Dungeon
/* 0x37F8 */ bool8 plusIsActive[2]; // Index 0: Enemy , Index 1: Team
/* 0x37FA */ bool8 minusIsActive[2]; // Index 0: Enemy , Index 1: Team
/* 0x37FC */ bool8 decoyActive;
/* 0x37FD */ u8 unk37FD;
/* 0x37FD */ bool8 unk37FD;
/* 0x37FE */ bool8 deoxysDefeat; // Flag set for deoxys in Meteor Cave
/* 0x37FE */ u8 unk37FF;
s16 unk3800;
EntityInfo *unk3804[DUNGEON_MAX_ITEMS];
/* 0x37FE */ bool8 unk37FF;
// dungeon_serializer.c refers to this as a u16 but elsewhere it's handled as a s16
/* 0x3800 */ s16 deoxysForm;
EntityInfo *unk3804[DUNGEON_MAX_ITEMS]; // TODO: ItemInfo[DUNGEON_MAX_ITEMS]
/* 0x3904 */ s16 unk3904;
EntityInfo *unk3908[DUNGEON_MAX_TRAPS];
/* 0x3A08 */ u8 unk3A08;
/* 0x3A09 */ u8 unk3A09;
/* 0x3A0A */ u8 unk3A0A;
/* 0x3A0B */ u8 unk3A0B;
EntityInfo *unk3908[DUNGEON_MAX_TRAPS]; // TODO: TrapInfo[DUNGEON_MAX_TRAPS]
/* 0x3A08 */ bool8 unk3A08;
/* 0x3A09 */ bool8 unk3A09;
/* 0x3A0A */ bool8 unk3A0A;
/* 0x3A0B */ bool8 unk3A0B;
u8 unk3A0C;
/* 0x3A0D */ u8 unk3A0D;
/* 0x3A0E */ s16 tileset;
@ -353,9 +372,9 @@ typedef struct Dungeon
Position unkE218;
Position unkE21C; // stair location?
Position unkE220[8];
u32 unkE240[4];
u32 unkE250[4];
u16 unkE260[2];
unkDungeonE240 unkE240;
unkDungeonE240 unkE250;
unkDungeonE260 unkE260;
/* 0xE264 */ Weather weather; // Uses the weather constants in weather.h.
/* 0xE27C */ Tile unkE27C[8][8];
/* 0xE87C */ u8 unkE87C[8][8];

View File

@ -278,8 +278,7 @@ SECTIONS {
src/trap.o(.text);
asm/code_807FCD4.o(.text);
src/trap_1.o(.text);
asm/code_8080CF0.o(.text);
src/code_8083288.o(.text);
src/dungeon_serializer.o(.text);
src/dungeon_range.o(.text);
src/code_808333C.o(.text);
src/dungeon_leader.o(.text);
@ -557,6 +556,8 @@ SECTIONS {
src/dungeon_capabilities.o(.rodata);
src/dungeon_ai_targeting.o(.rodata);
data/data_8107010.o(.rodata);
src/dungeon_serializer.o(.rodata);
data/data_8107224.o(.rodata);
src/game_options.o(.rodata);
data/data_8109964.o(.rodata);
src/code_80972F4.o(.rodata);

View File

@ -1,4 +1,5 @@
#include "global.h"
#include "code_800F958.h"
#include "dungeon_pokemon_sprites.h"
#include "memory.h"
@ -7,7 +8,8 @@ extern DungeonPokemonSprite* GetDungeonPokemonSprite(s32 id);
extern Position gUnknown_80D3564;
void AddPokemonDungeonSprite(s32 id, s16 species, Position *pos, u32 r3) {
void AddPokemonDungeonSprite(s32 id, s16 species, Position *pos, u32 r3)
{
DungeonPokemonSprite *dSprite;
DungeonPokemonSprite *newSprite;
Position newPos;

View File

@ -64,7 +64,6 @@ extern u32 gUnknown_3001018[];
extern void sub_8040A84();
extern void sub_8083D44(void);
extern void sub_8049ED4(void);
extern void sub_8040A84(void);
extern void sub_80400D4(void);
extern void sub_8041888(u8 param_1);

View File

@ -19,7 +19,6 @@ extern OpenedFile *gUnknown_202EE04;
extern void sub_803F7BC(void);
extern void sub_803F580(u32);
extern void sub_8049ED4();
extern void sub_8040A84();
extern const char *gUnknown_80FD040; // It became brighter on the floor

View File

@ -37,7 +37,6 @@ extern void PlaySoundEffect(u32);
extern u8 sub_803F428(Position *pos);
extern void sub_8041550(Entity *pokemon, u32, u32, u32, u32, u32);
void sub_80421C0(Entity *pokemon, u16 r1);
void EntityUpdateStatusSprites(Entity *entity);
extern s32 gDungeonBrightness;

View File

@ -1,6 +1,6 @@
#include "global.h"
#include "code_8041AD0.h"
#include "code_804267C.h"
#include "code_803E46C.h"
#include "code_803E668.h"
#include "code_8045A00.h"
@ -24,7 +24,6 @@ extern void sub_8040238(void);
extern void sub_804151C(Entity *pokemon, u32 r1, u8 r2);
extern void sub_804178C(u32);
extern void sub_80416A4(Position *r0, u32 r1, bool8 r2);
extern void sub_80421C0(Entity *pokemon, u16 r1);
extern void sub_80429A0(Entity *);
extern void sub_8042B34(u32, u32, u32);
extern bool8 sub_8042CC0(void);

View File

@ -35,6 +35,7 @@
#include "constants/dungeon.h"
#include "constants/monster.h"
#include "constants/trap.h"
#include "dungeon_serializer.h"
extern void sub_800EE5C(s32);
extern void sub_800EF64(void);
@ -243,7 +244,7 @@ void sub_8042EC8(Entity *a0, s32 a1)
}
extern u8 gUnknown_203B40C;
extern u16 gUnknown_203B410;
extern Position gUnknown_203B410;
extern u8 *gSerializedData_203B41C;
struct Substruct_xxx_dungeon_8042F6C
@ -332,13 +333,11 @@ extern void sub_80521D0(void);
extern void sub_803F27C(u8);
extern void sub_807E7FC(u8);
extern void sub_80095CC(u32, u32);
extern void ReadDungeonState(u8 *r0, u32 r1);
extern bool8 IsLevelResetTo1(u8 dungeon);
extern void sub_8068A84(PokemonStruct1 *pokemon);
extern void sub_807EAA0(u32, u32);
extern void sub_803D4D0(void);
extern void sub_80842F0(void);
extern void sub_8082B40(void);
extern void sub_80427AC(void);
extern void sub_806AA70(void);
extern void sub_803D8F0(void);
@ -357,7 +356,6 @@ extern void sub_8045CB0(void);
extern void sub_807FA18(void);
extern void sub_806A974(void);
extern void sub_806CF60(void);
extern void sub_8049ED4(void);
extern void sub_8049884(void);
extern void sub_8068F80(void);
extern bool8 sub_8044B28(void);
@ -371,7 +369,6 @@ extern void sub_803EAF0(u32, u32);
extern void sub_806A914(u8 a0, u8 a1, u8 a2);
extern void sub_803F4A0(Entity *a0);
extern void sub_8083AB0(s16 param_0, Entity * target, Entity * entity);
extern void WriteDungeonState(u8 *param_1,u32 param_2);
extern void sub_8046F84(s32 itemFlag);
extern bool8 sub_8083C50(void);
extern void sub_8068FE0(Entity *, u32, Entity *r2);
@ -400,7 +397,7 @@ extern const u8 *const gUnknown_80F89B4;
extern const u8 *const gUnknown_80F89D4;
extern const u8 *const gUnknown_80F89D8;
extern const s16 gUnknown_80F6850[];
extern const s16 gUnknown_80F6850[4];
extern const s16 gDungeonMusic[];
extern OpenedFile *gDungeonNameBannerPalette;
@ -433,8 +430,8 @@ void xxx_dungeon_8042F6C(struct UnkStruct_xxx_dungeon_8042F6C *r8)
dungeonPtr[i] = 0;
}
gUnknown_203B410 = 0; // Needed to match
gUnknown_203B410 = 100;
gUnknown_203B410.x = 0; // Needed to match
gUnknown_203B410.x = 100;
if (!r6) {
gDungeon->unk644.unk34 = r8->unkF;
@ -565,7 +562,7 @@ void xxx_dungeon_8042F6C(struct UnkStruct_xxx_dungeon_8042F6C *r8)
rnd = DungeonRandInt(4);
gDungeon->unk37FD = 0;
gDungeon->deoxysDefeat = FALSE;
gDungeon->unk3800 = gUnknown_80F6850[rnd];
gDungeon->deoxysForm = gUnknown_80F6850[rnd];
gDungeon->unk37FF = 0;
gDungeon->unk644.unk31 = 0;
}
@ -824,7 +821,7 @@ void xxx_dungeon_8042F6C(struct UnkStruct_xxx_dungeon_8042F6C *r8)
gUnknown_203B40C = 0;
if (gDungeon->unk3 != 0) {
WriteDungeonState(gSerializedData_203B41C, 0x4800);
SaveDungeonState(gSerializedData_203B41C, 0x4800);
r8->unk7C = 3;
r8->unk80 = gDungeon->unk644.dungeonLocation;
check = FALSE;
@ -834,7 +831,7 @@ void xxx_dungeon_8042F6C(struct UnkStruct_xxx_dungeon_8042F6C *r8)
s16 var;
if (gDungeon->unk6 != 0) {
WriteDungeonState(gSerializedData_203B41C, 0x4800);
SaveDungeonState(gSerializedData_203B41C, 0x4800);
}
else {
sub_8046F84(ITEM_FLAG_IN_SHOP);

View File

@ -1,5 +1,6 @@
#include "global.h"
#include "code_803E668.h"
#include "code_8041AD0.h"
#include "code_8045A00.h"
#include "dungeon_message.h"
#include "code_8077274_1.h"
@ -85,7 +86,6 @@ extern u8 *gUnknown_80F9BD8[];
#include "data/code_8048480.h"
extern void sub_80421C0(Entity *r0, u16 r1);
extern void sub_8078B5C(Entity *, Entity *, u32, u32, u32);
extern u8 sub_806A538(s32);
extern void sub_8051E7C(Entity *pokemon);

View File

@ -2,6 +2,7 @@
#include "code_805D8C8.h"
#include "structs/str_dungeon.h"
#include "dungeon_util.h"
#include "pokemon.h"
// monster_sbin.s
extern const struct FileArchive gMonsterFileArchive;
@ -35,14 +36,14 @@ void sub_80687AC(void)
OpenedFile *GetSpriteData(s16 species)
{
s32 species32 = species;
s32 species32 = SpeciesId(species);
return gDungeon->sprites[species32];
}
static void EnsureSpriteLoaded(s32 _id)
static void EnsureSpriteLoaded(s32 _id) // TODO: Should this param be s16? If so, the castform part of LoadPokemonSprite is preventing us
{
u8 name [12];
s32 id = (s16)_id;
u8 name[12];
s32 id = SpeciesId(_id);
if (gDungeon->sprites[id] == NULL) {
sprintf(name, gUnknown_8106EA0, id);
@ -52,20 +53,35 @@ static void EnsureSpriteLoaded(s32 _id)
void LoadPokemonSprite(s16 id, bool32 a1)
{
s32 id_s32 = id;
s32 id_s32 = SpeciesId(id);
bool8 param_2 = a1;
if (!param_2 &&
(id_s32 == MONSTER_DEOXYS_NORMAL || id_s32 == MONSTER_DEOXYS_ATTACK || id_s32 == MONSTER_DEOXYS_DEFENSE || id_s32 == MONSTER_DEOXYS_SPEED)) {
if (!param_2 && (id_s32 == MONSTER_DEOXYS_NORMAL || id_s32 == MONSTER_DEOXYS_ATTACK || id_s32 == MONSTER_DEOXYS_DEFENSE || id_s32 == MONSTER_DEOXYS_SPEED)) {
EnsureDeoxysLoaded();
}
else {
EnsureSpriteLoaded(id_s32);
// >= MONSTER_CASTFORM && <= MONSTER_CASTFORM_RAINY
if ((u16)(id_s32 - MONSTER_CASTFORM) < 4)
EnsureCastformLoaded();
}
}
/*void LoadPokemonSprite(s16 id, bool8 a1)
{
s32 id_s32 = SpeciesId(id);
if (!a1 && (id_s32 == MONSTER_DEOXYS_NORMAL || id_s32 == MONSTER_DEOXYS_ATTACK || id_s32 == MONSTER_DEOXYS_DEFENSE || id_s32 == MONSTER_DEOXYS_SPEED)) {
EnsureDeoxysLoaded();
}
else {
EnsureSpriteLoaded(id);
// TODO: >= MONSTER_CASTFORM && <= MONSTER_CASTFORM_RAINY
if (id_s32 == MONSTER_CASTFORM || id_s32 == MONSTER_CASTFORM_SNOWY || id_s32 == MONSTER_CASTFORM_SUNNY || id_s32 == MONSTER_CASTFORM_RAINY)
//if ((u16)(id_s32 - MONSTER_CASTFORM) < 4)
EnsureCastformLoaded();
}
}*/
static void EnsureCastformLoaded(void)
{
@ -77,7 +93,7 @@ static void EnsureCastformLoaded(void)
static void EnsureDeoxysLoaded(void)
{
EnsureSpriteLoaded(gDungeon->unk3800);
EnsureSpriteLoaded(gDungeon->deoxysForm);
}
void CloseAllSpriteFiles(void)

View File

@ -79,7 +79,6 @@ void sub_805E738(Entity *a0);
void sub_803E708(s32 a0, s32 a1);
void sub_8040A78(void);
void sub_805E804(void);
void sub_8049ED4(void);
void sub_8064BE0(void);
void sub_8075680(u32);
void sub_8094C88(void);

View File

@ -23,12 +23,13 @@
struct unkStruct_80F520C
{
u8 unk0;
u8 unk1;
s16 unk2;
u8 unk0; // types0
u8 unk1; // Most likely just padding and should be removed
s16 unk2; // monsterID
};
extern struct unkStruct_80F520C gUnknown_80F520C[];
// Castform Forecast ability data
extern struct unkStruct_80F520C gUnknown_80F520C[WEATHER_RANDOM];
extern u8 gUnknown_80F51E4[];
extern u8 *gUnknown_80FCC7C[];
@ -93,17 +94,15 @@ void TriggerWeatherAbilities(void)
}
}
s32 sub_8069F54(Entity *pokemon, s16 param_2)
s32 GetMonsterApparentID(Entity *pokemon, s16 id)
{
if ((((param_2 * 0x10000) + 0xfe880000U) >> 0x10) < 4) {
if (HasAbility(pokemon, ABILITY_FORECAST)) {
return gUnknown_80F520C[GetApparentWeather(pokemon)].unk2;
if (id == MONSTER_CASTFORM || id == MONSTER_CASTFORM_SNOWY || id == MONSTER_CASTFORM_SUNNY || id == MONSTER_CASTFORM_RAINY) {
if (HasAbility(pokemon, ABILITY_FORECAST))
return gUnknown_80F520C[GetApparentWeather(pokemon)].unk2;
return MONSTER_CASTFORM;
}
else {
return 0x178;
}
}
return param_2;
return id;
}
static inline u8 sub_8069F9C_sub(Entity *pokemon)

View File

@ -35,6 +35,7 @@
#include "code_8041AD0.h"
#include "type_chart.h"
#include "dungeon_message.h"
#include "dungeon_map_access.h"
extern u8 gUnknown_202F221;
@ -288,7 +289,6 @@ extern bool8 DoEnemiesEvolveWhenKOed(u8 dungeon);
extern bool8 sub_806FA5C(Entity *, Entity *, struct unkStruct_8069D4C *);
extern void EntityUpdateStatusSprites(Entity *);
extern bool8 sub_8045888(Entity *r0);
extern void sub_8049ED4(void);
extern const s32 gUnknown_8106A4C;
extern const s16 gUnknown_80F4E10;
@ -473,11 +473,11 @@ void HandleDealingDamage(Entity *attacker, Entity *target, struct DamageStruct *
if (r9) {
EntityInfo *targetInfo = GetEntInfo(target);
if (targetInfo->linked.linkedStatus == STATUS_DESTINY_BOND) {
Entity *destBondTarget = gDungeon->allPokemon[targetInfo->linked.unkD8];
Entity *destBondTarget = gDungeon->allPokemon[targetInfo->linked.unk8];
if (destBondTarget == NULL) {
targetInfo->linked.linkedStatus = 0;
}
else if (GetEntInfo(destBondTarget)->unk98 != targetInfo->linked.unkD4) {
else if (GetEntInfo(destBondTarget)->unk98 != targetInfo->linked.unk4) {
targetInfo->linked.linkedStatus = 0;
}
else {

View File

@ -4,6 +4,7 @@
#include "dungeon_pokemon_attributes.h"
#include "dungeon_leader.h"
#include "dungeon_message.h"
#include "code_8041AD0.h"
#include "code_8045A00.h"
#include "code_8077274_1.h"
#include "constants/dungeon.h"
@ -50,7 +51,6 @@ extern u8 *gUnknown_80FF730[];
extern u8 gUnknown_8107010[8];
extern u8 *gUnknown_8107018[3];
extern void sub_80421C0(Entity *pokemon, u16 r1);
void sub_8083D58(void);
void sub_8072778(Entity *, Entity *, u8, u8);
bool8 sub_80725A4(Entity *, Entity *);

View File

@ -529,7 +529,7 @@ void sub_8074094(Entity *entity)
if (entityInfo->linked.linkedStatus == STATUS_LEECH_SEED) {
if (entityInfo->linked.linkedStatusDamageCountdown == 0 || --entityInfo->linked.linkedStatusDamageCountdown == 0) {
s32 hp = gUnknown_80F4FB4;
Entity *target = gDungeon->allPokemon[entityInfo->linked.unkD8];
Entity *target = gDungeon->allPokemon[entityInfo->linked.unk8];
entityInfo->linked.linkedStatusDamageCountdown = gUnknown_80F4F40;
if (target == NULL) {
@ -537,7 +537,7 @@ void sub_8074094(Entity *entity)
}
else {
EntityInfo *targetInfo = GetEntInfo(target);
if (targetInfo->unk98 != entityInfo->linked.unkD4) {
if (targetInfo->unk98 != entityInfo->linked.unk4) {
entityInfo->linked.linkedStatus = 0;
}
else {

View File

@ -17,7 +17,6 @@
#include "position_util.h"
#include "trap.h"
extern void sub_8049ED4(void);
extern void sub_8073D14(Entity *);
void sub_8075680(void)

View File

@ -22,6 +22,7 @@
#include "status_checks_1.h"
#include "structs/dungeon_entity.h"
#include "structs/str_dungeon.h"
#include "dungeon_map_access.h"
extern u8 *gUnknown_80FA8BC[];
extern u8 *gUnknown_80FA824[];
@ -165,12 +166,11 @@ extern s16 gUnknown_80F4F1C[];
extern u8 *gUnknown_80FBF68[];
extern u8 *gUnknown_80FBF84[];
extern void sub_8049ED4();
extern void sub_8040A84();
extern void EntityUpdateStatusSprites(Entity *);
extern void sub_8042A74(Entity *r0);
extern void sub_807EC28(bool8);
extern s32 sub_8069F54(Entity *param_1, s16 param_2);
extern s32 GetMonsterApparentID(Entity *param_1, s16 param_2);
extern void sub_806A898(Entity *, u32, u32);
extern void HealTargetHP(Entity *pokemon, Entity *r1, s16, s16, u32);
extern void DealDamageToEntity(Entity *, s16, u32, u32);
@ -260,7 +260,7 @@ void TransformStatusTarget(Entity * pokemon, Entity * target)
for (index = 0; index < DUNGEON_MAX_POKEMON; index++) {
species = ExtractSpeciesIndex(&auStack544[DungeonRandInt(iVar5) * 2]);
apparentID_s16 = sub_8069F54(target, species);
apparentID_s16 = GetMonsterApparentID(target, species);
apparentID = apparentID_s16;
if (apparentID != entityInfo->apparentID && sub_806AA0C(apparentID, 1)) {
@ -1427,7 +1427,7 @@ void SendLinkedEndMessage(Entity * pokemon, Entity * target)
break;
}
entityInfo->linked.linkedStatus = STATUS_NONE;
entityInfo->linked.unkD8 = 0xff;
entityInfo->linked.unk8 = 0xff;
EntityUpdateStatusSprites(target);
}
}
@ -1486,7 +1486,7 @@ void SendTransformEndMessage(Entity * pokemon, Entity *target)
TryDisplayDungeonLoggableMessage(target,*gUnknown_80FABBC);
break;
case STATUS_TRANSFORMED:
entityInfo->apparentID = sub_8069F54(target, entityInfo->id);
entityInfo->apparentID = GetMonsterApparentID(target, entityInfo->id);
target->axObj.spriteFile = GetSpriteData(entityInfo->apparentID);
uVar3 = sub_806CEBC(target);
sub_806CCB4(target,uVar3);

View File

@ -18,6 +18,7 @@
#include "move_effects_target.h"
#include "moves.h"
#include "move_util.h"
#include "code_8041AD0.h"
extern u32 gUnknown_202EDCC;
@ -38,7 +39,6 @@ bool8 ExposeTrap(s32 x, s32 y);
void sub_8040A84();
void sub_8049ED4();
void sub_806A5B8(Entity *);
void sub_80421C0(Entity *, u32);
u8 sub_8045888(Entity *);
void sub_807EC28(u32);
void sub_80694C0(Entity *, s32, s32, s32);

View File

@ -1,548 +0,0 @@
#include "global.h"
#include "constants/dungeon_action.h"
#include "code_805D8C8.h"
#include "code_806CD90.h"
#include "code_8092334.h"
#include "dungeon_map_access.h"
#include "dungeon_util.h"
#include "structs/dungeon_entity.h"
#include "structs/str_dungeon.h"
#include "structs/str_position.h"
u16 ReadU16(DataSerializer *param_1);
s16 ReadS16(DataSerializer *param_1);
u8 ReadU8(DataSerializer *param_1);
u32 sub_80831A0(DataSerializer *param_1);
bool8 ReadBool8(DataSerializer *param_1);
void ReadBytes(DataSerializer *param_1, void *param_2, s32 size);
void ReadPosition8(DataSerializer *param_1,Position *param_2);
void AddPokemonDungeonSprite(u32, s16, Position *, u32);
void sub_8082B40(void)
{
EntityInfo *info;
Entity *entity;
int index;
Position pos;
for(index = 0; index < DUNGEON_MAX_POKEMON; index++)
{
entity = gDungeon->allPokemon[index];
if (EntityExists(entity)) {
info = GetEntInfo(entity);
entity->axObj.spriteFile = GetSpriteData(info->apparentID);
sub_806CCB4(entity,sub_806CEBC(entity));
pos = entity->pos;
AddPokemonDungeonSprite(info->unk98,info->apparentID,&pos,3);
entity->room = GetTileSafe(entity->pos.x,entity->pos.y)->room;
}
}
}
// Seems to be a new file (regarding serialization) starting here
s16 sub_8082BC0(DataSerializer *param_1)
{
s16 temp[2];
temp[0] = 0;
ReadBytes(param_1, temp, 2);
return temp[0];
}
u8 sub_8082BE0(DataSerializer *param_1)
{
u8 temp[4];
temp[0] = 0;
ReadBytes(param_1, temp, 1);
return temp[0];
}
u8 sub_8082BFC(DataSerializer *param_1)
{
u8 temp[4];
temp[0] = 0;
ReadBytes(param_1, temp, 1);
return temp[0];
}
u8 sub_8082C18(DataSerializer *param_1)
{
u8 temp[4];
temp[0] = 0;
ReadBytes(param_1, temp, 1);
return temp[0];
}
u8 sub_8082C34(DataSerializer *param_1)
{
u8 temp[4];
temp[0] = 0;
ReadBytes(param_1, temp, 1);
return temp[0];
}
u8 sub_8082C50(DataSerializer *param_1)
{
u8 temp[4];
temp[0] = 0;
ReadBytes(param_1, temp, 1);
return temp[0];
}
// Read some enum ?
u32 sub_8082C6C(DataSerializer *param_1)
{
u32 temp;
temp = 0;
ReadBytes(param_1, &temp, 4);
return temp;
}
u8 sub_8082C84(DataSerializer *param_1)
{
u8 temp[4];
temp[0] = 0;
ReadBytes(param_1, temp, 1);
return temp[0];
}
u8 sub_8082CA0(DataSerializer *param_1)
{
u8 temp[4];
temp[0] = 0;
ReadBytes(param_1, temp, 1);
return temp[0];
}
void ReadActionContainer(DataSerializer *param_1, ActionContainer *action)
{
action->action = ACTION_NOTHING;
ReadBytes(param_1, &action->direction, 1);
action->unk3 = 7;
ReadPosition8(param_1, &action->itemTargetPosition);
}
void ReadAITarget(DataSerializer *param_1, AITarget *aitarget)
{
ReadBytes(param_1, &aitarget->aiObjective, 1);
aitarget->aiNotNextToTarget = ReadBool8(param_1);
aitarget->aiTargetingEnemy = ReadBool8(param_1);
aitarget->aiTurningAround = ReadBool8(param_1);
aitarget->aiTargetSpawnGenID = ReadU16(param_1);
aitarget->aiTarget = NULL;
aitarget->unkC = 0;
ReadPosition8(param_1, &aitarget->aiTargetPos);
}
void Read3Bytes(DataSerializer *param_1, u8 *dst)
{
ReadBytes(param_1, dst, 3);
}
void ReadSleep(DataSerializer *param_1, Sleep *sleep)
{
ReadBytes(param_1, &sleep->sleep, 1);
sleep->sleepTurns = ReadU8(param_1);
}
void ReadNonVolatile(DataSerializer *param_1, NonVolatile *nonvolatile)
{
ReadBytes(param_1, &nonvolatile->nonVolatileStatus, 1);
nonvolatile->nonVolatileStatusTurns = ReadU8(param_1);
nonvolatile->nonVolatileStatusDamageCountdown = ReadU8(param_1);
nonvolatile->unk4 = ReadU8(param_1);
}
void ReadImmobilize(DataSerializer *param_1, Immobilize *immobilize)
{
ReadBytes(param_1, &immobilize->immobilizeStatus, 1);
immobilize->immobilizeStatusTurns = ReadU8(param_1);
immobilize->immobilizeStatusDamageCountdown = ReadU8(param_1);
immobilize->unk4 = sub_80831A0(param_1);
}
void ReadVolatileStatus(DataSerializer *param_1, Volatile *volatileStatus)
{
ReadBytes(param_1, &volatileStatus->volatileStatus, 1);
volatileStatus->volatileStatusTurns = ReadU8(param_1);
}
void ReadCharging(DataSerializer *param_1, Charging *charging)
{
ReadBytes(param_1, &charging->chargingStatus, 1);
charging->chargingStatusTurns = ReadU8(param_1);
charging->chargingStatusMoveIndex = ReadU8(param_1);
}
void ReadProtection(DataSerializer *param_1, Protection *protect)
{
ReadBytes(param_1, &protect->protectionStatus, 1);
protect->protectionStatusTurns = ReadU8(param_1);
}
void ReadWaiting(DataSerializer *param_1, Waiting *waiting)
{
ReadBytes(param_1, &waiting->waitingStatus, 1);
waiting->enemyDecoy = ReadBool8(param_1);
waiting->unkCA = ReadBool8(param_1);
waiting->waitingStatusTurns = ReadU8(param_1);
waiting->curseDamageCountdown = ReadU8(param_1);
}
void ReadLinked(DataSerializer *param_1, Linked *linked)
{
ReadBytes(param_1, &linked->linkedStatus, 1);
linked->unkD4 = sub_80831A0(param_1);
linked->unkD8 = ReadU8(param_1);
linked->linkedStatusTurns = ReadU8(param_1);
linked->linkedStatusDamageCountdown = ReadU8(param_1);
}
void ReadMoveStatus(DataSerializer *param_1, MoveStatus *moveStatus)
{
ReadBytes(param_1, &moveStatus->moveStatus, 1);
moveStatus->moveStatusTurns = ReadU8(param_1);
}
void sub_8082E88(DataSerializer *param_1, void *dst, s32 param_3)
{
ReadBytes(param_1, dst, 1);
}
void ReadTransformStatus(DataSerializer *param_1, TransformStatus *transform)
{
ReadBytes(param_1, &transform->transformStatus, 1);
transform->transformStatusTurns = ReadU8(param_1);
}
void ReadEyesightStatus(DataSerializer *param_1, EyesightStatus *eyesight)
{
ReadBytes(param_1, &eyesight->eyesightStatus, 1);
eyesight->eyesightStatusTurns = ReadU8(param_1);
}
void ReadMuzzled(DataSerializer *param_1, Muzzled *muzzle)
{
ReadBytes(param_1, &muzzle->muzzled, 1);
muzzle->muzzledTurns = ReadU8(param_1);
}
void RestoreDungeonPokemonMove(DataSerializer *param_1, Move *move)
{
move->moveFlags = ReadU8(param_1);
move->moveFlags2 = ReadU8(param_1);
ReadBytes(param_1, &move->id, 2);
move->PP = ReadU8(param_1);
move->ginseng = ReadU8(param_1);
}
void ReadMoves(DataSerializer *param_1, Moves *moves)
{
s32 index;
Move *move;
for (index = 0; index < MAX_MON_MOVES; index++) {
move = &moves->moves[index];
RestoreDungeonPokemonMove(param_1, move);
}
moves->struggleMoveFlags = ReadU8(param_1);
}
// TODO: R1 struct
void sub_8082F48(DataSerializer *param_1, u16 *r1)
{
r1[0] = ReadS16(param_1);
r1[1] = ReadS16(param_1);
}
void ReadJoinedAt(DataSerializer *param_1, JoinedAt *joined)
{
joined->joinedAt = ReadU8(param_1);
joined->unk1 = ReadU8(param_1);
}
void ReadHiddenPower(DataSerializer *param_1, HiddenPower *hidden)
{
hidden->hiddenPowerBasePower = ReadS16(param_1);
hidden->hiddenPowerType = sub_8082BFC(param_1);
}
void InitByteWriter(DataSerializer *param_1, u8 *dst, u32 capacity)
{
param_1->stream = dst;
param_1->count = 0;
param_1->end = dst + capacity;
}
void WriteBytes(DataSerializer *param_1, void *src, s32 numBytes)
{
u8 *curByte;
curByte = src;
while (numBytes != 0) {
*param_1->stream = *curByte;
param_1->stream++;
curByte++;
numBytes--;
param_1->count++;
}
}
void InitByteReader(DataSerializer *param_1, u8 *src, u32 length)
{
param_1->stream = src;
param_1->count = 0;
param_1->end = src + length;
}
void ReadBytes(DataSerializer *param_1, void *dst, s32 numBytes)
{
u8 *curByte;
curByte = dst;
while (numBytes != 0) {
*curByte = *param_1->stream;
param_1->stream++;
curByte++;
numBytes--;
param_1->count++;
}
}
// Finished reading/writing dungeon
void nullsub_98(DataSerializer *param_1)
{
}
void Write8Bytes(DataSerializer *param_1, u8 *src)
{
WriteBytes(param_1, src, 8);
}
void sub_8083018(DataSerializer *param_1)
{
u8 auStack_10 [12];
ReadBytes(param_1, auStack_10, 8);
auStack_10[8] = 0;
}
void WriteU16(DataSerializer *param_1, u16 value)
{
u16 uStack_8;
uStack_8 = value;
WriteBytes(param_1, &uStack_8, 2);
}
void WriteS16(DataSerializer *param_1, u32 value)
{
u16 uStack_8;
uStack_8 = value;
WriteBytes(param_1, &uStack_8, 2);
}
void WriteU8(DataSerializer *param_1, u32 value)
{
u8 uStack_8;
uStack_8 = value;
WriteBytes(param_1, &uStack_8, 1);
}
void WriteU32(DataSerializer *param_1, u32 value)
{
u32 uStack_8;
uStack_8 = value;
WriteBytes(param_1, &uStack_8, 4);
}
UNUSED void sub_808308C(DataSerializer *param_1, u32 value)
{
u32 uStack_8;
uStack_8 = value;
WriteBytes(param_1, &uStack_8, 4);
}
void WriteS32(DataSerializer *param_1, u32 value)
{
u32 uStack_8;
uStack_8 = value;
WriteBytes(param_1, &uStack_8, 4);
}
void WriteBool8(DataSerializer *param_1, bool8 value)
{
u8 local_8;
local_8 = value ? -1 : 0;
WriteBytes(param_1, &local_8, 1);
}
void WritePosition8(DataSerializer *param_1, Position *param_2)
{
WriteBytes(param_1, &param_2->x, 1);
WriteBytes(param_1, &param_2->y, 1);
}
// TODO: param_2 struct
void sub_80830F8(DataSerializer *param_1, u32 *param_2)
{
WriteBytes(param_1, &param_2[0], 1);
WriteBytes(param_1, &param_2[1], 1);
WriteBytes(param_1, &param_2[2], 1);
WriteBytes(param_1, &param_2[3], 1);
}
// TODO: param_2 struct
void sub_808312C(DataSerializer *param_1, u16 *param_2)
{
WriteBytes(param_1, &param_2[0], 1);
WriteBytes(param_1, &param_2[1], 1);
}
void xxx_WriteBytes(DataSerializer *param_1, void *src, u32 numBytes)
{
WriteBytes(param_1, src, numBytes);
}
u16 ReadU16(DataSerializer *param_1)
{
u16 local_8;
ReadBytes(param_1, &local_8, 2);
return local_8;
}
s16 ReadS16(DataSerializer *param_1)
{
s16 local_8;
ReadBytes(param_1, &local_8, 2);
return local_8;
}
u8 ReadU8(DataSerializer *param_1)
{
u8 local_8;
ReadBytes(param_1, &local_8, 1);
return local_8;
}
// ReadS32 or ReadU32 ?
u32 sub_80831A0(DataSerializer *param_1)
{
u32 local_8;
ReadBytes(param_1, &local_8, 4);
return local_8;
}
UNUSED u32 sub_80831B4(DataSerializer *param_1)
{
u32 local_8;
ReadBytes(param_1, &local_8, 4);
return local_8;
}
// ?
u32 sub_80831C8(DataSerializer *param_1)
{
u32 local_8;
ReadBytes(param_1, &local_8, 4);
return local_8;
}
bool8 ReadBool8(DataSerializer *param_1)
{
u8 local_8;
ReadBytes(param_1, &local_8, 1);
return local_8 != 0;
}
void ReadPosition8(DataSerializer *param_1, Position *param_2)
{
param_2->x = 0;
param_2->y = 0;
ReadBytes(param_1, &param_2->x, 1);
ReadBytes(param_1, &param_2->y, 1);
}
// TODO: param_2 struct
void sub_8083220(DataSerializer *param_1, u32 *param_2)
{
param_2[0] = 0;
param_2[1] = 0;
param_2[2] = 0;
param_2[3] = 0;
ReadBytes(param_1, &param_2[0], 1);
ReadBytes(param_1, &param_2[1], 1);
ReadBytes(param_1, &param_2[2], 1);
ReadBytes(param_1, &param_2[3], 1);
}
// TODO: param_2 struct
void sub_8083260(DataSerializer *param_1, u16 *param_2)
{
param_2[0] = 0;
param_2[1] = 0;
ReadBytes(param_1, &param_2[0], 1);
ReadBytes(param_1, &param_2[1], 1);
}
void xxx_ReadBytes(DataSerializer *r0, u8 *dst, u32 numBytes)
{
ReadBytes(r0, dst, numBytes);
}

View File

@ -0,0 +1,10 @@
// The code assumes these two strings are the same size:
ALIGNED(4) static const u8 sYayoiSan[] = _("やよい{INVALID_SEQUENCE_976C}"); // 0x82, 0xE2, 0x82, 0xE6, 0x82, 0xA2, 0x97, 0x6C, 0x00
ALIGNED(4) static const u8 sMisakiSan[] = _("みさき{INVALID_SEQUENCE_976C}"); // 0x82, 0xDD, 0x82, 0xB3, 0x82, 0xAB, 0x97, 0x6C, 0x00
// -1 because of the trailing "\0"
#define BLAME_SIZE (sizeof(sYayoiSan) - 1)
// Should be aligned to 4 bytes. Default blame size is 8, stack size 12. If blame size was 11, stack size should still be 12
#define BLAME_STACK_SIZE (BLAME_SIZE - (BLAME_SIZE % 4) + 4)

View File

@ -3,6 +3,7 @@
#include "code_800E9A8.h"
#include "code_803E46C.h"
#include "code_803E668.h"
#include "code_8041AD0.h"
#include "code_804267C.h"
#include "code_8045A00.h"
#include "code_80861A8.h"
@ -377,7 +378,6 @@ extern void DeoxysScreenFlash(void);
extern void sub_8085EB0(void);
extern void sub_8049884(void);
extern void sub_8049B8C(void);
extern void sub_8049ED4(void);
extern void sub_8040A84(void);
extern void sub_8086A54(Entity *);
extern void sub_806BFC0(EntityInfo *, u32);
@ -386,7 +386,6 @@ extern void sub_8041888(u32);
extern u32 sub_80861F8(u32, Entity *, u32);
extern u8 sub_80860A8(u32);
extern void sub_8052D44(s16 *, Entity *, Entity *);
extern void sub_80421C0(Entity *, u32);
extern void sub_80464C8(Entity *, Position *, Item *);
extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32);
extern u32 sub_8085EC8(u32, u32, u32, Position *, u32);

View File

@ -2,6 +2,7 @@
#include "dungeon_items.h"
#include "code_803E668.h"
#include "code_8041AD0.h"
#include "code_8045A00.h"
#include "code_80861A8.h"
#include "code_80869E4.h"
@ -20,7 +21,6 @@ extern u8 *gUnknown_81053A8[];
extern u8 *gUnknown_8105434[];
extern void sub_80416E0(Position32 *r0, u32, bool8);
extern void sub_80421C0(Entity *, u32);
extern void sub_80855E4(void *);
extern void PlaySoundEffect(u32);
extern void sub_804178C(u32);

View File

@ -37,6 +37,7 @@
#include "code_8045A00.h"
#include "code_803E668.h"
#include "code_803E46C.h"
#include "code_8041AD0.h"
extern void sub_80429C8(Entity *r0);
extern u8 sub_803F428(Position *);
@ -74,7 +75,6 @@ extern void sub_8042930(Entity *r0);
extern void sub_8041B48(Entity *pokemon);
extern void sub_8041BA8(Entity *pokemon);
extern void sub_8042950(Entity *r0);
extern void sub_80421C0(Entity *pokemon, u16 r1);
extern bool8 sub_8057634(Entity *pokemon, Entity *target, Move *move, s32 param_4);
extern bool8 YawnMoveAction(Entity *pokemon, Entity *target, Move *move, s32 param_4);
extern bool8 NightmareMoveAction(Entity *pokemon, Entity *target, Move *move, s32 param_4);

1816
src/dungeon_serializer.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -816,7 +816,7 @@ void HandleLeechSeed(Entity * pokemon, Entity * target, bool8 displayMessage)
entityInfo->linked.linkedStatusTurns = CalculateStatusTurns(target, gUnknown_80F4EB0, TRUE) + 1;
entityInfo->linked.linkedStatusDamageCountdown = 0;
nullsub_78(target);
entityInfo->linked.unkD8 = 0xff;
entityInfo->linked.unk8 = 0xff;
break;
case STATUS_LEECH_SEED:
TryDisplayDungeonLoggableMessage3(pokemon,target,*gUnknown_80FAE7C);
@ -825,9 +825,9 @@ void HandleLeechSeed(Entity * pokemon, Entity * target, bool8 displayMessage)
for(index = 0; index < DUNGEON_MAX_POKEMON; index++)
{
if (pokemon == gDungeon->allPokemon[index]) {
entityInfo->linked.unkD8 = index;
entityInfo->linked.unk8 = index;
entityInfo2 = GetEntInfo(pokemon);
entityInfo->linked.unkD4 = entityInfo2->unk98;
entityInfo->linked.unk4 = entityInfo2->unk98;
}
}
TryDisplayDungeonLoggableMessage3(pokemon,target,*gUnknown_80FAE58);
@ -852,7 +852,7 @@ void sub_8078084(Entity * pokemon)
entityInfo2 = GetEntInfo(target);
if((u8)(entityInfo2->linked.linkedStatus - 1) <= 1)
{
if(entityInfo2->linked.unkD4 == entityInfo->unk98)
if(entityInfo2->linked.unk4 == entityInfo->unk98)
{
entityInfo2->linked.linkedStatus = STATUS_NONE;
EntityUpdateStatusSprites(target);
@ -884,7 +884,7 @@ void DestinyBondStatusTarget(Entity * pokemon, Entity * target)
entityInfo->linked.linkedStatusTurns = CalculateStatusTurns(target,gUnknown_80F4EF0,TRUE) + 1;
entityInfo->linked.linkedStatusDamageCountdown = zero;
nullsub_74(target);
entityInfo->linked.unkD8 = 0xff;
entityInfo->linked.unk8 = 0xff;
}
else
{
@ -894,9 +894,9 @@ void DestinyBondStatusTarget(Entity * pokemon, Entity * target)
for(index = 0; index < DUNGEON_MAX_POKEMON; index++)
{
if (target == gDungeon->allPokemon[index]) {
entityInfo->linked.unkD8 = index;
entityInfo->linked.unk8 = index;
entityInfo2 = GetEntInfo(target);
entityInfo->linked.unkD4 = entityInfo2->unk98;
entityInfo->linked.unk4 = entityInfo2->unk98;
}
}
TryDisplayDungeonLoggableMessage3(pokemon,target,*gUnknown_80FBB4C);
@ -984,7 +984,7 @@ void FocusEnergyStatusTarget(Entity *pokemon, Entity * target)
}
}
void sub_80783C4(Entity * pokemon, Entity * target, u8 param_3)
void sub_80783C4(Entity * pokemon, Entity * target, bool8 param_3)
{
EntityInfo *targetEntityInfo;
EntityInfo *entityInfo;
@ -1016,7 +1016,7 @@ void sub_80783C4(Entity * pokemon, Entity * target, u8 param_3)
}
targetEntityInfo->waitingStruct.waitingStatus = STATUS_DECOY;
targetEntityInfo->waitingStruct.enemyDecoy = GetEntInfo(pokemon)->isNotTeamMember;
targetEntityInfo->waitingStruct.unkCA = param_3;
targetEntityInfo->waitingStruct.unk2 = param_3;
targetEntityInfo->waitingStruct.waitingStatusTurns = CalculateStatusTurns(target,gUnknown_80F4ED0,TRUE) + 1;
targetEntityInfo->waitingStruct.curseDamageCountdown = 0;
sub_806CCB4(target,sub_806CEBC(target));

View File

@ -45,7 +45,6 @@ extern void sub_806F370(Entity *r0, Entity *r1, u32, u32, u8 *, u8, s32, u32, u3
extern void sub_807FC3C(Position *, u32, u32);
extern void sub_8042A64(Position *);
extern void sub_8040A84(void);
extern void sub_8049ED4(void);
extern void sub_80498A8(s32, s32);
extern void sub_8042A54(Position *);
extern void sub_8049BB0(s32, s32);
@ -80,7 +79,7 @@ extern void sub_8075C58(Entity *, Entity *, s32, s32);
extern void DealDamageToEntity(Entity *, s32, u32, u32);
extern bool8 MoveRequiresCharging(Entity* pokemon,u16 moveID);
extern void sub_80783C4(Entity *, Entity *, u32);
extern void sub_80783C4(Entity *, Entity *, bool8);
// NOTE: Override pokemon.c types for these two funcs
@ -342,7 +341,7 @@ bool8 sub_805B2FC(Entity * pokemon,Entity * target,Move *move, s32 param_4)
bool8 sub_805B314(Entity * pokemon,Entity * target,Move *move, s32 param_4)
{
sub_80783C4(pokemon, target, 1);
sub_80783C4(pokemon, target, TRUE);
return TRUE;
}

View File

@ -88,7 +88,6 @@ extern void sub_80498A8(s32, s32);
extern void sub_80402AC(s32, s32);
extern void sub_8049BB0(s32, s32);
void sub_8042A14(Position *);
extern void sub_8049ED4(void);
bool8 PosHasItem(Position *pos)
{

View File

@ -2,6 +2,7 @@
#include "trap.h"
#include "code_803E668.h"
#include "code_8041AD0.h"
#include "code_8045A00.h"
#include "dungeon_message.h"
#include "code_8077274_1.h"
@ -79,12 +80,10 @@ void sub_8045C28(Item *, u8 , u8);
void sub_8045BF8(u8 *, Item *);
void DealDamageToEntity(Entity *,s16,u32,u32);
void sub_806F480(Entity *, u32);
extern void sub_80421C0(Entity *, u32);
void sub_804225C(Entity *, Position *, u8);
void sub_8071DA4(Entity *);
extern u8 sub_803F428(Position *pos);
void sub_806A1E8(Entity *pokemon);
void sub_8049ED4(void);
u8 sub_803D6FC(void);
Entity *sub_8045684(u8, Position *, u8);
extern void sub_807DF38(Entity *pokemon, Entity *target, Position *pos, u32, u8 moveType, s16);

View File

@ -1,103 +1,14 @@
#include "global.h"
#include "structs/dungeon_entity.h"
#include "structs/map.h"
#include "trap.h"
#include "code_803E668.h"
#include "code_8041AD0.h"
#include "code_806CD90.h"
#include "code_8092334.h"
#include "dungeon_map_access.h"
#include "items.h"
#include "dungeon_util.h"
#include "structs/str_dungeon.h"
#include "structs/str_traps.h"
#include "items.h"
extern u8 gMisakiSan[];
extern u8 gYayoiSan[];
// TODO: Merge this file with trap.c after "HandlePokemonTrap" is in c
extern void WriteBytes(DataSerializer *, void *, s32);
static void WriteDungeonTile(DataSerializer *r0, Tile *tile);
void sub_80830F8(void * , u32*);
void sub_808312C(void *, u16 *);
static void WriteDungeonWeather(DataSerializer *r0, Weather *weather);
void WriteU32(void *, u32);
void WriteBool8(void *, u8);
void WriteU16(void *, u16);
void SaveEntity(DataSerializer *param_1, Entity *);
void Write8Bytes(DataSerializer *param_1, u8 *);
void WriteDungeonItem(DataSerializer *param_1, Item *param_2);
void sub_8080B90(DataSerializer *param_1);
void WriteDungeonItems(DataSerializer *param_1);
void sub_8081454(DataSerializer *param_1);
void sub_808165C(DataSerializer *param_1);
void SaveDungeonMusic(DataSerializer *param_1);
void SaveTrapData(DataSerializer *param_1);
void sub_8080CF0(DataSerializer *param_1);
void nullsub_98(DataSerializer *param_1);
void InitByteWriter(DataSerializer *param_1, u8*, u32);
void sub_8049ED4(void);
void WriteU8(DataSerializer *param_1, u32);
void sub_80817F4(DataSerializer *param_1, u32 param_2);
void WriteS32(DataSerializer *param_1, u32);
void sub_808180C(DataSerializer *param_1, u32 param_2);
void WriteS16(DataSerializer *param_1, u32);
static void WriteJoinedAt(DataSerializer *param_1, JoinedAt *param_2);
void SaveActionContainer(DataSerializer *param_1, ActionContainer *param_2);
void sub_8081B34(DataSerializer *r0, s16 *r1);
void SaveEntityMoves(DataSerializer *r0, Moves *move);
void sub_8081824(DataSerializer *param_1, u32 param_2);
void sub_80817B0(DataSerializer *param_1, u32 param_2);
void WritePosition8(void*, Position *);
void SaveAITargetStatus(DataSerializer *param_1, AITarget* param_2);
void SaveIQFlags(DataSerializer *r0, u8 *r1);
void SaveSpeedStage(DataSerializer *param_1, s32 param_2);
void sub_8081854(DataSerializer *param_1, s32 param_2);
void sub_808183C(DataSerializer *param_1, s32 param_2);
void SaveMuzzledStatus(DataSerializer *param_1, Muzzled *param_2);
void SaveEyesightStatus(DataSerializer *param_1, EyesightStatus *param_2);
void SaveTransformStatus(DataSerializer *param_1, TransformStatus *param_2);
void SaveItemStatus(DataSerializer *param_1, ItemStatus *param_2);
void SaveMoveStatus(DataSerializer *param_1, MoveStatus* param_2);
void SaveLinkedStatus(DataSerializer *param_1, Linked *param_2);
void SaveVolatileStatus(DataSerializer *param_1, Volatile *param_2);
void SaveImmobilizeStatus(DataSerializer *param_1, Immobilize *param_2);
void SaveNonVolatileStatus(DataSerializer *param_1, NonVolatile *param_2);
void SaveEntitySleep(DataSerializer *param_1, Sleep* param_2);
void SaveTactic(DataSerializer *param_1, u8 param_2);
void SaveDungeonHiddenPower(DataSerializer *param_1, HiddenPower *param_2);
void SaveChargingStatus(DataSerializer *param_1, Charging *param_2);
void SaveProtectionStatus(DataSerializer *param_1, Protection *param_2);
void SaveWaitingStatus(DataSerializer *param_1, Waiting *param_2);
void xxx_WriteBytes(DataSerializer *param_1, u8 *speedCounters, u32 numCounters);
void SaveClientType(DataSerializer *param_1, u8 param_2);
void sub_80421C0(Entity *, u16);
void sub_804687C(Entity *, Position *, Position *, Item *, u32);
extern void sub_8083018(DataSerializer *, u8 *);
extern void sub_8081C50(DataSerializer *);
extern void sub_8081C7C(DataSerializer *);
extern void sub_8081F2C(DataSerializer *);
extern void RestoreDungeonMusic(DataSerializer *);
extern void RestoreItemData(DataSerializer *);
extern void RestoreTrapData(DataSerializer *);
extern void sub_808217C(DataSerializer *);
extern void InitByteReader(DataSerializer *param_1, u8 *r1, u32 r2);
extern void ReadBytes(DataSerializer *, void *, u32);
u8 ReadBool8(DataSerializer *r0);
u8 ReadU8(DataSerializer *r0);
s16 ReadS16(DataSerializer *r0);
void ReadPosition8(DataSerializer *r0, Position *);
void RestoreDungeonWeather(DataSerializer *r0, Weather *);
void sub_8083220(DataSerializer *r0, u32 *);
void sub_8083260(DataSerializer *r0, u16 *);
void RestoreTile(DataSerializer *r0, Tile *);
extern u16 ReadU16(DataSerializer *param_1);
void sub_80820A8(DataSerializer *r0, Item *);
void sub_80460F8(Position *, Item *, u32);
Entity *sub_8045684(u8, Position *, u8);
u32 sub_80831A0(DataSerializer *param_1);
void RestoreDungeonEntity(DataSerializer *param_1,bool8 isTeamMember,s32 index);
extern u8 gYayoiSan[];
extern void sub_804687C(Entity *, Position *, Position *, Item *, u32);
void HandleTripTrap(Entity *pokemon, Entity *target)
{
@ -137,882 +48,4 @@ void SetTrap(Tile *tile, u8 id)
}
sub_8049ED4();
}
}
// TODO: New file here
void WriteDungeonState(u8 *buffer, u32 bufLen)
{
DataSerializer seri;
InitByteWriter(&seri, buffer, bufLen);
seri.unkC = 0;
WriteBytes(&seri, &seri.unkC, 4);
sub_8080B90(&seri);
sub_8081454(&seri);
sub_808165C(&seri);
SaveDungeonMusic(&seri);
WriteDungeonItems(&seri);
SaveTrapData(&seri);
sub_8080CF0(&seri);
Write8Bytes(&seri, gYayoiSan);
nullsub_98(&seri);
}
void sub_8080B90(DataSerializer *param_1)
{
Write8Bytes(param_1, gMisakiSan);
WriteBytes(param_1, &gDungeon->unk644, sizeof(unkDungeon644));
}
void WriteDungeonItems(DataSerializer *param_1)
{
bool8 notEmpty;
Item *item;
Entity *entity;
int counter;
u8 emptyItem [5];
for (counter = 0; counter < 5; counter++)
emptyItem[counter] = 0;
Write8Bytes(param_1, gMisakiSan);
for (counter = 0; counter < DUNGEON_MAX_ITEMS; counter++) {
entity = gDungeon->items[counter];
notEmpty = FALSE;
if (entity != NULL && GetEntityType(entity) == ENTITY_ITEM) {
item = GetItemData(entity);
WriteDungeonItem(param_1, item); // 3 bytes
WriteBytes(param_1, &entity->pos.x, 1); // 1 byte
WriteBytes(param_1, &entity->pos.y, 1); // 1 byte
notEmpty = TRUE;
}
if (!notEmpty)
WriteBytes(param_1, emptyItem, 5);
}
}
void SaveTrapData(DataSerializer *param_1)
{
bool8 flag;
Trap *trap;
Entity *entity;
int counter;
u8 local_1c [5];
for(counter = 0; counter < 5; counter++)
{
local_1c[counter] = -1;
}
Write8Bytes(param_1,gMisakiSan);
for(counter = 0; counter < DUNGEON_MAX_TRAPS; counter++)
{
entity = gDungeon->traps[counter];
flag = FALSE;
if ((entity != NULL) && (GetEntityType(entity) == ENTITY_TRAP)) {
trap = GetTrapData(entity);
WriteBytes(param_1,&trap->id,1);
WriteBytes(param_1,&trap->unk1,1);
WriteBytes(param_1,&entity->isVisible,1);
WriteBytes(param_1,&entity->pos.x,1);
WriteBytes(param_1,&entity->pos.y,1);
flag = TRUE;
}
if (!flag) {
WriteBytes(param_1,local_1c,5);
}
}
}
void sub_8080CF0(DataSerializer *param_1)
{
s32 counter;
Write8Bytes(param_1,gMisakiSan);
WriteU32(param_1,gDungeon->unk37F0);
WriteU32(param_1,gDungeon->unk37F4);
WriteBool8(param_1,gDungeon->plusIsActive[0]);
WriteBool8(param_1,gDungeon->plusIsActive[1]);
WriteBool8(param_1,gDungeon->minusIsActive[0]);
WriteBool8(param_1,gDungeon->minusIsActive[1]);
WriteBool8(param_1,gDungeon->decoyActive);
WriteBool8(param_1,gDungeon->unk37FD);
WriteBool8(param_1,gDungeon->deoxysDefeat);
WriteBool8(param_1,gDungeon->unk37FF);
WriteU16(param_1,gDungeon->unk3800);
for(counter = 0; counter < MAX_TEAM_MEMBERS; counter++)
{
SaveEntity(param_1,gDungeon->teamPokemon[counter]);
}
for(counter = 0; counter < DUNGEON_MAX_WILD_POKEMON; counter++)
{
SaveEntity(param_1,gDungeon->wildPokemon[counter]);
}
}
void SaveEntity(DataSerializer *param_1, Entity *param_2)
{
Position *pos;
EntityInfo *info;
int counter;
EntityInfo info2;
u32 uStack_ac;
u32 uStack_a8;
HiddenPower *psStack_a4;
u8 *temp1;
u8 *temp2;
AITarget *temp3;
u8 *puStack_a0;
u32 *puStack_9c;
u32 *puStack_98;
u32 *puStack_94;
u8 *puStack_90;
Sleep *puStack_8c;
NonVolatile *puStack_88;
Immobilize *puStack_84;
Volatile *puStack_80;
Charging *puStack_7c;
Protection *puStack_78;
Waiting *puStack_74;
Linked *puStack_70;
MoveStatus *puStack_6c;
ItemStatus *puStack_68;
TransformStatus *puStack_64;
EyesightStatus *puStack_60;
Muzzled *pbStack_5c;
bool8 *pbStack_58;
bool8 *pbStack_54;
bool8 *pbStack_50;
bool8 *puStack_4c;
bool8 *pbStack_48;
bool8 *pbStack_44;
bool8 *pbStack_40;
bool8 *pbStack_3c;
u8 *puStack_38;
u8 *puStack_34;
bool8 *pbStack_30;
u8 *puStack_2c;
u8 *puStack_28;
u8 *puStack_24;
uStack_a8 = 0;
uStack_ac = 1;
WriteU8(param_1,0xaa);
WriteU8(param_1,0x55);
if (EntityExists(param_2)) {
info = GetEntInfo(param_2);
WriteBytes(param_1,&uStack_ac,1);
WriteBytes(param_1,&param_2->pos.x,1);
WriteBytes(param_1,&param_2->pos.y,1);
WriteBytes(param_1,&param_2->isVisible,1);
WriteBytes(param_1,&param_2->spawnGenID,2);
}
else {
memset(&info2,0,sizeof(EntityInfo));
info = &info2;
WriteBytes(param_1,&uStack_a8,1);
WriteBytes(param_1,&uStack_a8,1);
WriteBytes(param_1,&uStack_a8,1);
WriteBytes(param_1,&uStack_a8,1);
WriteBytes(param_1,&uStack_a8,2);
}
WriteU16(param_1,info->flags);
sub_80817F4(param_1,info->apparentID);
sub_80817F4(param_1,info->id);
WriteBool8(param_1,info->isNotTeamMember);
WriteBool8(param_1,info->isTeamLeader);
WriteU8(param_1,info->shopkeeper);
WriteU8(param_1,info->level);
WriteU8(param_1,info->teamIndex);
WriteJoinedAt(param_1,&info->joinedAt);
WriteS16(param_1,info->IQ);
WriteS16(param_1,info->HP);
WriteS16(param_1,info->maxHPStat);
WriteS16(param_1,info->originalHP);
WriteU8(param_1,info->atk[0]);
WriteU8(param_1,info->atk[1]);
WriteU8(param_1,info->def[0]);
WriteU8(param_1,info->def[1]);
WriteU32(param_1,info->exp);
WriteS16(param_1,info->offensiveStages[0]);
WriteS16(param_1,info->offensiveStages[1]);
WriteS16(param_1,info->defensiveStages[0]);
WriteS16(param_1,info->defensiveStages[1]);
WriteS16(param_1,info->hitChanceStages[0]);
WriteS16(param_1,info->hitChanceStages[1]);
WriteS16(param_1,info->flashFireBoost);
WriteS32(param_1,info->offensiveMultipliers[0]);
WriteS32(param_1,info->offensiveMultipliers[1]);
WriteS32(param_1,info->defensiveMultipliers[0]);
WriteS32(param_1,info->defensiveMultipliers[1]);
SaveActionContainer(param_1,&info->action);
sub_808180C(param_1,info->types[0]);
sub_808180C(param_1,info->types[1]);
sub_8081824(param_1,info->abilities[0]);
sub_8081824(param_1,info->abilities[1]);
WriteDungeonItem(param_1,&info->heldItem);
sub_80817B0(param_1,info->unk64);
temp3 = &info->aiTarget;
temp2 = info->IQSkillMenuFlags;
temp1 = info->IQSkillFlags;
puStack_a0 = &info->tactic;
psStack_a4 = &info->hiddenPower;
puStack_9c = &info->unk98;
puStack_98 = &info->unk9C;
puStack_94 = &info->unkA0;
puStack_8c = &info->sleep;
puStack_88 = &info->nonVolatile;
puStack_84 = &info->immobilize;
puStack_80 = &info->volatileStatus;
puStack_7c = &info->charging;
puStack_78 = &info->protection;
puStack_74 = &info->waitingStruct;
puStack_70 = &info->linked;
puStack_6c = &info->moveStatus;
puStack_68 = &info->itemStatus;
puStack_64 = &info->transformStatus;
puStack_60 = &info->eyesightStatus;
pbStack_5c = &info->muzzled;
pbStack_58 = &info->powerEars;
pbStack_54 = &info->scanning;
pbStack_50 = &info->stairSpotter;
puStack_4c = &info->unkF3;
pbStack_48 = &info->grudge;
puStack_34 = &info->expMultiplier;
pbStack_44 = &info->exposed;
pbStack_40 = &info->isColorChanged;
pbStack_3c = &info->bossFlag;
puStack_38 = &info->terrifiedTurns;
pbStack_30 = &info->useHeldItem;
puStack_2c = &info->perishSongTurns;
puStack_28 = &info->unkFE;
puStack_24 = &info->unkFF;
puStack_90 = &info->clientType;
pos = info->prevPos;
for(counter = 0; counter < NUM_PREV_POS; counter++)
{
WritePosition8(param_1,pos);
pos++;
}
SaveAITargetStatus(param_1,temp3);
SaveIQFlags(param_1,temp2);
SaveIQFlags(param_1,temp1);
SaveTactic(param_1,*puStack_a0);
SaveDungeonHiddenPower(param_1,psStack_a4);
WriteU32(param_1,*puStack_9c);
WriteU32(param_1,*puStack_98);
WriteU32(param_1,*puStack_94);
SaveEntitySleep(param_1,puStack_8c);
SaveNonVolatileStatus(param_1,puStack_88);
SaveImmobilizeStatus(param_1,puStack_84);
SaveVolatileStatus(param_1,puStack_80);
SaveChargingStatus(param_1,puStack_7c);
SaveProtectionStatus(param_1,puStack_78);
SaveWaitingStatus(param_1,puStack_74);
SaveLinkedStatus(param_1,puStack_70);
SaveMoveStatus(param_1,puStack_6c);
SaveItemStatus(param_1,puStack_68);
SaveTransformStatus(param_1,puStack_64);
SaveEyesightStatus(param_1,puStack_60);
SaveMuzzledStatus(param_1,pbStack_5c);
WriteBool8(param_1,*pbStack_58);
WriteBool8(param_1,*pbStack_54);
WriteBool8(param_1,*pbStack_50);
WriteBool8(param_1,*puStack_4c);
WriteBool8(param_1,*pbStack_48);
WriteU8(param_1,*puStack_34);
WriteBool8(param_1,*pbStack_44);
WriteBool8(param_1,*pbStack_40);
WriteBool8(param_1,*pbStack_3c);
WriteU8(param_1,*puStack_38);
WriteBool8(param_1,*pbStack_30);
WriteU8(param_1,*puStack_2c);
WriteU8(param_1,*puStack_28);
sub_808183C(param_1,*puStack_24);
sub_8081854(param_1,info->targetingDecoy);
SaveSpeedStage(param_1,info->speedStage);
xxx_WriteBytes(param_1,info->speedUpCounters,NUM_SPEED_COUNTERS);
xxx_WriteBytes(param_1,info->speedDownCounters,NUM_SPEED_COUNTERS);
WriteU8(param_1,info->stockpileStage);
WriteU8(param_1,info->unk113);
WriteU8(param_1,(u8)info->moveRandomly);
SaveEntityMoves(param_1,&info->moves);
sub_8081B34(param_1,(s16 *)&info->belly);
sub_8081B34(param_1,(s16 *)&info->maxBelly);
WriteBool8(param_1,info->aiNextToTarget);
WriteBool8(param_1,info->recalculateFollow);
WriteBool8(param_1,info->waiting);
WriteBool8(param_1,info->unk146);
WriteBool8(param_1,info->attacking);
WriteBool8(param_1,info->unk149);
WriteBool8(param_1,info->unk14A);
WriteBool8(param_1,info->unk14B);
WriteBool8(param_1,info->unk14C);
WriteU16(param_1,info->visualFlags);
WriteU16(param_1,info->previousVisualFlags);
WriteBool8(param_1,info->unk152);
WriteU8(param_1,info->unk153);
WriteBool8(param_1,info->unk154);
WriteBool8(param_1,info->unk155);
WriteBool8(param_1,info->unk156);
WriteU8(param_1,info->unk164);
WriteU8(param_1,info->unk165);
WriteU8(param_1,info->unk166);
WriteU8(param_1,info->unk167);
WriteU8(param_1,info->unk168);
WriteU8(param_1,info->turnsSinceWarpScarfActivation);
WritePosition8(param_1,&(info->targetPos));
WriteS32(param_1,info->unk174);
WriteU16(param_1,info->abilityEffectFlags);
WriteS16(param_1,info->unk1F8);
WriteS16(param_1,info->mobileTurnTimer);
WriteU32(param_1,info->expGainedInTurn);
SaveClientType(param_1,*puStack_90);
}
void sub_8081454(DataSerializer *param_1)
{
int iVar1;
int iVar2;
int iVar4;
Write8Bytes(param_1,gMisakiSan);
WriteBool8(param_1, gDungeon->unk3A08);
WriteBool8(param_1, gDungeon->unk3A09);
WriteBool8(param_1, gDungeon->unk3A0A);
WriteBool8(param_1, gDungeon->unk3A0B);
WriteU8(param_1, gDungeon->unk3A0C);
WriteU8(param_1, gDungeon->unk3A0D);
WriteS16(param_1, gDungeon->tileset);
WriteS16(param_1,gDungeon->unk3A10);
WriteS16(param_1, gDungeon->unk3A12);
WriteS16(param_1, gDungeon->bossBattleIndex);
WriteS16(param_1, gDungeon->unk3A16);
for(iVar1 = 0; iVar1 < DUNGEON_MAX_SIZE_Y; iVar1++)
{
for(iVar2 = 0; iVar2 < DUNGEON_MAX_SIZE_X; iVar2++)
{
WriteDungeonTile(param_1,&gDungeon->tiles[iVar1][iVar2]);
}
}
WritePosition8(param_1,&gDungeon->unkE218);
WritePosition8(param_1,&gDungeon->unkE21C);
for(iVar4 = 0; iVar4 < 8; iVar4++)
{
WritePosition8(param_1,&gDungeon->unkE220[iVar4]);
}
sub_80830F8(param_1, gDungeon->unkE240);
sub_80830F8(param_1, gDungeon->unkE250);
sub_808312C(param_1, gDungeon->unkE260);
for(iVar1 = 0; iVar1 < 8; iVar1++)
{
for(iVar2 = 0; iVar2 < 8; iVar2++)
{
WriteDungeonTile(param_1, &gDungeon->unkE27C[iVar1][iVar2]);
WriteU8(param_1, gDungeon->unkE87C[iVar1][iVar2]);
}
}
WriteDungeonWeather(param_1,&gDungeon->weather);
}
void sub_808165C(DataSerializer *param_1)
{
Write8Bytes(param_1,gMisakiSan);
WriteU8(param_1, gDungeon->unk181e8.unk18208);
WriteU8(param_1, gDungeon->unk181e8.visibilityRange);
WriteBool8(param_1, gDungeon->unk181e8.blinded);
WriteBool8(param_1, gDungeon->unk181e8.unk1820B);
WriteBool8(param_1, gDungeon->unk181e8.unk1820C);
WriteBool8(param_1, gDungeon->unk181e8.unk1820D);
WriteBool8(param_1, gDungeon->unk181e8.unk1820E);
WriteBool8(param_1, gDungeon->unk181e8.unk1820F);
WriteBool8(param_1, gDungeon->unk181e8.hallucinating);
WriteBool8(param_1, gDungeon->unk181e8.unk18211);
WriteBool8(param_1, gDungeon->unk181e8.unk18213);
}
// NOTE: forcing this s16 for now - Seth
void SaveDungeonMusic(DataSerializer *param_1)
{
WriteS16(param_1, (s16)gDungeon->musPlayer.songIndex);
WriteS16(param_1, (s16)gDungeon->musPlayer.pastSongIndex);
WriteS16(param_1, (s16)gDungeon->musPlayer.queuedSongIndex);
}
void WriteDungeonItem(DataSerializer *param_1, Item *param_2)
{
WriteBytes(param_1, &param_2->flags, 1);
WriteBytes(param_1, &param_2->quantity, 1);
WriteBytes(param_1, &param_2->id, 1);
}
void sub_80817B0(DataSerializer *param_1, u32 param_2)
{
u8 stack;
stack = param_2;
WriteBytes(param_1, &stack, 1);
}
void SaveActionContainer(DataSerializer *param_1, ActionContainer *param_2)
{
WriteBytes(param_1, &param_2->direction, 1);
WriteBytes(param_1, &param_2->itemTargetPosition.x, 1);
WriteBytes(param_1, &param_2->itemTargetPosition.y, 1);
}
void sub_80817F4(DataSerializer *param_1, u32 param_2)
{
u16 stack;
stack = param_2;
WriteBytes(param_1, &stack, 2);
}
void sub_808180C(DataSerializer *param_1, u32 param_2)
{
u8 stack;
stack = param_2;
WriteBytes(param_1, &stack, 1);
}
void sub_8081824(DataSerializer *param_1, u32 param_2)
{
u8 stack;
stack = param_2;
WriteBytes(param_1, &stack, 1);
}
void sub_808183C(DataSerializer *param_1, s32 param_2)
{
u8 stack;
stack = param_2;
WriteBytes(param_1, &stack, 1);
}
void sub_8081854(DataSerializer *param_1, s32 param_2)
{
u8 stack;
stack = param_2;
WriteBytes(param_1, &stack, 1);
}
void SaveSpeedStage(DataSerializer *param_1, s32 param_2)
{
WriteBytes(param_1, &param_2, 4);
}
void SaveTactic(DataSerializer *param_1, u8 param_2)
{
WriteBytes(param_1, &param_2, 1);
}
void SaveDungeonHiddenPower(DataSerializer *param_1, HiddenPower *param_2)
{
WriteS16(param_1, param_2->hiddenPowerBasePower);
sub_808180C(param_1, param_2->hiddenPowerType);
}
void SaveClientType(DataSerializer *param_1, u8 param_2)
{
WriteU8(param_1, param_2);
}
static void WriteJoinedAt(DataSerializer *param_1, JoinedAt *param_2)
{
WriteU8(param_1, param_2->joinedAt);
WriteU8(param_1, param_2->unk1);
}
void SaveAITargetStatus(DataSerializer *param_1, AITarget* param_2)
{
WriteBytes(param_1, &param_2->aiObjective, 1);
WriteBool8(param_1, param_2->aiNotNextToTarget);
WriteBool8(param_1, param_2->aiTargetingEnemy);
WriteBool8(param_1, param_2->aiTurningAround);
WriteU16(param_1, param_2->aiTargetSpawnGenID);
WritePosition8(param_1, &param_2->aiTargetPos);
}
void SaveEntitySleep(DataSerializer *param_1, Sleep* param_2)
{
WriteBytes(param_1, &param_2->sleep, 1);
WriteU8(param_1, param_2->sleepTurns);
}
void SaveNonVolatileStatus(DataSerializer *param_1, NonVolatile *param_2)
{
WriteBytes(param_1, &param_2->nonVolatileStatus, 1);
WriteU8(param_1, param_2->nonVolatileStatusTurns);
WriteU8(param_1, param_2->nonVolatileStatusDamageCountdown);
WriteU8(param_1, param_2->unk4);
}
void SaveImmobilizeStatus(DataSerializer *param_1, Immobilize *param_2)
{
WriteBytes(param_1, &param_2->immobilizeStatus, 1);
WriteU8(param_1, param_2->immobilizeStatusTurns);
WriteU8(param_1, param_2->immobilizeStatusDamageCountdown);
WriteU32(param_1, param_2->unk4);
}
void SaveVolatileStatus(DataSerializer *param_1, Volatile *param_2)
{
WriteBytes(param_1, &param_2->volatileStatus, 1);
WriteU8(param_1, param_2->volatileStatusTurns);
}
void SaveChargingStatus(DataSerializer *param_1, Charging *param_2)
{
WriteBytes(param_1, &param_2->chargingStatus, 1);
WriteU8(param_1, param_2->chargingStatusTurns);
WriteU8(param_1, param_2->chargingStatusMoveIndex);
}
void SaveProtectionStatus(DataSerializer *param_1, Protection *param_2)
{
WriteBytes(param_1, &param_2->protectionStatus, 1);
WriteU8(param_1, param_2->protectionStatusTurns);
}
void SaveWaitingStatus(DataSerializer *param_1, Waiting *param_2)
{
WriteBytes(param_1, &param_2->waitingStatus, 1);
WriteBool8(param_1, param_2->enemyDecoy);
WriteBool8(param_1, param_2->unkCA);
WriteU8(param_1, param_2->waitingStatusTurns);
WriteU8(param_1, param_2->curseDamageCountdown);
}
void SaveLinkedStatus(DataSerializer *param_1, Linked *param_2)
{
WriteBytes(param_1, &param_2->linkedStatus, 1);
WriteU32(param_1, param_2->unkD4);
WriteU8(param_1, param_2->unkD8);
WriteU8(param_1, param_2->linkedStatusTurns);
WriteU8(param_1, param_2->linkedStatusDamageCountdown);
}
void SaveMoveStatus(DataSerializer *param_1, MoveStatus* param_2)
{
WriteBytes(param_1, &param_2->moveStatus, 1);
WriteU8(param_1, param_2->moveStatusTurns);
}
void SaveItemStatus(DataSerializer *param_1, ItemStatus *param_2)
{
WriteBytes(param_1, &param_2->itemStatus, 1);
}
void SaveTransformStatus(DataSerializer *param_1, TransformStatus *param_2)
{
WriteBytes(param_1, &param_2->transformStatus, 1);
WriteU8(param_1, param_2->transformStatusTurns);
}
void SaveEyesightStatus(DataSerializer *param_1, EyesightStatus *param_2)
{
WriteBytes(param_1, &param_2->eyesightStatus, 1);
WriteU8(param_1, param_2->eyesightStatusTurns);
}
void SaveMuzzledStatus(DataSerializer *param_1, Muzzled *param_2)
{
WriteBytes(param_1, &param_2->muzzled, 1);
WriteU8(param_1, param_2->muzzledTurns);
}
void SaveEntityMove(DataSerializer *r0, Move *r1)
{
WriteU8(r0, r1->moveFlags);
WriteU8(r0, r1->moveFlags2);
WriteBytes(r0, &r1->id, 2);
WriteU8(r0, r1->PP);
WriteU8(r0, r1->ginseng);
}
void SaveEntityMoves(DataSerializer *r0, Moves *move)
{
s32 i;
for (i = 0; i < MAX_MON_MOVES; i++)
SaveEntityMove(r0, &move->moves[i]);
WriteU8(r0, move->struggleMoveFlags);
}
void sub_8081B34(DataSerializer *r0, s16 *r1)
{
WriteS16(r0, r1[0]);
WriteS16(r0, r1[1]);
}
void SaveIQFlags(DataSerializer *r0, u8 *r1)
{
WriteBytes(r0, r1, NUM_PICKED_IQ_SKILLS);
}
static void WriteDungeonTile(DataSerializer *r0, Tile *tile)
{
WriteU16(r0, tile->terrainType);
WriteU16(r0, tile->unk4);
WriteBytes(r0, &tile->room, 1);
WriteBytes(r0, &tile->unkE, 1);
}
static void WriteDungeonWeather(DataSerializer *r0, Weather *weather)
{
s32 i;
WriteBytes(r0, &weather->weather, 1);
WriteBytes(r0, &weather->unkE265, 1);
for (i = 0; i < 8; i++) {
WriteU8(r0, weather->unkE267[i]);
WriteU8(r0, weather->naturalWeather[i]);
}
WriteU8(r0, weather->weatherDamageCounter);
WriteU8(r0, weather->mudSportTurns);
WriteU8(r0, weather->waterSportTurns);
WriteBool8(r0, weather->nullifyWeather);
}
// Read func
void ReadDungeonState(u8 *buffer, u32 bufLen)
{
DataSerializer seri;
InitByteReader(&seri, buffer, bufLen);
ReadBytes(&seri, &seri.unkC, 4);
sub_8081C50(&seri);
sub_8081C7C(&seri);
sub_8081F2C(&seri);
RestoreDungeonMusic(&seri);
RestoreItemData(&seri);
RestoreTrapData(&seri);
sub_808217C(&seri);
sub_8083018(&seri, gYayoiSan);
nullsub_98(&seri);
}
void sub_8081C50(DataSerializer *r0)
{
sub_8083018(r0, gMisakiSan);
ReadBytes(r0, &gDungeon->unk644, sizeof(unkDungeon644));
}
void sub_8081C7C(DataSerializer *r0)
{
int x;
int y;
s32 iVar7;
sub_8083018(r0,gMisakiSan);
gDungeon->unk3A08 = ReadBool8(r0);
gDungeon->unk3A09 = ReadBool8(r0);
gDungeon->unk3A0A = ReadBool8(r0);
gDungeon->unk3A0B = ReadBool8(r0);
gDungeon->unk3A0C = ReadU8(r0);
gDungeon->unk3A0D = ReadU8(r0);
gDungeon->tileset = ReadS16(r0);
gDungeon->unk3A10 = ReadS16(r0);
gDungeon->unk3A12 = ReadS16(r0);
gDungeon->bossBattleIndex = ReadS16(r0);
gDungeon->unk3A16 = ReadS16(r0);
for(y = 0; y < DUNGEON_MAX_SIZE_Y; y++)
{
for(x = 0; x < DUNGEON_MAX_SIZE_X; x++)
{
RestoreTile(r0,&gDungeon->tiles[y][x]);
}
}
ReadPosition8(r0,&gDungeon->unkE218);
ReadPosition8(r0,&gDungeon->unkE21C);
for(iVar7 = 0; iVar7 < 8; iVar7++)
{
ReadPosition8(r0,&gDungeon->unkE220[iVar7]);
}
sub_8083220(r0, gDungeon->unkE240);
sub_8083220(r0, gDungeon->unkE250);
sub_8083260(r0, gDungeon->unkE260);
for(y = 0; y < 8; y++)
{
for(x = 0; x < 8; x++)
{
RestoreTile(r0,&gDungeon->unkE27C[y][x]);
gDungeon->unkE87C[y][x] = ReadU8(r0);
}
}
RestoreDungeonWeather(r0,&gDungeon->weather);
}
void RestoreTile(DataSerializer *r0, Tile *tile)
{
memset(tile, 0, sizeof(Tile));
tile->terrainType = ReadU16(r0);
tile->unk4 = ReadU16(r0);
ReadBytes(r0, (u32 *)&tile->room, 1);
ReadBytes(r0, (u32 *)&tile->unkE, 1);
tile->monster = NULL;
tile->object = NULL;
}
void RestoreDungeonWeather(DataSerializer *r0, Weather *weather)
{
s32 index;
memset(weather, 0, sizeof(Weather));
ReadBytes(r0, (u32 *)&weather->weather, 1);
ReadBytes(r0, (u32 *)&weather->unkE265, 1);
for(index = 0; index < 8; index++)
{
weather->unkE267[index] = ReadU8(r0);
weather->naturalWeather[index] = ReadU8(r0);
}
weather->weatherDamageCounter = ReadU8(r0);
weather->mudSportTurns = ReadU8(r0);
weather->waterSportTurns = ReadU8(r0);
weather->nullifyWeather = ReadBool8(r0);
}
void sub_8081F2C(DataSerializer *param_1)
{
sub_8083018(param_1,gMisakiSan);
gDungeon->unk181e8.cameraTarget = NULL;
gDungeon->unk181e8.unk18208 = ReadU8(param_1);
gDungeon->unk181e8.visibilityRange = ReadU8(param_1);
gDungeon->unk181e8.blinded = ReadBool8(param_1);
gDungeon->unk181e8.unk1820B = ReadBool8(param_1);
gDungeon->unk181e8.unk1820C = ReadBool8(param_1);
gDungeon->unk181e8.unk1820D = ReadBool8(param_1);
gDungeon->unk181e8.unk1820E = ReadBool8(param_1);
gDungeon->unk181e8.unk1820F = ReadBool8(param_1);
gDungeon->unk181e8.hallucinating = ReadBool8(param_1);
gDungeon->unk181e8.unk18211 = ReadBool8(param_1);
gDungeon->unk181e8.unk18213 = ReadBool8(param_1);
}
void RestoreDungeonMusic(DataSerializer *r0)
{
gDungeon->musPlayer.songIndex = ReadS16(r0);
gDungeon->musPlayer.pastSongIndex = ReadS16(r0);
gDungeon->musPlayer.queuedSongIndex = ReadS16(r0);
}
void RestoreItemData(DataSerializer *r0) {
s32 index;
Item item;
Position pos;
sub_8083018(r0, gMisakiSan);
for(index = 0; index < DUNGEON_MAX_ITEMS; index++)
{
sub_80820A8(r0, &item);
ReadPosition8(r0, &pos);
if(item.flags & ITEM_FLAG_EXISTS)
sub_80460F8(&pos, &item, 0);
}
}
void sub_80820A8(DataSerializer *param_1, Item *item)
{
memset(item, 0, sizeof(Item));
ReadBytes(param_1,(u32 *)&item->flags,1);
ReadBytes(param_1,(u32 *)&item->quantity,1);
ReadBytes(param_1,(u32 *)&item->id,1);
}
void RestoreTrapData(DataSerializer *param_1)
{
int counter;
Tile *tile;
Entity *entity;
Position pos;
u8 isVisible;
u8 unk1;
u8 trapID;
sub_8083018(param_1, gMisakiSan);
for(counter = 0; counter < DUNGEON_MAX_TRAPS; counter++)
{
trapID = 6;
unk1 = 0;
ReadBytes(param_1,(u32 *)&trapID,1);
ReadBytes(param_1,(u32 *)&unk1,1);
isVisible = ReadBool8(param_1);
ReadPosition8(param_1, &pos);
if(trapID != 0xFF)
{
tile = GetTileSafe(pos.x, pos.y);
entity = sub_8045684(trapID, &pos, unk1);
if(entity)
{
tile->object = entity;
entity->isVisible = isVisible;
}
}
}
}
void sub_808217C(DataSerializer *param_1)
{
s32 counter;
sub_8083018(param_1,gMisakiSan);
gDungeon->unk37F0 = sub_80831A0(param_1);
gDungeon->unk37F4 = sub_80831A0(param_1);
gDungeon->plusIsActive[0] = ReadBool8(param_1);
gDungeon->plusIsActive[1] = ReadBool8(param_1);
gDungeon->minusIsActive[0] = ReadBool8(param_1);
gDungeon->minusIsActive[1] = ReadBool8(param_1);
gDungeon->decoyActive = ReadBool8(param_1);
gDungeon->unk37FD = ReadBool8(param_1);
gDungeon->deoxysDefeat = ReadBool8(param_1);
gDungeon->unk37FF = ReadBool8(param_1);
gDungeon->unk3800 = ReadU16(param_1);
for(counter = 0; counter < MAX_TEAM_MEMBERS; counter++)
{
RestoreDungeonEntity(param_1, TRUE, counter);
}
for(counter = 0; counter < DUNGEON_MAX_WILD_POKEMON; counter++)
{
RestoreDungeonEntity(param_1, FALSE, counter);
}
}
// RestoreDungeonEntity should be here
}

View File

@ -225,7 +225,7 @@ gUnknown_203B40C: /* 203B40C (sub_803E46C - PrintFieldMessage) */
gUnknown_203B40D: /* 203B40D (sub_803E250 - sub_807E698) */
.space 0x3
gUnknown_203B410: /* 203B410 (sub_8040150 - RestoreDungeonEntity) */
gUnknown_203B410: /* 203B410 (sub_8040150 - ReadMonster) */
.space 0x4
.include "src/code_8042B34.o"
@ -258,7 +258,7 @@ gUnknown_203B43C: /* 203B43C (sub_8065FB4) */
gUnknown_203B444: /* 203B444 (sub_807DF38) */
.space 0xC
gLeaderPointer: /* 203B450 (xxx_dungeon_8042F6C - RestoreDungeonEntity) */
gLeaderPointer: /* 203B450 (xxx_dungeon_8042F6C - ReadMonster) */
.space 0x4
.include "src/dungeon_random.o"