60 Commits

Author SHA1 Message Date
athrxx
7b66f1191d KYRA: whitespace cleanup 2020-08-29 23:50:29 +02:00
athrxx
ed5f695c04 KYRA: (EOB/SegaCD) - fix warnings 2020-07-30 22:19:21 +02:00
athrxx
dda1559f03 KYRA: (EOB/SegaCD) - SegaCD sound effect adjustments 2020-07-30 22:19:21 +02:00
athrxx
8e800d44b1 KYRA: (EOB/SegaCD) - add sound driver 2020-07-30 22:19:21 +02:00
athrxx
9c1e8c99c6 KYRA: fix various warnings
(gcc warnings, valgrind 'conditional jump depends on uninitialized data and some valid cppcheck warnings)
2020-07-30 22:19:20 +02:00
athrxx
03a87dc6db KYRA: (EOB/SegaCD) - first part of camp menu
- fix preferences menu
- fix party resting
2020-07-30 22:19:15 +02:00
athrxx
73650a0f54 KYRA: (EOB/SegaCD) - fix main menu 2020-07-30 22:19:09 +02:00
athrxx
91b18f8343 KYRA: (EOB/SegaCD) - more graphics and sequence player code
- add support for the Sega Font and add text display methods at least for the sequence player
- finish sequence player (add all missing opcodes and other missing code portions)
- some improvement to the resource class
- some renaming and cleanup
2020-07-30 22:19:09 +02:00
athrxx
466a927738 KYRA: (EOB/SegaCD) - implement sequence player
This also (hopefully) involves most of the necessary graphics code. Text support is still missing. Otherwise, the intro and outro play mostly fine (except for some special opcodes).
2020-07-30 22:19:09 +02:00
athrxx
e4a33abfb5 KYRA: (EOB/SegaCD) - implement opening credits
Initial file handling, palette and graphics support. The opening credits get played satisfactory. Following up with the cinematics player will be much easier now...
2020-07-30 22:19:08 +02:00
NMIError
315bbc7b5b MIDI: Use driver-specific impl. for stopping all notes
When the MIDI parser wanted to stop all notes on a MIDI device, it would send
an All Notes Off message and, optionally, a Sustain off message on all 16 MIDI
channels. This is inefficient for devices like the MT-32, which uses only 9
channels. The MT-32 hardware is also quite slow, so it is more responsive if it
has to process less messages.

I've added a generic stopAllNotes message to the MIDI driver using the old
method, which can be overriden by more specific implementations in subclasses.
The Miles MIDI driver implementation sends All Notes Off only on the channels
used by the MT-32. There are probably also more efficient implementations
possible for f.e. AdLib.
2020-07-25 00:35:47 +02:00
NMIError
848d8315a6 MIDI/GROOVIE: Refactor XMIDI timbre chunk loading
XMIDI timbre chunk processing was implemented using a callback. This
reimplements this using an interface for the necessary driver method, which is
a somewhat cleaner solution.
2020-07-25 00:35:47 +02:00
NMIError
0af83d3faa
KYRA/MIDI: Fix minor MT-32/GM issues (#2333)
* KYRA: Added GM initialization for Lands of Lore

The original interpreter of Lands of Lore uses two executables, which
both do initialization of MIDI devices. The main executable runs a
sysex file for GM devices; the intro executable does not.

ScummVM only does MIDI initialization once and it performs this like
the intro executable. I've added the GM initialization of the main
executable. Note that the initialization file consists mostly of
sysexes which alter the display of the SC-55, so it's not particulary
useful. Not many games did this though, so I thought it would be a
fun feature to include.

I also noticed that the check which distinguishes between the two
demo versions of LoL did not work properly; the useAltShapeHeader
flag was true for both versions. I've changed it to check for the
existence of a PAK file which was only included with one of the two
demos.

* MIDI: Delay parser after handling SysEx events

This changes the way delays between SysEx events in MIDI data are handled from
delaying the backend to delaying the MidiParser.

SysEx events require a delay between events to ensure correct processing by the
MIDI device. This is usually implemented by calling OSystem::delayMillis.
Some games use some form of MIDI sequence filled with SysEx messages to
initialize the MIDI device. This is handled by the MidiParser. Using the
delayMillis method causes the following MIDI events to be "bunched up" and be
executed in a shorter timespan than intended.

I've altered this by making the MidiParser stop parsing when a SysEx event is
encountered and not enough time has passed since the last SysEx. After enough
time has passed, the next SysEx is sent and parsing resumes. To facilitate
this, I've introduced an alternate sysExNoDelay fuction on the MidiDiver. This
does not execute the delay itself, but instead returns the required delay time,
so the parser can handle this instead.

I've currently only implemented this method for the Miles MT-32/GM driver. For
other driver implementations, this will call the regular sysEx method and
return a 0 delay time, so there will be no change in behavior.

This restores a sound effect at the end of the Legend of Kyrandia MT-32 MIDI
initialization. Before, the Note On and Note Off events would be transmitted
instantly after each other, causing the notes not to play.

* MIDI: Add instrument bank fallback

Some games rely on a feature of the Roland SC-55 v1.xx that corrects invalid
instrument banks. This feature was removed in later versions of the device and
not implemented in most other GM devices, causing some MIDI data (sound effects
mostly) to play incorrectly.

Specifically, this applies to Lands of Lore. For example, in the intro, the
sound effect of the ring sparkling uses an incorrect instrument bank. Depending
on how the MIDI device handles this, the sound will play correctly, with the
wrong instrument, or not at all.

This commit emulates the SC-55 functionality that corrects the invalid bank
numbers. I've implemented this (partially) on the MidiDriver, so that it can be
re-used for other games (Xeen 4 and 5 also have this issue with some sound
effects).

* KYRA: Start MIDI playback after selecting track

The MIDI parser would automatically start playback after loading MIDI data, but
KYRA engine games use MIDI files with multiple tracks. Because of this it was
necessary to immediately stop playback after loading MIDI data, and then select
the track that should be played for correct playback. The parser now has a
feature to disable automatically starting playback, so I've implemented this
for KYRA.

* KYRA: Improve stopping MIDI playback

In two places All Notes Off events were sent on all channels to stop MIDI
playback of the background music. However, this will also cut off any MIDI
sound effects which are playing. Where needed I've replaced this with simply
stopping playback of the background music; the parser will turn off any active
notes.
I've also made sure playback is stopped before freeing the music data
memory to prevent any issues.
I've added sending All Notes Off events when the game quits, just in case any
hanging notes are not ended by the parsers (should not really be a problem
though).

* MIDI/KYRA: Add pausing playback to MIDI parser

* KYRA: Fix invalid track selection

If a game would attempt to play an invalid track, the parser would start
playing the previously selected track. Fixed this so the parser will not start
playing.
2020-06-20 23:27:30 +02:00
athrxx
975ec7b120 KYRA: fix nullptr dereference
This happens to Kyra 1 with the music set to MT-32, when the engine errors out prematurely due to a missing PAK file (before SoundMidiPC::init() is called).
2020-06-02 20:43:27 +02:00
NMIError
62387f8d38
MIDI/KYRA: Miles channel locking and GM support (#2273)
* MIDI/KYRA: Add channel locking and GM to XMIDI

This improves support for XMIDI channel locking and moves it from the KYRA
engine to the generic Miles MIDI driver. To support this, a source parameter
is added to the XMIDI parser and Miles driver so the driver can distinguish
several XMIDI parser instances sending MIDI events. I've also added GM support
to the generic Miles MIDI driver.

The previous implementation of channel locking did not always track and restore
controller values properly when unlocking a channel. Specifically, at the start
of Legend of Kyrandia, when Brandon talks to the tree, the tree "creaking"
sound effect uses some channels from the background music. The volume of the
music channels was not correctly restored, resulting in some instruments being
much louder then others.
Another issue was that volume was not always properly set when locking a
channel. In the Legend of Kyrandia intro, when Brandon is lifted up to the
house, some sound effects were missing because MIDI channel volume was 0.
This new implementation fixes these issues.

* MIDI: Suppress Miles controller warnings

Several Miles controller MIDI messages generate warnings in the XMIDI parser,
even though they are handled by the Miles drivers. I've removed these.

* MIDI: Fix Codacy issues
2020-05-29 17:50:14 +02:00
athrxx
eb501da161 KYRA: fix PC speaker driver (regression)
(seems that I accidently killed that in 46ef0109)
2020-05-24 02:13:15 +02:00
NMIError
c646bda078 KYRA: Add debug level to GS drumkit log message 2020-02-16 13:33:45 +02:00
NMIError
3628986b6d KYRA: Add debug message for GS drumkits 2020-02-16 13:33:45 +02:00
NMIError
18acefa6d2 KYRA: Apply correction for invalid GS drumkits
Lands of Lore sends several drumkit changes to Roland GS
devices with incorrect drumkit numbers. This would work
on some earlier devices like the SC-55, because they correct
these invalid selections. This change emulates the
corrections of the SC-55, so that the drumkit changes will
work on later Roland GS devices.
2020-02-16 13:33:45 +02:00
Bastien Bouclet
551ed6218a KYRA: Add override keywords 2020-02-09 12:43:15 +01:00
Eugene Sandulenko
cbfa891b0d KYRA: Added override keywords 2020-02-05 15:39:40 +01:00
athrxx
2ae66b7a00 KYRA: fix Pandora build
(missing #ifdef in case the EOB engine is disabled)
2020-02-01 21:35:03 +01:00
athrxx
0820b0617d KYRA: (EOB) - add PC Speaker driver 2020-02-01 21:09:49 +01:00
athrxx
46ef0109b5 KYRA: (EOB) - prepare for PC Speaker support
This commit does not include the actual driver. It only provides the necessary refactoring and resource handling.
2020-02-01 21:09:49 +01:00
athrxx
70e62a757b KYRA: (HOF) - fix bug #6314 (Wrong MIDI notes
sometimes heard at beginning of new s)

This is an attempt to fix that bug. It works for me, but it should see more testing.

I have tested the Windows "Microsoft GS Wavetable Synth" and our builtin MT-32 emulation. Both work fine with it. I presume the same will be true for all relevant hardware devices.

I haven't fully analyzed how the original driver silences the device (and I won't if I don't have to). My impression is that it does not send CC 0x78 (like I do). It seems to send only the CCs we have implemented (0x40, 0x60, 0x7B...). Maybe this whole bug is simply a race condition issue that the original didn't have...
2020-01-25 18:24:58 +01:00
athrxx
1b11def7bf KYRA: apply AdLib fix 12fd8cd4 to all Kyra games
The sound glitch has now been reported to also appear in EOB and LOL-Floppy. I was able to confirm at least LOL-Floppy.

And clipping from silence to max volume while doing a fade out really doesn't make much sense.
2020-01-18 21:52:32 +01:00
athrxx
12fd8cd45a KYRA: (LOK) - fix AdLib sound glitch (bug #11303) 2020-01-18 00:39:27 +01:00
athrxx
3dd3b61685 KYRA: (EOB/PC98) - fix music fadeout
(irrelevant to the game, since this function isn't used, but I like to fix it nonetheless)
2020-01-07 22:47:31 +01:00
athrxx
1403f9ffa2 KYRA: minor AdLib driver fix
This commit extends a fix that was previously limited to the EOB games. It seems that the later games can also have situations where this becomes necessary (e. g. I noticed that the HOF title music went missing when aborting the intro via left click).
2020-01-03 13:04:11 +01:00
athrxx
a48591ae0d KYRA: (HOF) - fix bug #10877 (Sound issues in the Legend of Kyrandia 2) 2019-12-22 19:09:34 +01:00
athrxx
64b897a560 KYRA: (EOB/PC98) - minor sfx code tweak
The original adds a delay after track 28.
2019-12-18 20:50:48 +01:00
athrxx
7cae73aae3 KYRA: (EOB/PC98) - initial startup fix
- hook up static resources, sound code, etc
- nothing really working yet, though (except the music)
2019-12-18 20:50:41 +01:00
athrxx
5cea166585 KYRA: (EOB/PC98) - add sound driver 2019-12-18 20:50:40 +01:00
athrxx
6651b08d31 KYRA: (EOB) - fix some typos in comments 2019-10-31 13:10:22 +01:00
athrxx
1a08072dea KYRA: (EOB/Amiga) - minor audio driver improvements
(mostly paranoia fixes)
2019-10-31 13:10:22 +01:00
athrxx
0e73472207 AUDIO: (FM-Towns/PC98) - cleanup mutex handling 2019-08-07 16:43:06 +02:00
athrxx
a6bf63bc1a SCI: revert accidental commits 2019-07-17 20:46:32 +02:00
athrxx
97ea9fd704 KYRA: (EOB/Amiga) - t 2019-07-17 17:38:24 +02:00
Cameron Cawley
d8248c14d6 ALL: Fix -Wnewline-eof warnings 2019-06-22 17:27:07 +01:00
athrxx
80f163b0fc ALL: revert accidental commits 2019-06-21 14:19:42 +02:00
athrxx
e2fa898021 KYRA: (EOB/Amiga) - t 2019-06-21 13:35:34 +02:00
Paul Gilbert
00acc57e31 KYRA: Fix VS unexpected end of file errors 2019-05-04 15:43:06 +10:00
athrxx
e28f6e1ead KYRA: - fix some license headers
Remove LGPL license part from files that shouldn't have them. I missed that when I rearranged that code a couple of weeks ago.
2019-04-30 01:12:25 +02:00
athrxx
f9cc32304f KYRA: (Adlib driver) - replace dead link reference removed in 94596c2
(new link provided by sev)
2019-04-30 00:55:55 +02:00
athrxx
94596c2b55 KYRA: (AdLib driver) - remove reference to dead web link 2019-04-29 23:39:28 +02:00
athrxx
4cb79db612 KYRA: add some #ifdefs for disabling EOB
Disabling EOB should already work without error. This adds some #ifdefs to recently added files.
2019-04-15 21:51:48 +02:00
athrxx
145edf0b94 KYRA: sound files/classes reorganization step #5
Rename some sound classes to reflect the recent file renamings.
2019-04-15 21:51:48 +02:00
athrxx
9144b8894e KYRA: sound files/classes reorganization step #4
Separate drivers from their wrapper classes and move them into their own files
2019-04-15 21:51:47 +02:00
athrxx
9d52746334 KYRA: sound files/classes reorganization step #3
Untangle FM-Towns and PC-98 sound classes and move them to separate files.
2019-04-15 21:51:47 +02:00
athrxx
a563817db0 KYRA: sound files/classes reorganization step #2
This is a followup to the last commit which fixes compilation. I wanted to have the pure file renaming separately.
2019-04-15 21:51:47 +02:00