@@ -58,10 +58,7 @@ break_irq:
5858 sta interpreter_jump_fixup
5959 ; Jump to original handler
6060brkky_save = *+1
61- jmp $FFFF
62-
63- new_brkky:
64- .word break_irq
61+ jmp break_irq
6562
6663 ; Compile current buffer, called from the editor
6764 .code
@@ -80,18 +77,15 @@ COMPILE_BUFFER:
8077 ; Parse
8178 jsr parser_start
8279
80+ ; Save BRKKY vector and instal our own vector
81+ jsr swap_brkky
82+
8383 ldx #$FE
8484 bcs load_editor_stack ; On error, exit returning <> 0 (0xFEFE)
8585
8686 ; Loops 2 times with X=$FE and X=$FF, exits with X=0
8787 ; C = clear and X = $FE on enter
8888sto_loop:
89- ; Also save BRKKY vector and instal our own vector
90- lda BRKKY - $FE , x
91- sta brkky_save - $FE , x
92- lda new_brkky - $FE , x
93- sta BRKKY - $FE , x
94-
9589 ; Copy program pointer to the "NEWPTR" editor variable
9690 lda <(prog_ptr - $FE ),x ; prog_ptr is ZP
9791 sta fb_var_NEWPTR - $FE ,x
@@ -113,10 +107,10 @@ sto_loop:
113107
114108 ; Check if need to run program, only if not relocated
115109 lda reloc_addr + 1
116- bne restore_break ; Exit returning X = 0 (from loop above)
110+ bne load_editor_stack ; Exit returning X = 0 (from loop above)
117111
118112 ; Runs current parsed program
119- run_program:
113+
120114 ; Save interpreter position
121115 ; Current EDITOR.BAS does not need saving of stack
122116 lda sptr
@@ -144,31 +138,31 @@ run_program:
144138 lda #>__HEAP_RUN__
145139 sta var_page
146140
147- restore_break:
148- ; Restore original BREAK key handler and sets X = 0
149- ldx #2
150- rbreak_loop:
151- lda brkky_save-1 , x
152- sta BRKKY-1 , x
153- dex
154- bne rbreak_loop
155-
156- ; Restore JUMP on interpreter
157- lda #$4C ; JMP abs
158- sta interpreter_jump_fixup
159-
160141 ; Restore saved CPU stack
161142load_editor_stack:
162143 pla
163144 sta saved_cpu_stack
164145
146+ ; Restore original BREAK key handler
147+ swap_brkky:
148+ ldy #2
149+ swap_loop:
150+ lda brkky_save-1 , y
151+ pha
152+ lda BRKKY-1 , y
153+ sta brkky_save-1 , y
154+ pla
155+ sta BRKKY-1 , y
156+ dey
157+ bne swap_loop
158+
159+ ; Restore JUMP on interpreter
160+ lda #$4C ; JMP abs
161+ sta interpreter_jump_fixup
162+
163+ ; Returns to the editor
165164 ; X = result, copy to A also
166165 txa
167-
168- ; Load all pointer to execute the editor
169- ; Does not modify A/X
170- load_editor:
171166 rts
172167
173-
174168; vi:syntax=asm_ca65
0 commit comments