@@ -58,10 +58,7 @@ break_irq:
58
58
sta interpreter_jump_fixup
59
59
; Jump to original handler
60
60
brkky_save = *+1
61
- jmp $FFFF
62
-
63
- new_brkky:
64
- .word break_irq
61
+ jmp break_irq
65
62
66
63
; Compile current buffer, called from the editor
67
64
.code
@@ -80,18 +77,15 @@ COMPILE_BUFFER:
80
77
; Parse
81
78
jsr parser_start
82
79
80
+ ; Save BRKKY vector and instal our own vector
81
+ jsr swap_brkky
82
+
83
83
ldx #$FE
84
84
bcs load_editor_stack ; On error, exit returning <> 0 (0xFEFE)
85
85
86
86
; Loops 2 times with X=$FE and X=$FF, exits with X=0
87
87
; C = clear and X = $FE on enter
88
88
sto_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
-
95
89
; Copy program pointer to the "NEWPTR" editor variable
96
90
lda <(prog_ptr - $FE ),x ; prog_ptr is ZP
97
91
sta fb_var_NEWPTR - $FE ,x
@@ -113,10 +107,10 @@ sto_loop:
113
107
114
108
; Check if need to run program, only if not relocated
115
109
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)
117
111
118
112
; Runs current parsed program
119
- run_program:
113
+
120
114
; Save interpreter position
121
115
; Current EDITOR.BAS does not need saving of stack
122
116
lda sptr
@@ -144,31 +138,31 @@ run_program:
144
138
lda #>__HEAP_RUN__
145
139
sta var_page
146
140
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
-
160
141
; Restore saved CPU stack
161
142
load_editor_stack:
162
143
pla
163
144
sta saved_cpu_stack
164
145
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
165
164
; X = result, copy to A also
166
165
txa
167
-
168
- ; Load all pointer to execute the editor
169
- ; Does not modify A/X
170
- load_editor:
171
166
rts
172
167
173
-
174
168
; vi:syntax=asm_ca65
0 commit comments