Decompile WRP BSS (#1337)

Move BSS definitions to code. This is the last of the ASM configured for
WRP.

---------

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
This commit is contained in:
Jonathan Hohle 2024-06-18 16:01:03 -07:00 committed by GitHub
parent e8922b9fef
commit d5977d931a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 72 additions and 51 deletions

View File

@ -235,6 +235,7 @@ set(SOURCE_FILES_STAGE_WRP
src/st/wrp/e_room_fg.c
src/st/wrp/popup.c
src/st/wrp/prim_helpers.c
src/st/wrp/bss.c
)
# organization is:

View File

@ -101,5 +101,5 @@ segments:
- [0x12E54, c, e_room_fg]
- [0x12F40, c, popup]
- [0x13270, c, prim_helpers]
- [0x13AA0, sbss] # bss?
- [0x13AB0, .bss, bss]
- [0x14768]

View File

@ -114,7 +114,7 @@ D_801804E0 = 0x0924B9B8;
D_80180528 = 0x0924B9E0;
D_80180538 = 0x0924B9E8;
D_80180608_wrp = 0x0924BA58;
D_8018065C = 0x0924BA98;
WarpRoomCoords = 0x0924BA98;
D_80186E30 = 0x0924BAB0;
D_80186E3C = 0x0924BAC0;
D_80186E4C = 0x0924BAD0;
@ -127,7 +127,7 @@ g_eBreakableExplosionTypes = 0x0924BCC8;
D_80180608 = 0x0924CCD0;
D_80180530 = 0x0924CCD8;
D_80180648 = 0x0924CCE0;
D_80193AAC = 0x0924CCE8;
D_80193AA8 = 0x0924CCF0;
D_80193AA4 = 0x0924CCF8;
D_80193AA0 = 0x0924CD00;
WarpBackgroundBrightness = 0x0924CCE8;
WarpBackgroundPhase = 0x0924CCF0;
WarpBackgroundAmplitiude = 0x0924CCF8;
DestinationWarpRoom = 0x0924CD00;

View File

@ -31,6 +31,10 @@ EntityRedDoor = 0x8018A9C8;
CollectGold = 0x8018CD10;
EntityEquipItemDrop = 0x8018DA34;
EntityStageNamePopup = 0x8019198C;
DestinationWarpRoom = 0x80193AA0;
WarpBackgroundAmplitiude = 0x80193AA4;
WarpBackgroundPhase = 0x80193AA8;
WarpBackgroundBrightness = 0x80193AAC;
g_LayoutObjHorizontal = 0x80193AB0;
g_LayoutObjVertical = 0x80193AB4;
g_LayoutObjPosHorizontal = 0x80193AB8;

View File

@ -56,18 +56,6 @@ static void* clut_anims[] = {
extern void* WRP_g_EntityGfxs[];
// BSS SECTION START
s32 D_80193AA0 = 0;
s32 D_80193AA4 = 0;
s32 D_80193AA8 = 0;
s32 D_80193AAC = 0;
u16* g_LayoutObjHorizontal = NULL;
u16* g_LayoutObjVertical = NULL;
u8 g_LayoutObjPosHorizontal = 0;
u8 g_LayoutObjPosVertical = 0;
u16 g_ItemIconSlots[32] = {0};
// BSS SECTION END
static Overlay g_StageDesc = {
Update,
HitDetection,

10
src/st/wrp/bss.c Normal file
View File

@ -0,0 +1,10 @@
#include "types.h"
s32 g_LayoutObjHorizontal;
s32 g_LayoutObjVertical;
s8 g_LayoutObjPosHorizontal;
static u8 pad0[3];
s8 g_LayoutObjPosVertical;
static u8 pad1[3];
static s32 pad2[0x31A];
s32 g_ItemIconSlots[16];

View File

@ -18,7 +18,7 @@ static u32 D_8018064C[] = {0x00040000, 0x00040000, 0xFFFC0004, 0x0000FFF8};
#endif
static WarpCoord D_8018065C[] = {
static WarpCoord WarpRoomCoords[] = {
{0x0F, 0x26}, // Entrance
{0x23, 0x2C}, // Abandoned pit to the Catacomb
{0x3B, 0x11}, // Outer Wall
@ -26,11 +26,28 @@ static WarpCoord D_8018065C[] = {
{0x25, 0x15}, // Orlox's Quarters
};
#ifndef VERSION_PSP
#ifdef VERSION_PSP
extern s32 DestinationWarpRoom;
extern s32 WarpBackgroundAmplitiude;
extern s32 WarpBackgroundPhase;
extern s32 WarpBackgroundBrightness;
#else
static u16 unused_array[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0001, 0x0000,
0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0101,
};
// the room the player will be warping to
static s32 DestinationWarpRoom;
// the amplitude of the current background phase
static s32 WarpBackgroundAmplitiude;
// the phase used to calculate the background color
static s32 WarpBackgroundPhase;
// the brightness of the background layer
static s32 WarpBackgroundBrightness;
#endif
// Handles everything about the warp room.
@ -107,7 +124,7 @@ void EntityWarpRoom(Entity* self) {
LOW(prim->r3) = LOW(prim->r0);
prim->priority = 0x1F0;
prim->drawMode = DRAW_HIDE;
D_80193AA4 = 0x100;
WarpBackgroundAmplitiude = 0x100;
for (i = 0; i < 32; i++) {
entity = AllocEntity(&g_Entities[0xA0], &g_Entities[0x100]);
if (entity != NULL) {
@ -193,19 +210,19 @@ void EntityWarpRoom(Entity* self) {
case 4:
// Perform the actual warp
move_room = self->params + 1;
for (i = 0; i < LEN(D_8018065C); i++, move_room++) {
if (move_room > LEN(D_8018065C) - 1) {
for (i = 0; i < LEN(WarpRoomCoords); i++, move_room++) {
if (move_room > LEN(WarpRoomCoords) - 1) {
move_room = 0;
}
if (g_CastleFlags[0xD0] & (1 << move_room)) {
break;
}
}
D_80193AA0 = move_room;
warpCoords = &D_8018065C[move_room];
DestinationWarpRoom = move_room;
warpCoords = &WarpRoomCoords[move_room];
moveX = warpCoords->x - g_Tilemap.left;
moveY = warpCoords->y - g_Tilemap.top;
FntPrint("move_room%x\n", D_80193AA0);
FntPrint("move_room%x\n", DestinationWarpRoom);
FntPrint("for_x:%x y%x\n", warpCoords->x, warpCoords->y);
FntPrint("move_x:%x y%x\n", moveX, moveY);
PLAYER.posX.i.hi += moveX << 8;
@ -252,40 +269,46 @@ void EntityWarpRoom(Entity* self) {
LOW(prim->r3) = LOW(prim->r0);
break;
default:
warpCoords = &D_8018065C[D_80193AA0];
warpCoords = &WarpRoomCoords[DestinationWarpRoom];
moveX = warpCoords->x - g_Tilemap.left;
moveY = warpCoords->y - g_Tilemap.top;
FntPrint("move_room%x\n", D_80193AA0);
FntPrint("move_room%x\n", DestinationWarpRoom);
FntPrint("for_x:%x y%x\n", warpCoords->x, warpCoords->y);
FntPrint("move_x:%x y%x\n", moveX, moveY);
break;
}
D_80193AA8 += 0x10;
D_80193AAC = (rsin(D_80193AA8) >> 8) + 0xD0;
if (D_80193AAC < 0) {
D_80193AAC = 0;
WarpBackgroundPhase += 0x10;
WarpBackgroundBrightness = (rsin(WarpBackgroundPhase) >> 8) + 0xD0;
if (WarpBackgroundBrightness < 0) {
WarpBackgroundBrightness = 0;
}
if (D_80193AAC > 0xFF) {
D_80193AAC = 0xFF;
if (WarpBackgroundBrightness > 0xFF) {
WarpBackgroundBrightness = 0xFF;
}
D_80193AA4 = (rcos(D_80193AA8) >> 8) + 0xD0;
WarpBackgroundAmplitiude = (rcos(WarpBackgroundPhase) >> 8) + 0xD0;
prim = self->ext.warpRoom.primBg;
for (i = 0; i < 16; i++) {
angle = D_80180608[(i + 0) % 16];
prim->r0 = ((rsin(angle) + 0x1000) >> 6) * D_80193AA4 / 256;
prim->r0 =
((rsin(angle) + 0x1000) >> 6) * WarpBackgroundAmplitiude / 256;
angle = D_80180608[(i + 5) % 16];
prim->g0 = ((rsin(angle) + 0x1000) >> 6) * D_80193AA4 / 256;
prim->g0 =
((rsin(angle) + 0x1000) >> 6) * WarpBackgroundAmplitiude / 256;
angle = D_80180608[(i + 10) % 16];
prim->b0 = ((rsin(angle) + 0x1000) >> 6) * D_80193AA4 / 256;
prim->b0 =
((rsin(angle) + 0x1000) >> 6) * WarpBackgroundAmplitiude / 256;
angle = D_80180608[(i + 1) % 16];
prim->r1 = ((rsin(angle) + 0x1000) >> 6) * D_80193AA4 / 256;
prim->r1 =
((rsin(angle) + 0x1000) >> 6) * WarpBackgroundAmplitiude / 256;
angle = D_80180608[(i + 6) % 16];
prim->g1 = ((rsin(angle) + 0x1000) >> 6) * D_80193AA4 / 256;
prim->g1 =
((rsin(angle) + 0x1000) >> 6) * WarpBackgroundAmplitiude / 256;
angle = D_80180608[(i + 11) % 16];
prim->b1 = ((rsin(angle) + 0x1000) >> 6) * D_80193AA4 / 256;
prim->b1 =
((rsin(angle) + 0x1000) >> 6) * WarpBackgroundAmplitiude / 256;
prim->r2 = prim->g2 = prim->b2 = prim->r3 = prim->g3 = prim->b3 =
D_80193AAC;
WarpBackgroundBrightness;
D_80180608[i] += 0x20;
prim = prim->next;
}

View File

@ -53,11 +53,6 @@ extern u16 g_ESoulStealOrbAngles[];
extern s16 g_ESoulStealOrbSprt[];
extern u8 g_ESoulStealOrbAnim[];
extern s32 D_80193AA0; // rename into move_room?
extern s32 D_80193AA4;
extern s32 D_80193AA8;
extern s32 D_80193AAC;
extern u16 g_ItemIconSlots[32];
void func_8018F838(Entity*);

View File

@ -1,10 +1,10 @@
#include <stage.h>
// warp.c
s32 D_80193AA0;
s32 D_80193AA4;
s32 D_80193AA8;
s32 D_80193AAC;
s32 DestinationWarpRoom;
s32 WarpBackgroundAmplitiude;
s32 WarpBackgroundPhase;
s32 WarpBackgroundBrightness;
s32 D_80180648;
// st_debug.c