JonMagon/BBTools

Question about tilemap ids maping

ApmeM opened this issue · 14 comments

ApmeM commented

Hi,

I'm writing a Beasts and Bumpkins resource unpacker and got a question.
The goal of my project is to convert those BOX files into more readable formats For example png for spritesheets and tmx for missions)
I took your repository as an inspiration and also as a source of texture id mappings, but it seems it lacks quite a few of those values (for example there are only 2 buildings - peasant hut & builders)

So my question is:
Where did you get those values?

I saw a reference to palettes in the code (https://bitbucket.org/trass3r/openbb/full-commit/881d183eda96/openbb/io/palette.d) but it seems this repository is not available anymore.

Do you know where / how I can get those values?

ApmeM commented

Hm, thanks for the link, but it seems id does not contain those mappings as well...

Trass3r has the most GitHub activity I've ever seen, maybe you could as them.

Those are the color palettes which are saved as PE resources.
I think the question is more about

switch ( object->class_id )

ApmeM commented

Aha, thanks @Trass3r, it seems it is what I need.
And I think this is also a part of the data:
https://github.com/JonMagon/BBTools/blob/4cdadffa9ac663fdc0162b2475836336d19540ca/additions/objects_list.txt

Thanks for the answer, I'll try to convert it to tmx and will see how it will looks like.

Aha, thanks @Trass3r, it seems it is what I need. And I think this is also a part of the data: https://github.com/JonMagon/BBTools/blob/4cdadffa9ac663fdc0162b2475836336d19540ca/additions/objects_list.txt

Thanks for the answer, I'll try to convert it to tmx and will see how it will looks like.

Pseudocode files are obtained via HexRays after restoring structures to readable level. The object file was generated automatically, but I have forgotten the approach used.

ApmeM commented

Hi,

I have made it in more-or-less stable.
There is an issue with images offset (for example farm's of peasant hut's positions are not in the center of their field (it is visible on the example linked above).
I tried different variants with tiled positions and images offsets, but the result is still not perfect, but for now I think I'll stop on that as it is now usable.

But now I have another question - I see this repository also contains wav files importer.

Can I migrate the code to my repository as well?
(I'm not sure about licensing - will it be enough to add a link from readme to this repo?)

The autor of the converter is Zench from xentax forum. Xentax no longer exists, so I don't think the author will mind, especially if you explicitly list him. But that code is not licensed.

ApmeM commented

Hm, maybe I'm doing something wrong, but I cant generate wav files using this converter from this repository.
Can you please check if I'm doing it right:

  • git clone git@github.com:JonMagon/BBTools.git
  • cd ./BBTools/decodem10_cppsrc/
  • cmake
  • make
  • ./decodem10 ../../Data/SPEECH4/wolfgrwl.m10 ./w.wav
    Compression: 9
    Total sample count: 13492

But when I open this w.wav I can hear only noise without meaningful sounds.
I can see that the converter is not fully done, so I assume not all the files can be properly converted, can you point me to the files that can be converted, so I can check my C# port works?

ApmeM commented

Oh, cool repository.
This is actually what I need instead of all those converters.
If you want I can create a pull request to that repository with those tiled files, and actually I do not need wav converter after that (well, maybe just for fun).

ApmeM commented

Thanks for all the hints, I have finished wav parser and it looks ok (I do not remember the real sounds quality of the game, but I can recognize phrases that I remember from my childhood :) )
But I have found 2 bugs in this c++ code (write/read outside of the array):

LINE: https://github.com/JonMagon/BBTools/blob/master/decodem10_cppsrc/src/Decoder.cpp#L646
REASON: BigTablePtr[i] = DecoderStruct->BigTable + BigTableIndex + i;
In worst case it is 540 - 0 + 108 = 648.
But the size of BigTable is 324
EXAMPLE: SPEECH4/monkf5.m10)
FIX: increasing the size of Bigtable to 756 is enough (540+108+108)

LINE: https://github.com/JonMagon/BBTools/blob/master/decodem10_cppsrc/src/Decoder.cpp#L359
REASON: SkipBits/GetBits tries to read outside of the compressed data array.
EXAMPLE: SPEECH1/arc3.m10
FIX: check the bounds and return 0 if outside

Those fixes are just temporary as it seems both issues means more complex bugs in parser, but

  • As I said I'm quite bad in low level decompilation, so cant suggest better fixes
  • With those quickfixes converter works well and produce proper sounds, so it is sort-of enough.