Shop OBEX P1 Docs P2 Docs Learn Events
Graphics driver — Parallax Forums

Graphics driver

FredBlaisFredBlais Posts: 380
edited 2009-09-18 13:13 in Propeller 1
I would like to learn to design my own graphics driver, so I tried to reverse engineer the parallax driver, but it was a bit unsuccessful. I'm not that level yet!
Does some of you know where I can find a good references (book or web page) how to design simple graphics functions to interface with the buffer of a VGA driver?
What I was thinking is not a sprite/tile driver, but a more general driver for drawing primitives and maybe more advanced stuff like GUI widgets, graphs etc...

Comments

  • Ken PetersonKen Peterson Posts: 806
    edited 2009-09-16 17:23
    Try "Game Programming for the Propeller Powered HYDRA" by Andre LaMothe. It has lots of in-depth information about how the propeller video works.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I have not failed. I've just found 10,000 ways that won't work. "
    - Thomas A. Edison
  • FredBlaisFredBlais Posts: 380
    edited 2009-09-16 17:36
    I have read the entire book, I own a Hydra. But it is more about games engine than GUI engine.
  • KyeKye Posts: 2,200
    edited 2009-09-16 21:37
    Err, well his driver is in asm while doing some pretty advanced math... and then bitmap functions. You can learn how it works but it will take you forever. If you don't know asm then start learning how something simple like the vga driver works. Then try to learn how the graphics driver works.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • ericballericball Posts: 774
    edited 2009-09-17 17:49
    FredBlais said...
    I would like to learn to design my own graphics driver, so I tried to reverse engineer the parallax driver, but it was a bit unsuccessful. I'm not that level yet!
    Does some of you know where I can find a good references (book or web page) how to design simple graphics functions to interface with the buffer of a VGA driver?· What I was thinking is not a sprite/tile driver, but a more general driver for drawing primitives and maybe more advanced stuff like GUI widgets, graphs etc...
    Although the Propeller has some special hardware which can be used to generate a video signal, it has to be controlled by a display driver (i.e. TV.spin, VGA.spin or the drivers in my sig) to generate an actual video signal.· The driver is responsible for translating data (typically stored in HUB RAM) into inputs to the video registers.· Sometimes a separate graphics driver is used to translate higher level constructs into the data used by the display driver.

    One of the limitting factors for a·Propeller display driver is the amount of HUB RAM which can be dedicated to the task.· A 640x480x8bpp VGA frame buffer requires 300K and thus won't fit into 32K HUB RAM.· Display drivers therefore use tiles and sprites to reduce the amount of HUB RAM required, although at the cost of flexibility.

    Now, if you have some kind of external RAM which can be used as a frame buffer, then I'd recommend some of the old VGA books.· I have Richard F. Ferraro's Programmer's Guide to the EGA, VGA, and Super VGA Cards at home somewhere, and I think it covered a lot of basic 2D graphics functions.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: Forum
    NTSC & PAL driver templates: ObEx Forum
    OnePinTVText driver: ObEx Forum
  • Agent420Agent420 Posts: 439
    edited 2009-09-17 18:13
    > What I was thinking is not a sprite/tile driver, but a more general driver for drawing primitives and maybe more advanced stuff like GUI widgets, graphs etc...


    As inferred above, this is really a two part question...· Creating the graphics vs displaying them.

    Though it is tile based, have you seen the HiRes Text VGA GUI driver?· It demonstrates the GUI aspects.· Combined with studying the VGA Bitmap driver, that kind of encapsulates much of what you may be looking for.

    edit -

    One thing to keep in mind is that bitmapped buffers require substantial memory resources.· Often you can 'fake' graphics on the screen using custom tiles in strategic places.

    Another good resource I would suggest is Raymond Allen's website, he has some good demos which really helped me as I am writing my Prop InVGAders code.


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


    Post Edited (Agent420) : 9/17/2009 7:31:57 PM GMT
  • FredBlaisFredBlais Posts: 380
    edited 2009-09-17 20:39
    ericball said...
    Now, if you have some kind of external RAM which can be used as a frame buffer, then I'd recommend some of the old VGA books.· I have Richard F. Ferraro's Programmer's Guide to the EGA, VGA, and Super VGA Cards at home somewhere, and I think it covered a lot of basic 2D graphics functions.
    you mean, like the hydra extreme ram·card? do you think that this·RAM is fast enough for the·purpose?·thanks for the book hint!
    Agent420 said...
    Though it is tile based, have you seen the HiRes Text VGA GUI driver?· It demonstrates the GUI aspects.· Combined with studying the VGA Bitmap driver, that kind of encapsulates much of what you may be looking for.
    I'll take a peek, looks like what I'm looking for [noparse]:)[/noparse]
  • VIRANDVIRAND Posts: 656
    edited 2009-09-18 05:57
    In as few words as I can explain GUI graphics elements:
    The different standard resolutions plot each pixel using a different equation to find the byte with the pixel in it.
    Standard VGA mode 13 is 320x200 with 256 colors available for 1 pixel per byte, and buffer address offset
    corresponds to a one dimensional array consisting of 320 bytes representing each a pixel, followed by the
    next row down and so on 200 times for each row. It is the easy one on a PC but not on a Propeller, which has
    different ones that were/are/willbe carefully optimally designed for Propeller.

    plot, unplot, and not essential but useful readpixelcolor x,y are the starting points.
    Lines can be made generally by moving on the axis which they are longest by counting from start to end
    on that coordinate, and using a fraction to find where along the other coordinate points should be plotted.
    The fraction can be avoided by a different method, since division is slow.
    Rectangles can be made simpler, with opposite corners x,y and a,b: while plotting count from x to a, then y to b,
    then a to x, then b to y.
    Filled rectangles: count from x to a within the process of counting from y to b (nested loop).
    Filled circles: relative to the center, pixels whose x*x+y*y is less than or equal radius*radius are plotted.
    Open circles: relative to the center, pixels whose x*x+y*y is nearly equal to radius*radius are plotted.
    (how nearly determines circle thickness)
    Open circles and ellipses and spirographs and other curves can be done relative to the center using
    x=cos(n)*radius:y=cos(n)*radius where n counts from 0 to 2pi in steps that get smaller with larger circles,
    probably radius/pi steps. Needs non-integer math.
    Filling weird shapes including closed mazes is done most simply by putting all adjacent unfilled pixel coordinates on
    a stack, and then pulling off all coordinates and plotting them, although this hogs memory and should be optimized
    at least by making sure no pixel is put on the stack more than once.
    Filled triangles, I don't know the math now but similar to making 2 or 3 lines at the same time.
    Filled trapeziums can be filled by another image, useful in virtual realities as textures, also related to simultaneous
    line drawing.
    Making text is easy with bitmap fonts, just copy them onto the screen, use OR logic, or AND NOT logic to make
    them background-transparent. They may be made of 8x8 blocks of pixels and have limited choices of size.
    I do not know how non-bitmap scalable fonts usually work, especially curvy ones, but an obvious method
    would be to make them with a drawing tablet and storing the directions the pen moved, which could be
    multiplied by any number to get any size.
    Making windows on a Propeller is best done with special characters that are re-used many times on the
    sides of a window plus 4 for the corners of a window plus ones for making clickable buttons, unless you
    are making a GUI for a flying saucer in Area 51 or a Federation of Planets Starship or a TARDIS.
    Cursors and Mouse pointers may simply use XOR logic, or else the area covered will need to be stored and replaced
    whenever they move.
    OR logic: binary 1 is preferred in the result (maybe white letters over background)
    AND NOT logic:binary 0 is preferred in the result (maybe black letters over background)
    XOR logic: do it once, something appears, do it again and it disappears, but tends to mix with background colors.
  • Agent420Agent420 Posts: 439
    edited 2009-09-18 10:35
    ^

    Though 320x200 may technically be a vga resolution (probably considered more cga), I tend to think 640x480 at a minimum and 1024x768 as most common (I think many people think of xga+ displays simply as vga).

    If you do a Google you will find a lot of information on graphic techniques...· I'd guess most are based on Bresenham's algorithms.

    As for cursors and such, it may be of value to investigate how Chip's vga demos display them; he uses an additional cog to generate video overlay for the cursor, similar to how hardware sprites are generated.· Sprites have the advantage of not having to manipulate the main bitmap memory array; they are just superimposed on top of the existing graphics.·


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • ericballericball Posts: 774
    edited 2009-09-18 13:05
    FredBlais said...
    ericball said...
    Now, if you have some kind of external RAM which can be used as a frame buffer, then I'd recommend some of the old VGA books.· I have Richard F. Ferraro's Programmer's Guide to the EGA, VGA, and Super VGA Cards at home somewhere, and I think it covered a lot of basic 2D graphics functions.
    you mean, like the hydra extreme ram·card? do you think that this·RAM is fast enough for the·purpose?·thanks for the book hint!
    I'm not sure it would be possible.· The typical pixel clock frequency for 640x480x60 VGA is 25.175·MHz.· Since a single PASM instruction requires 4 CLK cycles, that means you'd need a 100MHz CLK just to fetch the data from memory.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: Forum
    NTSC & PAL driver templates: ObEx Forum
    OnePinTVText driver: ObEx Forum
  • FredBlaisFredBlais Posts: 380
    edited 2009-09-18 13:13
    To ericball-> I just bought F. Ferraro's book on amazon, not the 1996 version you have, but the 2004 version. This book is really old!
    To VIRAND-> I think I might start with simple routine like the ones you enumerated, there is a good tutorial on how to plot pixels in the Tile Bitmap Memory in the hydra book. I won't try to rewrite TV.spin or VGA.spin, but I'll start to do my own Graphics.spin
Sign In or Register to comment.