Skip to content

Commit f3a00f1

Browse files
committed
simplify
1 parent 382e61f commit f3a00f1

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

interpreter.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,23 +94,17 @@ namespace microcode {
9494
this.loopIndex = 0
9595
}
9696

97-
private waitingOnTimer() {
98-
return this.wakeTime > 0
99-
}
100-
10197
kill() {
10298
const resource = this.getOutputResource()
10399
if (resource == OutputResource.LEDScreen) {
104100
led.stopAnimation()
105101
} else if (resource == OutputResource.Speaker) music.stopAllSounds()
106102
this.actionRunning = false
107103
// give the background fiber chance to finish unless it is waiting
108-
// while (!this.waitingOnTimer() && this.backgroundActive) {
104+
// while (this.wakeTime == 0 && this.backgroundActive) {
109105
// console.log(`killing rule ${this.index} ${this.wakeTime}...`)
110106
// basic.pause(0)
111107
// }
112-
console.log(`DONE rule ${this.index}`)
113-
this.reset()
114108
}
115109

116110
public matchWhen(tid: number, filter: number = undefined): boolean {
@@ -172,7 +166,7 @@ namespace microcode {
172166
// make sure we have something to do
173167
if (this.rule.actuators.length == 0) return
174168
// prevent re-entrancy
175-
if (this.actionRunning) return
169+
if (this.ok()) return
176170
this.actionRunning = true
177171
control.runInBackground(() => {
178172
this.backgroundActive = true
@@ -226,14 +220,13 @@ namespace microcode {
226220
}
227221

228222
private checkForLoopFinish() {
229-
if (!this.actionRunning) return
230223
control.waitMicros(ANTI_FREEZE_DELAY * 1000)
231224
const actionKind = this.getActionKind()
232225
if (
233226
actionKind === ActionKind.Instant ||
234227
getTid(this.rule.actuators[0]) == Tid.TID_ACTUATOR_SHOW_NUMBER
235228
) {
236-
this.reset()
229+
this.actionRunning = false
237230
return
238231
}
239232
if (!this.atLoop()) this.modifierIndex++
@@ -251,7 +244,7 @@ namespace microcode {
251244
) as number
252245
this.loopIndex++
253246
if (this.loopIndex >= loopBound) {
254-
this.reset()
247+
this.actionRunning = false
255248
} else {
256249
this.modifierIndex = 0
257250
}
@@ -260,7 +253,7 @@ namespace microcode {
260253
// we move to the next tile in sequence
261254
}
262255
} else {
263-
this.reset()
256+
this.actionRunning = false
264257
}
265258
}
266259

0 commit comments

Comments
 (0)