Skip to content

Commit a939ebc

Browse files
committed
sa2: match Knuckles_Glide_UpdateSpeed, fix sa1 sa2 InitGlide consistency
1 parent 67ecd33 commit a939ebc

3 files changed

Lines changed: 52 additions & 213 deletions

File tree

asm/non_matching/game/player__sub_80139B0.inc

Lines changed: 0 additions & 168 deletions
This file was deleted.

src/game/sa1/stage/player_knuckles.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct Task *Player_Knuckles_InitGfx_FloatSplash(Player *p);
2929

3030
extern const u8 gCharStatesKnucklesGlideTurn[];
3131

32-
void Player_Knuckles_GlideInit(Player *p)
32+
void Player_Knuckles_InitGlide(Player *p)
3333
{
3434
p->moveState &= ~MOVESTATE_SPIN_ATTACK;
3535
PLAYERFN_SET_SHIFT_OFFSETS(p, 6, 6);

src/game/sa2/stage/player_callbacks.c

Lines changed: 51 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,18 +1701,17 @@ void sub_801394C(Player *p)
17011701
}
17021702
}
17031703

1704-
// (76.32%) https://decomp.me/scratch/8fUWD
1705-
// (97.64%) https://decomp.me/scratch/Bd3kQ
1706-
// (98.61%) https://decomp.me/scratch/0zv3B
1707-
NONMATCH("asm/non_matching/game/player__sub_80139B0.inc", void Knuckles_Glide_UpdateSpeed(Player *player))
1704+
// 100% (fake match): https://decomp.me/scratch/63L6J
1705+
void Knuckles_Glide_UpdateSpeed(Player *player)
17081706
{
17091707
s32 speedGrnd = ABS(player->qSpeedGround);
17101708
s8 shift = player->w.kf.shift;
1709+
s32 cos;
17111710

17121711
if (speedGrnd < Q_24_8(3.0)) {
17131712
speedGrnd += Q_24_8(6.0 / 256.0);
17141713
} else if (speedGrnd < Q_24_8(15.0)) {
1715-
if ((player->w.kf.shift & 0x7F) == 0)
1714+
if ((player->w.kf.shift & 127) == 0)
17161715
speedGrnd += Q_24_8(3.0 / 256.0);
17171716
}
17181717
// _080139E4
@@ -1723,53 +1722,61 @@ NONMATCH("asm/non_matching/game/player__sub_80139B0.inc", void Knuckles_Glide_Up
17231722
}
17241723
}
17251724

1726-
{
1727-
s8 shift = player->w.kf.shift + Q_24_8(0.25);
1728-
if (shift <= 0) {
1729-
player->qSpeedGround = -speedGrnd;
1730-
} else {
1731-
player->qSpeedGround = +speedGrnd;
1732-
}
1725+
if ((s8)(player->w.kf.shift + Q_24_8(0.25)) <= 0) {
1726+
player->qSpeedGround = -speedGrnd;
1727+
} else {
1728+
player->qSpeedGround = +speedGrnd;
17331729
}
17341730

1735-
{
1736-
if (player->heldInput & DPAD_LEFT) {
1737-
if ((u8)shift != 128) {
1738-
if (shift < 0)
1739-
shift = -shift;
1740-
shift += 2;
1741-
}
1742-
player->w.kf.shift = shift;
1743-
} else if (player->heldInput & DPAD_RIGHT) {
1744-
if (shift != 0) {
1745-
if (shift > 0)
1746-
shift = -shift;
1747-
shift += 2;
1748-
}
1749-
player->w.kf.shift = shift;
1750-
} else {
1751-
if (shift & 0x7F) {
1752-
shift += 2;
1753-
}
1754-
player->w.kf.shift = shift;
1731+
if (player->heldInput & DPAD_LEFT) {
1732+
if ((u8)shift != 128) {
1733+
if (shift < 0)
1734+
shift = -shift;
1735+
shift += 2;
1736+
}
1737+
player->w.kf.shift = shift;
1738+
} else if (player->heldInput & DPAD_RIGHT) {
1739+
if (shift != 0) {
1740+
if (shift > 0)
1741+
shift = -shift;
1742+
shift += 2;
17551743
}
1744+
player->w.kf.shift = shift;
1745+
} else {
1746+
if (shift & 127) {
1747+
shift += 2;
1748+
}
1749+
player->w.kf.shift = shift;
1750+
}
17561751

1757-
player->qSpeedAirX = I(COS_24_8(shift << 2) * speedGrnd);
1752+
#ifndef NON_MATCHING
1753+
cos = Q_2_14_TO_Q_24_8(({
1754+
s32 offset;
1755+
const u16 *sineTable = gSineTable;
1756+
asm("lsl %0, %1, #0x18\n\t"
1757+
"lsr %0, %0, #0x15"
1758+
: "=r"(offset)
1759+
: "r"(shift));
1760+
offset += 0x200;
1761+
((s16) * (u16 *)((void *)sineTable + offset));
1762+
}));
1763+
#else
1764+
cos = COS_24_8((u8)shift * 4);
1765+
#endif
1766+
player->qSpeedAirX = Q_24_8_TO_INT(cos * speedGrnd);
17581767

1759-
if (player->qSpeedAirY < Q_24_8(0.5)) {
1760-
player->qSpeedAirY += Q_24_8(0.09375);
1761-
} else {
1762-
player->qSpeedAirY -= Q_24_8(0.09375);
1763-
}
1768+
if (player->qSpeedAirY < Q_24_8(0.5)) {
1769+
player->qSpeedAirY += Q_24_8(0.09375);
1770+
} else {
1771+
player->qSpeedAirY -= Q_24_8(0.09375);
1772+
}
17641773

1765-
if (gCamera.unk4C > 0) {
1766-
gCamera.unk4C -= 2;
1767-
} else if (gCamera.unk4C < 0) {
1768-
gCamera.unk4C += 4;
1769-
}
1774+
if (gCamera.unk4C > 0) {
1775+
gCamera.unk4C -= 2;
1776+
} else if (gCamera.unk4C < 0) {
1777+
gCamera.unk4C += 4;
17701778
}
17711779
}
1772-
END_NONMATCH
17731780

17741781
void Player_Knuckles_InitGlide(Player *p)
17751782
{

0 commit comments

Comments
 (0)