PDA

View Full Version : question about KOS



pfs
October 20th, 2004, 12:28
i have 2 questions about KOS


1. is it possible to load graphic in the main ram
and from there in the video ram



2. how does the threads working?
is there any samle code?

my problem is that i want to load from the disc during the game
so i thought i make 2 threads
1 thread is the normal game engine with high priority
1 thread is for loading gfx with low priority that is working if time is left in a frame.

the game is running with 60 fps. if the game engine has to much to do
somtimes it changes to 30 fps, thats ok,
but loading gfx should not be change the framerate.


is it generaly possible to change a thread during loading a gfx?

pfs
October 20th, 2004, 18:35
can no one help how to load
gfx from disc to main ram
and from main ram to video ram?

i only know how to load from CD direct to video ram.

BlackAura
October 21st, 2004, 01:46
You can only load graphics to VRAM if you're using the 3D rendering hardware, and how you do it depends on what you're loading, and how you want to use it.

pfs
October 21st, 2004, 03:47
what do you mean if i using 3D rendering?

i want to load the texture (pcx and png) files
into main ram.

for what does i have 16 MB ram if i cant use it

what is in the main ram
16 MB is a little bit big for ony the programm

BlackAura
October 21st, 2004, 06:15
Main memory gets eaten up really quickly if you're storing complex 3D models or levels. Some commercial games also use it to store textures and sound effects which are used in the current level, but aren't needed yet.

I assume you want to do something similar - load new graphics while the game is going, so you don't have to stop and load them later, right?

The easiest way is to copy them into the KOS ramdisk. Basically, you copy your files from /cd to /ram, and then load them from there the same way you would load them from CD. And the easiest way to copy files is:

fs_copy("/cd/filename.png", "/ram/filename.png");

Make sure you delete them when you've loaded them, because you'll run out of main RAM pretty quickly if you don't:

fs_unlink("/ram/filename.png");

One other thing you might consider - use the KMG image format instead of PNG or PCX.

When KallistiOS copies a PNG (or PCX) over to main memory, it needs to first convert it to a format the Dreamcast's video hardware can deal with. The PNG loader also doesn't realise that the file is already in memory. So, it loads the PNG, then decompresses it (allocating more memory), then converts it (taking up more memory still), and then copies it over. That's fine if you're loading them one at a time, but if you have lots of then stored in memory at once, you might run out of space.

A KMG is already converted, and the KMG loader can deal with the ramdisk (and romdisk) correctly. So, when you're loading a KMG from the ramdisk, it just copies the data over immediately.

As for the threading... It should work, as long as your loader thread isn't doing anything except loading. That means no compression or anything - just reading directly off the disc, and putting it into main memory.

If you're using a new-ish version of KallistiOS, you can also use romdisks instead of the ramdisk. Basically, you can pack all of the data you need for each level into a romdisk, and get the game to load that. You can then attach the romdisk somewhere (say, /data) and read files from there. This is what Feet of Fury does. In your loader thread, you can do something like this:

ssize_t size;
void *data;
size = fs_load("/cd/datafile.rd", &data);
assert(size != -1);
fs_romdisk_mount("data", data, 1);

Now, all the files in the romdisk will be available from /data. When you're done with them, you can remove the romdisk image from memory like this:

fs_romdisk_umount("data");

pfs
October 21st, 2004, 09:07
how can i covert my image to KMG?
gimp or adope dont support this format

GPF
October 21st, 2004, 10:17
under the KOS utilities folder is a program called kmgenc , which is a command line utility to convert to kmg format.

pfs
October 22nd, 2004, 13:30
from what format can i convert?

i convertet from png to kmg
and the compiler says:inverted, non-twiddled loading not supported yet.


kmgenc with no options what color format does it transform?
565?

why does the -a1 not work (only -a4)

if i make graphic with transparent where can i know if it is 4444 or 1555

and what is the different between rgb_565 and rgb_565_TWID

GPF
October 22nd, 2004, 14:12
I haven't used it yet, sorry