Merge pull request #361 from Slawter666/synchronise

Synchronise with pokeruby
This commit is contained in:
Diegoisawesome 2018-11-12 11:37:18 -06:00 committed by GitHub
commit 54ad6794bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 829 additions and 818 deletions

View File

@ -7851,7 +7851,7 @@ palette_bg_faded_fill_black: @ 80AF020
thumb_func_start pal_fill_for_maplights thumb_func_start pal_fill_for_maplights
pal_fill_for_maplights: @ 80AF040 pal_fill_for_maplights: @ 80AF040
push {r4,lr} push {r4,lr}
bl get_map_light_from_warp0 bl GetLastUsedWarpMapType
adds r4, r0, 0 adds r4, r0, 0
lsls r4, 24 lsls r4, 24
lsrs r4, 24 lsrs r4, 24

View File

@ -2262,8 +2262,8 @@ _080FAEA2:
bx r0 bx r0
thumb_func_end task50_overworld_poison_effect thumb_func_end task50_overworld_poison_effect
thumb_func_start overworld_poison_effect thumb_func_start FldeffPoison_Start
overworld_poison_effect: @ 80FAEA8 FldeffPoison_Start: @ 80FAEA8
push {lr} push {lr}
movs r0, 0x4F movs r0, 0x4F
bl PlaySE bl PlaySE
@ -2273,7 +2273,7 @@ overworld_poison_effect: @ 80FAEA8
pop {r0} pop {r0}
bx r0 bx r0
.pool .pool
thumb_func_end overworld_poison_effect thumb_func_end FldeffPoison_Start
thumb_func_start FieldPoisonEffectIsRunning thumb_func_start FieldPoisonEffectIsRunning
FieldPoisonEffectIsRunning: @ 80FAEC0 FieldPoisonEffectIsRunning: @ 80FAEC0

View File

@ -1,3 +1,3 @@
gUnknown_03005DD0 gFieldCamera
gUnknown_03005DE8 gTotalCameraPixelOffsetY
gUnknown_03005DEC gTotalCameraPixelOffsetX

View File

@ -3325,7 +3325,7 @@ EventScript_2736B3:: @ 82736B3
EventScript_Poison:: @ 82736BC EventScript_Poison:: @ 82736BC
lockall lockall
special sub_80F972C special ExecuteWhiteOut
waitstate waitstate
compare VAR_RESULT, 1 compare VAR_RESULT, 1
goto_eq EventScript_2736D9 goto_eq EventScript_2736D9

View File

@ -210,7 +210,7 @@ gSpecials:: @ 81DBA64
def_special ShowLinkBattleRecords def_special ShowLinkBattleRecords
def_special IsEnoughForCostInVar0x8005 def_special IsEnoughForCostInVar0x8005
def_special SubtractMoneyFromVar0x8005 def_special SubtractMoneyFromVar0x8005
def_special sub_80F972C def_special ExecuteWhiteOut
def_special sp0C8_whiteout_maybe def_special sp0C8_whiteout_maybe
def_special RotatingGate_InitPuzzle def_special RotatingGate_InitPuzzle
def_special RotatingGate_InitPuzzleAndGraphics def_special RotatingGate_InitPuzzleAndGraphics

View File

@ -1,6 +1,8 @@
#ifndef GUARD_BERRY_H #ifndef GUARD_BERRY_H
#define GUARD_BERRY_H #define GUARD_BERRY_H
#define BERRY_NONE 0
enum enum
{ {
BERRY_FIRMNESS_UNKNOWN, BERRY_FIRMNESS_UNKNOWN,
@ -21,6 +23,17 @@ enum
FLAVOR_COUNT FLAVOR_COUNT
}; };
enum
{
BERRY_STAGE_NO_BERRY, // there is no tree planted and the soil is completely flat.
BERRY_STAGE_PLANTED,
BERRY_STAGE_SPROUTED,
BERRY_STAGE_TALLER,
BERRY_STAGE_FLOWERING,
BERRY_STAGE_BERRIES,
BERRY_STAGE_SPARKLING = 0xFF,
};
#define NUM_BERRIES 44 #define NUM_BERRIES 44
extern const u8 *const gBerryTreeEventObjectGraphicsIdTablePointers[]; extern const u8 *const gBerryTreeEventObjectGraphicsIdTablePointers[];
@ -29,7 +42,6 @@ extern const u8 *const gBerryTreePaletteSlotTablePointers[];
void ClearEnigmaBerries(void); void ClearEnigmaBerries(void);
void SetEnigmaBerry(u8 *src); void SetEnigmaBerry(u8 *src);
u32 GetEnigmaBerryChecksum(struct EnigmaBerry *enigmaBerry);
bool32 IsEnigmaBerryValid(void); bool32 IsEnigmaBerryValid(void);
const struct Berry *GetBerryInfo(u8 berry); const struct Berry *GetBerryInfo(u8 berry);
struct BerryTree *GetBerryTreeInfo(u8 id); struct BerryTree *GetBerryTreeInfo(u8 id);
@ -37,28 +49,20 @@ bool32 EventObjectInteractionWaterBerryTree(void);
bool8 IsPlayerFacingPlantedBerryTree(void); bool8 IsPlayerFacingPlantedBerryTree(void);
bool8 TryToWaterBerryTree(void); bool8 TryToWaterBerryTree(void);
void ClearBerryTrees(void); void ClearBerryTrees(void);
bool32 BerryTreeGrow(struct BerryTree *tree);
void BerryTreeTimeUpdate(s32 minutes); void BerryTreeTimeUpdate(s32 minutes);
void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 sparkle); void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 sparkle);
void RemoveBerryTree(u8 id); void RemoveBerryTree(u8 id);
u8 GetBerryTypeByBerryTreeId(u8 id); u8 GetBerryTypeByBerryTreeId(u8 id);
u8 GetStageByBerryTreeId(u8); u8 GetStageByBerryTreeId(u8);
u8 ItemIdToBerryType(u16 item); u8 ItemIdToBerryType(u16 item);
u16 BerryTypeToItemId(u16 berry);
void GetBerryNameByBerryType(u8 berry, u8 *string); void GetBerryNameByBerryType(u8 berry, u8 *string);
void ResetBerryTreeSparkleFlag(u8 id); void ResetBerryTreeSparkleFlag(u8 id);
u8 BerryTreeGetNumStagesWatered(struct BerryTree *tree);
u8 GetNumStagesWateredByBerryTreeId(u8 id);
u8 CalcBerryYieldInternal(u16 max, u16 min, u8 water);
u8 CalcBerryYield(struct BerryTree *tree);
u8 GetBerryCountByBerryTreeId(u8 id);
u16 GetStageDurationByBerryType(u8);
void Bag_ChooseBerry(void); void Bag_ChooseBerry(void);
void EventObjectInteractionGetBerryTreeData(void); void EventObjectInteractionGetBerryTreeData(void);
void EventObjectInteractionPlantBerryTree(void); void EventObjectInteractionPlantBerryTree(void);
void EventObjectInteractionPickBerryTree(void); void EventObjectInteractionPickBerryTree(void);
void EventObjectInteractionRemoveBerryTree(void); void EventObjectInteractionRemoveBerryTree(void);
u8 PlayerHasBerries(void); bool8 PlayerHasBerries(void);
void ResetBerryTreeSparkleFlags(void); void ResetBerryTreeSparkleFlags(void);
extern const struct Berry gBerries[]; extern const struct Berry gBerries[];

View File

@ -75,14 +75,14 @@ struct PairedPalettes
struct LockedAnimEventObjects struct LockedAnimEventObjects
{ {
u8 eventObjectIds[NUM_EVENT_OBJECTS]; u8 eventObjectIds[EVENT_OBJECTS_COUNT];
u8 count; u8 count;
}; };
extern const struct SpriteFrameImage gEventObjectPicTable_PechaBerryTree[]; extern const struct SpriteFrameImage gEventObjectPicTable_PechaBerryTree[];
extern const u8 gReflectionEffectPaletteMap[]; extern const u8 gReflectionEffectPaletteMap[];
void sub_808D438(void); void ResetEventObjects(void);
u8 GetMoveDirectionAnimNum(u8); u8 GetMoveDirectionAnimNum(u8);
u8 GetEventObjectIdByLocalIdAndMap(u8, u8, u8); u8 GetEventObjectIdByLocalIdAndMap(u8, u8, u8);
bool8 TryGetEventObjectIdByLocalIdAndMap(u8, u8, u8, u8 *); bool8 TryGetEventObjectIdByLocalIdAndMap(u8, u8, u8, u8 *);
@ -180,9 +180,7 @@ u8 ZCoordToPriority(u8);
void EventObjectUpdateZCoord(struct EventObject *pObject); void EventObjectUpdateZCoord(struct EventObject *pObject);
void SetObjectSubpriorityByZCoord(u8, struct Sprite *, u8); void SetObjectSubpriorityByZCoord(u8, struct Sprite *, u8);
bool8 IsZCoordMismatchAt(u8, s16, s16); bool8 IsZCoordMismatchAt(u8, s16, s16);
void UpdateEventObjectSpriteSubpriorityAndVisibility(struct Sprite *);
void UnfreezeEventObject(struct EventObject *); void UnfreezeEventObject(struct EventObject *);
void oamt_npc_ministep_reset(struct Sprite *, u8, u8);
u8 FindLockedEventObjectIndex(struct EventObject *); u8 FindLockedEventObjectIndex(struct EventObject *);
bool8 obj_npc_ministep(struct Sprite *sprite); bool8 obj_npc_ministep(struct Sprite *sprite);
bool8 sub_80976EC(struct Sprite *sprite); bool8 sub_80976EC(struct Sprite *sprite);

View File

@ -7,16 +7,16 @@ struct CameraObject
{ {
void (*callback)(struct CameraObject *); void (*callback)(struct CameraObject *);
u32 spriteId; u32 spriteId;
s32 unk8; s32 movementSpeedX;
s32 unkC; s32 movementSpeedY;
s32 x; s32 x;
s32 y; s32 y;
}; };
// Exported RAM declarations // Exported RAM declarations
extern struct CameraObject gUnknown_03005DD0; extern struct CameraObject gFieldCamera;
extern u16 gUnknown_03005DEC; extern u16 gTotalCameraPixelOffsetX;
extern u16 gUnknown_03005DE8; extern u16 gTotalCameraPixelOffsetY;
// Exported ROM declarations // Exported ROM declarations
void DrawWholeMapView(void); void DrawWholeMapView(void);

View File

@ -25,7 +25,7 @@ struct FieldInput
void FieldClearPlayerInput(struct FieldInput *pStruct); void FieldClearPlayerInput(struct FieldInput *pStruct);
void FieldGetPlayerInput(struct FieldInput *pStruct, u16 keys, u16 heldKeys); void FieldGetPlayerInput(struct FieldInput *pStruct, u16 keys, u16 heldKeys);
int sub_809C014(struct FieldInput *pStruct); int ProcessPlayerFieldInput(struct FieldInput *pStruct);
u8 *sub_80682A8(struct MapPosition *, u8, u8); u8 *sub_80682A8(struct MapPosition *, u8, u8);
void overworld_poison_timer_set(void); void overworld_poison_timer_set(void);
void RestartWildEncounterImmunitySteps(void); void RestartWildEncounterImmunitySteps(void);

View File

@ -179,8 +179,8 @@ bool8 sub_80B7B94(struct Task *, struct EventObject *, struct Sprite *);
bool8 sub_80B7BCC(struct Task *, struct EventObject *, struct Sprite *); bool8 sub_80B7BCC(struct Task *, struct EventObject *, struct Sprite *);
bool8 sub_80B7BF4(struct Task *, struct EventObject *, struct Sprite *); bool8 sub_80B7BF4(struct Task *, struct EventObject *, struct Sprite *);
void sub_80B7D14(struct Task *); static void EscapeRopeFieldEffect_Step0(struct Task *);
void sub_80B7D34(struct Task *); static void EscapeRopeFieldEffect_Step1(struct Task *);
void sub_80B7EC4(struct Task *); void sub_80B7EC4(struct Task *);
void sub_80B7EE8(struct Task *); void sub_80B7EE8(struct Task *);

View File

@ -18,7 +18,7 @@ u8 FindTallGrassFieldEffectSpriteId(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s
void sub_8155F80(struct Sprite*); void sub_8155F80(struct Sprite*);
void UpdateShadowFieldEffect(struct Sprite*); void UpdateShadowFieldEffect(struct Sprite*);
void UpdateTallGrassFieldEffect(struct Sprite*); void UpdateTallGrassFieldEffect(struct Sprite*);
void sub_81561D0(struct Sprite*); void WaitFieldEffectSpriteAnim(struct Sprite*);
void UpdateAshFieldEffect(struct Sprite*); void UpdateAshFieldEffect(struct Sprite*);
void UpdateSurfBlobFieldEffect(struct Sprite*); void UpdateSurfBlobFieldEffect(struct Sprite*);
void sub_8156194(struct Sprite*); void sub_8156194(struct Sprite*);

View File

@ -13,7 +13,7 @@ enum {
FLDPSN_FNT FLDPSN_FNT
}; };
void sub_80F972C(void); void ExecuteWhiteOut(void);
int DoPoisonFieldEffect(void); s32 DoPoisonFieldEffect(void);
#endif //GUARD_FIELD_POISON_H #endif //GUARD_FIELD_POISON_H

View File

@ -11,7 +11,7 @@ void sub_80FA5E4(s16 id, s16 x, s16 y);
void sub_80FA794(s16 x, s16 y); void sub_80FA794(s16 x, s16 y);
void CreateRecordMixingSprite(void); void CreateRecordMixingSprite(void);
void DestroyRecordMixingSprite(void); void DestroyRecordMixingSprite(void);
void overworld_poison_effect(void); void FldeffPoison_Start(void);
void sub_80FA970(s16); void sub_80FA970(s16);
void sub_80FA9D0(void); void sub_80FA9D0(void);
bool8 sub_80FADE4(u16, u8); bool8 sub_80FADE4(u16, u8);

View File

@ -1,7 +0,0 @@
#ifndef GUARD_FLDEFF_TELEPORT_H
#define GUARD_FLDEFF_TELEPORT_H
void hm_teleport_run_dp02scr(void);
void sub_817C94C(void);
#endif // GUARD_FLDEFF_TELEPORT_H

View File

@ -1,8 +1,6 @@
#ifndef GUARD_GLOBAL_FIELDMAP_H #ifndef GUARD_GLOBAL_FIELDMAP_H
#define GUARD_GLOBAL_FIELDMAP_H #define GUARD_GLOBAL_FIELDMAP_H
#define NUM_EVENT_OBJECTS 16
enum enum
{ {
CONNECTION_SOUTH = 1, CONNECTION_SOUTH = 1,
@ -228,14 +226,14 @@ struct EventObjectGraphicsInfo
/*0x20*/ const union AffineAnimCmd *const *affineAnims; /*0x20*/ const union AffineAnimCmd *const *affineAnims;
}; };
#define PLAYER_AVATAR_FLAG_ON_FOOT (1 << 0) #define PLAYER_AVATAR_FLAG_ON_FOOT (1 << 0)
#define PLAYER_AVATAR_FLAG_MACH_BIKE (1 << 1) #define PLAYER_AVATAR_FLAG_MACH_BIKE (1 << 1)
#define PLAYER_AVATAR_FLAG_ACRO_BIKE (1 << 2) #define PLAYER_AVATAR_FLAG_ACRO_BIKE (1 << 2)
#define PLAYER_AVATAR_FLAG_SURFING (1 << 3) #define PLAYER_AVATAR_FLAG_SURFING (1 << 3)
#define PLAYER_AVATAR_FLAG_UNDERWATER (1 << 4) #define PLAYER_AVATAR_FLAG_UNDERWATER (1 << 4)
#define PLAYER_AVATAR_FLAG_5 (1 << 5) #define PLAYER_AVATAR_FLAG_5 (1 << 5)
#define PLAYER_AVATAR_FLAG_6 (1 << 6) #define PLAYER_AVATAR_FLAG_6 (1 << 6)
#define PLAYER_AVATAR_FLAG_DASH (1 << 7) #define PLAYER_AVATAR_FLAG_DASH (1 << 7)
enum enum
{ {
@ -311,7 +309,7 @@ struct Camera
s32 y; s32 y;
}; };
extern struct EventObject gEventObjects[NUM_EVENT_OBJECTS]; extern struct EventObject gEventObjects[EVENT_OBJECTS_COUNT];
extern u8 gSelectedEventObject; extern u8 gSelectedEventObject;
extern struct MapHeader gMapHeader; extern struct MapHeader gMapHeader;
extern struct PlayerAvatar gPlayerAvatar; extern struct PlayerAvatar gPlayerAvatar;

View File

@ -119,22 +119,22 @@ enum LanguageId
#define GAME_LANGUAGE (LANGUAGE_ENGLISH) #define GAME_LANGUAGE (LANGUAGE_ENGLISH)
// capacities of various saveblock objects // capacities of various saveblock objects
#define DAYCARE_MON_COUNT 2 #define DAYCARE_MON_COUNT 2
#define POKEBLOCKS_COUNT 40 #define POKEBLOCKS_COUNT 40
#define EVENT_OBJECTS_COUNT 16 #define EVENT_OBJECTS_COUNT 16
#define BERRY_TREES_COUNT 128 #define BERRY_TREES_COUNT 128
#define FLAGS_COUNT 300 #define FLAGS_COUNT 300
#define VARS_COUNT 256 #define VARS_COUNT 256
#define MAIL_COUNT 16 #define MAIL_COUNT 16
#define SECRET_BASES_COUNT 20 #define SECRET_BASES_COUNT 20
#define TV_SHOWS_COUNT 25 #define TV_SHOWS_COUNT 25
#define POKE_NEWS_COUNT 16 #define POKE_NEWS_COUNT 16
#define PC_ITEMS_COUNT 50 #define PC_ITEMS_COUNT 50
#define BAG_ITEMS_COUNT 30 #define BAG_ITEMS_COUNT 30
#define BAG_KEYITEMS_COUNT 30 #define BAG_KEYITEMS_COUNT 30
#define BAG_POKEBALLS_COUNT 16 #define BAG_POKEBALLS_COUNT 16
#define BAG_TMHM_COUNT 64 #define BAG_TMHM_COUNT 64
#define BAG_BERRIES_COUNT 46 #define BAG_BERRIES_COUNT 46
#define PYRAMID_BAG_ITEMS_COUNT 10 #define PYRAMID_BAG_ITEMS_COUNT 10
#define HALL_FACILITIES_COUNT 9 // 7 facilities for single mode + tower double mode + tower multi mode. #define HALL_FACILITIES_COUNT 9 // 7 facilities for single mode + tower double mode + tower multi mode.

View File

@ -77,7 +77,7 @@ bool8 MetatileBehavior_IsBerryTreeSoil(u8);
bool8 MetatileBehavior_IsAshGrass(u8); bool8 MetatileBehavior_IsAshGrass(u8);
bool8 MetatileBehavior_IsFootprints(u8); bool8 MetatileBehavior_IsFootprints(u8);
bool8 MetatileBehavior_IsBridge(u8); bool8 MetatileBehavior_IsBridge(u8);
u8 MetatileBehavior_GetBridgeSth(u8); u8 MetatileBehavior_GetBridgeType(u8);
u8 MetatileBehavior_8089510(u8); u8 MetatileBehavior_8089510(u8);
bool8 MetatileBehavior_IsLandWildEncounter(u8); bool8 MetatileBehavior_IsLandWildEncounter(u8);
bool8 MetatileBehavior_IsWaterWildEncounter(u8); bool8 MetatileBehavior_IsWaterWildEncounter(u8);

View File

@ -47,13 +47,13 @@ void Overworld_SetEventObjTemplateMovementType(u8 localId, u8 movementType);
const struct MapLayout *GetMapLayout(void); const struct MapLayout *GetMapLayout(void);
void ApplyCurrentWarp(void); void ApplyCurrentWarp(void);
void set_warp2_warp3_to_neg_1(void); void set_warp2_warp3_to_neg_1(void);
void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); static void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
bool32 IsDummyWarp(struct WarpData *warp); static bool32 IsDummyWarp(struct WarpData *warp);
struct MapHeader const *const Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u16 mapNum); struct MapHeader const *const Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u16 mapNum);
struct MapHeader const *const GetDestinationWarpMapHeader(void); struct MapHeader const *const GetDestinationWarpMapHeader(void);
void LoadCurrentMapData(void); static void LoadCurrentMapData(void);
void LoadSaveblockMapHeader(void); static void LoadSaveblockMapHeader(void);
void SetPlayerCoordsFromWarp(void); static void SetPlayerCoordsFromWarp(void);
void WarpIntoMap(void); void WarpIntoMap(void);
void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
void warp1_set_2(s8 mapGroup, s8 mapNum, s8 warpId); void warp1_set_2(s8 mapGroup, s8 mapNum, s8 warpId);
@ -67,7 +67,7 @@ void sub_8084D5C(s16 a1, s16 a2);
void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
void sub_8084E14(void); void sub_8084E14(void);
void SetFixedDiveWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void SetFixedDiveWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
void SetFixedDiveWarpAsDestination(void); static void SetFixedDiveWarpAsDestination(void);
void SetFixedHoleWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void SetFixedHoleWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
void SetFixedHoleWarpAsDestination(s16 x, s16 y); void SetFixedHoleWarpAsDestination(s16 x, s16 y);
void warp1_set_to_sav1w(void); void warp1_set_to_sav1w(void);
@ -75,7 +75,7 @@ void sub_8084F2C(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
void sub_8084F6C(u8 a1); void sub_8084F6C(u8 a1);
void sub_8084FAC(void); void sub_8084FAC(void);
const struct MapConnection *GetMapConnection(u8 dir); const struct MapConnection *GetMapConnection(u8 dir);
bool8 SetDiveWarp(u8 dir, u16 x, u16 y); static bool8 SetDiveWarp(u8 dir, u16 x, u16 y);
bool8 SetDiveWarpEmerge(u16 x, u16 y); bool8 SetDiveWarpEmerge(u16 x, u16 y);
bool8 SetDiveWarpDive(u16 x, u16 y); bool8 SetDiveWarpDive(u16 x, u16 y);
void mliX_load_map(u8 mapGroup, u8 mapNum); void mliX_load_map(u8 mapGroup, u8 mapNum);
@ -105,7 +105,7 @@ void UpdateAmbientCry(s16 *state, u16 *delayCounter);
u8 GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum); u8 GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum);
u8 GetMapTypeByWarpData(struct WarpData *warp); u8 GetMapTypeByWarpData(struct WarpData *warp);
u8 Overworld_GetMapTypeOfSaveblockLocation(void); u8 Overworld_GetMapTypeOfSaveblockLocation(void);
u8 get_map_light_from_warp0(void); u8 GetLastUsedWarpMapType(void);
bool8 is_map_type_1_2_3_5_or_6(u8 mapType); bool8 is_map_type_1_2_3_5_or_6(u8 mapType);
bool8 Overworld_MapTypeAllowsTeleportAndFly(u8 mapType); bool8 Overworld_MapTypeAllowsTeleportAndFly(u8 mapType);
bool8 Overworld_MapTypeIsIndoors(u8 mapType); bool8 Overworld_MapTypeIsIndoors(u8 mapType);

View File

@ -664,7 +664,7 @@ u8 BattleSetup_GetTerrainId(void)
return BATTLE_TERRAIN_MOUNTAIN; return BATTLE_TERRAIN_MOUNTAIN;
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING))
{ {
if (MetatileBehavior_GetBridgeSth(tileBehavior)) if (MetatileBehavior_GetBridgeType(tileBehavior))
return BATTLE_TERRAIN_POND; return BATTLE_TERRAIN_POND;
if (MetatileBehavior_IsBridge(tileBehavior) == TRUE) if (MetatileBehavior_IsBridge(tileBehavior) == TRUE)
return BATTLE_TERRAIN_WATER; return BATTLE_TERRAIN_WATER;

View File

@ -1,12 +1,13 @@
#include "global.h" #include "global.h"
#include "berry.h" #include "berry.h"
#include "main.h"
#include "item.h"
#include "constants/items.h"
#include "text.h"
#include "random.h"
#include "event_data.h" #include "event_data.h"
#include "fieldmap.h" #include "fieldmap.h"
#include "item.h"
#include "main.h"
#include "random.h"
#include "text.h"
#include "constants/event_object_movement_constants.h"
#include "constants/items.h"
extern u8 EventObjectGetBerryTreeId(u8 eventObjectId); extern u8 EventObjectGetBerryTreeId(u8 eventObjectId);
extern void sub_8092EF0(u8 mapId, u8 mapNumber, u8 mapGroup); extern void sub_8092EF0(u8 mapId, u8 mapNumber, u8 mapGroup);
@ -18,6 +19,17 @@ extern u16 gSpecialVar_ItemId;
extern const u8 BerryTreeScript[]; extern const u8 BerryTreeScript[];
static u32 GetEnigmaBerryChecksum(struct EnigmaBerry *enigmaBerry);
static bool32 BerryTreeGrow(struct BerryTree *tree);
static u16 BerryTypeToItemId(u16 berry);
static u8 BerryTreeGetNumStagesWatered(struct BerryTree *tree);
static u8 GetNumStagesWateredByBerryTreeId(u8 id);
static u8 CalcBerryYieldInternal(u16 max, u16 min, u8 water);
static u8 CalcBerryYield(struct BerryTree *tree);
static u8 GetBerryCountByBerryTreeId(u8 id);
static u16 GetStageDurationByBerryType(u8);
//.rodata
static const u8 sBerryDescriptionPart1_Cheri[] = _("Blooms with delicate pretty flowers."); static const u8 sBerryDescriptionPart1_Cheri[] = _("Blooms with delicate pretty flowers.");
static const u8 sBerryDescriptionPart2_Cheri[] = _("The bright red BERRY is very spicy."); static const u8 sBerryDescriptionPart2_Cheri[] = _("The bright red BERRY is very spicy.");
static const u8 sBerryDescriptionPart1_Chesto[] = _("The BERRYs thick skin and fruit are"); static const u8 sBerryDescriptionPart1_Chesto[] = _("The BERRYs thick skin and fruit are");
@ -845,6 +857,7 @@ const struct UnkStruct_0858AB24 gUnknown_0858AB24[] = {
const struct BerryTree gBlankBerryTree = {}; const struct BerryTree gBlankBerryTree = {};
//.text
// unused // unused
void ClearEnigmaBerries(void) void ClearEnigmaBerries(void)
{ {
@ -860,7 +873,7 @@ void SetEnigmaBerry(u8 *src)
dest[i] = src[i]; dest[i] = src[i];
} }
u32 GetEnigmaBerryChecksum(struct EnigmaBerry *enigmaBerry) static u32 GetEnigmaBerryChecksum(struct EnigmaBerry *enigmaBerry)
{ {
u32 i; u32 i;
u32 checksum; u32 checksum;
@ -889,12 +902,12 @@ bool32 IsEnigmaBerryValid(void)
const struct Berry *GetBerryInfo(u8 berry) const struct Berry *GetBerryInfo(u8 berry)
{ {
if (berry == 0x2B && IsEnigmaBerryValid()) if (berry == ITEM_TO_BERRY(ITEM_ENIGMA_BERRY) && IsEnigmaBerryValid())
return (struct Berry*)(&gSaveBlock1Ptr->enigmaBerry.berry); return (struct Berry*)(&gSaveBlock1Ptr->enigmaBerry.berry);
else else
{ {
if (berry == 0 || berry > 0x2B) if (berry == BERRY_NONE || berry > ITEM_TO_BERRY(LAST_BERRY_INDEX))
berry = 1; berry = ITEM_TO_BERRY(FIRST_BERRY_INDEX);
return &gBerries[berry - 1]; return &gBerries[berry - 1];
} }
} }
@ -910,16 +923,16 @@ bool32 EventObjectInteractionWaterBerryTree(void)
switch (tree->stage) switch (tree->stage)
{ {
case 1: case BERRY_STAGE_PLANTED:
tree->watered1 = TRUE; tree->watered1 = TRUE;
break; break;
case 2: case BERRY_STAGE_SPROUTED:
tree->watered2 = TRUE; tree->watered2 = TRUE;
break; break;
case 3: case BERRY_STAGE_TALLER:
tree->watered3 = TRUE; tree->watered3 = TRUE;
break; break;
case 4: case BERRY_STAGE_FLOWERING:
tree->watered4 = TRUE; tree->watered4 = TRUE;
break; break;
default: default:
@ -953,28 +966,28 @@ void ClearBerryTrees(void)
gSaveBlock1Ptr->berryTrees[i] = gBlankBerryTree; gSaveBlock1Ptr->berryTrees[i] = gBlankBerryTree;
} }
bool32 BerryTreeGrow(struct BerryTree *tree) static bool32 BerryTreeGrow(struct BerryTree *tree)
{ {
if (tree->growthSparkle) if (tree->growthSparkle)
return FALSE; return FALSE;
switch (tree->stage) switch (tree->stage)
{ {
case 0: case BERRY_STAGE_NO_BERRY:
return FALSE; return FALSE;
case 4: case BERRY_STAGE_FLOWERING:
tree->berryYield = CalcBerryYield(tree); tree->berryYield = CalcBerryYield(tree);
case 1: case BERRY_STAGE_PLANTED:
case 2: case BERRY_STAGE_SPROUTED:
case 3: case BERRY_STAGE_TALLER:
tree->stage++; tree->stage++;
break; break;
case 5: case BERRY_STAGE_BERRIES:
tree->watered1 = 0; tree->watered1 = 0;
tree->watered2 = 0; tree->watered2 = 0;
tree->watered3 = 0; tree->watered3 = 0;
tree->watered4 = 0; tree->watered4 = 0;
tree->berryYield = 0; tree->berryYield = 0;
tree->stage = 2; tree->stage = BERRY_STAGE_SPROUTED;
if (++tree->regrowthCount == 10) if (++tree->regrowthCount == 10)
*tree = gBlankBerryTree; *tree = gBlankBerryTree;
break; break;
@ -1012,7 +1025,7 @@ void BerryTreeTimeUpdate(s32 minutes)
tree->minutesUntilNextStage = GetStageDurationByBerryType(tree->berry); tree->minutesUntilNextStage = GetStageDurationByBerryType(tree->berry);
if (!BerryTreeGrow(tree)) if (!BerryTreeGrow(tree))
break; break;
if (tree->stage == 5) if (tree->stage == BERRY_STAGE_BERRIES)
tree->minutesUntilNextStage *= 4; tree->minutesUntilNextStage *= 4;
} }
} }
@ -1028,7 +1041,7 @@ void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 sparkle)
tree->berry = berry; tree->berry = berry;
tree->minutesUntilNextStage = GetStageDurationByBerryType(berry); tree->minutesUntilNextStage = GetStageDurationByBerryType(berry);
tree->stage = stage; tree->stage = stage;
if (stage == 5) if (stage == BERRY_STAGE_BERRIES)
{ {
tree->berryYield = CalcBerryYield(tree); tree->berryYield = CalcBerryYield(tree);
tree->minutesUntilNextStage *= 4; tree->minutesUntilNextStage *= 4;
@ -1064,7 +1077,7 @@ u8 ItemIdToBerryType(u16 item)
return ITEM_TO_BERRY(item); return ITEM_TO_BERRY(item);
} }
u16 BerryTypeToItemId(u16 berry) static u16 BerryTypeToItemId(u16 berry)
{ {
u16 item = berry - 1; u16 item = berry - 1;
@ -1087,10 +1100,10 @@ void GetBerryCountStringByBerryType(u8 berry, u8* dest, u32 berryCount)
void ResetBerryTreeSparkleFlag(u8 id) void ResetBerryTreeSparkleFlag(u8 id)
{ {
GetBerryTreeInfo(id)->growthSparkle = 0; GetBerryTreeInfo(id)->growthSparkle = FALSE;
} }
u8 BerryTreeGetNumStagesWatered(struct BerryTree *tree) static u8 BerryTreeGetNumStagesWatered(struct BerryTree *tree)
{ {
u8 count = 0; u8 count = 0;
@ -1105,12 +1118,12 @@ u8 BerryTreeGetNumStagesWatered(struct BerryTree *tree)
return count; return count;
} }
u8 GetNumStagesWateredByBerryTreeId(u8 id) static u8 GetNumStagesWateredByBerryTreeId(u8 id)
{ {
return BerryTreeGetNumStagesWatered(GetBerryTreeInfo(id)); return BerryTreeGetNumStagesWatered(GetBerryTreeInfo(id));
} }
u8 CalcBerryYieldInternal(u16 max, u16 min, u8 water) static u8 CalcBerryYieldInternal(u16 max, u16 min, u8 water)
{ {
u32 randMin; u32 randMin;
u32 randMax; u32 randMax;
@ -1133,7 +1146,7 @@ u8 CalcBerryYieldInternal(u16 max, u16 min, u8 water)
} }
} }
u8 CalcBerryYield(struct BerryTree *tree) static u8 CalcBerryYield(struct BerryTree *tree)
{ {
const struct Berry *berry = GetBerryInfo(tree->berry); const struct Berry *berry = GetBerryInfo(tree->berry);
u8 min = berry->minYield; u8 min = berry->minYield;
@ -1142,12 +1155,12 @@ u8 CalcBerryYield(struct BerryTree *tree)
return CalcBerryYieldInternal(max, min, BerryTreeGetNumStagesWatered(tree)); return CalcBerryYieldInternal(max, min, BerryTreeGetNumStagesWatered(tree));
} }
u8 GetBerryCountByBerryTreeId(u8 id) static u8 GetBerryCountByBerryTreeId(u8 id)
{ {
return gSaveBlock1Ptr->berryTrees[id].berryYield; return gSaveBlock1Ptr->berryTrees[id].berryYield;
} }
u16 GetStageDurationByBerryType(u8 berry) static u16 GetStageDurationByBerryType(u8 berry)
{ {
return GetBerryInfo(berry)->stageDuration * 60; return GetBerryInfo(berry)->stageDuration * 60;
} }
@ -1156,18 +1169,18 @@ void EventObjectInteractionGetBerryTreeData(void)
{ {
u8 id; u8 id;
u8 berry; u8 berry;
u8 unk; u8 localId;
u8 group; u8 group;
u8 num; u8 num;
id = EventObjectGetBerryTreeId(gSelectedEventObject); id = EventObjectGetBerryTreeId(gSelectedEventObject);
berry = GetBerryTypeByBerryTreeId(id); berry = GetBerryTypeByBerryTreeId(id);
ResetBerryTreeSparkleFlag(id); ResetBerryTreeSparkleFlag(id);
unk = gSpecialVar_LastTalked; localId = gSpecialVar_LastTalked;
num = gSaveBlock1Ptr->location.mapNum; num = gSaveBlock1Ptr->location.mapNum;
group = gSaveBlock1Ptr->location.mapGroup; group = gSaveBlock1Ptr->location.mapGroup;
if (IsBerryTreeSparkling(unk, num, group)) if (IsBerryTreeSparkling(localId, num, group))
gSpecialVar_0x8004 = 0xFF; gSpecialVar_0x8004 = BERRY_STAGE_SPARKLING;
else else
gSpecialVar_0x8004 = GetStageByBerryTreeId(id); gSpecialVar_0x8004 = GetStageByBerryTreeId(id);
gSpecialVar_0x8005 = GetNumStagesWateredByBerryTreeId(id); gSpecialVar_0x8005 = GetNumStagesWateredByBerryTreeId(id);
@ -1216,7 +1229,7 @@ void EventObjectInteractionRemoveBerryTree(void)
sub_8092EF0(gSpecialVar_LastTalked, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup); sub_8092EF0(gSpecialVar_LastTalked, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
} }
u8 PlayerHasBerries(void) bool8 PlayerHasBerries(void)
{ {
return IsBagPocketNonEmpty(POCKET_BERRIES); return IsBagPocketNonEmpty(POCKET_BERRIES);
} }
@ -1238,7 +1251,7 @@ void ResetBerryTreeSparkleFlags(void)
bottom = top + 8; bottom = top + 8;
for (i = 0; i < EVENT_OBJECTS_COUNT; i++) for (i = 0; i < EVENT_OBJECTS_COUNT; i++)
{ {
if (gEventObjects[i].active && gEventObjects[i].movementType == 12) if (gEventObjects[i].active && gEventObjects[i].movementType == MOVEMENT_TYPE_BERRY_TREE_GROWTH)
{ {
cam_left = gEventObjects[i].currentCoords.x; cam_left = gEventObjects[i].currentCoords.x;
cam_top = gEventObjects[i].currentCoords.y; cam_top = gEventObjects[i].currentCoords.y;

View File

@ -3,13 +3,13 @@
#include "event_object_movement.h" #include "event_object_movement.h"
#include "field_player_avatar.h" #include "field_player_avatar.h"
#include "fieldmap.h" #include "fieldmap.h"
#include "constants/flags.h"
#include "global.fieldmap.h" #include "global.fieldmap.h"
#include "metatile_behavior.h" #include "metatile_behavior.h"
#include "overworld.h" #include "overworld.h"
#include "constants/songs.h"
#include "sound.h" #include "sound.h"
#include "constants/flags.h"
#include "constants/map_types.h" #include "constants/map_types.h"
#include "constants/songs.h"
extern bool8 gBikeCyclingChallenge; extern bool8 gBikeCyclingChallenge;
extern u8 gBikeCollisions; extern u8 gBikeCollisions;

View File

@ -91,7 +91,7 @@ const union AnimCmd *const gFieldEffectObjectImageAnimTable_Ripple[] =
gFieldEffectObjectImageAnim_850CAE0, gFieldEffectObjectImageAnim_850CAE0,
}; };
const struct SpriteTemplate gFieldEffectObjectTemplate_Ripple = {0xFFFF, 0x1005, &gEventObjectBaseOam_16x16, gFieldEffectObjectImageAnimTable_Ripple, gFieldEffectObjectPicTable_Ripple, gDummySpriteAffineAnimTable, sub_81561D0}; const struct SpriteTemplate gFieldEffectObjectTemplate_Ripple = {0xFFFF, 0x1005, &gEventObjectBaseOam_16x16, gFieldEffectObjectImageAnimTable_Ripple, gFieldEffectObjectPicTable_Ripple, gDummySpriteAffineAnimTable, WaitFieldEffectSpriteAnim};
const struct SpriteFrameImage gFieldEffectObjectPicTable_Ash[] = { const struct SpriteFrameImage gFieldEffectObjectPicTable_Ash[] = {
overworld_frame(gFieldEffectObjectPic_Ash, 2, 2, 0), overworld_frame(gFieldEffectObjectPic_Ash, 2, 2, 0),
@ -124,25 +124,25 @@ const struct SpriteFrameImage gFieldEffectObjectPicTable_SurfBlob[] = {
overworld_frame(gFieldEffectObjectPic_SurfBlob, 4, 4, 2), overworld_frame(gFieldEffectObjectPic_SurfBlob, 4, 4, 2),
}; };
const union AnimCmd gFieldEffectObjectImageAnim_850CB94[] = const union AnimCmd gSurfBlobAnim_FaceSouth[] =
{ {
ANIMCMD_FRAME(0, 1), ANIMCMD_FRAME(0, 1),
ANIMCMD_JUMP(0), ANIMCMD_JUMP(0),
}; };
const union AnimCmd gFieldEffectObjectImageAnim_850CB9C[] = const union AnimCmd gSurfBlobAnim_FaceNorth[] =
{ {
ANIMCMD_FRAME(1, 1), ANIMCMD_FRAME(1, 1),
ANIMCMD_JUMP(0), ANIMCMD_JUMP(0),
}; };
const union AnimCmd gFieldEffectObjectImageAnim_850CBA4[] = const union AnimCmd gSurfBlobAnim_FaceWest[] =
{ {
ANIMCMD_FRAME(2, 1), ANIMCMD_FRAME(2, 1),
ANIMCMD_JUMP(0), ANIMCMD_JUMP(0),
}; };
const union AnimCmd gFieldEffectObjectImageAnim_850CBAC[] = const union AnimCmd gSurfBlobAnim_FaceEast[] =
{ {
ANIMCMD_FRAME(2, 1, .hFlip = TRUE), ANIMCMD_FRAME(2, 1, .hFlip = TRUE),
ANIMCMD_JUMP(0), ANIMCMD_JUMP(0),
@ -150,10 +150,10 @@ const union AnimCmd gFieldEffectObjectImageAnim_850CBAC[] =
const union AnimCmd *const gFieldEffectObjectImageAnimTable_SurfBlob[] = const union AnimCmd *const gFieldEffectObjectImageAnimTable_SurfBlob[] =
{ {
gFieldEffectObjectImageAnim_850CB94, gSurfBlobAnim_FaceSouth,
gFieldEffectObjectImageAnim_850CB9C, gSurfBlobAnim_FaceNorth,
gFieldEffectObjectImageAnim_850CBA4, gSurfBlobAnim_FaceWest,
gFieldEffectObjectImageAnim_850CBAC, gSurfBlobAnim_FaceEast,
}; };
const struct SpriteTemplate gFieldEffectObjectTemplate_SurfBlob = {0xFFFF, 0xFFFF, &gEventObjectBaseOam_32x32, gFieldEffectObjectImageAnimTable_SurfBlob, gFieldEffectObjectPicTable_SurfBlob, gDummySpriteAffineAnimTable, UpdateSurfBlobFieldEffect}; const struct SpriteTemplate gFieldEffectObjectTemplate_SurfBlob = {0xFFFF, 0xFFFF, &gEventObjectBaseOam_32x32, gFieldEffectObjectImageAnimTable_SurfBlob, gFieldEffectObjectPicTable_SurfBlob, gDummySpriteAffineAnimTable, UpdateSurfBlobFieldEffect};
@ -562,7 +562,7 @@ const union AnimCmd *const gFieldEffectObjectImageAnimTable_Unknown17[] =
gFieldEffectObjectImageAnim_850D05C, gFieldEffectObjectImageAnim_850D05C,
}; };
const struct SpriteTemplate gFieldEffectObjectTemplate_Unknown17 = {0xFFFF, 0x1005, &gEventObjectBaseOam_16x16, gFieldEffectObjectImageAnimTable_Unknown17, gFieldEffectObjectPicTable_Unknown17, gDummySpriteAffineAnimTable, sub_81561D0}; const struct SpriteTemplate gFieldEffectObjectTemplate_Unknown17 = {0xFFFF, 0x1005, &gEventObjectBaseOam_16x16, gFieldEffectObjectImageAnimTable_Unknown17, gFieldEffectObjectPicTable_Unknown17, gDummySpriteAffineAnimTable, WaitFieldEffectSpriteAnim};
const struct SpriteFrameImage gFieldEffectObjectPicTable_Unknown18[] = { const struct SpriteFrameImage gFieldEffectObjectPicTable_Unknown18[] = {
overworld_frame(gFieldEffectObjectPic_Unknown18, 2, 2, 0), overworld_frame(gFieldEffectObjectPic_Unknown18, 2, 2, 0),
@ -587,7 +587,7 @@ const union AnimCmd *const gFieldEffectObjectImageAnimTable_Unknown18[] =
gFieldEffectObjectImageAnim_850D0C0, gFieldEffectObjectImageAnim_850D0C0,
}; };
const struct SpriteTemplate gFieldEffectObjectTemplate_Unknown18 = {0xFFFF, 0x1005, &gEventObjectBaseOam_16x16, gFieldEffectObjectImageAnimTable_Unknown18, gFieldEffectObjectPicTable_Unknown18, gDummySpriteAffineAnimTable, sub_81561D0}; const struct SpriteTemplate gFieldEffectObjectTemplate_Unknown18 = {0xFFFF, 0x1005, &gEventObjectBaseOam_16x16, gFieldEffectObjectImageAnimTable_Unknown18, gFieldEffectObjectPicTable_Unknown18, gDummySpriteAffineAnimTable, WaitFieldEffectSpriteAnim};
const struct SpriteFrameImage gFieldEffectObjectPicTable_Unknown19[] = { const struct SpriteFrameImage gFieldEffectObjectPicTable_Unknown19[] = {
overworld_frame(gFieldEffectObjectPic_Unknown19, 2, 2, 0), overworld_frame(gFieldEffectObjectPic_Unknown19, 2, 2, 0),
@ -610,7 +610,7 @@ const union AnimCmd *const gFieldEffectObjectImageAnimTable_Unknown19[] =
gFieldEffectObjectImageAnim_850D118, gFieldEffectObjectImageAnim_850D118,
}; };
const struct SpriteTemplate gFieldEffectObjectTemplate_Unknown19 = {0xFFFF, 0x1004, &gEventObjectBaseOam_16x16, gFieldEffectObjectImageAnimTable_Unknown19, gFieldEffectObjectPicTable_Unknown19, gDummySpriteAffineAnimTable, sub_81561D0}; const struct SpriteTemplate gFieldEffectObjectTemplate_Unknown19 = {0xFFFF, 0x1004, &gEventObjectBaseOam_16x16, gFieldEffectObjectImageAnimTable_Unknown19, gFieldEffectObjectPicTable_Unknown19, gDummySpriteAffineAnimTable, WaitFieldEffectSpriteAnim};
const struct SpriteFrameImage gFieldEffectObjectPicTable_Unknown29[] = { const struct SpriteFrameImage gFieldEffectObjectPicTable_Unknown29[] = {
overworld_frame(gFieldEffectObjectPic_Unknown29, 2, 1, 0), overworld_frame(gFieldEffectObjectPic_Unknown29, 2, 1, 0),
@ -656,7 +656,7 @@ const union AnimCmd *const gFieldEffectObjectImageAnimTable_Unknown20[] =
gFieldEffectObjectImageAnim_850D1AC, gFieldEffectObjectImageAnim_850D1AC,
}; };
const struct SpriteTemplate gFieldEffectObjectTemplate_Unknown20 = {0xFFFF, 0x1004, &gEventObjectBaseOam_16x16, gFieldEffectObjectImageAnimTable_Unknown20, gFieldEffectObjectPicTable_Unknown20, gDummySpriteAffineAnimTable, sub_81561D0}; const struct SpriteTemplate gFieldEffectObjectTemplate_Unknown20 = {0xFFFF, 0x1004, &gEventObjectBaseOam_16x16, gFieldEffectObjectImageAnimTable_Unknown20, gFieldEffectObjectPicTable_Unknown20, gDummySpriteAffineAnimTable, WaitFieldEffectSpriteAnim};
const union AffineAnimCmd gFieldEffectObjectRotScalAnim_850D1E4[] = const union AffineAnimCmd gFieldEffectObjectRotScalAnim_850D1E4[] =
{ {
@ -733,7 +733,7 @@ const union AnimCmd *const gFieldEffectObjectImageAnimTable_BerryTreeGrowthSpark
gFieldEffectObjectImageAnim_850D2D4, gFieldEffectObjectImageAnim_850D2D4,
}; };
const struct SpriteTemplate gFieldEffectObjectTemplate_BerryTreeGrowthSparkle = {0xFFFF, 0xFFFF, &gEventObjectBaseOam_16x16, gFieldEffectObjectImageAnimTable_BerryTreeGrowthSparkle, gFieldEffectObjectPicTable_BerryTreeGrowthSparkle, gDummySpriteAffineAnimTable, sub_81561D0}; const struct SpriteTemplate gFieldEffectObjectTemplate_BerryTreeGrowthSparkle = {0xFFFF, 0xFFFF, &gEventObjectBaseOam_16x16, gFieldEffectObjectImageAnimTable_BerryTreeGrowthSparkle, gFieldEffectObjectPicTable_BerryTreeGrowthSparkle, gDummySpriteAffineAnimTable, WaitFieldEffectSpriteAnim};
const struct SpriteFrameImage gFieldEffectObjectPicTable_TreeDisguise[] = { const struct SpriteFrameImage gFieldEffectObjectPicTable_TreeDisguise[] = {
overworld_frame(gFieldEffectObjectPic_TreeDisguise, 2, 4, 0), overworld_frame(gFieldEffectObjectPic_TreeDisguise, 2, 4, 0),

View File

@ -1347,12 +1347,12 @@ void sub_8128060(u8 taskId)
void ConfigureCameraObjectForPlacingDecoration(struct PlaceDecorationGraphicsDataBuffer *data, u8 decor) void ConfigureCameraObjectForPlacingDecoration(struct PlaceDecorationGraphicsDataBuffer *data, u8 decor)
{ {
sDecor_CameraSpriteObjectIdx1 = gSprites[gUnknown_03005DD0.spriteId].data[0]; sDecor_CameraSpriteObjectIdx1 = gSprites[gFieldCamera.spriteId].data[0];
gUnknown_03005DD0.spriteId = gpu_pal_decompress_alloc_tag_and_upload(data, decor); gFieldCamera.spriteId = gpu_pal_decompress_alloc_tag_and_upload(data, decor);
gSprites[gUnknown_03005DD0.spriteId].oam.priority = 1; gSprites[gFieldCamera.spriteId].oam.priority = 1;
gSprites[gUnknown_03005DD0.spriteId].callback = sub_81292D0; gSprites[gFieldCamera.spriteId].callback = sub_81292D0;
gSprites[gUnknown_03005DD0.spriteId].pos1.x = gUnknown_085A7250[data->decoration->shape].x; gSprites[gFieldCamera.spriteId].pos1.x = gUnknown_085A7250[data->decoration->shape].x;
gSprites[gUnknown_03005DD0.spriteId].pos1.y = gUnknown_085A7250[data->decoration->shape].y; gSprites[gFieldCamera.spriteId].pos1.y = gUnknown_085A7250[data->decoration->shape].y;
} }
void SetUpPlacingDecorationPlayerAvatar(u8 taskId, struct PlaceDecorationGraphicsDataBuffer *data) void SetUpPlacingDecorationPlayerAvatar(u8 taskId, struct PlaceDecorationGraphicsDataBuffer *data)
@ -1374,7 +1374,7 @@ void SetUpPlacingDecorationPlayerAvatar(u8 taskId, struct PlaceDecorationGraphic
} }
gSprites[sDecor_CameraSpriteObjectIdx2].oam.priority = 1; gSprites[sDecor_CameraSpriteObjectIdx2].oam.priority = 1;
DestroySprite(&gSprites[sDecor_CameraSpriteObjectIdx1]); DestroySprite(&gSprites[sDecor_CameraSpriteObjectIdx1]);
sDecor_CameraSpriteObjectIdx1 = gUnknown_03005DD0.spriteId; sDecor_CameraSpriteObjectIdx1 = gFieldCamera.spriteId;
} }
void sub_812826C(u8 taskId) void sub_812826C(u8 taskId)
@ -2293,9 +2293,9 @@ bool8 sub_81299AC(u8 taskId)
void SetUpPuttingAwayDecorationPlayerAvatar(void) void SetUpPuttingAwayDecorationPlayerAvatar(void)
{ {
GetPlayerFacingDirection(); GetPlayerFacingDirection();
sDecor_CameraSpriteObjectIdx1 = gSprites[gUnknown_03005DD0.spriteId].data[0]; sDecor_CameraSpriteObjectIdx1 = gSprites[gFieldCamera.spriteId].data[0];
sub_812A39C(); sub_812A39C();
gUnknown_03005DD0.spriteId = CreateSprite(&gUnknown_085A7404, 0x78, 0x50, 0); gFieldCamera.spriteId = CreateSprite(&gUnknown_085A7404, 0x78, 0x50, 0);
if (gSaveBlock2Ptr->playerGender == MALE) if (gSaveBlock2Ptr->playerGender == MALE)
{ {
sDecor_CameraSpriteObjectIdx2 = AddPseudoEventObject(0xC1, SpriteCallbackDummy, 0x88, 0x48, 0); sDecor_CameraSpriteObjectIdx2 = AddPseudoEventObject(0xC1, SpriteCallbackDummy, 0x88, 0x48, 0);
@ -2306,7 +2306,7 @@ void SetUpPuttingAwayDecorationPlayerAvatar(void)
} }
gSprites[sDecor_CameraSpriteObjectIdx2].oam.priority = 1; gSprites[sDecor_CameraSpriteObjectIdx2].oam.priority = 1;
DestroySprite(&gSprites[sDecor_CameraSpriteObjectIdx1]); DestroySprite(&gSprites[sDecor_CameraSpriteObjectIdx1]);
sDecor_CameraSpriteObjectIdx1 = gUnknown_03005DD0.spriteId; sDecor_CameraSpriteObjectIdx1 = gFieldCamera.spriteId;
gSprites[sDecor_CameraSpriteObjectIdx1].oam.priority = 1; gSprites[sDecor_CameraSpriteObjectIdx1].oam.priority = 1;
} }

File diff suppressed because it is too large Load Diff

View File

@ -15,71 +15,71 @@
EWRAM_DATA bool8 gUnusedBikeCameraAheadPanback = FALSE; EWRAM_DATA bool8 gUnusedBikeCameraAheadPanback = FALSE;
// Static type declarations // Static type declarations
struct FieldCameraUnknownStruct struct FieldCameraOffset
{ {
u8 unk0; u8 xPixelOffset;
u8 unk1; u8 yPixelOffset;
u8 unk2; u8 xTileOffset;
u8 unk3; u8 yTileOffset;
bool8 unk4; bool8 copyBGToVRAM;
}; };
// static functions // static functions
static void RedrawMapSliceNorth(struct FieldCameraUnknownStruct *a, const struct MapLayout *mapLayout); static void RedrawMapSliceNorth(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout);
static void RedrawMapSliceSouth(struct FieldCameraUnknownStruct *a, const struct MapLayout *mapLayout); static void RedrawMapSliceSouth(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout);
static void RedrawMapSliceEast(struct FieldCameraUnknownStruct *a, const struct MapLayout *mapLayout); static void RedrawMapSliceEast(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout);
static void RedrawMapSliceWest(struct FieldCameraUnknownStruct *a, const struct MapLayout *mapLayout); static void RedrawMapSliceWest(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout);
static s32 MapPosToBgTilemapOffset(struct FieldCameraUnknownStruct *a, s32 x, s32 y); static s32 MapPosToBgTilemapOffset(struct FieldCameraOffset *a, s32 x, s32 y);
static void DrawWholeMapViewInternal(int x, int y, const struct MapLayout *mapLayout); static void DrawWholeMapViewInternal(int x, int y, const struct MapLayout *mapLayout);
static void DrawMetatileAt(const struct MapLayout *mapLayout, u16, int, int); static void DrawMetatileAt(const struct MapLayout *mapLayout, u16, int, int);
static void DrawMetatile(s32 a, u16 *b, u16 c); static void DrawMetatile(s32 a, u16 *b, u16 c);
static void CameraPanningCB_PanAhead(void); static void CameraPanningCB_PanAhead(void);
// IWRAM bss vars // IWRAM bss vars
static IWRAM_DATA struct FieldCameraUnknownStruct gUnknown_03000E20; static IWRAM_DATA struct FieldCameraOffset sFieldCameraOffset;
static IWRAM_DATA s16 gUnknown_03000E28; static IWRAM_DATA s16 sHorizontalCameraPan;
static IWRAM_DATA s16 gUnknown_03000E2A; static IWRAM_DATA s16 sVerticalCameraPan;
static IWRAM_DATA u8 gUnknown_03000E2C; static IWRAM_DATA u8 gUnknown_03000E2C;
static IWRAM_DATA void (*gUnknown_03000E30)(void); static IWRAM_DATA void (*sFieldCameraPanningCallback)(void);
struct CameraObject gUnknown_03005DD0; struct CameraObject gFieldCamera;
u16 gUnknown_03005DE8; u16 gTotalCameraPixelOffsetY;
u16 gUnknown_03005DEC; u16 gTotalCameraPixelOffsetX;
// text // text
static void move_tilemap_camera_to_upper_left_corner_(struct FieldCameraUnknownStruct *a) static void move_tilemap_camera_to_upper_left_corner_(struct FieldCameraOffset *cameraOffset)
{ {
a->unk2 = 0; cameraOffset->xTileOffset = 0;
a->unk3 = 0; cameraOffset->yTileOffset = 0;
a->unk0 = 0; cameraOffset->xPixelOffset = 0;
a->unk1 = 0; cameraOffset->yPixelOffset = 0;
a->unk4 = TRUE; cameraOffset->copyBGToVRAM = TRUE;
} }
static void tilemap_move_something(struct FieldCameraUnknownStruct *a, u32 b, u32 c) static void tilemap_move_something(struct FieldCameraOffset *cameraOffset, u32 b, u32 c)
{ {
a->unk2 += b; cameraOffset->xTileOffset += b;
a->unk2 %= 32; cameraOffset->xTileOffset %= 32;
a->unk3 += c; cameraOffset->yTileOffset += c;
a->unk3 %= 32; cameraOffset->yTileOffset %= 32;
} }
static void coords8_add(struct FieldCameraUnknownStruct *a, u32 b, u32 c) static void coords8_add(struct FieldCameraOffset *cameraOffset, u32 b, u32 c)
{ {
a->unk0 += b; cameraOffset->xPixelOffset += b;
a->unk1 += c; cameraOffset->yPixelOffset += c;
} }
void move_tilemap_camera_to_upper_left_corner(void) void move_tilemap_camera_to_upper_left_corner(void)
{ {
move_tilemap_camera_to_upper_left_corner_(&gUnknown_03000E20); move_tilemap_camera_to_upper_left_corner_(&sFieldCameraOffset);
} }
void FieldUpdateBgTilemapScroll(void) void FieldUpdateBgTilemapScroll(void)
{ {
u32 r4, r5; u32 r4, r5;
r5 = gUnknown_03000E20.unk0 + gUnknown_03000E28; r5 = sFieldCameraOffset.xPixelOffset + sHorizontalCameraPan;
r4 = gUnknown_03000E2A + gUnknown_03000E20.unk1 + 8; r4 = sVerticalCameraPan + sFieldCameraOffset.yPixelOffset + 8;
SetGpuReg(REG_OFFSET_BG1HOFS, r5); SetGpuReg(REG_OFFSET_BG1HOFS, r5);
SetGpuReg(REG_OFFSET_BG1VOFS, r4); SetGpuReg(REG_OFFSET_BG1VOFS, r4);
@ -91,14 +91,14 @@ void FieldUpdateBgTilemapScroll(void)
void sub_8089C08(s16 *a, s16 *b) void sub_8089C08(s16 *a, s16 *b)
{ {
*a = gUnknown_03000E20.unk0 + gUnknown_03000E28; *a = sFieldCameraOffset.xPixelOffset + sHorizontalCameraPan;
*b = gUnknown_03000E20.unk1 + gUnknown_03000E2A + 8; *b = sFieldCameraOffset.yPixelOffset + sVerticalCameraPan + 8;
} }
void DrawWholeMapView(void) void DrawWholeMapView(void)
{ {
DrawWholeMapViewInternal(gSaveBlock1Ptr->pos.x, gSaveBlock1Ptr->pos.y, gMapHeader.mapLayout); DrawWholeMapViewInternal(gSaveBlock1Ptr->pos.x, gSaveBlock1Ptr->pos.y, gMapHeader.mapLayout);
gUnknown_03000E20.unk4 = TRUE; sFieldCameraOffset.copyBGToVRAM = TRUE;
} }
static void DrawWholeMapViewInternal(int x, int y, const struct MapLayout *mapLayout) static void DrawWholeMapViewInternal(int x, int y, const struct MapLayout *mapLayout)
@ -110,13 +110,13 @@ static void DrawWholeMapViewInternal(int x, int y, const struct MapLayout *mapLa
for (i = 0; i < 32; i += 2) for (i = 0; i < 32; i += 2)
{ {
temp = gUnknown_03000E20.unk3 + i; temp = sFieldCameraOffset.yTileOffset + i;
if (temp >= 32) if (temp >= 32)
temp -= 32; temp -= 32;
r6 = temp * 32; r6 = temp * 32;
for (j = 0; j < 32; j += 2) for (j = 0; j < 32; j += 2)
{ {
temp = gUnknown_03000E20.unk2 + j; temp = sFieldCameraOffset.xTileOffset + j;
if (temp >= 32) if (temp >= 32)
temp -= 32; temp -= 32;
DrawMetatileAt(mapLayout, r6 + temp, x + j / 2, y + i / 2); DrawMetatileAt(mapLayout, r6 + temp, x + j / 2, y + i / 2);
@ -124,112 +124,112 @@ static void DrawWholeMapViewInternal(int x, int y, const struct MapLayout *mapLa
} }
} }
static void RedrawMapSlicesForCameraUpdate(struct FieldCameraUnknownStruct *a, int x, int y) static void RedrawMapSlicesForCameraUpdate(struct FieldCameraOffset *cameraOffset, int x, int y)
{ {
const struct MapLayout *mapLayout = gMapHeader.mapLayout; const struct MapLayout *mapLayout = gMapHeader.mapLayout;
if (x > 0) if (x > 0)
RedrawMapSliceWest(a, mapLayout); RedrawMapSliceWest(cameraOffset, mapLayout);
if (x < 0) if (x < 0)
RedrawMapSliceEast(a, mapLayout); RedrawMapSliceEast(cameraOffset, mapLayout);
if (y > 0) if (y > 0)
RedrawMapSliceNorth(a, mapLayout); RedrawMapSliceNorth(cameraOffset, mapLayout);
if (y < 0) if (y < 0)
RedrawMapSliceSouth(a, mapLayout); RedrawMapSliceSouth(cameraOffset, mapLayout);
a->unk4 = TRUE; cameraOffset->copyBGToVRAM = TRUE;
} }
static void RedrawMapSliceNorth(struct FieldCameraUnknownStruct *a, const struct MapLayout *mapLayout) static void RedrawMapSliceNorth(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout)
{ {
u8 i; u8 i;
u8 temp; u8 temp;
u32 r7; u32 r7;
temp = a->unk3 + 28; temp = cameraOffset->yTileOffset + 28;
if (temp >= 32) if (temp >= 32)
temp -= 32; temp -= 32;
r7 = temp * 32; r7 = temp * 32;
for (i = 0; i < 32; i += 2) for (i = 0; i < 32; i += 2)
{ {
temp = a->unk2 + i; temp = cameraOffset->xTileOffset + i;
if (temp >= 32) if (temp >= 32)
temp -= 32; temp -= 32;
DrawMetatileAt(mapLayout, r7 + temp, gSaveBlock1Ptr->pos.x + i / 2, gSaveBlock1Ptr->pos.y + 14); DrawMetatileAt(mapLayout, r7 + temp, gSaveBlock1Ptr->pos.x + i / 2, gSaveBlock1Ptr->pos.y + 14);
} }
} }
static void RedrawMapSliceSouth(struct FieldCameraUnknownStruct *a, const struct MapLayout *mapLayout) static void RedrawMapSliceSouth(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout)
{ {
u8 i; u8 i;
u8 temp; u8 temp;
u32 r7 = a->unk3 * 32; u32 r7 = cameraOffset->yTileOffset * 32;
for (i = 0; i < 32; i += 2) for (i = 0; i < 32; i += 2)
{ {
temp = a->unk2 + i; temp = cameraOffset->xTileOffset + i;
if (temp >= 32) if (temp >= 32)
temp -= 32; temp -= 32;
DrawMetatileAt(mapLayout, r7 + temp, gSaveBlock1Ptr->pos.x + i / 2, gSaveBlock1Ptr->pos.y); DrawMetatileAt(mapLayout, r7 + temp, gSaveBlock1Ptr->pos.x + i / 2, gSaveBlock1Ptr->pos.y);
} }
} }
static void RedrawMapSliceEast(struct FieldCameraUnknownStruct *a, const struct MapLayout *mapLayout) static void RedrawMapSliceEast(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout)
{ {
u8 i; u8 i;
u8 temp; u8 temp;
u32 r6 = a->unk2; u32 r6 = cameraOffset->xTileOffset;
for (i = 0; i < 32; i += 2) for (i = 0; i < 32; i += 2)
{ {
temp = a->unk3 + i; temp = cameraOffset->yTileOffset + i;
if (temp >= 32) if (temp >= 32)
temp -= 32; temp -= 32;
DrawMetatileAt(mapLayout, temp * 32 + r6, gSaveBlock1Ptr->pos.x, gSaveBlock1Ptr->pos.y + i / 2); DrawMetatileAt(mapLayout, temp * 32 + r6, gSaveBlock1Ptr->pos.x, gSaveBlock1Ptr->pos.y + i / 2);
} }
} }
static void RedrawMapSliceWest(struct FieldCameraUnknownStruct *a, const struct MapLayout *mapLayout) static void RedrawMapSliceWest(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout)
{ {
u8 i; u8 i;
u8 temp; u8 temp;
u8 r5 = a->unk2 + 28; u8 r5 = cameraOffset->xTileOffset + 28;
if (r5 >= 32) if (r5 >= 32)
r5 -= 32; r5 -= 32;
for (i = 0; i < 32; i += 2) for (i = 0; i < 32; i += 2)
{ {
temp = a->unk3 + i; temp = cameraOffset->yTileOffset + i;
if (temp >= 32) if (temp >= 32)
temp -= 32; temp -= 32;
DrawMetatileAt(mapLayout, temp * 32 + r5, gSaveBlock1Ptr->pos.x + 14, gSaveBlock1Ptr->pos.y + i / 2); DrawMetatileAt(mapLayout, temp * 32 + r5, gSaveBlock1Ptr->pos.x + 14, gSaveBlock1Ptr->pos.y + i / 2);
} }
} }
void CurrentMapDrawMetatileAt(int a, int b) void CurrentMapDrawMetatileAt(int x, int y)
{ {
int offset = MapPosToBgTilemapOffset(&gUnknown_03000E20, a, b); int offset = MapPosToBgTilemapOffset(&sFieldCameraOffset, x, y);
if (offset >= 0) if (offset >= 0)
{ {
DrawMetatileAt(gMapHeader.mapLayout, offset, a, b); DrawMetatileAt(gMapHeader.mapLayout, offset, x, y);
gUnknown_03000E20.unk4 = TRUE; sFieldCameraOffset.copyBGToVRAM = TRUE;
} }
} }
void DrawDoorMetatileAt(int x, int y, u16 *arr) void DrawDoorMetatileAt(int x, int y, u16 *arr)
{ {
int offset = MapPosToBgTilemapOffset(&gUnknown_03000E20, x, y); int offset = MapPosToBgTilemapOffset(&sFieldCameraOffset, x, y);
if (offset >= 0) if (offset >= 0)
{ {
DrawMetatile(1, arr, offset); DrawMetatile(1, arr, offset);
gUnknown_03000E20.unk4 = TRUE; sFieldCameraOffset.copyBGToVRAM = TRUE;
} }
} }
static void DrawMetatileAt(const struct MapLayout *mapLayout, u16 b, int c, int d) static void DrawMetatileAt(const struct MapLayout *mapLayout, u16 offset, int x, int y)
{ {
u16 metatileId = MapGridGetMetatileIdAt(c, d); u16 metatileId = MapGridGetMetatileIdAt(x, y);
u16 *metatiles; u16 *metatiles;
if (metatileId > NUM_METATILES_TOTAL) if (metatileId > NUM_METATILES_TOTAL)
@ -241,60 +241,69 @@ static void DrawMetatileAt(const struct MapLayout *mapLayout, u16 b, int c, int
metatiles = mapLayout->secondaryTileset->metatiles; metatiles = mapLayout->secondaryTileset->metatiles;
metatileId -= NUM_METATILES_IN_PRIMARY; metatileId -= NUM_METATILES_IN_PRIMARY;
} }
DrawMetatile(MapGridGetMetatileLayerTypeAt(c, d), metatiles + metatileId * 8, b); DrawMetatile(MapGridGetMetatileLayerTypeAt(x, y), metatiles + metatileId * 8, offset);
} }
static void DrawMetatile(s32 a, u16 *b, u16 c) static void DrawMetatile(s32 metatileLayerType, u16 *metatiles, u16 offset)
{ {
switch (a) switch (metatileLayerType)
{ {
case 2: case 2: // LAYER_TYPE_
gBGTilemapBuffers3[c] = b[0]; // Draw metatile's bottom layer to the bottom background layer.
gBGTilemapBuffers3[c + 1] = b[1]; gBGTilemapBuffers3[offset] = metatiles[0];
gBGTilemapBuffers3[c + 0x20] = b[2]; gBGTilemapBuffers3[offset + 1] = metatiles[1];
gBGTilemapBuffers3[c + 0x21] = b[3]; gBGTilemapBuffers3[offset + 0x20] = metatiles[2];
gBGTilemapBuffers3[offset + 0x21] = metatiles[3];
gBGTilemapBuffers1[c] = 0; // Draw transparent tiles to the middle background layer.
gBGTilemapBuffers1[c + 1] = 0; gBGTilemapBuffers1[offset] = 0;
gBGTilemapBuffers1[c + 0x20] = 0; gBGTilemapBuffers1[offset + 1] = 0;
gBGTilemapBuffers1[c + 0x21] = 0; gBGTilemapBuffers1[offset + 0x20] = 0;
gBGTilemapBuffers1[offset + 0x21] = 0;
gBGTilemapBuffers2[c] = b[4]; // Draw metatile's top layer to the top background layer.
gBGTilemapBuffers2[c + 1] = b[5]; gBGTilemapBuffers2[offset] = metatiles[4];
gBGTilemapBuffers2[c + 0x20] = b[6]; gBGTilemapBuffers2[offset + 1] = metatiles[5];
gBGTilemapBuffers2[c + 0x21] = b[7]; gBGTilemapBuffers2[offset + 0x20] = metatiles[6];
gBGTilemapBuffers2[offset + 0x21] = metatiles[7];
break; break;
case 1: case 1: // LAYER_TYPE_COVERED_BY_OBJECTS
gBGTilemapBuffers3[c] = b[0]; // Draw metatile's bottom layer to the bottom background layer.
gBGTilemapBuffers3[c + 1] = b[1]; gBGTilemapBuffers3[offset] = metatiles[0];
gBGTilemapBuffers3[c + 0x20] = b[2]; gBGTilemapBuffers3[offset + 1] = metatiles[1];
gBGTilemapBuffers3[c + 0x21] = b[3]; gBGTilemapBuffers3[offset + 0x20] = metatiles[2];
gBGTilemapBuffers3[offset + 0x21] = metatiles[3];
gBGTilemapBuffers1[c] = b[4]; // Draw metatile's top layer to the middle background layer.
gBGTilemapBuffers1[c + 1] = b[5]; gBGTilemapBuffers1[offset] = metatiles[4];
gBGTilemapBuffers1[c + 0x20] = b[6]; gBGTilemapBuffers1[offset + 1] = metatiles[5];
gBGTilemapBuffers1[c + 0x21] = b[7]; gBGTilemapBuffers1[offset + 0x20] = metatiles[6];
gBGTilemapBuffers1[offset + 0x21] = metatiles[7];
gBGTilemapBuffers2[c] = 0; // Draw transparent tiles to the top background layer.
gBGTilemapBuffers2[c + 1] = 0; gBGTilemapBuffers2[offset] = 0;
gBGTilemapBuffers2[c + 0x20] = 0; gBGTilemapBuffers2[offset + 1] = 0;
gBGTilemapBuffers2[c + 0x21] = 0; gBGTilemapBuffers2[offset + 0x20] = 0;
gBGTilemapBuffers2[offset + 0x21] = 0;
break; break;
case 0: case 0: // LAYER_TYPE_NORMAL
gBGTilemapBuffers3[c] = 0x3014; // Draw garbage to the bottom background layer.
gBGTilemapBuffers3[c + 1] = 0x3014; gBGTilemapBuffers3[offset] = 0x3014;
gBGTilemapBuffers3[c + 0x20] = 0x3014; gBGTilemapBuffers3[offset + 1] = 0x3014;
gBGTilemapBuffers3[c + 0x21] = 0x3014; gBGTilemapBuffers3[offset + 0x20] = 0x3014;
gBGTilemapBuffers3[offset + 0x21] = 0x3014;
gBGTilemapBuffers1[c] = b[0]; // Draw metatile's bottom layer to the middle background layer.
gBGTilemapBuffers1[c + 1] = b[1]; gBGTilemapBuffers1[offset] = metatiles[0];
gBGTilemapBuffers1[c + 0x20] = b[2]; gBGTilemapBuffers1[offset + 1] = metatiles[1];
gBGTilemapBuffers1[c + 0x21] = b[3]; gBGTilemapBuffers1[offset + 0x20] = metatiles[2];
gBGTilemapBuffers1[offset + 0x21] = metatiles[3];
gBGTilemapBuffers2[c] = b[4]; // Draw metatile's top layer to the top background layer, which covers event object sprites.
gBGTilemapBuffers2[c + 1] = b[5]; gBGTilemapBuffers2[offset] = metatiles[4];
gBGTilemapBuffers2[c + 0x20] = b[6]; gBGTilemapBuffers2[offset + 1] = metatiles[5];
gBGTilemapBuffers2[c + 0x21] = b[7]; gBGTilemapBuffers2[offset + 0x20] = metatiles[6];
gBGTilemapBuffers2[offset + 0x21] = metatiles[7];
break; break;
} }
schedule_bg_copy_tilemap_to_vram(1); schedule_bg_copy_tilemap_to_vram(1);
@ -302,51 +311,51 @@ static void DrawMetatile(s32 a, u16 *b, u16 c)
schedule_bg_copy_tilemap_to_vram(3); schedule_bg_copy_tilemap_to_vram(3);
} }
static s32 MapPosToBgTilemapOffset(struct FieldCameraUnknownStruct *a, s32 x, s32 y) static s32 MapPosToBgTilemapOffset(struct FieldCameraOffset *cameraOffset, s32 x, s32 y)
{ {
x -= gSaveBlock1Ptr->pos.x; x -= gSaveBlock1Ptr->pos.x;
x *= 2; x *= 2;
if (x >= 32 || x < 0) if (x >= 32 || x < 0)
return -1; return -1;
x = x + a->unk2; x = x + cameraOffset->xTileOffset;
if (x >= 32) if (x >= 32)
x -= 32; x -= 32;
y = (y - gSaveBlock1Ptr->pos.y) * 2; y = (y - gSaveBlock1Ptr->pos.y) * 2;
if (y >= 32 || y < 0) if (y >= 32 || y < 0)
return -1; return -1;
y = y + a->unk3; y = y + cameraOffset->yTileOffset;
if (y >= 32) if (y >= 32)
y -= 32; y -= 32;
return y * 32 + x; return y * 32 + x;
} }
static void CameraUpdateCallback(struct CameraObject *a) static void CameraUpdateCallback(struct CameraObject *fieldCamera)
{ {
if (a->spriteId != 0) if (fieldCamera->spriteId != 0)
{ {
a->unk8 = gSprites[a->spriteId].data[2]; fieldCamera->movementSpeedX = gSprites[fieldCamera->spriteId].data[2];
a->unkC = gSprites[a->spriteId].data[3]; fieldCamera->movementSpeedY = gSprites[fieldCamera->spriteId].data[3];
} }
} }
void ResetCameraUpdateInfo(void) void ResetCameraUpdateInfo(void)
{ {
gUnknown_03005DD0.unk8 = 0; gFieldCamera.movementSpeedX = 0;
gUnknown_03005DD0.unkC = 0; gFieldCamera.movementSpeedY = 0;
gUnknown_03005DD0.x = 0; gFieldCamera.x = 0;
gUnknown_03005DD0.y = 0; gFieldCamera.y = 0;
gUnknown_03005DD0.spriteId = 0; gFieldCamera.spriteId = 0;
gUnknown_03005DD0.callback = NULL; gFieldCamera.callback = NULL;
} }
u32 InitCameraUpdateCallback(u8 a) u32 InitCameraUpdateCallback(u8 trackedSpriteId)
{ {
if (gUnknown_03005DD0.spriteId != 0) if (gFieldCamera.spriteId != 0)
DestroySprite(&gSprites[gUnknown_03005DD0.spriteId]); DestroySprite(&gSprites[gFieldCamera.spriteId]);
gUnknown_03005DD0.spriteId = AddCameraObject(a); gFieldCamera.spriteId = AddCameraObject(trackedSpriteId);
gUnknown_03005DD0.callback = CameraUpdateCallback; gFieldCamera.callback = CameraUpdateCallback;
return 0; return 0;
} }
@ -354,54 +363,54 @@ void CameraUpdate(void)
{ {
int deltaX; int deltaX;
int deltaY; int deltaY;
int r0; int curMovementOffsetY;
int r1; int curMovementOffsetX;
int r7; int movementSpeedX;
int r8; int movementSpeedY;
if (gUnknown_03005DD0.callback != NULL) if (gFieldCamera.callback != NULL)
gUnknown_03005DD0.callback(&gUnknown_03005DD0); gFieldCamera.callback(&gFieldCamera);
r7 = gUnknown_03005DD0.unk8; movementSpeedX = gFieldCamera.movementSpeedX;
r8 = gUnknown_03005DD0.unkC; movementSpeedY = gFieldCamera.movementSpeedY;
deltaX = 0; deltaX = 0;
deltaY = 0; deltaY = 0;
r1 = gUnknown_03005DD0.x; curMovementOffsetX = gFieldCamera.x;
r0 = gUnknown_03005DD0.y; curMovementOffsetY = gFieldCamera.y;
if (r1 == 0 && r7 != 0) if (curMovementOffsetX == 0 && movementSpeedX != 0)
{ {
if (r7 > 0) if (movementSpeedX > 0)
deltaX = 1; deltaX = 1;
else else
deltaX = -1; deltaX = -1;
} }
if (r0 == 0 && r8 != 0) if (curMovementOffsetY == 0 && movementSpeedY != 0)
{ {
if (r8 > 0) if (movementSpeedY > 0)
deltaY = 1; deltaY = 1;
else else
deltaY = -1; deltaY = -1;
} }
if (r1 != 0 && r1 == -r7) if (curMovementOffsetX != 0 && curMovementOffsetX == -movementSpeedX)
{ {
if (r7 > 0) if (movementSpeedX > 0)
deltaX = 1; deltaX = 1;
else else
deltaX = -1; deltaX = -1;
} }
if (r0 != 0 && r0 == -r8) if (curMovementOffsetY != 0 && curMovementOffsetY == -movementSpeedY)
{ {
if (r8 > 0) if (movementSpeedY > 0)
deltaX = 1; deltaX = 1;
else else
deltaX = -1; deltaX = -1;
} }
gUnknown_03005DD0.x += r7; gFieldCamera.x += movementSpeedX;
gUnknown_03005DD0.x = gUnknown_03005DD0.x - 16 * (gUnknown_03005DD0.x / 16); gFieldCamera.x = gFieldCamera.x - 16 * (gFieldCamera.x / 16);
gUnknown_03005DD0.y += r8; gFieldCamera.y += movementSpeedY;
gUnknown_03005DD0.y = gUnknown_03005DD0.y - 16 * (gUnknown_03005DD0.y / 16); gFieldCamera.y = gFieldCamera.y - 16 * (gFieldCamera.y / 16);
if (deltaX != 0 || deltaY != 0) if (deltaX != 0 || deltaY != 0)
{ {
@ -409,50 +418,50 @@ void CameraUpdate(void)
UpdateEventObjectsForCameraUpdate(deltaX, deltaY); UpdateEventObjectsForCameraUpdate(deltaX, deltaY);
RotatingGatePuzzleCameraUpdate(deltaX, deltaY); RotatingGatePuzzleCameraUpdate(deltaX, deltaY);
ResetBerryTreeSparkleFlags(); ResetBerryTreeSparkleFlags();
tilemap_move_something(&gUnknown_03000E20, deltaX * 2, deltaY * 2); tilemap_move_something(&sFieldCameraOffset, deltaX * 2, deltaY * 2);
RedrawMapSlicesForCameraUpdate(&gUnknown_03000E20, deltaX * 2, deltaY * 2); RedrawMapSlicesForCameraUpdate(&sFieldCameraOffset, deltaX * 2, deltaY * 2);
} }
coords8_add(&gUnknown_03000E20, r7, r8); coords8_add(&sFieldCameraOffset, movementSpeedX, movementSpeedY);
gUnknown_03005DEC -= r7; gTotalCameraPixelOffsetX -= movementSpeedX;
gUnknown_03005DE8 -= r8; gTotalCameraPixelOffsetY -= movementSpeedY;
} }
void camera_move_and_redraw(int a, int b) //unused void MoveCameraAndRedrawMap(int deltaX, int deltaY) //unused
{ {
CameraMove(a, b); CameraMove(deltaX, deltaY);
UpdateEventObjectsForCameraUpdate(a, b); UpdateEventObjectsForCameraUpdate(deltaX, deltaY);
DrawWholeMapView(); DrawWholeMapView();
gUnknown_03005DEC -= a * 16; gTotalCameraPixelOffsetX -= deltaX * 16;
gUnknown_03005DE8 -= b * 16; gTotalCameraPixelOffsetY -= deltaY * 16;
} }
void SetCameraPanningCallback(void (*a)(void)) void SetCameraPanningCallback(void (*a)(void))
{ {
gUnknown_03000E30 = a; sFieldCameraPanningCallback = a;
} }
void SetCameraPanning(s16 a, s16 b) void SetCameraPanning(s16 a, s16 b)
{ {
gUnknown_03000E28 = a; sHorizontalCameraPan = a;
gUnknown_03000E2A = b + 32; sVerticalCameraPan = b + 32;
} }
void InstallCameraPanAheadCallback(void) void InstallCameraPanAheadCallback(void)
{ {
gUnknown_03000E30 = CameraPanningCB_PanAhead; sFieldCameraPanningCallback = CameraPanningCB_PanAhead;
gUnknown_03000E2C = 0; gUnknown_03000E2C = 0;
gUnknown_03000E28 = 0; sHorizontalCameraPan = 0;
gUnknown_03000E2A = 32; sVerticalCameraPan = 32;
} }
void UpdateCameraPanning(void) void UpdateCameraPanning(void)
{ {
if (gUnknown_03000E30 != NULL) if (sFieldCameraPanningCallback != NULL)
gUnknown_03000E30(); sFieldCameraPanningCallback();
//Update sprite offset of overworld objects //Update sprite offset of overworld objects
gSpriteCoordOffsetX = gUnknown_03005DEC - gUnknown_03000E28; gSpriteCoordOffsetX = gTotalCameraPixelOffsetX - sHorizontalCameraPan;
gSpriteCoordOffsetY = gUnknown_03005DE8 - gUnknown_03000E2A - 8; gSpriteCoordOffsetY = gTotalCameraPixelOffsetY - sVerticalCameraPan - 8;
} }
static void CameraPanningCB_PanAhead(void) static void CameraPanningCB_PanAhead(void)
@ -480,22 +489,21 @@ static void CameraPanningCB_PanAhead(void)
var = GetPlayerMovementDirection(); var = GetPlayerMovementDirection();
if (var == 2) if (var == 2)
{ {
if (gUnknown_03000E2A > -8) if (sVerticalCameraPan > -8)
gUnknown_03000E2A -= 2; sVerticalCameraPan -= 2;
} }
else if (var == 1) else if (var == 1)
{ {
if (gUnknown_03000E2A < 72) if (sVerticalCameraPan < 72)
gUnknown_03000E2A += 2; sVerticalCameraPan += 2;
} }
else if (gUnknown_03000E2A < 32) else if (sVerticalCameraPan < 32)
{ {
gUnknown_03000E2A += 2; sVerticalCameraPan += 2;
} }
else if (gUnknown_03000E2A > 32) else if (sVerticalCameraPan > 32)
{ {
gUnknown_03000E2A -= 2; sVerticalCameraPan -= 2;
} }
} }
} }

View File

@ -179,7 +179,7 @@ void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys)
input->dpadDirection = DIR_EAST; input->dpadDirection = DIR_EAST;
} }
int sub_809C014(struct FieldInput *input) int ProcessPlayerFieldInput(struct FieldInput *input)
{ {
struct MapPosition position; struct MapPosition position;
u8 playerDirection; u8 playerDirection;

View File

@ -1,10 +1,9 @@
#include "global.h" #include "global.h"
#include "field_effect.h"
#include "trainer_pokemon_sprites.h"
#include "decompress.h" #include "decompress.h"
#include "field_camera.h"
#include "field_effect_helpers.h"
#include "event_object_movement.h" #include "event_object_movement.h"
#include "field_camera.h"
#include "field_effect.h"
#include "field_effect_helpers.h"
#include "field_player_avatar.h" #include "field_player_avatar.h"
#include "field_screen.h" #include "field_screen.h"
#include "field_weather.h" #include "field_weather.h"
@ -22,8 +21,10 @@
#include "sound.h" #include "sound.h"
#include "sprite.h" #include "sprite.h"
#include "task.h" #include "task.h"
#include "trainer_pokemon_sprites.h"
#include "trig.h" #include "trig.h"
#include "util.h" #include "util.h"
#include "constants/event_object_movement_constants.h"
#include "constants/rgb.h" #include "constants/rgb.h"
#include "constants/songs.h" #include "constants/songs.h"
@ -322,9 +323,9 @@ bool8 (*const gUnknown_0855C460[])(struct Task *, struct EventObject *, struct S
sub_80B7BF4, sub_80B7BF4,
}; };
void (*const gUnknown_0855C474[])(struct Task *) = { void (*const gEscapeRopeFieldEffectFuncs[])(struct Task *) = {
sub_80B7D14, EscapeRopeFieldEffect_Step0,
sub_80B7D34, EscapeRopeFieldEffect_Step1,
}; };
// .text // .text
@ -1686,7 +1687,7 @@ bool8 sub_80B7478(struct Task *task, struct EventObject *eventObject)
return FALSE; return FALSE;
} }
void Task_Dive(u8); static void Task_Dive(u8);
extern int dive_warp(struct MapPosition *, u16); extern int dive_warp(struct MapPosition *, u16);
bool8 FldEff_UseDive(void) bool8 FldEff_UseDive(void)
@ -1999,7 +2000,7 @@ bool8 sub_80B7BCC(struct Task *task, struct EventObject *eventObject, struct Spr
return FALSE; return FALSE;
} }
void sub_80B7CE4(u8); static void DoEscapeRopeFieldEffect(u8);
void mapldr_080859D4(void); void mapldr_080859D4(void);
bool8 sub_80B7BF4(struct Task *task, struct EventObject *eventObject, struct Sprite *sprite) bool8 sub_80B7BF4(struct Task *task, struct EventObject *eventObject, struct Sprite *sprite)
@ -2032,29 +2033,29 @@ void sub_80B7CAC(struct Sprite *sprite)
} }
} }
void sub_80B7CC8(void) void StartEscapeRopeFieldEffect(void)
{ {
ScriptContext2_Enable(); ScriptContext2_Enable();
FreezeEventObjects(); FreezeEventObjects();
CreateTask(sub_80B7CE4, 0x50); CreateTask(DoEscapeRopeFieldEffect, 0x50);
} }
void sub_80B7CE4(u8 taskId) static void DoEscapeRopeFieldEffect(u8 taskId)
{ {
gUnknown_0855C474[gTasks[taskId].data[0]](&gTasks[taskId]); gEscapeRopeFieldEffectFuncs[gTasks[taskId].data[0]](&gTasks[taskId]);
} }
void sub_80B7D14(struct Task *task) static void EscapeRopeFieldEffect_Step0(struct Task *task)
{ {
task->data[0]++; task->data[0]++;
task->data[14] = 64; task->data[14] = 64;
task->data[15] = GetPlayerFacingDirection(); task->data[15] = GetPlayerFacingDirection();
} }
void sub_80B7D34(struct Task *task) static void EscapeRopeFieldEffect_Step1(struct Task *task)
{ {
struct EventObject *eventObject; struct EventObject *eventObject;
u8 spinDirections[5] = {1, 3, 4, 2, 1}; u8 spinDirections[5] = {DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH};
if (task->data[14] != 0 && (--task->data[14]) == 0) if (task->data[14] != 0 && (--task->data[14]) == 0)
{ {
music_something(); music_something();
@ -2070,7 +2071,7 @@ void sub_80B7D34(struct Task *task)
WarpIntoMap(); WarpIntoMap();
gFieldCallback = mapldr_080859D4; gFieldCallback = mapldr_080859D4;
SetMainCallback2(CB2_LoadMap); SetMainCallback2(CB2_LoadMap);
DestroyTask(FindTaskIdByFunc(sub_80B7CE4)); DestroyTask(FindTaskIdByFunc(DoEscapeRopeFieldEffect));
} else if (task->data[1] == 0 || (--task->data[1]) == 0) } else if (task->data[1] == 0 || (--task->data[1]) == 0)
{ {
EventObjectSetHeldMovement(eventObject, GetFaceDirectionMovementAction(spinDirections[eventObject->facingDirection])); EventObjectSetHeldMovement(eventObject, GetFaceDirectionMovementAction(spinDirections[eventObject->facingDirection]));
@ -2905,7 +2906,7 @@ void sub_80B8E14(struct Task *task)
if (!EventObjectIsMovementOverridden(eventObject) || EventObjectClearHeldMovementIfFinished(eventObject)) if (!EventObjectIsMovementOverridden(eventObject) || EventObjectClearHeldMovementIfFinished(eventObject))
{ {
sub_808C114(); sub_808C114();
EventObjectSetHeldMovement(eventObject, 0x39); EventObjectSetHeldMovement(eventObject, MOVEMENT_ACTION_START_ANIM_IN_DIRECTION);
task->data[0]++; task->data[0]++;
} }
} }
@ -3210,7 +3211,7 @@ void sub_80B9204(struct Task *task)
gPlayerAvatar.preventStep = TRUE; gPlayerAvatar.preventStep = TRUE;
SetPlayerAvatarStateMask(1); SetPlayerAvatarStateMask(1);
sub_808C114(); sub_808C114();
EventObjectSetHeldMovement(eventObject, 0x39); EventObjectSetHeldMovement(eventObject, MOVEMENT_ACTION_START_ANIM_IN_DIRECTION);
task->data[0]++; task->data[0]++;
} }
} }
@ -3250,7 +3251,7 @@ void sub_80B92F8(struct Task *task)
task->data[0]++; task->data[0]++;
task->data[2] = 16; task->data[2] = 16;
SetPlayerAvatarTransitionFlags(PLAYER_AVATAR_FLAG_ON_FOOT); SetPlayerAvatarTransitionFlags(PLAYER_AVATAR_FLAG_ON_FOOT);
EventObjectSetHeldMovement(&gEventObjects[gPlayerAvatar.eventObjectId], 0x02); EventObjectSetHeldMovement(&gEventObjects[gPlayerAvatar.eventObjectId], MOVEMENT_ACTION_FACE_LEFT);
} }
} }
@ -3275,7 +3276,7 @@ void sub_80B9390(struct Task *task)
EventObjectSetGraphicsId(eventObject, GetPlayerAvatarGraphicsIdByStateId(0x03)); EventObjectSetGraphicsId(eventObject, GetPlayerAvatarGraphicsIdByStateId(0x03));
StartSpriteAnim(&gSprites[eventObject->spriteId], 0x16); StartSpriteAnim(&gSprites[eventObject->spriteId], 0x16);
eventObject->inanimate = 1; eventObject->inanimate = 1;
EventObjectSetHeldMovement(eventObject, 0x48); EventObjectSetHeldMovement(eventObject, MOVEMENT_ACTION_JUMP_IN_PLACE_LEFT);
if (task->data[15] & 0x08) if (task->data[15] & 0x08)
{ {
DestroySprite(&gSprites[eventObject->fieldEffectSpriteId]); DestroySprite(&gSprites[eventObject->fieldEffectSpriteId]);
@ -3585,7 +3586,7 @@ void sub_80B9978(struct Task *task)
sprite->pos2.y = 0; sprite->pos2.y = 0;
sprite->coordOffsetEnabled = 1; sprite->coordOffsetEnabled = 1;
sub_808C114(); sub_808C114();
EventObjectSetHeldMovement(eventObject, 0x39); EventObjectSetHeldMovement(eventObject, MOVEMENT_ACTION_START_ANIM_IN_DIRECTION);
task->data[0]++; task->data[0]++;
} }
} }
@ -3791,8 +3792,8 @@ const struct SpriteTemplate gUnknown_0855C5EC = {
void sub_80B9D24(struct Sprite* sprite) void sub_80B9D24(struct Sprite* sprite)
{ {
int i; int i;
int xPos = (s16)gUnknown_03005DEC + sprite->pos1.x + sprite->pos2.x; int xPos = (s16)gTotalCameraPixelOffsetX + sprite->pos1.x + sprite->pos2.x;
int yPos = (s16)gUnknown_03005DE8 + sprite->pos1.y + sprite->pos2.y - 4; int yPos = (s16)gTotalCameraPixelOffsetY + sprite->pos1.y + sprite->pos2.y - 4;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {

View File

@ -14,22 +14,22 @@
#define EVENT_OBJ_PAL_TAG_NONE 0x11FF // duplicate of define in event_object_movement.c #define EVENT_OBJ_PAL_TAG_NONE 0x11FF // duplicate of define in event_object_movement.c
void UpdateObjectReflectionSprite(struct Sprite *); static void UpdateObjectReflectionSprite(struct Sprite *);
void LoadObjectReflectionPalette(struct EventObject *eventObject, struct Sprite *sprite); static void LoadObjectReflectionPalette(struct EventObject *eventObject, struct Sprite *sprite);
void LoadObjectHighBridgeReflectionPalette(struct EventObject *, u8); static void LoadObjectHighBridgeReflectionPalette(struct EventObject *, u8);
void LoadObjectRegularReflectionPalette(struct EventObject *, u8); static void LoadObjectRegularReflectionPalette(struct EventObject *, u8);
void sub_81561FC(struct Sprite *, u8, u8); static void sub_81561FC(struct Sprite *, u8, u8);
void FadeFootprintsTireTracks_Step0(struct Sprite *); static void FadeFootprintsTireTracks_Step0(struct Sprite *);
void FadeFootprintsTireTracks_Step1(struct Sprite *); static void FadeFootprintsTireTracks_Step1(struct Sprite *);
void UpdateFeetInFlowingWaterFieldEffect(struct Sprite *); static void UpdateFeetInFlowingWaterFieldEffect(struct Sprite *);
void UpdateAshFieldEffect_Step0(struct Sprite *); static void UpdateAshFieldEffect_Step0(struct Sprite *);
void UpdateAshFieldEffect_Step1(struct Sprite *); static void UpdateAshFieldEffect_Step1(struct Sprite *);
void UpdateAshFieldEffect_Step2(struct Sprite *); static void UpdateAshFieldEffect_Step2(struct Sprite *);
void sub_81556B0(struct EventObject *, struct Sprite *); static void SynchroniseSurfAnim(struct EventObject *, struct Sprite *);
void sub_81556E8(struct EventObject *, struct Sprite *); static void sub_81556E8(struct EventObject *, struct Sprite *);
void sub_815577C(struct EventObject *, struct Sprite *, struct Sprite *); static void CreateBobbingEffect(struct EventObject *, struct Sprite *, struct Sprite *);
void sub_8155850(struct Sprite *); static void sub_8155850(struct Sprite *);
u32 ShowDisguiseFieldEffect(u8, u8, u8); static u32 ShowDisguiseFieldEffect(u8, u8, u8);
void SetUpReflection(struct EventObject *eventObject, struct Sprite *sprite, bool8 stillReflection) void SetUpReflection(struct EventObject *eventObject, struct Sprite *sprite, bool8 stillReflection)
{ {
@ -59,12 +59,12 @@ static s16 GetReflectionVerticalOffset(struct EventObject *eventObject)
return GetEventObjectGraphicsInfo(eventObject->graphicsId)->height - 2; return GetEventObjectGraphicsInfo(eventObject->graphicsId)->height - 2;
} }
void LoadObjectReflectionPalette(struct EventObject *eventObject, struct Sprite *sprite) static void LoadObjectReflectionPalette(struct EventObject *eventObject, struct Sprite *sprite)
{ {
u8 bridgeType; u8 bridgeType;
u16 bridgeReflectionVerticalOffsets[] = { 12, 28, 44 }; u16 bridgeReflectionVerticalOffsets[] = { 12, 28, 44 };
sprite->data[2] = 0; sprite->data[2] = 0;
if (!GetEventObjectGraphicsInfo(eventObject->graphicsId)->disableReflectionPaletteLoad && ((bridgeType = MetatileBehavior_GetBridgeSth(eventObject->previousMetatileBehavior)) || (bridgeType = MetatileBehavior_GetBridgeSth(eventObject->currentMetatileBehavior)))) if (!GetEventObjectGraphicsInfo(eventObject->graphicsId)->disableReflectionPaletteLoad && ((bridgeType = MetatileBehavior_GetBridgeType(eventObject->previousMetatileBehavior)) || (bridgeType = MetatileBehavior_GetBridgeType(eventObject->currentMetatileBehavior))))
{ {
sprite->data[2] = bridgeReflectionVerticalOffsets[bridgeType - 1]; sprite->data[2] = bridgeReflectionVerticalOffsets[bridgeType - 1];
LoadObjectHighBridgeReflectionPalette(eventObject, sprite->oam.paletteNum); LoadObjectHighBridgeReflectionPalette(eventObject, sprite->oam.paletteNum);
@ -75,7 +75,7 @@ void LoadObjectReflectionPalette(struct EventObject *eventObject, struct Sprite
} }
} }
void LoadObjectRegularReflectionPalette(struct EventObject *eventObject, u8 paletteIndex) static void LoadObjectRegularReflectionPalette(struct EventObject *eventObject, u8 paletteIndex)
{ {
const struct EventObjectGraphicsInfo *graphicsInfo; const struct EventObjectGraphicsInfo *graphicsInfo;
@ -100,7 +100,7 @@ void LoadObjectRegularReflectionPalette(struct EventObject *eventObject, u8 pale
// When walking on a bridge high above water (Route 120), the reflection is a solid dark blue color. // When walking on a bridge high above water (Route 120), the reflection is a solid dark blue color.
// This is so the sprite blends in with the dark water metatile underneath the bridge. // This is so the sprite blends in with the dark water metatile underneath the bridge.
void LoadObjectHighBridgeReflectionPalette(struct EventObject *eventObject, u8 paletteNum) static void LoadObjectHighBridgeReflectionPalette(struct EventObject *eventObject, u8 paletteNum)
{ {
const struct EventObjectGraphicsInfo *graphicsInfo; const struct EventObjectGraphicsInfo *graphicsInfo;
@ -112,7 +112,7 @@ void LoadObjectHighBridgeReflectionPalette(struct EventObject *eventObject, u8 p
} }
} }
void UpdateObjectReflectionSprite(struct Sprite *reflectionSprite) static void UpdateObjectReflectionSprite(struct Sprite *reflectionSprite)
{ {
struct EventObject *eventObject; struct EventObject *eventObject;
struct Sprite *mainSprite; struct Sprite *mainSprite;
@ -579,7 +579,7 @@ void UpdateFootprintsTireTracksFieldEffect(struct Sprite *sprite)
gFadeFootprintsTireTracksFuncs[sprite->data[0]](sprite); gFadeFootprintsTireTracksFuncs[sprite->data[0]](sprite);
} }
void FadeFootprintsTireTracks_Step0(struct Sprite *sprite) static void FadeFootprintsTireTracks_Step0(struct Sprite *sprite)
{ {
// Wait 40 frames before the flickering starts. // Wait 40 frames before the flickering starts.
if (++sprite->data[1] > 40) if (++sprite->data[1] > 40)
@ -588,7 +588,7 @@ void FadeFootprintsTireTracks_Step0(struct Sprite *sprite)
UpdateEventObjectSpriteVisibility(sprite, FALSE); UpdateEventObjectSpriteVisibility(sprite, FALSE);
} }
void FadeFootprintsTireTracks_Step1(struct Sprite *sprite) static void FadeFootprintsTireTracks_Step1(struct Sprite *sprite)
{ {
sprite->invisible ^= 1; sprite->invisible ^= 1;
sprite->data[1]++; sprite->data[1]++;
@ -708,7 +708,7 @@ u32 FldEff_FeetInFlowingWater(void)
return 0; return 0;
} }
void UpdateFeetInFlowingWaterFieldEffect(struct Sprite *sprite) static void UpdateFeetInFlowingWaterFieldEffect(struct Sprite *sprite)
{ {
u8 eventObjectId; u8 eventObjectId;
struct Sprite *linkedSprite; struct Sprite *linkedSprite;
@ -913,7 +913,7 @@ void UpdateAshFieldEffect(struct Sprite *sprite)
gAshFieldEffectFuncs[sprite->data[0]](sprite); gAshFieldEffectFuncs[sprite->data[0]](sprite);
} }
void UpdateAshFieldEffect_Step0(struct Sprite *sprite) static void UpdateAshFieldEffect_Step0(struct Sprite *sprite)
{ {
sprite->invisible = TRUE; sprite->invisible = TRUE;
sprite->animPaused = TRUE; sprite->animPaused = TRUE;
@ -921,7 +921,7 @@ void UpdateAshFieldEffect_Step0(struct Sprite *sprite)
sprite->data[0] = 1; sprite->data[0] = 1;
} }
void UpdateAshFieldEffect_Step1(struct Sprite *sprite) static void UpdateAshFieldEffect_Step1(struct Sprite *sprite)
{ {
sprite->invisible = FALSE; sprite->invisible = FALSE;
sprite->animPaused = FALSE; sprite->animPaused = FALSE;
@ -931,7 +931,7 @@ void UpdateAshFieldEffect_Step1(struct Sprite *sprite)
sprite->data[0] = 2; sprite->data[0] = 2;
} }
void UpdateAshFieldEffect_Step2(struct Sprite *sprite) static void UpdateAshFieldEffect_Step2(struct Sprite *sprite)
{ {
UpdateEventObjectSpriteVisibility(sprite, FALSE); UpdateEventObjectSpriteVisibility(sprite, FALSE);
if (sprite->animEnded) if (sprite->animEnded)
@ -975,17 +975,17 @@ void sub_8155604(u8 spriteId, u8 value, s16 data1)
gSprites[spriteId].data[1] = data1; gSprites[spriteId].data[1] = data1;
} }
u8 sub_8155638(struct Sprite *sprite) static u8 sub_8155638(struct Sprite *sprite)
{ {
return sprite->data[0] & 0xF; return sprite->data[0] & 0xF;
} }
u8 sub_8155640(struct Sprite *sprite) static u8 sub_8155640(struct Sprite *sprite)
{ {
return (sprite->data[0] & 0xF0) >> 4; return (sprite->data[0] & 0xF0) >> 4;
} }
u8 sub_815564C(struct Sprite *sprite) static u8 sub_815564C(struct Sprite *sprite)
{ {
return (sprite->data[0] & 0xF00) >> 8; return (sprite->data[0] & 0xF00) >> 8;
} }
@ -997,13 +997,13 @@ void UpdateSurfBlobFieldEffect(struct Sprite *sprite)
eventObject = &gEventObjects[sprite->data[2]]; eventObject = &gEventObjects[sprite->data[2]];
linkedSprite = &gSprites[eventObject->spriteId]; linkedSprite = &gSprites[eventObject->spriteId];
sub_81556B0(eventObject, sprite); SynchroniseSurfAnim(eventObject, sprite);
sub_81556E8(eventObject, sprite); sub_81556E8(eventObject, sprite);
sub_815577C(eventObject, linkedSprite, sprite); CreateBobbingEffect(eventObject, linkedSprite, sprite);
sprite->oam.priority = linkedSprite->oam.priority; sprite->oam.priority = linkedSprite->oam.priority;
} }
void sub_81556B0(struct EventObject *eventObject, struct Sprite *sprite) static void SynchroniseSurfAnim(struct EventObject *eventObject, struct Sprite *sprite)
{ {
u8 surfBlobDirectionAnims[] = { u8 surfBlobDirectionAnims[] = {
0, // DIR_NONE 0, // DIR_NONE
@ -1126,7 +1126,7 @@ _08155770:\n\
} }
#endif #endif
void sub_815577C(struct EventObject *eventObject, struct Sprite *linkedSprite, struct Sprite *sprite) static void CreateBobbingEffect(struct EventObject *eventObject, struct Sprite *linkedSprite, struct Sprite *sprite)
{ {
u16 unk_085CDC6A[] = {3, 7}; u16 unk_085CDC6A[] = {3, 7};
u8 v0 = sub_8155638(sprite); u8 v0 = sub_8155638(sprite);
@ -1166,7 +1166,7 @@ u8 sub_8155800(u8 oldSpriteId)
return spriteId; return spriteId;
} }
void sub_8155850(struct Sprite *sprite) static void sub_8155850(struct Sprite *sprite)
{ {
struct Sprite *oldSprite; struct Sprite *oldSprite;
@ -1320,7 +1320,7 @@ u32 ShowSandDisguiseFieldEffect(void)
return ShowDisguiseFieldEffect(FLDEFF_SAND_DISGUISE, 28, 2); return ShowDisguiseFieldEffect(FLDEFF_SAND_DISGUISE, 28, 2);
} }
u32 ShowDisguiseFieldEffect(u8 fldEff, u8 templateIdx, u8 paletteNum) static u32 ShowDisguiseFieldEffect(u8 fldEff, u8 templateIdx, u8 paletteNum)
{ {
u8 spriteId; u8 spriteId;
struct Sprite *sprite; struct Sprite *sprite;
@ -1619,7 +1619,7 @@ void sub_8156194(struct Sprite *sprite)
} }
} }
void sub_81561D0(struct Sprite *sprite) void WaitFieldEffectSpriteAnim(struct Sprite *sprite)
{ {
if (sprite->animEnded) if (sprite->animEnded)
FieldEffectStop(sprite, sprite->data[0]); FieldEffectStop(sprite, sprite->data[0]);
@ -1628,7 +1628,7 @@ void sub_81561D0(struct Sprite *sprite)
} }
#ifdef NONMATCHING #ifdef NONMATCHING
void sub_81561FC(struct Sprite *sprite /*r6*/, u8 z, u8 offset) static void sub_81561FC(struct Sprite *sprite /*r6*/, u8 z, u8 offset)
{ {
u8 i; u8 i;
s16 xlo; s16 xlo;

View File

@ -32,7 +32,7 @@
#include "constants/species.h" #include "constants/species.h"
static EWRAM_DATA u8 gUnknown_0203734C = 0; static EWRAM_DATA u8 gUnknown_0203734C = 0;
EWRAM_DATA struct EventObject gEventObjects[NUM_EVENT_OBJECTS] = {}; EWRAM_DATA struct EventObject gEventObjects[EVENT_OBJECTS_COUNT] = {};
EWRAM_DATA struct PlayerAvatar gPlayerAvatar = {}; EWRAM_DATA struct PlayerAvatar gPlayerAvatar = {};
static void StartStrengthAnim(u8, u8); static void StartStrengthAnim(u8, u8);
@ -123,7 +123,7 @@ static u8 Fishing14(struct Task *task);
static u8 Fishing15(struct Task *task); static u8 Fishing15(struct Task *task);
static u8 Fishing16(struct Task *task); static u8 Fishing16(struct Task *task);
static bool8 (*const gUnknown_084973FC[])(u8) = static bool8 (*const sForcedMovementTestFuncs[])(u8) =
{ {
MetatileBehavior_IsTrickHouseSlipperyFloor, MetatileBehavior_IsTrickHouseSlipperyFloor,
MetatileBehavior_IsIce_2, MetatileBehavior_IsIce_2,
@ -145,7 +145,7 @@ static bool8 (*const gUnknown_084973FC[])(u8) =
MetatileBehavior_IsMuddySlope, MetatileBehavior_IsMuddySlope,
}; };
static bool8 (*const gUnknown_08497444[])(void) = static bool8 (*const sForcedMovementFuncs[])(void) =
{ {
ForcedMovement_None, ForcedMovement_None,
ForcedMovement_Slip, ForcedMovement_Slip,
@ -285,12 +285,12 @@ static bool8 (*const sPlayerAvatarSecretBaseMatSpin[])(struct Task *, struct Eve
// .text // .text
void MovementType_Player(struct Sprite *sprite) void MovementType_Player(struct Sprite *sprite)
{ {
UpdateEventObjectCurrentMovement(&gEventObjects[sprite->data[0]], sprite, EventObjectCB2_NoMovement2); UpdateEventObjectCurrentMovement(&gEventObjects[sprite->data[0]], sprite, EventObjectCB2_NoMovement2);
} }
static u8 EventObjectCB2_NoMovement2(void) static u8 EventObjectCB2_NoMovement2(void)
{ {
return 0; return 0;
} }
void player_step(u8 direction, u16 newKeys, u16 heldKeys) void player_step(u8 direction, u16 newKeys, u16 heldKeys)
@ -380,7 +380,7 @@ static void PlayerAllowForcedMovementIfMovingSameDirection(void)
static bool8 TryDoMetatileBehaviorForcedMovement(void) static bool8 TryDoMetatileBehaviorForcedMovement(void)
{ {
return gUnknown_08497444[GetForcedMovementByMetatileBehavior()](); return sForcedMovementFuncs[GetForcedMovementByMetatileBehavior()]();
} }
static u8 GetForcedMovementByMetatileBehavior(void) static u8 GetForcedMovementByMetatileBehavior(void)
@ -393,7 +393,7 @@ static u8 GetForcedMovementByMetatileBehavior(void)
for (i = 0; i < 18; i++) for (i = 0; i < 18; i++)
{ {
if (gUnknown_084973FC[i](metatileBehavior)) if (sForcedMovementTestFuncs[i](metatileBehavior))
return i + 1; return i + 1;
} }
} }
@ -622,7 +622,7 @@ static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys)
if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING)
{ {
// speed 2 is fast, same speed as running // speed 2 is fast, same speed as running
PlayerGoSpeed2(direction); PlayerGoSpeed2(direction);
return; return;
} }
@ -1700,7 +1700,7 @@ static bool8 (*const sFishingStateFuncs[])(struct Task *) =
}; };
static void Task_Fishing(u8 taskId); static void Task_Fishing(u8 taskId);
static void sub_808CF78(void); static void AlignFishingAnimationFrames(void);
#define tStep data[0] #define tStep data[0]
#define tFrameCounter data[1] #define tFrameCounter data[1]
@ -1759,7 +1759,7 @@ static bool8 Fishing2(struct Task *task)
static bool8 Fishing3(struct Task *task) static bool8 Fishing3(struct Task *task)
{ {
sub_808CF78(); AlignFishingAnimationFrames();
// Wait one second // Wait one second
task->tFrameCounter++; task->tFrameCounter++;
@ -1791,7 +1791,7 @@ static bool8 Fishing5(struct Task *task)
{ {
const u8 dot[] = _("·"); const u8 dot[] = _("·");
sub_808CF78(); AlignFishingAnimationFrames();
task->tFrameCounter++; task->tFrameCounter++;
if (gMain.newKeys & A_BUTTON) if (gMain.newKeys & A_BUTTON)
{ {
@ -1827,7 +1827,7 @@ static bool8 Fishing6(struct Task *task)
{ {
bool8 bite; bool8 bite;
sub_808CF78(); AlignFishingAnimationFrames();
task->tStep++; task->tStep++;
bite = FALSE; bite = FALSE;
@ -1872,7 +1872,7 @@ static bool8 Fishing6(struct Task *task)
// Oh! A Bite! // Oh! A Bite!
static bool8 Fishing7(struct Task *task) static bool8 Fishing7(struct Task *task)
{ {
sub_808CF78(); AlignFishingAnimationFrames();
AddTextPrinterParameterized(0, 1, gText_OhABite, 0, 17, 0, NULL); AddTextPrinterParameterized(0, 1, gText_OhABite, 0, 17, 0, NULL);
task->tStep++; task->tStep++;
task->tFrameCounter = 0; task->tFrameCounter = 0;
@ -1884,7 +1884,7 @@ static bool8 Fishing8(struct Task *task)
{ {
const s16 reelTimeouts[3] = {36, 33, 30}; const s16 reelTimeouts[3] = {36, 33, 30};
sub_808CF78(); AlignFishingAnimationFrames();
task->tFrameCounter++; task->tFrameCounter++;
if (task->tFrameCounter >= reelTimeouts[task->tFishingRod]) if (task->tFrameCounter >= reelTimeouts[task->tFishingRod])
task->tStep = FISHING_GOT_AWAY; task->tStep = FISHING_GOT_AWAY;
@ -1903,7 +1903,7 @@ static bool8 Fishing9(struct Task *task)
{70, 30} {70, 30}
}; };
sub_808CF78(); AlignFishingAnimationFrames();
task->tStep++; task->tStep++;
if (task->tRoundsPlayed < task->tMinRoundsRequired) if (task->tRoundsPlayed < task->tMinRoundsRequired)
{ {
@ -1922,7 +1922,7 @@ static bool8 Fishing9(struct Task *task)
static bool8 Fishing10(struct Task *task) static bool8 Fishing10(struct Task *task)
{ {
sub_808CF78(); AlignFishingAnimationFrames();
FillWindowPixelBuffer(0, 0x11); FillWindowPixelBuffer(0, 0x11);
AddTextPrinterParameterized2(0, 1, gText_PokemonOnHook, 1, 0, 2, 1, 3); AddTextPrinterParameterized2(0, 1, gText_PokemonOnHook, 1, 0, 2, 1, 3);
task->tStep++; task->tStep++;
@ -1933,7 +1933,7 @@ static bool8 Fishing10(struct Task *task)
static bool8 Fishing11(struct Task *task) static bool8 Fishing11(struct Task *task)
{ {
if (task->tFrameCounter == 0) if (task->tFrameCounter == 0)
sub_808CF78(); AlignFishingAnimationFrames();
RunTextPrinters(); RunTextPrinters();
@ -1969,7 +1969,7 @@ static bool8 Fishing11(struct Task *task)
// Not even a nibble // Not even a nibble
static bool8 Fishing12(struct Task *task) static bool8 Fishing12(struct Task *task)
{ {
sub_808CF78(); AlignFishingAnimationFrames();
StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingNoCatchDirectionAnimNum(GetPlayerFacingDirection())); StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingNoCatchDirectionAnimNum(GetPlayerFacingDirection()));
FillWindowPixelBuffer(0, 0x11); FillWindowPixelBuffer(0, 0x11);
AddTextPrinterParameterized2(0, 1, gText_NotEvenANibble, 1, 0, 2, 1, 3); AddTextPrinterParameterized2(0, 1, gText_NotEvenANibble, 1, 0, 2, 1, 3);
@ -1980,7 +1980,7 @@ static bool8 Fishing12(struct Task *task)
// It got away // It got away
static bool8 Fishing13(struct Task *task) static bool8 Fishing13(struct Task *task)
{ {
sub_808CF78(); AlignFishingAnimationFrames();
StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingNoCatchDirectionAnimNum(GetPlayerFacingDirection())); StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingNoCatchDirectionAnimNum(GetPlayerFacingDirection()));
FillWindowPixelBuffer(0, 0x11); FillWindowPixelBuffer(0, 0x11);
AddTextPrinterParameterized2(0, 1, gText_ItGotAway, 1, 0, 2, 1, 3); AddTextPrinterParameterized2(0, 1, gText_ItGotAway, 1, 0, 2, 1, 3);
@ -1991,14 +1991,14 @@ static bool8 Fishing13(struct Task *task)
// Wait one second // Wait one second
static bool8 Fishing14(struct Task *task) static bool8 Fishing14(struct Task *task)
{ {
sub_808CF78(); AlignFishingAnimationFrames();
task->tStep++; task->tStep++;
return FALSE; return FALSE;
} }
static bool8 Fishing15(struct Task *task) static bool8 Fishing15(struct Task *task)
{ {
sub_808CF78(); AlignFishingAnimationFrames();
if (gSprites[gPlayerAvatar.spriteId].animEnded) if (gSprites[gPlayerAvatar.spriteId].animEnded)
{ {
struct EventObject *playerEventObj = &gEventObjects[gPlayerAvatar.eventObjectId]; struct EventObject *playerEventObj = &gEventObjects[gPlayerAvatar.eventObjectId];
@ -2033,7 +2033,7 @@ static bool8 Fishing16(struct Task *task)
#undef tFrameCounter #undef tFrameCounter
#undef tFishingRod #undef tFishingRod
static void sub_808CF78(void) static void AlignFishingAnimationFrames(void)
{ {
struct Sprite *playerSprite = &gSprites[gPlayerAvatar.spriteId]; struct Sprite *playerSprite = &gSprites[gPlayerAvatar.spriteId];
u8 animCmdIndex; u8 animCmdIndex;
@ -2114,7 +2114,7 @@ static void sub_808D094(u8 taskId)
data[3] -= data[2]; data[3] -= data[2];
data[2] += 3; data[2] += 3;
sprite->pos1.y = data[3] >> 4; sprite->pos1.y = data[3] >> 4;
if (sprite->pos1.y + (s16)gUnknown_03005DE8 < -32) if (sprite->pos1.y + (s16)gTotalCameraPixelOffsetY < -32)
{ {
data[0]++; data[0]++;
} }

View File

@ -1,22 +1,22 @@
#include "global.h" #include "global.h"
#include "string_util.h"
#include "party_menu.h"
#include "constants/species.h"
#include "task.h"
#include "field_message_box.h"
#include "strings.h"
#include "rom_818CFC8.h"
#include "frontier_util.h"
#include "pokenav.h"
#include "event_data.h"
#include "script.h"
#include "battle.h" #include "battle.h"
#include "fldeff_80F9BCC.h" #include "event_data.h"
#include "field_message_box.h"
#include "field_poison.h" #include "field_poison.h"
#include "fldeff_80F9BCC.h"
#include "frontier_util.h"
#include "party_menu.h"
#include "pokenav.h"
#include "rom_818CFC8.h"
#include "script.h"
#include "string_util.h"
#include "strings.h"
#include "task.h"
#include "constants/species.h"
extern bool8 InBattlePike(void); extern bool8 InBattlePike(void);
static bool32 sub_80F9568(struct Pokemon *pokemon) static bool32 IsMonValidSpecies(struct Pokemon *pokemon)
{ {
u16 species = GetMonData(pokemon, MON_DATA_SPECIES2); u16 species = GetMonData(pokemon, MON_DATA_SPECIES2);
if (species == SPECIES_NONE || species == SPECIES_EGG) if (species == SPECIES_NONE || species == SPECIES_EGG)
@ -26,14 +26,14 @@ static bool32 sub_80F9568(struct Pokemon *pokemon)
return TRUE; return TRUE;
} }
static bool32 sub_80F958C(void) static bool32 AllMonsFainted(void)
{ {
int i; int i;
struct Pokemon *pokemon; struct Pokemon *pokemon = gPlayerParty;
for (pokemon = gPlayerParty, i = 0; i < PARTY_SIZE; i++, pokemon++) for (i = 0; i < PARTY_SIZE; i++, pokemon++)
{ {
if (sub_80F9568(pokemon) && GetMonData(pokemon, MON_DATA_HP) != 0) if (IsMonValidSpecies(pokemon) && GetMonData(pokemon, MON_DATA_HP) != 0)
{ {
return FALSE; return FALSE;
} }
@ -41,27 +41,28 @@ static bool32 sub_80F958C(void)
return TRUE; return TRUE;
} }
static void sub_80F95C0(u8 partyIdx) static void FaintFromFieldPoison(u8 partyIdx)
{ {
struct Pokemon *pokemon = gPlayerParty + partyIdx; struct Pokemon *pokemon = gPlayerParty + partyIdx;
unsigned int status = STATUS1_NONE; u32 status = STATUS1_NONE;
AdjustFriendship(pokemon, 0x07); AdjustFriendship(pokemon, 0x07);
SetMonData(pokemon, MON_DATA_STATUS, &status); SetMonData(pokemon, MON_DATA_STATUS, &status);
GetMonData(pokemon, MON_DATA_NICKNAME, gStringVar1); GetMonData(pokemon, MON_DATA_NICKNAME, gStringVar1);
StringGetEnd10(gStringVar1); StringGetEnd10(gStringVar1);
} }
static bool32 sub_80F960C(u8 partyIdx) static bool32 MonFaintedFromPoison(u8 partyIdx)
{ {
struct Pokemon *pokemon = gPlayerParty + partyIdx; struct Pokemon *pokemon = gPlayerParty + partyIdx;
if (sub_80F9568(pokemon) && GetMonData(pokemon, MON_DATA_HP) == 0 && pokemon_ailments_get_primary(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN) if (IsMonValidSpecies(pokemon) && GetMonData(pokemon, MON_DATA_HP) == 0 && pokemon_ailments_get_primary(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN)
{ {
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
static void sub_80F9654(u8 taskId) static void Task_WhiteOut(u8 taskId)
{ {
s16 *data = gTasks[taskId].data; s16 *data = gTasks[taskId].data;
switch (data[0]) switch (data[0])
@ -69,9 +70,9 @@ static void sub_80F9654(u8 taskId)
case 0: case 0:
for (; data[1] < PARTY_SIZE; data[1]++) for (; data[1] < PARTY_SIZE; data[1]++)
{ {
if (sub_80F960C(data[1])) if (MonFaintedFromPoison(data[1]))
{ {
sub_80F95C0(data[1]); FaintFromFieldPoison(data[1]);
ShowFieldMessage(gText_PkmnFainted3); ShowFieldMessage(gText_PkmnFainted3);
data[0]++; data[0]++;
return; return;
@ -86,7 +87,7 @@ static void sub_80F9654(u8 taskId)
} }
break; break;
case 2: case 2:
if (sub_80F958C()) if (AllMonsFainted())
{ {
if (InBattlePyramid() | InBattlePike() || sub_81D5C18()) if (InBattlePyramid() | InBattlePike() || sub_81D5C18())
{ {
@ -107,19 +108,19 @@ static void sub_80F9654(u8 taskId)
} }
} }
void sub_80F972C(void) void ExecuteWhiteOut(void)
{ {
CreateTask(sub_80F9654, 80); CreateTask(Task_WhiteOut, 80);
ScriptContext1_Stop(); ScriptContext1_Stop();
} }
int DoPoisonFieldEffect(void) s32 DoPoisonFieldEffect(void)
{ {
int i; int i;
unsigned int hp; u32 hp;
struct Pokemon *pokemon = gPlayerParty; struct Pokemon *pokemon = gPlayerParty;
unsigned int numPoisoned = 0; u32 numPoisoned = 0;
unsigned int numFainted = 0; u32 numFainted = 0;
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (GetMonData(pokemon, MON_DATA_SANITY_BIT2) && pokemon_ailments_get_primary(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN) if (GetMonData(pokemon, MON_DATA_SANITY_BIT2) && pokemon_ailments_get_primary(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN)
@ -136,7 +137,7 @@ int DoPoisonFieldEffect(void)
} }
if (numFainted != 0 || numPoisoned != 0) if (numFainted != 0 || numPoisoned != 0)
{ {
overworld_poison_effect(); FldeffPoison_Start();
} }
if (numFainted != 0) if (numFainted != 0)
{ {

View File

@ -595,7 +595,7 @@ static void LoadLinkPartnerEventObjectSpritePalette(u8 graphicsId, u8 localEvent
graphicsId == EVENT_OBJ_GFX_RIVAL_MAY_NORMAL) graphicsId == EVENT_OBJ_GFX_RIVAL_MAY_NORMAL)
{ {
u8 obj = GetEventObjectIdByLocalIdAndMap(localEventId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup); u8 obj = GetEventObjectIdByLocalIdAndMap(localEventId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
if (obj != NUM_EVENT_OBJECTS) if (obj != EVENT_OBJECTS_COUNT)
{ {
u8 spriteId = gEventObjects[obj].spriteId; u8 spriteId = gEventObjects[obj].spriteId;
struct Sprite *sprite = &gSprites[spriteId]; struct Sprite *sprite = &gSprites[spriteId];
@ -1513,7 +1513,7 @@ bool8 FoundBlackGlasses(void)
void SetRoute119Weather(void) void SetRoute119Weather(void)
{ {
if (is_map_type_1_2_3_5_or_6(get_map_light_from_warp0()) != TRUE) if (is_map_type_1_2_3_5_or_6(GetLastUsedWarpMapType()) != TRUE)
{ {
SetSav1Weather(20); SetSav1Weather(20);
} }
@ -1521,7 +1521,7 @@ void SetRoute119Weather(void)
void SetRoute123Weather(void) void SetRoute123Weather(void)
{ {
if (is_map_type_1_2_3_5_or_6(get_map_light_from_warp0()) != TRUE) if (is_map_type_1_2_3_5_or_6(GetLastUsedWarpMapType()) != TRUE)
{ {
SetSav1Weather(21); SetSav1Weather(21);
} }

View File

@ -156,7 +156,7 @@ void c2_change_map(void)
static bool8 sub_8137304(void) static bool8 sub_8137304(void)
{ {
u8 i; u8 i;
u8 v0 = get_map_light_from_warp0(); u8 v0 = GetLastUsedWarpMapType();
u8 v1 = Overworld_GetMapTypeOfSaveblockLocation(); u8 v1 = Overworld_GetMapTypeOfSaveblockLocation();
for (i = 0; gUnknown_085B27C8[i].unk0; i++) for (i = 0; gUnknown_085B27C8[i].unk0; i++)

View File

@ -1,6 +1,4 @@
#include "global.h" #include "global.h"
#include "constants/rgb.h"
#include "constants/songs.h"
#include "event_data.h" #include "event_data.h"
#include "event_scripts.h" #include "event_scripts.h"
#include "field_effect.h" #include "field_effect.h"
@ -14,22 +12,24 @@
#include "sprite.h" #include "sprite.h"
#include "task.h" #include "task.h"
#include "wild_encounter.h" #include "wild_encounter.h"
#include "constants/rgb.h"
#include "constants/songs.h"
void hm2_sweet_scent(void); static void FieldCallback_SweetScent(void);
void sub_8159F5C(void); static void StartSweetScentFieldEffect(void);
void sub_8159FEC(u8 taskId); static void TrySweetScentEncounter(u8 taskId);
void sub_815A090(u8 taskId); static void FailSweetScentEncounter(u8 taskId);
void sub_81BE6B8(void); void sub_81BE6B8(void);
void sub_81BE72C(void); void sub_81BE72C(void);
bool8 SetUpFieldMove_SweetScent(void) bool8 SetUpFieldMove_SweetScent(void)
{ {
gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu;
gPostMenuFieldCallback = hm2_sweet_scent; gPostMenuFieldCallback = FieldCallback_SweetScent;
return TRUE; return TRUE;
} }
void hm2_sweet_scent(void) static void FieldCallback_SweetScent(void)
{ {
FieldEffectStart(FLDEFF_SWEET_SCENT); FieldEffectStart(FLDEFF_SWEET_SCENT);
gFieldEffectArguments[0] = GetCursorSelectionMonId(); gFieldEffectArguments[0] = GetCursorSelectionMonId();
@ -41,12 +41,12 @@ bool8 FldEff_SweetScent(void)
sub_80AC3D0(); sub_80AC3D0();
taskId = oei_task_add(); taskId = oei_task_add();
gTasks[taskId].data[8] = (u32)sub_8159F5C >> 16; gTasks[taskId].data[8] = (u32)StartSweetScentFieldEffect >> 16;
gTasks[taskId].data[9] = (u32)sub_8159F5C; gTasks[taskId].data[9] = (u32)StartSweetScentFieldEffect;
return FALSE; return FALSE;
} }
void sub_8159F5C(void) static void StartSweetScentFieldEffect(void)
{ {
u8 taskId; u8 taskId;
@ -54,12 +54,12 @@ void sub_8159F5C(void)
CpuFastSet(gPlttBufferUnfaded, gPaletteDecompressionBuffer, 0x100); CpuFastSet(gPlttBufferUnfaded, gPaletteDecompressionBuffer, 0x100);
CpuFastSet(gPlttBufferFaded, gPlttBufferUnfaded, 0x100); CpuFastSet(gPlttBufferFaded, gPlttBufferUnfaded, 0x100);
BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 0, 8, RGB_RED); BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 0, 8, RGB_RED);
taskId = CreateTask(sub_8159FEC, 0); taskId = CreateTask(TrySweetScentEncounter, 0);
gTasks[taskId].data[0] = 0; gTasks[taskId].data[0] = 0;
FieldEffectActiveListRemove(FLDEFF_SWEET_SCENT); FieldEffectActiveListRemove(FLDEFF_SWEET_SCENT);
} }
void sub_8159FEC(u8 taskId) static void TrySweetScentEncounter(u8 taskId)
{ {
if (!gPaletteFade.active) if (!gPaletteFade.active)
{ {
@ -74,7 +74,7 @@ void sub_8159FEC(u8 taskId)
} }
else else
{ {
gTasks[taskId].func = sub_815A090; gTasks[taskId].func = FailSweetScentEncounter;
BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 8, 0, RGB_RED); BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 8, 0, RGB_RED);
sub_81BE6B8(); sub_81BE6B8();
} }
@ -86,7 +86,7 @@ void sub_8159FEC(u8 taskId)
} }
} }
void sub_815A090(u8 taskId) static void FailSweetScentEncounter(u8 taskId)
{ {
if (!gPaletteFade.active) if (!gPaletteFade.active)
{ {

View File

@ -1,5 +1,4 @@
#include "global.h" #include "global.h"
#include "fldeff_teleport.h"
#include "field_effect.h" #include "field_effect.h"
#include "field_player_avatar.h" #include "field_player_avatar.h"
#include "party_menu.h" #include "party_menu.h"
@ -7,18 +6,21 @@
#include "rom6.h" #include "rom6.h"
#include "task.h" #include "task.h"
static void FieldCallback_Teleport(void);
static void StartTeleportFieldEffect(void);
bool8 SetUpFieldMove_Teleport(void) bool8 SetUpFieldMove_Teleport(void)
{ {
if (Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE) if (Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE)
{ {
gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu;
gPostMenuFieldCallback = hm_teleport_run_dp02scr; gPostMenuFieldCallback = FieldCallback_Teleport;
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
void hm_teleport_run_dp02scr(void) static void FieldCallback_Teleport(void)
{ {
Overworld_ResetStateAfterTeleport(); Overworld_ResetStateAfterTeleport();
FieldEffectStart(FLDEFF_USE_TELEPORT); FieldEffectStart(FLDEFF_USE_TELEPORT);
@ -28,16 +30,14 @@ void hm_teleport_run_dp02scr(void)
bool8 FldEff_UseTeleport(void) bool8 FldEff_UseTeleport(void)
{ {
u8 taskId = oei_task_add(); u8 taskId = oei_task_add();
gTasks[taskId].data[8] = (u32)sub_817C94C >> 16; gTasks[taskId].data[8] = (u32)StartTeleportFieldEffect >> 16;
gTasks[taskId].data[9] = (u32)sub_817C94C; gTasks[taskId].data[9] = (u32)StartTeleportFieldEffect;
SetPlayerAvatarTransitionFlags(1); SetPlayerAvatarTransitionFlags(PLAYER_AVATAR_FLAG_ON_FOOT);
return FALSE; return FALSE;
} }
void sub_817C94C(void) static void StartTeleportFieldEffect(void)
{ {
FieldEffectActiveListRemove(FLDEFF_USE_TELEPORT); FieldEffectActiveListRemove(FLDEFF_USE_TELEPORT);
CreateTeleportFieldEffectTask(); CreateTeleportFieldEffectTask();
} }

View File

@ -7,8 +7,6 @@
#include "script_menu.h" #include "script_menu.h"
#include "task.h" #include "task.h"
extern void (*gUnknown_0300485C)(void);
extern void Overworld_PlaySpecialMapMusic(void); extern void Overworld_PlaySpecialMapMusic(void);
extern bool16 ScrSpecial_CreatePCMenu(void); extern bool16 ScrSpecial_CreatePCMenu(void);
extern void ScriptMenu_DisplayPCStartupPrompt(void); extern void ScriptMenu_DisplayPCStartupPrompt(void);

View File

@ -58,7 +58,7 @@ extern void sub_81C5924(void);
extern void sub_81C59BC(void); extern void sub_81C59BC(void);
extern void sub_81AB9A8(u8); extern void sub_81AB9A8(u8);
extern void sub_81ABA88(u8); extern void sub_81ABA88(u8);
extern void sub_80B7CC8(void); extern void StartEscapeRopeFieldEffect(void);
extern u8* sub_806CF78(u16); extern u8* sub_806CF78(u16);
extern void sub_81B89F0(void); extern void sub_81B89F0(void);
extern u8 GetItemEffectType(u16); extern u8 GetItemEffectType(u16);
@ -890,7 +890,7 @@ void ItemUseOutOfBattle_BlackWhiteFlute(u8 taskId)
void task08_080A1C44(u8 taskId) void task08_080A1C44(u8 taskId)
{ {
ResetInitialPlayerAvatarState(); ResetInitialPlayerAvatarState();
sub_80B7CC8(); StartEscapeRopeFieldEffect();
DestroyTask(taskId); DestroyTask(taskId);
} }

View File

@ -897,7 +897,7 @@ bool8 MetatileBehavior_IsBridge(u8 metatileBehavior)
return FALSE; return FALSE;
} }
u8 MetatileBehavior_GetBridgeSth(u8 metatileBehavior) u8 MetatileBehavior_GetBridgeType(u8 metatileBehavior)
{ {
u8 result = metatileBehavior - MB_WARP_OR_BRIDGE; u8 result = metatileBehavior - MB_WARP_OR_BRIDGE;
if (result < 4) if (result < 4)

View File

@ -585,7 +585,7 @@ void set_warp2_warp3_to_neg_1(void)
gFixedHoleWarp = sDummyWarpData; gFixedHoleWarp = sDummyWarpData;
} }
void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) static void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
{ {
warp->mapGroup = mapGroup; warp->mapGroup = mapGroup;
warp->mapNum = mapNum; warp->mapNum = mapNum;
@ -594,7 +594,7 @@ void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x,
warp->y = y; warp->y = y;
} }
bool32 IsDummyWarp(struct WarpData *warp) static bool32 IsDummyWarp(struct WarpData *warp)
{ {
if (warp->mapGroup != -1) if (warp->mapGroup != -1)
return FALSE; return FALSE;
@ -620,7 +620,7 @@ struct MapHeader const *const GetDestinationWarpMapHeader(void)
return Overworld_GetMapHeaderByGroupAndId(sWarpDestination.mapGroup, sWarpDestination.mapNum); return Overworld_GetMapHeaderByGroupAndId(sWarpDestination.mapGroup, sWarpDestination.mapNum);
} }
void LoadCurrentMapData(void) static void LoadCurrentMapData(void)
{ {
sLastMapSectionId = gMapHeader.regionMapSectionId; sLastMapSectionId = gMapHeader.regionMapSectionId;
gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum); gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum);
@ -628,13 +628,13 @@ void LoadCurrentMapData(void)
gMapHeader.mapLayout = GetMapLayout(); gMapHeader.mapLayout = GetMapLayout();
} }
void LoadSaveblockMapHeader(void) static void LoadSaveblockMapHeader(void)
{ {
gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum); gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum);
gMapHeader.mapLayout = GetMapLayout(); gMapHeader.mapLayout = GetMapLayout();
} }
void SetPlayerCoordsFromWarp(void) static void SetPlayerCoordsFromWarp(void)
{ {
if (gSaveBlock1Ptr->location.warpId >= 0 && gSaveBlock1Ptr->location.warpId < gMapHeader.events->warpCount) if (gSaveBlock1Ptr->location.warpId >= 0 && gSaveBlock1Ptr->location.warpId < gMapHeader.events->warpCount)
{ {
@ -729,7 +729,7 @@ void SetFixedDiveWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
SetWarpData(&gFixedDiveWarp, mapGroup, mapNum, warpId, x, y); SetWarpData(&gFixedDiveWarp, mapGroup, mapNum, warpId, x, y);
} }
void SetFixedDiveWarpAsDestination(void) static void SetFixedDiveWarpAsDestination(void)
{ {
sWarpDestination = gFixedDiveWarp; sWarpDestination = gFixedDiveWarp;
} }
@ -785,7 +785,7 @@ const struct MapConnection *GetMapConnection(u8 dir)
return NULL; return NULL;
} }
bool8 SetDiveWarp(u8 dir, u16 x, u16 y) static bool8 SetDiveWarp(u8 dir, u16 x, u16 y)
{ {
const struct MapConnection *connection = GetMapConnection(dir); const struct MapConnection *connection = GetMapConnection(dir);
@ -905,8 +905,8 @@ static void mli0_load_map(u32 a1)
void ResetInitialPlayerAvatarState(void) void ResetInitialPlayerAvatarState(void)
{ {
gInitialPlayerAvatarState.direction = 1; gInitialPlayerAvatarState.direction = DIR_SOUTH;
gInitialPlayerAvatarState.transitionFlags = 1; gInitialPlayerAvatarState.transitionFlags = PLAYER_AVATAR_FLAG_ON_FOOT;
} }
void StoreInitialPlayerAvatarState(void) void StoreInitialPlayerAvatarState(void)
@ -914,15 +914,15 @@ void StoreInitialPlayerAvatarState(void)
gInitialPlayerAvatarState.direction = GetPlayerFacingDirection(); gInitialPlayerAvatarState.direction = GetPlayerFacingDirection();
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE)) if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE))
gInitialPlayerAvatarState.transitionFlags = 2; gInitialPlayerAvatarState.transitionFlags = PLAYER_AVATAR_FLAG_MACH_BIKE;
else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_ACRO_BIKE)) else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_ACRO_BIKE))
gInitialPlayerAvatarState.transitionFlags = 4; gInitialPlayerAvatarState.transitionFlags = PLAYER_AVATAR_FLAG_ACRO_BIKE;
else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING))
gInitialPlayerAvatarState.transitionFlags = 8; gInitialPlayerAvatarState.transitionFlags = PLAYER_AVATAR_FLAG_SURFING;
else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_UNDERWATER)) else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_UNDERWATER))
gInitialPlayerAvatarState.transitionFlags = 16; gInitialPlayerAvatarState.transitionFlags = PLAYER_AVATAR_FLAG_UNDERWATER;
else else
gInitialPlayerAvatarState.transitionFlags = 1; gInitialPlayerAvatarState.transitionFlags = PLAYER_AVATAR_FLAG_ON_FOOT;
} }
static struct InitialPlayerAvatarState *GetInitialPlayerAvatarState(void) static struct InitialPlayerAvatarState *GetInitialPlayerAvatarState(void)
@ -940,44 +940,44 @@ static struct InitialPlayerAvatarState *GetInitialPlayerAvatarState(void)
static u8 GetAdjustedInitialTransitionFlags(struct InitialPlayerAvatarState *playerStruct, u16 metatileBehavior, u8 mapType) static u8 GetAdjustedInitialTransitionFlags(struct InitialPlayerAvatarState *playerStruct, u16 metatileBehavior, u8 mapType)
{ {
if (mapType != MAP_TYPE_INDOOR && FlagGet(FLAG_SYS_CRUISE_MODE)) if (mapType != MAP_TYPE_INDOOR && FlagGet(FLAG_SYS_CRUISE_MODE))
return 1; return PLAYER_AVATAR_FLAG_ON_FOOT;
else if (mapType == MAP_TYPE_UNDERWATER) else if (mapType == MAP_TYPE_UNDERWATER)
return 16; return PLAYER_AVATAR_FLAG_UNDERWATER;
else if (MetatileBehavior_IsSurfableWaterOrUnderwater(metatileBehavior) == TRUE) else if (MetatileBehavior_IsSurfableWaterOrUnderwater(metatileBehavior) == TRUE)
return 8; return PLAYER_AVATAR_FLAG_SURFING;
else if (Overworld_IsBikingAllowed() != TRUE) else if (Overworld_IsBikingAllowed() != TRUE)
return 1; return PLAYER_AVATAR_FLAG_ON_FOOT;
else if (playerStruct->transitionFlags == 2) else if (playerStruct->transitionFlags == PLAYER_AVATAR_FLAG_MACH_BIKE)
return 2; return PLAYER_AVATAR_FLAG_MACH_BIKE;
else if (playerStruct->transitionFlags != 4) else if (playerStruct->transitionFlags != PLAYER_AVATAR_FLAG_ACRO_BIKE)
return 1; return PLAYER_AVATAR_FLAG_ON_FOOT;
else else
return 4; return PLAYER_AVATAR_FLAG_ACRO_BIKE;
} }
static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStruct, u8 transitionFlags, u16 metatileBehavior, u8 mapType) static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStruct, u8 transitionFlags, u16 metatileBehavior, u8 mapType)
{ {
if (FlagGet(FLAG_SYS_CRUISE_MODE) && mapType == MAP_TYPE_6) if (FlagGet(FLAG_SYS_CRUISE_MODE) && mapType == MAP_TYPE_6)
return 4; return DIR_EAST;
else if (MetatileBehavior_IsDeepSouthWarp(metatileBehavior) == TRUE) else if (MetatileBehavior_IsDeepSouthWarp(metatileBehavior) == TRUE)
return 2; return DIR_NORTH;
else if (MetatileBehavior_IsNonAnimDoor(metatileBehavior) == TRUE || MetatileBehavior_IsDoor(metatileBehavior) == TRUE) else if (MetatileBehavior_IsNonAnimDoor(metatileBehavior) == TRUE || MetatileBehavior_IsDoor(metatileBehavior) == TRUE)
return 1; return DIR_SOUTH;
else if (MetatileBehavior_IsSouthArrowWarp(metatileBehavior) == TRUE) else if (MetatileBehavior_IsSouthArrowWarp(metatileBehavior) == TRUE)
return 2; return DIR_NORTH;
else if (MetatileBehavior_IsNorthArrowWarp(metatileBehavior) == TRUE) else if (MetatileBehavior_IsNorthArrowWarp(metatileBehavior) == TRUE)
return 1; return DIR_SOUTH;
else if (MetatileBehavior_IsWestArrowWarp(metatileBehavior) == TRUE) else if (MetatileBehavior_IsWestArrowWarp(metatileBehavior) == TRUE)
return 4; return DIR_EAST;
else if (MetatileBehavior_IsEastArrowWarp(metatileBehavior) == TRUE) else if (MetatileBehavior_IsEastArrowWarp(metatileBehavior) == TRUE)
return 3; return DIR_WEST;
else if ((playerStruct->transitionFlags == 16 && transitionFlags == 8) else if ((playerStruct->transitionFlags == PLAYER_AVATAR_FLAG_UNDERWATER && transitionFlags == PLAYER_AVATAR_FLAG_SURFING)
|| (playerStruct->transitionFlags == 8 && transitionFlags == 16)) || (playerStruct->transitionFlags == PLAYER_AVATAR_FLAG_SURFING && transitionFlags == PLAYER_AVATAR_FLAG_UNDERWATER ))
return playerStruct->direction; return playerStruct->direction;
else if (MetatileBehavior_IsLadder(metatileBehavior) == TRUE) else if (MetatileBehavior_IsLadder(metatileBehavior) == TRUE)
return playerStruct->direction; return playerStruct->direction;
else else
return 1; return DIR_SOUTH;
} }
static u16 GetCenterScreenMetatileBehavior(void) static u16 GetCenterScreenMetatileBehavior(void)
@ -1357,7 +1357,7 @@ u8 Overworld_GetMapTypeOfSaveblockLocation(void)
return GetMapTypeByWarpData(&gSaveBlock1Ptr->location); return GetMapTypeByWarpData(&gSaveBlock1Ptr->location);
} }
u8 get_map_light_from_warp0(void) u8 GetLastUsedWarpMapType(void)
{ {
return GetMapTypeByWarpData(&gLastUsedWarp); return GetMapTypeByWarpData(&gLastUsedWarp);
} }
@ -1458,7 +1458,7 @@ static void DoCB1_Overworld(u16 newKeys, u16 heldKeys)
FieldGetPlayerInput(&inputStruct, newKeys, heldKeys); FieldGetPlayerInput(&inputStruct, newKeys, heldKeys);
if (!ScriptContext2_IsEnabled()) if (!ScriptContext2_IsEnabled())
{ {
if (sub_809C014(&inputStruct) == 1) if (ProcessPlayerFieldInput(&inputStruct) == 1)
{ {
ScriptContext2_Enable(); ScriptContext2_Enable();
HideMapNamePopUpWindow(); HideMapNamePopUpWindow();
@ -2166,9 +2166,9 @@ static void sub_8086988(u32 a1)
static void sub_80869DC(void) static void sub_80869DC(void)
{ {
gUnknown_03005DEC = 0; gTotalCameraPixelOffsetX = 0;
gUnknown_03005DE8 = 0; gTotalCameraPixelOffsetY = 0;
sub_808D438(); ResetEventObjects();
TrySpawnEventObjects(0, 0); TrySpawnEventObjects(0, 0);
mapheader_run_first_tag4_script_list_match(); mapheader_run_first_tag4_script_list_match();
} }
@ -2178,9 +2178,9 @@ static void mli4_mapscripts_and_other(void)
s16 x, y; s16 x, y;
struct InitialPlayerAvatarState *player; struct InitialPlayerAvatarState *player;
gUnknown_03005DEC = 0; gTotalCameraPixelOffsetX = 0;
gUnknown_03005DE8 = 0; gTotalCameraPixelOffsetY = 0;
sub_808D438(); ResetEventObjects();
sav1_camera_get_focus_coords(&x, &y); sav1_camera_get_focus_coords(&x, &y);
player = GetInitialPlayerAvatarState(); player = GetInitialPlayerAvatarState();
InitPlayerAvatar(x, y, player->direction, gSaveBlock2Ptr->playerGender); InitPlayerAvatar(x, y, player->direction, gSaveBlock2Ptr->playerGender);

View File

@ -1,21 +1,22 @@
#include "global.h" #include "global.h"
#include "constants/event_objects.h"
#include "constants/songs.h"
#include "rom6.h"
#include "braille_puzzles.h" #include "braille_puzzles.h"
#include "event_data.h" #include "event_data.h"
#include "event_object_movement.h"
#include "event_scripts.h" #include "event_scripts.h"
#include "field_effect.h" #include "field_effect.h"
#include "event_object_movement.h"
#include "field_player_avatar.h" #include "field_player_avatar.h"
#include "item_use.h" #include "item_use.h"
#include "party_menu.h"
#include "overworld.h" #include "overworld.h"
#include "party_menu.h"
#include "rom6.h"
#include "script.h" #include "script.h"
#include "sound.h" #include "sound.h"
#include "sprite.h" #include "sprite.h"
#include "task.h" #include "task.h"
#include "constants/event_object_movement_constants.h"
#include "constants/event_objects.h"
#include "constants/map_types.h" #include "constants/map_types.h"
#include "constants/songs.h"
// static functions // static functions
static void task08_080C9820(u8 taskId); static void task08_080C9820(u8 taskId);
@ -31,14 +32,14 @@ static void sub_8135780(void);
extern struct MapPosition gPlayerFacingPosition; extern struct MapPosition gPlayerFacingPosition;
// text // text
bool8 CheckObjectGraphicsInFrontOfPlayer(u8 a) bool8 CheckObjectGraphicsInFrontOfPlayer(u8 graphicsId)
{ {
u8 eventObjId; u8 eventObjId;
GetXYCoordsOneStepInFrontOfPlayer(&gPlayerFacingPosition.x, &gPlayerFacingPosition.y); GetXYCoordsOneStepInFrontOfPlayer(&gPlayerFacingPosition.x, &gPlayerFacingPosition.y);
gPlayerFacingPosition.height = PlayerGetZCoord(); gPlayerFacingPosition.height = PlayerGetZCoord();
eventObjId = GetEventObjectIdByXYZ(gPlayerFacingPosition.x, gPlayerFacingPosition.y, gPlayerFacingPosition.height); eventObjId = GetEventObjectIdByXYZ(gPlayerFacingPosition.x, gPlayerFacingPosition.y, gPlayerFacingPosition.height);
if (gEventObjects[eventObjId].graphicsId != a) if (gEventObjects[eventObjId].graphicsId != graphicsId)
{ {
return FALSE; return FALSE;
} }
@ -73,7 +74,7 @@ static void task08_080C9820(u8 taskId)
else else
{ {
sub_808C114(); sub_808C114();
EventObjectSetHeldMovement(&gEventObjects[eventObjId], 0x39); EventObjectSetHeldMovement(&gEventObjects[eventObjId], MOVEMENT_ACTION_START_ANIM_IN_DIRECTION);
gTasks[taskId].func = sub_813552C; gTasks[taskId].func = sub_813552C;
} }
} }
@ -90,7 +91,7 @@ static void sub_813552C(u8 taskId)
static void sub_8135578(u8 taskId) static void sub_8135578(u8 taskId)
{ {
if (!FieldEffectActiveListContains(6)) if (!FieldEffectActiveListContains(FLDEFF_FIELD_MOVE_SHOW_MON))
{ {
gFieldEffectArguments[1] = GetPlayerFacingDirection(); gFieldEffectArguments[1] = GetPlayerFacingDirection();
if (gFieldEffectArguments[1] == 1) if (gFieldEffectArguments[1] == 1)
@ -189,7 +190,7 @@ bool8 FldEff_UseDig(void)
gTasks[taskId].data[8] = (u32)sub_8135780 >> 16; gTasks[taskId].data[8] = (u32)sub_8135780 >> 16;
gTasks[taskId].data[9] = (u32)sub_8135780; gTasks[taskId].data[9] = (u32)sub_8135780;
if (!ShouldDoBrailleDigEffect()) if (!ShouldDoBrailleDigEffect())
SetPlayerAvatarTransitionFlags(1); SetPlayerAvatarTransitionFlags(PLAYER_AVATAR_FLAG_ON_FOOT);
return FALSE; return FALSE;
} }

View File

@ -81,7 +81,7 @@ void UpdateShoalTideFlag(void)
1, // 23 1, // 23
}; };
if (is_map_type_1_2_3_5_or_6(get_map_light_from_warp0())) if (is_map_type_1_2_3_5_or_6(GetLastUsedWarpMapType()))
{ {
RtcCalcLocalTime(); RtcCalcLocalTime();
if (tide[gLocalTime.hours]) if (tide[gLocalTime.hours])

View File

@ -1,37 +1,24 @@
#include "global.h" #include "global.h"
#include "main.h"
#include "palette.h"
#include "gpu_regs.h"
#include "bg.h" #include "bg.h"
#include "rtc.h"
#include "clock.h" #include "clock.h"
#include "wallclock.h"
#include "event_data.h"
#include "graphics.h"
#include "text.h"
#include "window.h"
#include "text_window.h"
#include "menu.h"
#include "scanline_effect.h"
#include "task.h"
#include "strings.h"
#include "sound.h"
#include "constants/songs.h"
#include "trig.h"
#include "decompress.h" #include "decompress.h"
#include "event_data.h"
// static types #include "gpu_regs.h"
#include "graphics.h"
#define tMinuteHandAngle data[0] #include "main.h"
#define tHourHandAngle data[1] #include "menu.h"
#define tHours data[2] #include "palette.h"
#define tMinutes data[3] #include "rtc.h"
#define tMvmtDir data[4] #include "scanline_effect.h"
#define tPeriod data[5] #include "sound.h"
#define tMvmtSpeed data[6] #include "strings.h"
#include "task.h"
#define TAG_GFX_WALL_CLOCK_HAND 0x1000 #include "text.h"
#define TAG_PAL_WALL_CLOCK_HAND 0x1000 #include "text_window.h"
#include "trig.h"
#include "wallclock.h"
#include "window.h"
#include "constants/songs.h"
// static declarations // static declarations
@ -46,15 +33,39 @@ static void Task_ViewClock1(u8 taskId);
static void Task_ViewClock2(u8 taskId); static void Task_ViewClock2(u8 taskId);
static void Task_ViewClock3(u8 taskId); static void Task_ViewClock3(u8 taskId);
static void Task_ViewClock4(u8 taskId); static void Task_ViewClock4(u8 taskId);
static u16 CalcNewMinHandAngle(u16 a0, u8 command, u8 a2); static u16 CalcNewMinHandAngle(u16 angle, u8 direction, u8 speed);
static bool32 AdvanceClock(u8 taskId, u8 command); static bool32 AdvanceClock(u8 taskId, u8 direction);
static void UpdateClockPeriod(u8 taskId, u8 command); static void UpdateClockPeriod(u8 taskId, u8 direction);
static void InitClockWithRtc(u8 taskId); static void InitClockWithRtc(u8 taskId);
static void SpriteCB_MinuteHand(struct Sprite *sprite); static void SpriteCB_MinuteHand(struct Sprite *sprite);
static void SpriteCB_HourHand(struct Sprite *sprite); static void SpriteCB_HourHand(struct Sprite *sprite);
static void SpriteCB_AMIndicator(struct Sprite *sprite); static void SpriteCB_AMIndicator(struct Sprite *sprite);
static void SpriteCB_PMIndicator(struct Sprite *sprite); static void SpriteCB_PMIndicator(struct Sprite *sprite);
#define tMinuteHandAngle data[0]
#define tHourHandAngle data[1]
#define tHours data[2]
#define tMinutes data[3]
#define tMvmtDir data[4]
#define tPeriod data[5]
#define tMvmtSpeed data[6]
#define TAG_GFX_WALL_CLOCK_HAND 0x1000
#define TAG_PAL_WALL_CLOCK_HAND 0x1000
enum
{
PERIOD_AM,
PERIOD_PM,
};
enum
{
MVMT_NONE,
MVMT_BACKWARD,
MVMT_FORWARD,
};
// rodata // rodata
static const u32 sUnknown_085B1F58[] = INCBIN_U32("graphics/wallclock/graphics_85b1f58.4bpp.lz"); static const u32 sUnknown_085B1F58[] = INCBIN_U32("graphics/wallclock/graphics_85b1f58.4bpp.lz");
@ -122,17 +133,17 @@ static const struct SpritePalette gUnknown_085B2218[] = {
{} {}
}; };
static const struct OamData Unknown_085B2230 = { static const struct OamData Unknown_085B2230 = {
.y = 0xa0, .y = 160,
.size = 3, .size = 3,
.priority = 1 .priority = 1,
}; };
static const union AnimCmd Unknown_085B2238[] = { static const union AnimCmd Unknown_085B2238[] = {
ANIMCMD_FRAME(0, 30), ANIMCMD_FRAME(0, 30),
ANIMCMD_END ANIMCMD_END,
}; };
static const union AnimCmd Unknown_085B2240[] = { static const union AnimCmd Unknown_085B2240[] = {
ANIMCMD_FRAME(64, 30), ANIMCMD_FRAME(64, 30),
ANIMCMD_END ANIMCMD_END,
}; };
static const union AnimCmd *const gUnknown_085B2248[] = { static const union AnimCmd *const gUnknown_085B2248[] = {
Unknown_085B2238 Unknown_085B2238
@ -148,7 +159,7 @@ static const struct SpriteTemplate gUnknown_085B2250 =
.anims = gUnknown_085B2248, .anims = gUnknown_085B2248,
.images = NULL, .images = NULL,
.affineAnims = gDummySpriteAffineAnimTable, .affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_MinuteHand .callback = SpriteCB_MinuteHand,
}; };
static const struct SpriteTemplate gUnknown_085B2268 = static const struct SpriteTemplate gUnknown_085B2268 =
{ {
@ -158,20 +169,20 @@ static const struct SpriteTemplate gUnknown_085B2268 =
.anims = gUnknown_085B224C, .anims = gUnknown_085B224C,
.images = NULL, .images = NULL,
.affineAnims = gDummySpriteAffineAnimTable, .affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_HourHand .callback = SpriteCB_HourHand,
}; };
static const struct OamData Unknown_085B2280 = { static const struct OamData Unknown_085B2280 = {
.y = 0xa0, .y = 160,
.size = 1, .size = 1,
.priority = 3 .priority = 3,
}; };
static const union AnimCmd Unknown_085B2288[] = { static const union AnimCmd Unknown_085B2288[] = {
ANIMCMD_FRAME(0x84, 30), ANIMCMD_FRAME(132, 30),
ANIMCMD_END ANIMCMD_END,
}; };
static const union AnimCmd Unknown_085B2290[] = { static const union AnimCmd Unknown_085B2290[] = {
ANIMCMD_FRAME(0x80, 30), ANIMCMD_FRAME(128, 30),
ANIMCMD_END ANIMCMD_END,
}; };
static const union AnimCmd *const gUnknown_085B2298[] = { static const union AnimCmd *const gUnknown_085B2298[] = {
Unknown_085B2288 Unknown_085B2288
@ -648,21 +659,21 @@ void CB2_StartWallClock(void)
gTasks[taskId].tMinuteHandAngle = 0; gTasks[taskId].tMinuteHandAngle = 0;
gTasks[taskId].tHourHandAngle = 300; gTasks[taskId].tHourHandAngle = 300;
spriteId = CreateSprite(&gUnknown_085B2250, 0x78, 0x50, 1); spriteId = CreateSprite(&gUnknown_085B2250, 120, 80, 1);
gSprites[spriteId].data[0] = taskId; gSprites[spriteId].data[0] = taskId;
gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL;
gSprites[spriteId].oam.matrixNum = 0; gSprites[spriteId].oam.matrixNum = 0;
spriteId = CreateSprite(&gUnknown_085B2268, 0x78, 0x50, 0); spriteId = CreateSprite(&gUnknown_085B2268, 120, 80, 0);
gSprites[spriteId].data[0] = taskId; gSprites[spriteId].data[0] = taskId;
gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL;
gSprites[spriteId].oam.matrixNum = 1; gSprites[spriteId].oam.matrixNum = 1;
spriteId = CreateSprite(&gUnknown_085B22A0, 0x78, 0x50, 2); spriteId = CreateSprite(&gUnknown_085B22A0, 120, 80, 2);
gSprites[spriteId].data[0] = taskId; gSprites[spriteId].data[0] = taskId;
gSprites[spriteId].data[1] = 45; gSprites[spriteId].data[1] = 45;
spriteId = CreateSprite(&gUnknown_085B22B8, 0x78, 0x50, 2); spriteId = CreateSprite(&gUnknown_085B22B8, 120, 80, 2);
gSprites[spriteId].data[0] = taskId; gSprites[spriteId].data[0] = taskId;
gSprites[spriteId].data[1] = 90; gSprites[spriteId].data[1] = 90;
@ -696,21 +707,21 @@ void CB2_ViewWallClock(void)
angle2 = 135; angle2 = 135;
} }
spriteId = CreateSprite(&gUnknown_085B2250, 0x78, 0x50, 1); spriteId = CreateSprite(&gUnknown_085B2250, 120, 80, 1);
gSprites[spriteId].data[0] = taskId; gSprites[spriteId].data[0] = taskId;
gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL;
gSprites[spriteId].oam.matrixNum = 0; gSprites[spriteId].oam.matrixNum = 0;
spriteId = CreateSprite(&gUnknown_085B2268, 0x78, 0x50, 0); spriteId = CreateSprite(&gUnknown_085B2268, 120, 80, 0);
gSprites[spriteId].data[0] = taskId; gSprites[spriteId].data[0] = taskId;
gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL;
gSprites[spriteId].oam.matrixNum = 1; gSprites[spriteId].oam.matrixNum = 1;
spriteId = CreateSprite(&gUnknown_085B22A0, 0x78, 0x50, 2); spriteId = CreateSprite(&gUnknown_085B22A0, 120, 80, 2);
gSprites[spriteId].data[0] = taskId; gSprites[spriteId].data[0] = taskId;
gSprites[spriteId].data[1] = angle1; gSprites[spriteId].data[1] = angle1;
spriteId = CreateSprite(&gUnknown_085B22B8, 0x78, 0x50, 2); spriteId = CreateSprite(&gUnknown_085B22B8, 120, 80, 2);
gSprites[spriteId].data[0] = taskId; gSprites[spriteId].data[0] = taskId;
gSprites[spriteId].data[1] = angle2; gSprites[spriteId].data[1] = angle2;
@ -757,11 +768,11 @@ static void Task_SetClock2(u8 taskId)
gTasks[taskId].tMvmtDir = 0; gTasks[taskId].tMvmtDir = 0;
if (gMain.heldKeys & DPAD_LEFT) if (gMain.heldKeys & DPAD_LEFT)
{ {
gTasks[taskId].tMvmtDir = 1; gTasks[taskId].tMvmtDir = MVMT_BACKWARD;
} }
if (gMain.heldKeys & DPAD_RIGHT) if (gMain.heldKeys & DPAD_RIGHT)
{ {
gTasks[taskId].tMvmtDir = 2; gTasks[taskId].tMvmtDir = MVMT_FORWARD;
} }
if (gTasks[taskId].tMvmtDir != 0) if (gTasks[taskId].tMvmtDir != 0)
{ {
@ -794,12 +805,12 @@ static void Task_SetClock4(u8 taskId)
{ {
switch (Menu_ProcessInputNoWrapClearOnChoose()) switch (Menu_ProcessInputNoWrapClearOnChoose())
{ {
case 0: case 0: //YES
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
gTasks[taskId].func = Task_SetClock5; gTasks[taskId].func = Task_SetClock5;
break; break;
case 1: case 1: //B button
case -1: case -1: //NO
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
sub_8198070(0, FALSE); sub_8198070(0, FALSE);
ClearWindowTilemap(0); ClearWindowTilemap(0);
@ -855,45 +866,49 @@ static void Task_ViewClock4(u8 taskId)
} }
} }
static u8 CalcMinHandDelta(u16 a0) static u8 CalcMinHandDelta(u16 speed)
{ {
if (a0 > 60) if (speed > 60)
{ {
return 6; return 6;
} }
if (a0 > 30) if (speed > 30)
{ {
return 3; return 3;
} }
if (a0 > 10) if (speed > 10)
{ {
return 2; return 2;
} }
return 1; return 1;
} }
static u16 CalcNewMinHandAngle(u16 a0, u8 command, u8 a2) static u16 CalcNewMinHandAngle(u16 angle, u8 direction, u8 speed)
{ {
u8 r1 = CalcMinHandDelta(a2); u8 delta = CalcMinHandDelta(speed);
switch (command) switch (direction)
{ {
case 1: case MVMT_BACKWARD:
if (a0) a0 -= r1; if (angle)
else a0 = 360 - r1; angle -= delta ;
else
angle = 360 - delta ;
break; break;
case 2: case MVMT_FORWARD:
if (a0 < 360 - r1) a0 += r1; if (angle < 360 - delta )
else a0 = 0; angle += delta ;
else
angle = 0;
break; break;
} }
return a0; return angle;
} }
static bool32 AdvanceClock(u8 taskId, u8 command) static bool32 AdvanceClock(u8 taskId, u8 direction)
{ {
switch (command) switch (direction)
{ {
case 1: case MVMT_BACKWARD:
if (gTasks[taskId].tMinutes > 0) if (gTasks[taskId].tMinutes > 0)
{ {
gTasks[taskId].tMinutes--; gTasks[taskId].tMinutes--;
@ -909,10 +924,10 @@ static bool32 AdvanceClock(u8 taskId, u8 command)
{ {
gTasks[taskId].tHours = 23; gTasks[taskId].tHours = 23;
} }
UpdateClockPeriod(taskId, command); UpdateClockPeriod(taskId, direction);
} }
break; break;
case 2: case MVMT_FORWARD:
if (gTasks[taskId].tMinutes < 59) if (gTasks[taskId].tMinutes < 59)
{ {
gTasks[taskId].tMinutes++; gTasks[taskId].tMinutes++;
@ -928,37 +943,37 @@ static bool32 AdvanceClock(u8 taskId, u8 command)
{ {
gTasks[taskId].tHours = 0; gTasks[taskId].tHours = 0;
} }
UpdateClockPeriod(taskId, command); UpdateClockPeriod(taskId, direction);
} }
break; break;
} }
return FALSE; return FALSE;
} }
static void UpdateClockPeriod(u8 taskId, u8 command) static void UpdateClockPeriod(u8 taskId, u8 direction)
{ {
u8 hours = gTasks[taskId].tHours; u8 hours = gTasks[taskId].tHours;
switch (command) switch (direction)
{ {
case 1: case MVMT_BACKWARD:
switch (hours) switch (hours)
{ {
case 11: case 11:
gTasks[taskId].tPeriod = FALSE; gTasks[taskId].tPeriod = PERIOD_AM;
break; break;
case 23: case 23:
gTasks[taskId].tPeriod = TRUE; gTasks[taskId].tPeriod = PERIOD_PM;
break; break;
} }
break; break;
case 2: case MVMT_FORWARD:
switch (hours) switch (hours)
{ {
case 0: case 0:
gTasks[taskId].tPeriod = FALSE; gTasks[taskId].tPeriod = PERIOD_AM;
break; break;
case 12: case 12:
gTasks[taskId].tPeriod = TRUE; gTasks[taskId].tPeriod = PERIOD_PM;
break; break;
} }
break; break;
@ -974,11 +989,11 @@ static void InitClockWithRtc(u8 taskId)
gTasks[taskId].tHourHandAngle = (gTasks[taskId].tHours % 12) * 30 + (gTasks[taskId].tMinutes / 10) * 5; gTasks[taskId].tHourHandAngle = (gTasks[taskId].tHours % 12) * 30 + (gTasks[taskId].tMinutes / 10) * 5;
if (gLocalTime.hours < 12) if (gLocalTime.hours < 12)
{ {
gTasks[taskId].tPeriod = FALSE; gTasks[taskId].tPeriod = PERIOD_AM;
} }
else else
{ {
gTasks[taskId].tPeriod = TRUE; gTasks[taskId].tPeriod = PERIOD_PM;
} }
} }
@ -987,8 +1002,7 @@ static void SpriteCB_MinuteHand(struct Sprite *sprite)
u16 angle = gTasks[sprite->data[0]].tMinuteHandAngle; u16 angle = gTasks[sprite->data[0]].tMinuteHandAngle;
s16 sin = Sin2(angle) / 16; s16 sin = Sin2(angle) / 16;
s16 cos = Cos2(angle) / 16; s16 cos = Cos2(angle) / 16;
u16 xhat; u16 xhat, yhat;
u16 yhat;
SetOamMatrix(0, cos, sin, -sin, cos); SetOamMatrix(0, cos, sin, -sin, cos);
xhat = sClockHandCoords[angle][0]; xhat = sClockHandCoords[angle][0];
@ -1011,8 +1025,7 @@ static void SpriteCB_HourHand(struct Sprite *sprite)
u16 angle = gTasks[sprite->data[0]].tHourHandAngle; u16 angle = gTasks[sprite->data[0]].tHourHandAngle;
s16 sin = Sin2(angle) / 16; s16 sin = Sin2(angle) / 16;
s16 cos = Cos2(angle) / 16; s16 cos = Cos2(angle) / 16;
u16 xhat; u16 xhat, yhat;
u16 yhat;
SetOamMatrix(1, cos, sin, -sin, cos); SetOamMatrix(1, cos, sin, -sin, cos);
xhat = sClockHandCoords[angle][0]; xhat = sClockHandCoords[angle][0];