diff --git a/c64/kernal/chrin.s b/c64/kernal/chrin.s index 4121bdc4..8bd4850b 100644 --- a/c64/kernal/chrin.s +++ b/c64/kernal/chrin.s @@ -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. diff --git a/c64/kernal/chrout.s b/c64/kernal/chrout.s index 926a9391..b7266a66 100644 --- a/c64/kernal/chrout.s +++ b/c64/kernal/chrout.s @@ -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: diff --git a/c64/kernal/clrchn.s b/c64/kernal/clrchn.s index d0cd0243..22b4c9e0 100644 --- a/c64/kernal/clrchn.s +++ b/c64/kernal/clrchn.s @@ -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