[Scummvm-devel] PlayStation2 : files caching, TOC & data

sunmax at libero.it sunmax at libero.it
Thu Jul 10 07:42:31 CEST 2008


A-ok scummvm-team,

one more technical e-mail then time for bed!

The focus here is on games data and caching strategy for scummvm
console backends, with special attention to PlayStation2.

We have 3 kinds of data:

 * games data (original or re-mastered, e.g. a mp3 instead of audio
   track)

    -> for game A (let say "comi") they are always the same and they
       are all contained in one location, CD/DVD, USB device, HD,
       remote, etc.

       So we have this location "gamedata", where the game is installed


 * user data (config files, GUI themes, saved games)

     -> these change depending on user tastes, and mood for saving.
        They should be easy transfarable across scummvm platform,
        so that if I decide to continue the game I started on my PS2,
        on my Motorola Ming, or my laptop (maybe cause I am leaving
        for vacation) or if a friend of mine bring his USB stick with
        his saved games, we should easily be able to import them.

        For sake of semplicity let's say that is "userdata".
        (of course there may be more than one lcoation, but only one
        at a time is accessed)


 * special data (I am only aware of kyra.dat)

    -> these were not in the original game set of data, so the game
       CD won't be enough, I will need this file too. For games
       installed from a CD we could just copy it over (or if available
       for a certain version of scummvm on the net we could just
       dowlnload it on the fly while installing). But if we play the
       game from CD (and we don't want to burn a new one with the
       originala data + this file) we whould make this 'special data'
       file accessible in some other way.


But let's keep it simple. When a game starts everything we need is 
going to be in:

 - gamedata

 - userdata

Now only the first one need to be cached. This is very important for
slower media like CD/DVD on PS2 or playing from host: (i.e. a CD
folder accessed from the network). There are two things that may
be cached:

 - TOC

 - data

The first one is a must cause we cannot check every time after we
started the game if the file exists by trying to access to it, etc.

And starting from 0.11.0 with all thos .exists() & .isDirectory() it
happens a lot. On more powerful architecture the OS abstract part of
the caching logic, but on consoles (at least on PS2) you have to do
it yourself.

On the PS2 fopen (which is redefined in common/file.cpp as ps2_fopen)
implements the second logic (data caching), where File & FilesystemNode
implement a TOC. A simpler kind of TOC too, is implemented internally
to ps2_fopen (<-fopen), so we have kind-of a messy duplication.

On the other hand the actual common File / FileSystem which are used
by the engines don't let me cache data as far as I know, you may see
Ps2ReadFile::Ps2ReadFile for the way this was implemented on PS2 by
previous coders, for the ps2_fopen case (But not the File::* case).

So my question is: how do I get the best of the 2 worlds?

How do I cache a TOC + some data? Should I extend File? Should I
bypass it, in the way ps2_fopen does with fopen?

Brainstorming welcome!

Thanks,
 -max





More information about the Scummvm-devel mailing list