]> git.sur5r.net Git - cc65/blobdiff - libsrc/atari/cputc.s
New module fileio-test.c
[cc65] / libsrc / atari / cputc.s
index 088e2bbf15d2e07fb8250d301a5b3bd9f0df78e8..ca3f920284bb6ae95cf8890d847729f770484b8b 100644 (file)
@@ -7,7 +7,9 @@
 
        .export         _cputcxy, _cputc
        .export         plot, cputdirect, putchar
-       .import         popa, _gotoxy
+       .import         popa, _gotoxy, mul40
+       .importzp       tmp4,ptr4
+       .import         _revflag
 
        .include        "atari.inc"
 
@@ -17,11 +19,6 @@ _cputcxy:
        jsr     _gotoxy         ; Set cursor, drop x
        pla                     ; Restore C
 
-.ifdef DIRECT_SCREEN
-
-       .importzp tmp4,ptr4
-       .import _revflag
-
 _cputc:
        cmp     #$0D            ; CR
        bne     L4
@@ -47,6 +44,18 @@ L4:  cmp     #$0A            ; LF
 
 cputdirect:                    ; accepts screen code
        jsr     putchar
+
+       ; update cursor position pointer
+       ldy     #0
+       lda     OLDCHR
+       sta     (OLDADR),y
+       inc     OLDADR
+       bne     L1
+       inc     OLDADR+1
+L1:    lda     (OLDADR),y
+       sta     OLDCHR
+       ora     _revflag
+       sta     (OLDADR),y
        
 ; advance cursor
        inc     COLCRS
@@ -68,24 +77,16 @@ plot:       ldy     COLCRS
        ldx     ROWCRS
        rts
 
+; turn off cursor, update screen, turn on cursor
 putchar:
        pha                     ; save char
-       lda     #0
-       sta     tmp4
+
+       ldy     #0
+       lda     OLDCHR
+       sta     (OLDADR),y
+
        lda     ROWCRS
-       asl     a
-       rol     tmp4
-       asl     a
-       rol     tmp4            ; row * 4
-       adc     ROWCRS
-       bcc     L1
-       inc     tmp4            ; row * 5
-L1:    asl     a
-       rol     tmp4            ; row * 10
-       asl     a
-       rol     tmp4
-       asl     a
-       rol     tmp4            ; row * 40
+       jsr     mul40
 L3:    clc
        adc     SAVMSC          ; add start of screen memory
        sta     ptr4
@@ -93,99 +94,24 @@ L3: clc
        adc     SAVMSC+1
        sta     ptr4+1
        pla                     ; get char again
+
+       sta     OLDCHR
+
        ora     _revflag
        ldy     COLCRS
        sta     (ptr4),y
+
+       ; update OLDADR (maybe ROWCRS and COLCRS were changed)
+       sty     tmp4
+       lda     ptr4
+       clc
+       adc     tmp4
+       sta     OLDADR
+       lda     ptr4+1
+       adc     #0
+       sta     OLDADR+1
        rts
 
        .rodata
 ataint:        .byte   64,0,32,96
 
-;****************************************************************
-.else  ;***** above DIRECT_SCREEN, below thru OS ***************
-;****************************************************************
-
-       .import         __do_oserror,cursor,__oserror
-
-
-; Plot a character - also used as internal function
-
-_cputc: cmp    #$0D            ; CR?
-       bne     L1
-       lda     #0
-       sta     COLCRS
-               beq     plot            ; Recalculate pointers
-
-; don't know whether this is needed. the compiler generates
-; already ATEOL chars for \n
-
-L1:    cmp     #$0A            ; LF?
-               bne     L2
-       lda     #ATEOL
-
-; Printable char of some sort
-
-L2:
-cputdirect:
-       pha
-       and     #$7f
-       cmp     #32             ; control char?
-       bcs     goon
-       lda     #$1b
-       jsr     putchar
-goon:  pla
-       jsr     putchar         ; Write the character to the screen
-
-plot:  ldy     COLCRS
-       ldx     ROWCRS
-       rts
-
-; Write one character to the screen without doing anything else, return X
-; position in Y
-
-putchar:
-.if 0
-       tax
-       lda     #>(retr-1)
-       pha
-       lda     #<(retr-1)
-       pha
-       lda     ICPTH
-       pha
-       lda     ICPTL
-       pha
-       lda     #0
-       sta     LOGCOL
-       txa
-       rts
-retr:
-.endif
-.if 1
-       pha
-       ldx     #0              ; iocb #0 (screen editor)
-       txa
-       sta     ICBLL,x
-       sta     ICBLH,x
-       sta     ICBAL,x
-       sta     ICBAH,x
-       lda     #PUTCHR
-       sta     ICCOM,x
-       lda     cursor
-       beq     putc7
-       lda     #0
-       beq     putc8
-putc7: lda     #1
-putc8: sta     CRSINH
-       pla
-       jsr     CIOV
-       bpl     putc9
-       jmp     __do_oserror    ; update system specific error code
-
-putc9: tya
-       ldx     #0
-       stx     __oserror
-       ldy     COLCRS
-.endif
-       rts
-
-.endif ; not defined DIRECT_SCREEN