mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
Fix conflicts
This commit is contained in:
commit
b5ea69cf74
@ -7851,7 +7851,7 @@ palette_bg_faded_fill_black: @ 80AF020
|
||||
thumb_func_start pal_fill_for_maplights
|
||||
pal_fill_for_maplights: @ 80AF040
|
||||
push {r4,lr}
|
||||
bl get_map_light_from_warp0
|
||||
bl GetLastUsedWarpMapType
|
||||
adds r4, r0, 0
|
||||
lsls r4, 24
|
||||
lsrs r4, 24
|
||||
|
@ -2262,8 +2262,8 @@ _080FAEA2:
|
||||
bx r0
|
||||
thumb_func_end task50_overworld_poison_effect
|
||||
|
||||
thumb_func_start overworld_poison_effect
|
||||
overworld_poison_effect: @ 80FAEA8
|
||||
thumb_func_start FldeffPoison_Start
|
||||
FldeffPoison_Start: @ 80FAEA8
|
||||
push {lr}
|
||||
movs r0, 0x4F
|
||||
bl PlaySE
|
||||
@ -2273,7 +2273,7 @@ overworld_poison_effect: @ 80FAEA8
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end overworld_poison_effect
|
||||
thumb_func_end FldeffPoison_Start
|
||||
|
||||
thumb_func_start FieldPoisonEffectIsRunning
|
||||
FieldPoisonEffectIsRunning: @ 80FAEC0
|
||||
|
@ -1,3 +1,3 @@
|
||||
gUnknown_03005DD0
|
||||
gUnknown_03005DE8
|
||||
gUnknown_03005DEC
|
||||
gFieldCamera
|
||||
gTotalCameraPixelOffsetY
|
||||
gTotalCameraPixelOffsetX
|
||||
|
@ -3325,7 +3325,7 @@ EventScript_2736B3:: @ 82736B3
|
||||
|
||||
EventScript_Poison:: @ 82736BC
|
||||
lockall
|
||||
special sub_80F972C
|
||||
special ExecuteWhiteOut
|
||||
waitstate
|
||||
compare VAR_RESULT, 1
|
||||
goto_eq EventScript_2736D9
|
||||
|
@ -210,7 +210,7 @@ gSpecials:: @ 81DBA64
|
||||
def_special ShowLinkBattleRecords
|
||||
def_special IsEnoughForCostInVar0x8005
|
||||
def_special SubtractMoneyFromVar0x8005
|
||||
def_special sub_80F972C
|
||||
def_special ExecuteWhiteOut
|
||||
def_special sp0C8_whiteout_maybe
|
||||
def_special RotatingGate_InitPuzzle
|
||||
def_special RotatingGate_InitPuzzleAndGraphics
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef GUARD_BERRY_H
|
||||
#define GUARD_BERRY_H
|
||||
|
||||
#define BERRY_NONE 0
|
||||
|
||||
enum
|
||||
{
|
||||
BERRY_FIRMNESS_UNKNOWN,
|
||||
@ -21,6 +23,17 @@ enum
|
||||
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
|
||||
|
||||
extern const u8 *const gBerryTreeEventObjectGraphicsIdTablePointers[];
|
||||
@ -29,7 +42,6 @@ extern const u8 *const gBerryTreePaletteSlotTablePointers[];
|
||||
|
||||
void ClearEnigmaBerries(void);
|
||||
void SetEnigmaBerry(u8 *src);
|
||||
u32 GetEnigmaBerryChecksum(struct EnigmaBerry *enigmaBerry);
|
||||
bool32 IsEnigmaBerryValid(void);
|
||||
const struct Berry *GetBerryInfo(u8 berry);
|
||||
struct BerryTree *GetBerryTreeInfo(u8 id);
|
||||
@ -37,28 +49,20 @@ bool32 EventObjectInteractionWaterBerryTree(void);
|
||||
bool8 IsPlayerFacingPlantedBerryTree(void);
|
||||
bool8 TryToWaterBerryTree(void);
|
||||
void ClearBerryTrees(void);
|
||||
bool32 BerryTreeGrow(struct BerryTree *tree);
|
||||
void BerryTreeTimeUpdate(s32 minutes);
|
||||
void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 sparkle);
|
||||
void RemoveBerryTree(u8 id);
|
||||
u8 GetBerryTypeByBerryTreeId(u8 id);
|
||||
u8 GetStageByBerryTreeId(u8);
|
||||
u8 ItemIdToBerryType(u16 item);
|
||||
u16 BerryTypeToItemId(u16 berry);
|
||||
void GetBerryNameByBerryType(u8 berry, u8 *string);
|
||||
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 EventObjectInteractionGetBerryTreeData(void);
|
||||
void EventObjectInteractionPlantBerryTree(void);
|
||||
void EventObjectInteractionPickBerryTree(void);
|
||||
void EventObjectInteractionRemoveBerryTree(void);
|
||||
u8 PlayerHasBerries(void);
|
||||
bool8 PlayerHasBerries(void);
|
||||
void ResetBerryTreeSparkleFlags(void);
|
||||
|
||||
extern const struct Berry gBerries[];
|
||||
|
@ -75,14 +75,14 @@ struct PairedPalettes
|
||||
|
||||
struct LockedAnimEventObjects
|
||||
{
|
||||
u8 eventObjectIds[NUM_EVENT_OBJECTS];
|
||||
u8 eventObjectIds[EVENT_OBJECTS_COUNT];
|
||||
u8 count;
|
||||
};
|
||||
|
||||
extern const struct SpriteFrameImage gEventObjectPicTable_PechaBerryTree[];
|
||||
extern const u8 gReflectionEffectPaletteMap[];
|
||||
|
||||
void sub_808D438(void);
|
||||
void ResetEventObjects(void);
|
||||
u8 GetMoveDirectionAnimNum(u8);
|
||||
u8 GetEventObjectIdByLocalIdAndMap(u8, u8, u8);
|
||||
bool8 TryGetEventObjectIdByLocalIdAndMap(u8, u8, u8, u8 *);
|
||||
@ -180,9 +180,7 @@ u8 ZCoordToPriority(u8);
|
||||
void EventObjectUpdateZCoord(struct EventObject *pObject);
|
||||
void SetObjectSubpriorityByZCoord(u8, struct Sprite *, u8);
|
||||
bool8 IsZCoordMismatchAt(u8, s16, s16);
|
||||
void UpdateEventObjectSpriteSubpriorityAndVisibility(struct Sprite *);
|
||||
void UnfreezeEventObject(struct EventObject *);
|
||||
void oamt_npc_ministep_reset(struct Sprite *, u8, u8);
|
||||
u8 FindLockedEventObjectIndex(struct EventObject *);
|
||||
bool8 obj_npc_ministep(struct Sprite *sprite);
|
||||
bool8 sub_80976EC(struct Sprite *sprite);
|
||||
|
@ -7,16 +7,16 @@ struct CameraObject
|
||||
{
|
||||
void (*callback)(struct CameraObject *);
|
||||
u32 spriteId;
|
||||
s32 unk8;
|
||||
s32 unkC;
|
||||
s32 movementSpeedX;
|
||||
s32 movementSpeedY;
|
||||
s32 x;
|
||||
s32 y;
|
||||
};
|
||||
|
||||
// Exported RAM declarations
|
||||
extern struct CameraObject gUnknown_03005DD0;
|
||||
extern u16 gUnknown_03005DEC;
|
||||
extern u16 gUnknown_03005DE8;
|
||||
extern struct CameraObject gFieldCamera;
|
||||
extern u16 gTotalCameraPixelOffsetX;
|
||||
extern u16 gTotalCameraPixelOffsetY;
|
||||
|
||||
// Exported ROM declarations
|
||||
void DrawWholeMapView(void);
|
||||
|
@ -25,7 +25,7 @@ struct FieldInput
|
||||
|
||||
void FieldClearPlayerInput(struct FieldInput *pStruct);
|
||||
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);
|
||||
void overworld_poison_timer_set(void);
|
||||
void RestartWildEncounterImmunitySteps(void);
|
||||
|
@ -179,8 +179,8 @@ bool8 sub_80B7B94(struct Task *, struct EventObject *, struct Sprite *);
|
||||
bool8 sub_80B7BCC(struct Task *, struct EventObject *, struct Sprite *);
|
||||
bool8 sub_80B7BF4(struct Task *, struct EventObject *, struct Sprite *);
|
||||
|
||||
void sub_80B7D14(struct Task *);
|
||||
void sub_80B7D34(struct Task *);
|
||||
static void EscapeRopeFieldEffect_Step0(struct Task *);
|
||||
static void EscapeRopeFieldEffect_Step1(struct Task *);
|
||||
|
||||
void sub_80B7EC4(struct Task *);
|
||||
void sub_80B7EE8(struct Task *);
|
||||
|
@ -18,7 +18,7 @@ u8 FindTallGrassFieldEffectSpriteId(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s
|
||||
void sub_8155F80(struct Sprite*);
|
||||
void UpdateShadowFieldEffect(struct Sprite*);
|
||||
void UpdateTallGrassFieldEffect(struct Sprite*);
|
||||
void sub_81561D0(struct Sprite*);
|
||||
void WaitFieldEffectSpriteAnim(struct Sprite*);
|
||||
void UpdateAshFieldEffect(struct Sprite*);
|
||||
void UpdateSurfBlobFieldEffect(struct Sprite*);
|
||||
void sub_8156194(struct Sprite*);
|
||||
|
@ -13,7 +13,7 @@ enum {
|
||||
FLDPSN_FNT
|
||||
};
|
||||
|
||||
void sub_80F972C(void);
|
||||
int DoPoisonFieldEffect(void);
|
||||
void ExecuteWhiteOut(void);
|
||||
s32 DoPoisonFieldEffect(void);
|
||||
|
||||
#endif //GUARD_FIELD_POISON_H
|
||||
|
@ -11,7 +11,7 @@ void sub_80FA5E4(s16 id, s16 x, s16 y);
|
||||
void sub_80FA794(s16 x, s16 y);
|
||||
void CreateRecordMixingSprite(void);
|
||||
void DestroyRecordMixingSprite(void);
|
||||
void overworld_poison_effect(void);
|
||||
void FldeffPoison_Start(void);
|
||||
void sub_80FA970(s16);
|
||||
void sub_80FA9D0(void);
|
||||
bool8 sub_80FADE4(u16, u8);
|
||||
|
@ -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
|
@ -1,8 +1,6 @@
|
||||
#ifndef GUARD_GLOBAL_FIELDMAP_H
|
||||
#define GUARD_GLOBAL_FIELDMAP_H
|
||||
|
||||
#define NUM_EVENT_OBJECTS 16
|
||||
|
||||
enum
|
||||
{
|
||||
CONNECTION_SOUTH = 1,
|
||||
@ -228,14 +226,14 @@ struct EventObjectGraphicsInfo
|
||||
/*0x20*/ const union AffineAnimCmd *const *affineAnims;
|
||||
};
|
||||
|
||||
#define PLAYER_AVATAR_FLAG_ON_FOOT (1 << 0)
|
||||
#define PLAYER_AVATAR_FLAG_MACH_BIKE (1 << 1)
|
||||
#define PLAYER_AVATAR_FLAG_ACRO_BIKE (1 << 2)
|
||||
#define PLAYER_AVATAR_FLAG_SURFING (1 << 3)
|
||||
#define PLAYER_AVATAR_FLAG_ON_FOOT (1 << 0)
|
||||
#define PLAYER_AVATAR_FLAG_MACH_BIKE (1 << 1)
|
||||
#define PLAYER_AVATAR_FLAG_ACRO_BIKE (1 << 2)
|
||||
#define PLAYER_AVATAR_FLAG_SURFING (1 << 3)
|
||||
#define PLAYER_AVATAR_FLAG_UNDERWATER (1 << 4)
|
||||
#define PLAYER_AVATAR_FLAG_5 (1 << 5)
|
||||
#define PLAYER_AVATAR_FLAG_6 (1 << 6)
|
||||
#define PLAYER_AVATAR_FLAG_DASH (1 << 7)
|
||||
#define PLAYER_AVATAR_FLAG_5 (1 << 5)
|
||||
#define PLAYER_AVATAR_FLAG_6 (1 << 6)
|
||||
#define PLAYER_AVATAR_FLAG_DASH (1 << 7)
|
||||
|
||||
enum
|
||||
{
|
||||
@ -311,7 +309,7 @@ struct Camera
|
||||
s32 y;
|
||||
};
|
||||
|
||||
extern struct EventObject gEventObjects[NUM_EVENT_OBJECTS];
|
||||
extern struct EventObject gEventObjects[EVENT_OBJECTS_COUNT];
|
||||
extern u8 gSelectedEventObject;
|
||||
extern struct MapHeader gMapHeader;
|
||||
extern struct PlayerAvatar gPlayerAvatar;
|
||||
|
@ -119,22 +119,22 @@ enum LanguageId
|
||||
#define GAME_LANGUAGE (LANGUAGE_ENGLISH)
|
||||
|
||||
// capacities of various saveblock objects
|
||||
#define DAYCARE_MON_COUNT 2
|
||||
#define POKEBLOCKS_COUNT 40
|
||||
#define EVENT_OBJECTS_COUNT 16
|
||||
#define DAYCARE_MON_COUNT 2
|
||||
#define POKEBLOCKS_COUNT 40
|
||||
#define EVENT_OBJECTS_COUNT 16
|
||||
#define BERRY_TREES_COUNT 128
|
||||
#define FLAGS_COUNT 300
|
||||
#define VARS_COUNT 256
|
||||
#define MAIL_COUNT 16
|
||||
#define SECRET_BASES_COUNT 20
|
||||
#define TV_SHOWS_COUNT 25
|
||||
#define POKE_NEWS_COUNT 16
|
||||
#define PC_ITEMS_COUNT 50
|
||||
#define BAG_ITEMS_COUNT 30
|
||||
#define BAG_KEYITEMS_COUNT 30
|
||||
#define BAG_POKEBALLS_COUNT 16
|
||||
#define BAG_TMHM_COUNT 64
|
||||
#define BAG_BERRIES_COUNT 46
|
||||
#define MAIL_COUNT 16
|
||||
#define SECRET_BASES_COUNT 20
|
||||
#define TV_SHOWS_COUNT 25
|
||||
#define POKE_NEWS_COUNT 16
|
||||
#define PC_ITEMS_COUNT 50
|
||||
#define BAG_ITEMS_COUNT 30
|
||||
#define BAG_KEYITEMS_COUNT 30
|
||||
#define BAG_POKEBALLS_COUNT 16
|
||||
#define BAG_TMHM_COUNT 64
|
||||
#define BAG_BERRIES_COUNT 46
|
||||
|
||||
#define PYRAMID_BAG_ITEMS_COUNT 10
|
||||
#define HALL_FACILITIES_COUNT 9 // 7 facilities for single mode + tower double mode + tower multi mode.
|
||||
|
@ -77,7 +77,7 @@ bool8 MetatileBehavior_IsBerryTreeSoil(u8);
|
||||
bool8 MetatileBehavior_IsAshGrass(u8);
|
||||
bool8 MetatileBehavior_IsFootprints(u8);
|
||||
bool8 MetatileBehavior_IsBridge(u8);
|
||||
u8 MetatileBehavior_GetBridgeSth(u8);
|
||||
u8 MetatileBehavior_GetBridgeType(u8);
|
||||
u8 MetatileBehavior_8089510(u8);
|
||||
bool8 MetatileBehavior_IsLandWildEncounter(u8);
|
||||
bool8 MetatileBehavior_IsWaterWildEncounter(u8);
|
||||
|
@ -47,13 +47,13 @@ void Overworld_SetEventObjTemplateMovementType(u8 localId, u8 movementType);
|
||||
const struct MapLayout *GetMapLayout(void);
|
||||
void ApplyCurrentWarp(void);
|
||||
void set_warp2_warp3_to_neg_1(void);
|
||||
void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
|
||||
bool32 IsDummyWarp(struct WarpData *warp);
|
||||
static void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
|
||||
static bool32 IsDummyWarp(struct WarpData *warp);
|
||||
struct MapHeader const *const Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u16 mapNum);
|
||||
struct MapHeader const *const GetDestinationWarpMapHeader(void);
|
||||
void LoadCurrentMapData(void);
|
||||
void LoadSaveblockMapHeader(void);
|
||||
void SetPlayerCoordsFromWarp(void);
|
||||
static void LoadCurrentMapData(void);
|
||||
static void LoadSaveblockMapHeader(void);
|
||||
static void SetPlayerCoordsFromWarp(void);
|
||||
void WarpIntoMap(void);
|
||||
void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
|
||||
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_8084E14(void);
|
||||
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 SetFixedHoleWarpAsDestination(s16 x, s16 y);
|
||||
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_8084FAC(void);
|
||||
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 SetDiveWarpDive(u16 x, u16 y);
|
||||
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 GetMapTypeByWarpData(struct WarpData *warp);
|
||||
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 Overworld_MapTypeAllowsTeleportAndFly(u8 mapType);
|
||||
bool8 Overworld_MapTypeIsIndoors(u8 mapType);
|
||||
|
@ -664,7 +664,7 @@ u8 BattleSetup_GetTerrainId(void)
|
||||
return BATTLE_TERRAIN_MOUNTAIN;
|
||||
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING))
|
||||
{
|
||||
if (MetatileBehavior_GetBridgeSth(tileBehavior))
|
||||
if (MetatileBehavior_GetBridgeType(tileBehavior))
|
||||
return BATTLE_TERRAIN_POND;
|
||||
if (MetatileBehavior_IsBridge(tileBehavior) == TRUE)
|
||||
return BATTLE_TERRAIN_WATER;
|
||||
|
87
src/berry.c
87
src/berry.c
@ -1,12 +1,13 @@
|
||||
#include "global.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 "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 void sub_8092EF0(u8 mapId, u8 mapNumber, u8 mapGroup);
|
||||
@ -18,6 +19,17 @@ extern u16 gSpecialVar_ItemId;
|
||||
|
||||
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 sBerryDescriptionPart2_Cheri[] = _("The bright red BERRY is very spicy.");
|
||||
static const u8 sBerryDescriptionPart1_Chesto[] = _("The BERRY’s thick skin and fruit are");
|
||||
@ -845,6 +857,7 @@ const struct UnkStruct_0858AB24 gUnknown_0858AB24[] = {
|
||||
|
||||
const struct BerryTree gBlankBerryTree = {};
|
||||
|
||||
//.text
|
||||
// unused
|
||||
void ClearEnigmaBerries(void)
|
||||
{
|
||||
@ -860,7 +873,7 @@ void SetEnigmaBerry(u8 *src)
|
||||
dest[i] = src[i];
|
||||
}
|
||||
|
||||
u32 GetEnigmaBerryChecksum(struct EnigmaBerry *enigmaBerry)
|
||||
static u32 GetEnigmaBerryChecksum(struct EnigmaBerry *enigmaBerry)
|
||||
{
|
||||
u32 i;
|
||||
u32 checksum;
|
||||
@ -889,12 +902,12 @@ bool32 IsEnigmaBerryValid(void)
|
||||
|
||||
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);
|
||||
else
|
||||
{
|
||||
if (berry == 0 || berry > 0x2B)
|
||||
berry = 1;
|
||||
if (berry == BERRY_NONE || berry > ITEM_TO_BERRY(LAST_BERRY_INDEX))
|
||||
berry = ITEM_TO_BERRY(FIRST_BERRY_INDEX);
|
||||
return &gBerries[berry - 1];
|
||||
}
|
||||
}
|
||||
@ -910,16 +923,16 @@ bool32 EventObjectInteractionWaterBerryTree(void)
|
||||
|
||||
switch (tree->stage)
|
||||
{
|
||||
case 1:
|
||||
case BERRY_STAGE_PLANTED:
|
||||
tree->watered1 = TRUE;
|
||||
break;
|
||||
case 2:
|
||||
case BERRY_STAGE_SPROUTED:
|
||||
tree->watered2 = TRUE;
|
||||
break;
|
||||
case 3:
|
||||
case BERRY_STAGE_TALLER:
|
||||
tree->watered3 = TRUE;
|
||||
break;
|
||||
case 4:
|
||||
case BERRY_STAGE_FLOWERING:
|
||||
tree->watered4 = TRUE;
|
||||
break;
|
||||
default:
|
||||
@ -953,28 +966,28 @@ void ClearBerryTrees(void)
|
||||
gSaveBlock1Ptr->berryTrees[i] = gBlankBerryTree;
|
||||
}
|
||||
|
||||
bool32 BerryTreeGrow(struct BerryTree *tree)
|
||||
static bool32 BerryTreeGrow(struct BerryTree *tree)
|
||||
{
|
||||
if (tree->growthSparkle)
|
||||
return FALSE;
|
||||
switch (tree->stage)
|
||||
{
|
||||
case 0:
|
||||
case BERRY_STAGE_NO_BERRY:
|
||||
return FALSE;
|
||||
case 4:
|
||||
case BERRY_STAGE_FLOWERING:
|
||||
tree->berryYield = CalcBerryYield(tree);
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case BERRY_STAGE_PLANTED:
|
||||
case BERRY_STAGE_SPROUTED:
|
||||
case BERRY_STAGE_TALLER:
|
||||
tree->stage++;
|
||||
break;
|
||||
case 5:
|
||||
case BERRY_STAGE_BERRIES:
|
||||
tree->watered1 = 0;
|
||||
tree->watered2 = 0;
|
||||
tree->watered3 = 0;
|
||||
tree->watered4 = 0;
|
||||
tree->berryYield = 0;
|
||||
tree->stage = 2;
|
||||
tree->stage = BERRY_STAGE_SPROUTED;
|
||||
if (++tree->regrowthCount == 10)
|
||||
*tree = gBlankBerryTree;
|
||||
break;
|
||||
@ -1012,7 +1025,7 @@ void BerryTreeTimeUpdate(s32 minutes)
|
||||
tree->minutesUntilNextStage = GetStageDurationByBerryType(tree->berry);
|
||||
if (!BerryTreeGrow(tree))
|
||||
break;
|
||||
if (tree->stage == 5)
|
||||
if (tree->stage == BERRY_STAGE_BERRIES)
|
||||
tree->minutesUntilNextStage *= 4;
|
||||
}
|
||||
}
|
||||
@ -1028,7 +1041,7 @@ void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 sparkle)
|
||||
tree->berry = berry;
|
||||
tree->minutesUntilNextStage = GetStageDurationByBerryType(berry);
|
||||
tree->stage = stage;
|
||||
if (stage == 5)
|
||||
if (stage == BERRY_STAGE_BERRIES)
|
||||
{
|
||||
tree->berryYield = CalcBerryYield(tree);
|
||||
tree->minutesUntilNextStage *= 4;
|
||||
@ -1064,7 +1077,7 @@ u8 ItemIdToBerryType(u16 item)
|
||||
return ITEM_TO_BERRY(item);
|
||||
}
|
||||
|
||||
u16 BerryTypeToItemId(u16 berry)
|
||||
static u16 BerryTypeToItemId(u16 berry)
|
||||
{
|
||||
u16 item = berry - 1;
|
||||
|
||||
@ -1087,10 +1100,10 @@ void GetBerryCountStringByBerryType(u8 berry, u8* dest, u32 berryCount)
|
||||
|
||||
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;
|
||||
|
||||
@ -1105,12 +1118,12 @@ u8 BerryTreeGetNumStagesWatered(struct BerryTree *tree)
|
||||
return count;
|
||||
}
|
||||
|
||||
u8 GetNumStagesWateredByBerryTreeId(u8 id)
|
||||
static u8 GetNumStagesWateredByBerryTreeId(u8 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 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);
|
||||
u8 min = berry->minYield;
|
||||
@ -1142,12 +1155,12 @@ u8 CalcBerryYield(struct BerryTree *tree)
|
||||
return CalcBerryYieldInternal(max, min, BerryTreeGetNumStagesWatered(tree));
|
||||
}
|
||||
|
||||
u8 GetBerryCountByBerryTreeId(u8 id)
|
||||
static u8 GetBerryCountByBerryTreeId(u8 id)
|
||||
{
|
||||
return gSaveBlock1Ptr->berryTrees[id].berryYield;
|
||||
}
|
||||
|
||||
u16 GetStageDurationByBerryType(u8 berry)
|
||||
static u16 GetStageDurationByBerryType(u8 berry)
|
||||
{
|
||||
return GetBerryInfo(berry)->stageDuration * 60;
|
||||
}
|
||||
@ -1156,18 +1169,18 @@ void EventObjectInteractionGetBerryTreeData(void)
|
||||
{
|
||||
u8 id;
|
||||
u8 berry;
|
||||
u8 unk;
|
||||
u8 localId;
|
||||
u8 group;
|
||||
u8 num;
|
||||
|
||||
id = EventObjectGetBerryTreeId(gSelectedEventObject);
|
||||
berry = GetBerryTypeByBerryTreeId(id);
|
||||
ResetBerryTreeSparkleFlag(id);
|
||||
unk = gSpecialVar_LastTalked;
|
||||
localId = gSpecialVar_LastTalked;
|
||||
num = gSaveBlock1Ptr->location.mapNum;
|
||||
group = gSaveBlock1Ptr->location.mapGroup;
|
||||
if (IsBerryTreeSparkling(unk, num, group))
|
||||
gSpecialVar_0x8004 = 0xFF;
|
||||
if (IsBerryTreeSparkling(localId, num, group))
|
||||
gSpecialVar_0x8004 = BERRY_STAGE_SPARKLING;
|
||||
else
|
||||
gSpecialVar_0x8004 = GetStageByBerryTreeId(id);
|
||||
gSpecialVar_0x8005 = GetNumStagesWateredByBerryTreeId(id);
|
||||
@ -1216,7 +1229,7 @@ void EventObjectInteractionRemoveBerryTree(void)
|
||||
sub_8092EF0(gSpecialVar_LastTalked, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
|
||||
}
|
||||
|
||||
u8 PlayerHasBerries(void)
|
||||
bool8 PlayerHasBerries(void)
|
||||
{
|
||||
return IsBagPocketNonEmpty(POCKET_BERRIES);
|
||||
}
|
||||
@ -1238,7 +1251,7 @@ void ResetBerryTreeSparkleFlags(void)
|
||||
bottom = top + 8;
|
||||
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_top = gEventObjects[i].currentCoords.y;
|
||||
|
@ -3,13 +3,13 @@
|
||||
#include "event_object_movement.h"
|
||||
#include "field_player_avatar.h"
|
||||
#include "fieldmap.h"
|
||||
#include "constants/flags.h"
|
||||
#include "global.fieldmap.h"
|
||||
#include "metatile_behavior.h"
|
||||
#include "overworld.h"
|
||||
#include "constants/songs.h"
|
||||
#include "sound.h"
|
||||
#include "constants/flags.h"
|
||||
#include "constants/map_types.h"
|
||||
#include "constants/songs.h"
|
||||
|
||||
extern bool8 gBikeCyclingChallenge;
|
||||
extern u8 gBikeCollisions;
|
||||
|
@ -91,7 +91,7 @@ const union AnimCmd *const gFieldEffectObjectImageAnimTable_Ripple[] =
|
||||
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[] = {
|
||||
overworld_frame(gFieldEffectObjectPic_Ash, 2, 2, 0),
|
||||
@ -124,25 +124,25 @@ const struct SpriteFrameImage gFieldEffectObjectPicTable_SurfBlob[] = {
|
||||
overworld_frame(gFieldEffectObjectPic_SurfBlob, 4, 4, 2),
|
||||
};
|
||||
|
||||
const union AnimCmd gFieldEffectObjectImageAnim_850CB94[] =
|
||||
const union AnimCmd gSurfBlobAnim_FaceSouth[] =
|
||||
{
|
||||
ANIMCMD_FRAME(0, 1),
|
||||
ANIMCMD_JUMP(0),
|
||||
};
|
||||
|
||||
const union AnimCmd gFieldEffectObjectImageAnim_850CB9C[] =
|
||||
const union AnimCmd gSurfBlobAnim_FaceNorth[] =
|
||||
{
|
||||
ANIMCMD_FRAME(1, 1),
|
||||
ANIMCMD_JUMP(0),
|
||||
};
|
||||
|
||||
const union AnimCmd gFieldEffectObjectImageAnim_850CBA4[] =
|
||||
const union AnimCmd gSurfBlobAnim_FaceWest[] =
|
||||
{
|
||||
ANIMCMD_FRAME(2, 1),
|
||||
ANIMCMD_JUMP(0),
|
||||
};
|
||||
|
||||
const union AnimCmd gFieldEffectObjectImageAnim_850CBAC[] =
|
||||
const union AnimCmd gSurfBlobAnim_FaceEast[] =
|
||||
{
|
||||
ANIMCMD_FRAME(2, 1, .hFlip = TRUE),
|
||||
ANIMCMD_JUMP(0),
|
||||
@ -150,10 +150,10 @@ const union AnimCmd gFieldEffectObjectImageAnim_850CBAC[] =
|
||||
|
||||
const union AnimCmd *const gFieldEffectObjectImageAnimTable_SurfBlob[] =
|
||||
{
|
||||
gFieldEffectObjectImageAnim_850CB94,
|
||||
gFieldEffectObjectImageAnim_850CB9C,
|
||||
gFieldEffectObjectImageAnim_850CBA4,
|
||||
gFieldEffectObjectImageAnim_850CBAC,
|
||||
gSurfBlobAnim_FaceSouth,
|
||||
gSurfBlobAnim_FaceNorth,
|
||||
gSurfBlobAnim_FaceWest,
|
||||
gSurfBlobAnim_FaceEast,
|
||||
};
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
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[] = {
|
||||
overworld_frame(gFieldEffectObjectPic_Unknown18, 2, 2, 0),
|
||||
@ -587,7 +587,7 @@ const union AnimCmd *const gFieldEffectObjectImageAnimTable_Unknown18[] =
|
||||
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[] = {
|
||||
overworld_frame(gFieldEffectObjectPic_Unknown19, 2, 2, 0),
|
||||
@ -610,7 +610,7 @@ const union AnimCmd *const gFieldEffectObjectImageAnimTable_Unknown19[] =
|
||||
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[] = {
|
||||
overworld_frame(gFieldEffectObjectPic_Unknown29, 2, 1, 0),
|
||||
@ -656,7 +656,7 @@ const union AnimCmd *const gFieldEffectObjectImageAnimTable_Unknown20[] =
|
||||
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[] =
|
||||
{
|
||||
@ -733,7 +733,7 @@ const union AnimCmd *const gFieldEffectObjectImageAnimTable_BerryTreeGrowthSpark
|
||||
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[] = {
|
||||
overworld_frame(gFieldEffectObjectPic_TreeDisguise, 2, 4, 0),
|
||||
|
@ -1347,12 +1347,12 @@ void sub_8128060(u8 taskId)
|
||||
|
||||
void ConfigureCameraObjectForPlacingDecoration(struct PlaceDecorationGraphicsDataBuffer *data, u8 decor)
|
||||
{
|
||||
sDecor_CameraSpriteObjectIdx1 = gSprites[gUnknown_03005DD0.spriteId].data[0];
|
||||
gUnknown_03005DD0.spriteId = gpu_pal_decompress_alloc_tag_and_upload(data, decor);
|
||||
gSprites[gUnknown_03005DD0.spriteId].oam.priority = 1;
|
||||
gSprites[gUnknown_03005DD0.spriteId].callback = sub_81292D0;
|
||||
gSprites[gUnknown_03005DD0.spriteId].pos1.x = gUnknown_085A7250[data->decoration->shape].x;
|
||||
gSprites[gUnknown_03005DD0.spriteId].pos1.y = gUnknown_085A7250[data->decoration->shape].y;
|
||||
sDecor_CameraSpriteObjectIdx1 = gSprites[gFieldCamera.spriteId].data[0];
|
||||
gFieldCamera.spriteId = gpu_pal_decompress_alloc_tag_and_upload(data, decor);
|
||||
gSprites[gFieldCamera.spriteId].oam.priority = 1;
|
||||
gSprites[gFieldCamera.spriteId].callback = sub_81292D0;
|
||||
gSprites[gFieldCamera.spriteId].pos1.x = gUnknown_085A7250[data->decoration->shape].x;
|
||||
gSprites[gFieldCamera.spriteId].pos1.y = gUnknown_085A7250[data->decoration->shape].y;
|
||||
}
|
||||
|
||||
void SetUpPlacingDecorationPlayerAvatar(u8 taskId, struct PlaceDecorationGraphicsDataBuffer *data)
|
||||
@ -1374,7 +1374,7 @@ void SetUpPlacingDecorationPlayerAvatar(u8 taskId, struct PlaceDecorationGraphic
|
||||
}
|
||||
gSprites[sDecor_CameraSpriteObjectIdx2].oam.priority = 1;
|
||||
DestroySprite(&gSprites[sDecor_CameraSpriteObjectIdx1]);
|
||||
sDecor_CameraSpriteObjectIdx1 = gUnknown_03005DD0.spriteId;
|
||||
sDecor_CameraSpriteObjectIdx1 = gFieldCamera.spriteId;
|
||||
}
|
||||
|
||||
void sub_812826C(u8 taskId)
|
||||
@ -2293,9 +2293,9 @@ bool8 sub_81299AC(u8 taskId)
|
||||
void SetUpPuttingAwayDecorationPlayerAvatar(void)
|
||||
{
|
||||
GetPlayerFacingDirection();
|
||||
sDecor_CameraSpriteObjectIdx1 = gSprites[gUnknown_03005DD0.spriteId].data[0];
|
||||
sDecor_CameraSpriteObjectIdx1 = gSprites[gFieldCamera.spriteId].data[0];
|
||||
sub_812A39C();
|
||||
gUnknown_03005DD0.spriteId = CreateSprite(&gUnknown_085A7404, 0x78, 0x50, 0);
|
||||
gFieldCamera.spriteId = CreateSprite(&gUnknown_085A7404, 0x78, 0x50, 0);
|
||||
if (gSaveBlock2Ptr->playerGender == MALE)
|
||||
{
|
||||
sDecor_CameraSpriteObjectIdx2 = AddPseudoEventObject(0xC1, SpriteCallbackDummy, 0x88, 0x48, 0);
|
||||
@ -2306,7 +2306,7 @@ void SetUpPuttingAwayDecorationPlayerAvatar(void)
|
||||
}
|
||||
gSprites[sDecor_CameraSpriteObjectIdx2].oam.priority = 1;
|
||||
DestroySprite(&gSprites[sDecor_CameraSpriteObjectIdx1]);
|
||||
sDecor_CameraSpriteObjectIdx1 = gUnknown_03005DD0.spriteId;
|
||||
sDecor_CameraSpriteObjectIdx1 = gFieldCamera.spriteId;
|
||||
gSprites[sDecor_CameraSpriteObjectIdx1].oam.priority = 1;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -15,71 +15,71 @@
|
||||
EWRAM_DATA bool8 gUnusedBikeCameraAheadPanback = FALSE;
|
||||
|
||||
// Static type declarations
|
||||
struct FieldCameraUnknownStruct
|
||||
struct FieldCameraOffset
|
||||
{
|
||||
u8 unk0;
|
||||
u8 unk1;
|
||||
u8 unk2;
|
||||
u8 unk3;
|
||||
bool8 unk4;
|
||||
u8 xPixelOffset;
|
||||
u8 yPixelOffset;
|
||||
u8 xTileOffset;
|
||||
u8 yTileOffset;
|
||||
bool8 copyBGToVRAM;
|
||||
};
|
||||
|
||||
// static functions
|
||||
static void RedrawMapSliceNorth(struct FieldCameraUnknownStruct *a, const struct MapLayout *mapLayout);
|
||||
static void RedrawMapSliceSouth(struct FieldCameraUnknownStruct *a, const struct MapLayout *mapLayout);
|
||||
static void RedrawMapSliceEast(struct FieldCameraUnknownStruct *a, const struct MapLayout *mapLayout);
|
||||
static void RedrawMapSliceWest(struct FieldCameraUnknownStruct *a, const struct MapLayout *mapLayout);
|
||||
static s32 MapPosToBgTilemapOffset(struct FieldCameraUnknownStruct *a, s32 x, s32 y);
|
||||
static void RedrawMapSliceNorth(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout);
|
||||
static void RedrawMapSliceSouth(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout);
|
||||
static void RedrawMapSliceEast(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout);
|
||||
static void RedrawMapSliceWest(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout);
|
||||
static s32 MapPosToBgTilemapOffset(struct FieldCameraOffset *a, s32 x, s32 y);
|
||||
static void DrawWholeMapViewInternal(int x, int y, const struct MapLayout *mapLayout);
|
||||
static void DrawMetatileAt(const struct MapLayout *mapLayout, u16, int, int);
|
||||
static void DrawMetatile(s32 a, u16 *b, u16 c);
|
||||
static void CameraPanningCB_PanAhead(void);
|
||||
|
||||
// IWRAM bss vars
|
||||
static IWRAM_DATA struct FieldCameraUnknownStruct gUnknown_03000E20;
|
||||
static IWRAM_DATA s16 gUnknown_03000E28;
|
||||
static IWRAM_DATA s16 gUnknown_03000E2A;
|
||||
static IWRAM_DATA struct FieldCameraOffset sFieldCameraOffset;
|
||||
static IWRAM_DATA s16 sHorizontalCameraPan;
|
||||
static IWRAM_DATA s16 sVerticalCameraPan;
|
||||
static IWRAM_DATA u8 gUnknown_03000E2C;
|
||||
static IWRAM_DATA void (*gUnknown_03000E30)(void);
|
||||
static IWRAM_DATA void (*sFieldCameraPanningCallback)(void);
|
||||
|
||||
struct CameraObject gUnknown_03005DD0;
|
||||
u16 gUnknown_03005DE8;
|
||||
u16 gUnknown_03005DEC;
|
||||
struct CameraObject gFieldCamera;
|
||||
u16 gTotalCameraPixelOffsetY;
|
||||
u16 gTotalCameraPixelOffsetX;
|
||||
|
||||
// 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;
|
||||
a->unk3 = 0;
|
||||
a->unk0 = 0;
|
||||
a->unk1 = 0;
|
||||
a->unk4 = TRUE;
|
||||
cameraOffset->xTileOffset = 0;
|
||||
cameraOffset->yTileOffset = 0;
|
||||
cameraOffset->xPixelOffset = 0;
|
||||
cameraOffset->yPixelOffset = 0;
|
||||
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;
|
||||
a->unk2 %= 32;
|
||||
a->unk3 += c;
|
||||
a->unk3 %= 32;
|
||||
cameraOffset->xTileOffset += b;
|
||||
cameraOffset->xTileOffset %= 32;
|
||||
cameraOffset->yTileOffset += c;
|
||||
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;
|
||||
a->unk1 += c;
|
||||
cameraOffset->xPixelOffset += b;
|
||||
cameraOffset->yPixelOffset += c;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
u32 r4, r5;
|
||||
r5 = gUnknown_03000E20.unk0 + gUnknown_03000E28;
|
||||
r4 = gUnknown_03000E2A + gUnknown_03000E20.unk1 + 8;
|
||||
r5 = sFieldCameraOffset.xPixelOffset + sHorizontalCameraPan;
|
||||
r4 = sVerticalCameraPan + sFieldCameraOffset.yPixelOffset + 8;
|
||||
|
||||
SetGpuReg(REG_OFFSET_BG1HOFS, r5);
|
||||
SetGpuReg(REG_OFFSET_BG1VOFS, r4);
|
||||
@ -91,14 +91,14 @@ void FieldUpdateBgTilemapScroll(void)
|
||||
|
||||
void sub_8089C08(s16 *a, s16 *b)
|
||||
{
|
||||
*a = gUnknown_03000E20.unk0 + gUnknown_03000E28;
|
||||
*b = gUnknown_03000E20.unk1 + gUnknown_03000E2A + 8;
|
||||
*a = sFieldCameraOffset.xPixelOffset + sHorizontalCameraPan;
|
||||
*b = sFieldCameraOffset.yPixelOffset + sVerticalCameraPan + 8;
|
||||
}
|
||||
|
||||
void DrawWholeMapView(void)
|
||||
{
|
||||
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)
|
||||
@ -110,13 +110,13 @@ static void DrawWholeMapViewInternal(int x, int y, const struct MapLayout *mapLa
|
||||
|
||||
for (i = 0; i < 32; i += 2)
|
||||
{
|
||||
temp = gUnknown_03000E20.unk3 + i;
|
||||
temp = sFieldCameraOffset.yTileOffset + i;
|
||||
if (temp >= 32)
|
||||
temp -= 32;
|
||||
r6 = temp * 32;
|
||||
for (j = 0; j < 32; j += 2)
|
||||
{
|
||||
temp = gUnknown_03000E20.unk2 + j;
|
||||
temp = sFieldCameraOffset.xTileOffset + j;
|
||||
if (temp >= 32)
|
||||
temp -= 32;
|
||||
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;
|
||||
|
||||
if (x > 0)
|
||||
RedrawMapSliceWest(a, mapLayout);
|
||||
RedrawMapSliceWest(cameraOffset, mapLayout);
|
||||
if (x < 0)
|
||||
RedrawMapSliceEast(a, mapLayout);
|
||||
RedrawMapSliceEast(cameraOffset, mapLayout);
|
||||
if (y > 0)
|
||||
RedrawMapSliceNorth(a, mapLayout);
|
||||
RedrawMapSliceNorth(cameraOffset, mapLayout);
|
||||
if (y < 0)
|
||||
RedrawMapSliceSouth(a, mapLayout);
|
||||
a->unk4 = TRUE;
|
||||
RedrawMapSliceSouth(cameraOffset, mapLayout);
|
||||
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 temp;
|
||||
u32 r7;
|
||||
|
||||
temp = a->unk3 + 28;
|
||||
temp = cameraOffset->yTileOffset + 28;
|
||||
if (temp >= 32)
|
||||
temp -= 32;
|
||||
r7 = temp * 32;
|
||||
for (i = 0; i < 32; i += 2)
|
||||
{
|
||||
temp = a->unk2 + i;
|
||||
temp = cameraOffset->xTileOffset + i;
|
||||
if (temp >= 32)
|
||||
temp -= 32;
|
||||
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 temp;
|
||||
u32 r7 = a->unk3 * 32;
|
||||
u32 r7 = cameraOffset->yTileOffset * 32;
|
||||
|
||||
for (i = 0; i < 32; i += 2)
|
||||
{
|
||||
temp = a->unk2 + i;
|
||||
temp = cameraOffset->xTileOffset + i;
|
||||
if (temp >= 32)
|
||||
temp -= 32;
|
||||
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 temp;
|
||||
u32 r6 = a->unk2;
|
||||
u32 r6 = cameraOffset->xTileOffset;
|
||||
|
||||
for (i = 0; i < 32; i += 2)
|
||||
{
|
||||
temp = a->unk3 + i;
|
||||
temp = cameraOffset->yTileOffset + i;
|
||||
if (temp >= 32)
|
||||
temp -= 32;
|
||||
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 temp;
|
||||
u8 r5 = a->unk2 + 28;
|
||||
u8 r5 = cameraOffset->xTileOffset + 28;
|
||||
|
||||
if (r5 >= 32)
|
||||
r5 -= 32;
|
||||
for (i = 0; i < 32; i += 2)
|
||||
{
|
||||
temp = a->unk3 + i;
|
||||
temp = cameraOffset->yTileOffset + i;
|
||||
if (temp >= 32)
|
||||
temp -= 32;
|
||||
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)
|
||||
{
|
||||
DrawMetatileAt(gMapHeader.mapLayout, offset, a, b);
|
||||
gUnknown_03000E20.unk4 = TRUE;
|
||||
DrawMetatileAt(gMapHeader.mapLayout, offset, x, y);
|
||||
sFieldCameraOffset.copyBGToVRAM = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void DrawDoorMetatileAt(int x, int y, u16 *arr)
|
||||
{
|
||||
int offset = MapPosToBgTilemapOffset(&gUnknown_03000E20, x, y);
|
||||
int offset = MapPosToBgTilemapOffset(&sFieldCameraOffset, x, y);
|
||||
|
||||
if (offset >= 0)
|
||||
{
|
||||
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;
|
||||
|
||||
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;
|
||||
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:
|
||||
gBGTilemapBuffers3[c] = b[0];
|
||||
gBGTilemapBuffers3[c + 1] = b[1];
|
||||
gBGTilemapBuffers3[c + 0x20] = b[2];
|
||||
gBGTilemapBuffers3[c + 0x21] = b[3];
|
||||
case 2: // LAYER_TYPE_
|
||||
// Draw metatile's bottom layer to the bottom background layer.
|
||||
gBGTilemapBuffers3[offset] = metatiles[0];
|
||||
gBGTilemapBuffers3[offset + 1] = metatiles[1];
|
||||
gBGTilemapBuffers3[offset + 0x20] = metatiles[2];
|
||||
gBGTilemapBuffers3[offset + 0x21] = metatiles[3];
|
||||
|
||||
gBGTilemapBuffers1[c] = 0;
|
||||
gBGTilemapBuffers1[c + 1] = 0;
|
||||
gBGTilemapBuffers1[c + 0x20] = 0;
|
||||
gBGTilemapBuffers1[c + 0x21] = 0;
|
||||
// Draw transparent tiles to the middle background layer.
|
||||
gBGTilemapBuffers1[offset] = 0;
|
||||
gBGTilemapBuffers1[offset + 1] = 0;
|
||||
gBGTilemapBuffers1[offset + 0x20] = 0;
|
||||
gBGTilemapBuffers1[offset + 0x21] = 0;
|
||||
|
||||
gBGTilemapBuffers2[c] = b[4];
|
||||
gBGTilemapBuffers2[c + 1] = b[5];
|
||||
gBGTilemapBuffers2[c + 0x20] = b[6];
|
||||
gBGTilemapBuffers2[c + 0x21] = b[7];
|
||||
// Draw metatile's top layer to the top background layer.
|
||||
gBGTilemapBuffers2[offset] = metatiles[4];
|
||||
gBGTilemapBuffers2[offset + 1] = metatiles[5];
|
||||
gBGTilemapBuffers2[offset + 0x20] = metatiles[6];
|
||||
gBGTilemapBuffers2[offset + 0x21] = metatiles[7];
|
||||
break;
|
||||
case 1:
|
||||
gBGTilemapBuffers3[c] = b[0];
|
||||
gBGTilemapBuffers3[c + 1] = b[1];
|
||||
gBGTilemapBuffers3[c + 0x20] = b[2];
|
||||
gBGTilemapBuffers3[c + 0x21] = b[3];
|
||||
case 1: // LAYER_TYPE_COVERED_BY_OBJECTS
|
||||
// Draw metatile's bottom layer to the bottom background layer.
|
||||
gBGTilemapBuffers3[offset] = metatiles[0];
|
||||
gBGTilemapBuffers3[offset + 1] = metatiles[1];
|
||||
gBGTilemapBuffers3[offset + 0x20] = metatiles[2];
|
||||
gBGTilemapBuffers3[offset + 0x21] = metatiles[3];
|
||||
|
||||
gBGTilemapBuffers1[c] = b[4];
|
||||
gBGTilemapBuffers1[c + 1] = b[5];
|
||||
gBGTilemapBuffers1[c + 0x20] = b[6];
|
||||
gBGTilemapBuffers1[c + 0x21] = b[7];
|
||||
// Draw metatile's top layer to the middle background layer.
|
||||
gBGTilemapBuffers1[offset] = metatiles[4];
|
||||
gBGTilemapBuffers1[offset + 1] = metatiles[5];
|
||||
gBGTilemapBuffers1[offset + 0x20] = metatiles[6];
|
||||
gBGTilemapBuffers1[offset + 0x21] = metatiles[7];
|
||||
|
||||
gBGTilemapBuffers2[c] = 0;
|
||||
gBGTilemapBuffers2[c + 1] = 0;
|
||||
gBGTilemapBuffers2[c + 0x20] = 0;
|
||||
gBGTilemapBuffers2[c + 0x21] = 0;
|
||||
// Draw transparent tiles to the top background layer.
|
||||
gBGTilemapBuffers2[offset] = 0;
|
||||
gBGTilemapBuffers2[offset + 1] = 0;
|
||||
gBGTilemapBuffers2[offset + 0x20] = 0;
|
||||
gBGTilemapBuffers2[offset + 0x21] = 0;
|
||||
break;
|
||||
case 0:
|
||||
gBGTilemapBuffers3[c] = 0x3014;
|
||||
gBGTilemapBuffers3[c + 1] = 0x3014;
|
||||
gBGTilemapBuffers3[c + 0x20] = 0x3014;
|
||||
gBGTilemapBuffers3[c + 0x21] = 0x3014;
|
||||
case 0: // LAYER_TYPE_NORMAL
|
||||
// Draw garbage to the bottom background layer.
|
||||
gBGTilemapBuffers3[offset] = 0x3014;
|
||||
gBGTilemapBuffers3[offset + 1] = 0x3014;
|
||||
gBGTilemapBuffers3[offset + 0x20] = 0x3014;
|
||||
gBGTilemapBuffers3[offset + 0x21] = 0x3014;
|
||||
|
||||
gBGTilemapBuffers1[c] = b[0];
|
||||
gBGTilemapBuffers1[c + 1] = b[1];
|
||||
gBGTilemapBuffers1[c + 0x20] = b[2];
|
||||
gBGTilemapBuffers1[c + 0x21] = b[3];
|
||||
// Draw metatile's bottom layer to the middle background layer.
|
||||
gBGTilemapBuffers1[offset] = metatiles[0];
|
||||
gBGTilemapBuffers1[offset + 1] = metatiles[1];
|
||||
gBGTilemapBuffers1[offset + 0x20] = metatiles[2];
|
||||
gBGTilemapBuffers1[offset + 0x21] = metatiles[3];
|
||||
|
||||
gBGTilemapBuffers2[c] = b[4];
|
||||
gBGTilemapBuffers2[c + 1] = b[5];
|
||||
gBGTilemapBuffers2[c + 0x20] = b[6];
|
||||
gBGTilemapBuffers2[c + 0x21] = b[7];
|
||||
// Draw metatile's top layer to the top background layer, which covers event object sprites.
|
||||
gBGTilemapBuffers2[offset] = metatiles[4];
|
||||
gBGTilemapBuffers2[offset + 1] = metatiles[5];
|
||||
gBGTilemapBuffers2[offset + 0x20] = metatiles[6];
|
||||
gBGTilemapBuffers2[offset + 0x21] = metatiles[7];
|
||||
break;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
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 *= 2;
|
||||
if (x >= 32 || x < 0)
|
||||
return -1;
|
||||
x = x + a->unk2;
|
||||
x = x + cameraOffset->xTileOffset;
|
||||
if (x >= 32)
|
||||
x -= 32;
|
||||
|
||||
y = (y - gSaveBlock1Ptr->pos.y) * 2;
|
||||
if (y >= 32 || y < 0)
|
||||
return -1;
|
||||
y = y + a->unk3;
|
||||
y = y + cameraOffset->yTileOffset;
|
||||
if (y >= 32)
|
||||
y -= 32;
|
||||
|
||||
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];
|
||||
a->unkC = gSprites[a->spriteId].data[3];
|
||||
fieldCamera->movementSpeedX = gSprites[fieldCamera->spriteId].data[2];
|
||||
fieldCamera->movementSpeedY = gSprites[fieldCamera->spriteId].data[3];
|
||||
}
|
||||
}
|
||||
|
||||
void ResetCameraUpdateInfo(void)
|
||||
{
|
||||
gUnknown_03005DD0.unk8 = 0;
|
||||
gUnknown_03005DD0.unkC = 0;
|
||||
gUnknown_03005DD0.x = 0;
|
||||
gUnknown_03005DD0.y = 0;
|
||||
gUnknown_03005DD0.spriteId = 0;
|
||||
gUnknown_03005DD0.callback = NULL;
|
||||
gFieldCamera.movementSpeedX = 0;
|
||||
gFieldCamera.movementSpeedY = 0;
|
||||
gFieldCamera.x = 0;
|
||||
gFieldCamera.y = 0;
|
||||
gFieldCamera.spriteId = 0;
|
||||
gFieldCamera.callback = NULL;
|
||||
}
|
||||
|
||||
u32 InitCameraUpdateCallback(u8 a)
|
||||
u32 InitCameraUpdateCallback(u8 trackedSpriteId)
|
||||
{
|
||||
if (gUnknown_03005DD0.spriteId != 0)
|
||||
DestroySprite(&gSprites[gUnknown_03005DD0.spriteId]);
|
||||
gUnknown_03005DD0.spriteId = AddCameraObject(a);
|
||||
gUnknown_03005DD0.callback = CameraUpdateCallback;
|
||||
if (gFieldCamera.spriteId != 0)
|
||||
DestroySprite(&gSprites[gFieldCamera.spriteId]);
|
||||
gFieldCamera.spriteId = AddCameraObject(trackedSpriteId);
|
||||
gFieldCamera.callback = CameraUpdateCallback;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -354,54 +363,54 @@ void CameraUpdate(void)
|
||||
{
|
||||
int deltaX;
|
||||
int deltaY;
|
||||
int r0;
|
||||
int r1;
|
||||
int r7;
|
||||
int r8;
|
||||
int curMovementOffsetY;
|
||||
int curMovementOffsetX;
|
||||
int movementSpeedX;
|
||||
int movementSpeedY;
|
||||
|
||||
if (gUnknown_03005DD0.callback != NULL)
|
||||
gUnknown_03005DD0.callback(&gUnknown_03005DD0);
|
||||
r7 = gUnknown_03005DD0.unk8;
|
||||
r8 = gUnknown_03005DD0.unkC;
|
||||
if (gFieldCamera.callback != NULL)
|
||||
gFieldCamera.callback(&gFieldCamera);
|
||||
movementSpeedX = gFieldCamera.movementSpeedX;
|
||||
movementSpeedY = gFieldCamera.movementSpeedY;
|
||||
deltaX = 0;
|
||||
deltaY = 0;
|
||||
r1 = gUnknown_03005DD0.x;
|
||||
r0 = gUnknown_03005DD0.y;
|
||||
curMovementOffsetX = gFieldCamera.x;
|
||||
curMovementOffsetY = gFieldCamera.y;
|
||||
|
||||
|
||||
if (r1 == 0 && r7 != 0)
|
||||
if (curMovementOffsetX == 0 && movementSpeedX != 0)
|
||||
{
|
||||
if (r7 > 0)
|
||||
if (movementSpeedX > 0)
|
||||
deltaX = 1;
|
||||
else
|
||||
deltaX = -1;
|
||||
}
|
||||
if (r0 == 0 && r8 != 0)
|
||||
if (curMovementOffsetY == 0 && movementSpeedY != 0)
|
||||
{
|
||||
if (r8 > 0)
|
||||
if (movementSpeedY > 0)
|
||||
deltaY = 1;
|
||||
else
|
||||
deltaY = -1;
|
||||
}
|
||||
if (r1 != 0 && r1 == -r7)
|
||||
if (curMovementOffsetX != 0 && curMovementOffsetX == -movementSpeedX)
|
||||
{
|
||||
if (r7 > 0)
|
||||
if (movementSpeedX > 0)
|
||||
deltaX = 1;
|
||||
else
|
||||
deltaX = -1;
|
||||
}
|
||||
if (r0 != 0 && r0 == -r8)
|
||||
if (curMovementOffsetY != 0 && curMovementOffsetY == -movementSpeedY)
|
||||
{
|
||||
if (r8 > 0)
|
||||
if (movementSpeedY > 0)
|
||||
deltaX = 1;
|
||||
else
|
||||
deltaX = -1;
|
||||
}
|
||||
|
||||
gUnknown_03005DD0.x += r7;
|
||||
gUnknown_03005DD0.x = gUnknown_03005DD0.x - 16 * (gUnknown_03005DD0.x / 16);
|
||||
gUnknown_03005DD0.y += r8;
|
||||
gUnknown_03005DD0.y = gUnknown_03005DD0.y - 16 * (gUnknown_03005DD0.y / 16);
|
||||
gFieldCamera.x += movementSpeedX;
|
||||
gFieldCamera.x = gFieldCamera.x - 16 * (gFieldCamera.x / 16);
|
||||
gFieldCamera.y += movementSpeedY;
|
||||
gFieldCamera.y = gFieldCamera.y - 16 * (gFieldCamera.y / 16);
|
||||
|
||||
if (deltaX != 0 || deltaY != 0)
|
||||
{
|
||||
@ -409,50 +418,50 @@ void CameraUpdate(void)
|
||||
UpdateEventObjectsForCameraUpdate(deltaX, deltaY);
|
||||
RotatingGatePuzzleCameraUpdate(deltaX, deltaY);
|
||||
ResetBerryTreeSparkleFlags();
|
||||
tilemap_move_something(&gUnknown_03000E20, deltaX * 2, deltaY * 2);
|
||||
RedrawMapSlicesForCameraUpdate(&gUnknown_03000E20, deltaX * 2, deltaY * 2);
|
||||
tilemap_move_something(&sFieldCameraOffset, deltaX * 2, deltaY * 2);
|
||||
RedrawMapSlicesForCameraUpdate(&sFieldCameraOffset, deltaX * 2, deltaY * 2);
|
||||
}
|
||||
|
||||
coords8_add(&gUnknown_03000E20, r7, r8);
|
||||
gUnknown_03005DEC -= r7;
|
||||
gUnknown_03005DE8 -= r8;
|
||||
coords8_add(&sFieldCameraOffset, movementSpeedX, movementSpeedY);
|
||||
gTotalCameraPixelOffsetX -= movementSpeedX;
|
||||
gTotalCameraPixelOffsetY -= movementSpeedY;
|
||||
}
|
||||
|
||||
void camera_move_and_redraw(int a, int b) //unused
|
||||
void MoveCameraAndRedrawMap(int deltaX, int deltaY) //unused
|
||||
{
|
||||
CameraMove(a, b);
|
||||
UpdateEventObjectsForCameraUpdate(a, b);
|
||||
CameraMove(deltaX, deltaY);
|
||||
UpdateEventObjectsForCameraUpdate(deltaX, deltaY);
|
||||
DrawWholeMapView();
|
||||
gUnknown_03005DEC -= a * 16;
|
||||
gUnknown_03005DE8 -= b * 16;
|
||||
gTotalCameraPixelOffsetX -= deltaX * 16;
|
||||
gTotalCameraPixelOffsetY -= deltaY * 16;
|
||||
}
|
||||
|
||||
void SetCameraPanningCallback(void (*a)(void))
|
||||
{
|
||||
gUnknown_03000E30 = a;
|
||||
sFieldCameraPanningCallback = a;
|
||||
}
|
||||
|
||||
void SetCameraPanning(s16 a, s16 b)
|
||||
{
|
||||
gUnknown_03000E28 = a;
|
||||
gUnknown_03000E2A = b + 32;
|
||||
sHorizontalCameraPan = a;
|
||||
sVerticalCameraPan = b + 32;
|
||||
}
|
||||
|
||||
void InstallCameraPanAheadCallback(void)
|
||||
{
|
||||
gUnknown_03000E30 = CameraPanningCB_PanAhead;
|
||||
sFieldCameraPanningCallback = CameraPanningCB_PanAhead;
|
||||
gUnknown_03000E2C = 0;
|
||||
gUnknown_03000E28 = 0;
|
||||
gUnknown_03000E2A = 32;
|
||||
sHorizontalCameraPan = 0;
|
||||
sVerticalCameraPan = 32;
|
||||
}
|
||||
|
||||
void UpdateCameraPanning(void)
|
||||
{
|
||||
if (gUnknown_03000E30 != NULL)
|
||||
gUnknown_03000E30();
|
||||
if (sFieldCameraPanningCallback != NULL)
|
||||
sFieldCameraPanningCallback();
|
||||
//Update sprite offset of overworld objects
|
||||
gSpriteCoordOffsetX = gUnknown_03005DEC - gUnknown_03000E28;
|
||||
gSpriteCoordOffsetY = gUnknown_03005DE8 - gUnknown_03000E2A - 8;
|
||||
gSpriteCoordOffsetX = gTotalCameraPixelOffsetX - sHorizontalCameraPan;
|
||||
gSpriteCoordOffsetY = gTotalCameraPixelOffsetY - sVerticalCameraPan - 8;
|
||||
}
|
||||
|
||||
static void CameraPanningCB_PanAhead(void)
|
||||
@ -480,22 +489,21 @@ static void CameraPanningCB_PanAhead(void)
|
||||
var = GetPlayerMovementDirection();
|
||||
if (var == 2)
|
||||
{
|
||||
if (gUnknown_03000E2A > -8)
|
||||
gUnknown_03000E2A -= 2;
|
||||
if (sVerticalCameraPan > -8)
|
||||
sVerticalCameraPan -= 2;
|
||||
}
|
||||
else if (var == 1)
|
||||
{
|
||||
if (gUnknown_03000E2A < 72)
|
||||
gUnknown_03000E2A += 2;
|
||||
if (sVerticalCameraPan < 72)
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys)
|
||||
input->dpadDirection = DIR_EAST;
|
||||
}
|
||||
|
||||
int sub_809C014(struct FieldInput *input)
|
||||
int ProcessPlayerFieldInput(struct FieldInput *input)
|
||||
{
|
||||
struct MapPosition position;
|
||||
u8 playerDirection;
|
||||
|
@ -1,10 +1,9 @@
|
||||
#include "global.h"
|
||||
#include "field_effect.h"
|
||||
#include "trainer_pokemon_sprites.h"
|
||||
#include "decompress.h"
|
||||
#include "field_camera.h"
|
||||
#include "field_effect_helpers.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_screen.h"
|
||||
#include "field_weather.h"
|
||||
@ -22,8 +21,10 @@
|
||||
#include "sound.h"
|
||||
#include "sprite.h"
|
||||
#include "task.h"
|
||||
#include "trainer_pokemon_sprites.h"
|
||||
#include "trig.h"
|
||||
#include "util.h"
|
||||
#include "constants/event_object_movement_constants.h"
|
||||
#include "constants/rgb.h"
|
||||
#include "constants/songs.h"
|
||||
|
||||
@ -322,9 +323,9 @@ bool8 (*const gUnknown_0855C460[])(struct Task *, struct EventObject *, struct S
|
||||
sub_80B7BF4,
|
||||
};
|
||||
|
||||
void (*const gUnknown_0855C474[])(struct Task *) = {
|
||||
sub_80B7D14,
|
||||
sub_80B7D34,
|
||||
void (*const gEscapeRopeFieldEffectFuncs[])(struct Task *) = {
|
||||
EscapeRopeFieldEffect_Step0,
|
||||
EscapeRopeFieldEffect_Step1,
|
||||
};
|
||||
|
||||
// .text
|
||||
@ -1686,7 +1687,7 @@ bool8 sub_80B7478(struct Task *task, struct EventObject *eventObject)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void Task_Dive(u8);
|
||||
static void Task_Dive(u8);
|
||||
extern int dive_warp(struct MapPosition *, u16);
|
||||
|
||||
bool8 FldEff_UseDive(void)
|
||||
@ -1999,7 +2000,7 @@ bool8 sub_80B7BCC(struct Task *task, struct EventObject *eventObject, struct Spr
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void sub_80B7CE4(u8);
|
||||
static void DoEscapeRopeFieldEffect(u8);
|
||||
void mapldr_080859D4(void);
|
||||
|
||||
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();
|
||||
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[14] = 64;
|
||||
task->data[15] = GetPlayerFacingDirection();
|
||||
}
|
||||
|
||||
void sub_80B7D34(struct Task *task)
|
||||
static void EscapeRopeFieldEffect_Step1(struct Task *task)
|
||||
{
|
||||
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)
|
||||
{
|
||||
music_something();
|
||||
@ -2070,7 +2071,7 @@ void sub_80B7D34(struct Task *task)
|
||||
WarpIntoMap();
|
||||
gFieldCallback = mapldr_080859D4;
|
||||
SetMainCallback2(CB2_LoadMap);
|
||||
DestroyTask(FindTaskIdByFunc(sub_80B7CE4));
|
||||
DestroyTask(FindTaskIdByFunc(DoEscapeRopeFieldEffect));
|
||||
} else if (task->data[1] == 0 || (--task->data[1]) == 0)
|
||||
{
|
||||
EventObjectSetHeldMovement(eventObject, GetFaceDirectionMovementAction(spinDirections[eventObject->facingDirection]));
|
||||
@ -2905,7 +2906,7 @@ void sub_80B8E14(struct Task *task)
|
||||
if (!EventObjectIsMovementOverridden(eventObject) || EventObjectClearHeldMovementIfFinished(eventObject))
|
||||
{
|
||||
sub_808C114();
|
||||
EventObjectSetHeldMovement(eventObject, 0x39);
|
||||
EventObjectSetHeldMovement(eventObject, MOVEMENT_ACTION_START_ANIM_IN_DIRECTION);
|
||||
task->data[0]++;
|
||||
}
|
||||
}
|
||||
@ -3210,7 +3211,7 @@ void sub_80B9204(struct Task *task)
|
||||
gPlayerAvatar.preventStep = TRUE;
|
||||
SetPlayerAvatarStateMask(1);
|
||||
sub_808C114();
|
||||
EventObjectSetHeldMovement(eventObject, 0x39);
|
||||
EventObjectSetHeldMovement(eventObject, MOVEMENT_ACTION_START_ANIM_IN_DIRECTION);
|
||||
task->data[0]++;
|
||||
}
|
||||
}
|
||||
@ -3250,7 +3251,7 @@ void sub_80B92F8(struct Task *task)
|
||||
task->data[0]++;
|
||||
task->data[2] = 16;
|
||||
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));
|
||||
StartSpriteAnim(&gSprites[eventObject->spriteId], 0x16);
|
||||
eventObject->inanimate = 1;
|
||||
EventObjectSetHeldMovement(eventObject, 0x48);
|
||||
EventObjectSetHeldMovement(eventObject, MOVEMENT_ACTION_JUMP_IN_PLACE_LEFT);
|
||||
if (task->data[15] & 0x08)
|
||||
{
|
||||
DestroySprite(&gSprites[eventObject->fieldEffectSpriteId]);
|
||||
@ -3585,7 +3586,7 @@ void sub_80B9978(struct Task *task)
|
||||
sprite->pos2.y = 0;
|
||||
sprite->coordOffsetEnabled = 1;
|
||||
sub_808C114();
|
||||
EventObjectSetHeldMovement(eventObject, 0x39);
|
||||
EventObjectSetHeldMovement(eventObject, MOVEMENT_ACTION_START_ANIM_IN_DIRECTION);
|
||||
task->data[0]++;
|
||||
}
|
||||
}
|
||||
@ -3791,8 +3792,8 @@ const struct SpriteTemplate gUnknown_0855C5EC = {
|
||||
void sub_80B9D24(struct Sprite* sprite)
|
||||
{
|
||||
int i;
|
||||
int xPos = (s16)gUnknown_03005DEC + sprite->pos1.x + sprite->pos2.x;
|
||||
int yPos = (s16)gUnknown_03005DE8 + sprite->pos1.y + sprite->pos2.y - 4;
|
||||
int xPos = (s16)gTotalCameraPixelOffsetX + sprite->pos1.x + sprite->pos2.x;
|
||||
int yPos = (s16)gTotalCameraPixelOffsetY + sprite->pos1.y + sprite->pos2.y - 4;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
|
@ -14,22 +14,22 @@
|
||||
|
||||
#define EVENT_OBJ_PAL_TAG_NONE 0x11FF // duplicate of define in event_object_movement.c
|
||||
|
||||
void UpdateObjectReflectionSprite(struct Sprite *);
|
||||
void LoadObjectReflectionPalette(struct EventObject *eventObject, struct Sprite *sprite);
|
||||
void LoadObjectHighBridgeReflectionPalette(struct EventObject *, u8);
|
||||
void LoadObjectRegularReflectionPalette(struct EventObject *, u8);
|
||||
void sub_81561FC(struct Sprite *, u8, u8);
|
||||
void FadeFootprintsTireTracks_Step0(struct Sprite *);
|
||||
void FadeFootprintsTireTracks_Step1(struct Sprite *);
|
||||
void UpdateFeetInFlowingWaterFieldEffect(struct Sprite *);
|
||||
void UpdateAshFieldEffect_Step0(struct Sprite *);
|
||||
void UpdateAshFieldEffect_Step1(struct Sprite *);
|
||||
void UpdateAshFieldEffect_Step2(struct Sprite *);
|
||||
void sub_81556B0(struct EventObject *, struct Sprite *);
|
||||
void sub_81556E8(struct EventObject *, struct Sprite *);
|
||||
void sub_815577C(struct EventObject *, struct Sprite *, struct Sprite *);
|
||||
void sub_8155850(struct Sprite *);
|
||||
u32 ShowDisguiseFieldEffect(u8, u8, u8);
|
||||
static void UpdateObjectReflectionSprite(struct Sprite *);
|
||||
static void LoadObjectReflectionPalette(struct EventObject *eventObject, struct Sprite *sprite);
|
||||
static void LoadObjectHighBridgeReflectionPalette(struct EventObject *, u8);
|
||||
static void LoadObjectRegularReflectionPalette(struct EventObject *, u8);
|
||||
static void sub_81561FC(struct Sprite *, u8, u8);
|
||||
static void FadeFootprintsTireTracks_Step0(struct Sprite *);
|
||||
static void FadeFootprintsTireTracks_Step1(struct Sprite *);
|
||||
static void UpdateFeetInFlowingWaterFieldEffect(struct Sprite *);
|
||||
static void UpdateAshFieldEffect_Step0(struct Sprite *);
|
||||
static void UpdateAshFieldEffect_Step1(struct Sprite *);
|
||||
static void UpdateAshFieldEffect_Step2(struct Sprite *);
|
||||
static void SynchroniseSurfAnim(struct EventObject *, struct Sprite *);
|
||||
static void sub_81556E8(struct EventObject *, struct Sprite *);
|
||||
static void CreateBobbingEffect(struct EventObject *, struct Sprite *, struct Sprite *);
|
||||
static void sub_8155850(struct Sprite *);
|
||||
static u32 ShowDisguiseFieldEffect(u8, u8, u8);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void LoadObjectReflectionPalette(struct EventObject *eventObject, struct Sprite *sprite)
|
||||
static void LoadObjectReflectionPalette(struct EventObject *eventObject, struct Sprite *sprite)
|
||||
{
|
||||
u8 bridgeType;
|
||||
u16 bridgeReflectionVerticalOffsets[] = { 12, 28, 44 };
|
||||
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];
|
||||
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;
|
||||
|
||||
@ -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.
|
||||
// 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;
|
||||
|
||||
@ -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 Sprite *mainSprite;
|
||||
@ -579,7 +579,7 @@ void UpdateFootprintsTireTracksFieldEffect(struct Sprite *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.
|
||||
if (++sprite->data[1] > 40)
|
||||
@ -588,7 +588,7 @@ void FadeFootprintsTireTracks_Step0(struct Sprite *sprite)
|
||||
UpdateEventObjectSpriteVisibility(sprite, FALSE);
|
||||
}
|
||||
|
||||
void FadeFootprintsTireTracks_Step1(struct Sprite *sprite)
|
||||
static void FadeFootprintsTireTracks_Step1(struct Sprite *sprite)
|
||||
{
|
||||
sprite->invisible ^= 1;
|
||||
sprite->data[1]++;
|
||||
@ -708,7 +708,7 @@ u32 FldEff_FeetInFlowingWater(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void UpdateFeetInFlowingWaterFieldEffect(struct Sprite *sprite)
|
||||
static void UpdateFeetInFlowingWaterFieldEffect(struct Sprite *sprite)
|
||||
{
|
||||
u8 eventObjectId;
|
||||
struct Sprite *linkedSprite;
|
||||
@ -913,7 +913,7 @@ void UpdateAshFieldEffect(struct Sprite *sprite)
|
||||
gAshFieldEffectFuncs[sprite->data[0]](sprite);
|
||||
}
|
||||
|
||||
void UpdateAshFieldEffect_Step0(struct Sprite *sprite)
|
||||
static void UpdateAshFieldEffect_Step0(struct Sprite *sprite)
|
||||
{
|
||||
sprite->invisible = TRUE;
|
||||
sprite->animPaused = TRUE;
|
||||
@ -921,7 +921,7 @@ void UpdateAshFieldEffect_Step0(struct Sprite *sprite)
|
||||
sprite->data[0] = 1;
|
||||
}
|
||||
|
||||
void UpdateAshFieldEffect_Step1(struct Sprite *sprite)
|
||||
static void UpdateAshFieldEffect_Step1(struct Sprite *sprite)
|
||||
{
|
||||
sprite->invisible = FALSE;
|
||||
sprite->animPaused = FALSE;
|
||||
@ -931,7 +931,7 @@ void UpdateAshFieldEffect_Step1(struct Sprite *sprite)
|
||||
sprite->data[0] = 2;
|
||||
}
|
||||
|
||||
void UpdateAshFieldEffect_Step2(struct Sprite *sprite)
|
||||
static void UpdateAshFieldEffect_Step2(struct Sprite *sprite)
|
||||
{
|
||||
UpdateEventObjectSpriteVisibility(sprite, FALSE);
|
||||
if (sprite->animEnded)
|
||||
@ -975,17 +975,17 @@ void sub_8155604(u8 spriteId, u8 value, s16 data1)
|
||||
gSprites[spriteId].data[1] = data1;
|
||||
}
|
||||
|
||||
u8 sub_8155638(struct Sprite *sprite)
|
||||
static u8 sub_8155638(struct Sprite *sprite)
|
||||
{
|
||||
return sprite->data[0] & 0xF;
|
||||
}
|
||||
|
||||
u8 sub_8155640(struct Sprite *sprite)
|
||||
static u8 sub_8155640(struct Sprite *sprite)
|
||||
{
|
||||
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;
|
||||
}
|
||||
@ -997,13 +997,13 @@ void UpdateSurfBlobFieldEffect(struct Sprite *sprite)
|
||||
|
||||
eventObject = &gEventObjects[sprite->data[2]];
|
||||
linkedSprite = &gSprites[eventObject->spriteId];
|
||||
sub_81556B0(eventObject, sprite);
|
||||
SynchroniseSurfAnim(eventObject, sprite);
|
||||
sub_81556E8(eventObject, sprite);
|
||||
sub_815577C(eventObject, linkedSprite, sprite);
|
||||
CreateBobbingEffect(eventObject, linkedSprite, sprite);
|
||||
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[] = {
|
||||
0, // DIR_NONE
|
||||
@ -1126,7 +1126,7 @@ _08155770:\n\
|
||||
}
|
||||
#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};
|
||||
u8 v0 = sub_8155638(sprite);
|
||||
@ -1166,7 +1166,7 @@ u8 sub_8155800(u8 oldSpriteId)
|
||||
return spriteId;
|
||||
}
|
||||
|
||||
void sub_8155850(struct Sprite *sprite)
|
||||
static void sub_8155850(struct Sprite *sprite)
|
||||
{
|
||||
struct Sprite *oldSprite;
|
||||
|
||||
@ -1320,7 +1320,7 @@ u32 ShowSandDisguiseFieldEffect(void)
|
||||
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;
|
||||
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)
|
||||
FieldEffectStop(sprite, sprite->data[0]);
|
||||
@ -1628,7 +1628,7 @@ void sub_81561D0(struct Sprite *sprite)
|
||||
}
|
||||
|
||||
#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;
|
||||
s16 xlo;
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "constants/species.h"
|
||||
|
||||
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 = {};
|
||||
|
||||
static void StartStrengthAnim(u8, u8);
|
||||
@ -123,7 +123,7 @@ static u8 Fishing14(struct Task *task);
|
||||
static u8 Fishing15(struct Task *task);
|
||||
static u8 Fishing16(struct Task *task);
|
||||
|
||||
static bool8 (*const gUnknown_084973FC[])(u8) =
|
||||
static bool8 (*const sForcedMovementTestFuncs[])(u8) =
|
||||
{
|
||||
MetatileBehavior_IsTrickHouseSlipperyFloor,
|
||||
MetatileBehavior_IsIce_2,
|
||||
@ -145,7 +145,7 @@ static bool8 (*const gUnknown_084973FC[])(u8) =
|
||||
MetatileBehavior_IsMuddySlope,
|
||||
};
|
||||
|
||||
static bool8 (*const gUnknown_08497444[])(void) =
|
||||
static bool8 (*const sForcedMovementFuncs[])(void) =
|
||||
{
|
||||
ForcedMovement_None,
|
||||
ForcedMovement_Slip,
|
||||
@ -285,12 +285,12 @@ static bool8 (*const sPlayerAvatarSecretBaseMatSpin[])(struct Task *, struct Eve
|
||||
// .text
|
||||
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)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void player_step(u8 direction, u16 newKeys, u16 heldKeys)
|
||||
@ -380,7 +380,7 @@ static void PlayerAllowForcedMovementIfMovingSameDirection(void)
|
||||
|
||||
static bool8 TryDoMetatileBehaviorForcedMovement(void)
|
||||
{
|
||||
return gUnknown_08497444[GetForcedMovementByMetatileBehavior()]();
|
||||
return sForcedMovementFuncs[GetForcedMovementByMetatileBehavior()]();
|
||||
}
|
||||
|
||||
static u8 GetForcedMovementByMetatileBehavior(void)
|
||||
@ -393,7 +393,7 @@ static u8 GetForcedMovementByMetatileBehavior(void)
|
||||
|
||||
for (i = 0; i < 18; i++)
|
||||
{
|
||||
if (gUnknown_084973FC[i](metatileBehavior))
|
||||
if (sForcedMovementTestFuncs[i](metatileBehavior))
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
@ -622,7 +622,7 @@ static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys)
|
||||
|
||||
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);
|
||||
return;
|
||||
}
|
||||
@ -1700,7 +1700,7 @@ static bool8 (*const sFishingStateFuncs[])(struct Task *) =
|
||||
};
|
||||
|
||||
static void Task_Fishing(u8 taskId);
|
||||
static void sub_808CF78(void);
|
||||
static void AlignFishingAnimationFrames(void);
|
||||
|
||||
#define tStep data[0]
|
||||
#define tFrameCounter data[1]
|
||||
@ -1759,7 +1759,7 @@ static bool8 Fishing2(struct Task *task)
|
||||
|
||||
static bool8 Fishing3(struct Task *task)
|
||||
{
|
||||
sub_808CF78();
|
||||
AlignFishingAnimationFrames();
|
||||
|
||||
// Wait one second
|
||||
task->tFrameCounter++;
|
||||
@ -1791,7 +1791,7 @@ static bool8 Fishing5(struct Task *task)
|
||||
{
|
||||
const u8 dot[] = _("·");
|
||||
|
||||
sub_808CF78();
|
||||
AlignFishingAnimationFrames();
|
||||
task->tFrameCounter++;
|
||||
if (gMain.newKeys & A_BUTTON)
|
||||
{
|
||||
@ -1827,7 +1827,7 @@ static bool8 Fishing6(struct Task *task)
|
||||
{
|
||||
bool8 bite;
|
||||
|
||||
sub_808CF78();
|
||||
AlignFishingAnimationFrames();
|
||||
task->tStep++;
|
||||
bite = FALSE;
|
||||
|
||||
@ -1872,7 +1872,7 @@ static bool8 Fishing6(struct Task *task)
|
||||
// Oh! A Bite!
|
||||
static bool8 Fishing7(struct Task *task)
|
||||
{
|
||||
sub_808CF78();
|
||||
AlignFishingAnimationFrames();
|
||||
AddTextPrinterParameterized(0, 1, gText_OhABite, 0, 17, 0, NULL);
|
||||
task->tStep++;
|
||||
task->tFrameCounter = 0;
|
||||
@ -1884,7 +1884,7 @@ static bool8 Fishing8(struct Task *task)
|
||||
{
|
||||
const s16 reelTimeouts[3] = {36, 33, 30};
|
||||
|
||||
sub_808CF78();
|
||||
AlignFishingAnimationFrames();
|
||||
task->tFrameCounter++;
|
||||
if (task->tFrameCounter >= reelTimeouts[task->tFishingRod])
|
||||
task->tStep = FISHING_GOT_AWAY;
|
||||
@ -1903,7 +1903,7 @@ static bool8 Fishing9(struct Task *task)
|
||||
{70, 30}
|
||||
};
|
||||
|
||||
sub_808CF78();
|
||||
AlignFishingAnimationFrames();
|
||||
task->tStep++;
|
||||
if (task->tRoundsPlayed < task->tMinRoundsRequired)
|
||||
{
|
||||
@ -1922,7 +1922,7 @@ static bool8 Fishing9(struct Task *task)
|
||||
|
||||
static bool8 Fishing10(struct Task *task)
|
||||
{
|
||||
sub_808CF78();
|
||||
AlignFishingAnimationFrames();
|
||||
FillWindowPixelBuffer(0, 0x11);
|
||||
AddTextPrinterParameterized2(0, 1, gText_PokemonOnHook, 1, 0, 2, 1, 3);
|
||||
task->tStep++;
|
||||
@ -1933,7 +1933,7 @@ static bool8 Fishing10(struct Task *task)
|
||||
static bool8 Fishing11(struct Task *task)
|
||||
{
|
||||
if (task->tFrameCounter == 0)
|
||||
sub_808CF78();
|
||||
AlignFishingAnimationFrames();
|
||||
|
||||
RunTextPrinters();
|
||||
|
||||
@ -1969,7 +1969,7 @@ static bool8 Fishing11(struct Task *task)
|
||||
// Not even a nibble
|
||||
static bool8 Fishing12(struct Task *task)
|
||||
{
|
||||
sub_808CF78();
|
||||
AlignFishingAnimationFrames();
|
||||
StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingNoCatchDirectionAnimNum(GetPlayerFacingDirection()));
|
||||
FillWindowPixelBuffer(0, 0x11);
|
||||
AddTextPrinterParameterized2(0, 1, gText_NotEvenANibble, 1, 0, 2, 1, 3);
|
||||
@ -1980,7 +1980,7 @@ static bool8 Fishing12(struct Task *task)
|
||||
// It got away
|
||||
static bool8 Fishing13(struct Task *task)
|
||||
{
|
||||
sub_808CF78();
|
||||
AlignFishingAnimationFrames();
|
||||
StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingNoCatchDirectionAnimNum(GetPlayerFacingDirection()));
|
||||
FillWindowPixelBuffer(0, 0x11);
|
||||
AddTextPrinterParameterized2(0, 1, gText_ItGotAway, 1, 0, 2, 1, 3);
|
||||
@ -1991,14 +1991,14 @@ static bool8 Fishing13(struct Task *task)
|
||||
// Wait one second
|
||||
static bool8 Fishing14(struct Task *task)
|
||||
{
|
||||
sub_808CF78();
|
||||
AlignFishingAnimationFrames();
|
||||
task->tStep++;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 Fishing15(struct Task *task)
|
||||
{
|
||||
sub_808CF78();
|
||||
AlignFishingAnimationFrames();
|
||||
if (gSprites[gPlayerAvatar.spriteId].animEnded)
|
||||
{
|
||||
struct EventObject *playerEventObj = &gEventObjects[gPlayerAvatar.eventObjectId];
|
||||
@ -2033,7 +2033,7 @@ static bool8 Fishing16(struct Task *task)
|
||||
#undef tFrameCounter
|
||||
#undef tFishingRod
|
||||
|
||||
static void sub_808CF78(void)
|
||||
static void AlignFishingAnimationFrames(void)
|
||||
{
|
||||
struct Sprite *playerSprite = &gSprites[gPlayerAvatar.spriteId];
|
||||
u8 animCmdIndex;
|
||||
@ -2114,7 +2114,7 @@ static void sub_808D094(u8 taskId)
|
||||
data[3] -= data[2];
|
||||
data[2] += 3;
|
||||
sprite->pos1.y = data[3] >> 4;
|
||||
if (sprite->pos1.y + (s16)gUnknown_03005DE8 < -32)
|
||||
if (sprite->pos1.y + (s16)gTotalCameraPixelOffsetY < -32)
|
||||
{
|
||||
data[0]++;
|
||||
}
|
||||
|
@ -1,21 +1,21 @@
|
||||
#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 "fldeff_80F9BCC.h"
|
||||
#include "event_data.h"
|
||||
#include "field_message_box.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 "battle_pike.h"
|
||||
#include "constants/species.h"
|
||||
|
||||
static bool32 sub_80F9568(struct Pokemon *pokemon)
|
||||
static bool32 IsMonValidSpecies(struct Pokemon *pokemon)
|
||||
{
|
||||
u16 species = GetMonData(pokemon, MON_DATA_SPECIES2);
|
||||
if (species == SPECIES_NONE || species == SPECIES_EGG)
|
||||
@ -25,14 +25,14 @@ static bool32 sub_80F9568(struct Pokemon *pokemon)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool32 sub_80F958C(void)
|
||||
static bool32 AllMonsFainted(void)
|
||||
{
|
||||
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;
|
||||
}
|
||||
@ -40,27 +40,28 @@ static bool32 sub_80F958C(void)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void sub_80F95C0(u8 partyIdx)
|
||||
static void FaintFromFieldPoison(u8 partyIdx)
|
||||
{
|
||||
struct Pokemon *pokemon = gPlayerParty + partyIdx;
|
||||
unsigned int status = STATUS1_NONE;
|
||||
u32 status = STATUS1_NONE;
|
||||
|
||||
AdjustFriendship(pokemon, 0x07);
|
||||
SetMonData(pokemon, MON_DATA_STATUS, &status);
|
||||
GetMonData(pokemon, MON_DATA_NICKNAME, gStringVar1);
|
||||
StringGetEnd10(gStringVar1);
|
||||
}
|
||||
|
||||
static bool32 sub_80F960C(u8 partyIdx)
|
||||
static bool32 MonFaintedFromPoison(u8 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 FALSE;
|
||||
}
|
||||
|
||||
static void sub_80F9654(u8 taskId)
|
||||
static void Task_WhiteOut(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
switch (data[0])
|
||||
@ -68,9 +69,9 @@ static void sub_80F9654(u8 taskId)
|
||||
case 0:
|
||||
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);
|
||||
data[0]++;
|
||||
return;
|
||||
@ -85,7 +86,7 @@ static void sub_80F9654(u8 taskId)
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (sub_80F958C())
|
||||
if (AllMonsFainted())
|
||||
{
|
||||
if (InBattlePyramid() | InBattlePike() || sub_81D5C18())
|
||||
{
|
||||
@ -106,19 +107,19 @@ static void sub_80F9654(u8 taskId)
|
||||
}
|
||||
}
|
||||
|
||||
void sub_80F972C(void)
|
||||
void ExecuteWhiteOut(void)
|
||||
{
|
||||
CreateTask(sub_80F9654, 80);
|
||||
CreateTask(Task_WhiteOut, 80);
|
||||
ScriptContext1_Stop();
|
||||
}
|
||||
|
||||
int DoPoisonFieldEffect(void)
|
||||
s32 DoPoisonFieldEffect(void)
|
||||
{
|
||||
int i;
|
||||
unsigned int hp;
|
||||
u32 hp;
|
||||
struct Pokemon *pokemon = gPlayerParty;
|
||||
unsigned int numPoisoned = 0;
|
||||
unsigned int numFainted = 0;
|
||||
u32 numPoisoned = 0;
|
||||
u32 numFainted = 0;
|
||||
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)
|
||||
@ -135,7 +136,7 @@ int DoPoisonFieldEffect(void)
|
||||
}
|
||||
if (numFainted != 0 || numPoisoned != 0)
|
||||
{
|
||||
overworld_poison_effect();
|
||||
FldeffPoison_Start();
|
||||
}
|
||||
if (numFainted != 0)
|
||||
{
|
||||
|
@ -595,7 +595,7 @@ static void LoadLinkPartnerEventObjectSpritePalette(u8 graphicsId, u8 localEvent
|
||||
graphicsId == EVENT_OBJ_GFX_RIVAL_MAY_NORMAL)
|
||||
{
|
||||
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;
|
||||
struct Sprite *sprite = &gSprites[spriteId];
|
||||
@ -1513,7 +1513,7 @@ bool8 FoundBlackGlasses(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);
|
||||
}
|
||||
@ -1521,7 +1521,7 @@ void SetRoute119Weather(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);
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ void c2_change_map(void)
|
||||
static bool8 sub_8137304(void)
|
||||
{
|
||||
u8 i;
|
||||
u8 v0 = get_map_light_from_warp0();
|
||||
u8 v0 = GetLastUsedWarpMapType();
|
||||
u8 v1 = Overworld_GetMapTypeOfSaveblockLocation();
|
||||
|
||||
for (i = 0; gUnknown_085B27C8[i].unk0; i++)
|
||||
|
@ -1,6 +1,4 @@
|
||||
#include "global.h"
|
||||
#include "constants/rgb.h"
|
||||
#include "constants/songs.h"
|
||||
#include "event_data.h"
|
||||
#include "event_scripts.h"
|
||||
#include "field_effect.h"
|
||||
@ -14,22 +12,24 @@
|
||||
#include "sprite.h"
|
||||
#include "task.h"
|
||||
#include "wild_encounter.h"
|
||||
#include "constants/rgb.h"
|
||||
#include "constants/songs.h"
|
||||
|
||||
void hm2_sweet_scent(void);
|
||||
void sub_8159F5C(void);
|
||||
void sub_8159FEC(u8 taskId);
|
||||
void sub_815A090(u8 taskId);
|
||||
static void FieldCallback_SweetScent(void);
|
||||
static void StartSweetScentFieldEffect(void);
|
||||
static void TrySweetScentEncounter(u8 taskId);
|
||||
static void FailSweetScentEncounter(u8 taskId);
|
||||
void sub_81BE6B8(void);
|
||||
void sub_81BE72C(void);
|
||||
|
||||
bool8 SetUpFieldMove_SweetScent(void)
|
||||
{
|
||||
gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu;
|
||||
gPostMenuFieldCallback = hm2_sweet_scent;
|
||||
gPostMenuFieldCallback = FieldCallback_SweetScent;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void hm2_sweet_scent(void)
|
||||
static void FieldCallback_SweetScent(void)
|
||||
{
|
||||
FieldEffectStart(FLDEFF_SWEET_SCENT);
|
||||
gFieldEffectArguments[0] = GetCursorSelectionMonId();
|
||||
@ -41,12 +41,12 @@ bool8 FldEff_SweetScent(void)
|
||||
|
||||
sub_80AC3D0();
|
||||
taskId = oei_task_add();
|
||||
gTasks[taskId].data[8] = (u32)sub_8159F5C >> 16;
|
||||
gTasks[taskId].data[9] = (u32)sub_8159F5C;
|
||||
gTasks[taskId].data[8] = (u32)StartSweetScentFieldEffect >> 16;
|
||||
gTasks[taskId].data[9] = (u32)StartSweetScentFieldEffect;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void sub_8159F5C(void)
|
||||
static void StartSweetScentFieldEffect(void)
|
||||
{
|
||||
u8 taskId;
|
||||
|
||||
@ -54,12 +54,12 @@ void sub_8159F5C(void)
|
||||
CpuFastSet(gPlttBufferUnfaded, gPaletteDecompressionBuffer, 0x100);
|
||||
CpuFastSet(gPlttBufferFaded, gPlttBufferUnfaded, 0x100);
|
||||
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;
|
||||
FieldEffectActiveListRemove(FLDEFF_SWEET_SCENT);
|
||||
}
|
||||
|
||||
void sub_8159FEC(u8 taskId)
|
||||
static void TrySweetScentEncounter(u8 taskId)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
@ -74,7 +74,7 @@ void sub_8159FEC(u8 taskId)
|
||||
}
|
||||
else
|
||||
{
|
||||
gTasks[taskId].func = sub_815A090;
|
||||
gTasks[taskId].func = FailSweetScentEncounter;
|
||||
BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 8, 0, RGB_RED);
|
||||
sub_81BE6B8();
|
||||
}
|
||||
@ -86,7 +86,7 @@ void sub_8159FEC(u8 taskId)
|
||||
}
|
||||
}
|
||||
|
||||
void sub_815A090(u8 taskId)
|
||||
static void FailSweetScentEncounter(u8 taskId)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "global.h"
|
||||
#include "fldeff_teleport.h"
|
||||
#include "field_effect.h"
|
||||
#include "field_player_avatar.h"
|
||||
#include "party_menu.h"
|
||||
@ -7,18 +6,21 @@
|
||||
#include "rom6.h"
|
||||
#include "task.h"
|
||||
|
||||
static void FieldCallback_Teleport(void);
|
||||
static void StartTeleportFieldEffect(void);
|
||||
|
||||
bool8 SetUpFieldMove_Teleport(void)
|
||||
{
|
||||
if (Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE)
|
||||
{
|
||||
gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu;
|
||||
gPostMenuFieldCallback = hm_teleport_run_dp02scr;
|
||||
gPostMenuFieldCallback = FieldCallback_Teleport;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void hm_teleport_run_dp02scr(void)
|
||||
static void FieldCallback_Teleport(void)
|
||||
{
|
||||
Overworld_ResetStateAfterTeleport();
|
||||
FieldEffectStart(FLDEFF_USE_TELEPORT);
|
||||
@ -28,16 +30,14 @@ void hm_teleport_run_dp02scr(void)
|
||||
bool8 FldEff_UseTeleport(void)
|
||||
{
|
||||
u8 taskId = oei_task_add();
|
||||
gTasks[taskId].data[8] = (u32)sub_817C94C >> 16;
|
||||
gTasks[taskId].data[9] = (u32)sub_817C94C;
|
||||
SetPlayerAvatarTransitionFlags(1);
|
||||
gTasks[taskId].data[8] = (u32)StartTeleportFieldEffect >> 16;
|
||||
gTasks[taskId].data[9] = (u32)StartTeleportFieldEffect;
|
||||
SetPlayerAvatarTransitionFlags(PLAYER_AVATAR_FLAG_ON_FOOT);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void sub_817C94C(void)
|
||||
static void StartTeleportFieldEffect(void)
|
||||
{
|
||||
FieldEffectActiveListRemove(FLDEFF_USE_TELEPORT);
|
||||
CreateTeleportFieldEffectTask();
|
||||
}
|
||||
|
||||
|
||||
|
@ -7,8 +7,6 @@
|
||||
#include "script_menu.h"
|
||||
#include "task.h"
|
||||
|
||||
extern void (*gUnknown_0300485C)(void);
|
||||
|
||||
extern void Overworld_PlaySpecialMapMusic(void);
|
||||
extern bool16 ScrSpecial_CreatePCMenu(void);
|
||||
extern void ScriptMenu_DisplayPCStartupPrompt(void);
|
||||
|
@ -58,7 +58,7 @@ extern void sub_81C5924(void);
|
||||
extern void sub_81C59BC(void);
|
||||
extern void sub_81AB9A8(u8);
|
||||
extern void sub_81ABA88(u8);
|
||||
extern void sub_80B7CC8(void);
|
||||
extern void StartEscapeRopeFieldEffect(void);
|
||||
extern u8* sub_806CF78(u16);
|
||||
extern void sub_81B89F0(void);
|
||||
extern u8 GetItemEffectType(u16);
|
||||
@ -890,7 +890,7 @@ void ItemUseOutOfBattle_BlackWhiteFlute(u8 taskId)
|
||||
void task08_080A1C44(u8 taskId)
|
||||
{
|
||||
ResetInitialPlayerAvatarState();
|
||||
sub_80B7CC8();
|
||||
StartEscapeRopeFieldEffect();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
|
@ -897,7 +897,7 @@ bool8 MetatileBehavior_IsBridge(u8 metatileBehavior)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
u8 MetatileBehavior_GetBridgeSth(u8 metatileBehavior)
|
||||
u8 MetatileBehavior_GetBridgeType(u8 metatileBehavior)
|
||||
{
|
||||
u8 result = metatileBehavior - MB_WARP_OR_BRIDGE;
|
||||
if (result < 4)
|
||||
|
@ -585,7 +585,7 @@ void set_warp2_warp3_to_neg_1(void)
|
||||
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->mapNum = mapNum;
|
||||
@ -594,7 +594,7 @@ void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x,
|
||||
warp->y = y;
|
||||
}
|
||||
|
||||
bool32 IsDummyWarp(struct WarpData *warp)
|
||||
static bool32 IsDummyWarp(struct WarpData *warp)
|
||||
{
|
||||
if (warp->mapGroup != -1)
|
||||
return FALSE;
|
||||
@ -620,7 +620,7 @@ struct MapHeader const *const GetDestinationWarpMapHeader(void)
|
||||
return Overworld_GetMapHeaderByGroupAndId(sWarpDestination.mapGroup, sWarpDestination.mapNum);
|
||||
}
|
||||
|
||||
void LoadCurrentMapData(void)
|
||||
static void LoadCurrentMapData(void)
|
||||
{
|
||||
sLastMapSectionId = gMapHeader.regionMapSectionId;
|
||||
gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum);
|
||||
@ -628,13 +628,13 @@ void LoadCurrentMapData(void)
|
||||
gMapHeader.mapLayout = GetMapLayout();
|
||||
}
|
||||
|
||||
void LoadSaveblockMapHeader(void)
|
||||
static void LoadSaveblockMapHeader(void)
|
||||
{
|
||||
gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum);
|
||||
gMapHeader.mapLayout = GetMapLayout();
|
||||
}
|
||||
|
||||
void SetPlayerCoordsFromWarp(void)
|
||||
static void SetPlayerCoordsFromWarp(void)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
void SetFixedDiveWarpAsDestination(void)
|
||||
static void SetFixedDiveWarpAsDestination(void)
|
||||
{
|
||||
sWarpDestination = gFixedDiveWarp;
|
||||
}
|
||||
@ -785,7 +785,7 @@ const struct MapConnection *GetMapConnection(u8 dir)
|
||||
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);
|
||||
|
||||
@ -905,8 +905,8 @@ static void mli0_load_map(u32 a1)
|
||||
|
||||
void ResetInitialPlayerAvatarState(void)
|
||||
{
|
||||
gInitialPlayerAvatarState.direction = 1;
|
||||
gInitialPlayerAvatarState.transitionFlags = 1;
|
||||
gInitialPlayerAvatarState.direction = DIR_SOUTH;
|
||||
gInitialPlayerAvatarState.transitionFlags = PLAYER_AVATAR_FLAG_ON_FOOT;
|
||||
}
|
||||
|
||||
void StoreInitialPlayerAvatarState(void)
|
||||
@ -914,15 +914,15 @@ void StoreInitialPlayerAvatarState(void)
|
||||
gInitialPlayerAvatarState.direction = GetPlayerFacingDirection();
|
||||
|
||||
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))
|
||||
gInitialPlayerAvatarState.transitionFlags = 4;
|
||||
gInitialPlayerAvatarState.transitionFlags = PLAYER_AVATAR_FLAG_ACRO_BIKE;
|
||||
else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING))
|
||||
gInitialPlayerAvatarState.transitionFlags = 8;
|
||||
gInitialPlayerAvatarState.transitionFlags = PLAYER_AVATAR_FLAG_SURFING;
|
||||
else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_UNDERWATER))
|
||||
gInitialPlayerAvatarState.transitionFlags = 16;
|
||||
gInitialPlayerAvatarState.transitionFlags = PLAYER_AVATAR_FLAG_UNDERWATER;
|
||||
else
|
||||
gInitialPlayerAvatarState.transitionFlags = 1;
|
||||
gInitialPlayerAvatarState.transitionFlags = PLAYER_AVATAR_FLAG_ON_FOOT;
|
||||
}
|
||||
|
||||
static struct InitialPlayerAvatarState *GetInitialPlayerAvatarState(void)
|
||||
@ -940,44 +940,44 @@ static struct InitialPlayerAvatarState *GetInitialPlayerAvatarState(void)
|
||||
static u8 GetAdjustedInitialTransitionFlags(struct InitialPlayerAvatarState *playerStruct, u16 metatileBehavior, u8 mapType)
|
||||
{
|
||||
if (mapType != MAP_TYPE_INDOOR && FlagGet(FLAG_SYS_CRUISE_MODE))
|
||||
return 1;
|
||||
return PLAYER_AVATAR_FLAG_ON_FOOT;
|
||||
else if (mapType == MAP_TYPE_UNDERWATER)
|
||||
return 16;
|
||||
return PLAYER_AVATAR_FLAG_UNDERWATER;
|
||||
else if (MetatileBehavior_IsSurfableWaterOrUnderwater(metatileBehavior) == TRUE)
|
||||
return 8;
|
||||
return PLAYER_AVATAR_FLAG_SURFING;
|
||||
else if (Overworld_IsBikingAllowed() != TRUE)
|
||||
return 1;
|
||||
else if (playerStruct->transitionFlags == 2)
|
||||
return 2;
|
||||
else if (playerStruct->transitionFlags != 4)
|
||||
return 1;
|
||||
return PLAYER_AVATAR_FLAG_ON_FOOT;
|
||||
else if (playerStruct->transitionFlags == PLAYER_AVATAR_FLAG_MACH_BIKE)
|
||||
return PLAYER_AVATAR_FLAG_MACH_BIKE;
|
||||
else if (playerStruct->transitionFlags != PLAYER_AVATAR_FLAG_ACRO_BIKE)
|
||||
return PLAYER_AVATAR_FLAG_ON_FOOT;
|
||||
else
|
||||
return 4;
|
||||
return PLAYER_AVATAR_FLAG_ACRO_BIKE;
|
||||
}
|
||||
|
||||
static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStruct, u8 transitionFlags, u16 metatileBehavior, u8 mapType)
|
||||
{
|
||||
if (FlagGet(FLAG_SYS_CRUISE_MODE) && mapType == MAP_TYPE_6)
|
||||
return 4;
|
||||
return DIR_EAST;
|
||||
else if (MetatileBehavior_IsDeepSouthWarp(metatileBehavior) == TRUE)
|
||||
return 2;
|
||||
return DIR_NORTH;
|
||||
else if (MetatileBehavior_IsNonAnimDoor(metatileBehavior) == TRUE || MetatileBehavior_IsDoor(metatileBehavior) == TRUE)
|
||||
return 1;
|
||||
return DIR_SOUTH;
|
||||
else if (MetatileBehavior_IsSouthArrowWarp(metatileBehavior) == TRUE)
|
||||
return 2;
|
||||
return DIR_NORTH;
|
||||
else if (MetatileBehavior_IsNorthArrowWarp(metatileBehavior) == TRUE)
|
||||
return 1;
|
||||
return DIR_SOUTH;
|
||||
else if (MetatileBehavior_IsWestArrowWarp(metatileBehavior) == TRUE)
|
||||
return 4;
|
||||
return DIR_EAST;
|
||||
else if (MetatileBehavior_IsEastArrowWarp(metatileBehavior) == TRUE)
|
||||
return 3;
|
||||
else if ((playerStruct->transitionFlags == 16 && transitionFlags == 8)
|
||||
|| (playerStruct->transitionFlags == 8 && transitionFlags == 16))
|
||||
return DIR_WEST;
|
||||
else if ((playerStruct->transitionFlags == PLAYER_AVATAR_FLAG_UNDERWATER && transitionFlags == PLAYER_AVATAR_FLAG_SURFING)
|
||||
|| (playerStruct->transitionFlags == PLAYER_AVATAR_FLAG_SURFING && transitionFlags == PLAYER_AVATAR_FLAG_UNDERWATER ))
|
||||
return playerStruct->direction;
|
||||
else if (MetatileBehavior_IsLadder(metatileBehavior) == TRUE)
|
||||
return playerStruct->direction;
|
||||
else
|
||||
return 1;
|
||||
return DIR_SOUTH;
|
||||
}
|
||||
|
||||
static u16 GetCenterScreenMetatileBehavior(void)
|
||||
@ -1357,7 +1357,7 @@ u8 Overworld_GetMapTypeOfSaveblockLocation(void)
|
||||
return GetMapTypeByWarpData(&gSaveBlock1Ptr->location);
|
||||
}
|
||||
|
||||
u8 get_map_light_from_warp0(void)
|
||||
u8 GetLastUsedWarpMapType(void)
|
||||
{
|
||||
return GetMapTypeByWarpData(&gLastUsedWarp);
|
||||
}
|
||||
@ -1458,7 +1458,7 @@ static void DoCB1_Overworld(u16 newKeys, u16 heldKeys)
|
||||
FieldGetPlayerInput(&inputStruct, newKeys, heldKeys);
|
||||
if (!ScriptContext2_IsEnabled())
|
||||
{
|
||||
if (sub_809C014(&inputStruct) == 1)
|
||||
if (ProcessPlayerFieldInput(&inputStruct) == 1)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
HideMapNamePopUpWindow();
|
||||
@ -2166,9 +2166,9 @@ static void sub_8086988(u32 a1)
|
||||
|
||||
static void sub_80869DC(void)
|
||||
{
|
||||
gUnknown_03005DEC = 0;
|
||||
gUnknown_03005DE8 = 0;
|
||||
sub_808D438();
|
||||
gTotalCameraPixelOffsetX = 0;
|
||||
gTotalCameraPixelOffsetY = 0;
|
||||
ResetEventObjects();
|
||||
TrySpawnEventObjects(0, 0);
|
||||
mapheader_run_first_tag4_script_list_match();
|
||||
}
|
||||
@ -2178,9 +2178,9 @@ static void mli4_mapscripts_and_other(void)
|
||||
s16 x, y;
|
||||
struct InitialPlayerAvatarState *player;
|
||||
|
||||
gUnknown_03005DEC = 0;
|
||||
gUnknown_03005DE8 = 0;
|
||||
sub_808D438();
|
||||
gTotalCameraPixelOffsetX = 0;
|
||||
gTotalCameraPixelOffsetY = 0;
|
||||
ResetEventObjects();
|
||||
sav1_camera_get_focus_coords(&x, &y);
|
||||
player = GetInitialPlayerAvatarState();
|
||||
InitPlayerAvatar(x, y, player->direction, gSaveBlock2Ptr->playerGender);
|
||||
|
21
src/rom6.c
21
src/rom6.c
@ -1,21 +1,22 @@
|
||||
#include "global.h"
|
||||
#include "constants/event_objects.h"
|
||||
#include "constants/songs.h"
|
||||
#include "rom6.h"
|
||||
#include "braille_puzzles.h"
|
||||
#include "event_data.h"
|
||||
#include "event_object_movement.h"
|
||||
#include "event_scripts.h"
|
||||
#include "field_effect.h"
|
||||
#include "event_object_movement.h"
|
||||
#include "field_player_avatar.h"
|
||||
#include "item_use.h"
|
||||
#include "party_menu.h"
|
||||
#include "overworld.h"
|
||||
#include "party_menu.h"
|
||||
#include "rom6.h"
|
||||
#include "script.h"
|
||||
#include "sound.h"
|
||||
#include "sprite.h"
|
||||
#include "task.h"
|
||||
#include "constants/event_object_movement_constants.h"
|
||||
#include "constants/event_objects.h"
|
||||
#include "constants/map_types.h"
|
||||
#include "constants/songs.h"
|
||||
|
||||
// static functions
|
||||
static void task08_080C9820(u8 taskId);
|
||||
@ -31,14 +32,14 @@ static void sub_8135780(void);
|
||||
extern struct MapPosition gPlayerFacingPosition;
|
||||
|
||||
// text
|
||||
bool8 CheckObjectGraphicsInFrontOfPlayer(u8 a)
|
||||
bool8 CheckObjectGraphicsInFrontOfPlayer(u8 graphicsId)
|
||||
{
|
||||
u8 eventObjId;
|
||||
|
||||
GetXYCoordsOneStepInFrontOfPlayer(&gPlayerFacingPosition.x, &gPlayerFacingPosition.y);
|
||||
gPlayerFacingPosition.height = PlayerGetZCoord();
|
||||
eventObjId = GetEventObjectIdByXYZ(gPlayerFacingPosition.x, gPlayerFacingPosition.y, gPlayerFacingPosition.height);
|
||||
if (gEventObjects[eventObjId].graphicsId != a)
|
||||
if (gEventObjects[eventObjId].graphicsId != graphicsId)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@ -73,7 +74,7 @@ static void task08_080C9820(u8 taskId)
|
||||
else
|
||||
{
|
||||
sub_808C114();
|
||||
EventObjectSetHeldMovement(&gEventObjects[eventObjId], 0x39);
|
||||
EventObjectSetHeldMovement(&gEventObjects[eventObjId], MOVEMENT_ACTION_START_ANIM_IN_DIRECTION);
|
||||
gTasks[taskId].func = sub_813552C;
|
||||
}
|
||||
}
|
||||
@ -90,7 +91,7 @@ static void sub_813552C(u8 taskId)
|
||||
|
||||
static void sub_8135578(u8 taskId)
|
||||
{
|
||||
if (!FieldEffectActiveListContains(6))
|
||||
if (!FieldEffectActiveListContains(FLDEFF_FIELD_MOVE_SHOW_MON))
|
||||
{
|
||||
gFieldEffectArguments[1] = GetPlayerFacingDirection();
|
||||
if (gFieldEffectArguments[1] == 1)
|
||||
@ -189,7 +190,7 @@ bool8 FldEff_UseDig(void)
|
||||
gTasks[taskId].data[8] = (u32)sub_8135780 >> 16;
|
||||
gTasks[taskId].data[9] = (u32)sub_8135780;
|
||||
if (!ShouldDoBrailleDigEffect())
|
||||
SetPlayerAvatarTransitionFlags(1);
|
||||
SetPlayerAvatarTransitionFlags(PLAYER_AVATAR_FLAG_ON_FOOT);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ void UpdateShoalTideFlag(void)
|
||||
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();
|
||||
if (tide[gLocalTime.hours])
|
||||
|
197
src/wallclock.c
197
src/wallclock.c
@ -1,37 +1,24 @@
|
||||
#include "global.h"
|
||||
#include "main.h"
|
||||
#include "palette.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "bg.h"
|
||||
#include "rtc.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"
|
||||
|
||||
// static types
|
||||
|
||||
#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
|
||||
#include "event_data.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "graphics.h"
|
||||
#include "main.h"
|
||||
#include "menu.h"
|
||||
#include "palette.h"
|
||||
#include "rtc.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "sound.h"
|
||||
#include "strings.h"
|
||||
#include "task.h"
|
||||
#include "text.h"
|
||||
#include "text_window.h"
|
||||
#include "trig.h"
|
||||
#include "wallclock.h"
|
||||
#include "window.h"
|
||||
#include "constants/songs.h"
|
||||
|
||||
// static declarations
|
||||
|
||||
@ -46,15 +33,39 @@ static void Task_ViewClock1(u8 taskId);
|
||||
static void Task_ViewClock2(u8 taskId);
|
||||
static void Task_ViewClock3(u8 taskId);
|
||||
static void Task_ViewClock4(u8 taskId);
|
||||
static u16 CalcNewMinHandAngle(u16 a0, u8 command, u8 a2);
|
||||
static bool32 AdvanceClock(u8 taskId, u8 command);
|
||||
static void UpdateClockPeriod(u8 taskId, u8 command);
|
||||
static u16 CalcNewMinHandAngle(u16 angle, u8 direction, u8 speed);
|
||||
static bool32 AdvanceClock(u8 taskId, u8 direction);
|
||||
static void UpdateClockPeriod(u8 taskId, u8 direction);
|
||||
static void InitClockWithRtc(u8 taskId);
|
||||
static void SpriteCB_MinuteHand(struct Sprite *sprite);
|
||||
static void SpriteCB_HourHand(struct Sprite *sprite);
|
||||
static void SpriteCB_AMIndicator(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
|
||||
|
||||
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 = {
|
||||
.y = 0xa0,
|
||||
.y = 160,
|
||||
.size = 3,
|
||||
.priority = 1
|
||||
.priority = 1,
|
||||
};
|
||||
static const union AnimCmd Unknown_085B2238[] = {
|
||||
ANIMCMD_FRAME(0, 30),
|
||||
ANIMCMD_END
|
||||
ANIMCMD_END,
|
||||
};
|
||||
static const union AnimCmd Unknown_085B2240[] = {
|
||||
ANIMCMD_FRAME(64, 30),
|
||||
ANIMCMD_END
|
||||
ANIMCMD_END,
|
||||
};
|
||||
static const union AnimCmd *const gUnknown_085B2248[] = {
|
||||
Unknown_085B2238
|
||||
@ -148,7 +159,7 @@ static const struct SpriteTemplate gUnknown_085B2250 =
|
||||
.anims = gUnknown_085B2248,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = SpriteCB_MinuteHand
|
||||
.callback = SpriteCB_MinuteHand,
|
||||
};
|
||||
static const struct SpriteTemplate gUnknown_085B2268 =
|
||||
{
|
||||
@ -158,20 +169,20 @@ static const struct SpriteTemplate gUnknown_085B2268 =
|
||||
.anims = gUnknown_085B224C,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = SpriteCB_HourHand
|
||||
.callback = SpriteCB_HourHand,
|
||||
};
|
||||
static const struct OamData Unknown_085B2280 = {
|
||||
.y = 0xa0,
|
||||
.y = 160,
|
||||
.size = 1,
|
||||
.priority = 3
|
||||
.priority = 3,
|
||||
};
|
||||
static const union AnimCmd Unknown_085B2288[] = {
|
||||
ANIMCMD_FRAME(0x84, 30),
|
||||
ANIMCMD_END
|
||||
ANIMCMD_FRAME(132, 30),
|
||||
ANIMCMD_END,
|
||||
};
|
||||
static const union AnimCmd Unknown_085B2290[] = {
|
||||
ANIMCMD_FRAME(0x80, 30),
|
||||
ANIMCMD_END
|
||||
ANIMCMD_FRAME(128, 30),
|
||||
ANIMCMD_END,
|
||||
};
|
||||
static const union AnimCmd *const gUnknown_085B2298[] = {
|
||||
Unknown_085B2288
|
||||
@ -648,21 +659,21 @@ void CB2_StartWallClock(void)
|
||||
gTasks[taskId].tMinuteHandAngle = 0;
|
||||
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].oam.affineMode = ST_OAM_AFFINE_NORMAL;
|
||||
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].oam.affineMode = ST_OAM_AFFINE_NORMAL;
|
||||
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[1] = 45;
|
||||
|
||||
spriteId = CreateSprite(&gUnknown_085B22B8, 0x78, 0x50, 2);
|
||||
spriteId = CreateSprite(&gUnknown_085B22B8, 120, 80, 2);
|
||||
gSprites[spriteId].data[0] = taskId;
|
||||
gSprites[spriteId].data[1] = 90;
|
||||
|
||||
@ -696,21 +707,21 @@ void CB2_ViewWallClock(void)
|
||||
angle2 = 135;
|
||||
}
|
||||
|
||||
spriteId = CreateSprite(&gUnknown_085B2250, 0x78, 0x50, 1);
|
||||
spriteId = CreateSprite(&gUnknown_085B2250, 120, 80, 1);
|
||||
gSprites[spriteId].data[0] = taskId;
|
||||
gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL;
|
||||
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].oam.affineMode = ST_OAM_AFFINE_NORMAL;
|
||||
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[1] = angle1;
|
||||
|
||||
spriteId = CreateSprite(&gUnknown_085B22B8, 0x78, 0x50, 2);
|
||||
spriteId = CreateSprite(&gUnknown_085B22B8, 120, 80, 2);
|
||||
gSprites[spriteId].data[0] = taskId;
|
||||
gSprites[spriteId].data[1] = angle2;
|
||||
|
||||
@ -757,11 +768,11 @@ static void Task_SetClock2(u8 taskId)
|
||||
gTasks[taskId].tMvmtDir = 0;
|
||||
if (gMain.heldKeys & DPAD_LEFT)
|
||||
{
|
||||
gTasks[taskId].tMvmtDir = 1;
|
||||
gTasks[taskId].tMvmtDir = MVMT_BACKWARD;
|
||||
}
|
||||
if (gMain.heldKeys & DPAD_RIGHT)
|
||||
{
|
||||
gTasks[taskId].tMvmtDir = 2;
|
||||
gTasks[taskId].tMvmtDir = MVMT_FORWARD;
|
||||
}
|
||||
if (gTasks[taskId].tMvmtDir != 0)
|
||||
{
|
||||
@ -794,12 +805,12 @@ static void Task_SetClock4(u8 taskId)
|
||||
{
|
||||
switch (Menu_ProcessInputNoWrapClearOnChoose())
|
||||
{
|
||||
case 0:
|
||||
case 0: //YES
|
||||
PlaySE(SE_SELECT);
|
||||
gTasks[taskId].func = Task_SetClock5;
|
||||
break;
|
||||
case 1:
|
||||
case -1:
|
||||
case 1: //B button
|
||||
case -1: //NO
|
||||
PlaySE(SE_SELECT);
|
||||
sub_8198070(0, FALSE);
|
||||
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;
|
||||
}
|
||||
if (a0 > 30)
|
||||
if (speed > 30)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
if (a0 > 10)
|
||||
if (speed > 10)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static u16 CalcNewMinHandAngle(u16 a0, u8 command, u8 a2)
|
||||
static u16 CalcNewMinHandAngle(u16 angle, u8 direction, u8 speed)
|
||||
{
|
||||
u8 r1 = CalcMinHandDelta(a2);
|
||||
switch (command)
|
||||
u8 delta = CalcMinHandDelta(speed);
|
||||
switch (direction)
|
||||
{
|
||||
case 1:
|
||||
if (a0) a0 -= r1;
|
||||
else a0 = 360 - r1;
|
||||
case MVMT_BACKWARD:
|
||||
if (angle)
|
||||
angle -= delta ;
|
||||
else
|
||||
angle = 360 - delta ;
|
||||
break;
|
||||
case 2:
|
||||
if (a0 < 360 - r1) a0 += r1;
|
||||
else a0 = 0;
|
||||
case MVMT_FORWARD:
|
||||
if (angle < 360 - delta )
|
||||
angle += delta ;
|
||||
else
|
||||
angle = 0;
|
||||
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)
|
||||
{
|
||||
gTasks[taskId].tMinutes--;
|
||||
@ -909,10 +924,10 @@ static bool32 AdvanceClock(u8 taskId, u8 command)
|
||||
{
|
||||
gTasks[taskId].tHours = 23;
|
||||
}
|
||||
UpdateClockPeriod(taskId, command);
|
||||
UpdateClockPeriod(taskId, direction);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case MVMT_FORWARD:
|
||||
if (gTasks[taskId].tMinutes < 59)
|
||||
{
|
||||
gTasks[taskId].tMinutes++;
|
||||
@ -928,37 +943,37 @@ static bool32 AdvanceClock(u8 taskId, u8 command)
|
||||
{
|
||||
gTasks[taskId].tHours = 0;
|
||||
}
|
||||
UpdateClockPeriod(taskId, command);
|
||||
UpdateClockPeriod(taskId, direction);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void UpdateClockPeriod(u8 taskId, u8 command)
|
||||
static void UpdateClockPeriod(u8 taskId, u8 direction)
|
||||
{
|
||||
u8 hours = gTasks[taskId].tHours;
|
||||
switch (command)
|
||||
switch (direction)
|
||||
{
|
||||
case 1:
|
||||
case MVMT_BACKWARD:
|
||||
switch (hours)
|
||||
{
|
||||
case 11:
|
||||
gTasks[taskId].tPeriod = FALSE;
|
||||
gTasks[taskId].tPeriod = PERIOD_AM;
|
||||
break;
|
||||
case 23:
|
||||
gTasks[taskId].tPeriod = TRUE;
|
||||
gTasks[taskId].tPeriod = PERIOD_PM;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case MVMT_FORWARD:
|
||||
switch (hours)
|
||||
{
|
||||
case 0:
|
||||
gTasks[taskId].tPeriod = FALSE;
|
||||
gTasks[taskId].tPeriod = PERIOD_AM;
|
||||
break;
|
||||
case 12:
|
||||
gTasks[taskId].tPeriod = TRUE;
|
||||
gTasks[taskId].tPeriod = PERIOD_PM;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -974,11 +989,11 @@ static void InitClockWithRtc(u8 taskId)
|
||||
gTasks[taskId].tHourHandAngle = (gTasks[taskId].tHours % 12) * 30 + (gTasks[taskId].tMinutes / 10) * 5;
|
||||
if (gLocalTime.hours < 12)
|
||||
{
|
||||
gTasks[taskId].tPeriod = FALSE;
|
||||
gTasks[taskId].tPeriod = PERIOD_AM;
|
||||
}
|
||||
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;
|
||||
s16 sin = Sin2(angle) / 16;
|
||||
s16 cos = Cos2(angle) / 16;
|
||||
u16 xhat;
|
||||
u16 yhat;
|
||||
u16 xhat, yhat;
|
||||
|
||||
SetOamMatrix(0, cos, sin, -sin, cos);
|
||||
xhat = sClockHandCoords[angle][0];
|
||||
@ -1011,8 +1025,7 @@ static void SpriteCB_HourHand(struct Sprite *sprite)
|
||||
u16 angle = gTasks[sprite->data[0]].tHourHandAngle;
|
||||
s16 sin = Sin2(angle) / 16;
|
||||
s16 cos = Cos2(angle) / 16;
|
||||
u16 xhat;
|
||||
u16 yhat;
|
||||
u16 xhat, yhat;
|
||||
|
||||
SetOamMatrix(1, cos, sin, -sin, cos);
|
||||
xhat = sClockHandCoords[angle][0];
|
||||
|
Loading…
Reference in New Issue
Block a user