[Scummvm-devel] kyra.dat

Johannes Schickel lordhoto at scummvm.org
Sun Jul 12 22:28:19 CEST 2009


sunmax at libero.it wrote:
> Hi Johannes,
>
>   
>> Currently there's no API in Kyra to do that. 
>>     
>
>   
>> why don't you create a cache in your backend?
>>     
>
> We are already re-placing fopen and fclose in PS2 and we have
> both read and write cache. Still cache is deallocated on close
> (because on an embedded system with limited resources) we don't
> want to overcache.
>
> I would not mind keeping the FD open on close on a LRU base,
> but the FD slots are limited on PS2, and I just need to keep
> -one- file open: kyra.dat.
>
> The fact is we have this issue only with kyra.dat which is
> the only file (in a few engines I tried) that keeps getting
> opened/closed. To implement a smarter cache is possible but
> would be an overkill to fix a single file case in a single
> engine...
>   

Ok.

> So I thought it could be simpler to just keep it opened in
> kyra. I just had a quick look to the code:
>
> bool StaticResource::loadStaticResourceFile() {
>     Resource *res = _vm->resource();
>
>     if (res->isInCacheList(staticDataFilename()))
>         return true;
>
> Is this the only place where kyra.dat is loaded ?
>
> I see there is a "isInCacheList" check on KYRA.DAT,
> what do we need on PS2 backend to make it succeed,
> so the we skip loadPakFile ?
>
> Please note, I just had a very quick glimpse so it's
> possible I am missing quite a few things... ;-)
>   

You in fact missed that this code is only for loading the correct 
KYRA.DAT in the Archive cache of KYRA. That means it only looks for the 
most recent version the user has and then loads all filenames, offsets 
and sizes from the file for later use. It is not used to read data from 
that file.

Opening a file is done on a completely different basis. And in fact 
there is no easy way to keep a file open. I might implement a cache for 
that inside KYRA. I can't promise anything here though, since that might 
take some time till I find a clean way of implementing it. On the other 
hand I might just rework our static resource code in KYRA, but that will 
be too risky for the next release. Maybe I'll just add some HACK to the 
1.0.0 branch which keeps it open for some time... :-).

// Johannes





More information about the Scummvm-devel mailing list