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
+66 -6

No files matched your search

+29 -2
View File
@@ -10,15 +10,42 @@
;; XXX currently does not preserve register Y, to be fixed!
;; 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.
;; Repeated calls after that read out the successive bytes of the line of input.
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
txa
pha
chrin_repeat:
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.
+35 -3
View File
@@ -10,7 +10,6 @@
chrout:
;; Crude implementation of character output
;; Save X and Y values
;; (Confirmed by writing a test program that X and Y
@@ -22,7 +21,27 @@ chrout:
tya
pha
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
@@ -392,7 +411,20 @@ chrout_done:
pla
tax
lda last_printed_character_ascii
clc ; indicate success
clc ; indicate success
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:
+2 -1
View File
@@ -8,6 +8,7 @@
;; CPU registers that has to be preserved (see [RG64]): .Y
;;
clrchn:
;; Handle IEC input device
@@ -24,7 +25,7 @@ clrchn:
;; Handle IEC output device
jsr unlsn
*
clrchn_reset:
clrchn_reset: ;; entry needed by CHRIN
;; Set input device number to keyboard
lda #$00
sta DFLTN