Shop OBEX P1 Docs P2 Docs Learn Events
VGA learning driver — Parallax Forums

VGA learning driver

dfletchdfletch Posts: 165
edited 2009-04-11 18:59 in Propeller 1
Hi all!

I spent a week of evenings and two weekends slaving away to understand the VGA signal and how to implement it on the Prop. Some of the information was hard to find and it was in several different documents, so I've documented the whole thing in comments.

So I give you the most verbosely commented (and hopefully the simplest) VGA driver ever written!

Enjoy!

Cheers,

--fletch

file history
0.1 - Initial revision
0.2 - Fixed a couple of minor typos and adds a bibliography and more useful readme.
0.3 - Configurable color, some error corrections, and the acid test. WARNING: Do not take psychedelic drugs and run the acid test!
0.4 - Very early rev of a driver that can read a single line of pixel data from a buffer.
0.5 - Stabilized line driver. Still needs comments.
0.6 - Comments. Bit of animation on the line driver test.
0.7 - Improved VGA Learn driver with new information learned while building line driver. Improved comments everywhere. Fixed a couple of incorrect numbers in comments. Slowed the VGA Line Driver Test animation to more easily see the effect. Simplified unnecessary code in configuration pointers.

Post Edited (dfletch) : 2/9/2008 7:39:56 PM GMT

Comments

  • dfletchdfletch Posts: 165
    edited 2008-02-05 05:58
    Oh, and I am of course open to any / all suggestions for improvements!

    Thanks smile.gif

    --fletch
  • ColeyColey Posts: 1,110
    edited 2008-02-05 08:54
    Hi Fletch,

    this is great work thanks!

    I think there needs to be more drivers like this that help the no so adept programmers.

    Regards,

    Coley
  • AleAle Posts: 2,363
    edited 2008-02-05 09:28
    This is great info for the wiki, do you mind adding it ?

    Some weeks ago I spent countless hours trying to bend my monitor to accept a 320x240 mode, I hope this time I'll have more luck !.

    Great work !!
  • crgwbrcrgwbr Posts: 614
    edited 2008-02-05 16:05
    Thanks a lot! (especially for the bibliography) As much as I hate to admit it, I've had a lot of trouble trying to figure out how video works. This helped quite a bit. Their just doesn't seem to be quite enough documentation on how objects like the VGA, TV, and Graphics driver actually work.

    Thanks Again,
    Craig

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My system: 1.6 GHz AMD Turion64 X2, 4GB DDR2, 256MB ATI Radeon Graphics card, 15.4" Widescreen HD Screen

    I have a duel boot of Ubuntu Linux and Windows Vista. Vista, because it came with the PC, Ubuntu because I like software that works.

    "Failure is not an option -- it comes bundled with Windows."

    Use The Best...
    Linux for Servers
    Mac for Graphics
    Palm for Mobility
    Windows for Solitaire

    Post Edited (crgwbr) : 2/5/2008 4:12:36 PM GMT
  • dfletchdfletch Posts: 165
    edited 2008-02-05 18:35
    Great, I'm so glad you guys like it!

    I have a couple ideas for improvement already, I'll post a new version tonight with a couple corrections and the ability to change the color after calling start. I wanted to get started a bit here at the office, but the Prop Tool doesn't work so hot in Wine (hint, hint Parallax!)

    Coley: well I'm pretty new at this myself (you may have noticed my low forum post count) ... but I don't mind writing down what I find as I go. If I write drivers for other devices I'll be sure to keep up the verbosity and try to build things in the most straightforward way possible.

    Ale: Well I'd rather not copy the whole thing and maintain a whole separate version (as I said above, I already have changes in mind). How about for now we just link from the wiki to this thread?

    Crgwbr: Yep, I was having the same exact troubles understanding those drivers. The code is densely packed and unless you know all the Propeller Assembly instructions very well, it's really easy to get lost in them! So I've removed certain oddities of the VGA.spin driver (most notably, work between active video sections, interlacing support, tile support, support for configured modes), leaving only what's necessary to drive the monitor at 640x480.

    Thanks all for the terrific positive response!

    Cheers,

    --fletch
  • dfletchdfletch Posts: 165
    edited 2008-02-08 03:36
    Wow after having made this and had a few days to mess around, it's *really* tough to move data in fast enough to do real work.

    I'm guessing I'll have to take full advantage of the relative idleness of the porch/sync sections smilewinkgrin.gif

    Hopefully I'll have an update this weekend with the ability to drive a single line worth of data.

    Cheers,

    --fletch
  • dfletchdfletch Posts: 165
    edited 2008-02-08 06:23
    Whoa and then I got it! Well sort-of. It manages to call RDLONG twice (!!) between WAITVID calls devil.gif

    However, things seem shifted over just a shade (like 1 frame perhaps). I could use a hand debugging this a bit if anyone feels like looking. This may be due to a prob with the original learning driver, since I'm still very new to VGA.

    If you feel like peeking, run VGA Line Driver Test.spin, and I'm fairly certain the issue is in lines 88-100 of VGA Line Driver.spin

    Cheers!

    --fletch

    UPDATE: aaaah! now it's not syncing! Dang. Oh well I'll try some more tomorrow Sorry for the noise smile.gif

    Post Edited (dfletch) : 2/8/2008 7:00:59 AM GMT
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-08 07:28
    Feel free to tell us about your progress! There are some experts out here for TV and VGA who can and will help you when you have run into problems. Of course it is more fun to do it all by yourself.

    Just an idea: What is needed from time to time is a monochromious solution.. There are drivers for it (e.g. VGA_512x386_Bitmap) but GRAPHICS has to be adapted to it. None of my students has been bold enough to try that.... Graphics is a very demanding piece of code...
  • dfletchdfletch Posts: 165
    edited 2008-02-08 08:34
    Haha! Monochrome, eh?

    How about a fully working full color line driver!

    I doubled FRQA and set VSCL to 2 pixel clocks / 32 frame and the weird shift went away.

    I then moved part of the back porch (16 px worth) to the front of the loops, rather than the end, and voila, sync!

    I'm going to make some demos devil.gif Is there a Prop demoscene?
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-08 16:07
    Monochrome GRAPHICS would be more useful...
  • BaggersBaggers Posts: 3,019
    edited 2008-02-08 20:03
    Surely deSilva, you could still use this driver, and set the 6 pins ( 2R2G2B ) to be sent to all R,G & B ? and have 64 shades of grey?
    or just have 4 shades of grey setting the 2R, 2G and 2B values to the same numbers.

    PS dfletch, excellent work, and a very warm welcome to the forum [noparse]:)[/noparse]
    if you want, I'd like to help make this into a 320x240 display 64 colours, line renderer, like the tv game drivers.

    if not, I'll probably do it anyway [noparse]:)[/noparse] cos it needs doing lol.
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-08 21:22
    This is a misnderstanding smile.gif I need no driver, they exist.... I alone have 10 or so... . I need a 2-color GRAPHICS.SPIN
  • BaggersBaggers Posts: 3,019
    edited 2008-02-08 23:08
    ah, ok, now I get ya [noparse]:)[/noparse]
  • dfletchdfletch Posts: 165
    edited 2008-02-09 03:05
    Baggers: Yes I'd love to support more resolutions.

    The idea behind this driver of course is to keep things as simple as possible. I'd like to see all config calculations done in spin, so it's easier to understand what's happening.

    There could be a few longs worth of "padding pix" as my tutorial calls them that are configured in the start method to control the porches and sync sections. Of course, all the hard coded values at the bottom of the current driver would be configurable from outside too.

    Does this align with what you are thinking, or is it not too far off?

    Cheers,

    --fletch

    UPDATE: Hmm maybe I've changed my mind and it could just be a separate "spin off" driver packaged in there. One of the things I'm liking about the current driver is how tiny it is! If we start doing configs we complicate things *and* make bigger.

    Post Edited (dfletch) : 2/9/2008 3:15:46 AM GMT
  • cgraceycgracey Posts: 14,255
    edited 2008-02-09 06:43
    Fletch, good job. This is also a good tool for understanding WAITVID.

    I did noticed one·minor thing that could be optimized:

    ······················· RDLONG t2, t1·················· ' _pinvcfg
    ······················· MOV VCFG, t2
    ······················· ADD t1, #4
    ······················· RDLONG t2, t1·················· ' _diracfg
    ······················· MOV DIRA, t2
    ······················· ADD t1, #4
    ...could become...

    ······················· RDLONG VCFG, t1·················· ' _pinvcfg
    ······················· ADD t1, #4
    ······················· RDLONG DIRA, t1·················· ' _diracfg
    ······················· ADD t1, #4

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-09 08:17
    Reading Chapter 7 in deSilva's "Tutorial" also furthers the understanding of WAITVID smile.gif
  • BaggersBaggers Posts: 3,019
    edited 2008-02-09 10:33
    lol dfletch,
    Keeping it compact is good, and hard coding some numbers, isn't such a bad thing, as they can be documented, so people will still know how to change things. and it'll keep it tiny. [noparse];)[/noparse]
    Although after tinkering with it, for 320x240, I'm thinking it's going to have to be two cogs, one to fetch a line, and the other displaying, as there's VERY little time, between waitvids especially for 4 (all be it fat) pixels.

    Will keep you posted on my progress though, as I don't have much free time at the mo, as my mum died on Tuesday [noparse]:([/noparse]

    Baggers.
  • dfletchdfletch Posts: 165
    edited 2008-02-09 16:14
    Chip: Aha yes. I got burned early on trying to do something like `WRLONG cnt, somewhere` and I've put some kind of barrier up in my brain saying "don't RD/WRLONG on registers you don't control" which is obviously like screwing in a screw with a hammer smile.gif I'll fix it.

    deSilva: Yes everyone should read that! This thing in no way of course is meant to be any sort of replacement for those invaluable docs. Anyone reading this who hasn't read it, do so now!

    Baggers: Dang, that's awful about your mother, I'm so sorry. There is of course no pressure from me on your driver, I don't even know if I have a display that could be driven so low! So take your time and I'll include it whenever you're ready.

    I'll have an update later today with lots of minor corrections, stuff I learned from the line driver rolled back into the learning driver, and simpler config pointer reading, as per Chip's suggestion.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-04-11 16:46
    The article to which dfletch makes reference in VGAlearn is a dead link, I think. But I do believe I found the same article at this location.


    faculty.lasierra.edu/~ehwang/public/mypublications/VGA%20Monitor%20Controller.pdf

    For a newbie like me, this looks like a very good article!

    My thanks to Bob Lawrence for leading me to it. And thanks to dfletch for providing VGA code with comments and explanations!

    Mark

    smile.gif
  • dfletchdfletch Posts: 165
    edited 2009-04-11 18:29
    I moved it but I'm surprised the old link is broken. Here's the new home:

    http://fletchtronics.net/vga-learning-driver

    Cheers,

    --fletch

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
    Newbies, oldies, programmers, math professors, and everyone in-between welcome!
    Propeller IRC howto
    spinc - open source Spin compiler
  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-04-11 18:38
    Fletch,

    I was talking about the article written by Enoch Hwang, not the link to your folder download. Sorry about the confusion.

    Hey, but many thanks for posting this material for us newbies to learn from!


    smile.gif
  • dfletchdfletch Posts: 165
    edited 2009-04-11 18:40
    Ahhh darn, that was a PDF if I remember correctly. I wish I had downloaded it. Maybe I have a copy, if I dig one up I'll post it.

    Cheers,

    --fletch

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
    Newbies, oldies, programmers, math professors, and everyone in-between welcome!
    Propeller IRC howto
    spinc - open source Spin compiler
  • dfletchdfletch Posts: 165
    edited 2009-04-11 18:59
    Weird you know what? That link is working fine for me. Maybe you're having a temporary connection issue.

    Cheers,

    --fletch

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
    Newbies, oldies, programmers, math professors, and everyone in-between welcome!
    Propeller IRC howto
    spinc - open source Spin compiler
Sign In or Register to comment.