Python as a Game Dev tool on GBA

Emile van Sebille emile at fenx.com
Fri Jun 7 08:05:06 EDT 2002


"Gianluca Cancelmi" <cancelmi at cli.di.unipi.it> wrote in message
news:3cffe769$1_1 at nnrp1.news.uk.psi.net...
> Hi,
>
> I've been using python for a lot of little tools for Gameboy Advance.
>
> At the moment I'm using it to convert multiple bitmaps into a large
shared
> tile set and multiple maps.
>
> I'm using PIL to load the bitmaps and generate the tiles.
>
> At the moment I'm having a little bit of trouble with memory usage.
>
> I'm cutting the 8x8 pixels tiles using Image.crop().
> I'm creating 3 other versions of the current tile for Horizontal,
Vertical
> and H+V flipping.
> I convert the tiles in strings and use this string as a key for the
tile
> dictionary. The value for that key is an object (TileImage).
>
> That's the source code:
[snip]
> The problem is that is taking too much memory and I get something like
> memory error in python.
> The test images are 9600x512 pixels each (4 images).
>
> My PC has 512M of RAM and I'm running the script in win2000.
>
> Is there any way to debug memory usage?
>
> Anyone has an idea of what I'm doing wrong?
>
> Any help would be really appreciated.
>
> Cheers,
>
> Gianluca
>
>

It looks like 4 images of 9600 by 512 pixels of high color reduced to
16x16 or 2 bytes per pixel?  Then cut it into 8 pixel by 8 pixel pieces,
and save the pieces in objects in a dict keyed by a string of the image.

So, check my math:

9600*512  * 4bytes/pixel (high color)
~= 50 Mb per image * 4 images
~= 200Mb in the source images?

Then save two copies of in altered string forms and you're over 500Mb.
And that's before adding in overhead of the python structures.

You might try restructuring the need for multiple string versions, and
look into changing:

    for img in img_list:

to
    for img in img_list_names:
        img_list = <<get image loaded with PIL>>

Perhaps you can sneak through by saving that 150Mb...

--

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list