added IEC support to CHRIN and CHROUT

This commit is contained in:
FeralChild64 committed 2019-07-22 19:45:38 +02:00
1 parent 1bb195a9c4
commit 4980dff3bf
3 files changed
+63 -3

No files matched your search

+27
View File
@@ -13,12 +13,39 @@
;; Reads a byte of input, unless from keyboard. ;; Reads a byte of input, unless from keyboard.
;; 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:
;; First determine the device number
lda DFLTN
beq chrin_keyboard ; #$00 - keyboard
;; XXX add screen support
jsr iec_devnum_check
bcs chrin_done_fail ; not a supported device
chrin_iec:
jsr JACPTR
bcs chrin_done_fail
;; FALLTROUGH
chrin_done:
clc ; indicate success
rts
chrin_done_fail:
sec ; indicate failure
rts
chrin_keyboard:
;; Save X ;; Save X
txa txa
pha pha
chrin_repeat: chrin_repeat:
;; Do we have a line of input we are currently returning? ;; 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. ;; If so, return the next byte, and clear the flag when we reach the end.
+34 -2
View File
@@ -10,7 +10,6 @@
chrout: chrout:
;; Crude implementation of character output
;; Save X and Y values ;; Save X and Y values
;; (Confirmed by writing a test program that X and Y ;; (Confirmed by writing a test program that X and Y
@@ -22,7 +21,27 @@ chrout:
tya tya
pha pha
php php
sei
;; First determine the device number
lda DFLTO
cmp #$03 ; screen
beq chrout_screen
jsr iec_devnum_check
bcs chrout_done_fail ; not a supported device
chrout_iec:
lda last_printed_character_ascii
jsr JCIOUT
bcs chrout_done_fail
jmp chrout_done
chrout_screen:
;; Crude implementation of character output
sei ;; XXX why do we need to disable interrupts?
jsr hide_cursor_if_visible jsr hide_cursor_if_visible
@@ -395,6 +414,19 @@ chrout_done:
clc ; indicate success clc ; indicate success
rts rts
chrout_done_fail:
jsr show_cursor_if_enabled
plp
;; Restore X and Y, set carry to mark success on exit
pla
tay
pla
tax
sec ; indicate failure
rts
screen_grow_logical_line: screen_grow_logical_line:
ldy current_screen_y ldy current_screen_y
;; Don't grow line if it is already grown ;; Don't grow line if it is already grown
+2 -1
View File
@@ -8,6 +8,7 @@
;; CPU registers that has to be preserved (see [RG64]): .Y ;; CPU registers that has to be preserved (see [RG64]): .Y
;; ;;
clrchn: clrchn:
;; Handle IEC input device ;; Handle IEC input device
@@ -24,7 +25,7 @@ clrchn:
;; Handle IEC output device ;; Handle IEC output device
jsr unlsn jsr unlsn
* *
clrchn_reset: clrchn_reset: ;; entry needed by CHRIN
;; Set input device number to keyboard ;; Set input device number to keyboard
lda #$00 lda #$00
sta DFLTN sta DFLTN