Shop OBEX P1 Docs P2 Docs Learn Events
Problem creating a new text font for 1280x1024 tile driver.... — Parallax Forums

Problem creating a new text font for 1280x1024 tile driver....

DToolanDToolan Posts: 11
edited 2011-08-23 02:49 in Propeller 1
I am trying to create a 16 x 16 font using the "VGA Text Generic Demo" for the 1280x1024 tile driver. The original "VGA Text Generic Demo" uses the Parallax 16x32 ROM fonts. In creating a set of 16x16 fonts, I use the same format as the Parallax ROM fonts do (merging two characters into a LONG and then mirroring the LONG). The ROM font construction is detailed in the Parallax manual.

So... I have only made two characters to test out the process (B&C merged and mirrored). I adjusted the demo code so that no matter what characters it is trying to print (it is trying to print "VGA_Text_Generic_Driver "), it will always point to my "B" font and print all "B" characters (for testing).

The problem is... on each line, I only get the first couple of pixel rows of the "B" character from my font and then garbage pixel rows fill out the remaining 16x16 tile (and I dunno' why). If I knew why, of course, there wouldn't be a problem :-)

<edit> I am finding that it has something to do with the base address (where @font actually resides). I can get more or less of my character to display by padding longs before the "font" declaration in the DAT section or taking some away. If "font" is the VERY FIRST section declared in the DAT, I get about 3/4 of my character. This seems to be a memory alignment issue. Is there a directive for block alignment or some way I can memory align these fonts so the tile driver picks them up properly?

<edit #2> If I pad the DAT section with 10 LONGs prior to the font declaration... I get the full characters displayed. Seems like a waste of memory in order to align this data... but that's my fix for now?

Demo Code Character Printing...
PRI out(c) | i, j, k

'' Print a character
''
''       $0D = new line
''  $20..$FF = character
''      $100 = clear screen
''      $101 = home
''      $108 = backspace
''$110..$11F = select color

  case c
    $0D:                'return?
      newline

    $20..$FF:           'character?
     'k := crayon << 1 + c & 1         'k (color) selects the even or odd bits of the two merged font characters
      k := crayon << 1 + $00 & 1     'force any character to be $00 for testing  
      i := $200 + (c & $FE) + k << 10 'we aren't using i right now... this is for the Parallax ROM fonts

      j := @font >> 6                '<- my font... this leaves the upper 10 bits of the font address shifted right
      j := j + ($00 & $FE) + k << 10 
      
      array.word[row * cols + col] := j

      if ++col == cols
        newline

     '...other code that is not pertinent to character printing

New Line Adjustment for 16x16 characters instead of 16x32...
PUB newline | i

  col := 0

{ if (row += 2) == rows
    row -= 2
    'scroll lines
    repeat i from 0 to rows-3
      wordmove(@array.word[i*cols], @array.word[(i+2)*cols], cols)
    'clear new line
    wordfill(@array.word[(rows-2)*cols], spacetile, cols<<1) }

  if (row += 1) == rows
    row -= 1
    'scroll lines
    repeat i from 0 to rows-2
      wordmove(@array.word[i*cols], @array.word[(i+1)*cols], cols)
    'clear new line
    wordfill(@array.word[(rows-1)*cols], spacetile, cols<<1)
DAT section containing font...
DAT
{
Character "B" in 16x16 16-bit binary format

word %0000000000000000
word %0011111111000000
word %0011000000110000
word %0011000000011000
word %0011000000011000
word %0011000000110000
word %0011111111100000
word %0011000000110000
word %0011000000011000
word %0011000000011000
word %0011000000011000
word %0011000000110000
word %0011111111000000
word %0000000000000000
word %0000000000000000
word %0000000000000000

Character "C" in 16x16 16-bit binary format

word %0000000000000000
word %0000001111000000
word %0000110000110000
word %0001100000011000
word %0001100000000000
word %0011000000000000
word %0011000000000000
word %0011000000000000
word %0011000000000000
word %0001100000000000
word %0001100000011000
word %0000110000110000
word %0000001111000000
word %0000000000000000
word %0000000000000000
word %0000000000000000

My characters "B" AND "C" MERGED into 32-bit x 16 row binary format

long %00000000000000000000000000000000
long %00001010101011111111000000000000
long %00001010010100000000111100000000
long %00001011010000000001011010000000
long %00001011010000000000001010000000
long %00001111000000000000101000000000
long %00001111101010101010100000000000
long %00001111000000000000101000000000
long %00001111000000000000001010000000
long %00001011010000000000001010000000
long %00001011010000000000001111000000
long %00001010010100000000111100000000
long %00001010101011111111000000000000
long %00000000000000000000000000000000
long %00000000000000000000000000000000
long %00000000000000000000000000000000
}

'Characters "B" AND "C" MERGED and then MIRRORED in 32-bit x 16 row binary format
'color will select either the even or odd bits (thus selecting either the "B" or the "C")
font
long $00000000 '%00000000000000000000000000000000
long $000FF550 '%00000000000011111111010101010000
long $00F00A50 '%00000000111100000000101001010000
long $016802D0 '%00000001011010000000001011010000
long $014002D0 '%00000001010000000000001011010000
long $005000F0 '%00000000010100000000000011110000
long $001555F0 '%00000000000101010101010111110000
long $005000F0 '%00000000010100000000000011110000
long $014000F0 '%00000001010000000000000011110000
long $014002D0 '%00000001010000000000001011010000
long $03C002D0 '%00000011110000000000001011010000
long $00F00A50 '%00000000111100000000101001010000
long $000FF550 '%00000000000011111111010101010000
long $00000000 '%00000000000000000000000000000000
long $00000000 '%00000000000000000000000000000000  
long $00000000 '%00000000000000000000000000000000

Comments

  • RaymanRayman Posts: 14,876
    edited 2011-08-23 02:49
    One thing you might be facing is that user characters have to be aligned to a 16-long boundary. This is because the lower 6 bits of the address are assumed to be equal to zero...

    If you look on my website, I have some 1-bit and 2-bit bitmap tools and examples....
Sign In or Register to comment.