Shop OBEX P1 Docs P2 Docs Learn Events
Help with Pong Memory — Parallax Forums

Help with Pong Memory

RedcapRedcap Posts: 3
edited 2011-04-17 00:50 in Propeller 1
So I just got the Hydra a while ago and I have been studying and cramming all of this new information into my head, but now I'm stumped. I made Pong successfully and it was great and beautiful and I cried tears of joy. But then I added a "pause" function and now it wont compile and tells me:

"Object exceeds runtime memory limit by 17 longs"

How can I be out of memory already? It's not that big, I have the code attached here. I read about double buffering but I have no clue how to do graphics without the included graphics driver which seems to NEED double buffering. Can I open more cogs? Do I need to have less "if"s?

Please help this noob!

Comments

  • PerryPerry Posts: 253
    edited 2011-04-16 16:27
    You can remove every thing below "vecdef" and you are not useing NES_Read_Gamepad, get rid of that too
  • RedcapRedcap Posts: 3
    edited 2011-04-16 18:49
    Wow thanks! That helped a lot! :D
    I feel like this won't be permanent though, I'll write an ending sequence and I'll run out of memory again. Are there any other tricks I can do? And how exactly would I do single buffer? Is there another driver for that?
  • PerryPerry Posts: 253
    edited 2011-04-16 19:16
    Redcap wrote: »
    Wow thanks! That helped a lot! :D
    I feel like this won't be permanent though, I'll write an ending sequence and I'll run out of memory again. Are there any other tricks I can do? And how exactly would I do single buffer? Is there another driver for that?

    If this is going to stay a pong game you will have little success trying to make it single buffered.
    The double buffering makes it so you don't see all the changes you make between updates to the screen.

    The main problem is the wonky way that the buffers are allocated in the standard graphics and TV drivers. Memory is reserved from $3000 all the way up to the top of memory.

    This allocation is for the largest expected size of screen ( x_tiles * y_tiles)

    You could look at how it is done in my "Poor Man's Digital Oscilloscope" works. It is an adaptation of the way Phil Pilgrim used these drivers in his 3D project.

    This method shows more accurately how much memory you are really using

    but you will have to go through graphics.spin and make sure the methods that you need are still available.
  • RedcapRedcap Posts: 3
    edited 2011-04-16 19:28
    Ok so I downloaded the oscilloscope. Cool program, btw :D
    So the TV_Graphics.spin file looks like it is single buffered, am I right?
    And I know it might look messy, but I really need more memory. Would it work well if, instead of clearing and re-drawing:

    1. put a black dot over current pellet
    2. redraw pellet
    3. put black paddle over current paddle
    4. redraw paddle

    etc. That way the time between clearing and re-drawing is minimized? And there never really is any "clearing" at all.
  • PerryPerry Posts: 253
    edited 2011-04-16 20:13
    Redcap wrote: »
    Ok so I downloaded the oscilloscope. Cool program, btw :D
    So the TV_Graphics.spin file looks like it is single buffered, am I right?
    .

    No i't is double buffered. For anything that changes fast like action games it's very rare that they are not double buffered

    P.S.
    I just upload a new version of the "Poor Man's Digital Oscilloscope"
  • potatoheadpotatohead Posts: 10,261
    edited 2011-04-17 00:50
    You can do pong single buffered. The objects do not take all that long to draw.

    If it were me, I would not do a full screen clear.

    Use the tv_status flag to draw only during blanking times.

    During that blank, you have to erase both paddles, and the ball, then redraw them, leaving everything else alone. Optionally, you could erase and redraw the score, if it has changed.

    Using the small, black rectangle method you described would work very well. You could simply draw the objects twice too.

    During the blank, just draw them in black, at the current position, then draw them in whatever color you are using. That's it.

    So long as that drawing time doesn't exceed the blanking time, you are golden. No flicker will be seen.

    In my blog, I've got some single buffer example code that you might find interesting, though not necessary for a pong game.

    In graphics.spin, don't use the slower drawing primitives. Stick with basic lines, and such for the max speed. Text will be slow enough that you might have to be creative with that. One option I can think of, is to just update one character of the score per frame, or display the score graphically, with some dots, or something fast.
Sign In or Register to comment.