Skip to content

Commit

Permalink
Wind Waker: Use new J2D features to simplify place name loading
Browse files Browse the repository at this point in the history
  • Loading branch information
themikelester committed Dec 29, 2024
1 parent dbb6e39 commit 3baddf4
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/ZeldaWindWaker/d_place_name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,24 @@ export class d_place_name extends msg_class {
if (status !== cPhs__Status.Complete)
return status;

const screen = globals.resCtrl.getObjectRes(ResType.Blo, `PName`, 0x04);
const screenData = globals.resCtrl.getObjectRes(ResType.Blo, `PName`, 0x04);
this.screen = new J2DScreen(screenData, globals.renderer.renderCache, globals.resCtrl.getResResolver('PName'));
this.screen.search('blc1')!.hide();
this.screen.search('blc2')!.hide();

// The Outset Island image lives inside the arc. All others are loose files in 'res/placename/'
let img: BTIData;
// The Outset Island image lives inside the PName arc. All others are loose files in 'res/placename/'
if (globals.scnPlay.placenameIndex === Placename.OutsetIsland) {
img = globals.resCtrl.getObjectRes(ResType.Bti, `PName`, 0x07)
} else {
const placenameId = (globals.scnPlay.placenameIndex + 1);
const filename = `placename/pn_${placenameId.toString().padStart(2, "0")}.bti`;
status = globals.modelCache.requestFileData(filename);
if (status !== cPhs__Status.Complete)
return status;
const imgData = globals.modelCache.getFileData(filename);
img = new BTIData(globals.sceneContext.device, globals.renderer.renderCache, BTI.parse(imgData, filename).texture);
return cPhs__Status.Complete;
}

this.screen = new J2DScreen(screen, globals.renderer.renderCache, globals.resCtrl.getResResolver('PName'));

this.screen.search('blc1')!.hide();
this.screen.search('blc2')!.hide();
const placenameId = (globals.scnPlay.placenameIndex + 1);
const filename = `placename/pn_${placenameId.toString().padStart(2, "0")}.bti`;
status = globals.modelCache.requestFileData(filename);
if (status !== cPhs__Status.Complete)
return status;
const imgData = globals.modelCache.getFileData(filename);

const img = new BTIData(globals.sceneContext.device, globals.renderer.renderCache, BTI.parse(imgData, filename).texture);
const pic = assertExists(this.screen.search('\0\0pn')) as J2DPicture;
pic.setTexture(img);

Expand Down

0 comments on commit 3baddf4

Please sign in to comment.