From af1f5b079d885bb5cbf7898ab7e18c47056c664a Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 12 Feb 2020 20:37:10 +0100 Subject: [PATCH] fixed screen code to PETSCII conversion --- .../screen/chrout_screen_jumptable_codes.s | 6 +- c64/kernal/screen/screen_code_to_petscii.s | 79 +++++++++++++------ 2 files changed, 60 insertions(+), 25 deletions(-) diff --git a/c64/kernal/screen/chrout_screen_jumptable_codes.s b/c64/kernal/screen/chrout_screen_jumptable_codes.s index 303c48c4..66e56e74 100644 --- a/c64/kernal/screen/chrout_screen_jumptable_codes.s +++ b/c64/kernal/screen/chrout_screen_jumptable_codes.s @@ -94,6 +94,8 @@ chrout_screen_jumptable_hi: #else +__before_chrout_screen_jumptable: + .if (mod(*, $2) == 1) { brk } // align code so that vector never crosses page boundary chrout_screen_jumptable: @@ -121,6 +123,8 @@ chrout_screen_jumptable: .word chrout_screen_DEL .word chrout_screen_RETURN -.if (mod(*, $2) == 0) { brk } // make sure routine size is always the same, needed by build system + // Make sure routine size is always the same - build system limitation + +.if (__before_chrout_screen_jumptable == chrout_screen_jumptable) { brk } #endif diff --git a/c64/kernal/screen/screen_code_to_petscii.s b/c64/kernal/screen/screen_code_to_petscii.s index 4b0e00ad..1a66bff6 100644 --- a/c64/kernal/screen/screen_code_to_petscii.s +++ b/c64/kernal/screen/screen_code_to_petscii.s @@ -3,42 +3,73 @@ // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE +// +// Screen code to PETSCII conversion - see: +// +// - https://www.lemon64.com/forum/viewtopic.php?t=66362 +// - https://sta.c64.org/cbm64scrtopetext.html +// -// XXX - conversion should depend on QTSW too + +// XXX - part below might depend on QTSW too screen_code_to_petscii: - cmp #$1B - bcc s2p_adc_40 - -s2p_not_alpha: + + cmp #$20 + bcc s2p_adc_40 // $00-$1F -> $40-$5F + cmp #$40 - bcc s2p_end + bcc s2p_end // $20-$3F -> $20-$3F - // FALLTROUGH - -s2p_not_punctuation: - cmp #$5B - bcs s2p_not_shifted - - // carry already clear here - adc #$80 - - rts - -s2p_not_shifted: + cmp #$60 + bcc s2p_adc_80 // $40-$5F -> $C0-$DF cmp #$80 - bcs s2p_end // not vendor + bcc s2p_adc_40 // $60-$7F -> $A0-$BF - // $60-$7F -> $A0-$BF + // Here we have to check for quote mode + + bit QTSW + bmi screen_code_to_petscii_quote + + // Not quote mode - continue + + cmp #$A0 + bcc s2p_adc_C0 // $80-$9F -> $40-$5F + + cmp #$C0 + bcc s2p_adc_80 // $A0-$BF -> $20-$3F + + cmp #$E0 + bcc s2p_end // $C0-$DF -> $C0-$DF + + clc + bcc s2p_adc_C0 // $E0-$FF -> $A0-$BF s2p_adc_40: - clc - adc #$40 - - // FALLTROUGH + adc #$40 // Carry already clear s2p_end: + + rts + +s2p_adc_80: + + adc #$80 // Carry already clear + rts + +screen_code_to_petscii_quote: + + cmp #$C0 + bcc s2p_adc_80 // $80-$BF -> $00-$3F + + clc + + // FALLTROUGH $C0-$FF -> $80-$BF + +s2p_adc_C0: + + adc #$C0 // Carry already clear rts