diff --git a/ravi/CHANGES b/ravi/CHANGES index 47ecf26..a6ef7f7 100644 --- a/ravi/CHANGES +++ b/ravi/CHANGES @@ -1,3 +1,10 @@ +November 1, 2021 + - Merged version 0.5.4 of the original driver: + + June 16, 2005 - BETA 0.5.4 + - Turn off channels when their current instruments don't have a GM map + instead of defaulting to piano. + October 31, 2021 - A proper fix for 8086/80186 compatiblity, thanks to Jim Leonard. - Renamed the driver to "s2p.drv" diff --git a/ravi/s2p.asm b/ravi/s2p.asm index 30b0bf2..596d43a 100644 --- a/ravi/s2p.asm +++ b/ravi/s2p.asm @@ -5,13 +5,13 @@ ; GM on MPU-401 driver for SCI0 ; plays the MT-32 channels using Rickard's MIDI Mapping Magic ; (see http://freesci.linuxgames.com) -; assembles with NASM (see http://sourceforge.net/projects/nasm/): +; assembles with NASM (see http://nasm.sourceforge.net): ; nasm s2p.asm -o s2p.drv -f bin -; Copyright (c) 1999, 2000, 2002, 2003 by +; Copyright (c) 1999, 2000, 2002, 2003, 2005 by ; Rickard Lind ; Christoph Reichenbach -; Ravi Iyengar [ravi.i@softhome.net] +; Ravi Iyengar [ravi.i@rarefied.org] ; Andy Hefner ; ; This program is free software; you can redistribute it and/or @@ -115,6 +115,7 @@ pssndreset: db 0 ; boolean describing whether PauseSound should rese seekto: dw 0 ; the end point for SeekSound seekcue: dw 0 ; the desired sound cue at the end of SeekSound globalvol: dw 60 ; global volume on a scale of 0 to 63 +muteflags: dw 0 ; bit flag for each channel used to mute channels that have no GM instrument MIDI_mapping: times 128 db 0, 0, 0, 0, 0, 0, 0, 0 end_of_MIDI_mapping: ; used in ending loop conditions @@ -175,6 +176,13 @@ ExportTable: pop ax %endmacro +%macro __setne 1 + mov %1, 0 + je %%skip + mov %1, 1 +%%skip: +%endmacro + ; DriverInterface ; Saves registers and calls export ; Entry: bp = export number @@ -321,7 +329,7 @@ LoadSound: mov word [cs:pssndreset], 0 ; PauseSound does not reset by default mov byte [cs:fadeticks], 0 ; there is no fade in progress mov byte [cs:playstate], PLAYING ; we're playing this sound now - + mov cx, word [si+SND_VOLUME] shl cx, 1 shl cx, 1 ; we use a range of 0-63 for internal global volume @@ -581,11 +589,20 @@ StopNote: PlayNote: cmp byte [cs:playstate], PLAYING - je play_note + je check_mute add di, 2 ; we're just seeking, don't play anything ret + check_mute: ; check the channel mute flag + mov ax, 1 + shl ax, cl ; cl = channel + test word [cs:muteflags], ax + jz play_note + + add di, 2 ; skip over parameters + ret ; return without playing because the mute flag is set + play_note: mov al, dl call mpu_output @@ -629,7 +646,7 @@ ControlChange: pop bx je allow_cc ret ; ignore disallowed CCs - + allow_cc: mov al, dl call mpu_output @@ -671,13 +688,31 @@ PatchChange: test cl, 128 jz do_patch_change - mov cl, 0 ; we didn't find a mapped instrument, default to piano + mov al, dl + and al, 0x0F ; al = channel + cmp al, 9 ; see if this is the percussion channel + __setne al ; mute this channel unless it's the percussion channel + jmp set_channel_mute - do_patch_change: + do_patch_change: ; send the translated patch change to the mpu mov al, dl call mpu_output mov al, cl call mpu_output + mov al, 0 ; make sure the channel isn't muted + + set_channel_mute: + mov cl, dl ; dl is still the status + and cl, 0x0F ; cl = channel + mov bx, 1 + shl bx, cl + not bx + and word [cs:muteflags], bx ; clear the mute flag for the channel + xor bx, bx + mov bl, al + shl bx, cl + or word [cs:muteflags], bx ; set the mute flag for the channel if al is set + ret diff --git a/ravi/s2p.drv b/ravi/s2p.drv index 8053065..3d63698 100644 Binary files a/ravi/s2p.drv and b/ravi/s2p.drv differ diff --git a/ravi/s2p.txt b/ravi/s2p.txt index a4dcdcc..f3c62ff 100644 --- a/ravi/s2p.txt +++ b/ravi/s2p.txt @@ -9,14 +9,14 @@ The original documentation follows. ---------------------------------------------------------------------- gm -BETA 0.5.3 -Septermber 9, 2003 -Ravi I. [ravi.i@softhome.net] +BETA 0.5.4 +Jun 16, 2005 +Ravi I. [ravi.i@rarefied.org] The gm driver is a General MIDI sound driver for Sierra's SCI0 games. This covers games like Conquests of Camelot, Space Quest III, most copies of King's Quest IV, Leisure Suit Larry III, and so on. The latest version of -this driver is available from http://www4.ncsu.edu/~rniyenga/sci. +this driver is available from http://www.rarefied.org/sci/. The driver is licensed under the GNU GPL with specific permission for linking with Sierra's SCI0 interpreter. Full details are available in the file @@ -25,16 +25,16 @@ LICENSE. Source is available in the file gm.asm. Thanks to Rickard Lind and Christoph Reichenbach of the FreeSCI team (see http://freesci.linuxgames.com). Rickard wrote the patch mapping code in the file midi.c, which is copyrighted by him and Christoph. The code was -translated into assembly for inclusion into this driver. Additionally, -instead of muting the channel, the driver defaults to piano when an -instrument could not be mapped. +translated into assembly for inclusion into this driver. Contributors: + Rickard Lind Ravi Iyengar Andy Hefner + Christoph Reichenbach The driver also includes framework code. The framework driver is available -from http://www4.ncsu.edu/~rniyenga/sci/. +from http://www.rarefied.org/sci/. CAVEATS: This is an BETA version of the driver. Please feel free to report any bugs. To be especially helpful, include a patch.