Shop OBEX P1 Docs P2 Docs Learn Events
Question about VGA_Demo — Parallax Forums

Question about VGA_Demo

I've been looking at the VGA_Demo program which can be found in the OBEX

obex.parallax.com/object/645

I'm a little confused because of the following:
''***************************************
''* VGA Terminal 40x15 v1.0 *
''* Author: Chip Gracey *
''* Copyright (c) 2006 Parallax, Inc. *
''* See end of file for terms of use. *
''***************************************

CON

_clkmode = xtal1+pll16x
_clkfreq = 80_000_000

vga_params = 23
cols = 32
rows = 16
screensize = cols * rows

Where the confusion comes from is simple...
I see it uses the internal font found in the Propeller 1 Microcontroller.

And each font character is 16px wide by 32px high

In the very top of the source code it says..
''* VGA Terminal 40x15 v1.0 *

I understand that to be 40 columns and 15 rows

And yet in the source itself it defines 32 columns and 16 rows...
So which one is the right one?


Thank You

Jaan

Comments

  • jmgjmg Posts: 15,148
    JaanDoh wrote: »
    And yet in the source itself it defines 32 columns and 16 rows...
    So which one is the right one?

    Usually, real source trumps comments, which can be out of date...

  • Hiya JMG,
    Thank You for the response,
    it's much appreciated.

    Although I have not tried the code,

    That means the resolution of the screen is 512 x 480?
    (based on character size)

    Yet further in the code it also says...
    vgaparams long 0 'status
    long 1 'enable
    long %010_111 'pins
    long %011 'mode
    long 0 'videobase
    long 0 'colorbase
    long cols 'hc
    long rows 'vc
    long 1 'hx
    long 1 'vx
    long 0 'ho
    long 0 'vo
    long 512 'hd
    long 16 'hf
    long 96 'hs
    long 48 'hb
    long 380 'vd
    long 11 'vf
    long 2 'vs
    long 31 'vb
    long 20_000_000 'rate
    (Sorry for the spacing - it hasn't retained the spacing as in the code)

    Which doesn't match?

  • Without looking at the code, I can tell you a 16x32 pixel font that has a 40x15 character screen, is a 640x480 pixel screen.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2017-02-27 03:00
    The font is 16 wide by 32 high, so 32 high by 15 rows = 480 which is the value that I have in VGA driver in Tachyon, not 380.

    If it helps, this is the initialization values that I use in Tachyon. Only the PASM part of the driver is used and stored in upper EEPROM as a "ROM" to load into a cog at runtime on demand. Should be easy enough to follow.
    TABLE vgapars PRIVATE
        0 ,                --- 0:status              ' 0/1/2 = off/visible/invisible - read-only
        1 ,                --- 1:enable              ' 0=off (disabled completely)
        16 7 + ,           --- 2:pins                ' vga pin group 0,8, or 16.
        %1000 ,            --- 3:mode                ' %tihv = tile,interlace,hpol,vpol   write-only
        vgabuf , colors ,  --- 4:screen 5:colors     ' pointers to screen (words) and colors (longs)
        32 , 15 ,          --- 6:cols 7:rows         ' horz and vert tiles (characters)
        1 , 1 ,            --- 8:hx 9:vx             ' horz and vert tile expansion
        0 , 0 ,            --- 10:ho 11:vo           ' horz and vert offset
        512 , 10 ,         --- 12:hd 13:hf           ' horz display ticks, front porch
        75 , 43 ,          --- 14:hs 15:hb           ' horz synch ticks, back porch
        480 , 11 ,         --- 16:vd 17:vf           ' vert display lines, front porch
        2 , 31 ,           --- 18:vs 19:vb           ' vert synch lines, back porch
        CLKFREQ 2 >> ,     --- 20:rate		 ' tick rate (Hz)
    
  • Thank You both Ke4pjw and Peter Jakacki,

    You are both right in what you say.
    And together with what Jmg wrote, (importantly - source trumps comments)
    Your'e all right.

    So in fact the comments are wrong and the code has a slight minor typo.
    Well that's cleared up everything nicely.


    Moving on in the VGA_Demo code found in the link in my first thread in this post...

    In the Public method begin
    the first statement is ...
    start(%010111)

    This line passes the pins config to the method called start
    and the comments towards the end of the DAT section explain the following...
    '' ________
    '' vga_pins
    ''
    '' bits 5..3 select pin group:
    '' %000: pins 7..0
    '' %001: pins 15..8
    '' %010: pins 23..16
    '' %011: pins 31..24
    '' %100: pins 39..32
    '' %101: pins 47..40
    '' %110: pins 55..48
    '' %111: pins 63..56
    ''
    '' bits 2..0 select top pin within group
    '' for example: %01111 (15) will use pins %01000-%01111 (8-15)

    In the example above there are only 5 bits not 6
    and bits 5 to 3 are x01 where x is missing
    because %001111 is the same as %01111
    so this is pin group 15 to 8

    but bits 2 to 0 are 111 so how do I arrive at 8 (for pin 8)?



    Thank You for your input and patience.


    Jaan


  • I found some good working vga demo's on the Obex. Kwabena W Agyeman wrote a couple of good examples that work straight of the Box
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2017-02-27 04:12
    start(%010111) has %010 for bits 3 to 5 so that is pin group 16..23. The bottom two bits look like they are shortform for the VPins field (00001111 or 11110000 or 11111111) so %11 would be all 8 pins which is correct. (btw, I just guessed for the Vpins as I see there are 3 bits there, so I will go check and correct).



    EDIT: That's right, the basepin is offset by +7 which is correct. Forget the Vpins guess.

    btw, if you ran this in Tachyon you would be able to interactively play with all these values
    709 x 544 - 60K
  • Thank You

    That's answered my question.

    I gotta get time to try this out now.


    Jaan
Sign In or Register to comment.