[Update] Hocus Pocus Level editor v1.2

Discuss classic and favorite computer or console games here.
User avatar
keenmaster486
Vorticon Elite
Posts: 542
Joined: Sun Mar 20, 2016 18:29
Location: Tranquility Base
Contact:

Post by keenmaster486 »

The lost notes in OPL2 (Adlib) mode are due to OPL2 only having 9 channels, while OPL3 has 18. This also happens in games such as Descent, or, for that matter, any game that uses midi files with more than 9 simultaneously used instruments.
I flermmed the plootash just like you asked.
User avatar
K1n9_Duk3
Vorticon Elite
Posts: 779
Joined: Mon Aug 25, 2008 9:30
Location: Germany
Contact:

Post by K1n9_Duk3 »

Hisymak wrote:That's amazing! It's nice to see that somebody is actually hacking Hocus Pocus executable. I see God mode there, that's also your hack, isn't it?
It is my edit, but you can actually enable godmode in the original game by setting the difficulty to '3' in the savegame.
Hisymak wrote:I have one more question to you, regarding this thread. I believe Hocus Pocus music engine does some tricks to make OPL music sound better. I suspect it actually uses two OPL voices to play a single note (in OPL3 mode), because it sounds different with Adlib and there are lot of "lost notes", when replaying very polyphonic midi. Could you possibly look into this? Thanks!
Hocus Pocus uses the Apogee Sound System (written by Jim Dosé). The source code for that was released along with the source code to RotT and Duke3D (and possibly Shadow Warrior as well). But Hocus Pocus was the first game ever to use that (IIRC), so the released code will most likely differ from what was used in Hocus Pocus. The main difference being all the DPMI calls (Hocus Pocus is a real-mode game, RotT and the others are protected-mode games). One other difference would be the included timbre file (judging by the 'FAT MAN' credit in Hocus Pocus).

But what keenmaster486 said is true. Some soundcards actually have 2 different sets of 9 channels each, and the Apogee Sound System (as far as I can remember) does indeed make use of this for music playback.
Hail to the K1n9, baby!
http://k1n9duk3.shikadi.net
User avatar
Levellass
S-Triazine
Posts: 5265
Joined: Tue Sep 23, 2008 6:40

Post by Levellass »

This stuff is absolute madness. I love how these old programs have such mad formats.
What you really need, not what you think you ought to want.
Hisymak
Vortininja
Posts: 112
Joined: Sat Mar 26, 2016 20:13

Post by Hisymak »

Another preview of great upcoming features:

1. Viewing and exporting sprites (importing sprites will be done too):
Image

2. Drawing sprites on the map (can be turned on and off):
Image

3. The "Save map image" now saves into .png instead of extremely huge .bmp file.
User avatar
Levellass
S-Triazine
Posts: 5265
Joined: Tue Sep 23, 2008 6:40

Post by Levellass »

Oh yes, me likey.
What you really need, not what you think you ought to want.
User avatar
K1n9_Duk3
Vorticon Elite
Posts: 779
Joined: Mon Aug 25, 2008 9:30
Location: Germany
Contact:

Post by K1n9_Duk3 »

Yes, that looks very promising. Would be cool to see some Total Conversions for Hocus Pocus in the future. I think that should be possible once sprite import is included.

I wish I was motivated enough to rewrite my Duke Nukem II editor into an actual Windows GUI style application like your editors. Maybe that would have gotten more people to using it. Maybe not, I don't know. I'm still waiting to see a Duke 2 mod or at least a levelpack.

Don't let a lack of user generated content or feedback discourage you, though. I've probably had more feedback on stuff like broken links than I had on the actual tools I created.

For example, ReDuke got it's first user-generated graphics mod after I announced that the project was officially dead. The latest version of ReDuke is now hosted on http://hrp.duke4.net and you can even find ReDuke on Wikipedia in the list of game engine recreations. I didn't put it there myself, that must have been somebody who used and liked ReDuke enough to add it there, I guess.

Keep up the good work. And thanks for making HocusEditor open source. More people (including myself) should do that, too.
Hail to the K1n9, baby!
http://k1n9duk3.shikadi.net
Hisymak
Vortininja
Posts: 112
Joined: Sat Mar 26, 2016 20:13

Post by Hisymak »

Thank you guys for your comments.

One fresh information for you: The importing of sprites is finally DONE! I must say big Thank You to K1n9_Duk3 for providing me the algorithm for converting an input image into the Hocus Pocus sprite format. That helped me a lot and saved me much time and work on figuring it myself.

I'm still working on some more minor but important features, for example editing the menu/UI graphics. With all those, HocusEditor will become a complete modding tool for Hocus Pocus.

I'll post some screenshots later, most likely along with release of new version.
But anyway, here is preview for a small, but handy feature: Computation of VGA memory usage.
As K1n9_Duk3 informed me, Hocus Pocus uses VGA memory to store all the game graphics, and since its size is limited, this brings limitations of how much graphics (size of tileset and simultaneous monster types) can be used in a level. This feature tells you whether you exceeded this limit or not and how much free memory is remaining.

Image

However I still need some advice with a planned "EXE patching" functionality. That means, when you make some EXE hack, you make a patch of it and then you can apply it on a clean EXE. That itself is pretty easy, but in my case I need to solve two additional problems:
1. The patch must be applicable on any Hocus Pocus version. That means, if you edit a few bytes in full version, the patch is able to edit the same bytes in demo version even if they are at different position in EXE or some data differ between the versions.
2. The patch ignores the changes of data related to FAT or levels (elevator tiles, par times), which should be modified by different means.
So if you have any experience with this, I'd appreciate any help.

If you're interested in my progress, you can follow new commits in my git repository (I was quite active during recent days).
User avatar
K1n9_Duk3
Vorticon Elite
Posts: 779
Joined: Mon Aug 25, 2008 9:30
Location: Germany
Contact:

Post by K1n9_Duk3 »

As far as EXE patching is concerned, there are actually 8 different versions to worry about, not counting the leaked beta version.

There are the game versions 1.0 and 1.1, they can be shareware or registered versions of the game, and then there is the Gravis and the non-Gravis version of the executable.

The Gravis executable is "__hpgrvs.exe" and has a different layout than the regular "hocus.exe". My guess is that the Gravis playback code was too large to be added in the regular version (leading to "out of memory" errors), so they had to make a separate version for the Gravis Ultrasound soundcards.

This fact has been ignored for the longest time. You can't find any info about the Gravis versions on the ModdingWiki. Might be best to just ignore the Gravis versions altogether, but I just wanted to let you know they exist. Just in case you get bug reports from people trying to run mods with the Gravis version.


I think the only things that HocusEditor itself needs to patch are the lookup tables in the executable, like par times, elevator tiles and so on, and of course the FAT. That is relatively easy to do as long as you know where these tables are located in each executable.

Patching other stuff (like actually modifying the instructions and not just data) is beyond the scope of HocusEditor, I think. Since all the exes are different, you cannot just take a code patch that was written for v1.0 shareware and apply it to v1.1 registered. It just won't work. That is also the reason why almost all Keen mods require a specific version of the original EXE to work. The CKPatch utility appears to have some lookup tables to let you patch generic stuff like the EGAHEAD or MAPHEAD for any version of Keen, but all the "custom" patches are usually written to work on just one single version of the EXE.

I have already posted the locations of most of the "interesting" tables on the ModdingWiki for v1.1 registered. You can use a hex viewer/editor to see what data is stored at those locations and then search for the same string of bytes in the other EXEs, since the data itself should be identical in all versions of the game. I think even the shareware versions contain the full tables for par times and such, even though only the data for the first episode is ever used in that versions.

The only table that might differ (as far as I recall) is the table storing the sound effects, which stores actual FAT indices. They differ from version to version, but I don't think you'll ever need to patch them.

I'm not 100% sure, but I think the basic layout of the tables in the EXE is unchanged through all versions (with the possible exception of the Gravis EXEs), so you can use the difference between the FAT offsets for v1.1 registered and whichever version you want to add. Adding that difference to the offsets for the other tables might work, but you'll need to test that yourself.

Edit: I just realized that using the FAT offset is probably not a good idea, because the size of the FAT is not constant and all the other tables are stored after the FAT. Might be better to compare the offsets of some fixed-size data structures like the par times instead.
Hail to the K1n9, baby!
http://k1n9duk3.shikadi.net
Hisymak
Vortininja
Posts: 112
Joined: Sat Mar 26, 2016 20:13

Post by Hisymak »

Thank you K1n9_Duk3 for your reply.

I had absolutely no idea what "__hpgrvs.exe" was. I once tried to use Gravis Ultrasound in Dosbox but could not make it work.

And about the HOCUS.EXE patching. I just made this functionality! And it also works between different game versions, it seems I figured out how to do it. But it won't work always, as it depends on how big the differences are between the versions. I tried it on several text strings and it worked: I created a patch against full version and applied it on demo version (and even also beta version) and the strings were changed properly.

I was inspired by the Linux diff and patch utilities. The patch contains both original and modified bytes and their position in the original executable. When patching, the program searches for the original bytes at that position, and if they are not found, it looks for them before and after this position. If it finds them, it rewrites them.
The patching has two parameters:
1. Context size - additional several bytes before and after the difference section are included in the patch to make the search more reliable. Default is 3.
2. Look distance - how far it looks before and after if it doesn't find the bytes to be modified at expected location.
Hisymak
Vortininja
Posts: 112
Joined: Sat Mar 26, 2016 20:13

Post by Hisymak »

Good news everyone!

Release of HocusEditor version 1.2 is here!

With this new version, HocusEditor is no longer just a level editor, but it has developed into a complex modding tool for this awesome and popular classic VGA platformer!
Now, all kinds of graphics, most notably sprites, are editable - that means total conversions are likely to come!

What is new in this release:
- Created tool for viewing, exporting and importing sprites
- Created tool for viewing, exporting and importing menu and UI graphics
- The document "Graphics replacement guide" was updated accordingly
- Sprites are drawn on map (can be turned on and off)
- The "Save map image" now saves into .png instead of extremely huge .bmp file
- Added exe patching feature
- Added support for beta version
- Added "Compute VRAM usage" function
Levellass wrote:Brilliantly impressive. So tempted to add Keen to HP.
Your wish has come true! Now you can add Keen or whatever you like!

Download link:
Here

Demonstration:
To show you the full power of editing the sprites, I decided to turn Hocus Pocus into Doom marine and let him fight against the hellish monsters everyone knows from the legendary 3D game. Let's introduce Doom Pocus:

Image
Fire Crocs turned into Imps and Devil Dan is now a Cacodemon.

Image
Shooting dat Zombie and Imps.

Image
Besieged by Lost Souls.

Image
The final battle with a vicious Cyberdemon.

Screenshots:
Image
The final sprite editing UI.

Image
Sprites now being drawn on the map.

Image
The "Compute VRAM usage" helps you manage the limitations.

Important note:
If you work on your mod and something is not clear to you, you don't know how to achieve something, run into a problem, or just found a bug or missing functionality, don't hesitate to ask me! I spent a reasonable time making this program and playing around with the modifications so I'm really willing to share any information and experience with you.
Keening_Product
Kuliwho?
Posts: 2166
Joined: Fri Jan 20, 2012 7:02
Location: Tied up in the Oracle Chamber's basement
Contact:

Post by Keening_Product »

Haha, very nice work.

The VRAM calculator is a nice touch.
Keening_Product was defeated before the game.

"Wise words. One day I may even understand what they mean." - Levellass
User avatar
K1n9_Duk3
Vorticon Elite
Posts: 779
Joined: Mon Aug 25, 2008 9:30
Location: Germany
Contact:

Post by K1n9_Duk3 »

If anyone wants to read some technobabble, here's the good stuff I uploaded for Hisymak that led to some of the new features:

http://home.arcor.de/k1n9duk3/files/hpsprites.zip (this will disappear in January 2017!)

This was originally supposed to be for Hisymak only, but I posted a link to the archive over at the RGB forum, so I might as well post it here, too. There are some typos and bugs in the readme.txt file, but it seems Hisymak was able to get it to work anyway.
Hail to the K1n9, baby!
http://k1n9duk3.shikadi.net
Hisymak
Vortininja
Posts: 112
Joined: Sat Mar 26, 2016 20:13

Post by Hisymak »

Hello and merry Christmas!

I wanted to tell you that I just found a Hocus Pocus graphics mod from the very past on the old forums. It is a Xmas-themed mod which changes the graphics of the first episode and was made by "Unknown Rabbit" (probably it's VioletCLM). I tried it and looks pretty nice, especially the second tileset and the backdrops. Some of you probably already know about this, so I wanted to let know those who didn't know about it yet.

Download link
Link to the original forum post

I was really surprised that the download link still worked after 12 years (it was made back in 2004) and even more surprised that such mod for Hocus Pocus actually exists. Unfortunately there is big lack of Hocus Pocus mods due to non-existence of modding tools and especially fully functional level editor for long years. This game definitely deserves some!

Do you know about any other existing Hocus Pocus mod? Or something made by you?
User avatar
Roobar
Vorticon Elite
Posts: 3263
Joined: Tue Jan 08, 2008 16:12
Contact:

Post by Roobar »

There's no download link for Doom Pocus.
Hisymak
Vortininja
Posts: 112
Joined: Sat Mar 26, 2016 20:13

Post by Hisymak »

Roobar wrote:There's no download link for Doom Pocus.
You're right. This is actually not a playable mod, I made it just for a quick demonstration of the new HocusEditor features and modding possibilities. The sprites are not aligned and do not look very good because of resizing from their original size.
Apart from that there's no reason to not make "Doom Pocus" public so here is download link for you: https://drive.google.com/open?id=0B_Lu2 ... lBKakRidWM
(to play the mod, open HocusEditor, click Tools -> Apply mod patch and select doompocus.ini file)

If you like the idea of "Doom Pocus", you or anyone could actually help make the graphics and levels for it. I'm a programmer, but not a graphics artist, so making graphics and good level design is not my personal ability.
Post Reply