Skip to content

Commit bb66d5b

Browse files
committed
fix up switch page logic
1 parent 6f5a36a commit bb66d5b

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

interpreter.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,12 @@ namespace microcode {
291291
return undefined
292292
}
293293

294-
public runInstant() {
294+
public runInstant(): boolean {
295295
const actuator = this.rule.actuators[0]
296296
const param = this.getParamInstant()
297-
this.interp.runAction(this.index, actuator, param)
297+
const ok = this.interp.runAction(this.index, actuator, param)
298298
this.kill()
299+
return ok
299300
}
300301

301302
private runAction() {
@@ -520,9 +521,9 @@ namespace microcode {
520521
} as StateUpdateEvent)
521522
}
522523

523-
public runAction(ruleIndex: number, action: Tile, param: any) {
524+
public runAction(ruleIndex: number, action: Tile, param: any): boolean {
524525
switch (action) {
525-
case Tid.TID_ACTUATOR_SWITCH_PAGE:
526+
case Tid.TID_ACTUATOR_SWITCH_PAGE: {
526527
// no switch if no param
527528
if (param) {
528529
// when switching, drop any outstanding events
@@ -531,17 +532,21 @@ namespace microcode {
531532
kind: MicroCodeEventKind.SwitchPage,
532533
index: param,
533534
} as SwitchPageEvent)
535+
return true
534536
}
535-
return
537+
return false
538+
}
536539
case Tid.TID_ACTUATOR_CUP_X_ASSIGN:
537540
case Tid.TID_ACTUATOR_CUP_Y_ASSIGN:
538-
case Tid.TID_ACTUATOR_CUP_Z_ASSIGN:
541+
case Tid.TID_ACTUATOR_CUP_Z_ASSIGN: {
539542
const varName = getParam(action)
540543
this.updateState(ruleIndex, varName, param)
541-
return
544+
return true
545+
}
542546
default:
543547
this.host.execute(action as ActionTid, param)
544548
}
549+
return true
545550
}
546551

547552
private updateState(ruleIndex: number, varName: string, v: number) {
@@ -610,8 +615,7 @@ namespace microcode {
610615
rc => rc.getOutputResource() == OutputResource.PageCounter
611616
)
612617
if (switchPage) {
613-
switchPage.runInstant()
614-
return // others don't get chance to run
618+
if (switchPage.runInstant()) return // others don't get chance to run
615619
}
616620

617621
const takesTime = live.filter(

0 commit comments

Comments
 (0)