Hi all,
Since my last post, I have finally redone the files2pas converter to make it more flexible.

The latest files can be downloaded from here:

7-zip file containging the files2pas.exe + source code for any one interested in how I did it.

http://fpc4gp2x.eonclash.com/downloads/files2pas.7z

an example .rc file + the outputs that were created
http://fpc4gp2x.eonclash.com/downloa...pas_example.7z

The example .rc file that was used looks like this:

Code:
"background res"	BITMAP	"data\background.bmp"	True
"mario res"		BITMAP	"data\mario.bmp"		True
The first column now can be anything for the resource name used to retrieve the data as long as the name doesn't contain " characters.

The second column is the resource type.

The third column is the source file for this resource relative to the .rc file (with no " characters in the name).

The fourth column has been added and can be "True" or "False". If this value is true, then the binary data generated in the .pas file for that "resource" will be compressed using the TCompressionStream from either the FPC zstream unit, or the Delphi zlib unit (see below conditional defines below) prior to converting to hex format.

{$IFDEF FPC}
zstream,
{$ELSE}
zlib,
{$ENDIF}

For each resource in the .rc file, it will generate a single resource<number>.pas file.

A main resource pas file which uses the individual resource files will be generated.

It will also create a resource_unit.pas used by the generated units, but this doesn't need to be included in the project if you want to use the resources (see example below).

To retrieve a "resource", just include the resource file name .pas file in your code and also the Classes unit.

For example:

Code:
Uses
 Classes,
 Mario_Bros_Resource,

{...}

Var
  ResourceType  : AnsiString;
  ResourceStream : TMemoryStream;
Begin
  Result := False;
  Sprite := TSDLSprite.Create;
  If GetResourceByName('background res',ResourceType,ResourceStream) Then
  Begin
    Sprite.LoadFromStream_BMP(ResourceStream);
    ResourceStream.Free;
  End;
It will automatically decompress the data if necessary prior to returning the Resource Type string and a TMemoryStream containing the raw resource data.

Enjoy

cheers,
Paul