Shop OBEX P1 Docs P2 Docs Learn Events
[FYI] VGA, 40x15, single cog, per cell colour/palette, ROM font - Page 2 — Parallax Forums

[FYI] VGA, 40x15, single cog, per cell colour/palette, ROM font

2»

Comments

  • JRetSapDoogJRetSapDoog Posts: 954
    edited 2013-10-19 15:14
    @Marko: Great! That "saves" an additional 2K bytes. And thanks for pointing out localroger's "painless" interleaving/reversing technique!

    @localroger: Thanks for creating and sharing that great technique for keeping one's sanity in defining custom characters in a DAT section.
  • JRetSapDoogJRetSapDoog Posts: 954
    edited 2013-10-19 15:30
    So, I guess one can dispense with the font[] array in the VAR section if defining one's own font in a DAT section (someone correct me if I'm wrong).

    Marko's demo is cool, particularly the way it rotates the custom font (scroll-like). As another example, the code below is a rudimentary test that I made, which simply replaces Marko's "selftest" PUB method (and the VAR section may optionally be commented out):
    PUB selftest : c
    
      vga.init
      vga.str(string(vga#ESC, "s"))                         ' page mode
    
      vga.str(string($A,12,$B,2,"Custom Font Test"))
      vga.str(string($A,16,$B,5,"0 1 2 3"))
      vga.str(string($A,16,$B,6,"-------",$A,16,$B,7))
    
      repeat c from 0 to 3 'output 1st four ROM font characters
        vga.putc(c)
        vga.putc(" ")
    
      'non-changing chars (shows that chars>31 are constant)
      vga.str(string($A,7,$B,10,"abcdefghijklmnopqrstuvwxyz"))  
      vga.str(string($A,7,$B,11,"ABCDEFGHIJKLMNOPQRSTUVWXYZ"))
    
      repeat  'alternate between ROM and Custom fonts
        vga.setn(1, constant(NEGX|$8000))                   'use the ROM font for chars 0..31
        waitcnt(clkfreq*2+cnt)
        vga.setn(1, NEGX|@user_font)                        'use the custom font for chars 0..31  
        waitcnt(clkfreq*2+cnt) 
    
  • JRetSapDoogJRetSapDoog Posts: 954
    edited 2013-10-19 15:35
    And below is some sample custom font data (for 4 characters) for a DAT section to go along with the above test code:
    As suggested by kuroneko (Marko), this custom font-definition technique (the format/math) is from localroger (Roger Williams). Thanks to both!!
    DAT
    
    {
      *** This technique is from Roger Williams' vga_40x18_rom_demo.spin v1.1 ***
      
      The user defined chars must be reversed and interleaved like the ROM font,
      but in order to save memory they are only 16 pixels high.  This example
      shows a way to draw the font forward and un-interleaved so that the
      proptool will assemble it correctly.  Draw the left/lsb=0 character with
      2's and the right/lsb=1 character with 1's.  The reverse and add
      operations will take care of the interleave.
    }
    
    user_font   'beginning address of user's custom font data
    
            'Custom Font Data for Chars 0 & 1
    C00_01  long  %%22222222_22222222 >< 32 + %%11100000_00000111 >< 32
            long  %%22222222_22222222 >< 32 + %%11100000_00000111 >< 32
            long  %%22222222_22222222 >< 32 + %%11100000_00000111 >< 32
            long  %%22200000_00000222 >< 32 + %%01110000_00001110 >< 32
            long  %%22200000_00000222 >< 32 + %%01110000_00001110 >< 32
            long  %%22200000_00000222 >< 32 + %%01110000_00001110 >< 32
            long  %%22200000_00000222 >< 32 + %%00111000_00011100 >< 32
            long  %%22200000_00000222 >< 32 + %%00111000_00011100 >< 32                                                      
            long  %%22200000_00000222 >< 32 + %%00111000_00011100 >< 32
            long  %%22200000_00000222 >< 32 + %%00011100_00111000 >< 32
            long  %%22200000_00000222 >< 32 + %%00011100_00111000 >< 32
            long  %%22200000_00000222 >< 32 + %%00011100_00111000 >< 32
            long  %%22200000_00000222 >< 32 + %%00001110_01110000 >< 32
            long  %%22200000_00000222 >< 32 + %%00001110_01110000 >< 32
            long  %%22200000_00000222 >< 32 + %%00001110_01110000 >< 32
            long  %%22200000_00000222 >< 32 + %%00000111_11100000 >< 32
            long  %%22200000_00000222 >< 32 + %%00000111_11100000 >< 32
            long  %%22200000_00000222 >< 32 + %%00001110_01110000 >< 32
            long  %%22200000_00000222 >< 32 + %%00001110_01110000 >< 32
            long  %%22200000_00000222 >< 32 + %%00001110_01110000 >< 32
            long  %%22200000_00000222 >< 32 + %%00011100_00111000 >< 32
            long  %%22200000_00000222 >< 32 + %%00011100_00111000 >< 32
            long  %%22200000_00000222 >< 32 + %%00011100_00111000 >< 32
            long  %%22200000_00000222 >< 32 + %%00111000_00011100 >< 32
            long  %%22200000_00000222 >< 32 + %%00111000_00011100 >< 32
            long  %%22200000_00000222 >< 32 + %%00111000_00011100 >< 32
            long  %%22200000_00000222 >< 32 + %%01110000_00001110 >< 32
            long  %%22200000_00000222 >< 32 + %%01110000_00001110 >< 32
            long  %%22200000_00000222 >< 32 + %%01110000_00001110 >< 32
            long  %%22222222_22222222 >< 32 + %%11100000_00000111 >< 32
            long  %%22222222_22222222 >< 32 + %%11100000_00000111 >< 32
            long  %%22222222_22222222 >< 32 + %%11100000_00000111 >< 32
    
            'Custom Font Data for Chars 2 & 3
    C02_03  long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32                                                    
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
            long  %%22222200_00000000 >< 32 + %%00000000_00111111 >< 32
    
Sign In or Register to comment.