fix preserving X register in CHRIN
This commit is contained in:
1 parent
836f19e834
commit
374815ed68
1 file changed
+15
-9
+15
-9
@@ -4,9 +4,11 @@
|
||||
;; If from keyboard, then it gets a whole line of input, and returns the first char.
|
||||
;; Repeated calls after that read out the successive bytes of the line of input.
|
||||
chrin:
|
||||
;; XXX - Don't corrupt X
|
||||
stx last_printed_character_ascii
|
||||
|
||||
;; Save X
|
||||
txa
|
||||
pha
|
||||
|
||||
chrin_repeat:
|
||||
;; Do we have a line of input we are currently returning?
|
||||
;; If so, return the next byte, and clear the flag when we reach the end.
|
||||
|
||||
@@ -23,7 +25,8 @@ chrin:
|
||||
;; Return carriage return and clear pending input flag
|
||||
lda #$00
|
||||
sta keyboard_input_ready
|
||||
ldx last_printed_character_ascii
|
||||
pla
|
||||
tax
|
||||
lda #$0d
|
||||
clc
|
||||
rts
|
||||
@@ -31,7 +34,8 @@ chrin:
|
||||
not_end_of_input:
|
||||
;; Return next byte of waiting input and advance index
|
||||
tay
|
||||
ldx last_printed_character_ascii
|
||||
pla
|
||||
tax
|
||||
lda (start_of_keyboard_input),y
|
||||
inc keyboard_input_ready
|
||||
clc
|
||||
@@ -42,7 +46,7 @@ read_from_keyboard:
|
||||
|
||||
;; Wait for a key
|
||||
lda keys_in_key_buffer
|
||||
beq chrin
|
||||
beq chrin_repeat
|
||||
|
||||
lda keyboard_buffer
|
||||
cmp #$0d
|
||||
@@ -78,7 +82,8 @@ read_from_keyboard:
|
||||
sta keyboard_input_ready
|
||||
;; Return first char of line
|
||||
ldy #$00
|
||||
ldx last_printed_character_ascii
|
||||
pla
|
||||
tax
|
||||
lda (start_of_keyboard_input),y
|
||||
clc
|
||||
rts
|
||||
@@ -87,7 +92,8 @@ empty_line:
|
||||
;; For an empty line, just return the carriage return
|
||||
;; (and don't forget to actually print the carriage return, so that
|
||||
;; the cursor advances and screen scrolls as required)
|
||||
ldx last_printed_character_ascii
|
||||
pla
|
||||
tax
|
||||
lda #$0d
|
||||
clc
|
||||
rts
|
||||
@@ -100,7 +106,7 @@ not_enter:
|
||||
jsr pop_keyboard_buffer
|
||||
|
||||
;; Keep looking for input from keyboard until carriage return
|
||||
jmp chrin
|
||||
jmp chrin_repeat
|
||||
|
||||
pop_keyboard_buffer:
|
||||
;; Pop key out of keyboard buffer
|
||||
|
||||
Reference in new issue
Block a user