#!/bin/sh
##################################################################################################
#			S O U N D   C O N F I G U R A T I O N   U T I L I T Y
#
#			pare of KCU		VER. 2.00
#
#		 				IDO BAR-TANA
# 		              COPYRIGHT (C) 1995. GNU Public License
# last updated: Jan 8, 1995
# 
# Support Files: KernelParams
# Modified Files: $AUTOCONF_H (defined below)
# Documentation Files: README.Users, README.Developers, kcu200.lsm, README.History
#
# This is a script to configure the linux kernel sound supportvia dialog boxes. 
# Writing of this script was motivated by my desire to learn shell programming. As it is my
# first semi-serious shell program, I suggest it be taken with the appropriate amount of salt.
# Please send all comments, bug reports and fixes to bartana@boulder.colorado.edu.
# 
# List of configuration dialog functions, in order of appearance:
# ===============================================================
# AudioMidi()		Digitized Voice and MIDI support
# AudioMidiFM()		Digitized Voice, MIDI, FM Synthesis, Adlib Comp
# DMABuffer()		"DMA Buffer Size"
# MSSoundSystem()	Microsoft Sound System
# PSS()			PSS (ECHO-ADI2111)
# 6850UART()		UART 6850
# MPU401()		MPU-401
# GravisDaughtercard()	Gravis Ultrasound Daughtercard
# YN16bitDaughtercard()	Yes/No Gravis Ultrasound Daughtercard
# GravisUltrasound()	Gravis Ultrasound
# ProAudioSpectrum()	Pro Audio Spectrum
# SoundBlaster16()	Sound Blaster 16 specific
# SoundBlasterPro()	Sound Blaster Pro specific
# SoundBlasterComp()	Sound Blaster General
# 
##################################################################################################

TEMP=./answer						# Holds user choices from dialogs
CHANGE_FILE=TempFile; export CHANGE_FILE		# Holds the params and their status from a

if test ! -s ./Sound.Settings   
then				#First Timer
FirstTimer=1
printf "\
#define CONFIGURE_SOUNDCARD 
#define KERNEL_SOUNDCARD 
#define EXCLUDE_PAS 
#define EXCLUDE_SB 
#define EXCLUDE_ADLIB 
#define EXCLUDE_GUS 
#define EXCLUDE_MPU401 
#define EXCLUDE_UART6850 
#define EXCLUDE_PSS 
#define EXCLUDE_GUS16 
#define EXCLUDE_GUSMAX 
#define EXCLUDE_MSS 
#define EXCLUDE_SBPRO 
#define EXCLUDE_SB16 
#define EXCLUDE_AUDIO 
#define EXCLUDE_MIDI 
#define EXCLUDE_YM3812 
#define EXCLUDE_SEQUENCER 
" >> ./Sound.Settings
fi
cp Sound.Settings Sound.Settings.old	#in case user dosn't want to commit changes. This is checked
					#back in Configure.kcu script

AUTOCONF_S=./Sound.Settings	# This is the file to be configured.			

##################################################################################################
# Description: Used from within dialogs, returns 'on' or 'off' according to the status of the
# 	passed parameter: returns 'on' if parameter is #define in $AUTOCONF_S and 'off' if its
# 	#undef or not there. The parameter and its status (set, unset or undefined) 
#	are copied to $CHANGE_FILE.
# Usage: onoff PARAM
# Modifies: $CHANGE_FILE appended by each call to onoff		 	
##################################################################################################
onoff(){
echo -n $1 " " >>$CHANGE_FILE		# dirty way to zap contents of a file without deleting it
grep -w $1 $AUTOCONF_S |awk ' \
BEGIN {status="undefined"}		
$1=="#define" {status="set"}
$1=="#undef" {status="unset"}
END {if (status=="undefined"||status=="unset") {print "off"} else {print "on"}
system("echo " status " >> $CHANGE_FILE")}'
}

##################################################################################################
# Description: Used from within dialogs, returns 'on' or 'off' according to the status of the
# 	passed parameter: returns 'on' if parameter is #define in $AUTOCONF_S and 'off' if its
# 	#undef or not there. The parameter and its status (set, unset or undefined) 
#	are copied to $CHANGE_FILE.
# Usage: onoff PARAM
# Modifies: $CHANGE_FILE appended by each call to onoff		 	
##################################################################################################
Soundonoff(){
echo -n $1 " " >>$CHANGE_FILE		# dirty way to zap contents of a file without deleting it
grep -w $1 $AUTOCONF_S |awk ' \
BEGIN {status="Soundundefined"}		
$1=="#define" {status="Soundset"}
$1=="#undef" {status="Soundunset"}
END {if (status=="Soundundefined"||status=="Soundset") {print "off"} else {print "on"}
system("echo " status " >> $CHANGE_FILE")}'
}

##################################################################################################
# Description: Used after dialogs, creates a summary of changes according to the user's choice 
# 	within the dialog. File 'SoundChangesSummary' includes lines with two fields each, separated
# 	by TAB, the first field is the changed parameter and the second is a description of the
#	change ('changed from set to unset', 'changed from unset to set', 'newly created'). 
#	Input is from `cat $TEMP $CHANGE_FILE`. Output is to file "SoundChangesSummary".
# Usage: NoteChanges
# Modifies: recycles $CHANGE_FILE (next dialog creates new one). 			 	
##################################################################################################
NoteChanges() {
cat $TEMP $CHANGE_FILE |awk ' \
NR==1 {UserChoice=$0}	  #The first line includes the ON parameters in the form of "1" "3" etc
$2=="set" && !match(UserChoice, "\"" NR-1 "\"") \
	{printf ("%s\t changed from set to unset \n", $1) >> "SoundChangesSummary"}
$2=="unset" && match (UserChoice, "\"" NR-1 "\"") \
	{printf ("%s\t changed from unset to set \n", $1) >> "SoundChangesSummary"}
$2=="undefined" && match (UserChoice, "\"" NR-1 "\"") \
	{printf ("%s\t newly created \n", $1) >> "SoundChangesSummary"}

$2=="Soundset" && match(UserChoice, "\"" NR-1 "\"") \
	{printf ("%s\t Sound card support changed from unset to set \n", $1) >> "SoundChangesSummary"}
$2=="Soundunset" && !match (UserChoice, "\"" NR-1 "\"") \
	{printf ("%s\t Sound card support changed from set to unset \n", $1) >> "SoundChangesSummary"}
$2=="Soundundefined" && !match (UserChoice, "\"" NR-1 "\"") \
	{printf ("%s\t Sound card support newly created \n", $1) >> "SoundChangesSummary"}
$2=="Soundundefined" && match (UserChoice, "\"" NR-1 "\"") \
	{printf ("%s\t Sound card support changed from unset to set \n", $1) >> "SoundChangesSummary"}'
echo "" >$CHANGE_FILE
}			# At this point SoundChangesSummary was appended with the new changes. 

##################################################################################################
# Description: Used after all changes have been made, seechanges displays a summary of changes.
# 	If no changes are made, displays goodbye box and exits script. It collects descriptions 
#	from file KernelParams, formats them and appends them to file ViewChanges. Then, invokes
#	dialog to display the file ViewChanges.
# Usage: seechanges
# Modifies: creates file ViewChanges			 	
##################################################################################################
seechanges () {
#Nothing to show. Just append to regular ChangesSummary if applicable.
if test ! -s SoundChangesSummary 
then
	exit
else
	cat SoundChangesSummary >> ChangesSummary

fi
}  

##################################################################################################
# Description: commits changes to $AUTOCONF_S, displays wrap-up dialog and exits.
# 	Displays wrap up message box and exits script. Uses file SoundChangesSummary
# Usage: CommitChanges
# Modifies: Backs $AUTOCONF_S to $AUTOCONF_S.bak, modifies $AUTOCONF_S, 
#	creates temporary files $AUTOCONF_S.tmp1 autoconf.tmp.			 	
##################################################################################################
CommitChanges() {

cp $AUTOCONF_S ./$AUTOCONF_S.tmp
sed "/* begin sound parameters */, /* end sound parameters */d" $AUTOCONF_S.tmp > $AUTOCONF_S.tmp1; mv $AUTOCONF_S.tmp1 $AUTOCONF_S.tmp
echo -en "/* begin sound parameters */ " >>$AUTOCONF_S.tmp

awk ' \
BEGIN { FS="\t"}
$2==" Sound card support changed from unset to set " \
	{LookFor="#define "$1" ";ChangeTo="#undef  "$1" "; \
	system( "sed \"s/" LookFor "/" ChangeTo "/\" \Sound.Settings.tmp>Sound.Settings.tmp1 ;mv Sound.Settings.tmp1 Sound.Settings.tmp")}
$2==" Sound card support changed from set to unset " \
	{LookFor="#undef  "$1" ";ChangeTo="#define "$1" "; \
	system( "sed \"s/" LookFor "/" ChangeTo "/\" \Sound.Settings.tmp>Sound.Settings.tmp1 ;mv Sound.Settings.tmp1 Sound.Settings.tmp")}
$2==" Sound card support newly created " \
	{LookFor="#undef  "$1" ";ChangeTo="#define "$1" "; \
	system( "sed \"s/" LookFor "/" ChangeTo "/\" \Sound.Settings.tmp>Sound.Settings.tmp1 ;mv Sound.Settings.tmp1 Sound.Settings.tmp")}
' SoundChangesSummary	


awk ' \
BEGIN { FS="\t"}
$2==" changed from unset to set " \
	{LookFor="#undef  "$1;ChangeTo="#define "$1" 1"; \
	system( "sed \"s/" LookFor "/" ChangeTo "/\" \Sound.Settings.tmp>Sound.Settings.tmp1 ;mv Sound.Settings.tmp1 Sound.Settings.tmp")}
$2==" changed from set to unset " \
	{LookFor="#define "$1" 1";ChangeTo="#undef  "$1; \
	system( "sed \"s/" LookFor "/" ChangeTo "/\" \Sound.Settings.tmp>Sound.Settings.tmp1 ;mv Sound.Settings.tmp1 Sound.Settings.tmp")}
$2==" newly created " {system( "echo -en \"\n#define "$1" 1\" >>Sound.Settings.tmp")}
$2==" value set to" \
	{LookFor="#define "$1" (.)";ChangeTo="#define "$1" "$3; \
	system( "sed \"s/" LookFor "/""/\" \Sound.Settings.tmp>Sound.Settings.tmp1 ;mv Sound.Settings.tmp1 Sound.Settings.tmp"); \
	system( "echo -en \"\n" ChangeTo "\" >> Sound.Settings.tmp")}
$2== " sound parameter value set to" \
	{LookFor="#define "$1;ChangeTo="#define "$1" "$3; \
	system( "sed \"/" LookFor "/d\" Sound.Settings.tmp>Sound.Settings.tmp1 ;mv Sound.Settings.tmp1 Sound.Settings.tmp"); \
	system( "echo -en \"\n" ChangeTo "\" >> Sound.Settings.tmp")}' SoundChangesSummary

echo -en "\n/* end sound parameters */" >>  $AUTOCONF_S.tmp

if ((grep -q "#undef  EXCLUDE_YM3812" $AUTOCONF_S.tmp && grep -q "#undef  EXCLUDE_MIDI" $AUTOCONF_S.tmp)|| grep -q "#undef  EXCLUDE_GUS" $AUTOCONF_S.tmp)
then
sed "s/#define EXCLUDE_SEQUENCER /#undef  EXCLUDE_SEQUENCER /" $AUTOCONF_S.tmp> $AUTOCONF_S.tmp1; mv $AUTOCONF_S.tmp1 $AUTOCONF_S.tmp
else
sed "s/#undef  EXCLUDE_SEQUENCER /#define EXCLUDE_SEQUENCER /" $AUTOCONF_S.tmp> $AUTOCONF_S.tmp1; mv $AUTOCONF_S.tmp1 $AUTOCONF_S.tmp
fi

if (grep -q "#undef  EXCLUDE_MSS" $AUTOCONF_S.tmp)
then
sed "s/#undef  EXCLUDE_SEQUENCER /#define EXCLUDE_SEQUENCER /" $AUTOCONF_S.tmp> $AUTOCONF_S.tmp1; mv $AUTOCONF_S.tmp1 $AUTOCONF_S.tmp
sed "s/#define EXCLUDE_AUDIO /#undef  EXCLUDE_AUDIO /" $AUTOCONF_S.tmp> $AUTOCONF_S.tmp1; mv $AUTOCONF_S.tmp1 $AUTOCONF_S.tmp
fi

if (grep -q "#undef  EXCLUDE_ADLIB" $AUTOCONF_S.tmp)
then
sed "s/#define EXCLUDE_YM3812 /#undef  EXCLUDE_YM3812 /" $AUTOCONF_S.tmp> $AUTOCONF_S.tmp1; mv $AUTOCONF_S.tmp1 $AUTOCONF_S.tmp
fi

if (grep -q "#undef  EXCLUDE_ADLIB" $AUTOCONF_S.tmp)
then
sed "s/#define EXCLUDE_MIDI /#undef  EXCLUDE_MIDI /" $AUTOCONF_S.tmp> $AUTOCONF_S.tmp1; mv $AUTOCONF_S.tmp1 $AUTOCONF_S.tmp
fi

cp $AUTOCONF_S.tmp $AUTOCONF_S

rm $AUTOCONF_S.tmp $TEMP $CHANGE_FILE SoundChangesSummary
exit

}


###############################################################
AudioMidi() {
dialog --title "Digitized Voice and MIDI support" \
       --checklist "\nchoose the options to enable:" 10 50 2 \
1 "Digitized Voice" `Soundonoff EXCLUDE_AUDIO` \
2 "MIDI" `Soundonoff EXCLUDE_MIDI` 2>$TEMP

if [ "$?" != "0" ] ; then return; fi 
choice=`cat $TEMP`
NoteChanges

}


AudioMidiFM() {
dialog --title "Digitized Voice, MIDI, FM Synthesis, Adlib Comp" \
       --checklist "\nchoose the options to enable:" 12 55 4 \
1 "Digitized Voice" `Soundonoff EXCLUDE_AUDIO` \
2 "MIDI" `Soundonoff EXCLUDE_MIDI` \
3 "FM Synthesis" `Soundonoff EXCLUDE_YM3812` \
4 "Adlib Compatibility" `Soundonoff EXCLUDE_ADLIB` 2>$TEMP

if [ "$?" != "0" ] ; then return; fi 
choice=`cat $TEMP`
NoteChanges

}

DMABuffer() {
dialog --title "DMA Buffer Size" \
       --radiolist "\nchoose the size of the sound card DMA buffer
The recommended values are: 
16384 - Gravis Ultarsound
        MPU-401
        6850 UART MIDI
32768 - ProAudio Spectrum
        Sound Blaster Pro
        Sound Blaster 16
65536 - PSS (ECHO-ADI2111)
        Gravis Ultrasound Max
        Gravis Ultrasound w/ Daughtercard
        MS Sound System" 23 50 4 \
4096 "" on \
16384 "" off \
32768 "" off \
65536 "" off 2>$TEMP

choice=`cat $TEMP`
echo -e "DSP_BUFFSIZE\t sound parameter value set to\t$choice">>SoundChangesSummary

}

MSSoundSystem() {
dialog --title "Microsoft Sound System Base Address" \
       --radiolist "\nchoose the base address of your Microsoft Sound System" 12 60 4 \
530 "(factory default)" on \
604 "" off \
E80 "" off \
F40 "" off 2>$TEMP
choice=`cat $TEMP` 
printf "MSS_BASE\t sound parameter value set to\t0x%s\n" $choice>>SoundChangesSummary
exit
dialog --title "Microsoft Sound System IRQ number" \
       --radiolist "\nchoose the IRQ number of your Microsoft Sound System" 12 53 4 \
7 "" off \
9 "" off \
10 "(factory default)" on \
11 "" off2>$TEMP
choice=`cat $TEMP` 
printf "MSS_IRQ\t sound parameter value set to\t$choice\n" >>SoundChangesSummary

dialog --title "Microsoft Sound System DMA channel number" \
       --radiolist "\nchoose the DMA channel of your Microsoft Sound System" 13 55 5 \
1 "" off \
3 "" off \
5 "" off \
6 "(factory default)" on \
7 "" off 2>$TEMP

choice=`cat $TEMP` 
printf "MSS_DMA\t sound parameter value set to\t$choice\n" >>SoundChangesSummary

}

PSS() {
dialog --title "PSS (ECHO-ADI2111) Base Address" \
       --inputbox "\n Enter the base address of your PSS (ECHO-ADI2111)
 factory default is 220" 10 55 2>$TEMP

choice=`cat $TEMP`
echo -e "PSS_BASE\t sound parameter value set to\t$0xchoice">>SoundChangesSummary

dialog --title "PSS (ECHO-ADI2111) IRQ number" \
       --radiolist "\nchoose the IRQ number of your PSS (ECHO-ADI2111)" 14 53 6 \
3 "" off \
4 "" off \
5 "" off \
7 "" off \
9 "" off \
10 "(factory default)" on 2>$TEMP
choice=`cat $TEMP` 
printf "PSS_IRQ\t sound parameter value set to\t$choice\n" >>SoundChangesSummary

dialog --title "PSS (ECHO-ADI2111) DMA channel number" \
       --radiolist "\nchoose the DMA channel of your PSS (ECHO-ADI2111)" 13 55 5 \
1 "" off \
2 "" off \
3 "(factory default)" on \
5 "" off \
6 "" off \
7 "" off 2>$TEMP

choice=`cat $TEMP` 
printf "PSS_DMA\t sound parameter value set to\t$choice\n" >>SoundChangesSummary

}
6850UART() {
dialog --title "UART 6850 Base Address" \
       --inputbox "\n Enter the base address of your UART 6850" 9 50 2>$TEMP

choice=`cat $TEMP`
echo -e "U6850_BASE\t sound parameter value set to\t0x$choice">>SoundChangesSummary

dialog --title "UART 6850 IRQ number" \
       --radiolist "\nchoose the IRQ number of your UART 6850" 13 53 5 \
3 "" off \
4 "" off \
5 "(factory default)" on \
7 "" off \
9 "" off 2>$TEMP
choice=`cat $TEMP` 
printf "U6850_IRQ\t sound parameter value set to\t$choice\n" >>SoundChangesSummary
}


MPU401() {
dialog --title "MPU-401 Base Address" \
       --radiolist "\nchoose the base address of your MPU-401" 14 53 6 \
310 "" off \
320 "" on \
330 "(factory default)" off \
340 "" off \
350 "" off \
360 "" off 2>$TEMP
choice=`cat $TEMP` 
printf "MPU_BASE\t sound parameter value set to\t0x%s\n" $choice>>SoundChangesSummary

dialog --title "MPU-401 IRQ number" \
       --radiolist "\nchoose the IRQ number of your MPU-401" 13 53 5 \
3 "" off \
4 "" off \
5 "" off \
7 "" off \
9 "(factory default)" on 2>$TEMP
choice=`cat $TEMP` 
printf "MPU_IRQ\t sound parameter value set to\t$choice\n" >>SoundChangesSummary
}

GravisDaughtercard() {
dialog --title "Gravis Ultrasound Daughtercard Base Address" \
       --radiolist "\nchoose the base address of your Daughtercard" 12 60 4 \
530 "(factory default)" on \
604 "" off \
E80 "" off \
F40 "" off 2>$TEMP

choice=`cat $TEMP` 
printf "GUS16_BASE\t sound parameter value set to\t0x%s\n" $choice>>SoundChangesSummary

dialog --title "Gravis Daughtercard IRQ number" \
       --radiolist "\nchoose the IRQ number of your Gravis Daughtercard" 13 53 5 \
3 "" off \
4 "" off \
5 "" off \
7 "(factory default)" on \
9 "" off  2>$TEMP

choice=`cat $TEMP` 
printf "GUS16_IRQ\t sound parameter value set to\t$choice\n" >>SoundChangesSummary

dialog --title "Gravis Daughtercard DMA channel number" \
       --inputbox "\n Enter the DMA number of your Gravis Daughtercard
 factory default is 3" 10 55 2>$TEMP

choice=`cat $TEMP` 
printf "GUS16_DMA\t sound parameter value set to\t$choice\n" >>SoundChangesSummary
}


YN16bitDaughtercard() {
dialog --title "16 bit Ultrasound Daughter Card" \
       --yesno "Does your Ultrasound have a 16 bit doughter card?" 8 45 

case $? in
        0) GravisDaughtercard;;	#yes
	1) ;;	#no
esac
}


GravisUltrasound() {
dialog --title "Gravis Ultrasound Base Address" \
       --radiolist "\nchoose the base address of your sound card" 14 53 6 \
210 "" off \
220 "(factory default)" on \
230 "" off \
240 "" off \
250 "" off \
260 "" off 2>$TEMP
choice=`cat $TEMP` 
printf "GUS_BASE\t sound parameter value set to\t0x%s\n" $choice>>SoundChangesSummary

dialog --title "Gravis Ultrasound IRQ number" \
       --radiolist "\nchoose the IRQ number of your Gravis Ultrasound" 15 53 7 \
3 "" off \
5 "" off \
7 "" off \
9 "" off \
11 "" off \
12 "" off \
15 "(factory default)" on 2>$TEMP
choice=`cat $TEMP` 
printf "GUS_IRQ\t sound parameter value set to\t$choice\n" >>SoundChangesSummary

dialog --title "Gravis Ultrasound DMA channel number" \
       --radiolist "\nchoose the DMA channel of your Gravis Ultrasound" 13 55 5 \
1 "" off \
3 "" off \
5 "" off \
6 "(factory default)" on \
7 "" off 2>$TEMP

choice=`cat $TEMP` 
printf "GUS_DMA\t sound parameter value set to\t$choice\n" >>SoundChangesSummary


}

ProAudioSpectrum() {

dialog --title "Pro Audio Spectrum IRQ number" \
       --radiolist "\nchoose the IRQ number of your Pro Audio Spectrum" 19 53 10 \
4 "" off \
5 "" off \
7 "" off \
8 "" off \
9 "" off \
10 "(factory default)" on \
11 "" off \
12 "" off \
13 "" off \
14 "" off 2>$TEMP

choice=`cat $TEMP` 
printf "PAS_IRQ\t sound parameter value set to\t$choice\n" >>SoundChangesSummary

dialog --title "Pro Audio Spectrum DMA channel number" \
       --radiolist "\nchoose the DMA channel of your Pro Audio Spectrum" 14 55 6 \
1 "" off \
2 "" off \
3 "(factory default)" on \
5 "" off \
6 "" off \
7 "" off 2>$TEMP
choice=`cat $TEMP` 
printf "PAS_DMA\t sound parameter value set to\t$choice\n" >>SoundChangesSummary

}

SoundBlaster16() {
dialog --title "16 bit DMA channel for Sound Blaster 16" \
       --radiolist "\nchoose the 16 bit DMA channel" 11 47 3 \
5 "" off \
6 "(factory default)" on \
7 "" off 2>$TEMP

choice=`cat $TEMP` 
printf "SB16_DMA\t sound parameter value set to\t$choice\n" >>SoundChangesSummary

dialog --title "MIDI address base for Sound Blaster 16" \
       --radiolist "\nchoose the MIDI address base of your Sound Blaster 16" 10 58 2 \
0 "MIDI address at 300 " off \
3 "MIDI address at 330 (factory default)" on 2>$TEMP
choice=`cat $TEMP` 
printf "SB16MIDI_BASE\t sound parameter value set to\t0x3%s0\n" $choice>>SoundChangesSummary
}


SoundBlasterPro() {
onoff __SGNXPRO__ >/dev/null

dialog --title "SG NX Pro Mixer" \
       --yesno "Do you want to support the SG NX Pro mixer?" 8 45 

case $? in
        0) echo -n "\"1\"" >$TEMP;;     #yes
        1) echo -n "\"2\"" >$TEMP;;     #no
esac
NoteChanges
}

SoundBlasterComp() {
dialog --title "Sound Blaster and Compatibles Base Address" \
       --radiolist "\nchoose the base address of your sound card" 14 53 6 \
210 "" off \
220 "(factory default)" on \
230 "" off \
240 "" off \
250 "" off \
260 "" off 2>$TEMP
choice=`cat $TEMP` 
printf "SBC_BASE\t sound parameter value set to\t0x%s\n" $choice>>SoundChangesSummary

dialog --title "Sound Blaster and Compatibles IRQ number" \
       --radiolist "\nchoose the IRQ number of your sound card" 13 53 5 \
2 "" off \
5 "(factory default, model dep)" on \
7 "(factory default, model dep)" off \
9 "(same as 2)" off \
10 "" off 2>$TEMP

choice=`cat $TEMP` 
printf "SBC_IRQ\t sound parameter value set to\t$choice\n" >>SoundChangesSummary

dialog --title "Sound Blaster and Compatibles DMA channel number" \
       --radiolist "\nchoose the DMA channel of your sound card" 12 55 4 \
0 "(supported by SB Pro)" off \
1 "(for SB cards versions 1.0 1.5 2.0)" on \
2 "" off \
3 "" off 2>$TEMP

choice=`cat $TEMP` 
printf "SBC_DMA\t sound parameter value set to\t$choice\n" >>SoundChangesSummary

}

main_menu() {
dialog  --title "Sound Card Configuration" \
        --checklist "\nCheck the sound cards in your system. KCU does not
yet validates card combinations, so make sure your
selections can live together." 21 60 10 \
                1 "Plain Sound Blaster..." `Soundonoff EXCLUDE_SB` \
                2 "Sound Blaster Pro..." `Soundonoff EXCLUDE_SBPRO` \
                3 "Sound Blaster 16..." `Soundonoff EXCLUDE_SB16` \
                4 "ProAudioSpectrum 16..." `Soundonoff EXCLUDE_PAS` \
                5 "Gravis Ultrasound..." `Soundonoff EXCLUDE_GUS` \
                6 "Gravis Ultrasound Max..." `Soundonoff EXCLUDE_GUSMAX` \
                7 "MPU-401..." `Soundonoff EXCLUDE_MPU401` \
                8 "6850 UART MIDI..." `Soundonoff EXCLUDE_UART6850` \
		9 "Microsoft Sound System..." `Soundonoff EXCLUDE_MSS` \
		10 "PSS (ECHO-ADI2111)..." `Soundonoff EXCLUDE_PSS` 2>$TEMP
if [ "$?" != "0" ] ; then return; fi 
choice=`cat $TEMP`
NoteChanges

for selection in $choice
do
case $selection in
	\"1\") SoundBlasterComp;AudioMidiFM;;
	\"2\") SoundBlasterComp;SoundBlasterPro;;
	\"3\") SoundBlasterComp;SoundBlaster16;;
	\"4\") SoundBlasterComp;ProAudioSpectrum;;
	\"5\") GravisUltrasound;YN16bitDaughtercard;AudioMidi;;
	\"6\") GravisUltrasoundMax;AudioMidi;;
	\"7\") MPU401;;
	\"8\") 6850UART;;
	\"9\") MSSoundSystem;;
	\"10\") PSS;AudioMidiFM;;
	\"11\") FMSynth;;
	
esac
done

if grep -qv "EXCLUDE" SoundChangesSummary 	
then				# Changes in sound cards (added/removed cards)
DMABuffer
fi
}

echo "" >$CHANGE_FILE
echo -n "" >SoundChangesSummary

main_menu	# get changes from user
seechanges	# show them to him
CommitChanges