Page fault while extracting mod's graphics

ModKeen mods Tiles and Sprites in all episodes of Commander Keen.
Post Reply
User avatar
Alopex
Posts: 34
Joined: Thu Jun 15, 2017 7:27 pm
Location: Bloogfoods, Inc.

Page fault while extracting mod's graphics

Post by Alopex »

Howdy!

I'm trying to extract graphics of some Keen mod to see how other modders work.

After downloading the mod, I put

Code: Select all

modkeen
and

Code: Select all

CWSDPMI.EXE
in the mod folder and also created the BMP directory. With this situation set, I launched the old fashion command:

Code: Select all

modkeen -episode=4 -export -bmpdir="BMP"
But strangely, modkeen returns some nasty page fault error, as shown in the following image.

Image

It's very odd because I always have export mod's graphics, and I don't know why I'm facing this problem.

Any suggestions?

Thanks a lot!

P.S: modkeen and CWSDPMI.EXE are taken from the Keen Galaxy Modding Package.
User avatar
Fleexy
Site Admin
Posts: 491
Joined: Fri Dec 12, 2008 1:33 am
Location: Bloogton Tower

Re: Page fault while extracting mod's graphics

Post by Fleexy »

This error means the program tried to access a memory location outside a range that was actually allocated. Given that the crash happened while exporting fonts, it is likely that ModKeen misinterpreted the offset to a character graphic (which is specified within the font chunk), causing it to add the decompressed chunk's address to the wrong offset and obtain an out-of-bounds address. IIRC, though it's been a long time since I used it, ModKeen always uses the game default EGADICT to compress and decompress graphics chunks. If the mod's graphics were compressed with a different EGADICT due to having used a different graphics importer, ModKeen's attempt to decompress them with the original EGADICT will produce garbage data with garbage font character offsets, causing this crash.

The solution is to use a graphics exporter that can handle a different EGADICT. KeenGraph can, and is pretty easy to use; there's also ModId if you need something more flexible, like for source mods. I tested the mod you mentioned to me in PM and KeenGraph was able to export its graphics.
User avatar
Alopex
Posts: 34
Joined: Thu Jun 15, 2017 7:27 pm
Location: Bloogfoods, Inc.

Re: Page fault while extracting mod's graphics

Post by Alopex »

Fleexy wrote: Sat Jul 30, 2022 3:00 pm This error means the program tried to access a memory location outside a range that was actually allocated. Given that the crash happened while exporting fonts, it is likely that ModKeen misinterpreted the offset to a character graphic (which is specified within the font chunk), causing it to add the decompressed chunk's address to the wrong offset and obtain an out-of-bounds address. IIRC, though it's been a long time since I used it, ModKeen always uses the game default EGADICT to compress and decompress graphics chunks. If the mod's graphics were compressed with a different EGADICT due to having used a different graphics importer, ModKeen's attempt to decompress them with the original EGADICT will produce garbage data with garbage font character offsets, causing this crash.

The solution is to use a graphics exporter that can handle a different EGADICT. KeenGraph can, and is pretty easy to use; there's also ModId if you need something more flexible, like for source mods. I tested the mod you mentioned to me in PM and KeenGraph was able to export its graphics.
I used KeenGraph to export its BMPs, and it worked!
Thanks a lot, Fleexy!
I knew what the Page fault error meant, but I was unable to understand how to solve that situation "Keen speaking". :)
User avatar
proYorp
Posts: 5
Joined: Sun Oct 21, 2018 12:31 am

Re: Page fault while extracting mod's graphics

Post by proYorp »

PSA: KeenGraph is buggy and it corrupts hitboxes of sprites in Goodbye, Galaxy, leading to weird clipping errors and falling through the floor. Huge pain to fix all that if you were to use it for modding.

ModId is for more than just source modding. The name can give some misconceptions but it's really just an updated version of ModKeen (which is like 20 years old). More stable and more features. It can do anything KeenGraph can do, without that gaping issue.

Thank you for listening to this Public Service Announcement. Have a headache-free day.
User avatar
Alopex
Posts: 34
Joined: Thu Jun 15, 2017 7:27 pm
Location: Bloogfoods, Inc.

Re: Page fault while extracting mod's graphics

Post by Alopex »

proYorp wrote: Tue Aug 02, 2022 8:10 pm PSA: KeenGraph is buggy and it corrupts hitboxes of sprites in Goodbye, Galaxy, leading to weird clipping errors and falling through the floor. Huge pain to fix all that if you were to use it for modding.

ModId is for more than just source modding. The name can give some misconceptions but it's really just an updated version of ModKeen (which is like 20 years old). More stable and more features. It can do anything KeenGraph can do, without that gaping issue.

Thank you for listening to this Public Service Announcement. Have a headache-free day.
Actually, I used KeenGraph only for exporting a mod's graphics which ModKeen was unable to do. As I said in the first post, I was curious about seeing how other modders have done their work, and this obviously was not intended to be related to a real project. For real projects (like the newborn Back To Fribbulus Xax mod), I use ModKeen.
User avatar
proYorp
Posts: 5
Joined: Sun Oct 21, 2018 12:31 am

Re: Page fault while extracting mod's graphics

Post by proYorp »

Ok cool, I wasn't sure if you were planning to continue with it to start editing. I've done that sometimes. (Also I saw your mod was released! I hope to have a chance to try that sometime soon.)


Sorry if my post came off as overly sarcastic or anything. This issue has caused a lot of frustration for me personally, but I didn't mean to direct that towards anyone in particular. ModId seems to be the only program that is reliably stable and doesn't have certain extra complications like the black/white masks, but nobody seems to know what it does (and I didn't either, so I want to share this to help anyone else that runs into these problems).


The thing is, KeenGraph's problem happens during exporting. The right half of the sprite images are almost always supposed to have a red box in the gray area to define the sprite's collision area. In this screenshot of a row of images extracted by KeenGraph, you'll notice that half the sprites are missing that red box.
Image
This issue only breaks the game once the blank hitboxes are imported, but if you want to use this to learn how sprites work, it's not going to be totally accurate to how it's supposed to be. Just something to keep in mind.

Also KeenGraph is sometimes unable to export mods that were edited with ModKeen, as I was just reminded while trying to double-check this.

You can do whatever you want of course, but I can't say I recommend KeenGraph for thoroughly studying other mods, unless the mod itself was already made using KeenGraph.
Post Reply