TAQOZ - Tachyon Forth for the P2 BOOT ROM

191011121315»

Comments

  • roglohrogloh Posts: 889
    edited December 5 Vote Up0Vote Down
    Cool. I just wouldn't want to see something get into the next P2 ROM that is always off by one pixel, in case your VGA driver makes it in anyway.

    I guess you are just trying to fit 106 columns into 640 pixels, using your 5x7 font. Maybe 2+3 pixels is a good margin either side to centre it, though after the last character it needs some special treatment at the end of the line to clear the following pixels. I think you are just ending it right on the last character's last pixel, maybe for simplification. For a text mode 104 columns might be a good number too being divisible by 8, which works well for tabs. But maybe what you have was more for a graphics mode anyway given you can overlay coloured blocks onto it, in fact I'm not really sure what type of driver you have actually.
  • You're right, it is a bit rough and ready and I haven't done any work on it since I got it up and running. Seeing I have a real chance now of fitting this and the font table into ROM by storing TAQOZ as a compressed image, I should make sure it is working correctly and optimised.

    I just adapted the VGA code and allowed the palette and intensity to be updated on every frame as well as maintaining a frame count which can be used for synchronous and counted frame updates if needed.

    Here's the current VGA code and some other snippets:
    '******************************
    '*  VGA 640 x 480 x 8bpp-lut  *
    '
    ' PBJ: 181022 Adapted for TAQOZ
    '
    '******************************
    
    CON
    vsync		= 4
    intensity	= 120				'0..128
    
    bmpint		= $0				' 256 byte header - mostly free but top half may have bmp header written'
    hcnt		= $4
    vcnt		= $6
    bmppal		= $100
    bmppic		= $500
    
    fclk		= float(CPUHZ)
    fpix		= 25_000_000.0
    fset		= (fpix / fclk * 2.0) * float($4000_0000)
    
    DAT		org
    
    vgainit
    		call	#loadpal
    		rdfast	##640*480/64,##bmporg+bmppic 'set rdfast to wrap on bitmap
    		setxfrq ##round(fset)		'set transfer frequency to 25MHz
    
    		'  cmod   65_4_321_0'		' VGA
    		setcmod	#%01_0_000_0		'enable vga colorspace conversion
    		wrpin	dacmode,#0		'enable dac modes in pins 0..3
    		wrpin	dacmode,#1
    		wrpin	dacmode,#2
    		wrpin	dacmode,#3
    		dirh	#0			' silicon needs dir set to enable smartpin'
    		dirh	#1
    		dirh	#2
    		dirh	#3
    '
    ' XCONT D31..16 = INSTRUCTION, D15..0 = NCO ROLLERS, S=SUB-MODE
    ' Field loop
    '
    field		mov	x,#33			'top blanks
    		call	#blank
    
    		mov     x,#480			'set visible lines
    line		call	#hsync			'do horizontal sync
    		xcont	m_rf,#0			'visible line
    		djnz    x,#line           	'another line?
    
    		mov	x,#10			'bottom blanks
    		call	#blank
    		drvnot	#vsync			'sync on
    		mov	x,#2			'sync blanks
    		call	#blank
    		drvnot	#vsync			'sync off
    		call	#loadpal		' continually update palette in case it has changed'
                    jmp     #field                  'loop
    '
    ' Subroutines
    '
    blank		call	#hsync			'blank lines
    		xcont	m_vi,#0
    	_ret_	djnz	x,#blank
    
    hsync		xcont	m_bs,#0			'horizontal sync
    		xcont	m_sn,#1
    	_ret_	xcont	m_bv,#0
    
    ' Load palette from hub into lut '
    loadpal		mov	x,#0
    		rdfast	#0,##bmporg+bmppal 	'load .bmp palette into lut
    		rep	@.end,#$100		' 256 colors
    		rflong	y
    		shl	y,#8
    		wrlut	y,x
    		add	x,#1
    .end
    		rdbyte	x,##bmporg+bmpint	' update intensity'
    		shl	x,#8
    		setcq	x
    		shl	x,#8
    		setci	x
    		shl	x,#8
    		setcy	x
    		add	_vcnt,#1		' increment frame count'
    		wrword	_vcnt,##bmporg+vcnt
    		ret
    
    ' Initialized data
    '			 1098_7654_321_0987654321098_76_54321_0
    '			%AAAA_BBBB_FFF_DACxxDDDDDDDD_TT_MMMMM_0
    dacmode		long	%0000_0000_000_1010000000000_01_00000_0+vgacog<<8
    
    ' $CF00 = output X3, X2, X1, X0 on all four DAC channels'
    m_bs		long	$CF000000+16		'before sync  %1100_dddd_eppp_xxxx <long> 32-bit immediate
    m_sn		long	$CF000000+96		'sync
    m_bv		long	$CF000000+48		'before visible
    m_vi		long	$CF000000+640		'visible
    
    m_rf		long	$7F000000+640		'visible rflong 8bpp lut
    
    x		res	1
    y		res	1
    _vcnt		res	1
    

    There is one TAQOZ support word in the cog that draws the 5x7 character:
    ' DRAW VIDEO CHARACTER'
    ' WRCH ( font screen pen.paper )'
    WRCH		mov	r0,tos
    		shr	r0,#8		' r0 = pen, tos = paper'
    		mov	ptrb,tos1
    		mov	r1,#7
    wrch1		rdbyte	fx,tos2		' read in next font char
    		mov	r2,#6
    		rep	@wrchx,#5
    wrch2		shr	fx,#1 wc
      	if_c	wrbyte	r0,ptrb++
    	if_nc	wrbyte	tos,ptrb++
    wrchx		wrbyte	tos,ptrb++
    		add	ptrb,##640-6
    		add	tos2,#1
    wrch3		djnz	r1,#wrch1
    		jmp	#DROP3
    

    These are the terminal routines in TAQOZ:
    (		VGA BITMAP TEXT		)
    
    96 7 * TABLE FONT5X7
    
    FONT5X7 $20 7 * -	:= FONT5X7A
    
    10 	:= lsp	--- line space constant'
    6	:= csp	--- character space constant 
    
    --- User commands to change line and character spacing 
    : LSP ( n -- )	' lsp :=! ;
    : CSP ( n -- )	' csp :=! ;
    
    long col
    long col1
    long row
    long row1
    byte vflg	--- 0= noscroll
    byte _scrolls
    
    '' bytes/line of text
    : b/l ( -- bytes )	cols lsp W* ;
    
    --- setup _scr to point to screen at current row and column
    pri @RC 		col @ row @ cols W* + SCR + scr' ! ;
    
    pub VXY    ( x y -- )	row ! col ! ;
    pub VXY>		col1 @ row1 @ VXY ;
    pub >VXY		col @ col1 ! row1 @ row1 ! ;
    
    --- Set how many rows the terminal will use where 0 = all 
    pub NS			0
    pub TERM ( lines -- )	rows lsp / MIN _scrolls C! 0 rows lsp - VXY csp ' lm :=! ;
    
    pri VHOME		0 TERM 0 0 VXY 480 lsp / _scrolls C! ;
    
    pri SCROLL
    	_scrolls C@ IF SCR SCRSZ + b/l _scrolls C@ W* - DUP b/l + SWAP b/l _scrolls C@ 1- W* 4/ LMOVE THEN
    	SCR SCRSZ + b/l - b/l PAPER@ FILL
    	lsp NEGATE row +!
    	;
    
    pri NEWLINE
        lm col !
        lsp row +!
        row @ lsp 1- + rows => IF SCROLL THEN
        ;
    
    --- draw a 5X7 font character
    pub VCH ( char -- ) --- 8.750us @300MHZ
    	7 W* FONT5X7A +
    	col @ rm => IF NEWLINE THEN
    	col @ row @ cols W* + SCR +
    	PAPER@
    	WRCH ( font' screen' pen.paper  -- )
    	csp col +!
    	;
    : BELL ;
    
    --- make the VGA display the current output device
    pub VGA
        EMIT:
    pub VEMIT ( ch -- )
        DUP 32 <
        IF
        SWITCH
          $00 CASE BREAK
          $01 CASE VHOME BREAK
          $07 CASE BELL BREAK
          $08 CASE col @ lm <> IF csp NEGATE col +! THEN BREAK
          $09 CASE  BEGIN 32 VCH col @ 7 AND 0= UNTIL BREAK
          $0A CASE NEWLINE BREAK
          $0C CASE CLRSCR VHOME BREAK
          $0D CASE lm col ! BREAK
          CASE@ ( unknown control - display as character )
        THEN
        VCH
        ;
    

    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Latest binary V5.4 includes EASYFILE +++++ Tachyon Forth News Blog
    P2 SHORTFORM DATASHEET +++++ TAQOZ documentation
    Brisbane, Australia
Sign In or Register to comment.