Skip to content

Commit

Permalink
minor demo cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
magcius committed Dec 27, 2024
1 parent ea8324b commit d63648a
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 41 deletions.
20 changes: 9 additions & 11 deletions src/Common/JSYSTEM/JStudio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,7 @@ class TActorAdaptor extends TAdaptor {

if (reverse) { frame = maxFrame - frame; }
if (maxFrame > 0.0) {
const func = FVB.TFunctionValue.toFunction_outside(outsideType);
frame = func(frame, maxFrame);
frame = FVB.TFunctionValue.calcFunction_outside(outsideType, frame, maxFrame);
}
return frame;
}
Expand Down Expand Up @@ -1135,12 +1134,12 @@ namespace FVB {

public setIdNo(idNo: number) { this.idNo = idNo; }

public static toFunction_outside(type: EExtrapolateType): (frame: number, maxFrame: number) => number {
public static calcFunction_outside(type: EExtrapolateType, frame: number, maxFrame: number) {
switch (type) {
case EExtrapolateType.Raw: return (f, m) => f;
case EExtrapolateType.Repeat: return (f, m) => { f = f % m; return f < 0 ? f + m : f; }
case EExtrapolateType.Turn: return (f, m) => { f %= (2 * m); if (f < 0) f += m; return f > m ? 2 * m - f : f };
case EExtrapolateType.Clamp: return (f, m) => clamp(f, 0.0, m);
case EExtrapolateType.Raw: return frame;
case EExtrapolateType.Repeat: frame = frame % maxFrame; return frame < 0 ? frame + maxFrame : frame;
case EExtrapolateType.Turn: frame %= (2 * maxFrame); if (frame < 0) frame += maxFrame; return frame > maxFrame ? 2 * maxFrame - frame : frame;
case EExtrapolateType.Clamp: return clamp(frame, 0.0, maxFrame);
}
}
}
Expand Down Expand Up @@ -1391,8 +1390,8 @@ namespace FVB {
private extrapolate(progress: number) {
let t = progress
t -= this.begin;
if( t < 0.0 ) { t = FVB.TFunctionValue.toFunction_outside(this.underflow)(t, this.diff); }
else if( t >= this.diff) { t = FVB.TFunctionValue.toFunction_outside(this.overflow)(t, this.diff); }
if (t < 0.0) { t = FVB.TFunctionValue.calcFunction_outside(this.underflow, t, this.diff); }
else if (t >= this.diff) { t = FVB.TFunctionValue.calcFunction_outside(this.overflow, t, this.diff); }
t += this.begin;
return t;
}
Expand Down Expand Up @@ -1920,7 +1919,6 @@ export class TControl {
}

public forward(frameCount: number): boolean {
;
let andStatus = 0xFF;
let orStatus = 0;

Expand Down Expand Up @@ -1969,7 +1967,7 @@ export class TControl {
}

public createMessageObject(blockObj: TBlockObject): STBObject | null {
if( blockObj.type == 'JMSG' ) {
if (blockObj.type == 'JMSG') {
const adaptor = new TMessageAdaptor(this.msgControl);
const obj = new TMessageObject(this, blockObj, adaptor);

Expand Down
1 change: 0 additions & 1 deletion src/ZeldaWindWaker/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ export class dCamera_c {

if (!this.frozen) {
// Update the "player position" from the camera.
// TODO: Move this out of here
vec3.copy(globals.playerPosition, this.cameraPos);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/ZeldaWindWaker/d_a.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4766,11 +4766,12 @@ class d_a_npc_ls1 extends fopNpc_npc_c {
{ anmIdx: 0, nextPrmIdx: 1, morf: 8.0, playSpeed: 1.0, loopMode: 2, },
{ anmIdx: 5, nextPrmIdx: 1, morf: 8.0, playSpeed: 1.0, loopMode: 2, },
{ anmIdx: 10, nextPrmIdx: 2, morf: 8.0, playSpeed: 1.0, loopMode: 2, },
{ anmIdx: 5, nextPrmIdx: 1, morf: 8.0, playSpeed: 1.0, loopMode: 2, }];
{ anmIdx: 5, nextPrmIdx: 1, morf: 8.0, playSpeed: 1.0, loopMode: 2, }
];

public override subload(globals: dGlobals): cPhs__Status {
const success = this.decideType(this.parameters);
if (!success) { return cPhs__Status.Error; }
if (!success) { return cPhs__Status.Stop; }

let status = dComIfG_resLoad(globals, this.arcName);
if (status !== cPhs__Status.Complete)
Expand Down
52 changes: 26 additions & 26 deletions src/ZeldaWindWaker/d_demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export class dDemo_actor_c extends TActor {
case 4: btpId = this.stbData.getInt32(1); break;
case 5: btpId = this.stbData.getInt32(2); break;
case 6: btpId = this.stbData.getInt32(2); break;
default:
default:
return null;
}
}
Expand All @@ -242,7 +242,7 @@ export class dDemo_actor_c extends TActor {
if ((btpId & 0x10000) != 0) {
arcName = globals.roomCtrl.demoArcName!;
}

const btp = globals.resCtrl.getObjectIDRes(ResType.Btp, arcName, btpId);
this.textAnimFrameMax = this.stbData.getInt16(6);
return btp;
Expand All @@ -254,29 +254,29 @@ export class dDemo_actor_c extends TActor {
}

public getBtkData(globals: dGlobals, arcName: string): TTK1 | null {
if (!(this.flags & EDemoActorFlags.HasData)) {
return null;
}

let btkId;
switch(this.stbDataId) {
case 2: btkId = this.stbData.getInt16(4); break;
case 5: btkId = this.stbData.getInt32(6); break;
case 6: btkId = this.stbData.getInt32(6); break;
default:
return null;
}

if (btkId == this.btkId) {
if (!(this.flags & EDemoActorFlags.HasData)) {
return null;
}

let btkId;
switch(this.stbDataId) {
case 2: btkId = this.stbData.getInt16(4); break;
case 5: btkId = this.stbData.getInt32(6); break;
case 6: btkId = this.stbData.getInt32(6); break;
default:
return null;
}

this.btkId = btkId;
if ((btkId & 0x10000) != 0) {
arcName = globals.roomCtrl.demoArcName!;
}

return globals.resCtrl.getObjectIDRes(ResType.Btk, arcName, btkId);
}

if (btkId == this.btkId) {
return null;
}

this.btkId = btkId;
if ((btkId & 0x10000) != 0) {
arcName = globals.roomCtrl.demoArcName!;
}

return globals.resCtrl.getObjectIDRes(ResType.Btk, arcName, btkId);
}

public override JSGGetName() { return this.name; }
Expand Down Expand Up @@ -323,7 +323,7 @@ export class dDemo_actor_c extends TActor {

public override JSGSetShape(id: number): void {
this.shapeId = id;
this.flags |= EDemoActorFlags.HasShape
this.flags |= EDemoActorFlags.HasShape;
}

public override JSGSetAnimation(id: number): void {
Expand Down Expand Up @@ -489,7 +489,7 @@ export class dDemo_manager_c {
}

/**
* Called by Actor update functions to update their data from the demo version of the actor.
* Called by Actor update functions to update their data from the demo version of the actor.
*/
export function dDemo_setDemoData(globals: dGlobals, dtFrames: number, actor: fopAc_ac_c, flagMask: number,
morf: mDoExt_McaMorf | null = null, arcName: string | null = null) {
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ class Main {

private _loadTimeState(sceneDescId: string): void {
const timeStateKey = `TimeState/${sceneDescId}`;
const timeStateStr = this.saveManager.loadState(timeStateKey);
const timeStateStr = this.saveManager.loadStateFromLocation(timeStateKey, SaveStateLocation.SessionStorage);
if (!timeStateStr)
return;

Expand Down

0 comments on commit d63648a

Please sign in to comment.