02-10-2023, 05:47 AM (This post was last modified: 02-27-2023, 08:27 AM by Hansel.)
Hi! My dream is to create a remastered version of the old windows/DOS point-and-click adventure game "Hansel & Gretel and the Enchtanted Castle" from 1995 made by TerraGlyph Interactive. Therefore I need all the resource data of the game - that means all sounds, all background images and all animations images!
All the resource data is stored in a so called .TGR file (it is a TerraGlyph Interactive custom file used in all of their games). I had contact to some of the developers of the game and they said the data of the .TGR file was multiply compressed with different compression algorithms.
I uploaded the messages relating the compression from the developer and the HAG.TGR containing the recources. There are no copyright related material like ISOs or stuff like tat behind that link. If you need other data please message me.
The game is able to run from DOS up to Windows 2000 without problems. If you want to run it on modern systems let me know - there are some tricks to do this.
Here is a video of the game so you can see which images and sounds I'm talking about I need: Gameplay Video
Because this means a lot to me a will pay a reward of 150$ for the one who can extract alle the mentioned data out of the game for me! I don't know how to do it.
05-21-2023, 12:54 AM (This post was last modified: 05-21-2023, 01:01 AM by rufaswan.)
Hi! If the decompression is BIT level, and it has a switch case for multiple algorithm, it would be near impossible to do it by hand. Not to mention I don't have the decompressed data to verify against with.
But I can use a debugger to directly get the whole decompression function from the executable. Being a DOS game, the IDA Freeware Version 5.0 at ScummVM can be used for this.
Let me know if you need my help to find the decompression code.
- Rufas
Hi! I defenitly need help for this Do you can access the files via dropbox or need any more information? Did you read the developer information about the compression methods?
Hi! I never expect you are still here! Welcome back!
Being trying to use that IDA from ScummVM, and now I can see why nobody can help you. IDA can analyze only the DOS-extender stub on the beginning, and not the engine part of game (the part I need).
Tried DOS box debugger, but the thing just keep crashing.
Looking at TerraGlyph wiki page, I noticed "Tiny Toon Adventures: Buster and the Beanstalk" also uses .TGR file, and it is a windows game, so it has a 32-bit .EXE. IDA can analyze this.
Found the decompression code at sub_40ff70, and I got something:
The decompression is just like Final Fantasy 7. Read a byte (8-bits). If bit is 0, copy next byte, if not refer to dictionary. Good old LZ77.
Unfortunately, it only work for backgrounds. The sprites uses different function. I already located the function is at sub_408e60 and in middle of translating it. It has a messy 20 switch cases.
Managed to translate all 20 switch cases, so all images are now decoded!
Like Discworld, there are some sprites reuses pixels from previous frame, so it only has the difference. It is like animated GIF uses cumulative layers (combine) instead of one frame per layer (replace).
What is left now is the audio/sound data. The compression is just as the developers said - it is in BIT level, so it end up even more complicated than the 20 switch cases. Might need a few weeks to do it.
You'll only need "psxtools" folder under "tools/psxtools"
After that, get a PHP 7.0+ from its official site. You'll only need 3 files from the archive, "php.exe", "php7ts.dll", and "php.ini" (renamed from "php.ini-development"). My scripts doesn't need any PHP extensions.
NOTE: also opening the php.ini, looking up the word "memory_limit" than deleting 128Mb and writing something like 2048mb
Put all the files to a folder, like this (the .IRLST and .LRARC are from gunvolt, so put .TGR there instead):
After that, from command line, run
Code:
php.exe psxtools/pc_tinytoon_tgr.php HAG.TGR
This will properly extract the files with the correct file type. You will get 4 extensions
- .PAL are the 256 color palette
- .IMG are the compressed background or sprites
- .SND are the sound files
- .HOT are Hotspots (according to game engine)
You only need .PAL and .IMG files. Run this on the content of each folder to get all background and sprites:
Code:
php.exe psxtools/pc_tinytoon_img2clut.php *
The result .CLUT and .RGBA are raw image used for debugging. You can convert them into PNG by running:
06-02-2023, 11:22 AM (This post was last modified: 06-02-2023, 12:13 PM by rufaswan.)
Hmmm? Your HAG.TGR is 445,224,310 bytes (0x1a899576), but mine is 554,903,882 bytes (0x2113294a). Seems like there are multiple versions of the game. Or in different languages. I know ScummVM tries to keeps track every version and every release of the same game to fully support it.
I don't think my scripts will run with your HAG.TGR, unfortunately.
- Rufas
P.S. Did you get any files or folders after this error? If yes, what is the last file?
06-05-2023, 01:52 AM (This post was last modified: 06-05-2023, 01:53 AM by Hansel.)
Oh ok, but it's important it runs with my HAG.TGR because it's the version 2.0 and the german version. Is it possible to update the script? There are no files extracted. Thank you
06-05-2023, 04:40 AM (This post was last modified: 06-05-2023, 04:57 AM by rufaswan.)
I just got the version you have, and my script generate different error "unknown type 8". It seems they added some new file types. So it is updated to able to extract the newer TGR.
I also tried my .IMG script. The newer .IMG files is now completely different. Will have to figure out the newer format.
Also now I understand how to decompress the .SND files. Basically, except the first byte, everything after it is just the difference. So the data is like 87 -1 -1 -1 -1 -4 +2 -2 +1 0 0 0... , and it become 87 86 85 84 83 7f 81 7f 80 80 80 80... . It is in BIT level because it is suitable to compress audio data.
But luckily the .SND files remain the same. It will work for both version.
But they are in 1 second chunks. If you merge both .IMG and .SND together, you'll noticed they are in [image, image, image, sound], [image, image, image, sound], ... chunks. It is exactly like how a video data structure looks like.
Using number of images between .SND chunks, you can even tell Hansel and Gretel is animated in 12 FPS, while TinyToons is in 6 FPS.
Interesting behind the scene stuff, right?
- Rufas
P.S. if you still have problem extract .TGR file, let me see your folder setup. That 0x169e5d6ba is over 32-bit, but nothing on my code reads more than 4 bytes. Where in the world this value came from? Maybe it is reading something else entirely...
06-06-2023, 10:37 AM (This post was last modified: 06-06-2023, 10:38 AM by Hansel.)
Hey I downloaded the new version of your scripts but I still cannot extract the newer .TGR - I get the same errors as before. I added a screenshot of my folder. Do you have access to the correct .TGR version?
You do a great job man and really let my dream become more and more true. Thank a lot!