Author Topic: C# AGI Interpreter  (Read 43600 times)

0 Members and 1 Guest are viewing this topic.

Offline Collector

Re: C# AGI Interpreter
« Reply #15 on: January 12, 2017, 08:57:49 PM »
Trying to open King's Quest 2 version 2.1, int 2.411 with the version of the library in Developer I get one error:

Code: [Select]
*** Opened vol.2: 0x3C890 bytes.
SKIPPING: Could not decode resource. The error given was:
Decode error in command 0xF6 at position 507.
Command must have at least two data bytes, found 0.
KQII Remake Pic

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #16 on: January 13, 2017, 06:58:23 PM »
I've realised I wasn't running against a clean install of KQ2.  :-[ It had a couple of extra pictures added to it that had been extracted from the AGI v1 KQ2 (which was part of some tests I did to prove that they were the same format as AGI v2 pictures - Interesting that AGI Studio renders them fine though). So we can discount those two pictures for now at least.

So I think I'm back to a clean install and I'm now getting the one error that you are also getting. I've tweaked the SKIPPING messages for decode failures so that it includes the resource number. From this I can see that it doesn't like picture 12. AGI Studio is quite happy with it though, but I extracted it and then loaded it in to PICEDIT (1.3M6) and it didn't like it, in fact it ended up hanging. I had to use the Windows Task Manager to kill it. Tried it in Linux as well and the same thing happened. Had to kill the process. But PICEDIT 1.2.1 (the first of the Java versions) loaded the picture without any issues.

I think I need to take a look at position 507 and see what is going on.

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #17 on: January 13, 2017, 07:04:43 PM »
It would appear that there is indeed an 0xF6 code without any subsequent data bytes. That's kind of redundant then. It might imply that the person that created the picture switched to the absolute line tool but didn't actually plot any points. AGI Studio and PICEDIT 1.2.1 seem to handle this fine and don't require at least one point, but the AGI Library and the newer PICEDIT versions appear to expect at least one point.

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #18 on: January 13, 2017, 07:10:49 PM »
Fixed that by commenting out the validation check in the AGI Library. Now it's got to position 980 in the same picture and complaining that a 0xF7 (relative line) doesn't have at least one point.

Edit: I think it's going to need more that just removing those checks during the decode. The drawing routine also needs to change to cope with no points for those actions.
« Last Edit: January 13, 2017, 07:17:23 PM by lance.ewing »

Offline Collector

Re: C# AGI Interpreter
« Reply #19 on: January 13, 2017, 09:03:58 PM »
Since this is with an official Sierra game I would say that the library needs to handle this in a way that will allow the resource to load.

You mention AGI Studio. It has no picture editor. Are you talking about its viewer?

KQII Remake Pic

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #20 on: January 14, 2017, 04:43:23 AM »
Yeah, I agree. I'm going to try to make it work with that picture this evening. I confirmed by walking ego in to room 12 that the interpreter doesn't like that picture after having ignored/commented out the errors about there being no point data. It then fell over trying to draw the picture for the room when entering that room.

Yeah, the Picture viewer in AGI Studio is what I was referring to. It draws the picture without any problems, which means that it doesn't require there to be any points at all for the line drawing commands. This is probably because it would have been tested with all the games in its early days and things like this discovered. It is probably why version 1.2.1 of PICEDIT (and presumably the old DOS version as well) would handle it. I probably forgot about this when making the more enhanced version of PICEDIT.

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #21 on: January 14, 2017, 05:12:07 PM »
I was in two minds about how to fix this. I started going down the path of retaining the point-less (pun intended) line commands in the data and add support for decoding, drawing, and encoding such cases. But then I started thinking that maybe the decode should just ignore the whole picture command. So that's what I'm doing now. If an absolute or relative line command doesn't have any points, then it gets filtered out (I could do the same for other tool commands as well). This would mean that if the AGI Library were used to simply load, decode, encode and then save, the end result would be different from what it started with. Visually the pictures would be identical, but the end result would have less data due to the do nothing commands having been removed. That feels okay to me. The purest in me wouldn't want someone to save picture 12 back in to KQ2 thereby removing such junk data, but I doubt anyone is going to do that unless they are making some kind of KQ2 mod game. For fan games, I think it is fine to filter out junk data.

Regardless, this approach has fixed the rendering of KQ2 picture 12 in the C# AGI interpreter.

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #22 on: January 14, 2017, 05:33:32 PM »
I've also noticed that what PICEDIT calls the Brush command hasn't been implemented yet in the AGI Library. This might be why the interpreter isn't able to load SQ2 at the moment. I recall that that game used a lot of that particular picture command.

It also doesn't support AGI V3 games. I tried loading one and it asked me if I was sure it was an AGI V2 game. So that is currently ruling out KQ4, GR, and the MH games. It is not too involved to add AGI V3 support to the AGI Library, but that's one of the things I'll leave until after I've got the interpreter working nicely with the AGI V2 games.

Offline Collector

Re: C# AGI Interpreter
« Reply #23 on: January 15, 2017, 10:48:56 AM »
I had never tried to load a AGI3 game with the library before, so I had missed this.
KQII Remake Pic

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #24 on: January 16, 2017, 02:18:44 PM »
I'm making further good progress on the interpreter. The message boxes are now fully implemented, so the print, print.v, print.at, and print.at.v commands are all working as they should. The display commands were already working prior to them. As far as text features go, there is still the menu system, the status bar, and the inventory screen that need to be built. None of that is there yet.

I have also started to add some user input. It now reacts to the user skipping an intro to get in to the game (i.e. have.key is working) and the arrow keys are also working for moving ego around. So its now possible to get in to KQ1 and KQ2 to walk around their outside areas from room to room, and for KQ3 to walk around the rooms of the castle where you start.

There is no said command input yet though, so it isn't possible to do things like enter a building by opening the door. I think I'm going to work on that next, as it opens up a whole lot more of what you can do within a game. The menu, status bar, and inventory screens are nice to haves in comparison.   :)

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #25 on: January 21, 2017, 03:04:17 PM »
I now have the user input line working, so I can "look castle", "show carrot", etc. Actually I picked up a carrot in the garden in KQ1, opened the goat pen, showed the goat the carrot, he started following me, and then I took him to the bridge with the troll and he took care of him for me. So parsing seems to be working well. I've also got the status line working now.

I then moved on to the set.key and controller commands but I realised in the process that I needed to refactor the way I'm handling key events. The controller checks are working to a degree, but it's not ideal. So I'm partway through fixing that up at the moment.

I've noticed a few bugs as I was walking around KQ1 that I'm planning to take a look at after that, and then I might move on to either the inventory screen or the menu.

Offline Collector

Re: C# AGI Interpreter
« Reply #26 on: January 21, 2017, 08:34:45 PM »
Sounds like you are making good progress. Perhaps too soon, but one thought just occurred to me. For a new interpreter it would be a good idea to have the save directory default to the user space, say "C:\Users\<User_Name\Saved Games\<Game_Name>".
KQII Remake Pic

Offline Kawa

Re: C# AGI Interpreter
« Reply #27 on: January 21, 2017, 08:55:32 PM »
Oh yes please, more games should use that location instead of mucking up My Documents. I have some minimal C# code if you need it, since last I checked System.Environment's locations list didn't have it.

Because you should never hardcode such things. Profiles can be moved, specific folders can be moved, they can be localized... Is it "C:\Users\Kawa\Saved Games", "C:\Gebruikers\Kawa\Opgeslagen Spellen", "D:\Saves", or are you even running on a Windows with that folder at all? Best to try to retrieve the Saved Games location, then use System.Environment.GetFolderPath to grab AppData\Roaming as a fallback if it throws up. That way, Mono will automatically return ~/.config too.
« Last Edit: January 21, 2017, 09:06:16 PM by Kawa »

Offline Collector

Re: C# AGI Interpreter
« Reply #28 on: January 21, 2017, 11:23:44 PM »
I would assume that Lance would simply grab it from the environment variable. Not even sure why you are even bringing it up.
KQII Remake Pic

Offline Kawa

Re: C# AGI Interpreter
« Reply #29 on: January 22, 2017, 06:48:43 AM »
There's an environment variable for that thing?

Edit: not on my system there isn't! Unless you meant the user profile path, which only answers half the question.
« Last Edit: January 22, 2017, 06:58:50 AM by Kawa »


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

Page created in 0.024 seconds with 23 queries.