Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sfx and render modes cleanup #1124

Merged
merged 5 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions include/common_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1048,19 +1048,6 @@ typedef struct CollisionData {
/* 0x0E */ char unk_0E[2];
} CollisionData; // size = 0x10

typedef struct ModelGroupData {
/* 0x00 */ Mtx* transformMatrix;
/* 0x04 */ Lightsn* lightingGroup;
/* 0x08 */ s32 numLights;
/* 0x0C */ s32 numChildren;
/* 0x10 */ struct ModelNode** childList;
} ModelGroupData; // size = 0x14

typedef struct ModelDisplayData {
/* 0x0 */ Gfx* displayList;
/* 0x4 */ char unk_04[0x4];
} ModelDisplayData; // size = 0x8

typedef struct AnimatorNode {
/* 0x00 */ Gfx* displayList;
/* 0x04 */ struct AnimatorNode* children[32];
Expand Down
630 changes: 316 additions & 314 deletions include/enums.h

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions include/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@

#define PACK_PAL_RGBA(r, g, b, a) (((r) << 11) | ((g) << 6) | ((b) << 1) | (a));

#define PM_RM_TILEMODE_B GBL_c1(G_BL_CLR_BL, G_BL_A_FOG, G_BL_CLR_IN, G_BL_1MA)

#define PM_CC_01 0, 0, 0, TEXEL0, PRIMITIVE, 0, TEXEL0, 0
#define PM_CC_02 0, 0, 0, TEXEL0, TEXEL0, 0, PRIMITIVE, 0
#define PM_CC_03 TEXEL0, 0, SHADE, 0, PRIMITIVE, 0, SHADE, 0
Expand All @@ -302,6 +304,12 @@
#define PM_CC_16 COMBINED, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED
#define PM_CC_17 COMBINED, 0, PRIMITIVE, ENVIRONMENT, 0, 0, 0, COMBINED

#define PM_CC_18 COMBINED, 0, SHADE, 0, 0, 0, 0, COMBINED
#define PM_CC_19 COMBINED, 0, SHADE, PRIMITIVE, 0, 0, 0, COMBINED
#define PM_CC_1A COMBINED, 0, PRIMITIVE, ENVIRONMENT, 0, 0, 0, COMBINED

#define PM_CC_ALT_TRILERP TEXEL1, TEXEL0, LOD_FRACTION, TEXEL0, TEXEL1, TEXEL0, LOD_FRACTION, TEXEL0

// custom cycle1 modes for window styles
#define PM_CC_WINDOW_2 PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, TEXEL1
#define PM_CC_WINDOW_3 PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, 0, TEXEL1, 0
Expand Down
15 changes: 14 additions & 1 deletion include/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ typedef struct ModelNodeProperty {
/* 0x8 */ ModelNodePropertyData data;
} ModelNodeProperty; // size = 0xC;

typedef struct ModelGroupData {
/* 0x00 */ Mtx* transformMatrix;
/* 0x04 */ Lightsn* lightingGroup;
/* 0x08 */ s32 numLights;
/* 0x0C */ s32 numChildren;
/* 0x10 */ struct ModelNode** childList;
} ModelGroupData; // size = 0x14

typedef struct ModelDisplayData {
/* 0x0 */ Gfx* displayList;
/* 0x4 */ char unk_04[0x4];
} ModelDisplayData; // size = 0x8

typedef struct ModelNode {
/* 0x00 */ s32 type; /* 2 = model */
/* 0x04 */ ModelDisplayData* displayData;
Expand Down Expand Up @@ -172,7 +185,7 @@ typedef struct ShapeFile {
} ShapeFile; // size = variable

typedef ModelTreeInfo ModelTreeInfoList[0x200];
extern ModelTreeInfoList* mdl_currentModelTreeNodeInfo;
extern ModelTreeInfoList* gCurrentModelTreeNodeInfo;
extern ModelList* gCurrentModels;

void set_model_fog_color_parameters(u8 primR, u8 primG, u8 primB, u8 primA, u8 fogR, u8 fogG, u8 fogB, s32 fogStart, s32 fogEnd);
Expand Down
56 changes: 28 additions & 28 deletions src/animator.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ SHIFT_BSS Matrix4f gAnimTranslateMtx;
SHIFT_BSS Matrix4f gAnimRotScaleMtx;
SHIFT_BSS StaticAnimatorNode** gAnimTreeRoot;

extern Gfx D_8014B7F8[];
extern Gfx D_8014B820[];
extern Gfx D_8014B848[];
extern Gfx D_8014B870[];
extern Gfx D_8014B898[];
extern Gfx D_8014B8C0[];
extern Gfx D_8014B8E8[];
extern Gfx D_8014BE78[];
extern Gfx D_8014BEA0[];
extern Gfx D_8014BEC8[];
extern Gfx D_8014BEF0[];
extern Gfx D_8014BF18[];
extern Gfx D_8014BF40[];
extern Gfx D_8014BF68[];
extern Gfx Gfx_RM1_SURFACE_OPA[];
extern Gfx Gfx_RM1_DECAL_OPA[];
extern Gfx Gfx_RM1_INTERSECTING_OPA[];
extern Gfx Gfx_RM1_ALPHATEST[];
extern Gfx Gfx_RM1_SURFACE_XLU[];
extern Gfx Gfx_RM1_DECAL_XLU[];
extern Gfx Gfx_RM1_INTERSECTING_XLU[];
extern Gfx Gfx_RM3_SURFACE_OPA[];
extern Gfx Gfx_RM3_DECAL_OPA[];
extern Gfx Gfx_RM3_INTERSECTING_OPA[];
extern Gfx Gfx_RM3_ALPHATEST[];
extern Gfx Gfx_RM3_SURFACE_XLU[];
extern Gfx Gfx_RM3_DECAL_XLU[];
extern Gfx Gfx_RM3_INTERSECTING_XLU[];

AnimScript gAnimScriptDefault = {
as_Wait(60)
Expand Down Expand Up @@ -786,50 +786,50 @@ void appendGfx_animator(ModelAnimator* animator) {
case FALSE:
switch (animator->renderMode) {
case RENDER_MODE_SURFACE_OPA:
gSPDisplayList(gMainGfxPos++, D_8014B7F8);
gSPDisplayList(gMainGfxPos++, Gfx_RM1_SURFACE_OPA);
break;
case RENDER_MODE_DECAL_OPA:
gSPDisplayList(gMainGfxPos++, D_8014B820);
gSPDisplayList(gMainGfxPos++, Gfx_RM1_DECAL_OPA);
break;
case RENDER_MODE_INTERSECTING_OPA:
gSPDisplayList(gMainGfxPos++, D_8014B848);
gSPDisplayList(gMainGfxPos++, Gfx_RM1_INTERSECTING_OPA);
break;
case RENDER_MODE_ALPHATEST:
gSPDisplayList(gMainGfxPos++, D_8014B870);
gSPDisplayList(gMainGfxPos++, Gfx_RM1_ALPHATEST);
break;
case RENDER_MODE_SURFACE_XLU_LAYER1:
gSPDisplayList(gMainGfxPos++, D_8014B898);
gSPDisplayList(gMainGfxPos++, Gfx_RM1_SURFACE_XLU);
break;
case RENDER_MODE_DECAL_XLU:
gSPDisplayList(gMainGfxPos++, D_8014B8C0);
gSPDisplayList(gMainGfxPos++, Gfx_RM1_DECAL_XLU);
break;
case RENDER_MODE_INTERSECTING_XLU:
gSPDisplayList(gMainGfxPos++, D_8014B8E8);
gSPDisplayList(gMainGfxPos++, Gfx_RM1_INTERSECTING_XLU);
break;
}
break;
case TRUE:
switch (animator->renderMode) {
case RENDER_MODE_SURFACE_OPA:
gSPDisplayList(gMainGfxPos++, D_8014BE78);
gSPDisplayList(gMainGfxPos++, Gfx_RM3_SURFACE_OPA);
break;
case RENDER_MODE_DECAL_OPA:
gSPDisplayList(gMainGfxPos++, D_8014BEA0);
gSPDisplayList(gMainGfxPos++, Gfx_RM3_DECAL_OPA);
break;
case RENDER_MODE_INTERSECTING_OPA:
gSPDisplayList(gMainGfxPos++, D_8014BEC8);
gSPDisplayList(gMainGfxPos++, Gfx_RM3_INTERSECTING_OPA);
break;
case RENDER_MODE_ALPHATEST:
gSPDisplayList(gMainGfxPos++, D_8014BEF0);
gSPDisplayList(gMainGfxPos++, Gfx_RM3_ALPHATEST);
break;
case RENDER_MODE_SURFACE_XLU_LAYER1:
gSPDisplayList(gMainGfxPos++, D_8014BF18);
gSPDisplayList(gMainGfxPos++, Gfx_RM3_SURFACE_XLU);
break;
case RENDER_MODE_DECAL_XLU:
gSPDisplayList(gMainGfxPos++, D_8014BF40);
gSPDisplayList(gMainGfxPos++, Gfx_RM3_DECAL_XLU);
break;
case RENDER_MODE_INTERSECTING_XLU:
gSPDisplayList(gMainGfxPos++, D_8014BF68);
gSPDisplayList(gMainGfxPos++, Gfx_RM3_INTERSECTING_XLU);
break;
}

Expand Down
39 changes: 17 additions & 22 deletions src/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ typedef struct SoundPlayer {
/* 0x85 */ u8 triggers;
/* 0x86 */ char unk_86[0x2];
/* 0x88 */ s8* loopStartPos;
/* 0x8C */ u8 loopIterCount;
/* 0x8C */ u8 loopIterCount; // loopIterCount = 0 for infinite loop
/* 0x8D */ char unk_8D;
/* 0x8E */ u16 delay;
/* 0x90 */ u16 playLength;
Expand Down Expand Up @@ -783,28 +783,25 @@ typedef struct BGMInstrumentInfo {
/* 0x07 */ char pad_7[1];
} BGMInstrumentInfo; // size = 0x8

typedef struct AUFileMetadata {
/* 0x00 */ s32 signature; // file type identifer: 'SBN ', 'SEF ', etc
/* 0x04 */ s32 size; // full file size, including header and data
} AUFileMetadata;

typedef struct SBNHeader {
/* 0x00 */ s32 signature; // 'SBN '
/* 0x04 */ s32 size;
/* 0x08 */ s32 unk_08;
/* 0x0C */ s32 unk_0C;
/* 0x10 */ s32 tableOffset; // = 0x40
/* 0x14 */ s32 numEntries;
/* 0x18 */ s32 unk_18;
/* 0x1C */ s32 unk_1C;
/* 0x20 */ s32 unk_20;
/* 0x00 */ AUFileMetadata mdata; // uses identifer 'SBN '
/* 0x08 */ char unused_08[8];
/* 0x10 */ s32 tableOffset; // offset in the SBN file of the file table (== sizeof(SBNHeader))
/* 0x14 */ s32 numEntries; // number of entries in the SBN file table
/* 0x18 */ s32 fileSize; // full size of the SBN file (unread)
/* 0x1C */ s32 versionOffset;
/* 0x20 */ char unused_04[4];
/* 0x24 */ s32 INIToffset;
/* 0x28 */ s32 unk_28;
/* 0x2C */ s32 unk_2C;
/* 0x30 */ s32 unk_30;
/* 0x34 */ s32 unk_34;
/* 0x38 */ s32 unk_38;
/* 0x3C */ s32 unk_3C;
/* 0x28 */ char reserved[24];
} SBNHeader; // size = 0x40

typedef struct SEFHeader {
/* 0x00 */ s32 signature; // 'SEF '
/* 0x04 */ s32 size;
/* 0x00 */ AUFileMetadata mdata; // uses identifer 'SEF '
/* 0x08 */ s32 unk8;
/* 0x0C */ s8 unkC; // 0
/* 0x0D */ s8 unkD; // 0
Expand All @@ -815,8 +812,7 @@ typedef struct SEFHeader {
} SEFHeader; // size = 0x22

typedef struct INITHeader {
/* 0x00 */ s32 signature; // 'INIT'
/* 0x04 */ s32 size;
/* 0x00 */ AUFileMetadata mdata; // uses identifer 'INIT'
/* 0x08 */ u16 entriesOffset;
/* 0x0A */ u16 entriesSize;
/* 0x0C */ u16 tblOffset;
Expand All @@ -827,8 +823,7 @@ typedef struct INITHeader {
} INITHeader; // size = 0x20

typedef struct PERHeader {
/* 0x00 */ s32 signature; // 'PER ' or 'PRG '
/* 0x04 */ s32 size; // including this header
/* 0x00 */ AUFileMetadata mdata; // uses identifer 'PER ' or 'PRG '
/* 0x08 */ char unk_08[8];
} PERHeader; // size = 0x10

Expand Down
4 changes: 2 additions & 2 deletions src/audio/2e230_len_2190.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ void au_load_PER(AuGlobals* globals, s32 romAddr) {
void* end;

au_read_rom(romAddr, &header, sizeof(header));
size = header.size - sizeof(header);
size = header.mdata.size - sizeof(header);
au_read_rom(romAddr + sizeof(header), globals->dataPER, size);
numItems = size / sizeof(PEREntry);
numItemsLeft = 6 - numItems;
Expand All @@ -819,7 +819,7 @@ void au_load_PRG(AuGlobals* arg0, s32 romAddr) {

au_read_rom(romAddr, &header, sizeof(header));
dataRomAddr = romAddr + sizeof(header);
size = header.size - sizeof(header);
size = header.mdata.size - sizeof(header);
if (size > 0x200) {
size = 0x200;
}
Expand Down
Loading
Loading