Author Topic: C# AGILE  (Read 84019 times)

0 Members and 1 Guest are viewing this topic.

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #90 on: October 12, 2022, 01:34:48 AM »
Navigating to each page of demos with F9 and F10 works once in a while

I have discovered the cause of this one, and have pushed a fix to my github repo. Haven't created a new build yet. The cause was that F10 shifts focus to the window menu, by default. Apparently this is the default behaviour for Windows apps. So what was happening is that F10 shifted focus to there, then pressing F9 after that meant that F9 was never seen by AGILE. It also meant that only every second F10 was making it into AGILE.

I have fixed this by suppressing the keypress event for F10. I found that solution on stackoverflow. Now it seems to be working quite well. The Function keys were tracked through the keydown and keyup events anyway, and not my keypress event handler, so it doesn't matter that keypress is suppressed for F10.

I may have to do something similar for other key combinations that we discover are behaving strangely.

Offline AGKorson

Re: C# AGI Interpreter
« Reply #91 on: October 12, 2022, 04:20:29 AM »
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?

Yes, that is correct. Earlier versions (2.440 and earlier) did not have the dissolve feature. Version 2.089 also had no global volume control (all notes played at whatever attenuation value assigned to the note). Global volume control was added in version 2.272.

In all versions the interpreter sets up a 60 Hz timer that manages sound output. When a sound is playing, at each tick, each channel is checked for a change in note, and then volume is set for each channel (by combining note attenuation with global attenuation).

Beginning with version 2.903, dissolve values were also combined to generate note volume. The dissolve data was an array of 68 bytes in 2.9x versions and 78 bytes in 3.x versions. At each timer tick, a pointer to the dissolve data would increment, until the end was reached (indicated by a value of 0x80h). If the sound was longer than that the last value was used, with no further dissolve changes. In 2.9x versions, the dissolve lasted 68 ticks (1.13 seconds), and in 3.x versions it lasted 78 ticks (1.3 seconds).

I haven't done much analysis of the hardware side of the sounds, so I don't know exactly how the sound chip is controlled. The IN and OUT port opcodes are used to manipulate the chip, but I don't know what exactly is happening.

Dissolve Data for 2.9x:
Code: [Select]
FE FD FE FF 00 00 01 01
01 01 02 02 02 02 02 02
02 02 03 03 03 03 03 03
03 04 04 04 04 05 05 05
05 06 06 06 06 06 07 07
07 07 08 08 08 08 09 09
09 09 0A 0A 0A 0A 0B 0B
0B 0B 0B 0B 0C 0C 0C 0C
0C 0C 0D 80

Dissolve data for 3.x:
Code: [Select]
FE FD FE FF 00 00 00 00
00 01 01 01 01 01 01 02
02 02 02 02 02 02 02 02
02 03 03 03 03 03 03 03
03 04 04 04 04 04 05 05
05 05 05 06 06 06 06 06
07 07 07 07 08 08 08 08
09 09 09 09 0A 0A 0A 0A
0B 0B 0B 0B 0B 0B 0C 0C
0C 0C 0C 0C 0D 80

If you want it, I could send you the assembly code for the sound functions so you can examine how the sound chip is manipulated.

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #92 on: October 12, 2022, 06:00:57 AM »
Yeah, that would be great, especially the bit with the application of the dissolve data. Thanks.

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #93 on: October 12, 2022, 10:46:19 PM »
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 also had the idea of saving the window size and location, and the last browse path, in some kind of preferences, but hadn't yet looked into how to implement it. Sounds like we're thinking along the same lines.

Did you want to open a pull request to my repo with those changes? I can then merge them. I'd be quite happy for you and others to start submitting changes.

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.

Strange. I would have thought that the same app would pick up the same config. Was it that the config was being associated with the version of the app? Or did I misunderstand? I'd probably have to see the changes to get a better idea of the cause. Glad that you found a fix for it though.

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.

Yeah, I was wondering why those extra DLL files had been added. I couldn't figure out how to stop it from adding those and wasn't sure what it was that had added them. I set up the installer project to use the output of the AGILE project as its input, and for some reason it added those DLLs.

Offline Collector

Re: C# AGI Interpreter
« Reply #94 on: October 13, 2022, 07:37:04 AM »
It seemed to me that we were thinking along the same lines, too. There were a couple of things that I was going to suggest, like checking for a game in the app's own folder so it could work like NAGI does, but as I started browsing through the code I saw you had already implemented them. My next day off I'll open a pull request.

The reason that it was not using the same config every time is that it automatically generates an AppData folder name if the assembly does not have complete versioning info. No problem if it has all if this info.
KQII Remake Pic

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #95 on: October 15, 2022, 12:09:42 AM »
My next day off I'll open a pull request.

Thanks.

I noticed that you've now forked the repo, so are probably preparing to create the pull request soon. FYI, I was committing a few changes over the past day, so I thought I might list some of the things I've been changing this week:
  • I only just pushed a change to also support ALT-ENTER for toggling full screen mode.
  • Fixed all of the "key input" issues that MusicallyInspired mentioned earlier from the AGI Demos. There were actually three different issues: (1) 0-9 couldn't be mapped to a controller, now fixed. (2) F10 was shifting focus to the window menu; now fixed. (3) Alpha keys were being added twice in some scenarios; also now fixed.
  • Fixed another issue seen in the AGI Demos (and KQ3) where display strings written on top of the status line were being overdrawn each interpreter cycle. The status line is now drawn only in the same scenarios as the original interpreter, so display command text will stay.

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #96 on: October 15, 2022, 12:24:01 AM »
Yeah, KQ4 is one that I've also noticed takes a while to load. AGILE actually decodes everything up front, which makes it a lot quicker when ego is walking between the various rooms, but for some of the larger games, the delay up front is noticeable. I haven't looked into where the majority of the time is being spent. The LZW decompression of all the V3 resources, in addition to decoding all the resources, might be why the V3 games take a while longer to load.

Ha! How embarrassing  :-[ ;D. I just noticed that AGILE is decoding the game twice. It does it once while deciding whether the selected folder contains a game, and then it does it again just before running the game. This obviously wasn't what I intended, so I've just fixed that locally (will push the fix in a few minutes) and the games are now "loading" twice as quickly. So in the case of KQ4, before fixing this, it was taking 8 seconds on my Surface tablet to start up, but now it takes 4 seconds.

I'm still going to add the "Loading..." text, but this change will make things noticeable quicker for some games.

Offline Collector

Re: C# AGI Interpreter
« Reply #97 on: October 15, 2022, 07:18:29 AM »
I had changed the full screen to Alt+Enter in my fork, too. I am trying to get used to the GitHub Desktop. It is a fair bit different than Bitbucket's Atlassian. After I installed it, it created a tutorial project that I deleted locally, but can't get rid of it on Bitbucket.

I wonder if it might not make a little more sense to move some of the game loading from the Program.cs to a AgileForm Form_Load event. This would allow the form to load right away and display a label that says "Loding". I have added it to load other settings like remembering form location and size.

I changed the aspect correction to base the ratio from the user's chosen width. I have not done anything about full screen aspect correction as that will have to be handled differently.
KQII Remake Pic

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #98 on: October 16, 2022, 07:18:18 AM »
I wonder if it might not make a little more sense to move some of the game loading from the Program.cs to a AgileForm Form_Load event. This would allow the form to load right away and display a label that says "Loding".

Yeah, I was thinking that I would have to make such a change to add in the Loading text.

I am trying to get used to the GitHub Desktop. It is a fair bit different than Bitbucket's Atlassian. After I installed it, it created a tutorial project that I deleted locally, but can't get rid of it on Bitbucket.

I have merged your pull request into my repo now. I'm not sure why, but when I was reviewing the diffs for the pull request, it looked like it had picked up a number of files that I don't think you had changed but were older versions of files that I had recently changed. They were probably the version of those files at the time that you created the fork and I had subsequently made changes to them. So as part of the review, I pushed back edits to your master branch to align those files with the latest version on my master at the moment. This included files such as TextGraphics.cs, UserInput.cs, Interpreter.cs, GameState.cs, and Commands.cs.

After merging the PR, the code wouldn't build, due to the post build events that had been added. They all failed due to the path not being found. The build errors that the github action encountered can be seen on github here:
(you'll need to be logged into github to see them):

https://github.com/lanceewing/agile/actions/runs/3259094831/jobs/5351675917#step:8:84

I had the same errors trying to build it on my PC.

So for now, I have removed those post build copy steps to get the build working again. The build is green again on github:

https://github.com/lanceewing/agile/actions

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #99 on: October 16, 2022, 07:37:07 AM »
For those who are interested in trying the latest, I have attached the most recently built AGILE zip to this message. This is the one from the latest green build on github.

@MusicallyInspired, do the tone channels now sound closer to what you would expect? I have now implemented the dissolve logic. To me, it sounds a lot better in some of the games I have tried, e.g. KQ4 and BC. I haven't yet changed anything with the noise channel, so in SQ2, the broom noises are still being cut short for some reason. It makes me wonder whether there is a general "cutting short" issue with sounds. I'll probably start looking into this now.

This build also has the various fixes for the AGI Demo 2 that you identified.

And it has Collector's changes, to add the context menu, and the saving of certain state, i.e. last game folder, and the window size and position.

Offline Collector

Re: C# AGI Interpreter
« Reply #100 on: October 16, 2022, 06:15:26 PM »
Yeah, I didn't make any changes to those AGI classes, only the form and settings files and whatever automatic changes to the AGILE.csproj.

As to the post build events, it would compiled just fine by adding a "bin" directory in the base project directory. Not needed, but I only had it as convenience to not have to dig through the sub folders to get to the new compile. It was also to only copy the needed files without things like the pdb and config files. Only the EXE, the AGILibrary.dll and NAudio dlls are needed for distribution. I had not intended it to be merged with your branch. I am still trying to get used to

I see that it is no longer adding the unneeded DLLs. Not sure if you managed it or it came from my branch. Removing the unneeded references fixed it.
KQII Remake Pic

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #101 on: October 16, 2022, 07:04:30 PM »
I see that it is no longer adding the unneeded DLLs. Not sure if you managed it or it came from my branch. Removing the unneeded references fixed it.

Yeah, that must have come from your changes.

Offline MusicallyInspired

Re: C# AGI Interpreter
« Reply #102 on: October 18, 2022, 08:40:04 PM »
I apologize I've been really busy.

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

Yes, as has already been said, this is the case. The SN76489 (and others in the family) just aren't complex enough to have settings for volume envelopes. It just generates the tones at the requested level and duration and that's it. The envelopes are all handled in software. In fact, among the Sierra tools that were leaked semi-recently there's one for the Tandy driver for SCI games that was used to create Tandy patch files that were solely meant for creating custom volume envelopes for each channel per game.

@MusicallyInspired, do the tone channels now sound closer to what you would expect? I have now implemented the dissolve logic. To me, it sounds a lot better in some of the games I have tried, e.g. KQ4 and BC. I haven't yet changed anything with the noise channel, so in SQ2, the broom noises are still being cut short for some reason. It makes me wonder whether there is a general "cutting short" issue with sounds. I'll probably start looking into this now.

This build also has the various fixes for the AGI Demo 2 that you identified.

One thing I noticed right away is it forces me to uninstall the previous version before installing the new one. I kind of wish it would just install right on top of it or at least offer a way to automatically uninstall it before installing instead of having to bring up Control Panel->Add/Remove Programs manually. I tried to install it to one of my additional hard drives but it complains about not having permission to write there (even though it creates the folder just fine) which forces me to run the installer as admin. But these are small gripes, especially for a beta.  ;D

That said, yes the sound is great! But unfortunately, while watching the SQ2 demo in AGI Demo Pack 1, the sound resources overlap. When Vohaul shows up on the screen the the SQ2 theme is still playing and doesn't stop. Then on the next screen the hovercraft sound overlaps with itself. And then that overlaps with the next screen, and the final short tune at the end. Basically sounds aren't stopping when they're supposed to somehow along the lines.

And yeah, the broom sound effect seems to be truncated. It does sound like a noise channel sound and not a tone like I previously erroneously thought.
Brass Lantern Prop Competition

Offline Collector

Re: C# AGI Interpreter
« Reply #103 on: October 18, 2022, 11:23:10 PM »
I am wondering if it might not be best to just zip Agile. An MSI seems a bit heavy handed for what can used for what is essentially a portable app. It needs no Registry entries or system files written. All settings are saved in its AppData folder during usage.

A zip or even an NSIS installer is more transparent as the files are easily extracted from either. Additionally, a zip distribution would allow the user to simply extract it to an AGI game folder to run that game automatically without any browse for game dialog, like NAGI.
KQII Remake Pic

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #104 on: October 19, 2022, 12:20:30 AM »
One thing I noticed right away is it forces me to uninstall the previous version before installing the new one. I kind of wish it would just install right on top of it or at least offer a way to automatically uninstall it before installing instead of having to bring up Control Panel->Add/Remove Programs manually. I tried to install it to one of my additional hard drives but it complains about not having permission to write there (even though it creates the folder just fine) which forces me to run the installer as admin. But these are small gripes, especially for a beta.  ;D

I recall that there was an option, when configuring the installer project, to force uninstall first. I might see what happens if I change that option to false, e.g. does it install on top instead.

That said, yes the sound is great! But unfortunately, while watching the SQ2 demo in AGI Demo Pack 1, the sound resources overlap. When Vohaul shows up on the screen the the SQ2 theme is still playing and doesn't stop. Then on the next screen the hovercraft sound overlaps with itself. And then that overlaps with the next screen, and the final short tune at the end. Basically sounds aren't stopping when they're supposed to somehow along the lines.

Hmmm, okay. I think I know what might be causing that. I'll look at that one next.

And yeah, the broom sound effect seems to be truncated. It does sound like a noise channel sound and not a tone like I previously erroneously thought.

I have found the cause of this. The SOUND resource decoding code wasn't calculating the end of the noise channel correctly. I've fixed this in my github repository and the broom sweeping sounds a lot better now. It will be in the next build I put out, which might be the start of next week.


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

Page created in 0.022 seconds with 23 queries.