sa1: move more source, more alignment

This commit is contained in:
Oliver Bell committed 2026-04-09 23:44:28 +01:00
1 parent fc1ca96721
commit f4a041adde
58 files changed
+307 -240

No files matched your search

+3 -1
View File
@@ -14,8 +14,10 @@ typedef s32 CamCoord;
#define TILE_WIDTH 8
#define CAM_REGION_WIDTH 256
#define TILES_PER_METATILE_AXIS 12
#define METATILE_DIM (TILES_PER_METATILE_AXIS * TILE_WIDTH)
#define TO_WORLD_POS(pos, region) ((pos)*TILE_WIDTH + (region)*CAM_REGION_WIDTH)
#define TO_WORLD_POS(pos, region) ((pos)*TILE_WIDTH + (region)*CAM_REGION_WIDTH)
#define TO_WORLD_POS_INV(pos, region) ((region)*CAM_REGION_WIDTH + (pos)*TILE_WIDTH)
#define CAM_BOUND_X ((DISPLAY_WIDTH) + (CAM_REGION_WIDTH))
#define CAM_BOUND_Y ((DISPLAY_HEIGHT) + ((CAM_REGION_WIDTH) / 2))
+21
View File
@@ -11,6 +11,10 @@
#define COLL_FLAG_2 0x00000002
#define COLL_FLAG_4 0x00000004
#define COLL_FLAG_8 0x00000008
#define COLL_FLAG_10 0x00000010
#define COLL_FLAG_20 0x00000020
#define COLL_FLAG_40 0x00000040
#define COLL_FLAG_80 0x00000080
#define COLL_FLAG_10000 0x00010000
#define COLL_FLAG_20000 0x00020000
#define COLL_FLAG_40000 0x00040000
@@ -20,7 +24,11 @@
u32 Coll_Player_Entity_RectIntersection(Sprite *s, s32 sx, s32 sy, Player *p, Rect8 *rectPlayer);
// TODO: Include header this belongs to
#if (GAME == GAME_SA1)
u32 Coll_Player_Itembox(Sprite *s, CamCoord worldX, CamCoord worldY, Player *p);
#else
u32 Coll_Player_ItemBox(Sprite *, s32, s32);
#endif
bool32 Coll_Player_Entity_HitboxN(Sprite *, s32, s32, s16, Player *, s16);
bool32 Coll_Player_Boss_Attack(Sprite *s, s32 sx, s32 sy, s16 hbIndex, Player *p);
@@ -28,7 +36,16 @@ bool32 Coll_Player_Enemy(Sprite *s, s32 sx, s32 sy, s16 hbIndex, Player *p);
bool32 Coll_Cheese_Enemy_Attack(Sprite *sprTarget, s32 sx, s32 sy, s16 hbIndex, Player *p);
u32 sub_800DA4C(Sprite *opponent, s16 oppX, s16 oppY, UNUSED s32 param3, UNUSED s32 param4, u8 layer);
u32 sub_800CDBC(Sprite *, s32, s32, Player *);
#if (GAME == GAME_SA1)
u32 Coll_Player_SkatingStone(Sprite *, CamCoord x, CamCoord y, Player *);
u32 Coll_Player_Gate(Sprite *s, CamCoord worldX, CamCoord worldY, Player *p, u32 param4);
u32 sub_800C394(Sprite *s, CamCoord screenX, CamCoord screenY, Player *p);
u32 Coll_Player_Spring_Sideways(Sprite *s, CamCoord worldX, CamCoord worldY, Player *p);
u32 Coll_Player_PlatformCrumbling(Sprite *s, CamCoord worldX, CamCoord worldY, Player *p);
u32 Coll_Player_Entity_Intersection(Sprite *s, CamCoord x, CamCoord y, Player *p);
#else
u32 Coll_Player_Entity_Intersection(Sprite *, s32, s32, Player *);
#endif
u32 Coll_Player_Interactable(Sprite *s, s32 sx, s32 sy, Player *p);
bool32 Coll_DamagePlayer(Player *);
@@ -36,6 +53,10 @@ void Coll_Player_Enemy_AdjustSpeed(Player *);
u32 Coll_Player_Platform(Sprite *, s32 x, s32 y, Player *);
#if (GAME == GAME_SA1)
bool32 Coll_AmyHammer_Spring(Sprite *s, CamCoord worldX, CamCoord worldY, Player *p);
#endif
u32 sub_800CE94(Sprite *s, s32 sx, s32 sy, Rect8 *param3, Player *p);
bool32 SA2_LABEL(sub_800DD54)(Player *p);
bool32 SA2_LABEL(sub_800DE44)(Player *p);
@@ -6,6 +6,12 @@
#include "task.h"
#include "game/shared/stage/entity.h"
// TODO: merge with the below
typedef struct {
/* 0x00 */ SpriteBase base;
/* 0x0C */ Sprite s;
} EntityShared;
typedef struct {
/* 0x00 */ SpriteBase base;
/* 0x0C */ Sprite displayed;
@@ -42,5 +48,7 @@ void CreateEnemyDefeatScoreAndManageLives(s16 x, s16 y);
// TaskDestructor_SpriteEntity
void TaskDestructor_80095E8(struct Task *);
// The same as above, should align the name
void TaskDestructor_EntityShared(struct Task *);
#endif
+24 -7
View File
@@ -6,17 +6,21 @@
#include "sprite.h"
#include "game/globals.h"
#include "game/shared/stage/collision.h"
#include "game/shared/stage/player.h"
#include "game/shared/stage/terrain_collision.h"
#if (GAME == GAME_SA2)
#include "game/sa2/stage/player_callbacks.h"
#endif
#include "game/shared/stage/player.h"
#include "game/shared/stage/camera.h"
#define ENTITY_DATA_SIZE_SA1 4
#define ENTITY_DATA_SIZE_SA2 4
#define ENTITY_DATA_SIZE_SA3 5
#define ENTITY_DATA_SIZE ENTITY_DATA_SIZE_SA2
#define ENTITY_DATA_SIZE ENTITY_DATA_SIZE_SA1
PACKED(MapEntity, {
/* 0x00 */ u8 x; // While an enemy is active, x gets repurposed as a "state"
@@ -58,6 +62,10 @@ typedef struct {
Sprite s;
} EnemyBase;
u32 sub_800CDBC(Sprite *, s32, s32, Player *);
u32 Coll_Player_Entity_Intersection(Sprite *s, CamCoord x, CamCoord y, Player *p);
// After a MapEntity is initialized, its x-value in the layout-data gets set to -2.
// TODO:
// Find out whether casting these to u8 can work while still matching!
@@ -65,6 +73,8 @@ typedef struct {
#define MAP_ENTITY_STATE_INITIALIZED (-2)
#define MAP_ENTITY_STATE_MINUS_THREE (-3)
#define SET_MAP_ENTITY_INITIALIZED_SIMPLE(mapEnt) (mapEnt)->x = MAP_ENTITY_STATE_INITIALIZED;
// TODO: Find a way to simplify/remove this macro!
#define SET_MAP_ENTITY_INITIALIZED(mapEnt) \
{ \
@@ -101,13 +111,20 @@ typedef struct {
#define ENEMY_SET_SPAWN_POS_GROUND(_enemy, _mapEntity) \
ENEMY_SET_SPAWN_POS_STATIC(_enemy, _mapEntity); \
_enemy->offsetX = 0; \
_enemy->offsetY = Q(sub_801F07C(I(_enemy->spawnY), I(_enemy->spawnX), _enemy->clampParam, 8, NULL, sub_801EE64));
_enemy->offsetY = Q(SA2_LABEL(sub_801F07C)(I(_enemy->spawnY), I(_enemy->spawnX), _enemy->clampParam, 8, NULL, SA2_LABEL(sub_801EE64)));
#if (GAME == GAME_SA1)
#define ENEMY_UPDATE_EX_RAW(_s, _posX, _posY, code_insert) \
{ code_insert }; \
UpdateSpriteAnimation(_s); \
DisplaySprite(_s);
#else
#define ENEMY_UPDATE_EX_RAW(_s, _posX, _posY, code_insert) \
Player_UpdateHomingPosition(_posX, _posY); \
{ code_insert }; \
UpdateSpriteAnimation(_s); \
DisplaySprite(_s);
#endif
#define ENEMY_UPDATE_EX(_s, _posX, _posY, code_insert) ENEMY_UPDATE_EX_RAW(_s, QS(_posX), QS(_posY), code_insert);
@@ -161,8 +178,8 @@ typedef struct {
#define ENEMY_CLAMP_TO_GROUND_RAW(_enemy, _unknownBool, _p) \
{ \
s32 delta \
= sub_801F07C(I(_enemy->spawnY + _enemy->offsetY), I(_enemy->spawnX + _enemy->offsetX), _unknownBool, 8, _p, sub_801EE64); \
s32 delta = SA2_LABEL(sub_801F07C)(I(_enemy->spawnY + _enemy->offsetY), I(_enemy->spawnX + _enemy->offsetX), _unknownBool, 8, _p, \
sub_801EE64); \
\
if (delta < 0) { \
_enemy->offsetY += Q(delta); \
@@ -178,8 +195,8 @@ typedef struct {
#define ENEMY_CLAMP_TO_GROUND_2(_enemy, _unknownBool) \
{ \
s32 delta \
= sub_801F07C(I(_enemy->spawnY + _enemy->offsetY), I(_enemy->spawnX + _enemy->offsetX), _unknownBool, -8, NULL, sub_801EE64); \
s32 delta = SA2_LABEL(sub_801F07C)(I(_enemy->spawnY + _enemy->offsetY), I(_enemy->spawnX + _enemy->offsetX), _unknownBool, -8, \
NULL, SA2_LABEL(sub_801EE64)); \
\
if (delta < 0) { \
_enemy->offsetY -= Q(delta); \
@@ -0,0 +1,8 @@
#ifndef GUARD_GRIND_EFFECT_1_H
#define GUARD_GRIND_EFFECT_1_H
#include "task.h"
struct Task *CreateGrindEffect(void);
#endif // GUARD_GRIND_EFFECT_1_H
+14
View File
@@ -73,6 +73,20 @@ typedef struct {
u8 targetPlayer;
} RoomEvent_ItemEffect;
typedef struct {
ROOMEVENT_BASE;
u8 x; // regionX truncated
u8 y; // regionY truncated
u8 id;
u8 unk4;
} RoomEvent_BalloonPopped;
typedef struct {
ROOMEVENT_BASE;
u8 id1;
u8 id2;
} RoomEvent_ChaoCollected;
typedef struct {
ROOMEVENT_BASE;
u8 unk1;
+1 -1
View File
@@ -279,7 +279,7 @@ typedef struct Player_ {
#endif
} Player;
extern s32 sa2__sub_8022F58(u8 param0, Player *p);
s32 SA2_LABEL(sub_8022F58)(u8 param0, Player *p);
extern Player gPlayer;
#if (GAME == GAME_SA1)
@@ -5,20 +5,20 @@
#include "core.h"
typedef s32 (*Func801F100)(s32, s32, s32);
s32 sub_801EB44(s32, s32, s32);
s32 sub_801EC3C(s32, s32, s32);
s32 SA2_LABEL(sub_801EB44)(s32, s32, s32);
s32 SA2_LABEL(sub_801EC3C)(s32, s32, s32);
typedef s32 (*Func801F07C)(s32, s32, s32, u8 *);
s32 sub_801ED24(s32, s32, s32, u8 *);
s32 sub_801EE64(s32, s32, s32, u8 *);
s32 sub_801F07C(s32, s32, s32, s32, u8 *, Func801F07C);
s32 SA2_LABEL(sub_801ED24)(s32, s32, s32, u8 *);
s32 SA2_LABEL(sub_801EE64)(s32, s32, s32, u8 *);
s32 SA2_LABEL(sub_801F07C)(s32, s32, s32, s32, u8 *, Func801F07C);
// ground collision clamp functions
s32 sub_801E4E4(s32, s32, s32, s32, u8 *, Func801F07C);
s32 SA2_LABEL(sub_801E4E4)(s32, s32, s32, s32, u8 *, Func801F07C);
s32 sub_801E6D4(s32, s32, s32, s32, u8 *, Func801F07C);
void SA2_LABEL(sub_801F044)(void);
s32 sub_801F100(s32, s32, s32, s32, Func801F100);
s32 SA2_LABEL(sub_801F100)(s32, s32, s32, s32, Func801F100);
extern const Collision *gRefCollision;
extern const Collision *const gCollisionTable[];