From 3baddf423abe483bbbec79cc7adc3fd7d2f63a32 Mon Sep 17 00:00:00 2001 From: Mike Lester Date: Sun, 29 Dec 2024 16:03:33 -0700 Subject: [PATCH] Wind Waker: Use new J2D features to simplify place name loading --- src/ZeldaWindWaker/d_place_name.ts | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/ZeldaWindWaker/d_place_name.ts b/src/ZeldaWindWaker/d_place_name.ts index fe9de2437..d323cfc8e 100644 --- a/src/ZeldaWindWaker/d_place_name.ts +++ b/src/ZeldaWindWaker/d_place_name.ts @@ -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);