Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit d4a3a09

Browse files
committed
Align speedup code with SA2
1 parent 8e73a86 commit d4a3a09

2 files changed

Lines changed: 40 additions & 28 deletions

File tree

src/game/intro_animation.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#include "constants/songs.h"
1616

1717
#define INTRO_SPOTLIGHT_COUNT 2
18+
19+
#define EMERALD_START_X (DISPLAY_WIDTH / 2)
20+
#define EMERALD_START_Y -36
1821
typedef struct IntroSprite {
1922
Sprite s;
2023
u16 unk30;
@@ -229,6 +232,7 @@ void CreateIntroAnimation(void)
229232
SA2_LABEL(gUnknown_03005390) = 0;
230233
PAUSE_GRAPHICS_QUEUE();
231234
sub_80535FC();
235+
232236
UiGfxStackInit();
233237
gDispCnt = (DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
234238
gBgCntRegs[0] = 0x9D86;
@@ -252,14 +256,14 @@ void CreateIntroAnimation(void)
252256
s->graphics.dest = OBJ_VRAM0 + 0x20;
253257
s->graphics.anim = SA1_ANIM_INTRO_EMERALD;
254258
s->variant = 0;
255-
s->x = 0x78;
256-
s->y = 0xFFDC;
257-
s->oamFlags = 0xC0;
259+
s->x = EMERALD_START_X;
260+
s->y = EMERALD_START_Y;
261+
s->oamFlags = SPRITE_OAM_ORDER(3);
258262
s->graphics.size = 0;
259263
s->animCursor = 0;
260264
s->qAnimDelay = 0;
261265
s->prevVariant = -1;
262-
s->animSpeed = 0x10;
266+
s->animSpeed = SPRITE_ANIM_SPEED(1.0);
263267
s->palId = 0;
264268
s->hitboxes[0].index = -1;
265269
s->frameFlags = 0x1000;
@@ -278,10 +282,10 @@ void CreateIntroAnimation(void)
278282
introSpr->qUnk40 = Q(2.25);
279283
chunkOffset = (i * (4 * TILE_SIZE_4BPP));
280284
s->graphics.dest = (chunkOffset + OBJ_VRAM0 + (31 * TILE_SIZE_4BPP));
281-
s->graphics.anim = 0x307;
285+
s->graphics.anim = SA1_ANIM_SUPER_SONIC_SPARKLE;
282286
s->variant = 0;
283-
s->x = (Div(SIN(i << 6), 650) + 120);
284-
s->y = -36;
287+
s->x = EMERALD_START_X + Div(SIN(i << 6), 650);
288+
s->y = EMERALD_START_Y;
285289
s->oamFlags = 0;
286290
s->graphics.size = 0;
287291
s->animCursor = 0;
@@ -1655,7 +1659,7 @@ void sub_80656A4(void)
16551659
Sprite *s = &introSpr->s;
16561660
s16 temp_r0 = ++introSpr->unk30;
16571661

1658-
if ((introSpr->unk30) == 0x161) {
1662+
if ((introSpr->unk30) == 353) {
16591663
s->frameFlags = 0;
16601664
}
16611665

@@ -1681,7 +1685,7 @@ void sub_806571C(void)
16811685
Sprite *s = &introSpr->s;
16821686
s16 temp_r0 = ++introSpr->unk30;
16831687

1684-
if ((introSpr->unk30) == 0x161) {
1688+
if ((introSpr->unk30) == 353) {
16851689
s->frameFlags = 0;
16861690
}
16871691

@@ -1738,17 +1742,18 @@ void Task_IntroChaosEmeraldUpdate()
17381742
Sprite *s = &introSpr->s;
17391743
s16 unk30 = introSpr->unk30;
17401744

1741-
if ((u16)(unk30 - 90) > 0x8f) {
1745+
if ((unk30 < 90) || (unk30 > 233)) {
17421746
introSpr->qUnk3C += introSpr->qUnk40;
17431747
}
1748+
17441749
if (unk30 < 90) {
17451750
introSpr->qUnk40 -= Q(6. / 256.);
17461751
if (introSpr->qUnk40 < Q(0)) {
17471752
introSpr->qUnk40 = Q(0);
17481753
}
17491754
}
17501755

1751-
if (unk30 == 0xE9) {
1756+
if (unk30 == 233) {
17521757
introSpr->qUnk40 = Q(1.25);
17531758
}
17541759

src/platform/shared/input.c

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,51 @@
11
#ifdef _WIN32
2+
#include <stdlib.h>
3+
#include <stdio.h>
24
#include <windows.h>
35
#include <xinput.h>
46
#include "gba/io_reg.h"
57
#include "gba/types.h"
8+
#include "platform/shared/input.h"
69

710
#define STICK_THRESHOLD 0.5f
8-
u16 GetXInputKeys()
11+
SharedKeys GetXInputKeys()
912
{
1013
XINPUT_STATE state;
1114
ZeroMemory(&state, sizeof(XINPUT_STATE));
1215

1316
DWORD dwResult = XInputGetState(0, &state);
14-
u16 xinputKeys = 0;
17+
SharedKeys keys = 0;
1518

1619
if (dwResult == ERROR_SUCCESS) {
17-
/* A */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_A) >> 12;
18-
/* B */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_X) >> 13;
19-
/* Start */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_START) >> 1;
20-
/* Select */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_BACK) >> 3;
21-
/* L */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER) << 1;
22-
/* R */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER) >> 1;
23-
/* Up */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP) << 6;
24-
/* Down */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) << 6;
25-
/* Left */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT) << 3;
26-
/* Right */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) << 1;
20+
/* A */ keys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_A) >> 12;
21+
/* B */ keys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_X) >> 13;
22+
/* Start */ keys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_START) >> 1;
23+
/* Select */ keys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_BACK) >> 3;
24+
/* L */ keys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER) << 1;
25+
/* R */ keys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER) >> 1;
26+
/* Up */ keys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP) << 6;
27+
/* Down */ keys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) << 6;
28+
/* Left */ keys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT) << 3;
29+
/* Right */ keys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) << 1;
2730

2831
/* Control Stick */
2932
float xAxis = (float)state.Gamepad.sThumbLX / (float)SHRT_MAX;
3033
float yAxis = (float)state.Gamepad.sThumbLY / (float)SHRT_MAX;
3134

3235
if (xAxis < -STICK_THRESHOLD)
33-
xinputKeys |= DPAD_LEFT;
36+
keys |= DPAD_LEFT;
3437
else if (xAxis > STICK_THRESHOLD)
35-
xinputKeys |= DPAD_RIGHT;
38+
keys |= DPAD_RIGHT;
3639
if (yAxis < -STICK_THRESHOLD)
37-
xinputKeys |= DPAD_DOWN;
40+
keys |= DPAD_DOWN;
3841
else if (yAxis > STICK_THRESHOLD)
39-
xinputKeys |= DPAD_UP;
42+
keys |= DPAD_UP;
43+
44+
if (state.Gamepad.bRightTrigger > 170) {
45+
keys |= KEY_SPEEDUP;
46+
}
4047
}
4148

42-
return xinputKeys;
49+
return keys;
4350
}
4451
#endif // _WIN32

0 commit comments

Comments
 (0)