clean up input buffer, move input buffer to game/sa2

This commit is contained in:
Oliver Bell committed 2026-03-31 12:35:07 +01:00
1 parent 0111c71960
commit dc4ec6f8f9
13 files changed
+74 -96

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
#ifndef GUARD_SA2_DATA_INPUT_COMBOS
#define GUARD_SA2_DATA_INPUT_COMBOS
#include "types.h"
#include "constants/characters.h"
extern const u8 **gUnknown_08C871D4[NUM_CHARACTERS];
#endif // GUARD_SA2_DATA_INPUT_COMBOS
@@ -1,18 +0,0 @@
#ifndef GUARD_SA2_INPUT_BUFFER
#define GUARD_SA2_INPUT_BUFFER
#include "game/sa1_sa2_shared/player.h"
void InputBuffer_NewFrameInput(u16 param0, u16 param1);
void InputBuffer_HandleFrameInput(Player *p);
void InitNewInputCounters(void);
extern const u8 *unk_8C87198[3];
extern const u8 *unk_8C871A4[3];
extern const u8 *unk_8C871B0[3];
extern const u8 *unk_8C871BC[3];
extern const u8 *unk_8C871C8[3];
#define INPUTBUF_NULL_PTR ((void *)((intptr_t)-1))
#endif // GUARD_SA2_INPUT_BUFFER
+23
View File
@@ -0,0 +1,23 @@
#ifndef GUARD_SA2_INPUT_BUFFER
#define GUARD_SA2_INPUT_BUFFER
#include "game/sa1_sa2_shared/player.h"
void InputBuffer_NewFrameInput(u16 param0, u16 param1);
void InputBuffer_HandleFrameInput(Player *p);
void InitNewInputCounters(void);
extern const u8 gUnknown_080D5254[];
extern const u8 gUnknown_080D5262[];
extern const u8 gUnknown_080D5270[];
extern const u8 gUnknown_080D527E[];
extern const u8 gUnknown_080D528C[];
extern const u8 gUnknown_080D529A[];
extern const u8 gUnknown_080D52A8[];
extern const u8 gUnknown_080D52B6[];
extern const u8 gUnknown_080D52C4[];
extern const u8 gUnknown_080D52D2[];
#define INPUTBUF_NULL_PTR ((void *)((intptr_t)-1))
#endif // GUARD_SA2_INPUT_BUFFER
+1 -1
View File
@@ -4,4 +4,4 @@
// TODO: Replace with platform-specific types.h files!
#include "gba/types.h"
#endif // GUARD_TYPES_H
#endif // GUARD_TYPES_H
+5 -4
View File
@@ -42,6 +42,7 @@ SECTIONS
src/game/globals.o(.data);
/* game */
src/game/sa2/input_buffer.o(.data);
src/game/water_effects.o(.data);
src/game/cheese.o(.data);
src/game/boost_effect.o(.data);
@@ -116,7 +117,7 @@ SECTIONS
src/game/sa1_sa2_shared/magnetic_ring.o(.text);
src/game/sa1_sa2_shared/music_manager.o(.text);
src/game/sa1_sa2_shared/collision.o(.text);
src/game/sa1_sa2_shared/input_buffer.o(.text);
src/game/sa2/input_buffer.o(.text);
src/game/sa1_sa2_shared/interactables/spring.o(.text);
src/game/sa1_sa2_shared/interactables/platform.o(.text);
src/game/sa1_sa2_shared/interactables/platform_square.o(.text);
@@ -384,7 +385,7 @@ SECTIONS
src/game/sa1_sa2_shared/pause_menu.o(.rodata);
src/game/sa1_sa2_shared/itembox.o(.rodata);
src/game/sa1_sa2_shared/music_manager.o(.rodata);
src/game/sa1_sa2_shared/input_buffer.o(.rodata);
src/game/sa2/input_buffer.o(.rodata);
src/game/sa1_sa2_shared/interactables/spring.o(.rodata);
src/game/sa1_sa2_shared/interactables/platform.o(.rodata);
src/game/sa1_sa2_shared/interactables/platform_square.o(.rodata);
@@ -778,10 +779,10 @@ SECTIONS
/* It's possible that all of these were actually
set in a single asm file, since the order doesnt
make any logical sense */
src/game/sa1_sa2_shared/input_buffer.o(.data);
src/data/input_combos.o(.rodata);
data/special_stage_levels.o(.rodata);
src/data/handlers_ia_pipe_horn_sequences.o(.rodata);
src/game/sound_test.o(.data);
src/data/palettes.o(.rodata);
src/data/recordings.o(.rodata);
data/multiboot_collect_rings.o(.rodata);
data/multiboot_subgame_loader.o(.rodata);
@@ -1,17 +0,0 @@
#ifndef GUARD_SA2_INPUT_BUFFER
#define GUARD_SA2_INPUT_BUFFER
#include "game/sa1_sa2_shared/player.h"
void SA2_LABEL(sub_800E0C0)(u16 param0, u16 param1);
void SA2_LABEL(sub_800DF8C)(Player *p);
extern const u8 *SA2_LABEL(unk_8C87198)[3];
extern const u8 *SA2_LABEL(unk_8C871A4)[3];
extern const u8 *SA2_LABEL(unk_8C871B0)[3];
extern const u8 *SA2_LABEL(unk_8C871BC)[3];
extern const u8 *SA2_LABEL(unk_8C871C8)[3];
#define INPUTBUF_NULL_PTR ((void *)((intptr_t)-1))
#endif // GUARD_SA2_INPUT_BUFFER
+19
View File
@@ -0,0 +1,19 @@
#include "constants/characters.h"
#include "game/sa2/input_buffer.h"
// Unsure if this spacing is applied here
const u8 *const gUnknown_08c87098_unused[64] = { 0 };
const u8 *const unk_8C87198[] = { gUnknown_080D5254, gUnknown_080D5262, INPUTBUF_NULL_PTR };
const u8 *const unk_8C871A4[] = { gUnknown_080D5270, gUnknown_080D527E, INPUTBUF_NULL_PTR };
const u8 *const unk_8C871B0[] = { gUnknown_080D528C, gUnknown_080D529A, INPUTBUF_NULL_PTR };
const u8 *const unk_8C871BC[] = { gUnknown_080D52A8, gUnknown_080D52B6, INPUTBUF_NULL_PTR };
const u8 *const unk_8C871C8[] = { gUnknown_080D52C4, gUnknown_080D52D2, INPUTBUF_NULL_PTR };
const u8 *const *const gUnknown_08C871D4[NUM_CHARACTERS] = {
unk_8C87198, unk_8C871A4, unk_8C871B0, unk_8C871BC, unk_8C871C8,
};
+3
View File
@@ -0,0 +1,3 @@
#include "data/palettes.h"
const ColorRaw gBgGradientPalette[] = INCPAL("graphics/sound_test_bg.pal");
-14
View File
@@ -176,18 +176,4 @@ bool8 ALIGNED(4) gBoostEffectTasksCreated = 0;
#if COLLECT_RINGS_ROM
u8 unused2[8] = {};
#endif
#ifndef COLLECT_RINGS_ROM
#ifndef NON_MATCHING
u32 unused_030055C0[4] = {};
#endif
// TODO: move into input buffer
u8 gFrameInputsBuf[4] = {};
u8 gNewInputCountersIndex = 0;
u8 ALIGNED(4) gFrameInputsBufIndex = 0;
// Fills available space, but size not yet confirmed
struct InputCounters ALIGNED(8) gNewInputCounters[32] = {};
#endif
#endif
-6
View File
@@ -85,14 +85,8 @@ const u16 gLevelSongs[] = {
#if (GAME == GAME_SA1)
const u16 gUnkMusicMgrData[7] = { 0x001D, 0x001E, 0x001F, 0x0020, 0x0031, 0x0032, 0x0019 };
#elif (GAME == GAME_SA2)
// This data is unrelated to this module in SA2 but has been linked in here by some
// compilation quirk, see it's actual usage in input_buffer.c
#ifndef NON_MATCHING
const u16 gUnkMusicMgrData[7] = { 0x0104, 0xF000, 0x1008, 0x08F0, 0xF000, 0x1008, 0x01F0 };
#else
const u16 gUnkMusicMgrData[0] = {};
#endif
#endif
#if (GAME == GAME_SA1)
#define SET_UNK5(v)
@@ -1,20 +1,21 @@
#include "global.h"
#include "game/globals.h"
#include "game/sa1_sa2_shared/input_buffer.h"
#include "game/sa2/input_buffer.h"
#include "game/sa1_sa2_shared/player.h"
#include "constants/characters.h"
#include "data/input_combos.h"
UNUSED u32 unused_030055C0[4] = {};
u8 gFrameInputsBuf[4] = {};
u8 gNewInputCountersIndex = 0;
u8 ALIGNED(4) gFrameInputsBufIndex = 0;
// Fills available space, but size not yet confirmed
struct InputCounters ALIGNED(8) gNewInputCounters[32] = {};
// Trick input patterns
// In the original rom this data was somehow transferred to `music_manager.c` and the pointer
// referenced from there. However, this data definitely relates to this file and in advance 2
// the `gUnkMusicMgrData` is never used
#ifndef NON_MATCHING
extern const u8 gUnkMusicMgrData[];
#else
static const u8 pat1[] = { 0x04, 0x01, 0x00, 0xF0, 0x08, 0x10, 0xF0, 0x08, 0x00, 0xF0, 0x08, 0x10, 0xF0, 0x01 };
#endif
const u8 gUnknown_080D5254[] = { 0x04, 0x01, 0x00, 0xF0, 0x08, 0x10, 0xF0, 0x08, 0x00, 0xF0, 0x08, 0x10, 0xF0, 0x01 };
const u8 gUnknown_080D5262[] = {
0x04, // r6
0x01, // r8
@@ -34,26 +35,6 @@ const u8 gUnknown_080D52B6[] = { 0x04, 0x02, 0x10, 0xF0, 0x0F, 0x00, 0xF0, 0x0F,
const u8 gUnknown_080D52C4[] = { 0x04, 0x01, 0x10, 0xF0, 0x0F, 0x00, 0xF0, 0x0F, 0x10, 0xF0, 0x0F, 0x03, 0x07, 0x0F };
const u8 gUnknown_080D52D2[] = { 0x04, 0x02, 0x10, 0xF0, 0x0F, 0x00, 0xF0, 0x0F, 0x10, 0xF0, 0x0F, 0x03, 0x07, 0x0F };
const u8 *gUnknown_08c87098_unused[64] = { 0 };
#ifndef NON_MATCHING
const u8 *unk_8C87198[3] = { gUnkMusicMgrData, gUnknown_080D5262, INPUTBUF_NULL_PTR };
#else
const u8 *unk_8C87198[3] = { pat1, gUnknown_080D5262, INPUTBUF_NULL_PTR };
#endif
const u8 *unk_8C871A4[3] = { gUnknown_080D5270, gUnknown_080D527E, INPUTBUF_NULL_PTR };
const u8 *unk_8C871B0[3] = { gUnknown_080D528C, gUnknown_080D529A, INPUTBUF_NULL_PTR };
const u8 *unk_8C871BC[3] = { gUnknown_080D52A8, gUnknown_080D52B6, INPUTBUF_NULL_PTR };
const u8 *unk_8C871C8[3] = { gUnknown_080D52C4, gUnknown_080D52D2, INPUTBUF_NULL_PTR };
const u8 **gUnknown_08C871D4[NUM_CHARACTERS] = {
unk_8C87198, unk_8C871A4, unk_8C871B0, unk_8C871BC, unk_8C871C8,
};
// The current value in gNewInputCounters[gNewInputCountersIndex]
// gets increased until either it reaches 0xFF or a new button was pressed.
// Letting go of a button does not trigger the index increase.
+1 -4
View File
@@ -253,9 +253,6 @@ static const u32 sBackButtonText[NUM_LANGUAGES * 3 * 2] = {
Text(LANG_SPANISH, 10, 1037, 1, 2), Text(LANG_ITALIAN, 8, 1038, 0, 2), Text(LANG_ITALIAN, 12, 1038, 1, 2),
};
// NOTE: Not const, so it gets put into .data, not .rodata
static ColorRaw sSoundTestBGPalette[] = INCPAL("graphics/sound_test_bg.pal");
void CreateSoundTestScreen(struct OptionsScreen *optionsScreen)
{
struct Task *t
@@ -308,7 +305,7 @@ void CreateSoundTestScreen(struct OptionsScreen *optionsScreen)
bgPaletteEffect->bgPalId = 0;
bgPaletteEffect->pattern = sBgGradient;
bgPaletteEffect->palette = sSoundTestBGPalette;
bgPaletteEffect->palette = gBgGradientPalette;
bgPaletteEffect->offset = 0;
+1 -1
View File
@@ -14,7 +14,7 @@
#include "game/multiplayer/mp_player.h"
#include "game/parameters/bosses.h"
#include "game/player_callbacks.h"
#include "game/sa1_sa2_shared/input_buffer.h"
#include "game/sa2/input_buffer.h"
#include "game/sa1_sa2_shared/music_manager.h"
#include "game/sa2/save.h"
#include "game/stage/camera.h"