WIZ port and memory usage

Started by Imerion, July 29, 2010, 08:46:46 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Imerion

I have run into a quite big problem with my latest game. It doesn't seem to run on the WIZ and I believe the problem is that the .fpg file is to big. Does anyone know how the WIZ port of Bennu handles fpg files and memory? Is the max size the same as it's ram size (64 MB)?

And if that is the case, is there any way to make the game read the file directly from the disc instead of from the memory to save ram?

I tried compressing the fpg, but that didn't help. I guess it simply get's unpacked when the game starts so the memory fills up anyway.
Any help that can make my game run will be highly appreciated!
Try my games : Neotron Games

FreeYourMind

#1
The total of memory is close to 8 megabytes in the first game load.
If you use more memory, you need to load and unload during the execution of the game.

You can use more than 1 fpg, an example, at the begining load the intro's fpg, after the intro, unload and load the new fpg.

BoMbErLiNk

Total of RAM is about 34-38MB.

Is the fpg 32bits or are you trying to set 32bit mode ? Wiz can only manage 16bits and 8 bits.
To reduce memory you can set alpha_steps to 8 or less on the beginning of the program.

Imerion

I was considering the possibility of splitting up the fpg, loading and unloading a part at a time. But since the game is open-ended it's possible to go quickly between different areas, so I need to have most stuff available at all times. I could put intro, menus and ending in a different fpg, but that wouldn't be enough to get it into the 34-38MB range.

I use 16 bit color, so that is not the problem. The alpha_steps setting sounds very interesting though. How does it work? Can I simply use "alpha_steps 8" and it will reduce the amount of memory the loaded fpg file use?
Try my games : Neotron Games

BoMbErLiNk

Yeah, you will save around 3MB or 4MB on the program.

QuotePROGRAM my_program;
BEGIN
alpha_steps=8; // first setting alpha steps
load_fpg("file.fpg"); // then loading files
.....
...
END

EugeneP

You can activate swap on Wiz, if nothing else helped. This would affect performance of course.

Imerion

QuoteYeah, you will save around 3MB or 4MB on the program.

Thanks! That should help a bit. Maybe there's more tricks like that? Any little bit could help! :) I have already removed all modules that isn't used so they are not included.

Also, I was wondering: would loading each file on it's own change things? (That is, read them in and assign them positions manually from the code?) All graphics I have is saved as .png files which are really very small due to compression. I guess the fpg-format saves them as uncompressed files. But if there was a way to handle them as they are, compressed, that would make all my problems go away at once. :)

QuoteYou can activate swap on Wiz, if nothing else helped. This would affect performance of course.

Also very interesting! How do I do this? By using pollux_set? Performance shouldn't be that much of an issue, the game is not very processor intensive. Does it swap to the nand memory then, or to the SD card? I remember reading something about the nand-memory having limited amount of writes or something like that. I don't really remember the reason, but for the GP2X people refrained from using the nand-memory and said things like "save your precious nand". No idea if it's still an issue with the WIZ however.
Try my games : Neotron Games

EugeneP

Quote from: Imerion on July 30, 2010, 03:27:18 AM
Also very interesting! How do I do this? By using pollux_set? Performance shouldn't be that much of an issue, the game is not very processor intensive. Does it swap to the nand memory then, or to the SD card? I remember reading something about the nand-memory having limited amount of writes or something like that. I don't really remember the reason, but for the GP2X people refrained from using the nand-memory and said things like "save your precious nand". No idea if it's still an issue with the WIZ however.

Well on Wiz, as on any linux, swap can be made of/in file.
You need to create file of desired size, format it as "swap" and activate by "swapon".

HOWTO:
1) create file "myswap" of desired size

2) format it with mkswap.
if you pc runs Linux you can do it by sudo mkswap /path/to/myswap
or you can do it on wiz using such script (on wiz it would take time):

[code language="bash"]#!/bin/sh

mkswap /mnt/sd/myswap
cd /usr/gp2x
exec ./gp2xmenu
[/code]

3) copy "myswap" it to the root of SD card

4) add activating swap to your .gpe script like that:
[code language="bash"]#!/bin/sh

swapon /mnt/sd/myswap
./run_my_grat_program_binary
swapoff /mnt/sd/myswap

sync
cd /usr/gp2x
exec ./gp2xmenu
[/code]

Something like that. I don't have my Wiz with me, so I cant provide tested solution, but I'll post it few hours later if you need it.

EugeneP

WOW, Bennu has exec  :o This makes things easier.

Here is tested example (bennu + exec + standard linux utilites) which turns on swap, and successfully creates fifty 1024x1024x8 bitmaps on Wiz.

Imerion

I managed to create the swap using :
Quotedd if=/dev/zero of=/home/imerion/Dev/Fix/swapfile bs=1024 count=50000
Quotesudo mkswap swapfile

I then put the file in the game dir and used "swapon swapfile" and "swapoff swapfile" in the startscript.
It seems to work! The game started but only ran for a little bit before returning to menu, so I'll try to optimizse the size of the fpg a bit and hope it will be enough.
Being able to create the swap from within the game is really cool though, and that way I won't need to have a big file included. So I'll probably modify my game to work like that instead.

Thanks for all the help! Just one question though, how will this affect the SD Card? Will writing back and forth to it like this make it break? I guess it will wear out eventually, but I mean if something will happen much faster than that. Also, would a swap file in nand be faster or better?
Try my games : Neotron Games

EugeneP

SD card is affected, of course. Active using swap (active writing logs or saves) wears out flash memory. In other hand they used swap in alternative firmwares for Motorola Zine AFAIK and no one died :)

... and I would not recommend create swap for bennu programs. It is completely unportable approach.

Drumpi

You don't need to worry if FPG is compressed, uncompressed or are using another format: your graphics uncompress in memory when load.
So you must do more FPGs with less memory usage, and load/unload when needed. If you use more of 32MB you're using so big graphics (and big i'm saying 1024x768 or more) and maybe you must use tiles.

The problem with nand memory is that it will corrupt in no-time, compared with magnetics support or else. In SD is no problem, you can format or change it easily, but NAND memory needs a JTAG cable to format and reinstall firm, or a soldier if it brokes.
Hala, como con 1001 procesos sólo va a 9 FPS, vamos a meterle 32 veces más, a ver si revienta.
(Drumpi epic moment)

Imerion

QuoteYou don't need to worry if FPG is compressed, uncompressed or are using another format: your graphics uncompress in memory when load.
So you must do more FPGs with less memory usage, and load/unload when needed. If you use more of 32MB you're using so big graphics (and big i'm saying 1024x768 or more) and maybe you must use tiles.

Yes, we really should have should have used tiles. But we never expected the game to get so big and my friend who drew most of the graphics hasn't worked much with tile-based graphics so we decided not to do that. But I most likely will make my next game tile-based.


QuoteThe problem with nand memory is that it will corrupt in no-time, compared with magnetics support or else. In SD is no problem, you can format or change it easily, but NAND memory needs a JTAG cable to format and reinstall firm, or a soldier if it brokes.

I see, thanks for the info. I remember something like this being the case, so I haven't used the NAND at all but instead made a swap on the SD card.
The game works decently now. But if someone should have another nice trick for decreasing memory usage laying around I'll happily try it. :)
Try my games : Neotron Games

Drumpi

To avoid usage of memory with music, use LOAD_SONG instead LOAD_WAV. You only can play one every time, but you don't load all song in memory, just fill a memory buffer.

I can't remember more tricks now, so i hope it helps.
Hala, como con 1001 procesos sólo va a 9 FPS, vamos a meterle 32 veces más, a ver si revienta.
(Drumpi epic moment)