;
; Groepaz/Hitmen, 11.10.2015
;
+; high level implementation for the soft80 implementation
+;
; 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
+ .export soft80_checkchar
- .import popa, _gotoxy
+ .import gotoxy
.import soft80_kplot
- .import soft80_internal_bgcolor, soft80_internal_textcolor
+ .import soft80_internal_bgcolor, soft80_internal_cellcolor
.import soft80_internal_cursorxlsb
.importzp tmp4,tmp3
soft80_cputcxy:
pha ; Save C
- jsr popa ; Get Y
- jsr _gotoxy ; Set cursor, drop x
+ jsr gotoxy ; Set cursor, drop x and y
pla ; Restore C
; Plot a character - also used as internal function
; codes $00-$1f are control codes which are not printable and thus may
; give undefined result.
tay
- bpl L10
+ bpl @L10
; codes $80-$ff must get converted like this:
; $80-$9f -> dont care (control codes)
; $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
- cmp #%10100000
- bne @sk
-
- tya
- and #%00011111
- bpl L10 ; branch always
-@sk:
- tya
+ ora #%01000000 ; $40
clc
- adc #$20
- and #$7F
-L10:
+ adc #%00100000 ; $20
+ and #%01111111 ; $7f
+@L10:
; entry point for direct output of a character. the value passed in
; akku must match the offset in the charset.
; Advance cursor position
iny ; contains CURS_X
cpy #charsperline
- beq L3
+ beq @L3
sty CURS_X
tya
inc CRAM_PTR+1
@L5:
rts
-L3:
+@L3:
inc CURS_Y ; new line
ldy #0 ; + cr
sty CURS_X
clc
adc #40
sta CRAM_PTR
- bcc L5
+ bcc @L5
inc CRAM_PTR+1
-L5:
+@L5:
inc CURS_Y
rts
.if SOFT80COLORVOODOO = 1
jsr soft80_putcolor
.else
- lda CHARCOLOR
+ lda soft80_internal_cellcolor
sta (CRAM_PTR),y ; vram
.endif
.if SOFT80COLORVOODOO = 1
jsr soft80_putcolor
.else
- lda CHARCOLOR
+ lda soft80_internal_cellcolor
sta (CRAM_PTR),y ; vram
.endif
;
; in: x must be $34
; y must be $00
-; out: y = $00
+; out: x = $34
+; y = $00
remcolor:
;ldy #$00 ; is still $00
and #$0f
cmp soft80_internal_bgcolor
beq @sk2 ; yes, colram==bgcolor
+ sta tmp3 ; A contains colram
; two characters in the current cell, of which one will get removed
- ; vram = colram
- ;inc $01
- ;lda (CRAM_PTR),y ; colram
- ;stx $01 ;$34
- ;and #$0f
- sta tmp3 ; A contains colram
-
lda soft80_internal_cursorxlsb
bne @sk3
; vram = colram
lda (CRAM_PTR),y ; vram
and #$f0
- ora tmp3
+ ora tmp3 ; colram value
sta (CRAM_PTR),y ; vram
@sk3:
; colram = bgcolor
; => only one char in cell used
jsr soft80_checkchar
- bcc @sk1 ; space at current position
+ bcs @sk1 ; space at current position
; vram (textcolor) = bgcolor
lda (CRAM_PTR),y ; vram
bne @sk2 ; jump if odd xpos
; vram = textcol
- lda CHARCOLOR
+ lda soft80_internal_cellcolor
sta (CRAM_PTR),y ; vram
rts
@l2s:
; one character in cell is already used
jsr soft80_checkchar
- bcs @sk1 ; char at current position => overwrite 1st
+ bcc @sk1 ; char at current position => overwrite 1st
lda soft80_internal_cursorxlsb
beq @sk3 ; jump if even xpos
@sk2:
; colram = textcol
- lda soft80_internal_textcolor
+ lda CHARCOLOR
inc $01 ; $35
sta (CRAM_PTR),y ; colram
stx $01 ; $34
stx $01 ; $34
@sk1:
; vram = textcol
- lda CHARCOLOR
+ lda soft80_internal_cellcolor
sta (CRAM_PTR),y ; vram
rts
; test if there is a space or a character at current position
;
; in: x = $34
-; y must be $00
-; out: CLC: space SEC: character
+; $01 must be $34
+;
+; out: SEC: space
+; CLC: character
; x = $34
; y = $00
soft80_checkchar:
- ;ldy #$00 ; is still $00
-
lda soft80_internal_cursorxlsb
bne @l1a
.endif
.endrepeat
;ldy #$00 ; is 0
- clc
+ ;sec ; is set
rts
@ischar:
ldy #$00
- sec
+ ;clc ; is cleared
rts
@l1a:
ldy #$07
.endif
.endrepeat
;ldy #$00 ; is 0
- clc
+ ;sec ; is set
rts
.endif