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

Add hack to load bss texture in ovl_En_Jsjutan (fixes #69) #1482

Merged
merged 2 commits into from
Sep 20, 2022
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
7 changes: 6 additions & 1 deletion OTRExporter/OTRExporter/DisplayListExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,13 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
uint32_t seg = data & 0xFFFFFFFF;
int32_t texAddress = Seg2Filespace(data, dList->parent->baseAddress);

if (!Globals::Instance->HasSegment(GETSEGNUM(seg), res->parent->workerID))
if (!Globals::Instance->HasSegment(GETSEGNUM(seg), res->parent->workerID) || (res->GetName() == "sShadowMaterialDL"))
{
if (res->GetName() == "sShadowMaterialDL") {
// sShadowMaterialDL (In ovl_En_Jsjutan) has a texture in bss. This is a hack to override the reference to one
// to segment C. The actor has been modified to load the texture into segment C.
seg = 0x0C000000;
}
int32_t __ = (data & 0x00FF000000000000) >> 48;
int32_t www = (data & 0x00000FFF00000000) >> 32;

Expand Down
5 changes: 0 additions & 5 deletions libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2110,11 +2110,6 @@ unsigned int dListBP;
int matrixBP;
uintptr_t clearMtx;

extern "C"
{
uintptr_t jsjutanShadowTex = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing SoH code from LUS 👋

};

static void gfx_run_dl(Gfx* cmd) {
//puts("dl");
int dummy = 0;
Expand Down
6 changes: 2 additions & 4 deletions soh/src/overlays/actors/ovl_En_Jsjutan/z_en_jsjutan.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,6 @@ void EnJsjutan_Update(Actor* thisx, GlobalContext* globalCtx2) {
thisx->shape.rot.z = Math_CosS(globalCtx->gameplayFrames * 3500) * 300.0f;
}

extern uintptr_t jsjutanShadowTex;

void EnJsjutan_Draw(Actor* thisx, GlobalContext* globalCtx2) {
EnJsjutan* this = (EnJsjutan*)thisx;
GlobalContext* globalCtx = globalCtx2;
Expand Down Expand Up @@ -396,13 +394,12 @@ void EnJsjutan_Draw(Actor* thisx, GlobalContext* globalCtx2) {
}

func_80A89A6C(this, globalCtx);
jsjutanShadowTex = sShadowTex;

if (this->unk_164) {
this->unk_164 = false;
u8* carpTex = ResourceMgr_LoadTexByName(sCarpetTex);
u8* shadTex = sShadowTex;
for (i = 0; i < ARRAY_COUNT(shadTex); i++) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea why this worked before (IDO being bad?). But for the array size to be calculated correctly, it needed to be changed to something that was, well, an array

for (i = 0; i < ARRAY_COUNT(sShadowTex); i++) {
if (((u16*)carpTex)[i] != 0) { // Hack to bypass ZAPD exporting textures as u64.
shadTex[i] = 0xFF;
} else {
Expand All @@ -421,6 +418,7 @@ void EnJsjutan_Draw(Actor* thisx, GlobalContext* globalCtx2) {
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);

// Draws the carpet's shadow texture.
gSPSegment(POLY_OPA_DISP++, 0x0C, sShadowTex);
gSPDisplayList(POLY_OPA_DISP++, sShadowMaterialDL);
gDPPipeSync(POLY_OPA_DISP++);

Expand Down