partial implementation of CHRIN
This commit is contained in:
1 parent
f62a541d83
commit
3067744304
1 file changed
+18
-10
+18
-10
@@ -23,7 +23,7 @@ chrin:
|
|||||||
lda #$00
|
lda #$00
|
||||||
sta keyboard_input_ready
|
sta keyboard_input_ready
|
||||||
lda #$0d
|
lda #$0d
|
||||||
sec
|
clc
|
||||||
rts
|
rts
|
||||||
|
|
||||||
not_end_of_input:
|
not_end_of_input:
|
||||||
@@ -31,7 +31,7 @@ not_end_of_input:
|
|||||||
tay
|
tay
|
||||||
lda (start_of_keyboard_input),y
|
lda (start_of_keyboard_input),y
|
||||||
inc keyboard_input_ready
|
inc keyboard_input_ready
|
||||||
sec
|
clc
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
@@ -45,6 +45,8 @@ read_from_keyboard:
|
|||||||
cmp #$0d
|
cmp #$0d
|
||||||
bne not_enter
|
bne not_enter
|
||||||
|
|
||||||
|
jsr pop_keyboard_buffer
|
||||||
|
|
||||||
;; It was enter.
|
;; It was enter.
|
||||||
;; Note that we have a line of input to return, and return the first byte thereof
|
;; Note that we have a line of input to return, and return the first byte thereof
|
||||||
;; after computing and storing its length.
|
;; after computing and storing its length.
|
||||||
@@ -64,16 +66,17 @@ read_from_keyboard:
|
|||||||
beq empty_line
|
beq empty_line
|
||||||
lda (current_screen_line_ptr),y
|
lda (current_screen_line_ptr),y
|
||||||
cmp #$20
|
cmp #$20
|
||||||
bne -
|
beq -
|
||||||
sty keyboard_input_ready
|
sty end_of_input_line
|
||||||
|
lda #$01
|
||||||
|
sta keyboard_input_ready
|
||||||
;; Print the carriage return
|
;; Print the carriage return
|
||||||
lda #$0d
|
lda #$0d
|
||||||
jsr chrout
|
jsr chrout
|
||||||
;; Return first char of line
|
;; Return first char of line
|
||||||
ldy #$00
|
ldy #$00
|
||||||
lda (current_screen_line_ptr),y
|
lda (start_of_keyboard_input),y
|
||||||
inc $d020
|
clc
|
||||||
sec
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
empty_line:
|
empty_line:
|
||||||
@@ -83,7 +86,7 @@ empty_line:
|
|||||||
lda #$0d
|
lda #$0d
|
||||||
jsr chrout
|
jsr chrout
|
||||||
lda #$0d
|
lda #$0d
|
||||||
sec
|
clc
|
||||||
rts
|
rts
|
||||||
|
|
||||||
not_enter:
|
not_enter:
|
||||||
@@ -91,6 +94,12 @@ not_enter:
|
|||||||
lda keyboard_buffer
|
lda keyboard_buffer
|
||||||
jsr chrout
|
jsr chrout
|
||||||
|
|
||||||
|
jsr pop_keyboard_buffer
|
||||||
|
|
||||||
|
;; Keep looking for input from keyboard until carriage return
|
||||||
|
jmp chrin
|
||||||
|
|
||||||
|
pop_keyboard_buffer:
|
||||||
;; Pop key out of keyboard buffer
|
;; Pop key out of keyboard buffer
|
||||||
;; Disable interrupts while reading from keyboard buffer
|
;; Disable interrupts while reading from keyboard buffer
|
||||||
;; so that no race conditions can occur
|
;; so that no race conditions can occur
|
||||||
@@ -106,6 +115,5 @@ not_enter:
|
|||||||
dec keys_in_key_buffer
|
dec keys_in_key_buffer
|
||||||
cli
|
cli
|
||||||
|
|
||||||
lda #$00
|
|
||||||
clc
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
Reference in new issue
Block a user