Skip to content

Commit

Permalink
[BASIC] Prevent OLD command from hanging when run without a program i…
Browse files Browse the repository at this point in the history
…n memory (X16Community#237)

Should also prevent a needless freeze when loading a non-BASIC program into low ram by mistake

* Initialize a couple of memory locations to zero to prevent OLD from hanging

* Remove changes as they do not work on reset

* Ensore OLD function exits if index rolls over.
This is to solve the issue where OLD would hang if there is no program
present in memory.
If index rollover is detected, 0's will be written to the two first
bytes of txttab ($0801) to indicate that there is no BASIC program
in memory.

* Removing commented abandoned approach

* Clarify comments, save a byte

---------

Co-authored-by: mooinglemur <[email protected]>
  • Loading branch information
JimmyDansbo and mooinglemur authored Jan 14, 2024
1 parent 37bf417 commit 0585e47
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion basic/code1.s
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,13 @@ chead ldy #1
beq lnkrts
ldy #4
czloop iny
lda (index),y
bne :+ ; Continue as normal as long as Y has not rolled over to 0
tya ; If Y has rolled over to 0, we have encountered a line > 255 bytes.
sta (index),y ; store 0's in the next two bytes
iny ; to indicate the end of the BASIC program
sta (index),y
rts
: lda (index),y
bne czloop
iny
tya
Expand Down

0 comments on commit 0585e47

Please sign in to comment.