Skip to content
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

Closed
mewmew opened this issue Apr 24, 2018 · 8 comments
Closed
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@mewmew
Copy link

mewmew commented Apr 24, 2018

@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

@mewmew mewmew changed the title Consider parsing MIN files to determine the correct CEL type Consider parsing MIN files to determine the correct CEL frame type Apr 24, 2018
@savagesteel
Copy link
Collaborator

@mewmew

Sorry for the late answer and thank you! I'm glad that my work can be of some help for the D1 community.
I think it's a good suggestion, first I should try to parse the MIN file associated with the CEL file and maybe use the heuristics as a fallback method if the MIN file cannot be found or cannot be parsed properly.
I will implement it when I have some time, I also need to update the program to Qt 5.12 LTS.

Regards,

Savagesteel

@mewmew
Copy link
Author

mewmew commented Jan 2, 2020

I think it's a good suggestion, first I should try to parse the MIN file associated with the CEL file and maybe use the heuristics as a fallback method if the MIN file cannot be found or cannot be parsed properly.

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,
Robin

@AJenbo AJenbo added bug Something isn't working help wanted Extra attention is needed labels Sep 2, 2022
@AJenbo
Copy link
Member

AJenbo commented Sep 2, 2022

@mewmew any interest in working on this issue? :)

@mewmew
Copy link
Author

mewmew commented Sep 4, 2022

@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 :)

@AJenbo
Copy link
Member

AJenbo commented Sep 4, 2022

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;

@AJenbo AJenbo self-assigned this Sep 7, 2022
@AJenbo
Copy link
Member

AJenbo commented Sep 8, 2022

Done a515972

@AJenbo AJenbo closed this as completed Sep 8, 2022
@AJenbo
Copy link
Member

AJenbo commented Dec 23, 2022

Fun fact Hellfire's town.min file does not contain valid information for the last 9 frames :D

@AJenbo
Copy link
Member

AJenbo commented Dec 23, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants