Skip to content

Commit

Permalink
Formatting cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
themikelester committed Jan 1, 2025
1 parent 5b9e2d2 commit 4afc290
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 39 deletions.
30 changes: 15 additions & 15 deletions src/Common/JSYSTEM/J2Dv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ function parseResourceReference(buffer: ArrayBufferSlice, offset: number, resTyp
/**
* When rendering a J2D element that was originally designed for 4:3 in a wider aspect ratio, the screenspace Y
* positions are maintained but the X positions must be adjusted. Often we simply want to keep the elements centered,
* but occasionally we want to anchor them to the left or right.
* but occasionally we want to anchor them to the left or right side of the screen (e.g. Wind Waker place names).
* See also: J2DGrafContext.setPort() and dPlaceName.load()
*/
export enum J2DAnchorPos {
Left,
Center,
Right
Right
}

/**
Expand All @@ -79,7 +79,7 @@ const enum J2DUVBinding {
};

export class J2DGrafContext {
private clipSpaceNearZ: GfxClipSpaceNearZ;
private clipSpaceNearZ: GfxClipSpaceNearZ;
public sceneParams = new SceneParams();
public viewport = vec4.create();
public ortho = vec4.create();
Expand Down Expand Up @@ -115,7 +115,7 @@ export class J2DGrafContext {
const right = this.ortho[1] * this.aspectRatioCorrection;
const bottom = this.ortho[2] + 0.5;
const top = this.ortho[3];

projectionMatrixForCuboid(this.sceneParams.u_Projection, left, right, bottom, top, this.near, this.far);
projectionMatrixConvertClipSpaceNearZ(this.sceneParams.u_Projection, this.clipSpaceNearZ, GfxClipSpaceNearZ.NegativeOne);
}
Expand Down Expand Up @@ -246,8 +246,8 @@ export class BLO {
const panes: PAN1[] = [];

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,
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,
};

Expand Down Expand Up @@ -324,12 +324,12 @@ export class J2DPane {
this.data.visible = false;
}

public setAlpha(alpha: number) {
this.data.alpha = alpha * 0xFF;
public setAlpha(alpha: number) {
this.data.alpha = alpha * 0xFF;
}
public getAlpha(alpha: number) {
this.data.alpha = alpha / 0xFF;

public getAlpha(alpha: number) {
this.data.alpha = alpha / 0xFF;
}

// NOTE: Overwritten by child classes which actually do some rendering, such as J2DPicture
Expand Down Expand Up @@ -363,7 +363,7 @@ export class J2DPane {
}
}
}

public search(tag: string): J2DPane | null {
if (this.data.tag === tag)
return this;
Expand Down Expand Up @@ -526,7 +526,7 @@ export class J2DPicture extends J2DPane {

// Assume alpha is enabled. This is byte 1 on a JUTTexture, but noclip doesn't read it
mb.setChanCtrl(GX.ColorChannelID.COLOR0A0, false, GX.ColorSrc.REG, GX.ColorSrc.VTX, 0, GX.DiffuseFunction.NONE, GX.AttenuationFunction.NONE);

// 0: Multiply tex and vertex colors and alpha
mb.setTevOrder(tevStage, GX.TexCoordID.TEXCOORD0, GX.TexMapID.TEXMAP0, GX.RasColorChannelID.COLOR0A0);
mb.setTevColorIn(tevStage, GX.CC.ZERO, GX.CC.TEXC, GX.CC.RASC, GX.CC.ZERO);
Expand Down Expand Up @@ -562,7 +562,7 @@ export class J2DPicture extends J2DPane {

protected override resolveReferences(resolver: ResourceResolver<JUTResType.TIMG>): void {
const timg = this.data.timg;
if (timg.refType > 1) {
if (timg.refType > 1) {
if (timg.refType !== 2)
console.warn(`Untested J2D feature refType ${timg.refType}`);
this.tex = resolver(JUTResType.TIMG, timg.resName);
Expand All @@ -588,7 +588,7 @@ export class J2DScreen extends J2DPane {
}

public override draw(renderInstManager: GfxRenderInstManager, ctx2D: J2DGrafContext, offsetX?: number, offsetY?: number): void {
switch(this.anchorPos) {
switch (this.anchorPos) {
case J2DAnchorPos.Left: this.data.x = 0; break;
case J2DAnchorPos.Center: this.data.x = (ctx2D.aspectRatioCorrection - 1.0) * ctx2D.viewport[2] * 0.5; break;
case J2DAnchorPos.Right: this.data.x = (ctx2D.aspectRatioCorrection - 1.0) * ctx2D.viewport[2]; break;
Expand Down
18 changes: 10 additions & 8 deletions src/ZeldaWindWaker/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -940,9 +940,9 @@ class DemoDesc extends SceneDesc implements Viewer.SceneDesc {
public override stageDir: string,
public override name: string,
public override roomList: number[],
public stbFilename: string,
public stbFilename: string,
public layer: number,
public offsetPos?:vec3,
public offsetPos?: vec3,
public rotY: number = 0,
public startCode?: number,
public eventFlags?: number,
Expand All @@ -966,7 +966,7 @@ class DemoDesc extends SceneDesc implements Viewer.SceneDesc {
globals.scnPlay.demo.remove();

// TODO: Don't render until the camera has been placed for this demo. The cuts are jarring.

// noclip modification: This normally happens on room load. Do it here instead so that we don't waste time
// loading .arcs for cutscenes that aren't going to be played
const lbnk = globals.roomCtrl.status[this.roomList[0]].data.lbnk;
Expand All @@ -987,7 +987,7 @@ class DemoDesc extends SceneDesc implements Viewer.SceneDesc {
await globals.modelCache.waitForLoad();

// Most cutscenes expect the Link actor to be loaded
if(!fopAcM_searchFromName(globals, 'Link', 0, 0)) {
if (!fopAcM_searchFromName(globals, 'Link', 0, 0)) {
fopAcM_create(globals.frameworkGlobals, dProcName_e.d_a_py_lk, 0, null, globals.mStayNo, null, null, 0xFF, -1);
}

Expand All @@ -997,10 +997,12 @@ class DemoDesc extends SceneDesc implements Viewer.SceneDesc {
}

// noclip modification: ensure all the actors are created before we load the cutscene
await new Promise(resolve => { (function waitForActors(){
if (globals.frameworkGlobals.ctQueue.length === 0) return resolve(null);
setTimeout(waitForActors, 30);
})(); });
await new Promise(resolve => {
(function waitForActors() {
if (globals.frameworkGlobals.ctQueue.length === 0) return resolve(null);
setTimeout(waitForActors, 30);
})();
});

// @TODO: Set noclip layer visiblity based on this.layer

Expand Down
32 changes: 16 additions & 16 deletions src/ZeldaWindWaker/d_a.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5775,7 +5775,7 @@ class d_a_title extends fopAc_ac_c {
private btkSubtitle = new mDoExt_btkAnm();
private btkShimmer = new mDoExt_btkAnm();
private screen: J2DScreen;
private panes: J2DPane[] = [];
private panes: J2DPane[] = [];

private anmFrameCounter = 0
private delayFrameCounter = 120;
Expand All @@ -5789,17 +5789,17 @@ class d_a_title extends fopAc_ac_c {
const status = dComIfG_resLoad(globals, d_a_title.arcName);
if (status !== cPhs__Status.Complete)
return status;

this.proc_init2D(globals);
this.proc_init3D(globals);

return cPhs__Status.Next;
}

public override execute(globals: dGlobals, deltaTimeFrames: number): void {
if (this.delayFrameCounter > 0) {
this.delayFrameCounter -= deltaTimeFrames;

if (this.delayFrameCounter == 0) {
// TODO: mDoAud_seStart(JA_SE_TITLE_WIND);
}
Expand All @@ -5812,7 +5812,7 @@ class d_a_title extends fopAc_ac_c {
} else if (this.enterMode == 3) {
this.shipFrameCounter += deltaTimeFrames;
}

this.bckShip.play(deltaTimeFrames);
this.set_mtx();
}
Expand All @@ -5838,7 +5838,7 @@ class d_a_title extends fopAc_ac_c {
light.Position = [-35000.0, 0.0, -30000.0];
light.Direction = [0, 0, 0];
light.Color = White;

{
this.model_draw(globals, renderInstManager);

Expand All @@ -5860,14 +5860,14 @@ class d_a_title extends fopAc_ac_c {
this.screen = new J2DScreen(screenData, globals.renderer.renderCache, globals.resCtrl.getResResolver(d_a_title.arcName), J2DAnchorPos.Center);
this.screen.color = White;
this.screen.setAlpha(1.0); // TODO: This isn't here originally

this.panes[TitlePane.MainTitle] = this.screen.search('zeld')!;
this.panes[TitlePane.JapanSubtitle] = this.screen.search('zelj')!;
this.panes[TitlePane.PressStart] = this.screen.search('pres')!;
this.panes[TitlePane.Nintendo] = this.screen.search('nint')!;
this.panes[4] = this.screen.search('eft1')!;
this.panes[5] = this.screen.search('eft2')!;

for (let pane of this.panes) {
pane.setAlpha(0.0);
}
Expand All @@ -5876,7 +5876,7 @@ class d_a_title extends fopAc_ac_c {
private proc_init3D(globals: dGlobals) {
const modelDataShip = globals.resCtrl.getObjectRes(ResType.Model, d_a_title.arcName, 0xD);
this.modelShip = new J3DModelInstance(modelDataShip);

const modelDataSub = globals.resCtrl.getObjectRes(ResType.Model, d_a_title.arcName, 0xC);
this.modelSubtitle = new J3DModelInstance(modelDataSub);

Expand All @@ -5902,11 +5902,11 @@ class d_a_title extends fopAc_ac_c {
}

private model_draw(globals: dGlobals, renderInstManager: GfxRenderInstManager) {

if (this.btkSubtitle.frameCtrl.getFrame() != 0.0) {
this.btkShimmer.entry(this.modelSubtitleShimmer)
mDoExt_modelUpdateDL(globals, this.modelSubtitleShimmer, renderInstManager, globals.dlst.ui);

this.btkSubtitle.entry(this.modelSubtitle);
mDoExt_modelUpdateDL(globals, this.modelSubtitle, renderInstManager, globals.dlst.ui);
}
Expand All @@ -5921,16 +5921,16 @@ class d_a_title extends fopAc_ac_c {
private set_mtx() {
vec3.set(this.modelShip.baseScale, 0.9, 0.9, 0.9);
mat4.fromTranslation(this.modelShip.modelMatrix, [this.shipOffsetX, 0, 1000]);
mDoMtx_ZXYrotM(this.modelShip.modelMatrix, [0, 0x4000, 0]);
mDoMtx_ZXYrotM(this.modelShip.modelMatrix, [0, 0x4000, 0]);

vec3.set(this.modelSubtitle.baseScale, 1.0, 1.0, 1.0);
vec3.set(this.modelSubtitleShimmer.baseScale, 1.0, 1.0, 1.0);

mat4.fromTranslation(this.modelSubtitle.modelMatrix, [-57.0, -3.0, -10000.0]);
mDoMtx_ZXYrotM(this.modelSubtitle.modelMatrix, [0, -0x8000, 0]);
mDoMtx_ZXYrotM(this.modelSubtitle.modelMatrix, [0, -0x8000, 0]);

mat4.fromTranslation(this.modelSubtitleShimmer.modelMatrix, [-57.0, -3.0, -10010.0]);
mDoMtx_ZXYrotM(this.modelSubtitleShimmer.modelMatrix, [0, -0x8000, 0]);
mDoMtx_ZXYrotM(this.modelSubtitleShimmer.modelMatrix, [0, -0x8000, 0]);
}

private calc_2d_alpha(deltaTimeFrames: number) {
Expand Down Expand Up @@ -5962,7 +5962,7 @@ class d_a_title extends fopAc_ac_c {
if (this.anmFrameCounter >= 80) {
this.btkSubtitle.play(deltaTimeFrames);
}

if (this.anmFrameCounter <= 150) {
this.panes[TitlePane.Nintendo].setAlpha(0.0);
} else if (this.anmFrameCounter <= 170) {
Expand Down Expand Up @@ -6001,7 +6001,7 @@ class d_a_title extends fopAc_ac_c {

if (this.shimmerFrameCounter <= 0) {
const finished = this.btkShimmer.play(deltaTimeFrames);
if(finished) {
if (finished) {
this.btkShimmer.frameCtrl.setFrame(0.0);
this.btkShimmer.frameCtrl.setRate(1.0);
this.shimmerFrameCounter = cM_rndF(120) + 10;
Expand Down

0 comments on commit 4afc290

Please sign in to comment.