Posted: Tue Dec 20, 2011 1:31 am
Thinking back to the equivalent $FFD2 CHROUT routine on the C-64, I think I've got my routine down pretty close. And thanks to TeamTempest for contributing.
Sorry for the length, but I have now incorporated the PLTPOS and ATTBUTE routines within the PLTCHR routine. Plot Enable is now a bit value...
Also, all 16bits of the databus are used to define a character for the 8bit video TFT. The bit placements are commented within the assembly. Simply put, the lower 7 bits define the ASCII character, and bits 8thru15 are character plot enable, size, color and font attributes (1,3,4, & 1 bits respectively)...
The PLTCHR routine still needs just abit of final fine tuning to detect when to increment the Y Plot value, after reaching max X with variable character sizes, in order to continue plotting to the second and consecutive lines. Working...
I thought I would post the code now, even though it is incomplete, in order to show how many ASLs and LSR's are needed.
Sorry for the length, but I have now incorporated the PLTPOS and ATTBUTE routines within the PLTCHR routine. Plot Enable is now a bit value...
Also, all 16bits of the databus are used to define a character for the 8bit video TFT. The bit placements are commented within the assembly. Simply put, the lower 7 bits define the ASCII character, and bits 8thru15 are character plot enable, size, color and font attributes (1,3,4, & 1 bits respectively)...
The PLTCHR routine still needs just abit of final fine tuning to detect when to increment the Y Plot value, after reaching max X with variable character sizes, in order to continue plotting to the second and consecutive lines. Working...
I thought I would post the code now, even though it is incomplete, in order to show how many ASLs and LSR's are needed.
Code: Select all
PLTCHR STA CHR ; Plot Character Subroutine variable (1-7) H and V size
TYA ; save all reg's
PHA
TXA
PHA
ATTBUTE AND #%00000111100000000
LSR A ;get color VALUE from bits 8,9,10,11
LSR A
LSR A
LSR A
LSR A
LSR A ;multiply by 4 for easy indexing
TAX
LDA COLTABLE,X
STA PXLCOL1
INX
LDA COLTABLE,X
STA PXLCOL2
INX
LDA COLTABLE,X
STA PXLCOL3
LDA CHR ;check bits 12,13,14 for size
AND #%0111000000000000
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A ;make size 1x through 7x, no size 0!
STA XWIDTH
STA YWIDTH
LDA CHR ;check font bit 15, 1=C64 , 0=3x5
AND #%1000000000000000
CMP #$8000
BEQ n64
LDA #$08
STA PATROW
STA CHRXLEN
STA CHRYLEN
LDA #$CA00
STA CHRBASE
LDA #$0080
STA SENTINEL
JMP porc
n64 LDA #$04
STA CHRXLEN
LDA #$05
STA PATROW
STA CHRYLEN
LDA #$CD00
STA CHRBASE
LDA #$0800
STA SENTINEL
porc LDA CHR ;test PE bit 7 for plot or clear
AND #%0000000010000000
CMP #$80
BNE plot2
LDA SCRCOL1
STA TMPCOL1
LDA SCRCOL2
STA TMPCOL2
LDA SCRCOL3
STA TMPCOL3
JMP PLTPOS
plot2 LDA PXLCOL1
STA TMPCOL1
LDA PXLCOL2
STA TMPCOL2
LDA PXLCOL3
STA TMPCOL3
PLTPOS LDA #$2A ;set x address
STA DCOM
LDA XPOS
PHA
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A
STA DDAT ;X START MSB
PLA
AND #$00FF
STA DDAT ;X START LSB
LDA XPOS
CLC
LDX XWIDTH
AC ADC CHRXLEN
DEX
BNE AC
STA XPOS ;UPDATE X POSITION
INC XPOS ;NEXT CHR WILL GO HERE
SEC
SBC #$01
PHA
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A
STA DDAT ;X END MSB
PLA
AND #$00FF
STA DDAT ;X END LSB
LDA #$2B ;set y address
STA DCOM
LDA YPOS
PHA
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A
STA DDAT ;Y START MSB
PLA
AND #$00FF
STA DDAT ;Y START LSB
LDA YPOS
CLC
LDX YWIDTH
AD ADC CHRYLEN
DEX
BNE AD
SEC
SBC #$01
PHA
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A
STA DDAT ;Y END MSB
PLA
AND #$00FF
STA DDAT ;Y END LSB
CACALC LDA #$2C ; Prepare TFT to Plot
STA DCOM
LDA CHR
AND #$7F ; an ascii char ? - ATTRIBUTE INFO
CMP #$0D
BNE nnull
LDX #$00
STX XCHRPOS
INC YCHRPOS
LDA #$00 ; make undefined char's a defined zero (space character)
nnull SEC
SBC #$20
ASL A ; * 2
ASL A ; * 4
ASL A ; * 8
CLC
ADC CHRBASE ; add pointer to base either CA00 (C64) or CD00(3x5) (carry clear)
TAY
loop7 LDA XWIDTH ; plot row repeat count (1-7)
STA PIXROW
loop4 LDA CHARPIX,Y ; $FFFFCA00(c64) or $FFFFCD00(3x5)
ASL A ;
ASL A ;
ASL A ;
ASL A ;
ASL A ;
ASL A ;
ASL A ;
ASL A ; shift out upper 8 bits, don't care for 8-bit byte character font
ORA SENTINEL ; $0080 (C64) or $0800 (3x5)
ASL A ; get a pixel
loop5 PHA ; save remaining pixel row data
LDX YWIDTH ; plot column repeat count (1-7) (same as PLTHGT?)
BCC xwnp ; b: clear ('blank')
xwp LDA TMPCOL1
STA DDAT ; plot RED pixel TFT data
LDA TMPCOL2
STA DDAT ; plot GREEN pixel TFT data
LDA TMPCOL3
STA DDAT ; plot BLUE pixel TFT data
DEX
BNE xwp
BEQ nxtpix ; b: forced
xwnp LDA SCRCOL1
STA DDAT ; plot RED "blank" pixel TFT data
LDA SCRCOL2
STA DDAT ; plot GREEN "blank" pixel TFT data
LDA SCRCOL3
STA DDAT ; plot BLUE "blank" pixel TFT data
DEX
BNE xwnp
nxtpix PLA ; get pixel row data back
ASL A ; another pixel to plot ?
BNE loop5 ; b: yes (sentinel still hasn't shifted out)
DEC PIXROW ; repeat this row ?
BNE loop4 ; b: yes
INY
DEC PATROW ; another pattern row to plot ?
BNE loop7 ; b: yes
PLA
TAX
PLA
TAY ;reload reg's
RTS