Document some metatile behaviors and address review comments.

This commit is contained in:
ultima-soul 2020-03-15 19:44:47 -07:00
parent dd24bd3116
commit e1f7efb8e6
15 changed files with 869 additions and 885 deletions

View File

@ -1 +1 @@
gBackupMapLayout
VMap

View File

@ -13,21 +13,21 @@
#define MB_SEMI_DEEP_WATER 0x11
#define MB_DEEP_WATER 0x12
#define MB_WATERFALL 0x13
#define MB_SPLASHING_WATER 0x15
#define MB_OCEAN_WATER 0x15
#define MB_PUDDLE 0x16
#define MB_WATERFALL_BOTTOM 0x17
#define MB_SHALLOW_WATER 0x17
#define MB_19 0x19
#define MB_1A 0x1A
#define MB_1B 0x1B
#define MB_STRENGTH_BUTTON 0x20
#define MB_21 0x21
#define MB_SAND 0x21
#define MB_22 0x22
#define MB_ICE 0x23
#define MB_THIN_ICE 0x26
#define MB_CRACKED_ICE 0x27
#define MB_HOT_SPRINGS 0x28
#define MB_ROCK_STAIRS 0x2A
#define MB_SAND 0x2B
#define MB_SAND_CAVE 0x2B
#define MB_IMPASSABLE_EAST 0x30
#define MB_IMPASSABLE_WEST 0x31
#define MB_IMPASSABLE_NORTH 0x32

View File

@ -5,7 +5,8 @@
// Exported struct declarations
enum SpinnerRunnerFollowPatterns {
enum SpinnerRunnerFollowPatterns
{
RUNFOLLOW_ANY,
RUNFOLLOW_NORTH_SOUTH,
RUNFOLLOW_EAST_WEST,
@ -191,7 +192,6 @@ extern const struct SpriteTemplate *const gFieldEffectObjectTemplatePointers[];
extern const struct SpritePalette gUnknown_83A5348;
extern const struct SpriteTemplate * const gFieldEffectObjectTemplatePointers[];
extern const struct OamData gObjectEventBaseOam_32x32;
extern const struct Coords16 sDirectionToVectors[];
extern const u16 gUnknown_8398648[];
extern const u16 gUnknown_8398688[];
extern const u8 gReflectionEffectPaletteMap[];

View File

@ -11,5 +11,4 @@ void SetCableClubWarp(void);
void sub_806DE28(struct ObjectEvent *);
void dive_warp(struct MapPosition * pos, u16 behavior);
#endif //GUARD_FIELD_CONTROL_AVATAR_H

View File

@ -11,7 +11,7 @@
#define NUM_PALS_TOTAL 13
#define VIRTUAL_MAP_SIZE 0x2800
extern struct BackupMapLayout gBackupMapLayout;
extern struct BackupMapLayout VMap;
extern const struct MapLayout Route1_Layout;
u32 MapGridGetMetatileIdAt(int, int);

View File

@ -9,8 +9,8 @@ bool8 MetatileBehavior_IsJumpWest(u8 metatileBehavior);
bool8 MetatileBehavior_IsJumpNorth(u8 metatileBehavior);
bool8 MetatileBehavior_IsJumpSouth(u8 metatileBehavior);
bool8 MetatileBehavior_IsPokeGrass(u8 metatileBehavior);
bool8 MetatileBehavior_IsSandOrDeepSand(u8 metatileBehavior);
bool8 MetatileBehavior_IsMB21OrWaterfallBottom(u8 metatileBehavior);
bool8 MetatileBehavior_IsSand(u8 metatileBehavior);
bool8 MetatileBehavior_IsSandOrShallowFlowingWater(u8 metatileBehavior);
bool8 MetatileBehavior_IsDeepSand(u8 metatileBehavior);
bool8 MetatileBehavior_IsReflective(u8 metatileBehavior);
bool8 MetatileBehavior_IsIce(u8 metatileBehavior);
@ -64,7 +64,7 @@ bool8 MetatileBehavior_IsIndoorEncounter(u8 metatileBehavior);
bool8 MetatileBehavior_IsMountain(u8 metatileBehavior);
bool8 MetatileBehavior_IsDeepOrSemiDeepWater(u8 metatileBehavior);
bool8 MetatileBehavior_IsMB19(u8 metatileBehavior);
bool8 MetatileBehavior_IsWaterfallBottom(u8 metatileBehavior);
bool8 MetatileBehavior_IsShallowFlowingWater(u8 metatileBehavior);
bool8 MetatileBehavior_IsThinIce(u8 metatileBehavior);
bool8 MetatileBehavior_IsCrackedIce(u8 metatileBehavior);
bool8 MetatileBehavior_IsDeepSemiDeepOrSplashingWater(u8 metatileBehavior);

View File

@ -94,7 +94,6 @@ SECTIONS {
src/field_door.o(.text);
asm/field_player_avatar.o(.text);
src/event_object_movement.o(.text);
src/event_object_80688E4.o(.text); /* event_object_movement */
src/field_message_box.o(.text);
src/event_object_lock.o(.text);
src/text_window_graphics.o(.text);
@ -427,7 +426,6 @@ SECTIONS {
data/field_player_avatar.o(.rodata);
data/event_object_movement.o(.rodata);
src/event_object_movement.o(.rodata);
src/event_object_80688E4.o(.rodata); /* event_object_movement */
src/scrcmd.o(.rodata);
src/coord_event_weather.o(.rodata);
src/field_tasks.o(.rodata);

View File

@ -461,7 +461,7 @@ u8 BattleSetup_GetTerrainId(void)
return BATTLE_TERRAIN_GRASS;
if (MetatileBehavior_IsLongGrass(tileBehavior))
return BATTLE_TERRAIN_LONG_GRASS;
if (MetatileBehavior_IsMB21OrWaterfallBottom(tileBehavior))
if (MetatileBehavior_IsSandOrShallowFlowingWater(tileBehavior))
return BATTLE_TERRAIN_SAND;
switch (gMapHeader.mapType)
{

View File

@ -1,652 +0,0 @@
#include "global.h"
#include "event_object_movement.h"
#include "field_effect.h"
// This is part of evobjmv.c (see assert statement in DoObjectUnionRoomWarpYDisplacement).
static void DoObjectUnionRoomWarpYDisplacement(struct Sprite * sprite);
bool8 FreezeObjectEvent(struct ObjectEvent * objectEvent)
{
if (objectEvent->heldMovementActive || objectEvent->frozen)
return TRUE;
objectEvent->frozen = TRUE;
objectEvent->spriteAnimPausedBackup = gSprites[objectEvent->spriteId].animPaused;
objectEvent->spriteAffineAnimPausedBackup = gSprites[objectEvent->spriteId].affineAnimPaused;
gSprites[objectEvent->spriteId].animPaused = TRUE;
gSprites[objectEvent->spriteId].affineAnimPaused = TRUE;
return FALSE;
}
void FreezeObjectEvents(void)
{
u8 i;
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
{
if (gObjectEvents[i].active && i != gPlayerAvatar.objectEventId)
FreezeObjectEvent(&gObjectEvents[i]);
}
}
void FreezeObjectEventsExceptOne(u8 noFreeze)
{
u8 i;
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
{
if (i != noFreeze && gObjectEvents[i].active && i != gPlayerAvatar.objectEventId)
FreezeObjectEvent(&gObjectEvents[i]);
}
}
void UnfreezeObjectEvent(struct ObjectEvent * objectEvent)
{
if (objectEvent->active && objectEvent->frozen)
{
objectEvent->frozen = FALSE;
gSprites[objectEvent->spriteId].animPaused = objectEvent->spriteAnimPausedBackup;
gSprites[objectEvent->spriteId].affineAnimPaused = objectEvent->spriteAffineAnimPausedBackup;
}
}
void UnfreezeObjectEvents(void)
{
u8 i;
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
{
if (gObjectEvents[i].active)
UnfreezeObjectEvent(&gObjectEvents[i]);
}
}
#define tObjectEventId data[0]
#define tZCoord data[1]
#define tInvisible data[2]
#define tDirection data[3]
#define tSpeed data[4]
#define tStepNo data[5]
static void little_step(struct Sprite * sprite, u8 direction)
{
sprite->pos1.x += sDirectionToVectors[direction].x;
sprite->pos1.y += sDirectionToVectors[direction].y;
}
static void double_little_steps(struct Sprite * sprite, u8 direction)
{
sprite->pos1.x += 2 * (u16) sDirectionToVectors[direction].x;
sprite->pos1.y += 2 * (u16) sDirectionToVectors[direction].y;
}
static void triple_little_steps(struct Sprite * sprite, u8 direction)
{
sprite->pos1.x += 2 * (u16) sDirectionToVectors[direction].x + (u16) sDirectionToVectors[direction].x;
sprite->pos1.y += 2 * (u16) sDirectionToVectors[direction].y + (u16) sDirectionToVectors[direction].y;
}
static void quad_little_steps(struct Sprite * sprite, u8 direction)
{
sprite->pos1.x += 4 * (u16) sDirectionToVectors[direction].x;
sprite->pos1.y += 4 * (u16) sDirectionToVectors[direction].y;
}
static void oct_little_steps(struct Sprite * sprite, u8 direction)
{
sprite->pos1.x += 8 * (u16) sDirectionToVectors[direction].x;
sprite->pos1.y += 8 * (u16) sDirectionToVectors[direction].y;
}
void oamt_npc_ministep_reset(struct Sprite * sprite, u8 direction, u8 speed)
{
sprite->tDirection = direction;
sprite->tSpeed = speed;
sprite->tStepNo = 0;
}
typedef void (*SpriteStepFunc)(struct Sprite *sprite, u8 direction);
static const SpriteStepFunc sSpeed0[] = {
little_step,
little_step,
little_step,
little_step,
little_step,
little_step,
little_step,
little_step,
little_step,
little_step,
little_step,
little_step,
little_step,
little_step,
little_step,
little_step
};
static const SpriteStepFunc sSpeed1[] = {
double_little_steps,
double_little_steps,
double_little_steps,
double_little_steps,
double_little_steps,
double_little_steps,
double_little_steps,
double_little_steps
};
static const SpriteStepFunc sSpeed2[] = {
double_little_steps,
triple_little_steps,
triple_little_steps,
double_little_steps,
triple_little_steps,
triple_little_steps
};
static const SpriteStepFunc sSpeed3[] = {
quad_little_steps,
quad_little_steps,
quad_little_steps,
quad_little_steps
};
static const SpriteStepFunc sSpeed4[] = {
oct_little_steps,
oct_little_steps
};
static const SpriteStepFunc *const sSpriteStepFuncsBySpeed[] = {
sSpeed0,
sSpeed1,
sSpeed2,
sSpeed3,
sSpeed4
};
static const s16 sSpriteStepCountsBySpeed[] = {
NELEMS(sSpeed0),
NELEMS(sSpeed1),
NELEMS(sSpeed2),
NELEMS(sSpeed3),
NELEMS(sSpeed4)
};
bool8 obj_npc_ministep(struct Sprite *sprite)
{
if (sprite->tStepNo >= sSpriteStepCountsBySpeed[sprite->tSpeed])
return FALSE;
sSpriteStepFuncsBySpeed[sprite->tSpeed][sprite->tStepNo](sprite, sprite->tDirection);
sprite->tStepNo++;
if (sprite->tStepNo < sSpriteStepCountsBySpeed[sprite->tSpeed])
return FALSE;
return TRUE;
}
#undef tStepNo
#undef tSpeed
#undef tDirection
#define tDirection data[3]
#define tDelay data[4]
#define tStepNo data[5]
void sub_8068BBC(struct Sprite *sprite, u8 direction)
{
sprite->tDirection = direction;
sprite->tDelay = 0;
sprite->tStepNo = 0;
}
// used by an_walk_any_2
bool8 sub_8068BCC(struct Sprite *sprite)
{
if (!(sprite->tDelay & 1))
{
little_step(sprite, sprite->tDirection);
sprite->tStepNo++;
}
sprite->tDelay++;
if (sprite->tStepNo > 15)
return TRUE;
else
return FALSE;
}
void sub_8068C08(struct Sprite *sprite, u8 direction)
{
sprite->tDirection = direction;
sprite->tDelay = 0;
sprite->tStepNo = 0;
}
bool8 sub_8068C18(struct Sprite *sprite)
{
if (++sprite->tDelay < 3)
{
little_step(sprite, sprite->tDirection);
sprite->tStepNo++;
}
else
sprite->tDelay = 0;
if (sprite->tStepNo > 15)
return TRUE;
else
return FALSE;
}
void sub_8068C58(struct Sprite *sprite, u8 direction)
{
sprite->tDirection = direction;
sprite->tDelay = 0;
sprite->tStepNo = 0;
}
bool8 sub_8068C68(struct Sprite *sprite)
{
if (++sprite->tDelay > 9)
{
sprite->tDelay = 0;
little_step(sprite, sprite->tDirection);
sprite->tStepNo++;
}
if (sprite->tStepNo > 15)
return TRUE;
else
return FALSE;
}
void sub_8068CA4(struct Sprite *sprite, u8 direction)
{
sprite->tDirection = direction;
sprite->tDelay = 0;
sprite->tStepNo = 0;
}
bool8 sub_8068CB4(struct Sprite *sprite)
{
if ((++sprite->tDelay) & 1)
{
little_step(sprite, sprite->tDirection);
sprite->tStepNo++;
}
else
{
double_little_steps(sprite, sprite->tDirection);
sprite->tStepNo += 2;
}
if (sprite->tStepNo > 15)
return TRUE;
else
return FALSE;
}
#undef tStepNo
#undef tDelay
#undef tDirection
#define tDirection data[3]
#define tJumpSpeed data[4]
#define tJumpHeight data[5]
#define tStepNo data[6]
static const s8 sJumpHeight12[] = {
-4, -6, -8, -10, -11, -12, -12, -12, -11, -10, -9, -8, -6, -4, 0, 0
};
static const s8 sJumpHeight6[] = {
0, -2, -3, -4, -5, -6, -6, -6, -5, -5, -4, -3, -2, 0, 0, 0
};
static const s8 sJumpHeight10[] = {
-2, -4, -6, -8, -9, -10, -10, -10, -9, -8, -6, -5, -3, -2, 0, 0
};
static const s8 *const sYDisplacementPtrs[] = {
sJumpHeight12,
sJumpHeight6,
sJumpHeight10
};
static s16 GetJumpYDisplacement(s16 stepno, u8 jumpno)
{
return sYDisplacementPtrs[jumpno][stepno];
}
void sub_8068D1C(struct Sprite *sprite, u8 direction, u8 speed, u8 height)
{
sprite->tDirection = direction;
sprite->tJumpSpeed = speed;
sprite->tJumpHeight = height;
sprite->tStepNo = 0;
}
u8 sub_8068D3C(struct Sprite *sprite)
{
s16 duration[3] = {0x10, 0x10, 0x20};
u8 shifts[3] = {0, 0, 1};
u8 jumpPhase = 0;
if (sprite->tJumpSpeed != 0)
little_step(sprite, sprite->tDirection);
sprite->pos2.y = GetJumpYDisplacement(sprite->tStepNo >> shifts[sprite->tJumpSpeed], sprite->tJumpHeight);
sprite->tStepNo++;
if (sprite->tStepNo == (duration[sprite->tJumpSpeed] >> 1))
jumpPhase = 1;
if (sprite->tStepNo >= duration[sprite->tJumpSpeed])
{
sprite->pos2.y = 0;
jumpPhase = -1;
}
return jumpPhase;
}
u8 sub_8068DC4(struct Sprite *sprite)
{
s16 duration[3] = {0x20, 0x20, 0x40};
u8 shifts[3] = {1, 1, 2};
u8 jumpPhase = 0;
if (sprite->tJumpSpeed != 0 && !(sprite->tStepNo & 1))
little_step(sprite, sprite->tDirection);
sprite->pos2.y = GetJumpYDisplacement(sprite->tStepNo >> shifts[sprite->tJumpSpeed], sprite->tJumpHeight);
sprite->tStepNo++;
if (sprite->tStepNo == (duration[sprite->tJumpSpeed] >> 1))
jumpPhase = 1;
if (sprite->tStepNo >= duration[sprite->tJumpSpeed])
{
sprite->pos2.y = 0;
jumpPhase = -1;
}
return jumpPhase;
}
#undef tStepNo
#undef tJumpHeight
#undef tJumpSpeed
#undef tDirection
#define tDelay data[3]
void SetMovementDelay(struct Sprite *sprite, s16 delay)
{
sprite->tDelay = delay;
}
bool8 WaitForMovementDelay(struct Sprite *sprite)
{
sprite->tDelay--;
if (sprite->tDelay == 0)
return TRUE;
else
return FALSE;
}
#undef tDelay
void SetAndStartSpriteAnim(struct Sprite *sprite, u8 animNum, u8 animCmdIndex)
{
sprite->animNum = animNum;
sprite->animPaused = FALSE;
SeekSpriteAnim(sprite, animCmdIndex);
}
bool8 SpriteAnimEnded(struct Sprite *sprite)
{
if (sprite->animEnded)
return TRUE;
else
return FALSE;
}
void UpdateObjectEventSpriteVisibility(struct Sprite *sprite, bool8 invisible)
{
u16 x, y;
s16 x2, y2;
sprite->invisible = invisible;
if (sprite->coordOffsetEnabled)
{
x = sprite->pos1.x + sprite->pos2.x + sprite->centerToCornerVecX + gSpriteCoordOffsetX;
y = sprite->pos1.y + sprite->pos2.y + sprite->centerToCornerVecY + gSpriteCoordOffsetY;
}
else
{
x = sprite->pos1.x + sprite->pos2.x + sprite->centerToCornerVecX;
y = sprite->pos1.y + sprite->pos2.y + sprite->centerToCornerVecY;
}
x2 = x - (sprite->centerToCornerVecX >> 1);
y2 = y - (sprite->centerToCornerVecY >> 1);
if ((s16)x > 255 || x2 < -16)
sprite->invisible = TRUE;
if ((s16)y > 175 || y2 < -16)
sprite->invisible = TRUE;
}
void UpdateObjectEventSpriteSubpriorityAndVisibility(struct Sprite *sprite)
{
DoObjectUnionRoomWarpYDisplacement(sprite);
SetObjectSubpriorityByZCoord(sprite->tZCoord, sprite, 1);
UpdateObjectEventSpriteVisibility(sprite, sprite->tInvisible);
}
void sub_8068FD0(void)
{
s32 i;
for (i = 0; i < MAX_SPRITES; i++)
{
struct Sprite *sprite = &gSprites[i];
if (sprite->inUse && sprite->callback == UpdateObjectEventSpriteSubpriorityAndVisibility)
{
DestroySprite(sprite);
}
}
}
#define tUnionRoomWarpAnimNo data[3]
#define tUnionRoomWarpAnimState data[4]
static int GetObjectEventSpriteId(u8 objectEventId)
{
int i;
for (i = 0; i < MAX_SPRITES; i++)
{
struct Sprite *sprite = &gSprites[i];
if (sprite->inUse && sprite->callback == UpdateObjectEventSpriteSubpriorityAndVisibility && (u8)sprite->tObjectEventId == objectEventId)
{
return i;
}
}
return MAX_SPRITES;
}
void TurnObjectEvent(u8 objectEventId, u8 direction)
{
u8 animNum;
u8 spriteId = GetObjectEventSpriteId(objectEventId);
if (spriteId != MAX_SPRITES)
{
struct Sprite *sprite = &gSprites[spriteId];
StartSpriteAnim(sprite, GetFaceDirectionAnimNum(direction));
}
}
void RfuUnionObjectSetFacingDirection(u8 objectEventId, u8 direction)
{
u8 animNum;
int spriteId = GetObjectEventSpriteId(objectEventId);
u16 baseBlock;
if (spriteId != MAX_SPRITES)
{
struct Sprite *sprite = &gSprites[spriteId];
const struct ObjectEventGraphicsInfo * info = GetObjectEventGraphicsInfo(direction);
baseBlock = sprite->oam.tileNum;
sprite->oam = *info->oam;
sprite->oam.tileNum = baseBlock;
sprite->oam.paletteNum = info->paletteSlot;
sprite->images = info->images;
if (info->subspriteTables == NULL)
{
sprite->subspriteTables = NULL;
sprite->subspriteTableNum = 0;
sprite->subspriteMode = SUBSPRITES_OFF;
}
else
{
SetSubspriteTables(sprite, info->subspriteTables);
sprite->subspriteMode = SUBSPRITES_IGNORE_PRIORITY;
}
StartSpriteAnim(sprite, 0);
}
}
void RfuUnionObjectToggleInvisibility(u8 objectEventId, bool32 invisible)
{
u8 spriteId = GetObjectEventSpriteId(objectEventId);
if (spriteId != MAX_SPRITES)
{
if (invisible)
gSprites[spriteId].tInvisible = TRUE;
else
gSprites[spriteId].tInvisible = FALSE;
}
}
bool32 RfuUnionObjectIsInvisible(u8 objectEventId)
{
u8 spriteId = GetObjectEventSpriteId(objectEventId);
if (spriteId == MAX_SPRITES)
return FALSE;
return gSprites[spriteId].tInvisible == TRUE;
}
void RfuUnionObjectStartWarp(u8 objectEventId, u8 animNo)
{
u8 spriteId = GetObjectEventSpriteId(objectEventId);
if (spriteId != MAX_SPRITES)
{
gSprites[spriteId].tUnionRoomWarpAnimNo = animNo;
gSprites[spriteId].tUnionRoomWarpAnimState = 0;
}
}
static void DoObjectUnionRoomWarpYDisplacementUpwards(struct Sprite * sprite)
{
switch (sprite->tUnionRoomWarpAnimState)
{
case 0:
sprite->pos2.y = 0;
sprite->tUnionRoomWarpAnimState++;
// fallthrough
case 1:
if ((sprite->pos2.y -= 8) == -160)
{
sprite->pos2.y = 0;
sprite->tInvisible = 1;
sprite->tUnionRoomWarpAnimNo = 0;
sprite->tUnionRoomWarpAnimState = 0;
}
break;
}
}
static void DoObjectUnionRoomWarpYDisplacementDownwards(struct Sprite * sprite)
{
switch (sprite->tUnionRoomWarpAnimState)
{
case 0:
sprite->pos2.y = -160;
sprite->tUnionRoomWarpAnimState++;
// fallthrough
case 1:
if ((sprite->pos2.y += 8) == 0)
{
sprite->tUnionRoomWarpAnimNo = 0;
sprite->tUnionRoomWarpAnimState = 0;
}
break;
}
}
static void DoObjectUnionRoomWarpYDisplacement(struct Sprite * sprite)
{
switch (sprite->tUnionRoomWarpAnimNo)
{
case 0:
break;
case 1:
DoObjectUnionRoomWarpYDisplacementDownwards(sprite);
break;
case 2:
DoObjectUnionRoomWarpYDisplacementUpwards(sprite);
break;
default:
sprite->tUnionRoomWarpAnimNo = 0;
AGB_ASSERT_EX(0, ABSPATH("evobjmv.c"), 13331);
}
}
bool32 RfuUnionObjectIsWarping(u8 objectEventId)
{
u8 spriteId = GetObjectEventSpriteId(objectEventId);
if (spriteId == MAX_SPRITES)
return FALSE;
if (gSprites[spriteId].tUnionRoomWarpAnimNo)
return TRUE;
else
return FALSE;
}
#undef tUnionRoomWarpAnimState
#undef tUnionRoomWarpAnimNo
#undef tInvisible
#undef tZCoord
#undef tObjectEventId
u32 StartFieldEffectForObjectEvent(u8 fieldEffectId, struct ObjectEvent * objectEvent)
{
ObjectEventGetLocalIdAndMap(objectEvent, (u8 *)&gFieldEffectArguments[0], (u8 *)&gFieldEffectArguments[1], (u8 *)&gFieldEffectArguments[2]);
return FieldEffectStart(fieldEffectId);
}
void DoShadowFieldEffect(struct ObjectEvent *objectEvent)
{
if (!objectEvent->hasShadow)
{
objectEvent->hasShadow = TRUE;
StartFieldEffectForObjectEvent(FLDEFF_SHADOW, objectEvent);
}
}
void DoRippleFieldEffect(struct ObjectEvent *objectEvent, struct Sprite *sprite)
{
const struct ObjectEventGraphicsInfo *graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId);
gFieldEffectArguments[0] = sprite->pos1.x;
gFieldEffectArguments[1] = sprite->pos1.y + (graphicsInfo->height >> 1) - 2;
gFieldEffectArguments[2] = 151;
gFieldEffectArguments[3] = 3;
FieldEffectStart(FLDEFF_RIPPLE);
}

File diff suppressed because it is too large Load Diff

View File

@ -323,7 +323,6 @@ void AnimatePcTurnOff()
void SpawnCameraObject(void)
{
u8 objectEventId = SpawnSpecialObjectEventParameterized(OBJ_EVENT_GFX_YOUNGSTER, 8, OBJ_EVENT_ID_CAMERA, gSaveBlock1Ptr->pos.x + 7, gSaveBlock1Ptr->pos.y + 7, 3);
gObjectEvents[objectEventId].invisible = TRUE;
CameraObjectSetFollowedObjectId(gObjectEvents[objectEventId].spriteId);

View File

@ -7,8 +7,6 @@
#include "quest_log.h"
#include "fieldmap.h"
#define VMap gBackupMapLayout // Needed for AGB_ASSERT_EX to match
struct ConnectionFlags
{
u8 south:1;
@ -29,7 +27,7 @@ static struct MapConnection *sub_8059600(u8 direction, s32 x, s32 y);
static bool8 sub_8059658(u8 direction, s32 x, s32 y, struct MapConnection *connection);
static bool8 sub_80596BC(s32 x, s32 src_width, s32 dest_width, s32 offset);
struct BackupMapLayout gBackupMapLayout;
struct BackupMapLayout VMap;
EWRAM_DATA u16 gBackupMapData[VIRTUAL_MAP_SIZE] = {};
EWRAM_DATA struct MapHeader gMapHeader = {};
EWRAM_DATA struct Camera gCamera = {};
@ -82,9 +80,9 @@ static void InitMapLayoutData(struct MapHeader * mapHeader)
{
const struct MapLayout * mapLayout = mapHeader->mapLayout;
CpuFastFill(0x03FF03FF, gBackupMapData, sizeof(gBackupMapData));
gBackupMapLayout.map = gBackupMapData;
gBackupMapLayout.Xsize = mapLayout->width + 15;
gBackupMapLayout.Ysize = mapLayout->height + 14;
VMap.map = gBackupMapData;
VMap.Xsize = mapLayout->width + 15;
VMap.Ysize = mapLayout->height + 14;
AGB_ASSERT_EX(VMap.Xsize * VMap.Ysize <= VIRTUAL_MAP_SIZE, ABSPATH("fieldmap.c"), 158);
map_copy_with_padding(mapLayout->map, mapLayout->width, mapLayout->height);
mapheader_copy_mapdata_of_adjacent_maps(mapHeader);
@ -93,8 +91,8 @@ static void InitMapLayoutData(struct MapHeader * mapHeader)
static void map_copy_with_padding(u16 *map, u16 width, u16 height)
{
s32 y;
u16 *dest = gBackupMapLayout.map;
dest += gBackupMapLayout.Xsize * 7 + 7;
u16 *dest = VMap.map;
dest += VMap.Xsize * 7 + 7;
for (y = 0; y < height; y++)
{
@ -159,12 +157,12 @@ static void sub_8058B54(s32 x, s32 y, const struct MapHeader *connectedMapHeader
mapWidth = connectedMapHeader->mapLayout->width;
src = &connectedMapHeader->mapLayout->map[mapWidth * y2 + x2];
dest = &gBackupMapLayout.map[gBackupMapLayout.Xsize * y + x];
dest = &VMap.map[VMap.Xsize * y + x];
for (i = 0; i < height; i++)
{
CpuCopy16(src, dest, width * 2);
dest += gBackupMapLayout.Xsize;
dest += VMap.Xsize;
src += mapWidth;
}
}
@ -185,26 +183,26 @@ static void fillSouthConnection(struct MapHeader const *mapHeader, struct MapHea
{
x2 = -x;
x += cWidth;
if (x < gBackupMapLayout.Xsize)
if (x < VMap.Xsize)
{
width = x;
}
else
{
width = gBackupMapLayout.Xsize;
width = VMap.Xsize;
}
x = 0;
}
else
{
x2 = 0;
if (x + cWidth < gBackupMapLayout.Xsize)
if (x + cWidth < VMap.Xsize)
{
width = cWidth;
}
else
{
width = gBackupMapLayout.Xsize - x;
width = VMap.Xsize - x;
}
}
@ -233,26 +231,26 @@ static void fillNorthConnection(struct MapHeader const *mapHeader, struct MapHea
{
x2 = -x;
x += cWidth;
if (x < gBackupMapLayout.Xsize)
if (x < VMap.Xsize)
{
width = x;
}
else
{
width = gBackupMapLayout.Xsize;
width = VMap.Xsize;
}
x = 0;
}
else
{
x2 = 0;
if (x + cWidth < gBackupMapLayout.Xsize)
if (x + cWidth < VMap.Xsize)
{
width = cWidth;
}
else
{
width = gBackupMapLayout.Xsize - x;
width = VMap.Xsize - x;
}
}
@ -280,26 +278,26 @@ static void fillWestConnection(struct MapHeader const *mapHeader, struct MapHead
if (y < 0)
{
y2 = -y;
if (y + cHeight < gBackupMapLayout.Ysize)
if (y + cHeight < VMap.Ysize)
{
height = y + cHeight;
}
else
{
height = gBackupMapLayout.Ysize;
height = VMap.Ysize;
}
y = 0;
}
else
{
y2 = 0;
if (y + cHeight < gBackupMapLayout.Ysize)
if (y + cHeight < VMap.Ysize)
{
height = cHeight;
}
else
{
height = gBackupMapLayout.Ysize - y;
height = VMap.Ysize - y;
}
}
@ -325,26 +323,26 @@ static void fillEastConnection(struct MapHeader const *mapHeader, struct MapHead
if (y < 0)
{
y2 = -y;
if (y + cHeight < gBackupMapLayout.Ysize)
if (y + cHeight < VMap.Ysize)
{
height = y + cHeight;
}
else
{
height = gBackupMapLayout.Ysize;
height = VMap.Ysize;
}
y = 0;
}
else
{
y2 = 0;
if (y + cHeight < gBackupMapLayout.Ysize)
if (y + cHeight < VMap.Ysize)
{
height = cHeight;
}
else
{
height = gBackupMapLayout.Ysize - y;
height = VMap.Ysize - y;
}
}
@ -406,9 +404,9 @@ union Block
block; \
})
#define AreCoordsWithinMapGridBounds(x, y) (x >= 0 && x < gBackupMapLayout.Xsize && y >= 0 && y < gBackupMapLayout.Ysize)
#define AreCoordsWithinMapGridBounds(x, y) (x >= 0 && x < VMap.Xsize && y >= 0 && y < VMap.Ysize)
#define MapGridGetTileAt(x, y) (AreCoordsWithinMapGridBounds(x, y) ? gBackupMapLayout.map[x + gBackupMapLayout.Xsize * y] : MapGridGetBorderTileAt2(x, y))
#define MapGridGetTileAt(x, y) (AreCoordsWithinMapGridBounds(x, y) ? VMap.map[x + VMap.Xsize * y] : MapGridGetBorderTileAt2(x, y))
u8 MapGridGetZCoordAt(s32 x, s32 y)
{
@ -473,37 +471,37 @@ u8 MapGridGetMetatileLayerTypeAt(s16 x, s16 y)
void MapGridSetMetatileIdAt(s32 x, s32 y, u16 metatile)
{
s32 i;
if (x >= 0 && x < gBackupMapLayout.Xsize
&& y >= 0 && y < gBackupMapLayout.Ysize)
if (x >= 0 && x < VMap.Xsize
&& y >= 0 && y < VMap.Ysize)
{
i = x + y * gBackupMapLayout.Xsize;
gBackupMapLayout.map[i] = (gBackupMapLayout.map[i] & 0xf000) | (metatile & 0xfff);
i = x + y * VMap.Xsize;
VMap.map[i] = (VMap.map[i] & 0xf000) | (metatile & 0xfff);
}
}
void MapGridSetMetatileEntryAt(s32 x, s32 y, u16 metatile)
{
s32 i;
if (x >= 0 && x < gBackupMapLayout.Xsize
&& y >= 0 && y < gBackupMapLayout.Ysize)
if (x >= 0 && x < VMap.Xsize
&& y >= 0 && y < VMap.Ysize)
{
i = x + gBackupMapLayout.Xsize * y;
gBackupMapLayout.map[i] = metatile;
i = x + VMap.Xsize * y;
VMap.map[i] = metatile;
}
}
void MapGridSetMetatileImpassabilityAt(s32 x, s32 y, bool32 arg2)
{
if (x >= 0 && x < gBackupMapLayout.Xsize
&& y >= 0 && y < gBackupMapLayout.Ysize)
if (x >= 0 && x < VMap.Xsize
&& y >= 0 && y < VMap.Ysize)
{
if (arg2)
{
gBackupMapLayout.map[x + gBackupMapLayout.Xsize * y] |= 0x0C00;
VMap.map[x + VMap.Xsize * y] |= 0x0C00;
}
else
{
gBackupMapLayout.map[x + gBackupMapLayout.Xsize * y] &= ~0x0C00;
VMap.map[x + VMap.Xsize * y] &= ~0x0C00;
}
}
}
@ -535,7 +533,7 @@ void save_serialize_map(void)
u16 *mapView;
s32 width;
mapView = gSaveBlock2Ptr->mapView;
width = gBackupMapLayout.Xsize;
width = VMap.Xsize;
x = gSaveBlock1Ptr->pos.x;
y = gSaveBlock1Ptr->pos.y;
for (i = y; i < y + 14; i++)
@ -576,7 +574,7 @@ static void LoadSavedMapView(void)
mapView = gSaveBlock2Ptr->mapView;
if (!SavedMapViewIsEmpty())
{
width = gBackupMapLayout.Xsize;
width = VMap.Xsize;
x = gSaveBlock1Ptr->pos.x;
y = gSaveBlock1Ptr->pos.y;
for (i = y; i < y + 14; i++)
@ -603,7 +601,7 @@ static void sub_8059250(u8 a1)
s32 x, y;
s32 i, j;
mapView = gSaveBlock2Ptr->mapView;
width = gBackupMapLayout.Xsize;
width = VMap.Xsize;
r9 = 0;
r8 = 0;
x0 = gSaveBlock1Ptr->pos.x;
@ -654,7 +652,7 @@ s32 GetMapBorderIdAt(s32 x, s32 y)
return -1;
}
if (x >= gBackupMapLayout.Xsize - 8)
if (x >= VMap.Xsize - 8)
{
if (!gMapConnectionFlags.east)
{
@ -672,7 +670,7 @@ s32 GetMapBorderIdAt(s32 x, s32 y)
return CONNECTION_WEST;
}
if (y >= gBackupMapLayout.Ysize - 7)
if (y >= VMap.Ysize - 7)
{
if (!gMapConnectionFlags.south)
{

View File

@ -7,7 +7,7 @@ static const bool8 sTileSurfable[METATILE_COUNT] = {
[MB_SEMI_DEEP_WATER] = TRUE,
[MB_DEEP_WATER] = TRUE,
[MB_WATERFALL] = TRUE,
[MB_SPLASHING_WATER] = TRUE,
[MB_OCEAN_WATER] = TRUE,
[MB_1A] = TRUE,
[MB_1B] = TRUE,
[MB_EASTWARD_CURRENT] = TRUE,
@ -69,17 +69,17 @@ bool8 MetatileBehavior_IsPokeGrass(u8 metatileBehavior)
return FALSE;
}
bool8 MetatileBehavior_IsSandOrDeepSand(u8 metatileBehavior)
bool8 MetatileBehavior_IsSand(u8 metatileBehavior)
{
if(metatileBehavior == MB_21 || metatileBehavior == MB_SAND)
if(metatileBehavior == MB_SAND || metatileBehavior == MB_SAND_CAVE)
return TRUE;
else
return FALSE;
}
bool8 MetatileBehavior_IsMB21OrWaterfallBottom(u8 metatileBehavior)
bool8 MetatileBehavior_IsSandOrShallowFlowingWater(u8 metatileBehavior)
{
if(metatileBehavior == MB_21 || metatileBehavior == MB_WATERFALL_BOTTOM)
if(metatileBehavior == MB_SAND || metatileBehavior == MB_SHALLOW_WATER)
return TRUE;
else
return FALSE;
@ -490,9 +490,9 @@ bool8 MetatileBehavior_IsMB19(u8 metatileBehavior)
return FALSE;
}
bool8 MetatileBehavior_IsWaterfallBottom(u8 metatileBehavior)
bool8 MetatileBehavior_IsShallowFlowingWater(u8 metatileBehavior)
{
if(metatileBehavior == MB_WATERFALL_BOTTOM)
if(metatileBehavior == MB_SHALLOW_WATER)
return TRUE;
else
return FALSE;
@ -517,7 +517,7 @@ bool8 MetatileBehavior_IsCrackedIce(u8 metatileBehavior)
bool8 MetatileBehavior_IsDeepSemiDeepOrSplashingWater(u8 metatileBehavior)
{
if((metatileBehavior >= MB_SEMI_DEEP_WATER && metatileBehavior <= MB_DEEP_WATER)
|| metatileBehavior == MB_SPLASHING_WATER)
|| metatileBehavior == MB_OCEAN_WATER)
return TRUE;
else
return FALSE;
@ -647,7 +647,7 @@ bool8 MetatileBehavior_IsUnionRoomWarp(u8 metatileBehavior)
bool8 MetatileBehavior_IsWater(u8 metatileBehavior)
{
if((metatileBehavior >= MB_POND_WATER && metatileBehavior <= MB_DEEP_WATER)
|| metatileBehavior == MB_SPLASHING_WATER
|| metatileBehavior == MB_OCEAN_WATER
|| (metatileBehavior >= MB_EASTWARD_CURRENT && metatileBehavior <= MB_SOUTHWARD_CURRENT))
return TRUE;
else

View File

@ -633,7 +633,7 @@ void sub_810C444(void)
for (i = 0; i < gMapHeader.events->objectEventCount; i++)
{
if ((templates[i].trainerType == 1 || templates[i].trainerType == 3) && (templates[i].movementType == 0x4D || templates[i].movementType == 0x4E || templates[i].movementType == 0x4F))
if ((templates[i].trainerType == 1 || templates[i].trainerType == 3) && (templates[i].movementType == MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_DOWN || templates[i].movementType == MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_UP || templates[i].movementType == MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_LEFT))
{
r6 = sub_810CF54();
TryGetObjectEventIdByLocalIdAndMap(templates[i].localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &sp0);
@ -696,7 +696,7 @@ static void sub_810C594(void)
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
{
struct ObjectEvent * objectEvent = &gObjectEvents[i];
if (objectEvent->movementType == 0x4D || objectEvent->movementType == 0x4E || objectEvent->movementType == 0x4F)
if (objectEvent->movementType == MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_DOWN || objectEvent->movementType == MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_UP || objectEvent->movementType == MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_LEFT)
{
u8 r3 = sub_810CF54();
if (objectEvent->active && gSprites[objectEvent->spriteId].data[0] == i)

View File

@ -87,20 +87,14 @@ gUnknown_2036E30: @ 2036E30
gUnknown_2036E34: @ 2036E34
.space 0x4
.align 2
@ .include "src/event_object_movement.o"
gObjectEvents: @ 2036E38
.space 0x240
gPlayerAvatar: @ 2037078
.space 0x20
sCurrentReflectionType: @ 2037098
.space 0x2
sCurrentSpecialObjectPaletteTag: @ 203709A
.space 0x2
.align 2
.include "src/event_object_movement.o"
.align 2
.include "src/field_message_box.o"
.align 2