        startup($0,$1,$2,$3,$4,$5,$6,$7,$8,$9)

	$dir="\HEALTH"
	$size=8500      ; SimHealth + installation needs

	check_video(VGA)
	check_RAM(540)

	strcmp ($loadpath,C)
	if $>0 {goto fromharddisk}

fromfloppydisk:

	continue("Welcome to SimHealth")

	choose_destination()
	; register_user()
	; remind_registration()
	
	set(y,50)
	copy ("$loadpath\INSTALL.exe","INSTALL.exe")
	copy ("$loadpath\INSTALL.txt","INSTALL.txt")
	copy ("$loadpath\MAXIS.CIM","MAXIS.CIM")
	copy ("$loadpath\INFO.EXE","INFO.EXE")
	copy ("$loadpath\README.TXT","README.TXT")

	extract ("$loadpath\INSTALL._")
	extract ("$loadpath\SHEALTH._")
	extract ("$loadpath\GRAPHICS._")
	extract ("$loadpath\SOUND._")
	extract ("$loadpath\HELP._")

        insert_disk(2,"DATA._")
	extract ("$loadpath\DATA._")
	extract ("$loadpath\SCENREC._")

        setup_video()
        setup_mouse()
        setup_music()
;        setup_sound()
	write_config_file()
	click_OK(
"Installation Completed.
    Enjoy SimHealth!")

	exit("")


fromharddisk:
	continue("SimHealth Settings Utility")
        $=find("sim.cfg")
        if $="" {goto config_seq}
        $default_cfg = readtext("sim.cfg")
        $default_cfg = translate($default_cfg,"^0D", "")
        $default_cfg = translate($default_cfg,"^0A", "")
        $svga = $default_cfg
        $default_cfg = shift($default_cfg)
        $mouse = $default_cfg
        $default_cfg = shift($default_cfg)
        $ms_driver = $default_cfg
        $default_cfg = shift($default_cfg)
        $ms_IO = $default_cfg
        $default_cfg = shift($default_cfg)
        $ms_IRQ = $default_cfg
        $default_cfg = shift($default_cfg)
        $ms_DMA = $default_cfg
        $default_cfg = shift($default_cfg)
        $ms_DRQ = $default_cfg
        $default_cfg = shift($default_cfg)
        $ds_driver = $default_cfg
        $default_cfg = shift($default_cfg)
        $ds_IO = $default_cfg
        $default_cfg = shift($default_cfg)
        $ds_IRQ = $default_cfg
        $default_cfg = shift($default_cfg)
        $ds_DMA = $default_cfg
        $default_cfg = shift($default_cfg)
        $ds_DRQ = $default_cfg
        config_sys()
        goto config_complete;
config_seq:
        setup_video()
        setup_mouse()
        setup_music()
;        setup_sound()
config_complete:
	write_config_file()
	click_OK(
"Settings Complete.
  Enjoy SimHealth!")

	exit("")

; END OF MAIN CODE

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;                                                                        ;;
;;  ALL THE CODE BELOW IS SET OF ROUTINES OR KIND OF STANDARD GIP LIBRARY ;;
;;                                                                        ;;
;;            BETTER TOUCH IF LOOKING FOR TROUBLE                         ;;
;;                                                                        ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
maxis_installer:

	$maxis="* Maxis Presents - SimHealth Installer (Script v1.0) *"
	set(y,5) 
	set(background,LIGHTGRAY) 
	set(color,BLUE) 
	if $video=HERCMONO {set(color,BLACK)}
	if $video=MCGA {set(color,BLACK)}
	set(open,yes) 
	set(save,no)
	say ($maxis)
	return ()

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
click_OK:
	set(background,WHITE)
	set(color,BLACK)
	set(save,yes)
	set(open,yes)
	set(font,normal)
	set(x,50)
	set(y,50)
	set(window,$screen)

	$0="$0

"
	say ($0)

	set(y,80) set(open,no) set(save,no)
	say ("%%%",OK)
	wclose()
	return()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
red_continue:
	set(background,LIGHTRED)
	goto continue_merge

continue: ; message
	set(background,WHITE)
continue_merge:
	set(color,BLACK)
	set(save,yes)
	set(open,yes)
	set(font,normal)
	set(x,50)
	set(y,50)
	set(window,$screen)

	$0="$0

"

	say ($0)  

	set(y,80) set(open,no) set(save,no)
	say ("%%%%%%%%%   %%%%%%%%",CONTINUE,Cancel)
	if $=Cancel {exit("Installation Canceled")}
	wclose()  ;closes 1st window because it's last saved
	return()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
yes_or_no:
	set(background,LIGHTRED)
	set(color,BLACK)
	set(save,yes)
	set(open,yes)
	set(font,normal)
	set(x,50)
	set(y,50)
	set(window,$screen)

	$0="$0

"

	say ($0)

	set(y,80) set(open,no) set(save,no)
	$0=say ("%%%%   %%%",YES,NO)
	wclose()
	return($0)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
abort_box:
	set(background,LIGHTRED)
	$0="$0


"
	set(open,yes) set(save,yes)
	say ($0)
	$w=window()
	set(window,$w)
	set(x,45) set(y,82)
	set(open,no) set(save,no)
	say ("%%%%%%%",ABORT)
	wclose($w)
	return()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
register_user:
;       set(open,yes) set(save,yes)
	$name="SimMayor"
ru_loop:
	say (
" Please enter your name
 @@@@@@@@@@@@@@@@@@@@@

    %%%    %%%%%%%%%",name,OK,Cancel)
	if $=Cancel {
	    cancel()
	    set(open,no) set(save,no)
	    goto ru_loop
	}

	wclose()
	set(window,$screen) 
	set(y,23) set(background,LIGHTGRAY) 
	set(color,BLUE) set(save,no) set(open,yes)
	if $video=HERCMONO {set(color,BLACK)}
	if $video=MCGA {set(color,BLACK)}
	say ("Licensed to $name")
	return()

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
choose_destination:

	set(x,50)
	set(y,50)
	set(save,yes)
	set(open,yes)
	$w=""
destination_loop:
$0=say(
"    Enter the Drive & Directory

Drive:       @@
Directory:   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

	     %%%     %%%%%%%%",
drive, dir, OK, Cancel)

	if $w="" {
	    $w=window()
	    set(save,no) set(open,no)
	}

	if $0=Cancel { cancel() goto destination_loop}

	set(error,NO)
	setdrive($drive)
	if ERROR {
	    set(ERROR,YES) ; restore error alert
	    continue_or_exit ("DRIVE $drive DOESN'T EXIST.")
	    goto destination_loop
	}
	set(ERROR,YES) ; restore error alert

	$space=getspace($drive)
	if $space<$size {
continue_or_exit (
"FREE SPACE ON DRIVE $DRIVE IS $space K.
   You must have $size K free to
    complete this installation.")
	    ;wclear($w)
	    ;set(save,no) set(open,no)
	    goto destination_loop
	}

	;; Don't allow illegal paths such as "D:\somedir"
	$=strstr($dir,":") ; result of strstr >= 0 means substring was found
	if $>"-1" {
	    continue_or_exit("':' is not allowed in directory name");
	    goto destination_loop
	}

	; Look for '\' occurence in $dir
	$=strstr($dir,"\")
	if $ # 0 { ; '\' is NOT found in $dir as very 1st char (at offset 0)
	    ; Perform appropriate actions here
	    ; example:
	    $=yes_or_no("Install to \$dir?");     
	    if $=NO {goto destination_loop}
	    $dir="\$dir"
	}


	set(error,NO)
	md($dir)  ; ignore system error when creating already existing dir
	if ERROR {
	    cd ($dir)
	    if NOERROR {
		set(error,YES)
		$=yes_or_no(
"Directory $dir already exists.
Do you want to install over old files?")
		if $=NO {goto destination_loop}
	    }
	}
	cd($dir)
	if ERROR {
	    set(error,YES)
	    continue_or_exit("Can't make $dir");
	    goto destination_loop
	}
	set(ERROR,YES)

	wclose($w)
	set(window,$screen)
	set(y,14) 
	set(background,LIGHTGRAY) set(color,BLUE)
	if $video=HERCMONO {set(color,BLACK)}
	if $video=MCGA {set(color,BLACK)}
	set(open,yes) set(save,no)
	say("Installing SimHealth to $drive $dir")
	return()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
continue_or_exit: ; (message)

$0=
"$0

"
set(open,YES) 
set(save,YES) 
set(BACKGROUND,LIGHTRED) 
set(COLOR,BLACK) 
set(x,50) 
set(y,50)
say ($0) $9=window()

set(open,NO) set(save,NO) set(y,80) set(window,$9)

say ("%%%%%%%%%   %%%%%",
     Continue,    Exit)
if $=Exit {exit ("")}
wclose($9)
return()

check_video: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

if $video=$0 {return()}

continue_or_exit(
"    Your computer's video card is $video.
SimHealth currently only supports Super-VGA.
       You still can install SimHealth,
  BUT YOU WILL NOT BE ABLE TO PLAY THE GAME
    without Super-VGA."
)

	return()

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
check_RAM:

if $RAM<$0 {continue_or_exit(
"  Your computer has $RAM K of memory.
    SimHealth requires at least $0 K.
     You still can install SimHealth,
BUT YOU WILL NOT BE ABLE TO PLAY THE GAME
  until you have $0 K memory installed." )
}
return()

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
extract_files: ; (template)
	$0="$loadpath\$0"
	$filelist=find($0) 
ef_loop:
	if $filelist # "" {
	    extract("$loadpath\$filelist") 
	    $9=strlen($filelist) 
	    $filelist=rotate($filelist,$9)
	    $filelist=rotate($filelist,1)    ; end null
	    goto ef_loop
	}
	return()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
insert_disk: ; (LABEL,FILENAME to verify)
	$1="$loadpath\$1"
	$=strlen($0)

	;; Extra space for narrow message
	$9=""
	if $<10 { $9="       "}


	$9="$9 Insert Disk $0 $9

"
	set(background,WHITE)
	set(color,BLACK)
	set(save,yes)
	set(open,yes)
	set(font,normal)
	set(x,50)
	set(y,50)
	set(window,$screen)

	say ($9)

	set(y,80) set(open,no) set(save,no)

	say ("%%%%%%%%%   %%%%%%%%",CONTINUE,Cancel)
	if $=Cancel {exit("Installation Canceled")}
reinsert:
	$=find($1)
	if $="" {
	    red_continue(" WRONG  DISK  INSERTED ! ")
	    goto reinsert;
	}
	wclose()  ;closes 1st window because it's last saved

	return()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
write_config_file:

	$1="$ms_driver^0D^0A$ms_IO^0D^0A$ms_IRQ^0D^0A$ms_DMA^0D^0A$ms_DRQ"
	$2="$ds_driver^0D^0A$ds_IO^0D^0A$ds_IRQ^0D^0A$ds_DMA^0D^0A$ds_DRQ"
	writetext("SIM.CFG","$svga^0D^0A$mouse^0D^0A$1^0D^0A$2^0D^0A")

	return()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
nowsay:
	$=say($0,$1,$2,$3,$4,$5,$6,$7,$8,$9)
	return ($)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
nowimage:
	image($0)
	return()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
shift: ; $0 - value
	    $9=strlen($0)
	    $0=rotate($0,$9)
	    $0=rotate($0,1)    ; end null

	return ($0)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cancel:
	continue_or_exit("Do you want to exit now?")
	return ()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;                       NEW SOUND STUFF
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
get_blaster_set:
       set(error,NO)
       $blaster=getenv("BLASTER")
       if ERROR {goto gbs_end}
       $blaster=translate($blaster," ","")
       $ds_io=$blaster
       $ds_io=translate($ds_io,"A","")
       $ds_io=shift($ds_io)
       $blaster=shift($blaster)
       $ds_IRQ=$blaster
       $ds_IRQ=translate($ds_IRQ,"I","")
       $ds_IRQ=shift($ds_IRQ)
       $blaster=shift($blaster)
       $ds_DMA=$blaster
       $ds_DMA=translate($ds_DMA,"D","")
       $ds_DMA=shift($ds_DMA)
       $ms_io=$ds_io
       $ms_IRQ=$ds_IRQ
       $ms_DMA=$ds_DMA
gbs_end:
return()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

choose_music_carda:

	set(font,small)

	$1=          "NO MUSIC"                      
	$2=          "PC Speaker" 
        $3=          "Tandy 3-voice speaker"                   
	$4=          "Ad Lib"                        
	$5=          "Ad Lib Gold"                 
	$6=          "Roland MT-32"
        $7=          "Pro Audio Spectrum"
        $8=          "Pro Audio Spectrum Plus/16"                   


	$0=say (
"   Choose Music Sound Card:   

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ",

	$1,$2,$3,$4,$5,$6,$7,$8,$more)


	if $0=$1     {   $sc_name=$1      $sc_dll="NOMUSIC"    }
	if $0=$2     {   $sc_name=$2      $sc_dll="a16spkr"  }
	if $0=$3     {   $sc_name=$3      $sc_dll="a16tandy"   }
	if $0=$4     {   $sc_name=$4      $sc_dll="a16adlib"    }
	if $0=$5     {   $sc_name=$5      $sc_dll="a16algfm"  }
	if $0=$6     {   $sc_name=$6      $sc_dll="a16mt32" }
	if $0=$7     {   $sc_name=$6      $sc_dll="a16pasfm" }
	if $0=$8     {   $sc_name=$6      $sc_dll="a16pasop" }
	if $0=$more     {   $sc_name=$more      $sc_dll=$more}

wclose()
return()

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
choose_music_cardb:

	set(font,small)

        $1=          "Sound Blaster"
	$2=          "Sound Blaster Pro 1"       
	$3=          "Sound Blaster Pro 2"       
	$4=          "Sound Blaster/16"               

	$0=say (
"   Choose Music Sound Card:   

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                               
          end of list          
                                
                                

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ",
	$1,$2,$3,$4,$more)


	if $0=$1     {   $sc_name=$1      $sc_dll="a16sbfm" }
	if $0=$2     {   $sc_name=$2      $sc_dll="a16sp1fm"}
	if $0=$3     {   $sc_name=$3      $sc_dll="a16sp2fm"}
	if $0=$4     {   $sc_name=$4      $sc_dll="a16sp2fm"}
	if $0=$more     {   $sc_name=$more      $sc_dll=$more}
	
wclose()
return()

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

choose_sfx_card:

	set(font,small)

	$1=          "NO SOUND"                 
	$2=          "Sound Blaster" 
        $3=          "Sound Blaster Pro"      
	$4=          "Pro Audio Spectrum"       
	$5=          "Ad Lib Gold"            
	
	$0=say (
"  Choose Sound Effects Card:   

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ",

	$1,$2,$3,$4,$5)

	if $0=$1     {   $sc_name=$1      $sc_dll="NOSOUND"   }
	if $0=$2     {   $sc_name=$2      $sc_dll="a16sbdg" }
	if $0=$3     {   $sc_name=$3      $sc_dll="a16sbpdg" }
	if $0=$4     {   $sc_name=$4      $sc_dll="a16pasdg"}
	if $0=$5     {   $sc_name=$5      $sc_dll="a16algdg" }

wclose()
return()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
verify_dll:
	if $sc_dll="NOSOUND"   {return()}
	if $sc_dll="NOMUSIC"   {return()}
	if $sc_dll="PCSPKR.ADV" {return()}

vd_cont:
	say("
	     Verifying hardware presence...                   ")
	set(open,no) set(save,no) set(x,50) set(y,10) 
	nowsay ($sc_name)
        copy2("$sc_dll.dll","$dest_dll")         
	exec("sdetect.EXE $music_sound $s_IO $s_IRQ $s_DMA $s_DRQ")
	$ver="FAILED !"
	if $=0 {$ver="OK."}
	if ERROR { $ver="Can't verify" }
	wclear()

	set(y,50)
	$setting="CHANGE SETTINGS"
	set(y,10)
	nowsay("$sc_name VERIFICATION: $ver")
	set(y,90)
	$stat=nowsay("%%%%%%%%%%    %%%%%%%%%%%%%    %%%%%%%%%%%%%%%%%",
		   $continue,    "CHANGE CARD",       $setting)

	if $stat=$setting {
	    edit_IO_settings()
	    wclear()
	    goto vd_cont;
	}
	wclose()
	return()

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
edit_IO_settings: 

	$defpar="*"
	set(x,50) set(y,100) 
	set(font,small) 
	set(open,yes) set(save,yes)

	$8=window()
	$9=""

settings_loop:
	set(window,$8);

$7=say(
"$sc_name
* - factory default
    IO : @@@ Hex
    IRQ: @@
    DMA: @@

   %%%%%%%%%

   %%%%%%%%%", 
s_io,s_IRQ,s_DMA,
DEFAULTS, CONTINUE)
if $9="" {$9=window()}
	if $7=DEFAULTS {
	    $s_IO=$defpar 
	    $s_IRQ=$defpar 
	    $s_DMA=$defpar 
	    $s_DRQ=$defpar
	    wclear()
	    set(open,no) set(save,no)
	    goto settings_loop;
	}

wclose($9)
return()

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
setup_music:

	;Music Sound Cards

sm_more:
	$defpar="*"
	$s_io=$ms_io $s_IRQ=$ms_IRQ $s_DMA=$ms_DMA $s_DRQ=$ms_DRQ

	$sc_dll=$more
	if $sc_dll=$more {choose_music_carda()}
	if $sc_dll=$more {choose_music_cardb()}
	if $sc_dll=$more {goto sm_more}

	$stat=$continue
        $music_sound = "0"
        $dest_dll = "ailxmi.dll"
	verify_dll()
	if $stat#$continue {goto sm_more}

        $ms_card=$sc_name
	$ms_driver=$sc_dll
	$ms_IO=$s_IO
	$ms_IRQ=$s_IRQ
	$ms_DMA=$s_DMA
	$ms_DRQ=$s_DRQ

	set(font,normal)
	return()

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

setup_sound:

	;Sound Effects Sound Cards
	
ss_more:       
	$defpar="*"
	$s_io=$ds_io $s_IRQ=$ds_IRQ $s_DMA=$ds_DMA $s_DRQ=$ds_DRQ

	choose_sfx_card()

	$stat=$continue
        $music_sound = "1"
        $dest_dll = "ailpcm.dll"
	verify_dll()
	if $stat#$continue {goto ss_more}

        $ds_card=$sc_name
	$ds_driver=$sc_dll
	$ds_IO=$s_IO
	$ds_IRQ=$s_IRQ
	$ds_DMA=$s_DMA
	$ds_DRQ=$s_DRQ

	set(font,normal)
	return()

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
setup_mouse:
   set(font,small)
   set(save,yes) set(open,yes)
   $1 = "no mouse" 
   $2 = "Mouse driver"
   $3 = "Microsoft mouse, COM1"
   $4 = "Microsoft mouse, COM2"
   $5 = "Logitech/Mouse Systems mouse, COM1"
   $6 = "Logitech/Mouse Systems mouse, COM2"
   
   $mouse="none"
   $0=say (
"   Choose Mouse:   
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ",
    $1,$2,$3,$4,$5,$6)

    wclose()
    if $0=$1 { continue
("SimHealth currently requires a mouse,
You may continue installation but will
be unable to run SimHealth") goto sm_done }
    if $0=$2 { $mouse="MsDriver" $9=0 }
    if $0=$3 { $mouse="MsCOM1"   $9=1 }
    if $0=$4 { $mouse="MsCOM2"   $9=2 }
    if $0=$5 { $mouse="MoCOM1"   $9=3 }
    if $0=$6 { $mouse="MoCOM2"   $9=4 }
    goto sm_done                          ; detection not working
    exec("idetect $9")
    if $=0 { goto sm_done }
    click_ok("Hardware not detected")
    goto setup_mouse  
sm_done:
    $detectm = $0
    return()

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
set_defaults:
   $detectv=""
   $ms_card=""
   $ds_card=""
   if $svga="ai:30,1" { $detectv = "ATI, VGA Wonder" }
   if $svga="ai:50,2" { $detectv = "ATI, Graphics Ultra Pro" }
   if $svga="ch:23,3" { $detectv = "CHIPS 82C45x" }
   if $svga="cp:11,4" { $detectv = "Compaq Advanced VGA" }
   if $svga="t3:31,5" { $detectv = "Diamond Speedstar" }
   if $svga="s3:10,6" { $detectv = "Diamond Stealth (S3)" }
   if $svga="g:6,7"   { $detectv = "Genoa, SuperVGA 5000" }
   if $svga="g:8,8"   { $detectv = "Genoa, SuperVGA 6000" }
   if $svga="s3:10,9" { $detectv = "HP Ultra VGA" }
   if $svga="ok:3,10"  { $detectv = "OAK VGA" }
   if $svga="st:31,11" { $detectv = "Orchid, Designer VGA" }
   if $svga="ts:31,12" { $detectv = "Orchid, ProDesigner II" }
   if $svga="s3:10,13" { $detectv = "Orchid Fahrenheit 1280" }
   if $svga="p:4,14"   { $detectv = "Paradise, VGA 1024" }
   if $svga="q:3,15"   { $detectv = "Quadram, VGA Spectra" }
   if $svga="v7:10,16" { $detectv = "Radius Multiview" }
   if $svga="s3:10,17" { $detectv = "S3 Incorporated" }
   if $svga="st:31,18" { $detectv = "STB, VGA Extra/EM" }
   if $svga="ts:31,19" { $detectv = "STB VGA EM-16 Plus" }
   if $svga="tc:4,20"  { $detectv = "Tecmar, VGA/AD" }
   if $svga="tr:3,21"  { $detectv = "Trident Impact" }
   if $svga="ts:31,22" { $detectv = "Tseng 4000" }
   if $svga="ve:31,23" { $detectv = "VESA Super VGA" }
   if $svga="v7:7,24"  { $detectv = "V7, FastWrite VGA" }
   if $svga="v7:7,25"  { $detectv = "V7, VRAM VGA" }                
   if $svga="v7:7,26"  { $detectv = "V7, VGA 1024i" }
   if $svga="v7:10,27" { $detectv = "V7, VRAM II" }
   if $mouse="none"    { $detectm = "no mouse"  }
   if $mouse="MsDriver"{ $detectm = "Mouse driver" }
   if $mouse="MsCOM1"  { $detectm = "Microsoft mouse, COM1" }
   if $mouse="MsCOM2"  { $detectm = "Microsoft mouse, COM2" }
   if $mouse="MoCOM1"  { $detectm = "Logitech/Mouse Systems mouse, COM1" }
   if $mouse="MoCOM2"  { $detectm = "Logitech/Mouse Systems mouse, COM2" }
   if $ms_driver="NOMUSIC"   { $ms_card = "NO MUSIC" }                  
   if $ms_driver="a16spkr"   { $ms_card = "PC Speaker" }
   if $ms_driver="a16tandy"  { $ms_card = "Tandy 3-voice speaker" }     
   if $ms_driver="a16adlib"  { $ms_card = "Ad Lib" }                   
   if $ms_driver="a16algfm"  { $ms_card = "Ad Lib Gold" }               
   if $ms_driver="a16mt32"   { $ms_card = "Roland MT-32" }
   if $ms_driver="a16pasfm"  { $ms_card = "Pro Audio Spectrum" }
   if $ms_driver="a16pasop"  { $ms_card = "Pro Audio Spectrum Plus/16" }
   if $ms_driver="a16sbfm"   { $ms_card = "Sound Blaster" }
   if $ms_driver="a16sp1fm"  { $ms_card = "Sound Blaster Pro 1" }
   if $ms_driver="a16sp2fm"  { $ms_card = "Sound Blaster Pro 2" }
   if $ms_driver="a16sp2fm"  { $ms_card = "Sound Blaster/16" }   
   if $ds_driver="NOSOUND"   { $ds_card = "NO SOUND" }          
   if $ds_driver="a16sbdg"   { $ds_card = "Sound Blaster" } 
   if $ds_driver="a16sbpdg"  { $ds_card = "Sound Blaster Pro" }
   if $ds_driver="a16pasdg"  { $ds_card = "Pro Audio Spectrum" }
   if $ds_driver="a16algdg"  { $ds_card = "Ad Lib Gold" }       
   return()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
config_sys:
   set(font,large)
   set_defaults()
   $quit = "done"
cs_begin:   
   set(y,25)
        $0=say2 (
" System Configuration                           %%%%%%

 Video:         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 Mouse:         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 MIDI Sound:    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
                
        $quit, $detectv, $detectm, $ms_card)
	$1=window()
        set(y,60)
	set(window,$screen)
        set(save,yes) set(open,yes)
        if $0=1 { setup_video() goto cs_100 }
        if $0=2 { setup_mouse() goto cs_100 }
	if $0=3 { setup_music() goto cs_100 }
;	if $0=3 { setup_sound() goto cs_100 }
        if $0=0 { goto cs_end }
cs_100:
        set(window,$1)
        set(save,no) set(open,no)
        goto cs_begin
cs_end: 
        set(window,$1)
        wclose()
        return()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
setup_video:
	set(font,small)
        set(save,yes) set(open,yes)
        $first="true"
begin_sv:
        $lp = ">" $rp = "<"
        exec("vdetect.exe 0")
        if $=0 { $lp = " " $rp = " " }
        $1="$lp ATI, VGA Wonder $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 1")
        if $=0 { $lp = " " $rp = " " }
        $2="$lp ATI, Graphics Ultra Pro $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 2")
        if $=0 { $lp = " " $rp = " " }
        $3="$lp CHIPS 82C45x $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 3")
        if $=0 { $lp = " " $rp = " " }
        $4="$lp Compaq Advanced VGA $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 4")
        if $=0 { $lp = " " $rp = " " }
        $5="$lp Diamond Speedstar $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 5")
        if $=0 { $lp = " " $rp = " " }
        $6="$lp Diamond Stealth (S3) $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 6")
        if $=0 { $lp = " " $rp = " " }
        $7="$lp Genoa, SuperVGA 5000 $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 7")
        if $=0 { $lp = " " $rp = " " }
        $8="$lp Genoa, SuperVGA 6000 $rp"
        $9="more"
cont1_sv:
 	$temp=say (
"   Choose Super VGA model:   

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                               
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ",

	$1,$2,$3,$4,$5,$6,$7,$8,$9)

        if $temp=$1 {$svga="ai:30,1"}
        if $temp=$2 {$svga="ai:50,2"}
        if $temp=$3 {$svga="ch:23,3"}
        if $temp=$4 {$svga="cp:11,4"}
        if $temp=$5 {$svga="t3:31,5"}
        if $temp=$6 {$svga="s3:10,6"}
        if $temp=$7 {$svga="g:6,7"}
        if $temp=$8 {$svga="g:8,8"}
        $=strstr($temp, ">") 
        set(save,no) set(open,no)
        if $="0" { $temp=replace($temp,">","")  
                   $temp=replace($temp,"<","") 
                   goto cont2_sv}
        if $temp#"more" {click_OK("Invalid Selection") 
        goto cont1_sv }

cont2_sv:

        if $temp # "more" {
           goto end_sv }
        $temp = sv2()
        if $temp # "more" {
           goto end_sv }
        $temp = sv3()
        if $temp # "more" {
           goto end_sv }
        $temp = sv4()
        if $temp # "more" {
           goto end_sv }
        goto begin_sv
end_sv:
        $detectv = $temp
        wclose()
        return()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
sv2:
        $lp = ">" $rp = "<"
        exec("vdetect.exe 9")
        if $=0 { $lp = " " $rp = " " }
        $1="$lp HP Ultra VGA $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 9")
        if $=0 { $lp = " " $rp = " " }
        $2="$lp OAK VGA $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 10")
        if $=0 { $lp = " " $rp = " " }
        $3="$lp Orchid, Designer VGA $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 11")
        if $=0 { $lp = " " $rp = " " }
        $4="$lp Orchid, ProDesigner II $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 12")
        if $=0 { $lp = " " $rp = " " }
        $5="$lp Orchid Fahrenheit 1280 $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 13")
        if $=0 { $lp = " " $rp = " " }
        $6="$lp Paradise, VGA 1024 $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 14")
        if $=0 { $lp = " " $rp = " " }
        $7="$lp Quadram, VGA Spectra $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 15")
        if $=0 { $lp = " " $rp = " " }
        $8="$lp Radius Multiview $rp"
        $9="more"
        set(save,no) set(open,no)

cont3_sv:

	$0=say (
"   Choose Super VGA model:   

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ",

	$1,$2,$3,$4,$5,$6,$7,$8,$9)

        if $0=$1 {$svga="s3:10,9"}
        if $0=$2 {$svga="ok:3,10"}
        if $0=$3 {$svga="st:31,11"}
        if $0=$4 {$svga="ts:31,12"}
        if $0=$5 {$svga="s3:10,13"}
        if $0=$6 {$svga="p:4,14"}
        if $0=$7 {$svga="q:3,15"}
        if $0=$8 {$svga="v7:10,16"}
        $temp2 = $0
        $=strstr($temp2, ">") 
        if $="0" { $temp2=replace($temp2,">","")  
                   $temp2=replace($temp2,"<","") 
                   goto cont4_sv }
        if $temp2 # "more" {click_OK("Invalid Selection") 
                            goto cont3_sv }

cont4_sv:
        return($temp2) 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
sv3:

        $lp = ">" $rp = "<"
        exec("vdetect.exe 16")
        if $=0 { $lp = " " $rp = " " }
        $1="$lp S3 Incorporated $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 17")
        if $=0 { $lp = " " $rp = " " }
        $2="$lp STB, VGA Extra/EM $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 18")
        if $=0 { $lp = " " $rp = " " }
        $3="$lp STB VGA EM-16 Plus $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 19")
        if $=0 { $lp = " " $rp = " " }
        $4="$lp Tecmar, VGA/AD $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 20")
        if $=0 { $lp = " " $rp = " " }
        $5="$lp Trident Impact $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 21")
        if $=0 { $lp = " " $rp = " " }
        $6="$lp Tseng 4000 $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 22")
        if $=0 { $lp = " " $rp = " " }
        $7="$lp VESA Super VGA $rp"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 23")
        if $=0 { $lp = " " $rp = " " }
        $8="$lp V7, FastWrite VGA $rp"
        $9="more"

        set(save,no) set(open,no)
cont5_sv:

	$0=say (
"   Choose Super VGA model:   

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ",

	$1,$2,$3,$4,$5,$6,$7,$8,$9)

        if $0=$1 {$svga="s3:10,17"}
        if $0=$2 {$svga="st:31,18"}
        if $0=$3 {$svga="ts:31,19"}
        if $0=$4 {$svga="tc:4,20" }
        if $0=$5 {$svga="tr:3,21" }
        if $0=$6 {$svga="ts:31,22"}
        if $0=$7 {$svga="ve:31,23"}
        if $0=$8 {$svga="v7:7,24"  }
        $temp2 = $0
        $=strstr($temp2, ">") 
        if $="0" { $temp2=replace($temp2,">","")  
                   $temp2=replace($temp2,"<","") 
                   goto cont6_sv }
        if $temp2 # "more" {click_OK("Invalid Selection") 
                            goto cont5_sv }

cont6_sv:

        return($temp2) 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
sv4:

        $lp = ">" $rp = "<"
        exec("vdetect.exe 24")
        if $=0 { $lp = " " $rp = " " }
        $1="V7, VRAM VGA"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 25")
        if $=0 { $lp = " " $rp = " " }
        $2="V7, VGA 1024i"
        $lp = ">" $rp = "<"
        exec("vdetect.exe 26")
        if $=0 { $lp = " " $rp = " " }
        $3="V7, VRAM II"
        $4="more"
        set(save,no) set(open,no)
        wclear()
cont7_sv:

	$0=say (
"   Choose Super VGA model:   

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                               
          end of list          
                               

                               
                               
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ",

	$1,$2,$3,$4)

        if $0=$1 {$svga="v7:7,25"}
        if $0=$2 {$svga="v7:7,26"}
        if $0=$3 {$svga="v7:10,27"}
        $temp2 = $0
        $=strstr($temp2, ">") 
        if $="0" { $temp2=replace($temp2,">","")  
                   $temp2=replace($temp2,"<","") 
                   goto cont8_sv }
        if $temp2 # "more" {click_OK("Invalid Selection") 
                            goto cont7_sv }

cont8_sv:

        return($temp2) 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
extract_to_subdir: ;;; (subdir_name,archive_name)

	; Prevent system error when creating already existing dir
	set(error,no) md ($0) set(error,yes)
	cd ($0)
	extract ("$loadpath\$1")
	cd("..")
	return()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
patch_name:
	exec("patch.exe $0")
	delete("PATCH.EXE")
	return()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
remind_registration:
	set(y,51)
	image("$loadpath\postcard.cim")
	set(y,45) set(font,large) set (open,no) set(save,no)
	set(color,BLACK)
	nowsay(
" All we've got to offer is:
   FREE software,
   FREE subscriptions, and
   someone nice to talk to 
   when you're in trouble.")
	set(open,yes)
	set(font,large)
	set(y,78) set(background,YELLOW) set(color,BLACK)
	say("DON'T FORGET TO REGISTER TODAY !");

	return()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
draw_desktop:
;       set(background,BLUE)
;       wclear($screen)
	
	set(open,no) set(save,no)
	set(color,YELLOW) set(font,large) nowsay("LOADING...")
	image("$loadpath\MAXIS.CIM")
	return()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
startup:
	$loadpath=$
	$CPU=$0
	$NDP=$1
	$RAM=$2
	$XRAM=$3
	;
	$video=$5
	$ncolor=$6
	$DOS=$8
	$screen=$9
	;
	$drive="C:"
	$newline="^0D^0A"
	$null="^00"
	$continue=CONTINUE      

	draw_desktop()
	delay(1)

	maxis_installer()

	$no_sound=      "NO SOUND"
	$adlib=         "Ad Lib ¯"
	$sb=            "Sound Blaster ¯"
	$pas=           "Pro Audio Spectrum ¯" 
	$roland=        "Roland Sound Canvas"
	$sierra=        "ARIA Sound Synth"  
	$mt32=          "Roland MT-32/LAPC-1"
	$genmid=        "MPU-401 General MIDI"

	$vmode1=4        
	$vmode2=E
	$gset="CEGADAT"

	$s_card=$no_sound
	$ms_IO="*" $ms_IRQ="*" $ms_DMA="*" $ms_DRQ="*"
	$ds_IO="*" $ds_IRQ="*" $ds_DMA="*" $ds_DRQ="*"
        get_blaster_set()
	$speaker="PC Speaker"
        $svga="none"
        $mouse="none"
        $ms_driver="NOMUSIC"
        $ds_driver="NOSOUND"
	$defpar="*"
	$s_io=$defpar $s_IRQ=$defpar $s_DMA=$defpar $s_DRQ=$defpar
	$more="MORE..."
	return()


