work towards chrin returning a line of input
This commit is contained in:
1 parent
83c6a669d6
commit
028d82fc11
2 files changed
+83
-2
No files matched your search
@@ -28,12 +28,14 @@
|
|||||||
.alias last_key_matrix_position $C5
|
.alias last_key_matrix_position $C5
|
||||||
.alias keys_in_key_buffer $C6
|
.alias keys_in_key_buffer $C6
|
||||||
.alias reverse_video_flag $C7
|
.alias reverse_video_flag $C7
|
||||||
|
.alias end_of_input_line $C8
|
||||||
|
.alias start_of_keyboard_input $C9
|
||||||
.alias current_key_index_entry $CB
|
.alias current_key_index_entry $CB
|
||||||
.alias cursor_blink_disable $CC
|
.alias cursor_blink_disable $CC
|
||||||
.alias cursor_blink_countdown $CD
|
.alias cursor_blink_countdown $CD
|
||||||
.alias cursor_saved_character $CE
|
.alias cursor_saved_character $CE
|
||||||
.alias cursor_is_visible $CF
|
.alias cursor_is_visible $CF
|
||||||
.alias input_source $D0
|
.alias keyboard_input_ready $D0
|
||||||
.alias current_screen_line_ptr $D1
|
.alias current_screen_line_ptr $D1
|
||||||
.alias current_screen_x $D3
|
.alias current_screen_x $D3
|
||||||
.alias quote_mode_flag $D4
|
.alias quote_mode_flag $D4
|
||||||
|
|||||||
+80
-1
@@ -4,10 +4,89 @@
|
|||||||
;; If from keyboard, then it gets a whole line of input, and returns the first char.
|
;; 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.
|
;; Repeated calls after that read out the successive bytes of the line of input.
|
||||||
chrin:
|
chrin:
|
||||||
;; XXX - Not yet implemented, so infinite loop for now
|
|
||||||
|
;; 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.
|
||||||
|
;; XXX - Implement
|
||||||
|
|
||||||
|
;; Do we have a line of input waiting?
|
||||||
|
lda keyboard_input_ready
|
||||||
|
beq read_from_keyboard
|
||||||
|
|
||||||
|
;; Yes, we have input waiting at (start_of_keyboard_input)+keyboard_input_ready
|
||||||
|
;; When keyboard_input_ready = end_of_input_line, then we return a carriage return
|
||||||
|
;; and clear the flag
|
||||||
|
cmp end_of_input_line
|
||||||
|
bne not_end_of_input
|
||||||
|
|
||||||
|
;; Return carriage return and clear pending input flag
|
||||||
|
lda #$00
|
||||||
|
sta keyboard_input_ready
|
||||||
|
lda #$0d
|
||||||
|
sec
|
||||||
|
rts
|
||||||
|
|
||||||
|
not_end_of_input:
|
||||||
|
;; Return next byte of waiting input and advance index
|
||||||
|
tay
|
||||||
|
lda (start_of_keyboard_input),y
|
||||||
|
inc keyboard_input_ready
|
||||||
|
sec
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
read_from_keyboard:
|
||||||
|
|
||||||
|
;; Wait for a key
|
||||||
lda keys_in_key_buffer
|
lda keys_in_key_buffer
|
||||||
beq chrin
|
beq chrin
|
||||||
|
|
||||||
|
lda keyboard_buffer
|
||||||
|
cmp #$0d
|
||||||
|
bne not_enter
|
||||||
|
|
||||||
|
;; It was enter.
|
||||||
|
;; Note that we have a line of input to return, and return the first byte thereof
|
||||||
|
;; after computing and storing its length.
|
||||||
|
;; (Compute's Mapping the 64, p96)
|
||||||
|
|
||||||
|
;; Set pointer to line of input
|
||||||
|
lda current_screen_line_ptr+0
|
||||||
|
sta start_of_keyboard_input+0
|
||||||
|
lda current_screen_line_ptr+1
|
||||||
|
sta start_of_keyboard_input+1
|
||||||
|
|
||||||
|
;; Calculate length
|
||||||
|
jsr get_current_line_logical_length
|
||||||
|
tay
|
||||||
|
iny
|
||||||
|
* dey
|
||||||
|
beq empty_line
|
||||||
|
lda (current_screen_line_ptr),y
|
||||||
|
cmp #$20
|
||||||
|
bne -
|
||||||
|
sty keyboard_input_ready
|
||||||
|
;; Print the carriage return
|
||||||
|
lda #$0d
|
||||||
|
jsr chrout
|
||||||
|
;; Return first char of line
|
||||||
|
ldy #$00
|
||||||
|
lda (current_screen_line_ptr),y
|
||||||
|
inc $d020
|
||||||
|
sec
|
||||||
|
rts
|
||||||
|
|
||||||
|
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)
|
||||||
|
lda #$0d
|
||||||
|
jsr chrout
|
||||||
|
lda #$0d
|
||||||
|
sec
|
||||||
|
rts
|
||||||
|
|
||||||
|
not_enter:
|
||||||
;; Print character
|
;; Print character
|
||||||
lda keyboard_buffer
|
lda keyboard_buffer
|
||||||
jsr chrout
|
jsr chrout
|
||||||
|
|||||||
Reference in new issue
Block a user