10 December, 2011

SCUMM v3/v4 AD resource player

A new blog post again, yay!

Over the past weeks I used some of my free time to implement a (standalone) player for SCUMM v3/v4 AdLib music and sound effect resources. I published it in a git repo on github.

This project was born when I wanted to fix a few shortcomings with our AD support in ScummVM. A well known problem of our ScummVM implementation is that some sound effects are off. For example the door opening and closing sound effect in Monkey Island. There is a bit of information and most notably some recordings of that over here . Also we do not "loop" some sound effects correclty, most notable is the Indiana Jones 3 waterfall sound effect, see here. Technically these sound effects are not looped, but just have an infinite play time though. We also have some minor bug for music files, where (sometimes) the note frequencies do not exactly match the original.

My current adplayer should have none of these issues. I checked its OPL register writes for the beginning of the Monkey Island 1 intro and some sound effects, i.e. the door opening and the typewriter, in Indy3 and they matched the original interpreter. It's not well tested enough to say it's totally bug free though ;-).

One of the main problems with integrating the code in ScummVM would be to ensure savegame compatibility. This is a problem because to properly support the sound effects, we would need to implement a non-iMuse based player and hook that up instead of iMuse. Now all old savegames might contain iMuse save data and we would need to come up with a way to properly detect and skip/handle it. It might be notable that this is also an issue when you load savegames, which were made when you had AdLib sound configured, in a configuration which has PC Speaker or Creative Music System configured as output device.

Another problem is that we have support for what we call "Mixed AdLib/MIDI mode", which improves the game experience when using a MIDI device by playing AdLib resources when there is no (MT-32) MIDI data for sound resources (at least in the case of SCUMM). This feature is currently implemented via some magic in the iMuse code. Since we always play the MIDI data of SCUMM games via our iMuse implementation and as far as I know we cannot use a non-iMuse based output as fallback right now, adding my code would break "Mixed AdLib/MIDI mode" support for The Secret of Monkey Island for example.

Maybe I will find some time to look into how to fix these issues. For now I am happy to listen to some good game music outside of ScummVM ;-).

11 August, 2009

Kyrandia 1 Amiga completable

Today I tried to make a complete playthrough of Kyrandia 1 Amiga. It turned out I had to fix a few things, like the opcode used to display Kallak's Note and some potion animation related code. For the latter it turned out, that some offsets in kyra.dat were wrong, after fixing them up it worked like charm. After that I was finally able to complete the game. Yeah! I did not find any time to fix the credits yet though, so those are still a bit glitchy. I can not await merging of the MaxTrax playback code from the GSoC 2009 mod player branch. That might require some adjustments in the outro though, since unlike all other Kyrandia versions, the Amiga version seems to use a special sound file for that.

Anyway I made some screenshots of my playthrough. I just uploaded the nicest ones (IMHO) though. I hope you will like them :-).

After all the graphics are still nice, despite them using only 32 colors for the game screen.

For those of you who wonder: just because game is completable that does not imply that there is no more work to be done on it. For example I still need to check some bits I noticed in my playthrough, most important the colors of Brandon, when he is poisoned by the snake. The DOS version makes Brandon greenish when that happens, while the Amiga version does not change his colors at all (at least not in ScummVM). I will need to investigate that. Also I need to create an offset table for my German Kyrandia 1 Amiga version, which was kindly donated by sanguine (thanks to him again), so it can be used with ScummVM. And of course the aforementioned credits glitch needs to be fixed. And probably other bits I did not notice yet... :-).

More progress on Kyrandia 1 Amiga

Today I started to implement more differences in the Kyrandia 1 Amiga code. I finally got the GUI colors to work. Here is an screenshot of the text input field of the GUI.

Fixing up the colors of the GUI was quite easy. It was just a matter of changing some color values if the game platform is set to Amiga. The Amiga GUI uses color 17 for the background, and the colors 18 and 31 for the outlines. Color 18 is also used for the text field input background.

What was more work was to get the GUI strings to work. It turned out that the extraction routines, which extracted the strings from the original executable, were bugged. The Amiga version does use padding bytes now and then, so all strings start at even addresses. After I fixed proper handling of that, it worked just fine.

I was also able to implement palette differences for all opcodes I tested so far. This resulted in the grotto to be working now. Before I implemented the differences ScummVM always crashed, because the code tried to access non existent data. Funny here is that while the DOS version contained the special palettes in the executable, the Amiga version goes a much nicer way: All the special palettes are placed inside "PALETTE.DAT". This saved me some time finding the correct executable offsets for extraction. Now the fireberry glow palette for example works, which handles darkening of the grotto scenes, depending on the brightest fireberry in the scene and/or the players inventory. Here are some screenshots for that feature:

As you can see the brighter the fireberries are, the brighter the scene's color is.

The Will-O-Wisp also uses a special palette in the grotto. At first I thought it would work out of the box with the aforementioned changes, but sadly the Will-O-Wisp code has hardcoded palette handling, so I had to adjust that too. A little side note: I noticed that, when I wanted to make an screenshot of it for this blog entry ;-). Here comes a screenshot for the Will-O-Wisp in the grotto:

If I caught all palette differences, the game might be completable now. I probably missed some bits though. Of course there might be some other differences in the Amiga version, which might render the game not completable, but seeing how nice it worked so far, I doubt that is the case.

For the people interested why the palette differences might render the game not completable: I have an object / class handling palettes in the code. To catch all palette differences this code does assert out when the client code tries to access colors outside of the palette scope. This makes ScummVM quit when the code tries for example to use color 250 in a 32 color palette, which only offers colors 0 to 31. Of course that assertion also helps to catch out of bounds access in general cases too. So if now there is still a place I missed, which has hardcoded palette access based on the 256 color version, ScummVM will quit and that might render the game not completable. Of course that only applies if it is a critical point, which has to be passed, like for example the fireberry glow palette of the grotto was.

I also started to look a little bit into the outro / credits code. After implementing the differences, the outro works fine. The fewer colors of the Amiga version are noticeable here though. For example the Amiga version does not offer any Kyragem fading effects, as far as I can tell. I do not have any screenshot for that yet though, I will post some, when I really played the game till that point, instead of just using the ScummVM debugger for cheating ;-). The credits show up, but there are graphical glitches, like text not being aligned properly. I will need to take a look into that soon.

10 August, 2009

Kyrandia 1 Amiga

This time a really long time passed since the last post. I decided to make a new entry now, since there has been finally some progress on Kyrandia 1 Amiga. Some of you might know that we have an GSoC student working on support for various AMIGA sound formats (to be precise: TFMX for Monkey Island 1 Amiga and MaxTrax for Kyrandia 1 Amiga). You can find his blog over here. He already finished MaxTrax support. This gave me enough motivation to look into Kyrandia 1 Amiga again.

First of all I finally managed to implement a font renderer. That was a major PITA at first, but with help from nolange (the GSoC student) I was able to get a bit into how the library code on Amiga works. This helped to RE the font format, since it used blitting of the "graphics.library". With this information I was able to decode all the important information and write an implementation for rendering the fonts in ScummVM.

Here is some screen of a font use in the intro:

As you can see it works fine, even the colors seem correct. I do not have any Amiga to check that though.

Next I implemented some differences in the Amiga palette code. Kyrandia 1 Amiga uses two 32 color palettes. It splits the screen into two areas: the main game screen and the inventory. The first one uses a palette supplied by the scene files, the latter uses a fixed palette, which also includes all colors used by the items. Now the in-game parts looks nice too.

There was a major other palette difference I implemented too: Since the Amiga has not too many free colors, the game overwrites color index 16 with the correct font color every time a text is displayed. The original used some kind of switch statement to determine from the color index passed from the scripts, which color to set up in the palette. I did implement that too, I chose to cleanup the way it is done though. Here comes a funny side note: the Amiga version still uses the 256 color indexes from the DOS version for text processing. It uses fixed colors for the font: 16 and 19. Color 16 is the font color, while color 19 is the outline color, which is usually black. Now the Amiga text palette color setup code takes the DOS color index compares it to certain values and then sets up color 16 accordingly. The font drawing code on the other hand ignores the passed color indices and just uses the aforementioned colors.

Here are two in-game screens of Kyrandia 1 Amiga:

and here is how it looked before:

As you can see the interface changed the colors back then, since the whole screen used the scene palette.

Of course there is still plenty of work to do. For example the in-game GUI is still horribly broken color wise (and text wise). Just take a look at this screenshot:

I will also try to make some more blog updates now in the future. So long. See you in the next blog entry.

30 November, 2008

Kyrandia MIDI support

It's been some while since the last post on this blog, but there was nothing interesting I did on ScummVM in the meantime. Now I finally finished XMIDI support for the KYRA engine. The PC DOS version of Kyrandia should be supported with every major music output. Of course PC Speaker is still missing, but since nobody complained about missing support for it yet I guess it's rather ultra low priority :-). The MIDI output itself might have some minor glitches, but those seem to be timing related, since they don't happen every time and there are no valgrind warnings about anything related either. It might even be caused by the ScummVM XMIDI parser, which overwrites timing related meta events, to play at a fixed tempo, as far as I get it at least. Maybe I can fix it in the near future, but it should be fine now never the less. I hope there are some people out there, who will test it and give feedback about it :-).

It seems clone2727 can't joke about me not doing any serious coding anymore!

11 August, 2008

Lands of Lore, Coders::Block, GSoC

Weeeee long time no news, I know. But I finally got around to talk about the current state of things in this place of the world.

After _athrxx and I finished support for Kyra2, better known as Hand of Fate or for short: HoF, and Kyra3, better known as Malcolm's Revenge, I started to look into Lands of Lore support in the Kyra engine. I actually got around to extend the TIM, some script format used by Westwood for animations, used by Kyra2 to support the intro of the Lands of Lore CD Version. Also the character selection is up and working fine. Now all left is the actual in game, which means most of the work has still to be done ;-), apart the outro TIM script is not working currently, since it uses some different commands and additional opcodes. Might be old news to those of you who checking our ScummVM commit logs frequently, but well I actually didn't come around to write a blog entry about it. Now here it is!

For some people it was like wow Lands of Lore will be supported, but the reality is that I think I'm currently having yet another Coders::Block, I came across this nice pun in our IRC channel on freenode btw., so sadly I didn't came around to work on it this week :-/. It might be related to school starting again this week, thus I have no real motivation to work on something in the afternoon. Of course clone2727, who actually seems to make jokes about my blog on his, would now say I'm just lazy as always. Another problem actually might be that I started to play World of Warcraft again with some real life, yeah I know nobody suspects that I have that!, friends again, I hope I can keep my playtime low though.
I still hope I will get around to work a bit more on it in the next weeks. So there's no need to fear, since Lands of Lore will be worked on in the (near) future, and no we will not support Lands of Lore 2 and 3 in the future!

Last but not least I have to note over here that I really appreciate the work by my GSoC student Vincent Marti, you can find his blog over here btw. It is some real impressive work he had done on ScummVM's GUI this summer. I hope he can get rid of some bugs remaining this week and of course finish (or rather start ;-) the user documentation of the new theme description format. After all I feel I had been not a good mentor at all, at least he seems to make jokes in our IRC channel that I'm "the master of the torture chamber", I guess I didn't gave enough kudos to him.

11 May, 2008

Malcolm's Revenge supported as of today

Wee! I implemented the album and helium mode of Malcolm's Revenge today, thus Malcolm's Revenge is fully supported now by ScummVM. So I added a news item and a forum post today. I hope this time there will be some people reporting bugs and submitting screenshots. Last time, when Hand of Fate was announced, sadly just a few people reported bugs, and those even reported them before I announced support for Hand of Fate, but maybe I should be happy and take it as there were not much bugs :-).

Funnily as Eugene pointed out in IRC, he wrote a blog entry about Kyrandia yesterday. Another funny thing is that olhoh still did not catch up any of my Malcolm's Revenge related commits as of today. There is only one commit shown up there related to Malcolm's Revenge, but that one was not related to any real work on it.