1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 23:29:39 +00:00

Merge pull request #1412 from jedeoric/master

[Telestrat] Fix many bugs in conio Telestrat target
This commit is contained in:
greg-king5 2021-03-09 18:44:20 -05:00 committed by GitHub
commit 23fba6cc37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 204 additions and 56 deletions

View File

@ -85,6 +85,8 @@
#define CH_LTEE '+'
#define CH_RTEE '+'
#define CH_CROSS '+'
#define CH_HLINE '-'
#define CH_VLINE '|'
#define CH_CURS_UP 11
#define CH_CURS_DOWN 10
#define CH_CURS_LEFT 8
@ -119,3 +121,9 @@ void shoot();
void explode();
void kbdclick1();
/* The following #defines will cause the matching functions calls in conio.h
** to be overlaid by macros with the same names, saving the function call
** overhead.
*/
#define _bordercolor(color) COLOR_BLACK

View File

@ -0,0 +1,14 @@
;
; Ullrich von Bassewitz, 06.08.1998
;
; unsigned char __fastcall__ bordercolor (unsigned char color);
;
.export _bordercolor
.import return0
.include "telestrat.inc"
_bordercolor := return0

View File

@ -6,7 +6,7 @@
;
.export _cclearxy, _cclear
.import update_adscr
.import update_adscr, display_conio
.importzp tmp1
.import popax
@ -27,7 +27,7 @@ _cclear:
@L1:
stx tmp1 ; Save X
lda #' ' ; Erase current char
BRK_TELEMON XFWR
jsr display_conio
ldx tmp1
dex
bne @L1

View File

@ -1,22 +1,34 @@
;
; jede jede@oric.org 2018-04-17
;
; void chlinexy (unsigned char x, unsigned char y, unsigned char length);
; void chline (unsigned char length);
;
.export _chline
.export _chlinexy, _chline
.import rvs, display_conio, update_adscr
.import popax
.include "telestrat.inc"
.include "zeropage.inc"
.proc _chline
sta tmp1
@loop:
lda #'-' ; horizontal line screen code
BRK_TELEMON XWR0 ; macro send char to screen (channel 0 in telemon terms)
dec tmp1
bne @loop
rts
.endproc
_chlinexy:
pha ; Save the length
jsr popax ; Get X and Y
sta SCRY ; Store Y
stx SCRX ; Store X
jsr update_adscr
pla ; Restore the length and run into _chline
_chline:
tax ; Is the length zero?
beq @L9 ; Jump if done
@L1:
lda #'-' ; Horizontal line screen code
ora rvs
jsr display_conio
@L2: dex
bne @L1
@L9: rts

View File

@ -3,7 +3,7 @@
;
.export _clrscr
.import OLD_CHARCOLOR, OLD_BGCOLOR
.import OLD_CHARCOLOR, OLD_BGCOLOR, BGCOLOR, CHARCOLOR
.include "telestrat.inc"
@ -23,22 +23,25 @@
; reset prompt position
lda #<(SCREEN+40)
sta ADSCRL
lda #>(SCREEN+40)
sta ADSCRH
lda #<SCREEN
sta ADSCR
lda #>SCREEN
sta ADSCR+1
lda #$00
sta SCRDY
; reset display position
ldx #$01
ldx #$00
stx SCRY
dex
stx SCRX
; At this step X is equal to $00
dex
; At this step X is equal to $FF
stx OLD_BGCOLOR
stx OLD_BGCOLOR ; Black
stx BGCOLOR
ldx #$07 ; White
stx OLD_CHARCOLOR
stx CHARCOLOR
rts
.endproc

View File

@ -4,26 +4,50 @@
; void cputc (char c);
;
.export _cputc, cputdirect
.export _cputc, _cputcxy, cputdirect, display_conio
.export 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
_cputc:
cmp #$0D
bne @not_CR
ldy #$00
sty SCRX
rts
@not_CR:
cmp #$0A
bne not_LF
inc SCRY
jmp update_adscr
cputdirect:
.proc _cputc
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:
@ -33,18 +57,37 @@ 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
.proc display_conio
; This routine is used to displays char on screen
ldy SCRX
sta (ADSCR),y
iny
cpy #SCREEN_XSIZE
bne @no_inc
ldy #$00
sty SCRX
inc SCRY
jmp update_adscr
@no_inc:
sty SCRX
rts
.endproc
.bss
CHARCOLOR:
.res 1
@ -54,3 +97,4 @@ BGCOLOR:
.res 1
OLD_BGCOLOR:
.res 1

40
libsrc/telestrat/cvline.s Normal file
View File

@ -0,0 +1,40 @@
;
; Ullrich von Bassewitz, 2003-04-13
;
; void cvlinexy (unsigned char x, unsigned char y, unsigned char length);
; void cvline (unsigned char length);
;
.export _cvlinexy, _cvline
.import rvs, display_conio, update_adscr
.import popax
.include "telestrat.inc"
_cvlinexy:
pha ; Save the length
jsr popax ; Get X and Y
sta SCRY ; Store Y
stx SCRX ; Store X
jsr update_adscr
pla ; Restore the length and run into _cvline
_cvline:
tax ; Is the length zero?
beq @L9 ; Jump if done
@L1:
lda #'|'
ora rvs
ldy SCRX
sta (ADSCR),y
; compute next line
inc SCRY
jsr update_adscr
@L2: dex
bne @L1
@L9: rts

View File

@ -8,9 +8,5 @@
.proc _gotox
sta SCRX
lda #$FF
sta OLD_CHARCOLOR
sta OLD_BGCOLOR
rts
.endproc

View File

@ -29,30 +29,23 @@ gotoxy: jsr popa ; Get Y
.endproc
.proc update_adscr
; Force to set again color if cursor moves
; $FF is used because we know that it's impossible to have this value with a color
; It prevents a bug : If bgcolor or textcolor is set to black for example with no char displays,
; next cputsxy will not set the attribute if y coordinate changes
lda #$FF
sta OLD_CHARCOLOR
sta OLD_BGCOLOR
lda #<SCREEN
sta ADSCRL
sta ADSCR
lda #>SCREEN
sta ADSCRH
sta ADSCR+1
ldy SCRY
beq out
loop:
lda ADSCRL
lda ADSCR
clc
adc #SCREEN_XSIZE
bcc skip
inc ADSCRH
inc ADSCR+1
skip:
sta ADSCRL
sta ADSCR
dey
bne loop
out:

37
libsrc/telestrat/revers.s Normal file
View File

@ -0,0 +1,37 @@
;
; Ullrich von Bassewitz, 07.08.1998
;
; unsigned char revers (unsigned char onoff);
;
.export _revers
.export rvs
; ------------------------------------------------------------------------
;
.code
.proc _revers
ldx #$00 ; Assume revers off
tay ; Test onoff
beq L1 ; Jump if off
ldx #$80 ; Load on value
ldy #$00 ; Assume old value is zero
L1: lda rvs ; Load old value
stx rvs ; Set new value
beq L2 ; Jump if old value zero
iny ; Make old value = 1
L2: ldx #$00 ; Load high byte of result
tya ; Load low byte, set CC
rts
.endproc
; ------------------------------------------------------------------------
;
.bss
rvs: .res 1

View File

@ -2,12 +2,13 @@
;
.export _textcolor
.import CHARCOLOR
.import CHARCOLOR, OLD_CHARCOLOR
.include "telestrat.inc"
.proc _textcolor
ldx CHARCOLOR ; Get previous color
sta CHARCOLOR
stx OLD_CHARCOLOR
txa ; Return previous color
rts
.endproc