View Single Post
Old 10 April 2022, 19:22   #5
Havie
Registered User
 
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,895
Quote:
Originally Posted by Daedalus View Post
To be fair, the discussion wasn't really on topic in the other thread, which was about Amiga Addict magazine so it makes sense to create one here.

But anyway, loading or creating a graphical object will allocate an area of chip RAM to store the graphical data. That area will be located at the first free area that's large enough. The next object loaded or created will do the same, which means it will often appear next to the previous object in memory. Now, this is fine until you don't need some of them any more. You can free the objects you don't need and that will free up their RAM, but it doesn't move the location of any later objects which weren't freed, so what happens is that you have a small bubble of free RAM surrounded by used RAM. When you then need to create a larger object, it won't fit into any of those small empty bubbles, even if it's smaller than the amount of RAM they collectively take up.

In this respect, whether you grab the shapes from a single file or load them individually doesn't make much difference - the problem is that if you free some of them up later it's difficult to reuse the RAM they took up. One possible approach is to make sure the objects that will be freed up are all the last objects to be created. That way, when you free them up, their space is all side-by-side and therefore is a single, large block when it's freed. And if nothing else is allocated in the meantime, that large block will be next to the rest of the free chip RAM, meaning it can be used for much larger objects.

In your particular example, this is complicated by creating sprite objects from the shapes. The first thing to do though is to load all the shapes first, then create your sprites. This way, at least the shape objects will be side-by-side in RAM, instead of being Shape-Sprite-Shape-Sprite... So when you free the shapes, at least you'll have a single free block the size of all the shapes, instead of a single shape-sized block in between each sprite and the next.
This is the sort of thing I thought would be helpful. So basically I need to rearrange the loading of graphics so that the sprite shapes are last so when I copy the sprites into shapes, I can then free up the shape (chip ram) before setting up the screens.
Havie is offline  
 
Page generated in 0.05368 seconds with 11 queries