Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some more documentation and cleanup #176

Merged
merged 16 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ tools/agbcc
reports
.vscode/*.log
.vs/
*.pdb
*.gbapal
*.lz
*.rl
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
.include "asm/macros.inc"
.include "constants/constants.inc"

.section .rodata

.text
.syntax unified
.arm

@ These are all multiplayer-only, but there is one procedure (sub_800DF38)
@ of collision code behind this that is not MP-exclusive.
@
@ Either everything gets merged into collision.c, which seems like the best approach,
@ or we have a main collision.c and a collision_mp.c, the latter of which contains SP-called code.

@ Called by: player_mp_actor.s
thumb_func_start sub_800D0A0
sub_800D0A0: @ 0x0800D0A0
.text
push {r4, r5, r6, r7, lr}
mov r7, sl
mov r6, sb
Expand Down Expand Up @@ -1283,3 +1269,5 @@ _0800DA38:
bx r1
.align 2, 0
_0800DA48: .4byte gPlayer

.syntax divided
10 changes: 10 additions & 0 deletions chao_garden/include/language.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef GUARD_TCG_LANGUAGE_H
#define GUARD_TCG_LANGUAGE_H

#define TCGLANG_JAPANESE 0
#define TCGLANG_ENGLISH 1 // Used for English and Italian in SA2
#define TCGLANG_FRENCH 2
#define TCGLANG_GERMAN 3
#define TCGLANG_SPANISH 4

#endif // GUARD_TCG_LANGUAGE_H
6 changes: 6 additions & 0 deletions chao_garden/include/program_params.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef GUARD_TCG_PROGRAM_PARAMS_H
#define GUARD_TCG_PROGRAM_PARAMS_H

#define TinyChaoGardenConfig ((u32 *)(EWRAM_START + 0x8))

#endif // GUARD_TCG_PROGRAM_PARAMS_H
16 changes: 10 additions & 6 deletions include/constants/characters.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#ifndef GUARD_CONSTANTS_CHARACTERS_H
#define GUARD_CONSTANTS_CHARACTERS_H

#define CHARACTER_SONIC 0
#define CHARACTER_CREAM 1
#define CHARACTER_TAILS 2
#define CHARACTER_KNUCKLES 3
#define CHARACTER_AMY 4
typedef enum {
CHARACTER_SONIC,
#if (GAME >= GAME_SA2)
CHARACTER_CREAM,
#endif
CHARACTER_TAILS,
CHARACTER_KNUCKLES,
CHARACTER_AMY,

#define NUM_CHARACTERS 5
NUM_CHARACTERS
} ECharacters;

// NOTE: Put this after NUM_CHARACTERS, to allow BriBaSA_ex to parse this file properly.
// Naming it CHARACTER_<something> before NUM_CHARACTERS confuses it.
Expand Down
2 changes: 1 addition & 1 deletion include/game/sa1_sa2_shared/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ extern u8 gUnknown_030053E0;
extern u8 gUnknown_0300543C;
extern struct Task *gEntitiesManagerTask;

extern u8 gUnknown_030054E4;
extern u8 gDestroySpotlights;

extern u8 gUnknown_03005420;

Expand Down
16 changes: 14 additions & 2 deletions include/game/save.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ struct TimeRecords {

#define NUM_TIME_RECORD_ROWS (NUM_COURSE_ZONES * ACTS_PER_ZONE * NUM_CHARACTERS * TIME_RECORDS_PER_COURSE)

#if (GAME == GAME_SA1)
struct SaveGame {
/* 0x10 */ u16 playerName[MAX_PLAYER_NAME_LENGTH];
/* 0x1A */ u8 language;

/* 0x428 */ u32 score;
}

// NOTE: Not a pointer in SA1!
extern struct SaveGame gLoadedSaveGame;
#elif (GAME == GAME_SA2)
struct SaveGame {
/* 0x000 */ u32 id;

Expand Down Expand Up @@ -67,12 +78,13 @@ struct SaveGame {
/* 0x374 */ u32 score;
};

extern struct SaveGame *gLoadedSaveGame;
#endif

#define MULTIPLAYER_RESULT_WIN 0
#define MULTIPLAYER_RESULT_LOSS 1
#define MULTIPLAYER_RESULT_DRAW 2

extern struct SaveGame *gLoadedSaveGame;

void InsertMultiplayerProfile(u32 playerId, u16 *name);
void RecordOwnMultiplayerResult(s16 result);
void RecordMultiplayerResult(u32 id, u16 *name, s16 result);
Expand Down
16 changes: 12 additions & 4 deletions include/game/stage/dust_effect_braking.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@ struct Task *CreateBrakingDustEffect(s32, s32);
void CreateBrakingDustEffectRelatedTask(void);
void DestroyBrakingDustEffectRelatedTask(void);

typedef struct {
/* 0x00 */ u16 x;
/* 0x02 */ u16 y;
/* 0x04 */ u16 unk4;
/* 0x06 */ u16 unk6;
/* 0x08 */ Sprite s;
} BrakeDustEffect;

typedef struct {
s8 unk0;
u8 filler1[3];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably remove this now :)

struct Task *t;
} UNK_30059D0;
struct Task *t; // -> BrakeDustEffect
} DustEffectBraking;

extern UNK_30059D0 gUnknown_030059D0;
extern DustEffectBraking gDustEffectBrakingTask;

#endif // GUARD_BRAKE_DUST_CLOUD_H
#endif // GUARD_BRAKE_DUST_CLOUD_H
4 changes: 0 additions & 4 deletions ldscript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,6 @@ SECTIONS
src/game/sa1_sa2_shared/ring.o(.text);
src/game/sa1_sa2_shared/music_manager.o(.text);
src/game/sa1_sa2_shared/collision.o(.text);
#if (CPU_ARCH_ARM == 1)
asm/collision_mp.o(.text);
#endif
src/game/sa1_sa2_shared/collision_1.o(.text);
src/game/sa1_sa2_shared/input_buffer.o(.text);
src/game/sa1_sa2_shared/interactables/spring.o(.text);
src/game/sa1_sa2_shared/interactables/platform.o(.text);
Expand Down
10 changes: 5 additions & 5 deletions src/game/amy_attack_heart_effect.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ typedef struct {
/* 0x10A */ u16 unk10A;
} AmyAtkHearts; /* size: 0x10C */

void Task_8015CE4(void);
void Task_AmyAttackHeartEffect(void);
void sub_8015E28(u16);
void TaskDestructor_8015FF0(struct Task *);
void TaskDestructor_AmyAttackHeartEffect(struct Task *);

ALIGNED(4)
const s16 sHeartOffsets[AMY_HEART_PATTERN_COUNT][8][3] = {
Expand Down Expand Up @@ -93,7 +93,7 @@ void CreateAmyAttackHeartEffect(u16 kind)

if ((gPlayer.charState == CHARSTATE_BOOSTLESS_ATTACK) || (gPlayer.charState == CHARSTATE_SOME_ATTACK)
|| (gPlayer.charState == CHARSTATE_TRICK_DOWN)) {
struct Task *t = TaskCreate(Task_8015CE4, sizeof(AmyAtkHearts), 0x3001, 0, TaskDestructor_8015FF0);
struct Task *t = TaskCreate(Task_AmyAttackHeartEffect, sizeof(AmyAtkHearts), 0x3001, 0, TaskDestructor_AmyAttackHeartEffect);
AmyAtkHearts *hearts = TASK_DATA(t);

hearts->unk100 = sCharStateAnimInfo[gPlayer.charState][0];
Expand All @@ -116,7 +116,7 @@ void CreateAmyAttackHeartEffect(u16 kind)

// NOTE: Fakematch
// (99.97%) https://decomp.me/scratch/Z3oDP
void Task_8015CE4(void)
void Task_AmyAttackHeartEffect(void)
{
#ifndef NON_MATCHING
register struct Task *t asm("r2") = gCurTask;
Expand Down Expand Up @@ -249,7 +249,7 @@ void sub_8015E28(u16 p0)
}
}

void TaskDestructor_8015FF0(struct Task *t)
void TaskDestructor_AmyAttackHeartEffect(struct Task *t)
{
AmyAtkHearts *hearts = TASK_DATA(t);

Expand Down
8 changes: 6 additions & 2 deletions src/game/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void GameInit(void)
gPlayer.spriteTask = NULL;
gCamera.movementTask = NULL;

gUnknown_030059D0.t = NULL;
gDustEffectBrakingTask.t = NULL;
gWater.t = NULL;

gUnknown_0300543C = 0;
Expand All @@ -58,12 +58,16 @@ void GameInit(void)
gSmallAirBubbleCount = 0;
gDemoPlayCounter = 0;
// TODO: resolve this
gUnknown_030054E4 = 0;
gDestroySpotlights = 0;

for (i = 0; i < 4; i++) {
gMultiplayerPlayerTasks[i] = NULL;
}

#if (GAME == GAME_SA1)
gTask_03006240 = 0;
#endif

for (i = 0; i < 4; i++) {
gMultiplayerCharacters[i] = 0;
gUnknown_030054B4[i] = 0;
Expand Down
Loading