Help with Pong Memory
Redcap
Posts: 3
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!
"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
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.
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.
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"
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.