Skip to content

Commit

Permalink
J2DScreen: Fixed parsing to allow multiple root-level panes
Browse files Browse the repository at this point in the history
d_a_title now loads its screen
  • Loading branch information
themikelester committed Dec 28, 2024
1 parent 5f7e8a0 commit e7a458a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
17 changes: 10 additions & 7 deletions src/Common/JSYSTEM/J2Dv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,8 @@ function readPAN1Chunk(buffer: ArrayBufferSlice, parent: PAN1 | null): PAN1 {
//#endregion Loading/J2Pane

//#region Loading/J2Screen
export interface SCRN {
inf1: INF1;
panes: PAN1[];
export interface SCRN extends PAN1 {
color: Color
}

export class BLO {
Expand All @@ -194,7 +193,11 @@ export class BLO {
const inf1 = readINF1Chunk(j2d.nextChunk('INF1'))
const panes: PAN1[] = [];

let parentStack: (PAN1 | null)[] = [null];
const screen: SCRN = { parent: null, type: 'SCRN', children: [], visible: true,
x: 0, y: 0, w: inf1.width, h: inf1.height, color: inf1.color, rot: 0, tag: '', basePos: 0,
alpha: inf1.color.a, inheritAlpha: false, offset: 0 };

let parentStack: (PAN1 | null)[] = [screen];
let shouldContinue = true;
while (shouldContinue) {
const magic = readString(buffer, j2d.offs, 4);
Expand Down Expand Up @@ -226,7 +229,7 @@ export class BLO {
}
}

return { inf1, panes };
return screen;
}
}

Expand Down Expand Up @@ -453,8 +456,8 @@ export class J2DScreen extends J2DPane {
public color: Color

constructor(data: SCRN, cache: GfxRenderCache) {
super(data.panes[0], cache, null);
this.color = data.inf1.color;
super(data, cache, null);
this.color = data.color;
}

public override draw(renderInstManager: GfxRenderInstManager, viewerRenderInput: ViewerRenderInput, ctx2D: J2DGrafContext, offsetX?: number, offsetY?: number): void {
Expand Down
22 changes: 20 additions & 2 deletions src/ZeldaWindWaker/d_a.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { fopAcIt_JudgeByID, fopAcM_create, fopAcM_prm_class, fopAc_ac_c } from "
import { cPhs__Status, fGlobals, fpcPf__Register, fpcSCtRq_Request, fpc_bs__Constructor } from "./framework.js";
import { mDoExt_McaMorf, mDoExt_bckAnm, mDoExt_brkAnm, mDoExt_btkAnm, mDoExt_btpAnm, mDoExt_modelEntryDL, mDoExt_modelUpdateDL } from "./m_do_ext.js";
import { MtxPosition, MtxTrans, calc_mtx, mDoMtx_XYZrotM, mDoMtx_XrotM, mDoMtx_YrotM, mDoMtx_YrotS, mDoMtx_ZXYrotM, mDoMtx_ZrotM, mDoMtx_ZrotS, quatM } from "./m_do_mtx.js";
import { J2DGrafContext } from "../Common/JSYSTEM/J2Dv1.js";
import { J2DGrafContext, J2DScreen } from "../Common/JSYSTEM/J2Dv1.js";

// Framework'd actors

Expand Down Expand Up @@ -5761,6 +5761,7 @@ class d_a_title extends fopAc_ac_c {
private modelShip: J3DModelInstance;
private bckShip = new mDoExt_bckAnm();
private bpkShip = new mDoExt_brkAnm();
private screen: J2DScreen;

private anmFrameCounter = 0
private delayFrameCounter = 120;
Expand Down Expand Up @@ -5835,10 +5836,27 @@ class d_a_title extends fopAc_ac_c {
mat4.mul(globals.camera.clipFromWorldMatrix, globals.camera.clipFromViewMatrix, globals.camera.viewFromWorldMatrix);
globals.camera.frustum.updateClipFrustum(globals.camera.clipFromWorldMatrix, globals.camera.clipSpaceNearZ);
renderInstManager.popTemplate();

this.screen.draw(renderInstManager, viewerInput, globals.scnPlay.orthoGraf2D);
}

private proc_init2D(globals: dGlobals) {

const screenData = globals.resCtrl.getObjectResByName(ResType.Blo, d_a_title.arcName, "title_logo_e.blo");
assert(screenData !== null);
this.screen = new J2DScreen(screenData, globals.renderer.renderCache);

// m0A0[2] = this.screen->search('pres');
// m0A0[3] = this.screen->search('nint');
// m0A0[0] = this.screen->search('zeld');
// m0A0[1] = this.screen->search('zelj');
// m0A0[4] = this.screen->search('eft1');
// m0A0[5] = this.screen->search('eft2');

// for (s32 i = 0; i < (s32)ARRAY_SIZE(pane); i++) {
// fopMsgM_setPaneData(&pane[i], m0A0[i]);
// fopMsgM_setNowAlpha(&pane[i], 0.0f);
// fopMsgM_setAlpha(&pane[i]);
// }
}

private proc_init3D(globals: dGlobals) {
Expand Down
6 changes: 3 additions & 3 deletions src/ZeldaWindWaker/d_place_name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ export class d_place_name extends msg_class {
}

this.screen = new J2DScreen(screen, globals.renderer.renderCache);
this.screen.children[0].data.visible = false;
this.screen.children[1].data.visible = false;
const pic = this.screen.children[2] as J2DPicture;
this.screen.children[0].children[0].data.visible = false;
this.screen.children[0].children[1].data.visible = false;
const pic = this.screen.children[0].children[2] as J2DPicture;
pic.setTexture(img);

return cPhs__Status.Complete;
Expand Down

0 comments on commit e7a458a

Please sign in to comment.