Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 29

Thread: files2pas data 'resource' creator

  1. #11

    files2pas data 'resource' creator

    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

  2. #12

    files2pas data 'resource' creator

    Nice work Paul, just downloaded the latest version to take a look at it. This could be very useful for embedding resources especially now with the compression. Have you thought about simple encryption as well to make resources a bit more difficult to "hack over"?

  3. #13

    files2pas data 'resource' creator

    Quote Originally Posted by jdarling
    Nice work Paul, just downloaded the latest version to take a look at it. This could be very useful for embedding resources especially now with the compression. Have you thought about simple encryption as well to make resources a bit more difficult to "hack over"?
    Hi Jeremy,
    Thanks for the kind words

    Wouldn't it be already be very difficult to get at the 'resources' as they are in a very non-standard format?

    On the other hand, I could always add XOR encryption/decryption as a starting point as that is the easiest and very hard to crack.

    EDIT:
    Off-topic: I read your blog http://eonclash.blogspot.com/ about your children who have allergies and I can totally relate.

    My oldest daughter Kendra (2 years 9 months) is quite intolerance to AMINES and SALICYLATES http://www.cs.nsw.gov.au/rpa/Allergy...alicylates.cfm.

    Amines can cause her to get bad stomach pains and make her get very bad eczema + other symptoms.

    Salicylates give her very very bad 'nappy rash', burns actually around her nether regins.

    Perhaps you may be interested in this book (Friendly Food) from the above site:
    http://www.cs.nsw.gov.au/rpa/allergy...iendlyfood.cfm

    Friendly Food is a recipe book and a complete guide to avoiding allergies, additives and problem chemicals. It is available to all members of the general public for $38.50 (price includes GST and postage and handing within Australia) and can be purchased here from the Allergy Unit, or from all major book stores throughout Australia.
    (Murdoch Books® ISBN 1-74045-376-X)
    cheers,
    Paul

  4. #14

    files2pas data 'resource' creator

    Nice tool. How many platforms did you test? I'm just curious.
    No signature provided yet.

  5. #15

    files2pas data 'resource' creator

    Quote Originally Posted by ?ëu?±o Mart??nez
    Nice tool. How many platforms did you test? I'm just curious.
    It works on my WindowsXP PC and the previous version worked on both my PC and gp2x hand-held (arm-linux) computer, but I haven't tested this newest version on the gp2x yet.

    I am hopeful this one will work there too.

    cheers,
    Paul

  6. #16

    files2pas data 'resource' creator

    Paul, yes allergies can be a complete pain especially with the current labeling laws around food. At least now they have to call out the top 10, but that doesn't help anyone with a "local" allergy. Unfortunately they didn't expand the laws to cover derivative's such as SOY Oil (commonly called Vegetable Oil) and other such things to be labeled as an allergic warning.

    We are looking into BHA and BHT allergies for my oldest son now, as we have started to notice some bad things there as well. It seems that what it all adds up to is that parents like us need to make sure our manufactures are up front and honest with us.

    PS: I feel for you on the allergies, I can only imagine how difficult those are to find in product listings.

  7. #17

    files2pas data 'resource' creator

    Quote Originally Posted by jdarling
    Paul, yes allergies can be a complete pain especially with the current labeling laws around food. At least now they have to call out the top 10, but that doesn't help anyone with a "local" allergy. Unfortunately they didn't expand the laws to cover derivative's such as SOY Oil (commonly called Vegetable Oil) and other such things to be labeled as an allergic warning.

    We are looking into BHA and BHT allergies for my oldest son now, as we have started to notice some bad things there as well. It seems that what it all adds up to is that parents like us need to make sure our manufactures are up front and honest with us.

    PS: I feel for you on the allergies, I can only imagine how difficult those are to find in product listings.
    Yeah, it is a real pain to find those in product listings; instead we have to rely on a 'safe' product list given to us by a dietitian with regards to the low allergy diet. On the other hand, we do get 'used' to what things to avoid on labels :-)

    BACK ON TOPIC: I have tested the latest version of the files2pas and it works on my gp2x arm-linux hand-held computer too as well as under Win32!

    cheers,
    Paul

  8. #18
    Hi all,
    since the original download link for files2pas has expired, and at least one person is still interested in it, I have uploaded it to my dropbox folder now (includes source code):
    https://dl.dropbox.com/u/1805932/files2pas.7z

  9. #19
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Make that one more person who's interested...
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  10. #20
    Quote Originally Posted by code_glitch View Post
    Make that one more person who's interested...
    LOL! Thanks mate

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •