diff --git a/c64/basic/cmd_load.s b/c64/basic/cmd_load.s index 4090be5b..335270b3 100644 --- a/c64/basic/cmd_load.s +++ b/c64/basic/cmd_load.s @@ -35,6 +35,7 @@ cmd_load: ;; Now relink the loaded program, as we cannot trust the line ;; links supplied. For example, the VICE virtual drive emulation ;; always supplies $0101 as the address of the next line. + jsr basic_relink_program ;; After LOADing, we either start the program from the beginning, ;; or go back to the READY prompt if LOAD was called from direct mode. @@ -47,3 +48,68 @@ cmd_load: ;; Try to keep executing jmp basic_execute_statement + + +basic_relink_program: + + ;; Start by getting pointer to the first line + lda basic_start_of_text_ptr+0 + sta basic_current_line_ptr+0 + lda basic_start_of_text_ptr+1 + sta basic_current_line_ptr+1 + +basic_relink_loop: + ;; Is the pointer to the end of the program + ldy #1 + ldx #