X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libsrc%2Fapple2%2Fcputc.s;h=f3adc2f5478a7fc31f46375fdf1ec9e03e878675;hb=6aee0eff045e059de9da2a63c7476c22f9d00d53;hp=f8ea39dff165851c7a41b8938b72e70236e1f345;hpb=53dd513176425872128ef26031d00952ef7a0628;p=cc65 diff --git a/libsrc/apple2/cputc.s b/libsrc/apple2/cputc.s index f8ea39dff..f3adc2f54 100644 --- a/libsrc/apple2/cputc.s +++ b/libsrc/apple2/cputc.s @@ -1,85 +1,94 @@ ; ; Ullrich von Bassewitz, 06.08.1998 ; -; void cputcxy (unsigned char x, unsigned char y, char c); -; void cputc (char c); +; void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c); +; void __fastcall__ cputc (char c); ; - .export _cputcxy, _cputc - .export _gotoxy, cputdirect - .export newline, putchar + .ifdef __APPLE2ENH__ + .constructor initconio, 17 + .endif + .export _cputcxy, _cputc + .export cputdirect, newline, putchar + .import popa, _gotoxy, VTABZ - .import popa + .include "apple2.inc" - .include "apple2.inc" + .segment "INIT" + + .ifdef __APPLE2ENH__ +initconio: + sta SETALTCHAR ; Switch in alternate charset + bit LORES ; Limit SET80COL-HISCR to text + rts + .endif + + .code ; Plot a character - also used as internal function _cputcxy: - pha ; Save C - jsr popa ; Get Y - jsr _gotoxy - pla ; Restore C + pha ; Save C + jsr popa ; Get Y + jsr _gotoxy + pla ; Restore C _cputc: - cmp #$0D ; Test for \r = carrage return - bne L1 - lda #$00 ; Goto left edge of screen - sta CH - rts ; That's all we do -L1: - cmp #$0A ; Test for \n = line feed - beq newline + cmp #$0D ; Test for \r = carrage return + beq left + cmp #$0A ; Test for \n = line feed + beq newline + ora #$80 ; Turn on high bit + .ifndef __APPLE2ENH__ + cmp #$E0 ; Test for lowercase + bcc cputdirect + and #$DF ; Convert to uppercase + .endif cputdirect: - jsr putchar - ;; Bump to next column - inc CH - lda CH - cmp MAX_X - bne return - lda #$00 - sta CH -return: - rts - -putchar: - ora #$80 ; Turn on high bit - and TEXTTYP ; Apply normal, inverse, flash - ldy CH - ldx RD80COL ; In 80 column mode? - bpl col40 ; No, in 40 cols - pha - tya - lsr ; Div by 2 - tay - pla - bcs col40 ; odd cols go in 40 col memory - sta PG2ON -col40: sta (BASL),Y - sta PG2OFF - rts + jsr putchar + inc CH ; Bump to next column + lda CH + cmp WNDWDTH + bcc :+ +left: lda #$00 ; Goto left edge of screen + sta CH +: rts newline: - lda CH - pha - inc CV - lda CV - cmp MAX_Y - bne L2 - lda #$00 - sta CV -L2: - jsr VTABZ - pla - sta CH - rts - -_gotoxy: - sta CV ; Store Y - jsr VTABZ - jsr popa ; Get X - sta CH ; Store X - rts - - + inc CV ; Bump to next line + lda CV + cmp WNDBTM + bcc :+ + lda WNDTOP ; Goto top of screen + sta CV +: jmp VTABZ + +putchar: + .ifdef __APPLE2ENH__ + ldy INVFLG + cpy #$FF ; Normal character display mode? + beq put + cmp #$E0 ; Lowercase? + bcc mask + and #$7F ; Inverse lowercase + bra put + .endif +mask: and INVFLG ; Apply normal, inverse, flash +put: ldy CH + .ifdef __APPLE2ENH__ + bit RD80VID ; In 80 column mode? + bpl col40 ; No, in 40 cols + pha + tya + lsr ; Div by 2 + tay + pla + bcs col40 ; Odd cols go in 40 col memory + bit HISCR ; Assume SET80COL + sta (BASL),Y + bit LOWSCR ; Assume SET80COL + rts + .endif +col40: sta (BASL),Y + rts