Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/game/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ u16 Random(void);
// Returns a 32-bit pseudorandom number
#define Random32() ((Random() << 16) | Random())

#define ShuffleRngSeed() \
#define SHUFFLE_RNG_SEED() \
({ \
u32 rand1, rand2, rand3; \
rand1 ^= (Random() << 16); \
Expand Down
94 changes: 29 additions & 65 deletions include/game/shared/stage/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,83 +30,52 @@ typedef void (*BgUpdate)(s32, s32);

// NOTE: This was copy-pasted from SA2.
// There are type differences for members
typedef struct Camera {
typedef struct {
/* 0x00|0x04 */ CamCoord x; // TODO: might this be unsigned actually?
/* 0x02|0x04 */ CamCoord y; // TODO: might this be unsigned actually?
#if (GAME == GAME_SA1)
/* 0x04 */ s16 SA2_LABEL(unk8);
/* 0x06 */ s16 SA2_LABEL(unkC);
/* 0x04 */ CamCoord SA2_LABEL(unk8);
/* 0x06 */ CamCoord SA2_LABEL(unkC);
/* 0x08 */ CamCoord SA2_LABEL(unk10);
/* 0x0A */ CamCoord SA2_LABEL(unk14);
/* 0x0C */ s16 shiftX;
/* 0x0E */ s16 shiftY;
/* 0x10 */ s16 SA2_LABEL(unk20);
/* 0x12 */ s16 SA2_LABEL(unk24);

/* 0x18 */ CamCoord shiftX;
/* 0x1C */ CamCoord shiftY;
/* 0x20 */ CamCoord SA2_LABEL(unk20);
/* 0x12 */ CamCoord SA2_LABEL(unk24);
// TODO: Why are X/Y swapped?
// Did they make this a matrix or sth.?
// (Used to calc min/max cam pos in UpdateCamera())
/* 0x14 */ s16 minY;
/* 0x16 */ s16 maxY;
/* 0x18 */ s16 minX;
/* 0x1A */ s16 maxX;
/* 0x28 */ CamCoord minY;
/* 0x2c */ CamCoord maxY;
/* 0x30 */ CamCoord minX;
/* 0x34 */ CamCoord maxX;
#if (GAME == GAME_SA2)
/* 0x38 */ CamCoord dx;
/* 0x3c */ CamCoord dy;
#endif
/* 0x1C */ s16 SA2_LABEL(unk40);
/* 0x1E */ s16 SA2_LABEL(unk44);
/* 0x20 */ s16 SA2_LABEL(unk48);
/* 0x22 */ s16 SA2_LABEL(unk4C);
/* 0x1E */ CamCoord SA2_LABEL(unk44);
/* 0x20 */ CamCoord SA2_LABEL(unk48);
/* 0x22 */ CamCoord SA2_LABEL(unk4C);
#if (GAME == GAME_SA1)
/* 0x24 */ u16 unk24;
#endif
// 0x4 = spectator
// mode
/* 0x26 */ u16 SA2_LABEL(unk50);
/* 0x28 */ u16 SA2_LABEL(unk52);
/* 0x2A */ u16 SA2_LABEL(unk54);
#if (GAME == GAME_SA2)
/* 0x56 */ s16 unk56;
#endif
/* 0x2C */ BgUpdate fnBgUpdate;
/* 0x30 */ struct Task *movementTask;
/* 0x34 */ s16 shakeOffsetX;
/* 0x36 */ s16 shakeOffsetY;
/* 0x38 */ s16 SA2_LABEL(unk64);
/* 0x3A */ u8 spectatorTarget;
/* 0x3B */ u8 filler3B[0x2];
#elif (GAME == GAME_SA2)
/* 0x08 */ s32 unk8;
/* 0x0C */ s32 unkC;
/* 0x10 */ s32 unk10;
/* 0x14 */ s32 unk14;
/* 0x18 */ s32 shiftX;
/* 0x1C */ s32 shiftY;
/* 0x20 */ s32 unk20;
/* 0x24 */ s32 unk24;

// TODO: Why are X/Y swapped?
// Did they make this a matrix or sth.?
// (Used to calc min/max cam pos in UpdateCamera())
/* 0x28 */ s32 minY;
/* 0x2c */ s32 maxY;
/* 0x30 */ s32 minX;
/* 0x34 */ s32 maxX;

/* 0x38 */ s32 dx;
/* 0x3c */ s32 dy;
/* 0x40 */ s16 unk40;
/* 0x44 */ s32 unk44;
/* 0x48 */ s32 unk48;
/* 0x4c */ s32 unk4C;

// 0x4 = spectator
// mode
/* 0x50 */ u16 unk50;

/* 0x52 */ u16 SA2_LABEL(unk52);
/* 0x54 */ u16 SA2_LABEL(unk54);
/* 0x56 */ s16 SA2_LABEL(unk56);
/* 0x58 */ BgUpdate fnBgUpdate;
/* 0x5C */ struct Task *movementTask;
/* 0x60 */ s16 shakeOffsetX;
/* 0x62 */ s16 shakeOffsetY;
/* 0x64 */ s16 unk64;
/* 0x66 */ u8 spectatorTarget;
#endif
} Camera; /* size 0x80(in SA2) */

extern struct Camera gCamera;
extern Camera gCamera;

// TODO: Merge all these into one!
#define IS_OUT_OF_RANGE_2(x, y, radiusX, radiusY) \
Expand Down Expand Up @@ -157,12 +126,12 @@ extern struct Camera gCamera;
#define CAM_SCREENBASE_MAP_BACK 56
#endif

struct Backgrounds {
typedef struct {
Background unk0;
Background unk40;
Background unk80;
Background unkC0;
};
} StageBackgrounds;

extern const Background gStageCameraBgTemplates[4];

Expand All @@ -180,12 +149,7 @@ void HBlankCB_BgUpdateZone5ActBoss(int_vcount vcount);
void HBlankCB_BgUpdateZoneFinalActXX(int_vcount vcount);
#endif

#if (GAME == GAME_SA1)
// TODO: should be included from terrain_collision.h
extern const Collision *gRefCollision;
#endif

extern const u16 gBossCameraYClamps[][2];
extern struct Backgrounds gStageBackgroundsRam;
extern StageBackgrounds gStageBackgroundsRam;

#endif // GUARD_GAME_STAGE_CAMERA_H
2 changes: 1 addition & 1 deletion src/game/sa1/menus/mp_mode_select.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ typedef enum PakModes {
PM_COUNT
} PakModes;

typedef struct ModeSelect {
typedef struct {
/* 0x00 */ Background bg;
/* 0x40 */ Sprite s[3];
/* 0xD0 */ Sprite s4;
Expand Down
6 changes: 3 additions & 3 deletions src/game/sa1/menus/mp_mode_select_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ typedef enum PakModes {
PM_COUNT
} PakModes;

typedef struct ModeSelect {
typedef struct {
/* 0x00 */ Background bg;
/* 0x40 */ Sprite s[3];
/* 0xD0 */ Sprite s4;
Expand All @@ -60,7 +60,7 @@ typedef struct ModeSelect {
/* 0x219 */ u8 unk219;
} ModeSelect; /* 0x21C */

typedef struct SioMultiplayerScore {
typedef struct {
u16 unk0;
u8 unk2;
u8 unk3;
Expand All @@ -81,7 +81,7 @@ void Task_800F058(void);

extern const VoidFn gUnknown_080BB3F8[9];

void sa2__sub_80818B8(void)
void SA2_LABEL(sub_80818B8)(void)
{
u32 var_r1;
u8 temp_r4_3;
Expand Down
2 changes: 1 addition & 1 deletion src/game/sa1/menus/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "constants/sa1/songs.h"
#include "constants/sa1/text.h" // for UILANG_COUNT

typedef struct OptionsMenu {
typedef struct {
/* 0x000 */ Sprite s0;
/* 0x030 */ Sprite sprites30[8];
/* 0x1B0 */ Sprite s1B0;
Expand Down
2 changes: 1 addition & 1 deletion src/game/sa1/menus/player_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ typedef enum EPDM_Options {
PDM_OPTION_COUNT
} EPDM_Options;

typedef struct PlayerDataMenu {
typedef struct {
/* 0x00 */ Sprite s;
/* 0x30 */ Sprite s2[PDM_OPTION_COUNT + 1];
/* 0xF0 */ StrcUi_805423C strcF0;
Expand Down
2 changes: 1 addition & 1 deletion src/game/sa1/menus/time_attack.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "constants/sa1/songs.h"
#include "constants/sa1/text.h"

typedef struct TimeAttackMenu {
typedef struct {
StrcUi_805423C unk0;
Sprite s;
Sprite s2;
Expand Down
10 changes: 5 additions & 5 deletions src/game/sa1/menus/title_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,18 @@ const u8 gUnknown_080BB327[] = { 0, 1, 3, 2, 0 };
const VoidFn sMainMenuSecondaryItems[NUM_MAIN_MENU_ITEMS - 1]
= { CreateMultiplayerModeSelectScreen, CreateTimeAttackMenu, CreateOptionsMenu, LoadTinyChaoGarden };

typedef struct SegaLogo {
typedef struct {
u16 unk0;
Background bg;
} SegaLogo; /* 0x44 */

typedef struct SonicTeamLogo {
typedef struct {
u16 unk0;
Background bg;
s16 qFade;
} SonicTeamLogo; /* 0x48 */

typedef struct MainMenu {
typedef struct {
/* 0x000 */ Sprite s;
/* 0x030 */ Sprite items[NUM_MAIN_MENU_ITEMS];
/* 0x120 */ Background bg120;
Expand Down Expand Up @@ -324,7 +324,7 @@ void Task_800D4B0(void)
CreateTitleScreen(1);
}

typedef struct TitleScreen {
typedef struct {
/* 0x00 */ Sprite s;
/* 0x30 */ Sprite s2;
/* 0x60 */ Background bg;
Expand Down Expand Up @@ -514,7 +514,7 @@ void CreateMainMenu(u32 param0)
s8 *temp_r0;

struct Task *t;
struct MainMenu *menu;
MainMenu *menu;
Sprite *s;
Background *bg;

Expand Down
6 changes: 3 additions & 3 deletions src/game/sa1/multiplayer/chao_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#define CM_BACKGROUND_COLOR RGB16_REV(0, 27, 30)

typedef struct ChaoMessage {
typedef struct {
/* 0x00 */ Background bg;
/* 0x40 */ u8 unk40[2][4];
/* 0x48 */ s16 unk48[4];
Expand All @@ -29,14 +29,14 @@ typedef struct ChaoMessage {
/* 0x56 */ u8 unk56;
} ChaoMessage; /* 0x58 */

typedef struct ChaoMsgSprite {
typedef struct {
/* 0x00 */ Sprite s;
/* 0x30 */ s16 unk30;
/* 0x32 */ s16 unk32;
/* 0x34 */ u8 unk34;
} ChaoMsgSprite; /* 0x38 */

typedef struct ChaoMsg68 {
typedef struct {
GameOverB overBs[4];
s16 unk60;
s16 unk62;
Expand Down
20 changes: 10 additions & 10 deletions src/game/sa1/special_stage/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ extern struct MP2KSongHeader se_ring_copy;
#include "constants/sa1/songs.h"
#include "constants/sa1/zones.h"

typedef struct Strc_30055E0 {
typedef struct {
u8 unk0;
s16 unk2;
u16 qBlend;
s32 qUnk8;
u8 fillerC[0x4];
} Strc_30055E0; /* 0x10 */

typedef struct Strc_3005690 {
typedef struct {
s32 unk0;
s32 unk4;
s32 unk8;
Expand Down Expand Up @@ -76,7 +76,7 @@ typedef struct Strc_3005690 {
u8 filler56[0xA];
} Strc_3005690; /* 0x60 */

typedef struct Strc_3005780 {
typedef struct {
s16 unk0;
s16 unk2;
s16 unk4;
Expand All @@ -90,7 +90,7 @@ typedef struct Strc_3005780 {
s8 unk13;
} Strc_3005780;

typedef struct SpStage74 {
typedef struct {
SpriteTransform tf;
Sprite s;
s32 unk3C;
Expand Down Expand Up @@ -123,22 +123,22 @@ typedef struct SpStage74 {
u8 filler72[2];
} SpStage74;

typedef struct SpStage8 {
typedef struct {
u8 filler0[2];
u16 unk2;
u16 unk4;
u8 unk6;
} SpStage8;

// Stage layouts?
typedef struct SpStageC {
typedef struct {
s16 unk0;
s16 unk2;
s32 unk4;
u16 unk8;
} SpStageC; /* 0x0C */

typedef struct SpStage40 {
typedef struct {
SpriteTransform tf;
Sprite s;
void *mem;
Expand Down Expand Up @@ -225,7 +225,7 @@ extern void sub_8068D0C();

extern void SetPlayerControls(bool32 flipFaceButtons);

typedef struct TfSprite {
typedef struct {
SpriteTransform tf;
Sprite s;
} TfSprite;
Expand Down Expand Up @@ -343,7 +343,7 @@ const Background gUnknown_084870F4 = {
.prevScrollY = 0x7FFF,
};

typedef struct HitboxS16 {
typedef struct {
s16 left;
s16 top;
s16 right;
Expand Down Expand Up @@ -2014,7 +2014,7 @@ void sub_802C0CC(void)
x = (strc5690->unkC - strc74->unk4C);
y = (strc5690->unkE - strc74->unk4E);

theta = sa2__sub_8004418(y, x);
theta = SA2_LABEL(sub_8004418)(y, x);
strc74->unk52 += 0x15;
v0 = (strc74->unk52 * COS(theta));
v1 = (SIN(theta));
Expand Down
2 changes: 1 addition & 1 deletion src/game/sa1/stage/backgrounds/zone_1.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

void StageBgUpdate_Zone1Acts12(s32 x, s32 UNUSED y)
{
struct Camera *cam = &gCamera;
Camera *cam = &gCamera;
Background *bg;
u16 *offsets;
s32 i;
Expand Down
4 changes: 2 additions & 2 deletions src/game/sa1/stage/backgrounds/zone_3.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void Task_UpdateFireworkAnimation(void)
{
CasinoParadiseFirework *firework = TASK_DATA(gCurTask);
Sprite *s = &firework->s;
struct Camera *cam = &gCamera;
Camera *cam = &gCamera;

if (s->frameFlags & SPRITE_FLAG_MASK_ANIM_OVER) {
TaskDestroy(gCurTask);
Expand Down Expand Up @@ -66,7 +66,7 @@ void Task_UpdateFireworkAnimation(void)

void StageBgUpdate_Zone3Acts12(s32 x, s32 y)
{
struct Camera *cam = &gCamera;
Camera *cam = &gCamera;
const Collision *collision;
s32 xSub, ySub;
s32 scanline;
Expand Down
Loading
Loading