Fix many bugs

This commit is contained in:
jede
2021-03-01 22:33:12 +01:00
parent b8889bf37e
commit 02e52fe24d
8 changed files with 109 additions and 55 deletions

View File

@@ -4,24 +4,50 @@
; void cputc (char c);
;
.export _cputc, CHARCOLOR, OLD_CHARCOLOR, BGCOLOR, OLD_BGCOLOR
.export _cputc, _cputcxy, display_conio, CHARCOLOR, OLD_CHARCOLOR, BGCOLOR, OLD_BGCOLOR
.import update_adscr
.import popax
.include "telestrat.inc"
_cputcxy:
pha ; Save C
jsr popax ; Get X and Y
sta SCRY ; Store Y
stx SCRX ; Store X
jsr update_adscr
pla
.proc _cputc
cmp #$0D
bne @not_CR
ldy #$00
sty SCRX
rts
@not_CR:
cmp #$0A
bne @not_LF
inc SCRY
jmp update_adscr
@not_LF:
ldx CHARCOLOR
cpx OLD_CHARCOLOR
beq do_not_change_color_foreground
stx OLD_CHARCOLOR ; Store CHARCOLOR into OLD_CHARCOLOR
dec SCRX
dec SCRX
pha
txa ; Swap X to A because, X contains CHARCOLOR
BRK_TELEMON XFWR ; Change color on the screen (foreground)
inc SCRX
jsr display_conio
pla
do_not_change_color_foreground:
@@ -31,18 +57,38 @@ do_not_change_color_foreground:
stx OLD_BGCOLOR
dec SCRX ; Dec SCRX in order to place attribute before the right position
pha
txa ; Swap X to A because, X contains BGCOLOR
ORA #%00010000 ; Add 16 because background color is an attribute between 16 and 23. 17 is red background for example
BRK_TELEMON XFWR ; Change color on the screen (background)
ora #%00010000 ; Add 16 because background color is an attribute between 16 and 23. 17 is red background for example
jsr display_conio
pla
do_not_change_color:
BRK_TELEMON XFWR ; Macro send char to screen (channel 0)
; it continues to display_conio
.endproc
.proc display_conio
ldy SCRX
sta (ADSCR),y
iny
cpy #SCREEN_XSIZE
bne @no_inc
ldy #$00
sty SCRX
jmp update_adscr
@no_inc:
sty SCRX
rts
.endproc
.bss
CHARCOLOR:
.res 1
@@ -52,3 +98,4 @@ BGCOLOR:
.res 1
OLD_BGCOLOR:
.res 1