Community

AGI Programming => AGI Development Tools => Topic started by: AGKorson on March 06, 2021, 02:29:37 AM

Title: WinAGI Version 2.1.10
Post by: AGKorson on March 06, 2021, 02:29:37 AM
The console mode that I added in version 2.1.6 was a bit of a hack, and I just couldn't leave it that way. So here's an update that includes a separate executable, conWAGI.exe for running a windowless console mode. It's a much cleaner implementation and it supports importing games (creating WinAGI game files from an existing AGI game) and all three compile options. (The main app also includes a couple minor bug fixes.)

You can get the latest version from the AGI wiki (http://agiwiki.sierrahelp.com/index.php?title=WinAGI). Here's a direct link to the install file:
http://agiwiki.sierrahelp.com/images/8/8b/WinAGI_2_1_10.zip

I am still working on a C# version of WinAGI. I got the all the basic AGI library functions moved over, and have a working app that can display all resources. There are no resource editors or tools added yet, and it's not real stable; there are a ton of bugs, and it's easy to crash right now.

If anyone is interested, I guess I could share a link to the git files. Just don't make fun of my poor C# coding skills...
Title: Re: WinAGI Version 2.1.10
Post by: Collector on March 06, 2021, 07:01:37 PM
I wouldn't mind having a look. I understand that it is a wip. Nice to know you are making progress. For a C# logic editor take a look at FastColoredTextBox. https://github.com/PavelTorgashov/FastColoredTextBox
Title: Re: WinAGI Version 2.1.10
Post by: AGKorson on March 07, 2021, 05:11:13 PM
I sent you a PM.

I found FastColoredTextBox a month or so ago. It's pretty impressive. I was able to modify it to handle extended characters properly, which is important for working with AGI logics. I haven't added it to my project yet, though. I want to get the core functions and preview features to a more stable state before I begin working on the resource editors.  But certainly I'll be using FastColoredTextBox once I do build the logic editor.
Title: Re: WinAGI Version 2.1.10
Post by: ZvikaZ on March 08, 2021, 02:33:00 AM
If you've mentioned extended characters handling - it'd be nice to be able to choose the encoding of the extended character set.
It's not really important for me, as I export all the strings to a csv file, and they are translated by a team in a Google Drive, and then imported back to the logic files by a script - but still, it's a nice feature - if it's not too hard to implement.
Title: Re: WinAGI Version 2.1.10
Post by: Spikey on March 25, 2021, 02:44:23 PM
Hey Andrew,

Thanks for your awesome work on this program.

I noticed AppleII GS sounds can be opened but not extracted, despite the program extracting them. Is it possible to capture those extracted SND files in some way? If not, is there another way to do it that you know of?
Title: Re: WinAGI Version 2.1.10
Post by: AGKorson on March 26, 2021, 10:50:12 AM
You can use the export feature to extract those sounds. It's on the Resource menu. You can choose to export them as an AGI resource file, which keeps all the AGI formatting (you could then add them to another game if you wanted to), or you can export them as a MIDI/WAV file, depending on the type of sound.

Let me know if this helps, or if you still have questions.
Title: Re: WinAGI Version 2.1.10
Post by: Spikey on March 29, 2021, 01:34:35 PM
Thanks a lot man. I just had the wrong window open, got a bit lost in there. :) All sorted, thanks a lot!


EDIT: Question. It's been posited the AppleII GS version sends SysEx data at game launch. If this was correct, how would one go about extracting it?
Title: Re: WinAGI Version 2.1.10
Post by: AGKorson on March 30, 2021, 10:55:55 AM
That's a tough one. I know very little about Apple IIgs and how AGI actually works on that platform. I do have the binary files, and if I could find a decent dissassembler, I could probably figure it out. I did some searching, but haven't come across anything like IDAPro Free that would be useful. So unfortunately, I can't help much. I suspect there are some people out there who know more about Apple IIgs who might be able to answer that question for you.
Title: Re: WinAGI Version 2.1.10
Post by: Spikey on March 31, 2021, 10:53:44 AM
Thanks, man. Unfortunately the list of people who know about Sierra + Apple IIGS games is about as long as the people who actually know details about Sierra's MIDI implementation- something like less than 5, and they don't know each other. :P

Are you familiar with SCI games, where they utilise a 1.pat and other similar patch files for different MIDI devices? That's what I'm trying to find out here. I guess I don't even know if AGI is compatible with that. Although, the SND files that are in AGI Apple games seem very similar to the SCI SND files (although different enough to both SCI and AGI SND files that neither's convertors work).
Title: Re: WinAGI Version 2.1.10
Post by: AGKorson on April 02, 2021, 11:10:43 AM
Unfortunately, I know very little about SCI games. I spend enough time studying AGI, and have never had the time or interest to delve into the world of SCI.

As for converters, I'm not sure what exactly you mean. WinAGI is able to extract both MIDI and PCM sounds from IIgs games, which you can then export (i.e. convert) to the corresponding modern format. I admit that I don't have definitive answers as to exactly what each byte of data means in the sound headers, but using the assumptions I made, all IIgs sounds I've extracted sound legitimate. Here are my notes on both sound types, and how WinAGI handles them for doing the extraction:
Code: [Select]
  ' IIgs MIDI sounds:

  ' this function extracts the raw MIDI data from the IIgs sound
  ' and creates a new MIDI stream that is compatible with modern
  ' MIDI player format 

  ' length value gets calculated by counting total number of ticks
  ' assumption is 60 ticks per second; nothing to indicate that is
  ' not correct; all sounds 'sound' right, so we go with it
 
  ' the raw midi data embedded in the sound seems to play OK
  ' when using 'high-end' players (WinAmp as an example) but not
  ' Windows Media Player, or the midi API functions; even in
  ' WinAmp, the total sound length (ticks and seconds) doesn't
  ' calculate correctly, even though it plays;
  ' this seems to be due to the presence of 0FCh commands
  ' it looks like every sound resource has them; sometimes
  ' one 0FCh ends the file; other times there are a series of
  ' them that are followed by a set of 0Dyh and 0Byh commands
  ' that appear to reset all 16 channels
 
  ' eliminating the 0FCh command and everything that follows
  ' plays the sound correctly (I think)
 
  ' a common 'null' file is one with just four 0FCh codes, and
  ' nothing else, so ANY file starting with 0FCh is considered empty

  ' time values are supposed to be a 'delta' value
  ' but it appears that AGI used an absolute value; so if time
  ' is greater than 07Fh, it will cause a hiccup in modern midi
  ' players (we need to convert them to a valid delta time value)

  ' treat 0FCh as an end mark, even if found in time position
  ' 0F8h also appears to cause an end


  ' IIgs PCM (wav file) sounds:

  ' this function extracts the raw PCM data from a IIgs sound and
  ' adds a properly formatted WAV file header to it
   
  ' AGI header is 54 bytes for pcm, but its purpose is still mostly
  ' unknown; the total size is a word value at positon 08h; the rest of
  ' the header appears identical across resources, with exception of
  ' position 02h- it seems to vary from low thirties to upper 60s,
  ' maybe it's a volume thing?
 
  ' at position 06h is a word value of 02Ch = 44; this might be size
  ' of an internal header; there are 44 bytes of data, followed
  ' by 00-00 before the raw pcm data starts? (probably not - because at
  ' position 02Ah, there are six word values; 0C07Fh, 0236h, 0000h,
  ' 0C07Fh, 0236h, 0000h; this has the feel of two channel info,
  ' where both channels use the same data; 0C07Fh=49279; 0236h=566;
  ' 0C0h=192; 07F=127; 036h=54 not sure if any of these values
  ' are significant)
 
  ' at position 022h, there is a word value of 0203h = 8195; this
  ' might be the actual sample rate? it's close to 8000 (which was my
  ' original assumption) and it's really hard to tell the difference when either
  ' value is used for the exported sound
 
  ' all resources appear to end with a byte value of 0; not sure
  ' if it's necessary for wav files, but we keep it anyway

I figure it's a good idea to make this public information so others who are interested or are working on this can compare notes and (hopefully) improve on it.

Maybe this will be of use to you? Let me know if you become aware of any further information, especially if it affects how to correctly extract and convert the sounds for true replication. That way I can update WinAGI as well.
Title: Re: WinAGI Version 2.1.10
Post by: ZvikaZ on April 04, 2021, 09:22:26 AM
Thanks, man. Unfortunately the list of people who know about Sierra + Apple IIGS games is about as long as the people who actually know details about Sierra's MIDI implementation- something like less than 5, and they don't know each other. :P

I think you're too pessimistic...

Anyway, if you want information regarding Sierra's Apple IIgs games, I assume you've read http://www.agidev.com/articles/agispec/agispecs-9.html. Another, less known resource - https://wiki.scummvm.org/index.php?title=User:Buddha%5E/GSoC2007-ProjectDiary.
You might also want to just read ScummVM's implementation, it's not too long: https://github.com/scummvm/scummvm/blob/master/engines/agi/sound_2gs.cpp

Quote
It's been posited the AppleII GS version sends SysEx data at game launch.
Where have you seen that? I don't think it's accurate.

If it's true, you should be able to find it either in the game source files, or in the aforementioned ScummVM's 2gs 'driver'.
ScummVM doesn't have such code. I haven't searched the game source files, but I believe it's not there either. You can simply check it.

BTW, it won't help you with your 2gs query, but I have added a feature to ScummVM to dump MIDI commands, if using standard MIDI devices. Just run it with '--dump-midi'.
Title: Re: WinAGI Version 2.1.10
Post by: envoid on April 23, 2021, 09:45:54 PM
I've been working on a project for the IIgs, thank you Andrew as you are making it much more possible, and might be able to offer some info.

I've heard a good disassembler for the IIgs is FlamingBirdDisassembler (link below) but i haven't used it.

From what I think I know and have learned is the MIDI stuff is legit MIDI stored in the AGI files. Or it looks amazingly similar. I don't think it has any headers so would be considered raw I guess. The sound hardware on the IIgs is the Ensoniq 5503 DOC which has 64K of its own memory. A Yamaha keyboard or several were made on this chip as well. The SierraStandard game file is the soundfont for the AGI MIDI and fills the DOC's memory. It consists of about 34 samples though I think it should be 32 since there are 32 channels on the 5503. They are all 8bit unsigned PCM waves that butt against each other except one that is thought of as a timer sequence, but this is still unconfirmed. I've been trying to get into the code to understand which sample/channel is which instrument but I'm not so good with that and have resorted to sample wave comparison (and that sucks). A friend in the Apple II community disassembled KQ1 and can share that assembler source if that is helpful.

I did notice some of the PCM sounds played in WinAGI are fast. However, I think this is a trick they did to conserve space as the DOC can play samples faster or slower. An example is Sound4 on Space Quest for the IIgs. If you play it 0.4x the 8khz speed it sounds like it does in the game. I have no idea where it is told to do this and was hoping it was in the PCM header, but apparently not.

The one person that had all this knowledge was Carlos Escobar of Sierra but he never responded when others had reached out to him in the past. Sadly he passed away a decade ago.

For a feature request, i would love to be able to import IIgs PCM and MIDI sounds now that we can export them.  ;D

Hope this helps in some way.

https://www.brutaldeluxe.fr/products/thirdparties/tfbd/index.html (https://www.brutaldeluxe.fr/products/thirdparties/tfbd/index.html)

edit: just noticed the code area had a scroll...
Title: Re: WinAGI Version 2.1.10
Post by: brewton on November 01, 2021, 03:21:58 PM
Wow. I remember the first release of WinAGI way back when. I'm glad to see that it's still alive, and that people are still using it!
Title: Re: WinAGI Version 2.1.10
Post by: obscurenforeign on February 02, 2022, 05:18:30 PM
I'm back to... report another bug I found. Or I think this is a bug. Sorry.

This makes no sense, but if you save a project in WinAGI and then open it again later, all comments will disappear from the source code editor... it looks more like decompiled code. (In fact, I think it is decompiling the logics instead of using the saved source.) The comments thankfully don't disappear from the file on disk, I can still see them in notepad or if I open the .lgc files directly in WinAGI. It also complains about not being able to find AGI.wag. (It seems the file's being named AGIV2.wag instead.)

Attached is some before and after screenshots of a newly created template game and the game after closing WinAGI and opening it again.

E: Ok! I think I have a partial understanding of what's going on here... I hope this makes things easier for somebody.

WinAGI appears to be looking for the source code in a src directory but is instead saving it in a Resources directory. I'm not sure why though... Copying the lgc files from Resources to src makes them appear in the editor mostly-normally, but it'll think every logic needs to be recompiled.
Title: Re: WinAGI Version 2.1.10
Post by: AGKorson on February 02, 2022, 10:07:50 PM
Can you check which version you are using? If it's 2.1.10, I believe there was a bug with the 'New from Template' function. I thought I fixed it for 2.1.12. (The current dev version I have definitely fixes this. But I might be misremembering when I made the fix.)

What's happening is that the game file name and resource directory name aren't being properly renamed after they get copied from the template. The template game filename is 'AGIV2.wag', and the template resource directory is named 'Resources'. Which matches what you are describing. The wag file does have your new resource directory name (src), but since the copied directory didn't get renamed to 'src', when you re-open the game, it will create a directory named 'src', and then decompile the logics. Your solution is a good way to fix the problem.

And don't worry about the files being marked as needing to be recompiled; it's because once the decompiled logics are created, the CRC check gets reset, so replacing them with the original source files creates a CRC mismatch. It's no big deal- just do a game recompile and the CRC values will be restored.

Another easy workaround to this problem when you want to create a new game is to use file explorer to make a copy of the template into your desired new location, then edit the game properties, including the resource directory name the first time you open it.

The current dev version I have fixes a bunch of other bugs, mostly very minor stuff. I should be releasing another minor upgrade soon. Sorry for the inconvenience.
Title: Re: WinAGI Version 2.1.10
Post by: klownstein on February 02, 2022, 10:13:45 PM
I'm glad to know that I am not the only person to have had this happen! I ran into this less than a week ago and thought I'd done something crazy because all my comments and formatting throughout all my logics had seemed to disappear. I wasn't even able to retrieve them by opening my backups. All my comments/editing had just disappeared. I even uninstalled my old version of WinAGI and reinstalled the most current version to see if it would fix it, without success. I just started to process of trying to re-add comments and rename variables yesterday so I could read my code again. But, thanks to your post, I have been able to find that my comments aren't really gone into oblivion. I'm sure it was something I did that caused the issue, but I don't know what it was, so wouldn't be able to reproduce it (on purpose anyway). Thanks a million!
-klownstein
Title: Re: WinAGI Version 2.1.10
Post by: obscurenforeign on February 02, 2022, 11:25:33 PM
Can you check which version you are using? If it's 2.1.10, I believe there was a bug with the 'New from Template' function.
2.1.12 here. I made sure to download a fresh copy of WinAGI from the wiki. (Not that I really had a choice, it wasn't installed on my PC anymore.)

What's happening is that the game file name and resource directory name aren't being properly renamed after they get copied from the template. The template game filename is 'AGIV2.wag', and the template resource directory is named 'Resources'. Which matches what you are describing. The wag file does have your new resource directory name (src), but since the copied directory didn't get renamed to 'src', when you re-open the game, it will create a directory named 'src', and then decompile the logics. Your solution is a good way to fix the problem.

This was actually what clued me in. I decided to screw around (because what else will I do with hosed barely-developed source code?) with the data files in the project directory when I realized that the wag file is actually just plaintext. I saw "ResDir = src" and I figured I may as well try copying the lgc files over. (Afterwards I deleted the files in the src directory to see if they were even being accessed... and I made a backup of the project files after finding my comments gone, at least...)

I'm glad to know that I am not the only person to have had this happen! I ran into this less than a week ago and thought I'd done something crazy because all my comments and formatting throughout all my logics had seemed to disappear. I wasn't even able to retrieve them by opening my backups. All my comments/editing had just disappeared. I even uninstalled my old version of WinAGI and reinstalled the most current version to see if it would fix it, without success. I just started to process of trying to re-add comments and rename variables yesterday so I could read my code again. But, thanks to your post, I have been able to find that my comments aren't really gone into oblivion. I'm sure it was something I did that caused the issue, but I don't know what it was, so wouldn't be able to reproduce it (on purpose anyway). Thanks a million!
-klownstein
It's a really terrible feeling to lose a significant amount of work like that. I'm glad my post helped you! (Fortunately for me I barely wrote half a function before I had to close WinAGI, so my mood was mild annoyance...)

I'm just a bit amused that every time I try picking this program up again, I seem to find a brand new bug... no offense.
Title: Re: WinAGI Version 2.1.10
Post by: AGKorson on February 03, 2022, 11:38:51 PM
I'm glad to know that I am not the only person to have had this happen! I ran into this less than a week ago and thought I'd done something crazy because all my comments and formatting throughout all my logics had seemed to disappear. I wasn't even able to retrieve them by opening my backups. All my comments/editing had just disappeared. I even uninstalled my old version of WinAGI and reinstalled the most current version to see if it would fix it, without success. I just started to process of trying to re-add comments and rename variables yesterday so I could read my code again. But, thanks to your post, I have been able to find that my comments aren't really gone into oblivion. I'm sure it was something I did that caused the issue, but I don't know what it was, so wouldn't be able to reproduce it (on purpose anyway). Thanks a million!
-klownstein

I'm sorry you had trouble with this. It's hard to do thorough testing on such a complex application, but I still should have caught this one before release.

One thing I did make sure I incorporated into WinAGI was a philosophy of protecting game files as much as possible from catastrophic errors; it's pretty hard to make things actually disappear; backup copies are made of game files before running critical file operations, so if something does go wrong, it should be possible to recover. And if the WAG file gets corrupted, it may not know where resources are anymore but they aren't gone - they'll still be in the source directory.

I prefer (and strongly recommend) using the 'AutoExport' option (on the General tab of the Settings form) to always have backup copies of non-logic resources as well. That way, if disaster strikes your VOL and DIR files, you still have all your pictures, sounds, and views as individual files.

I am curious how you got into this situation - for the WAG file to get confused about the location of your source files, it had to have been modified somehow to point to the wrong subdirectory. If you still have the 'broken' WAG file on your system, can open it in a text editor and see what it looks like? It might give a hint as to what happened if I know what properties got changed. I'm hoping it's something you did, and not a bug! ;D

Oh, and btw, have you had a chance to check out Flag Quest? It's got code in there that shows how to move objects in a straight line. Check it out, and let me know if you have any questions. Hopefully it's something you can use in your project.


Title: Re: WinAGI Version 2.1.10
Post by: AGKorson on February 03, 2022, 11:47:20 PM
2.1.12 here. I made sure to download a fresh copy of WinAGI from the wiki. (Not that I really had a choice, it wasn't installed on my PC anymore.)

Yeah, I went back and checked the change history in github, and found that I made that fix AFTER releasing 2.1.12.

I'm just a bit amused that every time I try picking this program up again, I seem to find a brand new bug... no offense.

Well, it does suck a bit when I learn of these kinds of bugs- I always try to make sure everything is working before releasing it. But on the plus side, any extra help with testing is a good thing, so I can at least get these bugs fixed, and get an update out.

Speaking of which, I have another update that's pretty much ready for release, but before I do, are you aware of any other bugs (big or small) that I need to address? I'd like to get this out in the next couple of days.

Thx again for all the feedback!
Title: Re: WinAGI Version 2.1.10
Post by: ZvikaZ on February 04, 2022, 03:22:31 AM
Hi.
It's a good opportunity to say how much I, and I assume everyone here, appreciate your work on creating, and constantly improving, WinAGI.

Quote
I prefer (and strongly recommend) using the 'AutoExport' option
Suggestion - if this feature is strongly recommended, maybe you can turn it on by default? If someone dislikes it, it can always be turned off.
Title: Re: WinAGI Version 2.1.10
Post by: Collector on February 04, 2022, 09:22:36 AM
Hey Andrew, off topic , but how's progress on your C# implementation going?
Title: Re: WinAGI Version 2.1.10
Post by: AGKorson on February 04, 2022, 10:46:52 AM
Hi.
It's a good opportunity to say how much I, and I assume everyone here, appreciate your work on creating, and constantly improving, WinAGI.

Quote
I prefer (and strongly recommend) using the 'AutoExport' option
Suggestion - if this feature is strongly recommended, maybe you can turn it on by default? If someone dislikes it, it can always be turned off.

Thx for the compliment, I appreciate it.

AutoExport actually is on by default, at least it has been for all version 2 releases.

When you upgrade from one version to another, your settings (usually) get saved, so if you had it turned off before it will remain turned off even after an upgrade. This is actually an unintended side effect of how Windows stores the configuration settings file; it typically is put in the AppsData folder instead of the game directory, so when you remove an old version (an absolute must when upgrading), the config file doesn't usually go away. So when you reinstall the next version, WinAGI just grabs the previous config file and chugs along.) There are a few situations where Windows will kill the config file after uninstalling, but I haven't figured out exactly what's going on. I haven't spent a lot of energy trying to tweak the installation process, and have pretty much accepted what ever Windows throws at me as long as the program installs and runs.

So if you've ever disabled it in the past, it will (usually) remain disabled after an update. But it's easy enough to turn back on.
Title: Re: WinAGI Version 2.1.10
Post by: AGKorson on February 04, 2022, 10:54:28 AM
Hey Andrew, off topic , but how's progress on your C# implementation going?

I got most of the code working to load and view game resources; it's still quite buggy, and need a lot of work to clean up all the bad coding practices that come from the VB6 model. I haven't even started on any of the editors yet. That was almost a year ago.

I got sidetracked last year on another AGI project. I'm not ready to share that project yet - hopefully real soon. Once that's done I'll try to refocus on C#.

But I can't help myself from tweaking the VB6 code; I am using WinAGI a lot on my current project, and often come across new bugs and tweaks that I just can't ignore. Old habits (and familiar tools) die hard I guess.
Title: Re: WinAGI Version 2.1.10
Post by: Collector on February 15, 2022, 06:39:59 PM
I know what you mean about the VB practices. As I have noted elsewhere my SCI Audio Utilities started life as VB and its conversion to C# is how I first taught myself C#. It was mostly just a conversion when I should have just completely rewritten it in C#. Inevitable bugs are a result. I have it mostly refactored, but have not touched it in a while. I still need to finish the Unicode support, but have been distracted by other projects, too.