Author Topic: C# AGILE  (Read 84553 times)

0 Members and 2 Guests are viewing this topic.

Offline MusicallyInspired

Re: C# AGI Interpreter
« Reply #75 on: October 10, 2022, 11:40:13 AM »
Yeah, I'll probably have to go back to the sound, particularly the noise. Do the tone voices sound okay?

In what way is the noise gimped? Do you have a link to a video of SQ2 running on an IBM PC JR for comparison? Original machine rather than emulator. I couldn't find one online for SQ2. There are other games, like BC, but couldn't spot SQ2. I've been trying to implement it based on the SN76496 chip, and what is known about it, but I don't think it is quite right yet.

Actually it seems like it just doesn't make any sounds. Or if it does it tries to make sound with a tone instead of noise. I can't find any authentic IBM PCjr footage except for this video



The only noise that sounds however is when the hovercraft is moving at 1:18.

The only other thing I notice is that unlike the above footage, the tones don't have a volume envelope. The volume falls off at a certain rate on every tone on the PC jr and Tandy 1000. ScummVM's PC jr emulation is the most perfect I've heard both with noise channel and tone volume envelopes. Even better than DOSBox's.

Incidentally, I just tried running the AGI Demo 2 game (which has the SQ2 demo in it) and it doesn't seem to like it. Navigating to each page of demos with F9 and F10 works once in a while, but I can't hit a number to select a demo to run. It just doesn't respond.
Brass Lantern Prop Competition

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #76 on: October 10, 2022, 04:07:37 PM »
If you cannot speed up the loading, perhaps add a message that it is loading the game so the user knows it is working. At first I thought that AGILE failed to launch.

Yeah, I agree. I'll try to pop up something to show that it is loading, whether that is just a simple dialog, or the AGILE window in a loading mode. The AGILibrary did/does have code in it to show the progress of its decoding, but I disabled that, as it was very low level, and tended to slow things down. It's useful during development, particularly when a game is failing to load, but not really appropriate for a release version. I probably need a simple progress bar replacement, or simple message like you suggested.

Offline Collector

Re: C# AGI Interpreter
« Reply #77 on: October 10, 2022, 04:36:23 PM »
I'd say an AGILE window in a loading mode makes the most sense. Now that you mention it, I remember that Visual AGI showed a loading progress when loading a game. Perhaps put the progress bar in a second thread?
KQII Remake Pic

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #78 on: October 10, 2022, 06:13:11 PM »
Actually it seems like it just doesn't make any sounds. Or if it does it tries to make sound with a tone instead of noise.

It is definitely making a noise sound for me, quite distinct from the tone, but it probably isn't right yet. What does the rushing water sound like for you in Black Cauldron when you're in the scenes with the stream?

For King's Quest 2, the waves breaking are meant to make a noise sound, which I've seen on Youtube videos for the PC JR version. I know that AGILE doesn't sound right for that one either. It sounds a lot more like crashing rather than a wave breaking.

I can't find any authentic IBM PCjr footage except for this video



The only noise that sounds however is when the hovercraft is moving at 1:18.

Thanks. I'll take a look at that one later today.

The only other thing I notice is that unlike the above footage, the tones don't have a volume envelope. The volume falls off at a certain rate on every tone on the PC jr and Tandy 1000. ScummVM's PC jr emulation is the most perfect I've heard both with noise channel and tone volume envelopes. Even better than DOSBox's.

I have seen in the comments that DOSBox uses the MAME source code for this emulation. Haven't checked to see if they're currently in sync, but a comment in the code implies that it was at some point.

I think I see what bit in the scummvm code is handling this volume envelope. There is some "dissolve" data defined, which is set differently for different AGI versions. Hmmm, not sure how that could be the case though, as what you are describing sounds more like a feature of the hardware rather than AGI versions. But "dissolve" does sound like it might be related to what you describe. I noticed that NAGI also has that dissolve data defined (a comment in there also calls it "fade out"):

https://github.com/sonneveld/nagi/blob/master/src/sound/sound_gen.c#L46

From what you can hear, do you think that this "fade out" happens from the point that the tone ends, i.e. at the point that its duration count has ended? Or do you think it fades out leading up to the point where the duration count ends? - This distinction will determine whether each channel needs to generate/mix both its current tone and also the fade out of the previously tone simultaneously.

Incidentally, I just tried running the AGI Demo 2 game (which has the SQ2 demo in it) and it doesn't seem to like it. Navigating to each page of demos with F9 and F10 works once in a while, but I can't hit a number to select a demo to run. It just doesn't respond.

That sounds like something I can hopefully fix more quickly than how the sound sounds. I'll take a look later on.

Keep feeding through any issues you find. I think I'll start adding them as github Issues so that I can track what I've looked at and fixed.

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #79 on: October 10, 2022, 10:50:27 PM »
For King's Quest 2, the waves breaking are meant to make a noise sound, which I've seen on Youtube videos for the PC JR version. I know that AGILE doesn't sound right for that one either. It sounds a lot more like crashing rather than a wave breaking.

Actually, now that I've tried KQ2 again, the breaking waves in AGILE do sound very similar to SCUMMVM at the moment.

...and now that I've listened again to a video of the original sound, they're both similar to the original machine, but neither one sounds quite right.







The real machine sounds more... "watery/ocean-y/wavey", hard to describe what I mean, but AGILE and SCUMMVM sound artificial, whereas the original sounds like that wave breaking noise that we hear at the beach. Both AGILE and SCUMMVM seem to have this repeating smashing noise rather than a smoother noise.

Offline Collector

Re: C# AGI Interpreter
« Reply #80 on: October 10, 2022, 10:50:38 PM »
How difficult would aspect correction be? Ideally switchable.
KQII Remake Pic

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #81 on: October 11, 2022, 12:09:08 AM »
It shouldn't be too difficult to fix the height and width of the graphics so that it maintains the original aspect ratio. At the moment, it stretches to fill the window, which means you can make it look however you want, as the window is resizable. I haven't mentioned it yet, but you can press F11 to toggle full screen as well. I chose F11 to go full screen because it isn't a key that existed back when these AGI games were made, and F11 is the full screen key in browsers, so is familiar.

I'm wondering now how I might support the setting of the aspect ratio correction option. I want to avoid a launcher screen in the app itself, and I'd prefer not to have an options window, so I guess that leaves me with command line options and a config file. Hmmm, I guess I could have a certain key combination pop up an options window, a key or key combination that AGI doesn't use, but I think I'll hold off on that and start with the config file and command line options.

I currently have F12 as showing the priority screen, but that is an "undocumented" feature that I might remove, in fact I'd forgotten that I'd done that. So I could repurpose the F12 key to toggle aspect ratio correction, but there will be more options required at some point, and I'll quickly run out of non-AGI keys, so the config file and command line options will need to be introduced. I guess I could have F11 cover all display options, so F11 is toggle full screen and perhaps ALT-F11 toggles aspect ratio correction. Maybe CTRL-F11 and SHIFT-F11 could be other display related features at some point. I could make F12 multi featured like that as well, to toggle various things. Will I need more than 8 toggleable options?  ;D

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #82 on: October 11, 2022, 12:37:32 AM »
Incidentally, I just tried running the AGI Demo 2 game (which has the SQ2 demo in it) and it doesn't seem to like it. Navigating to each page of demos with F9 and F10 works once in a while, but I can't hit a number to select a demo to run. It just doesn't respond.

That sounds like something I can hopefully fix more quickly than how the sound sounds. I'll take a look later on.

This is happening in all 5 demo packs. Weird. Sometimes F9 works, sometimes it doesn't. For me, F10 seems to work every second time I hit it, and if I hold down F10, then it continuously scrolls through the pages, but it doesn't do the same thing when I hold down F9. The "H" key doesn't work, but SHIFT-H does work, but then "C" works fine without SHIFT.

Time to dig into the LOGIC scripts and my keyboard event handling code.

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #83 on: October 11, 2022, 01:48:08 AM »
The numbers 1-9 were easy to fix. I literally hadn't mapped those as keys that you can set a controller for!  :-[

So I can now start up the games, i.e. hit a number and then ENTER to play, but the F9 and F10 are still temperamental. That issue is different. When they do nothing, there isn't even a "key" on the waiting queue for it, so it must be a bug in the code that tracks when those keys are hit. I haven't started looking at why yet.

Not sure why, for me, the "h" key doesn't work unless I use it with SHIFT. The LOGIC script maps both "H" and "h" to the same thing. Obviously a bug in there somewhere.

Edit: I think I need to review the mappings for all other controller keys, as I think there will be more missing. Yeah, I can see quite a few that are missing. Probably not used much though.
« Last Edit: October 11, 2022, 02:02:56 AM by lance.ewing »

Offline Collector

Re: C# AGI Interpreter
« Reply #84 on: October 11, 2022, 08:57:13 AM »
Showing the priority screen makes sense given that the original Idea of the project was to be a way to test run a game in development. As to full screen you could just use the standard Alt+Enter that most applications use.

One other thought about full screen and aspect correction is that currently if you have the window stretched for aspect correction and then go to full screen it goes back to the starting aspect, letterboxed. For aspect correction full screen it would have to be pillarboxed. Some might want it stretched top to bottom, left to right.

I am going to try to upgrade to the latest VS in the next day or two so I can build this.
KQII Remake Pic

Offline Collector

Re: C# AGI Interpreter
« Reply #85 on: October 11, 2022, 12:53:29 PM »
I just installed VS2022 and the installer extension and got it to build. What 2019 was not telling me was that NAudio and the AGI library were compiled with a later target framework than AGIL  so the build failed. An easy fix. I easily implemented the aspect correction for windowed mode, though it could stand refinement. I just added a context menu in order to not use any of the function keys or adding a menubar and nothing else is using the mouse. It could easily be moved to any where else, from a key press or menubar.

Code: [Select]
        /// <summary>
        /// Turn aspect correctiion on
        /// </summary>
        private void cntxtMenuAspectCorrectionOn_Click(object sender, EventArgs e)
        {
            this.ClientSize = new System.Drawing.Size(960, 732);

            if (cntxtMenuAspectCorrectionOn.Checked == true)
                cntxtMenuAspectCorrectionOff.Checked = false;
            else
                cntxtMenuAspectCorrectionOff.Checked = true;
        }

        /// <summary>
        /// Turn aspect correctiion off
        /// </summary>
        private void cntxtMenuAspectCorrectionOff_Click(object sender, EventArgs e)
        {
            this.ClientSize = new System.Drawing.Size(960, 600);

            if (cntxtMenuAspectCorrectionOff.Checked == true)
                cntxtMenuAspectCorrectionOn.Checked = false;
            else
                cntxtMenuAspectCorrectionOn.Checked = true;
        }

This is just a quick and dirty fix. Turning it off just reverts to your default initial form size. Ideally it would based on the user's chosen overall window size. Also it does not address full screen.
KQII Remake Pic

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #86 on: October 11, 2022, 07:19:56 PM »
The only other thing I notice is that unlike the above footage, the tones don't have a volume envelope. The volume falls off at a certain rate on every tone on the PC jr and Tandy 1000.

Do you think that what the following web page describes is the same thing that you're describing above?

https://www.smspower.org/Development/SN76489#TheImperfectSN76489

If so, then at the moment it seems that I'm outputting the perfect square wave, but the real thing had this decay/leakage going on, that probably wasn't intended, but was a characteristic of the sound (??).

I was reading up on the SN76489 (the IBM PC jr used the SN76496, but it is essentially the same thing) and its use in the BBC Micro. Apparently BBC BASIC implemented a volume envelope within software, in order to create different sounds. I keep thinking back to the NAGI and scummvm source code, which has different dissolve data for different AGI interpreter versions:

https://github.com/scummvm/scummvm/blob/master/engines/agi/sound_pcjr.cpp#L105

Repeating the comment from the above source below:

Quote
   // 0 = no dissolve.. just play for as long as it's meant to be played
   // this was used in older v2.4 and under games i THINK
   // 1 = not used
   // 2 = v2.9+ games used a shorter dissolve
   // 3 (default) = v3 games used this dissolve pattern.. slightly longer

Is this true? Do interpreters 2.4xx and below not have any volume envelope decay happening? And do 2.9XX and V3 games have it, but with different lengths of "dissolve"?

If so, does this imply that the AGI interpreter is using software to manipulate the volume envelope?

I might need @AGKorson to weigh in on this with his knowledge from disassembling the various AGI interpreter versions.

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #87 on: October 11, 2022, 08:36:59 PM »
As to full screen you could just use the standard Alt+Enter that most applications use.

Yeah, that's a good call. I could support both. I tend to hang out in the browser quite a lot, both while working, and outside work, so F11 is what came to my mind first. But dosbox, scummvm, etc. are using Alt-Enter, so would be good to be consistent with them.

One other thought about full screen and aspect correction is that currently if you have the window stretched for aspect correction and then go to full screen it goes back to the starting aspect, letterboxed. For aspect correction full screen it would have to be pillarboxed. Some might want it stretched top to bottom, left to right.

Yes, I was imagining that if the aspect ratio correction is not active, then it would stretch to fill the full screen in both directions, but if aspect ratio correction is active, then it would be pillarboxed for most people, as they'd generally have a wider screen. How I imagine it working is the same as in scummvm, where if you resize the window, it dynamically adjusts, maintaining the aspect ratio (assuming that option is enabled). So depending on what size you've adjusted the window do, it could be either pillarboxed or letterboxed, within the window.

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #88 on: October 11, 2022, 08:55:41 PM »
I just installed VS2022 and the installer extension and got it to build. What 2019 was not telling me was that NAudio and the AGI library were compiled with a later target framework than AGIL  so the build failed. An easy fix.

That's good to hear, that you having it building now. I tried to make the target framework for AGILE 4.8 everywhere that I could find a setting for it. Is it that, when loading into VS2019, it changes back to an older version of the framework? I haven't tried this myself. I was using VS2017 the last time I worked on it, and VS2015 before that (I think). I did switch to the latest version of NAudio as part of recent changes.

I easily implemented the aspect correction for windowed mode, though it could stand refinement. I just added a context menu in order to not use any of the function keys or adding a menubar and nothing else is using the mouse. It could easily be moved to any where else, from a key press or menubar.

I quite like the idea of a context menu actually. I think it is a good middle ground between a config file/command line options and having a proper menubar or launch screen with options section. My preference is not to have a menubar in the actual game window, but a context menu might be okay. I guess it could support everything, i.e. config file, command line options, context menu, and keyboard shortcuts (assuming they're not used by the interpreter).

I may end up supporting the mouse within the interpreter itself, but that might not be for a while.

This is just a quick and dirty fix. Turning it off just reverts to your default initial form size. Ideally it would based on the user's chosen overall window size. Also it does not address full screen.

Yeah, I agree. It should ideally be based on the user's chosen window size. I haven't yet looked into it though. I've added it as an Issue to the github project, which I'm planning to use as my todo list.

Offline Collector

Re: C# AGI Interpreter
« Reply #89 on: October 12, 2022, 12:41:04 AM »
I thought an approach to working from the user's chosen window size would be to use the user's width and basing height as a ratio of that width. Shouldn't take that much to modify my code to do it.

As to a config, this is one of the strong points of dotNET. It has a native config system that writes an XML in a %AppData% sub folder. No need to touch the Registry. If you go to properties/settings from the Solution Explorer you can easily add settings to be saved automatically. In my build I have form location and size stored on close. I have also added a lastBrowsePath string to store the last opened game folder, so next launch the browse dialog will open to that folder. For debug purposes I added a "Open User.config" item to the context menu if there are problems. I did encounter a problem with it creating a completely new config on every launch instead of using the previous one. I fixed it by completing the version and file build info in the Assembly Information from Properties/Application tab. Now it uses the same config on every launch, at least per application location and/or user.

Also, several of the references and DLLs in the package are not needed. Some of the references are in the Windows directory. Microsoft.Win32.Registry is not needed by AGILE, So I removed it. Perhaps the installer needs it, but I have not looked at that, yet. For distribution the only files that are needed are the NAudio and AGILibrary DLLs and the main EXE.
KQII Remake Pic


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

Page created in 0.041 seconds with 24 queries.