Skip to content

Commit 5e0a429

Browse files
committed
stop properly
1 parent 8ccbc08 commit 5e0a429

2 files changed

Lines changed: 15 additions & 14 deletions

File tree

editor.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,7 @@ namespace microcode {
283283
x: Screen.LEFT_EDGE + 52,
284284
y: 8,
285285
onClick: () => {
286-
if (isProgramRunning()) {
287-
stopProgram()
288-
this.runBtn.buildSprite(icondb.run)
289-
this.stopBtn.buildSprite(icondb.stopDisabled)
290-
this.dirty = true
291-
basic.showIcon(IconNames.No)
292-
control.waitMicros(200000)
293-
basic.clearScreen()
294-
}
286+
if (isProgramRunning()) this.stopProgram()
295287
},
296288
})
297289
this.pageBtn = new Button({
@@ -302,7 +294,7 @@ namespace microcode {
302294
y: 8,
303295
onClick: () => this.pickPage(),
304296
})
305-
stopProgram()
297+
this.stopProgram()
306298
const buf = this.app.load(SAVESLOT_AUTO)
307299
if (!buf) {
308300
// onboarding experience
@@ -317,6 +309,15 @@ namespace microcode {
317309
this.configureP1Keys()
318310
}
319311

312+
public stopProgram() {
313+
stopProgram()
314+
this.runBtn.buildSprite(icondb.run)
315+
this.stopBtn.buildSprite(icondb.stopDisabled)
316+
this.dirty = true
317+
basic.showIcon(IconNames.No, 100)
318+
basic.clearScreen()
319+
}
320+
320321
private configureP1Keys() {
321322
const forward = () => {
322323
this.cursor.click()
@@ -605,7 +606,7 @@ namespace microcode {
605606
}
606607

607608
public moveRuleAt(index: number, up: boolean) {
608-
stopProgram()
609+
this.editor.stopProgram()
609610
const delta = up ? -1 : 1
610611
const deleted = this.pagedef.deleteRuleAt(index)
611612
this.pagedef.insertRuleAt(index + delta, deleted)
@@ -618,14 +619,14 @@ namespace microcode {
618619
}
619620

620621
public deleteRuleAt(index: number) {
621-
stopProgram()
622+
this.editor.stopProgram()
622623
this.pagedef.deleteRuleAt(index)
623624
this.ruleEditors.splice(index, 1)
624625
this.reassignIndices()
625626
}
626627

627628
public insertRuleAt(index: number) {
628-
stopProgram()
629+
this.editor.stopProgram()
629630
const newRule = this.pagedef.insertRuleAt(index, undefined)
630631
if (newRule) {
631632
this.ruleEditors.insertAt(

ruleeditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ namespace microcode {
213213
}
214214

215215
private editTile(name: string, index: number) {
216-
stopProgram()
216+
this.editor.stopProgram()
217217
const ruleTiles = this.ruledef.getRuleRep()[name]
218218
const tileUpdated = (tile: Tile) => {
219219
this.editor.programChanged = true

0 commit comments

Comments
 (0)