Skip to content

Commit

Permalink
[ntsc-1.2] Match z_file_choose.c and z_boss_tw.c (#2146)
Browse files Browse the repository at this point in the history
* Match z_file_choose.c

* Match z_boss_tw.c

* Format

* end: -> close_disps:
  • Loading branch information
cadmic authored Sep 7, 2024
1 parent ed870e0 commit 8a3ba35
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 48 deletions.
4 changes: 2 additions & 2 deletions src/code/z_eff_blure.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ void EffectBlure_DrawElemNoInterpolation(EffectBlure* this, EffectBlureElement*
if (vtx == NULL) {
PRINTF(T("z_eff_blure.c::SQ_NoInterpolate_disp() 頂点確保できず。\n",
"z_eff_blure.c::SQ_NoInterpolate_disp() Vertices cannot be secured.\n"));
goto end;
goto close_disps;
}

vtx[0].v = baseVtx;
Expand Down Expand Up @@ -470,7 +470,7 @@ void EffectBlure_DrawElemNoInterpolation(EffectBlure* this, EffectBlureElement*
gSPVertex(POLY_XLU_DISP++, vtx, 4, 0);
gSP2Triangles(POLY_XLU_DISP++, 0, 1, 2, 0, 0, 2, 3, 0);

end:
close_disps:
CLOSE_DISPS(gfxCtx, "../z_eff_blure.c", 932);
}

Expand Down
6 changes: 3 additions & 3 deletions src/code/z_eff_spark.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) {
if (vertices == NULL) {
PRINTF(T("EffectSparkInfo_disp():メモリー確保失敗 graph_malloc\n",
"EffectSparkInfo_disp(): Memory Allocation Failure graph_malloc\n"));
goto end;
goto close_disps;
}

j = 0;
Expand Down Expand Up @@ -262,7 +262,7 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) {

mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &sp12C);
if (mtx == NULL) {
goto end;
goto close_disps;
}

gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
Expand All @@ -273,6 +273,6 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) {
gDPPipeSync(POLY_XLU_DISP++);
}

end:
close_disps:
CLOSE_DISPS(gfxCtx, "../z_eff_spark.c", 498);
}
67 changes: 35 additions & 32 deletions src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c
Original file line number Diff line number Diff line change
Expand Up @@ -3411,45 +3411,48 @@ void func_80942C70(Actor* thisx, PlayState* play) {

OPEN_DISPS(play->state.gfxCtx, "../z_boss_tw.c", 6765);

if (this->beamDist != 0.0f) {
Matrix_Push();
gSPSegment(POLY_XLU_DISP++, 0xC,
Gfx_TexScroll(play->state.gfxCtx, 0, (u8)(this->work[CS_TIMER_1] * -0xF), 0x20, 0x40));
alpha = this->beamScale * 100.0f * 255.0f;
if (this->beamDist == 0.0f) {
goto close_disps;
}

if (this->actor.params == TW_KOUME) {
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 60, alpha);
gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128);
} else {
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, alpha);
gDPSetEnvColor(POLY_XLU_DISP++, 100, 100, 255, 128);
}
Matrix_Push();
gSPSegment(POLY_XLU_DISP++, 0xC,
Gfx_TexScroll(play->state.gfxCtx, 0, (u8)(this->work[CS_TIMER_1] * -0xF), 0x20, 0x40));
alpha = this->beamScale * 100.0f * 255.0f;

if (this->actor.params == TW_KOUME) {
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 60, alpha);
gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128);
} else {
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, alpha);
gDPSetEnvColor(POLY_XLU_DISP++, 100, 100, 255, 128);
}

Matrix_Translate(this->beamOrigin.x, this->beamOrigin.y, this->beamOrigin.z, MTXMODE_NEW);
Matrix_RotateY(this->beamYaw, MTXMODE_APPLY);
Matrix_RotateX(this->beamPitch, MTXMODE_APPLY);
Matrix_RotateZ(this->beamRoll, MTXMODE_APPLY);
Matrix_Scale(this->beamScale, this->beamScale, (this->beamDist * 0.01f * 98.0f) / 20000.0f, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_boss_tw.c", 6846),
G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH);
gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gTwinrovaBeamDL));

Matrix_Translate(this->beamOrigin.x, this->beamOrigin.y, this->beamOrigin.z, MTXMODE_NEW);
Matrix_RotateY(this->beamYaw, MTXMODE_APPLY);
Matrix_RotateX(this->beamPitch, MTXMODE_APPLY);
if (this->beamReflectionDist > 10.0f) {
Matrix_Translate(this->beamReflectionOrigin.x, this->beamReflectionOrigin.y, this->beamReflectionOrigin.z,
MTXMODE_NEW);
Matrix_RotateY(this->beamReflectionYaw, MTXMODE_APPLY);
Matrix_RotateX(this->beamReflectionPitch, MTXMODE_APPLY);
Matrix_RotateZ(this->beamRoll, MTXMODE_APPLY);
Matrix_Scale(this->beamScale, this->beamScale, (this->beamDist * 0.01f * 98.0f) / 20000.0f, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_boss_tw.c", 6846),
Matrix_Scale(this->beamScale, this->beamScale, (this->beamReflectionDist * 0.01f * 100.0f) / 20000.0f,
MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_boss_tw.c", 6870),
G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH);
gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gTwinrovaBeamDL));

if (this->beamReflectionDist > 10.0f) {
Matrix_Translate(this->beamReflectionOrigin.x, this->beamReflectionOrigin.y, this->beamReflectionOrigin.z,
MTXMODE_NEW);
Matrix_RotateY(this->beamReflectionYaw, MTXMODE_APPLY);
Matrix_RotateX(this->beamReflectionPitch, MTXMODE_APPLY);
Matrix_RotateZ(this->beamRoll, MTXMODE_APPLY);
Matrix_Scale(this->beamScale, this->beamScale, (this->beamReflectionDist * 0.01f * 100.0f) / 20000.0f,
MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_boss_tw.c", 6870),
G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH);
gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gTwinrovaBeamDL));
}

Matrix_Pop();
}

Matrix_Pop();

close_disps:
CLOSE_DISPS(play->state.gfxCtx, "../z_boss_tw.c", 6878);
}

Expand Down
50 changes: 41 additions & 9 deletions src/overlays/gamestates/ovl_file_choose/z_file_choose.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include "versions.h"
#include "assets/textures/title_static/title_static.h"
#include "assets/textures/parameter_static/parameter_static.h"
#if PLATFORM_N64
#include "n64dd.h"
#endif

static s16 sUnused = 106;

Expand Down Expand Up @@ -219,6 +222,14 @@ void FileSelect_UpdateMainMenu(GameState* thisx) {
} else if (!this->n64ddFlags[this->buttonIndex]) {
Audio_PlaySfxGeneral(NA_SE_SY_FSEL_ERROR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
} else {
#if PLATFORM_N64
if (D_80121212 != 0) {
func_801C7268();
// Setting ioData to 1 and writing it to ioPort 7 will skip the harp intro
Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_MAIN, NA_BGM_FILE_SELECT, 0, 7, 1);
}
#endif
}
} else {
if (this->warningLabel == FS_WARNING_NONE) {
Expand Down Expand Up @@ -821,14 +832,13 @@ static s16 sHeartEnvColors[2][3] = { { 50, 40, 60 }, { 255, 255, 255 } };
void FileSelect_DrawFileInfo(GameState* thisx, s16 fileIndex, s16 isActive) {
FileSelectState* this = (FileSelectState*)thisx;
Font* sp54 = &this->font;
s32 heartType;
s16 i;
s16 heartType;
s16 vtxOffset;
s16 i;
s16 j;
s16 k;
s16 deathCountSplit[3];

if (1) {}

OPEN_DISPS(this->state.gfxCtx, "../z_file_choose.c", 1709);

gDPPipeSync(POLY_OPA_DISP++);
Expand Down Expand Up @@ -857,8 +867,8 @@ void FileSelect_DrawFileInfo(GameState* thisx, s16 fileIndex, s16 isActive) {
FileSelect_SplitNumber(this->deaths[fileIndex], &deathCountSplit[0], &deathCountSplit[1], &deathCountSplit[2]);

// draw death count
for (i = 0, vtxOffset = 0; i < 3; i++, vtxOffset += 4) {
FileSelect_DrawCharacter(this->state.gfxCtx, sp54->fontBuf + deathCountSplit[i] * FONT_CHAR_TEX_SIZE,
for (k = 0, vtxOffset = 0; k < 3; k++, vtxOffset += 4) {
FileSelect_DrawCharacter(this->state.gfxCtx, sp54->fontBuf + deathCountSplit[k] * FONT_CHAR_TEX_SIZE,
vtxOffset);
}

Expand All @@ -874,10 +884,10 @@ void FileSelect_DrawFileInfo(GameState* thisx, s16 fileIndex, s16 isActive) {
gDPSetEnvColor(POLY_OPA_DISP++, sHeartEnvColors[heartType][0], sHeartEnvColors[heartType][1],
sHeartEnvColors[heartType][2], 255);

i = this->healthCapacities[fileIndex] / 0x10;
k = this->healthCapacities[fileIndex] / 0x10;

// draw hearts
for (vtxOffset = 0, j = 0; j < i; j++, vtxOffset += 4) {
for (vtxOffset = 0, j = 0; j < k; j++, vtxOffset += 4) {
gSPVertex(POLY_OPA_DISP++, &this->windowContentVtx[D_8081284C[fileIndex] + vtxOffset] + 0x30, 4, 0);

POLY_OPA_DISP = FileSelect_QuadTextureIA8(POLY_OPA_DISP, sHeartTextures[heartType], 0x10, 0x10, 0);
Expand Down Expand Up @@ -984,9 +994,9 @@ static void* sOptionsButtonTextures[] = LANGUAGE_ARRAY(gFileSelOptionsButtonJPNT
void FileSelect_DrawWindowContents(GameState* thisx) {
FileSelectState* this = (FileSelectState*)thisx;
s16 fileIndex;
s16 temp;
s16 i;
s16 quadVtxIndex;
s16 temp;
s16 isActive;
s16 pad;

Expand Down Expand Up @@ -1560,6 +1570,14 @@ void FileSelect_LoadGame(GameState* thisx) {
gSaveContext.save.info.equips.equipment &= gEquipNegMasks[EQUIP_TYPE_SWORD];
gSaveContext.save.info.inventory.equipment ^= OWNED_EQUIP_FLAG(EQUIP_TYPE_SWORD, swordEquipValue - 1);
}

#if PLATFORM_N64
if (D_80121212 != 0) {
s32 fileNum = gSaveContext.fileNum;

n64dd_SetDiskVersion(this->n64ddFlags[fileNum]);
}
#endif
}

static void (*sSelectModeUpdateFuncs[])(GameState*) = {
Expand Down Expand Up @@ -1645,7 +1663,15 @@ void FileSelect_Main(GameState* thisx) {

OPEN_DISPS(this->state.gfxCtx, "../z_file_choose.c", 2898);

#if PLATFORM_N64
if ((D_80121212 != 0) && (func_801C70FC() != 0)) {
this->n64ddFlag = 1;
} else {
this->n64ddFlag = 0;
}
#else
this->n64ddFlag = 0;
#endif

gSPSegment(POLY_OPA_DISP++, 0x00, NULL);
gSPSegment(POLY_OPA_DISP++, 0x01, this->staticSegment);
Expand Down Expand Up @@ -1924,6 +1950,12 @@ void FileSelect_Init(GameState* thisx) {
u32 size = (uintptr_t)_title_staticSegmentRomEnd - (uintptr_t)_title_staticSegmentRomStart;
s32 pad;

#if PLATFORM_N64
if (D_80121212 != 0) {
func_801C7268();
}
#endif

SREG(30) = 1;
PRINTF("SIZE=%x\n", size);

Expand Down
2 changes: 1 addition & 1 deletion src/overlays/gamestates/ovl_file_choose/z_file_nameset.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ void FileSelect_SetNameEntryVtx(GameState* thisx) {
gSPVertex(POLY_OPA_DISP++, this->nameEntryVtx + 4, 32, 0);
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->nameEntryBoxAlpha);

for (phi_v0 = 0, phi_s0 = 0; phi_s0 < 0x20; phi_s0 += 4, phi_v0++) {
for (phi_s0 = 0, phi_v0 = 0; phi_s0 < 0x20; phi_s0 += 4, phi_v0++) {
FileSelect_DrawCharacter(this->state.gfxCtx,
font->fontBuf + this->fileNames[this->buttonIndex][phi_v0] * FONT_CHAR_TEX_SIZE,
phi_s0);
Expand Down
2 changes: 1 addition & 1 deletion tools/disasm/ntsc-1.2/files_ovl_file_choose.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
offset,vram,.text
0,80803880,src/overlays/gamestates/ovl_file_choose/z_file_copy_erase
3040,808068C0,src/overlays/gamestates/ovl_file_choose/z_file_nameset
8440,8080BCC0,z_file_choose
8440,8080BCC0,src/overlays/gamestates/ovl_file_choose/z_file_choose

offset,vram,.data
EC50,808124D0,src/overlays/gamestates/ovl_file_choose/z_file_nameset_data
Expand Down
2 changes: 2 additions & 0 deletions tools/disasm/ntsc-1.2/functions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3099,6 +3099,8 @@ Regs_InitDataImpl = 0x800E2704; // type:func
Regs_InitData = 0x800E35D0; // type:func
njpgdspMainTextStart = 0x800E7200; // type:func
func_801C6E80 = 0x801C7740; // type:func
func_801C70FC = 0x801C79BC; // type:func
func_801C7268 = 0x801C7BC4; // type:func
func_801C7C1C = 0x801C8510; // type:func
n64dd_SetDiskVersion = 0x801C8808; // type:func
ConsoleLogo_Calc = 0x80800000; // type:func
Expand Down

0 comments on commit 8a3ba35

Please sign in to comment.