Fixed problems with the Atari Lynx's TGI driver.

* The sprite-types for black and transparent backgrounds were swapped.
* A filler-byte for text output isn't printed.  (A hardware bug might not need that work-around in most cases.)
This commit is contained in:
Greg King
2019-10-12 04:01:03 -04:00
parent 39b10f9599
commit f3f15cfd25

View File

@@ -1,10 +1,10 @@
; ;
; Graphics driver for the 160x102x16 mode on the Lynx. ; Graphics driver for the 160x102x16 mode on the Lynx.
; ;
; All the drawing functions are simply done by sprites as the sprite ; All the drawing functions simply are done by sprites, as the sprite
; engine is the only way to do fast graphics on a Lynx. ; engine is the only way to do fast graphics on a Lynx.
; ;
; This code is written by Karri Kaksonen, 2004 for the cc65 compiler. ; This code was written by Karri Kaksonen, 2004 for the cc65 compiler.
; ;
.include "zeropage.inc" .include "zeropage.inc"
@@ -104,8 +104,10 @@ BGINDEX: .res 1 ; Pen to use for text background
DRAWPAGE: .res 1 DRAWPAGE: .res 1
SWAPREQUEST: .res 1 SWAPREQUEST: .res 1
; 8 rows with (one offset-byte plus 20 character bytes plus one fill-byte) plus one 0-offset-byte.
; (As an experiment, the fill-byte isn't being generated.
; It might not be needed to work around a Suzy bug.)
text_bitmap: .res 8*(1+20+1)+1 text_bitmap: .res 8*(1+20+1)+1
; 8 rows with (one offset-byte plus 20 character bytes plus one fill-byte) plus one 0-offset-byte
; Constants and tables ; Constants and tables
@@ -830,7 +832,7 @@ TEXTSTYLE:
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
; OUTTEXT: Output text at X/Y = ptr1/ptr2 using the current color and the ; OUTTEXT: Output text at X/Y = ptr1/ptr2 using the current color and the
; current text style. The text to output is given as a zero terminated ; current text style. The text to output is given as a zero-terminated
; string with address in ptr3. ; string with address in ptr3.
; ;
; Must set an error code: NO ; Must set an error code: NO
@@ -842,12 +844,11 @@ OUTTEXT:
lda TEXTMAGY lda TEXTMAGY
sta text_sy+1 sta text_sy+1
stz text_sprite ; Set normal sprite
lda BGINDEX lda BGINDEX
bne @L1 beq @L1 ; Choose opaque black sprite?
lda #4 lda #$04 ; No, choose normal sprite
sta text_sprite ; Set opaque sprite
@L1: @L1:
sta text_sprite
lda DRAWINDEX ; Set color lda DRAWINDEX ; Set color
asl asl
asl asl
@@ -875,15 +876,18 @@ OUTTEXT:
ldy #20 ldy #20
@L3: @L3:
sty STRLEN sty STRLEN
tya
bne @L4 bne @L4
rts ; Zero length string rts ; Zero-length string
@L4: @L4:
iny ; Prepare text_bitmap iny ; Prepare text_bitmap
iny
; The next instruction is commented because the code won't include a fill-byte.
; iny
sty STROFF sty STROFF
ldy #8-1 ; 8 pixel lines per character ldy #8-1 ; 8 pixel lines per character
ldx #0 ldx #$00
clc clc
@L5: @L5:
lda STROFF lda STROFF
@@ -891,45 +895,45 @@ OUTTEXT:
txa txa
adc STROFF adc STROFF
tax tax
lda #$ff
sta text_bitmap-1,x ; This was the fill-byte.
; lda #$FF
; sta text_bitmap-1,x
dey dey
bpl @L5 bpl @L5
stz text_bitmap,x stz text_bitmap,x
stz tmp2 stz tmp2
iny iny ;(ldy #$00)
@L6: @L6:
lda (STRPTR),y lda (STRPTR),y
sty tmp1 sty tmp1
sec ; (ch-' ') * 8 sub #' ' ; (ch - ' ') * 8
sbc #32
stz FONTOFF
stz FONTOFF+1 stz FONTOFF+1
asl asl
asl asl
rol FONTOFF+1 rol FONTOFF+1
asl asl
rol FONTOFF+1 rol FONTOFF+1
clc ; Choose font ;clc ; (cleared by rol)
adc #<font adc #<font ; Choose font
sta FONTOFF sta FONTOFF
lda FONTOFF+1 lda FONTOFF+1
adc #>font adc #>font
sta FONTOFF+1 sta FONTOFF+1
; and now copy the 8 bytes of that char ; And now, copy the 8 bytes of that glyph.
ldx tmp2 ldx tmp2
inx inx
stx tmp2 stx tmp2
; draw char from top to bottom, reading char-data from offset 8-1 to offset 0 ; Draw char. from top to bottom, reading char-data from offset 8-1 to offset 0.
ldy #8-1 ldy #8-1
@L7: @L7:
lda (FONTOFF),y ; *chptr lda (FONTOFF),y ; *chptr
sta text_bitmap,x ;textbuf[y*(1+len+1)+1+x] sta text_bitmap,x ; textbuf[y*(1+len+1)+1+x]
txa txa
adc STROFF adc STROFF
@@ -938,7 +942,7 @@ OUTTEXT:
dey dey
bpl @L7 bpl @L7
; goto next char ; Goto next char.
ldy tmp1 ldy tmp1
iny iny
dec STRLEN dec STRLEN