Skip to content

Commit

Permalink
decompile sub_802E784, fix some macos compiler issues
Browse files Browse the repository at this point in the history
  • Loading branch information
freshollie committed Jan 5, 2025
1 parent ac3c4eb commit db841c4
Show file tree
Hide file tree
Showing 8 changed files with 696 additions and 1,212 deletions.
1,198 changes: 0 additions & 1,198 deletions asm/game_7.s

This file was deleted.

407 changes: 407 additions & 0 deletions asm/non_matching/game/stage/sub_802E49C.inc

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion include/game/stage/game_7.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ void sub_802DCC8(u8 p0, u16 p1);
void sub_802DDC4(u8 p0, u16 p1);
void sub_802DF18(u8 p0, u16 p1);

void sub_802E784(u16, u16, u16, s16 x, s16 y, s16);
void sub_802E784(u16, u16, u16, s16 x, s16 y, u8);

#endif // GUARD_GAME_7_H
11 changes: 3 additions & 8 deletions ldscript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,14 @@ SECTIONS
src/game/cheese.o(.text);
src/game/boost_effect.o(.text);
src/game/amy_attack_heart_effect.o(.text);

src/game/multiplayer/mp_player.o(.text);
src/game/multiplayer/unknown_task.o(.text);
src/game/multiplayer/player_unk_1.o(.text);
src/game/multiplayer/indicators.o(.text);
src/game/multiplayer/finish.o(.text);
src/game/multiplayer/player_unk_2.o(.text);

src/game/game.o(.text);
src/game/dummy_task.o(.text);

Expand Down Expand Up @@ -178,31 +180,23 @@ SECTIONS
src/game/stage/dust_effect_spindash.o(.text);
src/game/stage/grind_effect_1.o(.text);
src/game/stage/rings_scatter.o(.text);

/* player */
src/game/stage/player.o(.text);

src/game/stage/item_tasks.o(.text);
src/game/stage/underwater_effects.o(.text);
src/game/stage/screen_shake.o(.text);
src/game/stage/player_controls.o(.text);

src/game/stage/player_super_sonic.o(.text);
src/game/stage/ui.o(.text);
src/game/stage/debug_text_printer.o(.text);
src/game/stage/screen_fade.o(.text);
src/game/stage/trapped_animals.o(.text);
src/game/stage/game_7.o(.text);
#if (CPU_ARCH_ARM == 1)
asm/game_7.o(.text);
#endif
src/game/stage/boss_results_transition.o(.text);
src/game/stage/intro.o(.text);
src/game/stage/results.o(.text);

src/game/character_select.o(.text);
src/game/course_select.o(.text);

src/game/countdown.o(.text);
src/game/game_over.o(.text);

Expand All @@ -219,6 +213,7 @@ SECTIONS
src/game/bosses/boss_7.o(.text);
src/game/bosses/boss_8.o(.text);
src/game/bosses/boss_9.o(.text);

src/game/enemies/projectiles.o(.text);
src/game/enemies/mon.o(.text);
src/game/enemies/gohla.o(.text);
Expand Down
1 change: 1 addition & 0 deletions src/game/sa1_sa2_shared/collision.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ u32 sub_800CE94(Sprite *s, s32 sx, s32 sy, struct Rect8 *inRect, Player *p)
NONMATCH("asm/non_matching/game/sa1_sa2_shared/collision__sub_800D0A0.inc",
u32 sub_800D0A0(Sprite *s, s16 param1, s16 param2, s16 param3, s16 param4, u8 param5, u32 param6))
{
return 0;
}
END_NONMATCH

Expand Down
282 changes: 282 additions & 0 deletions src/game/stage/game_7.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "global.h"
#include "core.h"
#include "trig.h"
#include "flags.h"
#include "game/stage/game_7.h"

void sub_802DBC0(u8 p0, u16 p1)
{
Expand Down Expand Up @@ -635,3 +637,283 @@ void sub_802E384(s16 *p0, u16 pairCount)
}
}
}

NONMATCH("asm/non_matching/game/stage/sub_802E49C.inc", void sub_802E49C(s16 *tmp8, s32 length)) { }
END_NONMATCH

void sub_802E784(u16 a, u16 b, u16 c, s16 x, s16 y, u8 d)
{
s32 r6, r7, r1;

s16 temp, r3, sl = 0;
s16 tmp8[7][2];

s16 limitY2, limitX2;
s16 limitX1, limitY1;

gUnknown_03002A80 = 2;
gUnknown_03002878 = (void *)REG_ADDR_WIN0H;
gFlags |= FLAGS_4;

if (x > 0 && x < DISPLAY_WIDTH && y < DISPLAY_HEIGHT && x > 0) {
u16 i;
#ifndef NON_MATCHING
s32 r8;
#endif
if (gBgOffsetsHBlank == gBgOffsetsBuffer) {
DmaFill16(3, 0, &gBgOffsetsBuffer[0], sizeof(gBgOffsetsBuffer[0]));
} else {
DmaFill16(3, 0, &gBgOffsetsBuffer[1], sizeof(gBgOffsetsBuffer[1]));
}

r1 = CLAMP_SIN_PERIOD(a - Q(1));
r6 = (COS(r1) * b) >> 15;
#ifndef NON_MATCHING
{
register void *r1_2 asm("r1") = (r1 * 2) + ((void *)gSineTable);
r8 = *(s16 *)r1_2;
r7 = (r8 * b) >> 15;
}
#else
r7 = (COS(r1) * b) >> 15;
#endif

tmp8[1][0] = x + r6;
tmp8[1][1] = y + r7;
tmp8[0][0] = (x - r6);
tmp8[0][1] = (y - r7);

r6 = (COS(a) * d) >> 14;
r7 = (SIN(a) * d) >> 14;

tmp8[1][0] += r6;
tmp8[1][1] += r7;

tmp8[0][0] += r6;
tmp8[0][1] += r7;

limitX1 = tmp8[1][0];
limitY1 = tmp8[1][1];
limitX2 = tmp8[0][0];
limitY2 = tmp8[0][1];

r6 = (COS(r1) * c) >> 15;
#ifndef NON_MATCHING
r7 = (r8 * c) >> 15;
#else
r7 = (SIN(r1) * c) >> 15;
#endif

tmp8[2][0] = x + r6;
tmp8[2][1] = y + r7;
tmp8[3][0] = x - r6;
tmp8[3][1] = y - r7;

r6 = (COS(a) * 15) >> 2;
r7 = SIN(a) >> 6;

if (r6 != 0) {
if (r7 != 0) {
r6 = Div(r6, r7);
} else {
r6 = Q(DISPLAY_WIDTH);
}
}

r1 = Q(limitX1);

if (a < Q(2)) {
for (i = limitY1; i < (DISPLAY_HEIGHT - 1); i++) {
r1 += r6;
sl = I(r1);
if (sl >= DISPLAY_WIDTH) {
sl = DISPLAY_WIDTH;
break;
}

if (sl < 0) {
sl = 0;
break;
}
}
} else {
for (i = limitY1; i != 0; i--) {
r1 -= r6;
sl = r1 >> 8;
if (sl >= DISPLAY_WIDTH) {
sl = DISPLAY_WIDTH;
break;
}

if (sl < 0) {
sl = 0;
break;
}
}
}

tmp8[4][0] = sl;
tmp8[4][1] = i;

r1 = Q(limitX2);

if (a < Q(2)) {
for (i = limitY2; i < (DISPLAY_HEIGHT - 1); i++) {
r1 += r6;
sl = I(r1);
if (sl >= DISPLAY_WIDTH) {
sl = DISPLAY_WIDTH;
break;
}

if (sl < 0) {
sl = 0;
break;
}
}
} else {
for (i = limitY2; i != 0; i--) {
r1 -= r6;
sl = I(r1);
if (sl >= DISPLAY_WIDTH) {
sl = DISPLAY_WIDTH;
break;
}

if (sl < 0) {
sl = 0;
break;
}
}
}
tmp8[5][0] = sl;
tmp8[5][1] = i;

temp = tmp8[5][0];
if (tmp8[5][0] != tmp8[4][0] && tmp8[5][1] != tmp8[4][1]) {
if (tmp8[4][0] == 0) {
tmp8[6][0] = tmp8[4][0];
tmp8[6][1] = tmp8[5][1];
} else {
if (tmp8[5][0] != 0 && tmp8[4][0] == DISPLAY_WIDTH) {
tmp8[6][0] = tmp8[4][0];
tmp8[6][1] = tmp8[5][1];
} else {
tmp8[6][0] = temp;
tmp8[6][1] = tmp8[4][1];
}
}
sub_802E49C(tmp8[0], 7);
} else {
sub_802E49C(tmp8[0], 6);
}
} else {

if ((b / 2) == 0) {
if (gBgOffsetsHBlank == gBgOffsetsBuffer) {
DmaFill16(3, 0, &gBgOffsetsBuffer[0], sizeof(gBgOffsetsBuffer[0]));
} else {
DmaFill16(3, 0, &gBgOffsetsBuffer[1], sizeof(gBgOffsetsBuffer[1]));
}
return;
}

if (a > Q(1) && a < Q(3) && x >= DISPLAY_WIDTH) {
r7 = (SIN(a) * (x - DISPLAY_WIDTH)) >> 14;
r7 += y;

if (r7 > 0 && r7 < DISPLAY_HEIGHT) {
s16 r3, r4;
r3 = DISPLAY_WIDTH + 1;
if (gBgOffsetsHBlank == gBgOffsetsBuffer) {
DmaFill16(3, r3, &gBgOffsetsBuffer[0], sizeof(gBgOffsetsBuffer[0]));
} else {
DmaFill16(3, r3, &gBgOffsetsBuffer[1], sizeof(gBgOffsetsBuffer[1]));
}

r4 = r7 - (b / 2);
if (r4 < 0) {
r4 = 0;
} else if (r4 > DISPLAY_HEIGHT) {
r4 = DISPLAY_HEIGHT;
}
sub_802DF18(r4, a);

r4 = r7 + (b / 2);
if (r4 < 0) {
r4 = 0;
} else if (r4 > DISPLAY_HEIGHT) {
r4 = DISPLAY_HEIGHT;
}
sub_802DDC4(r4, a);
return;
}
}

if (a > Q(2)) {
if (y >= DISPLAY_HEIGHT) {
s16 r3, r4;
r6 = (COS(a) * (y - DISPLAY_HEIGHT)) >> 14;
r6 += x;

if (r6 > 0 && r6 < DISPLAY_WIDTH) {
r3 = DISPLAY_WIDTH + 1;
if (gBgOffsetsHBlank == gBgOffsetsBuffer) {
DmaFill16(3, r3, &gBgOffsetsBuffer[0], sizeof(gBgOffsetsBuffer[0]));
} else {
DmaFill16(3, r3, &gBgOffsetsBuffer[1], sizeof(gBgOffsetsBuffer[1]));
}

r4 = r6 - (b / 2);
if (r4 < 0) {
r4 = 0;
} else if (r4 > DISPLAY_WIDTH) {
r4 = DISPLAY_WIDTH;
}
sub_802E0D4(r4 << 8, a);

r4 = r6 + (b / 2);
if (r4 < 0) {
r4 = 0;
} else if (r4 > DISPLAY_WIDTH) {
r4 = DISPLAY_WIDTH;
}
sub_802E044(Q(r4), a);
return;
}
}
}

if (a <= Q(2)) {
if (y < 0) {
s16 r3, r4;
r6 = (COS(a) * (y - DISPLAY_HEIGHT)) >> 14;
r6 += x;
if (r6 > 0 && r6 < DISPLAY_WIDTH) {
r3 = DISPLAY_WIDTH + 1;
if (gBgOffsetsHBlank == gBgOffsetsBuffer) {
DmaFill16(3, r3, &gBgOffsetsBuffer[0], sizeof(gBgOffsetsBuffer[0]));
} else {
DmaFill16(3, r3, &gBgOffsetsBuffer[1], sizeof(gBgOffsetsBuffer[1]));
}

r4 = r6 - (b / 2);
if (r4 < 0) {
r4 = 0;
} else if (r4 > DISPLAY_WIDTH) {
r4 = DISPLAY_WIDTH;
}
sub_802E1EC(Q(r4), a);

r4 = r6 + (b / 2);
if (r4 < 0) {
r4 = 0;
} else if (r4 > DISPLAY_WIDTH) {
r4 = DISPLAY_WIDTH;
}
sub_802E164(Q(r4), a);
}
}
}
}
}
4 changes: 2 additions & 2 deletions src/game/stage/player.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,10 +691,10 @@ void SetStageSpawnPos(u32 character, u32 level, u32 p2, Player *p)
void InitializePlayer(Player *p)
{
#ifndef NON_MATCHING
register u8 *u99_r6 asm("r6");
register s8 *u99_r6 asm("r6");
register s8 *unk60 asm("r4");
#else
u8 *u99_r6;
s8 *u99_r6;
s8 *unk60;
#endif
s8 *character;
Expand Down
3 changes: 0 additions & 3 deletions src/platform/shared/stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@ void *ewram_end = 0;
void *iwram_end = 0;
char gNumMusicPlayers = 4;
int gMaxLines = 0;

// boss_5
void sub_802E784(u16 p0, u16 p1, u16 p2, s16 x, s16 y, s16 p5) { }

0 comments on commit db841c4

Please sign in to comment.