Author Topic: Errors when compiling KQ3 with WinAGI  (Read 1295 times)

0 Members and 1 Guest are viewing this topic.

Offline rzil

Errors when compiling KQ3 with WinAGI
« on: August 14, 2023, 12:32:23 PM »
Hi,
In attempts to translate KQ3, I have tried compiling the scripts with WinAGI (version 2.3.1) but I couldn't. (as part of larger workflow using conWAGI for compilation *)
On clean version of the game from GOG... when opening the game and trying to compile using WinAGI GUI it fails on Sound36 resource.
deleting this resource allows compilation to finish successfully. (I haven't checked if it is affecting something else though)

using
Code: [Select]
"C:\Program Files (x86)\WinAGI GDS\conWAGI.exe" /c AGI.wag (from game's directory, after opening the clean game) just prints the following error
Code: [Select]
Error: Missing game property file (c).when also trying to use the clean game after removing Sound36 it keeps failing with same message.
trying the other commands available in conWAGI (including /i) fail with the same message replacing the letter with the letter of command.

Could please tell me if I miss something in usage (e.g. what is the appropiate command line or what's missing?) or help fixing it if it's an actual error?
Thank you ;D

PS, when I got the error I went to see if I can find what it is from the source code, but it appears to be of an older version (2.1.14).

* https://github.com/adventurebrew/re-quest/blob/master/tools/agi/import_all.py#L68
« Last Edit: August 14, 2023, 12:33:55 PM by rzil »



Offline AGKorson

Re: Errors when compiling KQ3 with WinAGI
« Reply #1 on: August 14, 2023, 04:48:51 PM »
Hi rzil,

KQ3 does in fact come with an invalid sound resource #36 in it. Sierra quite often shipped games with orphaned resources, or resources with bad pointers (that's the case here). The MSDOS interpreter is very forgiving of these kinds of errors - as long as the game doesn't try to access them, it happily runs the rest of the game.

WinAGI on the other hand (and I believe AGI Studio has similar behavior) is able to identify the bad pointer for sound 36 and mark it as invalid. As long as there's an invalid resource, WinAGI will not compile a game. That's the error you're seeing. The correct action is to remove the invalid resource (as you did).

I suppose I could have instead wrote the game compiler to ignore any invalid resources and compiling the rest (providing feedback to the user). But no one's ever suggested that's a feature that would be desirable. Not sure I would want to do that even if asked. I'd have to think about it.

Regarding the error from the console, I'll have to look into it. I didn't get a lot testers to look at the console app, so it's possible (probable?) that there are some errors still lurking about. A quick check of the app in my test environment shows the same behavior you're describing. So something is definitely wrong.  I'll take a look at it tonight and let you know what I find, and if there's a temporary fix available.

I'll be releasing version 2.3.2 when I finish my demo game, hopefully in the next month or so. I'll definitely include a fix for this once I figure it out.

thx for the bug report!

Offline AGKorson

Re: Errors when compiling KQ3 with WinAGI
« Reply #2 on: August 14, 2023, 05:24:11 PM »
LOL! I see what happened! The correct syntax for conWAGI is to put the wag file first, THEN the switches. So you should use
Code: [Select]
"C:\Program Files (x86)\WinAGI GDS\conWAGI.exe" AGI.wag /c
When I did my quick test, I didn't realize the arguments were backwards! Later, looking more closely I realized the problem.

So, try it again with the correct syntax. (Note you'll still need to remove the bad sound36, or the console will give you the same 'invalid sound resource' error as the windowed version.)

Offline rzil

Re: Errors when compiling KQ3 with WinAGI
« Reply #3 on: August 15, 2023, 02:22:55 PM »
Thank you, indeed switching the switches solved to issue with conWAGI.

Regarding removing Sound36, It have something odd.
When opening clean version of the game, attempting compile (with failure), removing sound36 resource and compiling again, it finishes with warnings only.
but if opening clean version of the game, then directly removing sound36 resource (without attempting to compile before), when compiling now, it will fail because sound36 is suddenly used in several places in scripts ???

So I'm not sure it can be safely removed (I was told it is actually the sound played when mannanan is casting a spell for making the player doing sport)

Offline AGKorson

Re: Errors when compiling KQ3 with WinAGI
« Reply #4 on: August 16, 2023, 12:34:52 AM »
Well, you are quite right, Sound 36 in KQ3 is definitely odd! I looked at it closer, and discovered that it IS a valid resource, at least in the sense that the entry in the SNDDIR file does in fact point to a resource in VOL.1 that can be loaded by the MSDOS interpreter. Track 0 of that resource is what you hear in the game (as you described).

HOWEVER, that resource has bad pointers for tracks 1, 2, and 3. All three of those tracks have starting and/or ending locations well beyond the end of the resource, meaning they don't point to any valid data.  Track 0 is 757 bytes long (151 5-byte notes, with trailing FF-FF marker). But the resource is 1035 bytes long. There are ~280 bytes of extra data; they contain notes that are nearly identical to the first 48 notes of track 0, but with slightly different duration and volume settings. I'd guess it's remnants of a previous version of the sound.

Logic 7 is where that sound gets used. It works in MSDOS because only track 0 is played. The bad data for the other tracks are never accessed so you never know there's a problem. The Sierra interpreter is full of examples where badly formatted resources run OK due to bugs and such.

WinAGI detects the bad track data and assumes the sound is no good. That's why it gives the invalid resource error. I assumed the error was an invalid pointer in SNDDIR (there are several Sierra games where I've seen that) but turns out I was wrong! Now that I understand what's going on I can update WinAGI to better handle this situation.

The only workaround I can suggest is to not do a full game compile; if you just compile dirty logics, the other resources (pics, views, sounds) are left alone. Or you could manually extract the resource from the VOL file, fix it in a hex editor, then import it back into sound 36. Or, you can just use the repaired sound file that I've attached to this thread. I'll make it a priority to do some kind of patch in the next version of WinAGI that can deal with this problem.


You also helped me find another bug in WinAGI - when compiling, all ResourceIDs are stored in a list so they can be used as defines. But when a resource gets deleted, its ResourceID isn't removed from the list. That leads to the odd behavior you are seeing. I'll fix that for the next version.

TL-DR:
Sound 36 is definitely needed in KQ3. It works in original MSDOS interpreter even though it has bad data in it. WinAGI sees the bad data and considers it an invalid resource. I need to update WinAGI to allow corrupt sounds as long as there's enough good data to play in MSDOS. A repaired version of Sound 36 is attached that you can use to continue working on the game in WinAGI current version.

Offline rzil

Re: Errors when compiling KQ3 with WinAGI
« Reply #5 on: August 17, 2023, 02:23:24 PM »
Thank you   :)

Offline rzil

Re: Errors when compiling KQ3 with WinAGI
« Reply #6 on: August 22, 2023, 01:59:02 PM »
Hi again, I experienced another issue with compiling KQ3, which I don't know if releated
When compiling the game (after patching the invalid resource sound 36, without other changes) and playing the result
The player can walk right through the cat (on room up from starting position, at random on enterance)
and can't interact with it (on original game, the cat blocks the player way)
Do you think it might be related to the previous issue with removing sound 36?

Offline lskovlun

Re: Errors when compiling KQ3 with WinAGI
« Reply #7 on: August 23, 2023, 12:30:45 AM »
Excuse me for butting in, but have you guys looked at the version of that sound in the now-public KQ3 repository? If I am doing this right, it is bigger and also not broken - but not being an AGI guy, I can't tell for sure.

Offline AGKorson

Re: Errors when compiling KQ3 with WinAGI
« Reply #8 on: August 23, 2023, 01:06:30 AM »
The version of KQ3 that I have (Version 2.14  3/15/88, as noted in Logic0) specifically calls the ignore.objs on the cat object in that room.

The room is Logic5. During first run of Logic5, it loads Logic104, which contains all code related to the cat. There's roughly a 1 in 3 chance the cat will appear. If it does, the cat is assigned to screen object o13. Immediately after running Logic5, the command
Code: [Select]
ignore.objs(o13);is called. So all other objects, including ego, ignore the cat and can walk through it. Curiously, this appears to be the only room where the cat is set to ignore objects.

I don't know why that's so.

Are you sure your version (unmodified) does NOT ignore the cat in that room? Because there is no way that editing a sound can affect a logic in that way.

Offline AGKorson

Re: Errors when compiling KQ3 with WinAGI
« Reply #9 on: August 23, 2023, 01:15:22 AM »
Excuse me for butting in, but have you guys looked at the version of that sound in the now-public KQ3 repository? If I am doing this right, it is bigger and also not broken - but not being an AGI guy, I can't tell for sure.
Can you share a link to that? I've never heard of a public repository for AGI games. The KQ3 version I have is 2.14, dated 3/15/88, and the files I used to find the sound36 issue come from disk images of my original 5.25 disks. I wonder what version is in that repository?

Offline Collector

Re: Errors when compiling KQ3 with WinAGI
« Reply #10 on: August 23, 2023, 06:56:06 AM »
I would love to see a link to it as well.
KQII Remake Pic

Offline lskovlun

Re: Errors when compiling KQ3 with WinAGI
« Reply #11 on: August 23, 2023, 09:49:51 AM »

Offline AGKorson

Re: Errors when compiling KQ3 with WinAGI
« Reply #12 on: August 23, 2023, 09:43:58 PM »
OK, thanks. My bad- I misunderstood and thought you meant the actual game files were made public.

I wonder what happened when the game was compiled by Sierra that caused sound36 to get truncated from what was in the source files...

Offline lance.ewing

Re: Errors when compiling KQ3 with WinAGI
« Reply #13 on: August 25, 2023, 04:14:17 AM »
A shame that this historical source is missing the VIEWs. I guess they're easy to come by but it would be nice for this repo to have the versions as they were at the same date as this source.

Offline Collector

Re: Errors when compiling KQ3 with WinAGI
« Reply #14 on: August 25, 2023, 10:40:36 AM »
Might be easy enough to recreate it. Determine the version number of the game from the scripts and take the other resources from the released game of the same version. Might still be missing things like any unused resources that were removed for the release version, etc.
KQII Remake Pic


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.039 seconds with 22 queries.