File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,6 +61,15 @@ namespace microcode {
6161 public popScene ( ) {
6262 this . sceneManager . popScene ( )
6363 }
64+
65+ public runFromEditor ( ) {
66+ const topIndex = this . sceneManager . scenes . length - 1
67+ const topScene = this . sceneManager . scenes [ topIndex ]
68+ if ( topScene instanceof Editor ) {
69+ const editor : Editor = topScene
70+ editor . runProgram ( )
71+ }
72+ }
6473 }
6574
6675 let theInterpreter : Interpreter = undefined
Original file line number Diff line number Diff line change @@ -267,12 +267,7 @@ namespace microcode {
267267 x : Screen . LEFT_EDGE + 32 ,
268268 y : 8 ,
269269 onClick : ( ) => {
270- if ( ! isProgramRunning ( ) ) {
271- runProgram ( this . progdef )
272- this . runBtn . buildSprite ( icondb . runDisabled )
273- this . stopBtn . buildSprite ( icondb . car_stop )
274- this . dirty = true
275- }
270+ this . runProgram ( )
276271 } ,
277272 } )
278273 this . stopBtn = new Button ( {
@@ -309,6 +304,15 @@ namespace microcode {
309304 this . configureP1Keys ( )
310305 }
311306
307+ public runProgram ( ) {
308+ if ( ! isProgramRunning ( ) ) {
309+ runProgram ( this . progdef )
310+ this . runBtn . buildSprite ( icondb . runDisabled )
311+ this . stopBtn . buildSprite ( icondb . car_stop )
312+ this . dirty = true
313+ }
314+ }
315+
312316 public stopProgram ( ) {
313317 if ( isProgramRunning ( ) ) {
314318 stopProgram ( )
Original file line number Diff line number Diff line change @@ -77,14 +77,20 @@ namespace microcode {
7777 buttons . forEach ( b => {
7878 control . onEvent ( b , DAL . DEVICE_EVT_ANY , ( ) => {
7979 const ev = control . eventValue ( )
80- const tid =
81- ev == DAL . DEVICE_BUTTON_EVT_DOWN
82- ? Tid . TID_SENSOR_PRESS
83- : ev == DAL . DEVICE_BUTTON_EVT_UP
84- ? Tid . TID_SENSOR_RELEASE
85- : undefined
86- const filter = matchPressReleaseTable [ b ]
87- this . _handler ( tid , filter )
80+ if ( isProgramRunning ( ) ) {
81+ const tid =
82+ ev == DAL . DEVICE_BUTTON_EVT_DOWN
83+ ? Tid . TID_SENSOR_PRESS
84+ : ev == DAL . DEVICE_BUTTON_EVT_UP
85+ ? Tid . TID_SENSOR_RELEASE
86+ : undefined
87+ const filter = matchPressReleaseTable [ b ]
88+ this . _handler ( tid , filter )
89+ } else {
90+ // start up the program using the editor
91+ if ( ev == DAL . DEVICE_BUTTON_EVT_DOWN )
92+ app . runFromEditor ( )
93+ }
8894 } )
8995 } )
9096
You can’t perform that action at this time.
0 commit comments