.export soft80_newline, soft80_plot
.import popa, _gotoxy
- .import xsize
+
.import soft80_kplot
.import soft80_internal_bgcolor, soft80_internal_textcolor
.import soft80_internal_cursorxlsb
.importzp tmp4,tmp3
- .macpack longbranch
-
.include "c64.inc"
.include "soft80.inc"
-.if SOFT80COLORVOODOO = 1
- .export soft80_putcolor
-.endif
-
soft80_cputcxy:
pha ; Save C
jsr popa ; Get Y
L1: cmp #$0D ; LF?
beq soft80_newline ; Recalculate pointers
- ; Printable char of some sort
+ ; shortcut for codes < $80 ... codes $20-$7f can be printed directly,
+ ; codes $00-$1f are control codes which are not printable and thus may
+ ; give undefined result.
tay
bpl L10
+ ; codes $80-$ff must get converted like this:
+ ; $80-$9f -> dont care (control codes)
+ ; $a0-$bf -> $00-$1f
+ ; $c0-$df -> $60-$7f
+ ; $e0-$ff -> $00-$1f
+
; extra check for petscii codes 160-191, these have been moved to
; 0-31 in the charset
and #%11100000
soft80_cputdirect:
jsr soft80_putchar ; Write the character to the screen
-; Advance cursor position
-
-advance:
+ ; Advance cursor position
iny ; contains CURS_X
cpy #charsperline
beq L3
inc CURS_Y
rts
-; Write one character to the screen without doing anything else
-; in: A: character
-; returns: Y: cursor X position
-; this function is going to be used a lot so we unroll it a bit for speed
+;-------------------------------------------------------------------------------
+; All following code belongs to the character output to bitmap
+;
+; this stuff is going to be used a lot so we unroll it a bit for speed
+;-------------------------------------------------------------------------------
.if SOFT80FASTSPACE = 1
-; output space
-; in: y must be $00
-_space:
- lda RVS
- jne _spaceinvers
+; output inverted space (odd)
+draw_spaceinvers_odd:
+ .repeat 8,line
+ lda (SCREEN_PTR),y
+ and #$f0
+ sta (SCREEN_PTR),y
+ .if line < 7
+ iny
+ .endif
+ .endrepeat
+ jmp draw_back
+
+; output inverted space (general entry point)
+; in: y must be $00
+draw_spaceinvers:
.if SOFT80COLORVOODOO = 1
- jsr remcolor
+ jsr soft80_putcolor
+.else
+ lda CHARCOLOR
+ sta (CRAM_PTR),y ; vram
.endif
- ;ldy #$00 ; is still $00
;lda CURS_X
;and #$01
lda soft80_internal_cursorxlsb
- bne @l1
+ bne draw_spaceinvers_odd
+; output inverted space (even)
.repeat 8,line
lda (SCREEN_PTR),y
- ora #$f0
+ and #$0f
sta (SCREEN_PTR),y
- .if (line < 7)
+ .if line < 7
iny
.endif
.endrepeat
- jmp _back
-@l1:
+ jmp draw_back
+
+; output space (odd)
+draw_space_odd:
.repeat 8,line
lda (SCREEN_PTR),y
ora #$0f
iny
.endif
.endrepeat
-@l2:
- jmp _back
+ jmp draw_back
-; output inverted space
+; output space (general entry point)
; in: y must be $00
-_spaceinvers:
+draw_space:
+
+ lda RVS
+ bne draw_spaceinvers
.if SOFT80COLORVOODOO = 1
- jsr soft80_putcolor
-.else
- lda CHARCOLOR
- sta (CRAM_PTR),y ; vram
+ jsr remcolor
.endif
+ ;ldy #$00 ; is still $00
;lda CURS_X
;and #$01
lda soft80_internal_cursorxlsb
- bne @l1
+ bne draw_space_odd
+; output space (even)
.repeat 8,line
lda (SCREEN_PTR),y
- and #$0f
- sta (SCREEN_PTR),y
- .if line < 7
- iny
- .endif
- .endrepeat
- jmp _back
-@l1:
- .repeat 8,line
- lda (SCREEN_PTR),y
- and #$f0
+ ora #$f0
sta (SCREEN_PTR),y
- .if line < 7
+ .if (line < 7)
iny
.endif
.endrepeat
-
- jmp _back
+ jmp draw_back
.endif
- ; entry point for outputting one character in internal encoding
- ; without advancing cursor position
- ; - the following may not modify tmp1
+;-------------------------------------------------------------------------------
+; output one character in internal encoding without advancing cursor position
+; generic entry point
+;
+; - the following may not modify tmp1
+; in: A: charcode
+; out: Y: CURS_X
+;
soft80_putchar:
sta tmp3 ; remember charcode
.if SOFT80FASTSPACE = 1
cmp #' ' ; space is a special (optimized) case
- jeq _space
+ beq draw_space
.endif
.if SOFT80COLORVOODOO = 1
lda CHARCOLOR
sta (CRAM_PTR),y ; vram
.endif
- ; output character
+; output character
ldx tmp3 ; get charcode
lda RVS
- jne _invers
-
- ;lda CURS_X
- ;and #$01
+ beq @skp
+ jmp draw_charinvers
+@skp:
lda soft80_internal_cursorxlsb
- bne @l1
+ bne draw_char_even
+; output character (odd)
.repeat 8,line
lda (SCREEN_PTR),y
and #$0f
iny
.endif
.endrepeat
- jmp @l2
-@l1:
+ jmp draw_back
+; output character (even)
+draw_char_even:
.repeat 8,line
lda (SCREEN_PTR),y
and #$f0
.endif
.endrepeat
-@l2:
-
-_back:
+draw_back:
lda tmp4
sta $01
cli
ldy CURS_X
rts
-; output inverted character
-_invers:
-
- ;lda CURS_X
- ;and #$01
- lda soft80_internal_cursorxlsb
- bne @l1
-
+; output inverted character (odd)
+draw_charinvers_odd:
.repeat 8,line
lda (SCREEN_PTR),y
- ora #$f0
- eor soft80_hi_charset+(line*$80),x
+ ora #$0f
+ eor soft80_lo_charset+(line*$80),x
sta (SCREEN_PTR),y
.if line < 7
iny
.endif
.endrepeat
- jmp _back
-@l1:
+ jmp draw_back
+
+; output inverted character (generic)
+draw_charinvers:
+ lda soft80_internal_cursorxlsb
+ bne draw_charinvers_odd
+
.repeat 8,line
lda (SCREEN_PTR),y
- ora #$0f
- eor soft80_lo_charset+(line*$80),x
+ ora #$f0
+ eor soft80_hi_charset+(line*$80),x
sta (SCREEN_PTR),y
.if line < 7
iny
.endif
.endrepeat
- jmp _back
+ jmp draw_back
;-------------------------------------------------------------------------------
; optional "color voodoo". the problem is that each 8x8 cell can only contain
bne @l1a
; check charset data from bottom up, since a lot of eg lowercase chars
- ; have no data in the top rows, but all of the DO have data in the
+ ; have no data in the top rows, but all of them DO have data in the
; second to bottom row, this will likely be faster in average.
ldy #7
dey
.endif
.endrepeat
-
;ldy #$00 ; is 0
clc
rts
lda (SCREEN_PTR),y
and #$0f
cmp #$0f
- bne @l2bb
+ bne @l2b
.if line < 7
dey
.endif
;ldy #$00 ; is 0
clc
rts
-@l2bb:
- ldy #$00
- sec
- rts
+;@l2bb:
+; ldy #$00
+; sec
+; rts
.endif