-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider parsing MIN files to determine the correct CEL frame type #2
Comments
Sorry for the late answer and thank you! I'm glad that my work can be of some help for the D1 community. Regards, Savagesteel |
Sounds like a good approach to use the heuristics as fallback for when the MIN file is not available. Wish you a great start of the year @savagesteel! Cheers, |
@mewmew any interest in working on this issue? :) |
heh :P c++ is not quite my cup of tea. but if someone wishes to try, I'd be happy to aid with information on how the MIN format works if wanted :) |
To parse the min-file we need to know the block size (16 for hell/town, 10 for everything else). Rather then hard coding it I have figured out a way to derive it from the size of the sol-file: // int numberOfMegaTiles = sizeof(amp) / 2; // only available for some levels
int numberOfMegaTiles = sizeof(til) / 2 / 4;
int numberDPices = sizeof(sol);
int blockSize = sizeof(min) / 2 / numberDPices; |
Done a515972 |
Fun fact Hellfire's town.min file does not contain valid information for the last 9 frames :D |
The issue turned out to be Hellfire's town.sol only having 1376 tiles instead of 1379 which caused us to not parse the last 3 columns missing there frame types. |
@savagesteel Very happy and excited to see that you've been working on a range of Diablo 1 related projects! As @dgengin has now incorporated a CEL decoder based on https://github.com/savagesteel/d1-graphics-tool, it would be great to ensure that its output is correct in 100% of the cases (this may already be the case today, even based on heuristics). Even still, I'll present my case for moving towards a CEL frame type lookup table based approach for parsing CEL images, with lookup tables automatically generated by parsing MIN files.
The current CEL decoder implementation relies on heuristics to determine which CEL type a specific frame is.
For instance, one heuristic employed is to determine if a set of bytes are zero at specified offsets (e.g. https://github.com/savagesteel/d1-graphics-tool/blob/master/source/d1cel.cpp#L39). Another is to parse a frame of size
0x400
using regular CEL decoding to determine whether the number of decoded pixels correspond to a 32x32 image.While both of these heuristics are unlikely to fail, it would be preferable to not have to rely on heuristics all together.
For background and reference implementations: https://github.com/mewrnd/blizzconv/blob/master/images/cel/decode.go was based on similar (although less reliable heuristics), and decoding tables generated by parsing MIN files was determined to be more reliable as incorrectly decoded frames were discovered.
Hope to hear from you and get to know your thoughts.
Cheerful regards,
/u
The text was updated successfully, but these errors were encountered: