I would like to create new levels, and maybe write a small level editor
for Hex-a-hop. AFAICS, I can achieve this by editing the levels.dat
file. Is there a description of the syntax of this file? Any help is
appreciated!
I inherited the project from the original author @amuzen, unfortunately they didn't document the format apart from the source code in packfile.h and they didn't release the source level files. I have been meaning to decompile levels.dat back to some sort of source level files and then delete the levels.dat file from git, but I never got around to it.
Looking at the code, I see there might already be some form of level editor that is enabled when you define an EDIT macro, and I got it to compile and run (see attached diff), but I wasn't successful getting to do anything useful and I don't know the keyboard shortcuts for it yet.
I think it would be great to remove the EDIT macro and instead enable the edit mode when a menu option is enabled, if you would like to work on that, then I will definitely review and merge any patches you write.
Any other help you can give on Hex-A-Hop would be very appreciated.
@guillemj is the most recent person to work on Hex-A-Hop btw.
My approach is basically the same as what you had planned: First,
decompile levels.dat back to some readable ASCII files. Then, write a
level editor that works with these ASCII files.
So far, I've been able to locate the individual levels in levels.dat.
Inside each level, I can see the hexagonal map (more details below). I
can even change individual bytes in levels.dat and get different tiles
when restarting hex-a-hop.
What I'm still struggling with are the bytes before and after the tile
definitions. I assume they define the width and height of the hexagonal
map. Also, there must be the starting position of Emi somewhere.
Deciphering these bytes is where I mostly need help, as I cannot find
the part of the code where these bytes are read and applied.
As an example, here is the 2nd level (called "Hive"). The header is:
I inherited the project from the original author @amuzen, unfortunately they didn't document the format apart from the source code in packfile.h and they didn't release the source level files. I have been meaning to decompile levels.dat back to some sort of source level files and then delete the levels.dat file from git, but I never got around to it.
Looking at the code, I see there might already be some form of level editor that is enabled when you define an EDIT macro, and I got it to compile and run (see attached diff), but I wasn't successful getting to do anything useful and I don't know the keyboard shortcuts for it yet.
I think it would be great to remove the EDIT macro and instead enable the edit mode when a menu option is enabled, if you would like to work on that, then I will definitely review and merge any patches you write.
Any other help you can give on Hex-A-Hop would be very appreciated.
@guillemj is the most recent person to work on Hex-A-Hop btw.
Thanks for your feedback, Paul!
My approach is basically the same as what you had planned: First,
decompile levels.dat back to some readable ASCII files. Then, write a
level editor that works with these ASCII files.
So far, I've been able to locate the individual levels in levels.dat.
Inside each level, I can see the hexagonal map (more details below). I
can even change individual bytes in levels.dat and get different tiles
when restarting hex-a-hop.
What I'm still struggling with are the bytes before and after the tile
definitions. I assume they define the width and height of the hexagonal
map. Also, there must be the starting position of Emi somewhere.
Deciphering these bytes is where I mostly need help, as I cannot find
the part of the code where these bytes are read and applied.
As an example, here is the 2nd level (called "Hive"). The header is:
18 00 00 00 03 00 00 00 01 08 07 0d 01 00 00 00 0b 00 00 00 00 00
Next, the layout of the tiles:
00 00 02 02 00 00
00 02 02 00 02 02 00
02 00 02 02 00 02
01 02 02 00 02 02 01
02 00 02 02 00 02
00 02 02 00 02 02 00
00 00 02 02 00 00
00 00 00 01 00 00 00
If you flip this along the main diagonal, you can recognize the
hexagonal map of the "Hive" level (00=water, 01=gray, 02=green).
Finally, there is a footer:
00 00 89 00 00 00
If I manage to understand this syntax and write some sort of level
editor, I will of course make my code and data publically available.