From 9656dde9e3e6a3ab9fd178d78b8fd115b875829d Mon Sep 17 00:00:00 2001 From: uz Date: Sun, 7 Mar 2010 13:37:58 +0000 Subject: [PATCH] Fix scrolling (again). The old code switched off scrolling completely, as a consequence it didn't work when write(FILENO_STDOUT, ...) was used. So we will have to disable scrolling on a per character basis in cputc. git-svn-id: svn://svn.cc65.org/cc65/trunk@4617 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- libsrc/c128/cputc.s | 39 +++++++++++++++++++++------------------ libsrc/c128/videomode.s | 3 +-- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/libsrc/c128/cputc.s b/libsrc/c128/cputc.s index 5442e9f57..d69170bce 100644 --- a/libsrc/c128/cputc.s +++ b/libsrc/c128/cputc.s @@ -7,15 +7,12 @@ ; .export _cputcxy, _cputc, cputdirect, putchar - .export newline, plot - .constructor initcputc - .destructor donecputc + .export newline, plot .import popa, _gotoxy .import PLOT .include "c128.inc" -cputdirect = PRINT newline = NEWLINE ;-------------------------------------------------------------------------- @@ -40,15 +37,26 @@ _cputc: cmp #$0A ; CR? ; Printable char of some sort L2: cmp #' ' - bcc L4 ; Other control char + bcc cputdirect ; Other control char tay bmi L5 cmp #$60 bcc L3 and #$DF - bne L4 ; Branch always + bne cputdirect ; Branch always L3: and #$3F -L4: jmp PRINT ; Output character + +; Output one character to the screen. We will disable scrolling while doing so + +cputdirect: + ldx SCROLL + stx ScrollSave ; Save scroll flag + ldx #$C0 + stx SCROLL ; Disable scrolling + jsr PRINT ; Call kernal entry point + ldx ScrollSave + stx SCROLL ; Restore old scroll flag + rts ; Handle character if high bit set @@ -56,9 +64,9 @@ L5: and #$7F cmp #$7E ; PI? bne L6 lda #$5E ; Load screen code for PI - bne L4 + bne cputdirect L6: ora #$40 - bne L4 ; Branch always + bne cputdirect ; Branch always ; Carriage return @@ -78,14 +86,9 @@ plot: ldy CURS_X putchar = $CC2F ;-------------------------------------------------------------------------- -; Module constructor/destructor. Don't move the constructor into the INIT -; segment, because it shares most of the code with the destructor. +; Data +.bss + +ScrollSave: .res 1 ; Save location for scroll byte -initcputc: - lda #$C0 - .byte $2C -donecputc: - lda #$00 - sta SCROLL - rts diff --git a/libsrc/c128/videomode.s b/libsrc/c128/videomode.s index fd37b7b6a..d07df5160 100644 --- a/libsrc/c128/videomode.s +++ b/libsrc/c128/videomode.s @@ -22,8 +22,7 @@ jsr SWAPPER ; Toggle the mode lda #14 jsr BSOUT ; Switch to lower case chars - lda #$C0 - sta SCROLL ; Disable scrolling + pla ; Get old mode into A ; Done, old mode is in A