2015-09-27 16:12:25 +00:00
|
|
|
;
|
2015-10-11 15:13:28 +00:00
|
|
|
; Groepaz/Hitmen, 11.10.2015
|
|
|
|
;
|
2015-10-19 00:47:40 +00:00
|
|
|
; high level implementation for the soft80 implementation
|
|
|
|
;
|
2015-09-27 16:12:25 +00:00
|
|
|
; void cputcxy (unsigned char x, unsigned char y, char c);
|
|
|
|
; void cputc (char c);
|
|
|
|
;
|
|
|
|
|
|
|
|
.export soft80_cputcxy, soft80_cputc
|
|
|
|
.export soft80_cputdirect, soft80_putchar
|
|
|
|
.export soft80_newline, soft80_plot
|
2015-10-13 02:14:04 +00:00
|
|
|
.export soft80_checkchar
|
2015-09-27 17:10:06 +00:00
|
|
|
|
2016-06-05 12:58:38 +00:00
|
|
|
.import gotoxy
|
2015-10-12 16:01:48 +00:00
|
|
|
|
2015-09-27 17:10:06 +00:00
|
|
|
.import soft80_kplot
|
2015-10-14 15:24:16 +00:00
|
|
|
.import soft80_internal_bgcolor, soft80_internal_cellcolor
|
2015-10-12 13:44:41 +00:00
|
|
|
.import soft80_internal_cursorxlsb
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-09-27 17:10:06 +00:00
|
|
|
.importzp tmp4,tmp3
|
|
|
|
|
2015-09-27 16:12:25 +00:00
|
|
|
.include "c64.inc"
|
|
|
|
.include "soft80.inc"
|
|
|
|
|
|
|
|
soft80_cputcxy:
|
|
|
|
pha ; Save C
|
2016-06-05 12:58:38 +00:00
|
|
|
jsr gotoxy ; Set cursor, drop x and y
|
2015-09-27 16:12:25 +00:00
|
|
|
pla ; Restore C
|
|
|
|
|
|
|
|
; Plot a character - also used as internal function
|
|
|
|
|
|
|
|
soft80_cputc:
|
|
|
|
cmp #$0A ; CR?
|
|
|
|
bne L1
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
sta CURS_X
|
|
|
|
|
|
|
|
; Set cursor position, calculate RAM pointers
|
|
|
|
soft80_plot:
|
|
|
|
ldx CURS_Y
|
|
|
|
ldy CURS_X
|
|
|
|
clc
|
2015-09-28 13:10:57 +00:00
|
|
|
jmp soft80_kplot ; Set the new cursor
|
2015-09-27 16:12:25 +00:00
|
|
|
|
|
|
|
L1: cmp #$0D ; LF?
|
2015-09-28 13:10:57 +00:00
|
|
|
beq soft80_newline ; Recalculate pointers
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-10-12 16:01:48 +00:00
|
|
|
; 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.
|
2015-09-27 16:12:25 +00:00
|
|
|
tay
|
2015-10-12 16:53:55 +00:00
|
|
|
bpl @L10
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-10-12 16:01:48 +00:00
|
|
|
; 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
|
|
|
|
|
2015-10-12 16:53:55 +00:00
|
|
|
ora #%01000000 ; $40
|
2015-09-27 16:12:25 +00:00
|
|
|
clc
|
2015-10-12 16:53:55 +00:00
|
|
|
adc #%00100000 ; $20
|
|
|
|
and #%01111111 ; $7f
|
|
|
|
@L10:
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-10-12 13:04:55 +00:00
|
|
|
; entry point for direct output of a character. the value passed in
|
|
|
|
; akku must match the offset in the charset.
|
|
|
|
; - the following may not modify tmp1
|
2015-09-27 16:12:25 +00:00
|
|
|
soft80_cputdirect:
|
2015-09-28 13:10:57 +00:00
|
|
|
jsr soft80_putchar ; Write the character to the screen
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-10-12 16:01:48 +00:00
|
|
|
; Advance cursor position
|
2015-09-28 13:10:57 +00:00
|
|
|
iny ; contains CURS_X
|
2015-09-27 16:12:25 +00:00
|
|
|
cpy #charsperline
|
2015-10-12 17:57:33 +00:00
|
|
|
beq @L3
|
2015-09-27 16:12:25 +00:00
|
|
|
|
|
|
|
sty CURS_X
|
|
|
|
tya
|
|
|
|
and #$01
|
2015-10-12 13:44:41 +00:00
|
|
|
sta soft80_internal_cursorxlsb
|
2015-09-27 16:12:25 +00:00
|
|
|
bne @L5
|
|
|
|
|
|
|
|
lda SCREEN_PTR
|
|
|
|
clc
|
|
|
|
adc #8
|
|
|
|
sta SCREEN_PTR
|
|
|
|
bcc @L4
|
|
|
|
inc SCREEN_PTR+1
|
|
|
|
@L4:
|
|
|
|
inc CRAM_PTR
|
|
|
|
bne @L5
|
|
|
|
inc CRAM_PTR+1
|
|
|
|
@L5:
|
|
|
|
rts
|
2015-10-12 17:57:33 +00:00
|
|
|
@L3:
|
2015-09-27 16:12:25 +00:00
|
|
|
inc CURS_Y ; new line
|
|
|
|
ldy #0 ; + cr
|
|
|
|
sty CURS_X
|
|
|
|
jmp soft80_plot
|
|
|
|
|
2015-10-12 13:04:55 +00:00
|
|
|
; - the following may not modify tmp1
|
2015-09-27 16:12:25 +00:00
|
|
|
soft80_newline:
|
|
|
|
|
|
|
|
lda SCREEN_PTR
|
|
|
|
clc
|
|
|
|
adc #<(40*8)
|
|
|
|
sta SCREEN_PTR
|
|
|
|
|
|
|
|
lda SCREEN_PTR+1
|
|
|
|
adc #>(40*8)
|
|
|
|
sta SCREEN_PTR+1
|
|
|
|
|
|
|
|
lda CRAM_PTR
|
|
|
|
clc
|
|
|
|
adc #40
|
|
|
|
sta CRAM_PTR
|
2015-10-12 17:57:33 +00:00
|
|
|
bcc @L5
|
2015-09-27 16:12:25 +00:00
|
|
|
inc CRAM_PTR+1
|
2015-10-12 17:57:33 +00:00
|
|
|
@L5:
|
2015-09-27 16:12:25 +00:00
|
|
|
inc CURS_Y
|
|
|
|
rts
|
|
|
|
|
2015-10-12 16:01:48 +00:00
|
|
|
;-------------------------------------------------------------------------------
|
|
|
|
; 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
|
|
|
|
;-------------------------------------------------------------------------------
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-10-08 18:43:25 +00:00
|
|
|
.if SOFT80FASTSPACE = 1
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-10-12 16:01:48 +00:00
|
|
|
; 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:
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-10-08 18:43:25 +00:00
|
|
|
.if SOFT80COLORVOODOO = 1
|
2015-10-12 16:01:48 +00:00
|
|
|
jsr soft80_putcolor
|
|
|
|
.else
|
2015-10-14 15:24:16 +00:00
|
|
|
lda soft80_internal_cellcolor
|
2015-10-12 16:01:48 +00:00
|
|
|
sta (CRAM_PTR),y ; vram
|
2015-10-08 18:43:25 +00:00
|
|
|
.endif
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-10-12 13:44:41 +00:00
|
|
|
lda soft80_internal_cursorxlsb
|
2015-10-12 16:01:48 +00:00
|
|
|
bne draw_spaceinvers_odd
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-10-12 16:01:48 +00:00
|
|
|
; output inverted space (even)
|
2015-09-27 16:12:25 +00:00
|
|
|
.repeat 8,line
|
|
|
|
lda (SCREEN_PTR),y
|
2015-10-12 16:01:48 +00:00
|
|
|
and #$0f
|
2015-09-27 16:12:25 +00:00
|
|
|
sta (SCREEN_PTR),y
|
2015-10-12 16:01:48 +00:00
|
|
|
.if line < 7
|
2015-09-27 16:12:25 +00:00
|
|
|
iny
|
|
|
|
.endif
|
|
|
|
.endrepeat
|
2015-10-12 16:01:48 +00:00
|
|
|
jmp draw_back
|
|
|
|
|
|
|
|
; output space (odd)
|
|
|
|
draw_space_odd:
|
2015-09-27 16:12:25 +00:00
|
|
|
.repeat 8,line
|
|
|
|
lda (SCREEN_PTR),y
|
|
|
|
ora #$0f
|
|
|
|
sta (SCREEN_PTR),y
|
|
|
|
.if line < 7
|
|
|
|
iny
|
|
|
|
.endif
|
|
|
|
.endrepeat
|
2015-10-12 16:01:48 +00:00
|
|
|
jmp draw_back
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-10-12 16:01:48 +00:00
|
|
|
; output space (general entry point)
|
2015-10-08 18:43:25 +00:00
|
|
|
; in: y must be $00
|
2015-10-12 16:01:48 +00:00
|
|
|
draw_space:
|
|
|
|
|
|
|
|
lda RVS
|
|
|
|
bne draw_spaceinvers
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-10-08 18:43:25 +00:00
|
|
|
.if SOFT80COLORVOODOO = 1
|
2015-10-12 16:01:48 +00:00
|
|
|
jsr remcolor
|
2015-10-08 18:43:25 +00:00
|
|
|
.endif
|
2015-10-12 16:01:48 +00:00
|
|
|
;ldy #$00 ; is still $00
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-10-12 13:44:41 +00:00
|
|
|
lda soft80_internal_cursorxlsb
|
2015-10-12 16:01:48 +00:00
|
|
|
bne draw_space_odd
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-10-12 16:01:48 +00:00
|
|
|
; output space (even)
|
2015-09-27 16:12:25 +00:00
|
|
|
.repeat 8,line
|
|
|
|
lda (SCREEN_PTR),y
|
2015-10-12 16:01:48 +00:00
|
|
|
ora #$f0
|
2015-09-27 16:12:25 +00:00
|
|
|
sta (SCREEN_PTR),y
|
2015-10-12 16:01:48 +00:00
|
|
|
.if (line < 7)
|
2015-09-27 16:12:25 +00:00
|
|
|
iny
|
|
|
|
.endif
|
|
|
|
.endrepeat
|
2015-10-12 16:01:48 +00:00
|
|
|
jmp draw_back
|
2015-10-08 18:43:25 +00:00
|
|
|
.endif
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-10-12 16:01:48 +00:00
|
|
|
;-------------------------------------------------------------------------------
|
|
|
|
; 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
|
|
|
|
;
|
2015-09-27 16:12:25 +00:00
|
|
|
soft80_putchar:
|
2015-10-08 18:43:25 +00:00
|
|
|
sta tmp3 ; remember charcode
|
2015-09-27 16:12:25 +00:00
|
|
|
|
|
|
|
sei
|
|
|
|
ldx $01
|
|
|
|
stx tmp4
|
|
|
|
ldx #$34
|
|
|
|
|
|
|
|
stx $01 ; will stay $34 for space
|
|
|
|
ldy #$00 ; will be $00 from now on
|
|
|
|
|
2015-10-08 18:43:25 +00:00
|
|
|
.if SOFT80FASTSPACE = 1
|
2015-09-27 16:12:25 +00:00
|
|
|
cmp #' ' ; space is a special (optimized) case
|
2015-10-12 16:01:48 +00:00
|
|
|
beq draw_space
|
2015-10-08 18:43:25 +00:00
|
|
|
.endif
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-10-08 18:43:25 +00:00
|
|
|
.if SOFT80COLORVOODOO = 1
|
2015-09-27 17:10:06 +00:00
|
|
|
jsr soft80_putcolor
|
2015-10-08 18:43:25 +00:00
|
|
|
.else
|
2015-10-14 15:24:16 +00:00
|
|
|
lda soft80_internal_cellcolor
|
2015-10-08 18:43:25 +00:00
|
|
|
sta (CRAM_PTR),y ; vram
|
|
|
|
.endif
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-10-12 16:01:48 +00:00
|
|
|
; output character
|
2015-10-08 18:43:25 +00:00
|
|
|
ldx tmp3 ; get charcode
|
2015-09-27 16:12:25 +00:00
|
|
|
|
|
|
|
lda RVS
|
2015-10-12 16:01:48 +00:00
|
|
|
beq @skp
|
|
|
|
jmp draw_charinvers
|
|
|
|
@skp:
|
2015-10-12 13:44:41 +00:00
|
|
|
lda soft80_internal_cursorxlsb
|
2015-10-12 16:01:48 +00:00
|
|
|
bne draw_char_even
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-10-12 16:01:48 +00:00
|
|
|
; output character (odd)
|
2015-09-27 16:12:25 +00:00
|
|
|
.repeat 8,line
|
|
|
|
lda (SCREEN_PTR),y
|
|
|
|
and #$0f
|
|
|
|
ora soft80_hi_charset+(line*$80),x
|
|
|
|
sta (SCREEN_PTR),y
|
|
|
|
.if line < 7
|
|
|
|
iny
|
|
|
|
.endif
|
|
|
|
.endrepeat
|
2015-10-12 16:01:48 +00:00
|
|
|
jmp draw_back
|
2015-09-27 16:12:25 +00:00
|
|
|
|
2015-10-12 16:01:48 +00:00
|
|
|
; output character (even)
|
|
|
|
draw_char_even:
|
2015-09-27 16:12:25 +00:00
|
|
|
.repeat 8,line
|
|
|
|
lda (SCREEN_PTR),y
|
|
|
|
and #$f0
|
|
|
|
ora soft80_lo_charset+(line*$80),x
|
|
|
|
sta (SCREEN_PTR),y
|
|
|
|
.if line < 7
|
|
|
|
iny
|
|
|
|
.endif
|
|
|
|
.endrepeat
|
|
|
|
|
2015-10-12 16:01:48 +00:00
|
|
|
draw_back:
|
2015-09-27 16:12:25 +00:00
|
|
|
lda tmp4
|
|
|
|
sta $01
|
|
|
|
cli
|
|
|
|
|
|
|
|
ldy CURS_X
|
|
|
|
rts
|
|
|
|
|
2015-10-12 16:01:48 +00:00
|
|
|
; output inverted character (odd)
|
|
|
|
draw_charinvers_odd:
|
2015-09-27 16:12:25 +00:00
|
|
|
.repeat 8,line
|
|
|
|
lda (SCREEN_PTR),y
|
2015-10-12 16:01:48 +00:00
|
|
|
ora #$0f
|
|
|
|
eor soft80_lo_charset+(line*$80),x
|
2015-09-27 16:12:25 +00:00
|
|
|
sta (SCREEN_PTR),y
|
|
|
|
.if line < 7
|
|
|
|
iny
|
|
|
|
.endif
|
|
|
|
.endrepeat
|
2015-10-12 16:01:48 +00:00
|
|
|
jmp draw_back
|
|
|
|
|
|
|
|
; output inverted character (generic)
|
|
|
|
draw_charinvers:
|
|
|
|
lda soft80_internal_cursorxlsb
|
|
|
|
bne draw_charinvers_odd
|
|
|
|
|
2015-09-27 16:12:25 +00:00
|
|
|
.repeat 8,line
|
|
|
|
lda (SCREEN_PTR),y
|
2015-10-12 16:01:48 +00:00
|
|
|
ora #$f0
|
|
|
|
eor soft80_hi_charset+(line*$80),x
|
2015-09-27 16:12:25 +00:00
|
|
|
sta (SCREEN_PTR),y
|
|
|
|
.if line < 7
|
|
|
|
iny
|
|
|
|
.endif
|
|
|
|
.endrepeat
|
2015-10-12 16:01:48 +00:00
|
|
|
jmp draw_back
|
2015-10-08 18:43:25 +00:00
|
|
|
|
|
|
|
;-------------------------------------------------------------------------------
|
2015-10-09 21:39:37 +00:00
|
|
|
; optional "color voodoo". the problem is that each 8x8 cell can only contain
|
|
|
|
; two colors, one of which is used for the background color, so two characters
|
|
|
|
; have to share the same text color.
|
|
|
|
;
|
|
|
|
; - in a cell that contains two spaces, both the color ram and the text color
|
|
|
|
; in vram contain the background color
|
|
|
|
;
|
|
|
|
; - in a cell that contains one character, its text color goes into vram. the
|
|
|
|
; color ram contains the background color.
|
|
|
|
;
|
|
|
|
; - in a cell that contains two characters, the color of the left character goes
|
|
|
|
; to vram (and is shared by both for display). the "would be" color of the
|
|
|
|
; right character goes to color ram as a reminder and can be restored when one
|
|
|
|
; of the two characters is cleared by a space.
|
2015-10-08 18:43:25 +00:00
|
|
|
|
|
|
|
.if SOFT80COLORVOODOO = 1
|
|
|
|
|
|
|
|
; remove color from cell, called before putting a "space" character to the bitmap
|
2015-10-09 21:39:37 +00:00
|
|
|
;
|
|
|
|
; __ -> __ -
|
|
|
|
; _A -> _A -
|
|
|
|
; B_ -> B_ -
|
|
|
|
; _A -> __ vram = bgcol
|
|
|
|
; B_ -> __ vram = bgcol
|
|
|
|
; BA -> _A vram = colram, colram = bgcol
|
|
|
|
; BA -> B_ colram = bgcol
|
|
|
|
;
|
|
|
|
; in: x must be $34
|
|
|
|
; y must be $00
|
2015-10-12 17:57:33 +00:00
|
|
|
; out: x = $34
|
|
|
|
; y = $00
|
2015-10-08 18:43:25 +00:00
|
|
|
remcolor:
|
|
|
|
|
|
|
|
;ldy #$00 ; is still $00
|
|
|
|
|
|
|
|
; if the textcolor in vram is equal to the background color, then
|
|
|
|
; no (visible) character is in the current cell and we can exit
|
|
|
|
; immediately.
|
|
|
|
lda (CRAM_PTR),y ; vram (textcolor)
|
|
|
|
and #$0f
|
2015-10-12 13:04:55 +00:00
|
|
|
cmp soft80_internal_bgcolor
|
2015-10-09 21:39:37 +00:00
|
|
|
beq @sk1 ; yes, vram==bgcolor
|
2015-10-08 18:43:25 +00:00
|
|
|
|
|
|
|
; now check if the textcolor in color ram is equal the background color,
|
|
|
|
; if yes then there is only one (visible) character in the current cell
|
2015-10-09 21:39:37 +00:00
|
|
|
inc $01 ; $35
|
2015-10-08 18:43:25 +00:00
|
|
|
lda (CRAM_PTR),y ; colram (2nd textcolor)
|
2015-10-09 21:39:37 +00:00
|
|
|
stx $01 ; $34
|
2015-10-08 18:43:25 +00:00
|
|
|
and #$0f
|
2015-10-12 13:04:55 +00:00
|
|
|
cmp soft80_internal_bgcolor
|
2015-10-09 21:39:37 +00:00
|
|
|
beq @sk2 ; yes, colram==bgcolor
|
2015-10-12 17:57:33 +00:00
|
|
|
sta tmp3 ; A contains colram
|
2015-10-08 18:43:25 +00:00
|
|
|
|
|
|
|
; two characters in the current cell, of which one will get removed
|
|
|
|
|
2015-10-12 13:44:41 +00:00
|
|
|
lda soft80_internal_cursorxlsb
|
2015-10-09 21:39:37 +00:00
|
|
|
bne @sk3
|
|
|
|
|
|
|
|
; vram = colram
|
2015-10-08 18:43:25 +00:00
|
|
|
lda (CRAM_PTR),y ; vram
|
|
|
|
and #$f0
|
2015-10-12 17:57:33 +00:00
|
|
|
ora tmp3 ; colram value
|
2015-10-08 18:43:25 +00:00
|
|
|
sta (CRAM_PTR),y ; vram
|
2015-10-09 21:39:37 +00:00
|
|
|
@sk3:
|
2015-10-08 18:43:25 +00:00
|
|
|
; colram = bgcolor
|
2015-10-12 13:04:55 +00:00
|
|
|
lda soft80_internal_bgcolor
|
2015-10-09 21:39:37 +00:00
|
|
|
inc $01 ; $35
|
2015-10-08 18:43:25 +00:00
|
|
|
sta (CRAM_PTR),y ; colram
|
2015-10-09 21:39:37 +00:00
|
|
|
stx $01 ; $34
|
2015-10-08 18:43:25 +00:00
|
|
|
|
2015-10-09 21:39:37 +00:00
|
|
|
rts
|
2015-10-08 18:43:25 +00:00
|
|
|
|
2015-10-09 21:39:37 +00:00
|
|
|
@sk2:
|
2015-10-08 18:43:25 +00:00
|
|
|
; colram is bgcolor
|
|
|
|
; => only one char in cell used
|
|
|
|
|
|
|
|
jsr soft80_checkchar
|
2015-10-12 17:03:50 +00:00
|
|
|
bcs @sk1 ; space at current position
|
2015-10-08 18:43:25 +00:00
|
|
|
|
|
|
|
; vram (textcolor) = bgcolor
|
|
|
|
lda (CRAM_PTR),y ; vram
|
|
|
|
and #$f0
|
2015-10-12 13:04:55 +00:00
|
|
|
ora soft80_internal_bgcolor
|
2015-10-08 18:43:25 +00:00
|
|
|
sta (CRAM_PTR),y ; vram
|
2015-10-09 21:39:37 +00:00
|
|
|
@sk1:
|
2015-10-08 18:43:25 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
; put color to cell
|
2015-10-09 21:39:37 +00:00
|
|
|
;
|
|
|
|
; __ -> _A vram = textcol
|
|
|
|
; __ -> B_ vram = textcol
|
|
|
|
; _A -> BA colram = vram, vram = textcol
|
|
|
|
; B_ -> BA colram = textcol
|
|
|
|
;
|
|
|
|
; _A -> _C vram = textcol
|
|
|
|
; B_ -> C_ vram = textcol
|
|
|
|
; BA -> BC colram = textcol
|
|
|
|
; BA -> CA vram = textcol
|
|
|
|
;
|
|
|
|
; in: $01 is $34 (RAM under I/O) when entering
|
|
|
|
; x must be $34
|
|
|
|
; y must be $00
|
|
|
|
; out: x = $34
|
|
|
|
; y = $00
|
2015-10-08 18:43:25 +00:00
|
|
|
soft80_putcolor:
|
|
|
|
|
|
|
|
;ldy #$00 ; is still $00
|
|
|
|
|
|
|
|
lda (CRAM_PTR),y ; vram
|
|
|
|
and #$0f
|
2015-10-12 13:04:55 +00:00
|
|
|
cmp soft80_internal_bgcolor
|
2015-10-09 21:39:37 +00:00
|
|
|
beq @sk1 ; vram==bgcolor => first char in cell
|
2015-10-08 18:43:25 +00:00
|
|
|
|
|
|
|
; vram!=bgcolor => second char in cell
|
|
|
|
|
2015-10-09 21:39:37 +00:00
|
|
|
inc $01 ; $35
|
2015-10-08 18:43:25 +00:00
|
|
|
lda (CRAM_PTR),y ; colram
|
2015-10-09 21:39:37 +00:00
|
|
|
stx $01 ; $34
|
2015-10-08 18:43:25 +00:00
|
|
|
and #$0f
|
2015-10-12 13:04:55 +00:00
|
|
|
cmp soft80_internal_bgcolor
|
2015-10-09 21:39:37 +00:00
|
|
|
beq @l2s ; colram==bgcolor -> second char in cell
|
2015-10-08 18:43:25 +00:00
|
|
|
|
2015-10-09 21:39:37 +00:00
|
|
|
; botch characters in the cell are used
|
2015-10-08 18:43:25 +00:00
|
|
|
|
2015-10-12 13:44:41 +00:00
|
|
|
lda soft80_internal_cursorxlsb
|
2015-10-09 21:39:37 +00:00
|
|
|
bne @sk2 ; jump if odd xpos
|
|
|
|
|
|
|
|
; vram = textcol
|
2015-10-14 15:24:16 +00:00
|
|
|
lda soft80_internal_cellcolor
|
2015-10-09 21:39:37 +00:00
|
|
|
sta (CRAM_PTR),y ; vram
|
|
|
|
rts
|
|
|
|
|
|
|
|
@l2s:
|
|
|
|
; one character in cell is already used
|
2015-10-08 18:43:25 +00:00
|
|
|
jsr soft80_checkchar
|
2015-10-12 17:03:50 +00:00
|
|
|
bcc @sk1 ; char at current position => overwrite 1st
|
2015-10-09 21:39:37 +00:00
|
|
|
|
2015-10-12 13:44:41 +00:00
|
|
|
lda soft80_internal_cursorxlsb
|
2015-10-09 21:39:37 +00:00
|
|
|
beq @sk3 ; jump if even xpos
|
|
|
|
@sk2:
|
|
|
|
; colram = textcol
|
2015-10-14 15:24:16 +00:00
|
|
|
lda CHARCOLOR
|
2015-10-09 21:39:37 +00:00
|
|
|
inc $01 ; $35
|
|
|
|
sta (CRAM_PTR),y ; colram
|
|
|
|
stx $01 ; $34
|
|
|
|
rts
|
2015-10-08 18:43:25 +00:00
|
|
|
|
2015-10-09 21:39:37 +00:00
|
|
|
@sk3:
|
2015-10-08 18:43:25 +00:00
|
|
|
; colram=vram
|
|
|
|
lda (CRAM_PTR),y ; vram
|
2015-10-09 21:39:37 +00:00
|
|
|
inc $01 ; $35
|
2015-10-08 18:43:25 +00:00
|
|
|
sta (CRAM_PTR),y ; colram
|
2015-10-09 21:39:37 +00:00
|
|
|
stx $01 ; $34
|
|
|
|
@sk1:
|
|
|
|
; vram = textcol
|
2015-10-14 15:24:16 +00:00
|
|
|
lda soft80_internal_cellcolor
|
2015-10-08 18:43:25 +00:00
|
|
|
sta (CRAM_PTR),y ; vram
|
|
|
|
rts
|
|
|
|
|
2015-10-12 14:15:40 +00:00
|
|
|
;
|
2015-10-08 18:43:25 +00:00
|
|
|
; test if there is a space or a character at current position
|
2015-10-12 14:15:40 +00:00
|
|
|
;
|
|
|
|
; in: x = $34
|
2015-10-13 02:14:04 +00:00
|
|
|
; $01 must be $34
|
|
|
|
;
|
2015-10-12 17:03:50 +00:00
|
|
|
; out: SEC: space
|
|
|
|
; CLC: character
|
2015-10-12 14:15:40 +00:00
|
|
|
; x = $34
|
2015-10-08 18:43:25 +00:00
|
|
|
; y = $00
|
|
|
|
soft80_checkchar:
|
|
|
|
|
2015-10-12 13:44:41 +00:00
|
|
|
lda soft80_internal_cursorxlsb
|
2015-10-12 14:15:40 +00:00
|
|
|
bne @l1a
|
|
|
|
|
|
|
|
; check charset data from bottom up, since a lot of eg lowercase chars
|
2015-10-12 16:01:48 +00:00
|
|
|
; have no data in the top rows, but all of them DO have data in the
|
2015-10-12 14:15:40 +00:00
|
|
|
; second to bottom row, this will likely be faster in average.
|
2015-10-08 18:43:25 +00:00
|
|
|
|
2015-10-12 14:15:40 +00:00
|
|
|
ldy #7
|
2015-10-08 18:43:25 +00:00
|
|
|
.repeat 8,line
|
|
|
|
lda (SCREEN_PTR),y
|
|
|
|
and #$f0
|
|
|
|
cmp #$f0
|
2015-10-12 16:09:50 +00:00
|
|
|
bne @ischar
|
2015-10-08 18:43:25 +00:00
|
|
|
.if (line < 7)
|
2015-10-12 14:15:40 +00:00
|
|
|
dey
|
2015-10-08 18:43:25 +00:00
|
|
|
.endif
|
|
|
|
.endrepeat
|
2015-10-12 14:15:40 +00:00
|
|
|
;ldy #$00 ; is 0
|
2015-10-12 17:03:50 +00:00
|
|
|
;sec ; is set
|
2015-10-08 18:43:25 +00:00
|
|
|
rts
|
2015-10-12 16:09:50 +00:00
|
|
|
@ischar:
|
2015-10-08 18:43:25 +00:00
|
|
|
ldy #$00
|
2015-10-12 17:03:50 +00:00
|
|
|
;clc ; is cleared
|
2015-10-08 18:43:25 +00:00
|
|
|
rts
|
|
|
|
@l1a:
|
2015-10-12 14:15:40 +00:00
|
|
|
ldy #$07
|
2015-10-08 18:43:25 +00:00
|
|
|
.repeat 8,line
|
|
|
|
lda (SCREEN_PTR),y
|
|
|
|
and #$0f
|
|
|
|
cmp #$0f
|
2015-10-12 16:09:50 +00:00
|
|
|
bne @ischar
|
2015-10-08 18:43:25 +00:00
|
|
|
.if line < 7
|
2015-10-12 14:15:40 +00:00
|
|
|
dey
|
2015-10-08 18:43:25 +00:00
|
|
|
.endif
|
|
|
|
.endrepeat
|
2015-10-12 14:15:40 +00:00
|
|
|
;ldy #$00 ; is 0
|
2015-10-12 17:03:50 +00:00
|
|
|
;sec ; is set
|
2015-10-08 18:43:25 +00:00
|
|
|
rts
|
|
|
|
.endif
|