Shop OBEX P1 Docs P2 Docs Learn Events
Possible Reductin in double buffer memory using graphics.spin — Parallax Forums

Possible Reductin in double buffer memory using graphics.spin

RIT StudentRIT Student Posts: 4
edited 2009-01-30 18:49 in Propeller 1
Hello,

I am trying to use the propeller to run a game I wrote. To display images I am using graphics.spin & tv.spin. Unfortunately, the double buffering needed to prevent flicker severely limits the memory I have for the game itself. It seems that it might be possible to reduce the buffer size by 1/2 yet still retain a double buffer. To do this, you would sacrifice resolution in both the x and y direction by 2. My thought is that you treat each tile as an 8 x 8 . Then when TV converts the pixels to an NTSC signal, it will perform an "interpolation" to display the 16 x 16. That is, it will take the necessary steps to display a single pixel that is physically set in the bitmap memory, then set the proceeding pixel to display the exact same color. Has anyone attempted anything like this. It seem that this might involve a lot of changes to the algorithms in graphics.spin used to generate the shapes. Is there a quick change in graphics to treat tiles as 8 x 8 appose 16 x 16? If so I think I might be able to make changes to tv.spin to perform the 8 x 8 to 16 x 16 interpolation. If you don't understand what I am trying to say, please feel free to ask further questions. Any suggestions/hints would be appreciated.

Thanks
burger.gif

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-01-30 01:10
    You could certainly cut the size of the buffer to 1/4th of that used in the normal driver (1/2 x and 1/2 y). You'd have to change the actual TV.spin driver to do so and that's written in assembly ... not difficult to do, but not trivial. I don't know if this has already been done for the Hydra. You might look through the various Hydra I/O drivers. See this thread: http://forums.parallax.com/showthread.php?p=780158.
  • Erik FriesenErik Friesen Posts: 1,071
    edited 2009-01-30 01:50
    I haven't tried it but I suspect all you would need to do is set your TV driver to fewer tiles, and set the graphics driver accordingly. This will effectively make a smaller screen so you would have to rewrite your graphics calling routines.

    What I have done that works is make a large font with the TV_text by doing something similar, but if this will not work someone else will hopefully correct this idea.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2009-01-30 06:29
    RIT Student said...
    It seem that this might involve a lot of changes to the algorithms in graphics.spin used to generate the shapes. Is there a quick change in graphics to treat tiles as 8 x 8 appose 16 x 16? If so I think I might be able to make changes to tv.spin to perform the 8 x 8 to 16 x 16 interpolation.
    If you want all the functions it will require extensive changes to the graphics driver and you'll basically need to understand all of it before you start. Depending on what functions you are using it could be a lot easier though. If you don't use wide pixels or any of the rectangle/triangle/fill functions you should only have to change the plotp routine which shouldn't be too hard.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2009-01-30 06:30
    Erik Friesen said...
    I haven't tried it but I suspect all you would need to do is set your TV driver to fewer tiles, and set the graphics driver accordingly. This will effectively make a smaller screen so you would have to rewrite your graphics calling routines.

    What I have done that works is make a large font with the TV_text by doing something similar, but if this will not work someone else will hopefully correct this idea.
    Looks like a much easier approach.
  • JoJo Posts: 55
    edited 2009-01-30 18:14
    The other alternative to double buffering is the XOR graphics mode.
    SDM_graphics_XOR -> http://obex.parallax.com/objects/310/
    and the thread that discussed it: http://forums.parallax.com/forums/default.aspx?f=25&p=1&m=248864

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ---
    Jo
  • JetfireJetfire Posts: 34
    edited 2009-01-30 18:45
    You just setup graphics and tv to use a different size, and give them new start addresses for the buffers.


    CON
    
      _stack = ($C00 + $C00 + 100) >> 2   'accomodate display memory and stack
    
      x_tiles = 8
      y_tiles = 6
    
      paramcount = 14       
      bitmap_base = $6800
      display_base = $7400
    
    



    gr.setup(8, 6, 64, 48, bitmap_base)
    
    



    tvparams                long    0               'status
                            long    1               'enable
                            long    %001_0101       'pins
                            long    %0000           'mode
                            long    0               'screen
                            long    0               'colors
                            long    x_tiles         'hc
                            long    y_tiles         'vc
                            long    [b]20[/b]              'hx
                            long    [b]2[/b]               'vx
                            long    0               'ho
                            long    0               'vo
                            long    0               'broadcast
                            long    0               'auralcog
    
    



    Changing the expansion tells tv to double up horizontally and vertically.

    This gives you a resolution of 128x96 and uses about 6KB of hub ram instead of 24KB, assuming I did everything and got the math right.
  • RIT StudentRIT Student Posts: 4
    edited 2009-01-30 18:49
    Erik, I implemented your approach and it works. Basically, reduce the tiles in the x and y dimension by 2. Then in the TV driver there is a horizontal and vertical tile expansion factor. Doubled these values and it worked. Thanks for the help!
Sign In or Register to comment.