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

Various RAM map documentation and alignment with SA3 #175

Merged
merged 31 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e89c35c
Various documentation and alignment with SA3
JaceCear Dec 9, 2024
71ecccb
Format
JaceCear Dec 9, 2024
c250823
Extract input_recorder.c .data section from core.c, as in SA3
JaceCear Dec 9, 2024
8a947c6
Align multi_sio.c with SA3
JaceCear Dec 9, 2024
7fdb4af
Format
JaceCear Dec 9, 2024
6cda527
Document parameters of DisplaySprites
JaceCear Dec 9, 2024
bcf1acc
Document centerOffsetX/Y in DisplaySprites
JaceCear Dec 9, 2024
04a48f0
Only display copyright note
JaceCear Dec 9, 2024
eddb0ba
Split GAME_ and ENGINE_ macros
JaceCear Dec 10, 2024
1a49900
Use ENGINE macros in core.c
JaceCear Dec 10, 2024
d4fd416
Rename game<->engine interface procedures
JaceCear Dec 10, 2024
cf83fc3
Remove searching in /src for header files in genctx.py
JaceCear Dec 12, 2024
77b1713
Fix global.h<->config.h dependency in genctx.py
JaceCear Dec 12, 2024
db26dbc
Address review comments
JaceCear Dec 19, 2024
cdb71c9
Only enable Task logging in debug versions
JaceCear Dec 19, 2024
4df35ab
Fix build
JaceCear Dec 19, 2024
c16600c
Fix uses of DEBUG, remove TEST_GFX_POINTERS because current gfx copy …
JaceCear Dec 19, 2024
6f5691e
Use 64bit as default target in Win SDL
JaceCear Dec 21, 2024
df12bd3
Align some files with sa1 and sa3
JaceCear Dec 24, 2024
e75b4f0
Align sprite.c and other files closer with sa1 and sa3
JaceCear Dec 24, 2024
e511be4
Fix build
JaceCear Dec 24, 2024
8a2e826
Various documentation
JaceCear Dec 26, 2024
fd791ff
Formatter
JaceCear Dec 26, 2024
3a2b369
Add small player note
JaceCear Dec 27, 2024
c613909
Some dodumentation and cleanup from SA1 core.c integration
JaceCear Dec 27, 2024
71951d7
Fix build
JaceCear Dec 27, 2024
57cd202
Rename sa1_leftovers/ -> sa1_sa2_shared/
JaceCear Dec 27, 2024
e760e92
Maybe fix build
JaceCear Dec 27, 2024
6db20a7
Formatter...
JaceCear Dec 27, 2024
c9f34ca
Three time's the charm?
JaceCear Dec 27, 2024
68ebace
Put gEwramHeap into ewram_data section
JaceCear Dec 28, 2024
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
6 changes: 6 additions & 0 deletions include/game/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@

void GameStart(void);

#define GAME_SA1 1
#define GAME_SA2 2
#define GAME_SA3 3
#define GAME_KATAM 4
freshollie marked this conversation as resolved.
Show resolved Hide resolved
#define CURRENT_GAME GAME_SA2

#endif // GUARD_GAME_H
2 changes: 2 additions & 0 deletions include/game/parameters/characters.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "constants/zones.h"

// TODO: Be consistent about whether these are Q() or I() values!

/*** Common ***/
#define PLAYER_FLYING_END_GRAVITY (0.033) // = (8. / 256.)
#define PLAYER_GRAVITY 42.0 / 256.0
Expand Down
7 changes: 7 additions & 0 deletions include/sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,18 @@ typedef struct {
} Background; /* size = 0x40 */

typedef struct {
#if (CURRENT_GAME >= GAME_SA3)
// In SA3 flip-bits are integrated into the oamIndex.
// X-Flip: Bit 14
// Y-Flip: Bit 15
/* 0x00 */ u16 oamIndex;
#else
/* 0x00 */ u8 flip;

// every animation has an associated oamData pointer, oamIndex starts at
// 0 for every new animation and ends at variantCount-1
/* 0x01 */ u8 oamIndex;
#endif

// some sprite frames consist of multiple images (of the same size
// as GBA's Object Attribute Memory, e.g. 8x8, 8x32, 32x64, ...)
Expand Down
1 change: 1 addition & 0 deletions ldscript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ SECTIONS

/* engine */
src/core.o(.data);
src/input_recorder.o(.data);

/* "SA1 Leftovers" */
. = ALIGN(32);
Expand Down
12 changes: 9 additions & 3 deletions src/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ u8 gNumHBlankIntrs = 0;
struct BlendRegs gBldRegs ALIGNED(8) = {};
u8 gOamFreeIndex = 0;
struct Task gEmptyTask ALIGNED(16) = {};
BgAffineReg gBgAffineRegs[NUM_AFFINE_BACKGROUNDS] ALIGNED(8) = {};
u8 gNextFreeAffineIndex = 0;
freshollie marked this conversation as resolved.
Show resolved Hide resolved
BgAffineReg gBgAffineRegs[NUM_AFFINE_BACKGROUNDS] = {};
void *gVramHeapStartAddr = NULL;
u16 gUnknown_03001944 ALIGNED(4) = 0;
u8 gUnknown_03001948 ALIGNED(4) = 0;
Expand Down Expand Up @@ -124,8 +125,6 @@ FuncType_030053A0 gUnknown_030053A0[] ALIGNED(16) = {};
const u8 *gInputPlaybackData = NULL;
bool8 gExecSoundMain ALIGNED(4) = FALSE;
s32 gPseudoRandom = 0;
struct InputRecorder gInputRecorder ALIGNED(8) = {};
u16 *gInputRecorderTapeBuffer = NULL;

static void UpdateScreenDma(void);
static void UpdateScreenCpuSet(void);
Expand Down Expand Up @@ -252,6 +251,9 @@ void GameInit(void)
gBgAffineRegs[1].x = 0;
gBgAffineRegs[1].y = 0;

#if (CURRENT_GAME >= GAME_SA3)
gNextFreeAffineIndex = 0;
#endif
gUnknown_03001944 = 0;
gUnknown_030017F0 = 0x100;
gUnknown_03005394 = 0x100;
Expand Down Expand Up @@ -379,6 +381,10 @@ void GameLoop(void)
gFlagsPreVBlank = gFlags;
VBlankIntrWait();

#if (CURRENT_GAME >= GAME_SA3)
gNextFreeAffineIndex = 0;
#endif

if (gFlags & FLAGS_4000) {
UpdateScreenCpuSet();

Expand Down
18 changes: 9 additions & 9 deletions src/game/math.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ u32 gRngValue = 0;

const u16 gUnknown_080E0290[] = { 0x0AAA, 0x02AA };

typedef struct {
void *unk0;
void *start;
void *next;
void *unkC;
} UNK_8085DEC;

bool8 sub_8085D98(UNK_8085DEC *thing, UNK_8085DEC *target);

#define RAND_CONST 0x37119371;

NONMATCH("asm/non_matching/game/math/unused_sub_80832FC.inc", void sub_80832FC()) { }
Expand Down Expand Up @@ -609,15 +618,6 @@ void sub_8085D14(UNK_8085D14 *p1, u32 p2, u32 p3, u32 p4)
p1->unk12 = p4;
}

typedef struct {
void *unk0;
void *start;
void *next;
void *unkC;
} UNK_8085DEC;

bool8 sub_8085D98(UNK_8085DEC *thing, UNK_8085DEC *target);

void sub_8085D44(UNK_8085DEC *thing)
{
thing->unk0 = NULL;
Expand Down
4 changes: 1 addition & 3 deletions src/game/title_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1892,9 +1892,7 @@ static void Task_StartTitleScreenDemo(void)
gSelectedCharacter = CHARACTER_SONIC;
gCurrentLevel = sDemoLevels[0];

gDemoPlayCounter++;
// Don't count higher than 3
gDemoPlayCounter &= 3;
gDemoPlayCounter = (gDemoPlayCounter + 1) % 4u;

gGameMode = GAME_MODE_SINGLE_PLAYER;

Expand Down
3 changes: 3 additions & 0 deletions src/input_recorder.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#define TAPE_LENGTH 0x800
#endif

struct InputRecorder gInputRecorder ALIGNED(8) = { 0 };
u16 *gInputRecorderTapeBuffer = NULL;

static void Task_InputRecorder(void);
static void InputRecorderEject(struct Task *);

Expand Down
3 changes: 3 additions & 0 deletions src/multi_sio.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "global.h"
#include "game/game.h"
freshollie marked this conversation as resolved.
Show resolved Hide resolved
#include "multi_sio.h"
#include "sio32_multi_load.h"

Expand All @@ -10,7 +11,9 @@ u32 gMultiSioIntrFuncBuf[0x120 / 4] = {}; // Interrupt Routine RAM Execution Buf

struct MultiSioArea gMultiSioArea = {};

#if (CURRENT_GAME <= GAME_SA2)
UNUSED u32 gUnusedMultiSioSpace[2] = {};
#endif

#ifdef MULTI_SIO_DI_FUNC_FAST
u32 gMultiSioRecvFuncBuf[0x40 / 4] = {}; // Receive Data/Check Buffer Change Routine RAM Execution Buffer
Expand Down
2 changes: 1 addition & 1 deletion src/sprite.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ void DisplaySprite(Sprite *sprite)
}
}

void sub_081569A0(Sprite *sprite, u16 *sp08, u8 sp0C)
void DisplaySprites(Sprite *sprite, u16 *sp08, u8 sp0C)
freshollie marked this conversation as resolved.
Show resolved Hide resolved
{
vs32 x, y;
s32 sprWidth, sprHeight;
Expand Down