diff --git a/c64/kernal/chrout_real.s b/c64/kernal/chrout_screen.s similarity index 92% rename from c64/kernal/chrout_real.s rename to c64/kernal/chrout_screen.s index f30d2e16..898f1b53 100644 --- a/c64/kernal/chrout_real.s +++ b/c64/kernal/chrout_screen.s @@ -1,86 +1,9 @@ // -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmer's Reference Guide - page 278/279 -// - [CM64] Compute's Mapping the Commodore 64 - page 228 -// -// CPU registers that has to be preserved (see [RG64]): .Y +// CHROUT routine - screen support // -chrout_real: - - sta SCHAR - - // Save X and Y values - // (Confirmed by writing a test program that X and Y - // don't get modified, in agreement with C64 PRG's - // description of CHROUT) - txa - pha - tya - pha - php - - // Determine the device number - lda DFLTO - - cmp #$03 // screen - beq chrout_screen - - jsr iec_check_devnum - bcs chrout_done_unknown_device // not a supported device - -chrout_iec: - - lda SCHAR - jsr JCIOUT - bcc chrout_done - - // FALLTROUGH - -chrout_done_fail: - jsr show_cursor_if_enabled - - plp - - // Restore X and Y - pla - tay - pla - tax - sec // indicate failure - rts - -chrout_done_unknown_device: - jsr show_cursor_if_enabled - - plp - - // Restore X and Y - pla - tay - pla - tax - - // End wioth error - jmp lvs_device_not_found_error - -chrout_done: - jsr show_cursor_if_enabled - - plp - - // Restore X and Y - pla - tay - pla - tax - lda SCHAR - clc // indicate success - rts - chrout_screen: // Crude implementation of character output diff --git a/c64/kernal/f1ca.chrout.jmp.s b/c64/kernal/f1ca.chrout.jmp.s deleted file mode 100644 index 6a1993c3..00000000 --- a/c64/kernal/f1ca.chrout.jmp.s +++ /dev/null @@ -1,6 +0,0 @@ - -// Our implementation is longer than the original one, -// placing it here would cause a collision with CHKIN - -CHROUT: - jmp chrout_real diff --git a/c64/kernal/f1ca.chrout.s b/c64/kernal/f1ca.chrout.s new file mode 100644 index 00000000..e13da0f8 --- /dev/null +++ b/c64/kernal/f1ca.chrout.s @@ -0,0 +1,82 @@ + +// +// Official Kernal routine, described in: +// +// - [RG64] C64 Programmer's Reference Guide - page 278/279 +// - [CM64] Compute's Mapping the Commodore 64 - page 228 +// +// CPU registers that has to be preserved (see [RG64]): .Y +// + +CHROUT: + + sta SCHAR + + // Save X and Y values + // (Confirmed by writing a test program that X and Y + // don't get modified, in agreement with C64 PRG's + // description of CHROUT) + txa + pha + tya + pha + php + + // Determine the device number + lda DFLTO + + cmp #$03 // screen + bne !+ + jmp chrout_screen +!: + jsr iec_check_devnum + bcs chrout_done_unknown_device // not a supported device + +chrout_iec: + + lda SCHAR + jsr JCIOUT + bcc chrout_done + + // FALLTROUGH + +chrout_done_fail: + jsr show_cursor_if_enabled + + plp + + // Restore X and Y + pla + tay + pla + tax + sec // indicate failure + rts + +chrout_done_unknown_device: + jsr show_cursor_if_enabled + + plp + + // Restore X and Y + pla + tay + pla + tax + + // End wioth error + jmp lvs_device_not_found_error + +chrout_done: + jsr show_cursor_if_enabled + + plp + + // Restore X and Y + pla + tay + pla + tax + lda SCHAR + clc // indicate success + rts