;**************************************************
;
;$VER: e586DX Emulation Installer v1.9 (24 Feb 1995)
;
; Title:
;    EMPLANT's e586DX Emulation Software Installer
; 
; Description:
;    The Commodore Installer Script for EMPLANT's
;    e586DX emulation module software.
;
; Installer script by Jim Drew
;
;**************************************************

(set true 1)
(set false 0)
(set quote "\"")
(set nothing "")
(set WB2 (< 2293760 (getversion "exec.library" (resident)))) ; true if under 2.0

(set mode 0)				;default to 32 bit mode

(set EMPLANT_dir (getassign "EMPLANT"))
(set c_dir (getassign "C"))
(set libs_dir (getassign "LIBS"))
(set fonts_dir (getassign "FONTS"))
(set devs_dir (getassign "DEVS"))
(set s_dir (getassign "S"))

(set Src_c "OurPC:PC_EMU/c/")
(set Src_s "OurPC:PC_EMU/s/")
(set Src_libs "OurPC:PC_EMU/libs/")
(set Src_fonts "OurPC:PC_EMU/fonts/")
(set Src_devs "OurPC:PC_EMU/devs/")
(set Src_main "OurPC:PC_EMU/")
;(set Src_Launcher "OurPC:PC_EMU/Launcher/")
(set Src_docs "OurPC:PC_EMU/Documentation/")
(set Src_ROMS "OurPC:PC_EMU/ROM_Images/")
(set Src_Video "OurPC:PC_EMU/Video_Drivers/")
;(set Src_Logo "OurPC:PC_EMU/Logos/")
(set Src_ExtIO "OurPC:PC_EMU/Ext_IO/")

(if  (<> EMPLANT_dir nothing)
     (if  (askbool
               (prompt "\n\n\nAt least one EMPLANT emulation module has been "
               "detected in the root drawer: \n\n"
               quote EMPLANT_dir quote
               "\n\nDo you want the update installed into this drawer?")
               (help
               "\n\n\nThe installer has determined that you already have a "
               "some version of an EMPLANT emulation module installed "
               "on your system.  If this is wrong or you want the update "
               "installed elsewhere, select 'NO', otherwise select 'YES'."
               )
               (default 1)
          )
               (set is_update true) 

;else ask where to put software

               (
               (set is_update false)
               (set EMPLANT_dir
               (askdir
                    (prompt "Where would you like the updated software "
                    "installed?\n"
                    "'EMPLANT' will be automatically appended.")
                    (help @askdir-help)
                    (default @default-dest)
               )
               )

               (set EMPLANT_dir
               (tackon EMPLANT_dir "EMPLANT")
               )

               (makedir EMPLANT_dir
               (infos)
               )
          )
     )
)

; EMPLANT: was not previously assigned, so ask where to make it
(if  (= EMPLANT_dir nothing)
          (
          (set EMPLANT_dir
               (askdir
                    (prompt "Where would you like the software installed? "
                    "'EMPLANT' will be automatically appended.")
                    (help @askdir-help)
                    (default @default-dest)
               )
          )

          (set EMPLANT_dir
          (tackon EMPLANT_dir "EMPLANT")
          )

          (makedir EMPLANT_dir
          (infos)
          )
     )
)

          (set EMU_Dir
          (tackon EMPLANT_dir "PC")
          )

          (makedir EMU_dir
          (infos)
          )

(set @default-dest EMU_dir)

(complete 10)

; ask user to locate LIBS: directory

(set libs_dir
     (askdir
          (prompt "Please locate your LIBS: directory.")
          (help @askdir-help)
          (default libs_dir)
          (newpath)
     )
)

(working omp "...Please Wait...")

(copyfiles
     (prompt "Select file(s) to be copied into your LIBS: directory:")
     (help "\n\n\n\n\nThis will copy the necessary "
     "libraries into your system's LIBS: directory.\n\n\n\n\n\n\n"
     @copylib-help)
     (source Src_libs)
     (dest libs_dir)
     (pattern "(#?.library#?)")
     (confirm)
)

(complete 20)

; ask user to locate DEVS: directory

(set devs_dir
     (askdir
          (prompt "Please locate your DEVS: directory")
          (help @askdir-help)
          (default devs_dir)
     )
)
 
(working omp "...Please Wait...")  

(copyfiles
     (prompt "Select file(s) to be copied into your DEVS: directory:")
     (help "\n\n\n\n\nThis will copy the device drivers for the use "
     "with EMPLANT's various I/O ports.\n\n\n\n\n\n\n"
     @copyfiles-help)
     (source Src_devs)
     (dest DEVS_dir)
     (pattern "#?")
     (confirm)
)

(complete 40)

(working omp "...Please Wait...")

; Copy utilities
   
(set EMPLANT_dir
     (copyfiles
          (prompt "Select files to be copied to the EMPLANT: directory:")
          (help "\n\n\n\n\nThis will copy all of the utilities for the "
          "EMPLANT hardware and the e586DX emulation.\n\n\n\n\n\n\n"
          @copyfiles-help)
          (source Src_main)
          (dest EMPLANT_dir)
          (pattern "(Conv#?|Diag#?|Dump#?|HardFile#?|MAC_HDSetup#?)")
          (confirm)
     )
)

(complete 50)

; Copy over the e586DX EMULATION programs

(working omp "...Please Wait...")
   
(set EMU_dir
     (copyfiles
          (prompt "Select files to be copied to the EMPLANT:PC/ directory:")
          (help "\n\n\n\n\n\nThis will copy the e586DX emulation's main "
          "programs.\n\n\n\n\n\n\n"
          @copyfiles-help)
          (source Src_main)
          (dest EMU_dir)
          (pattern "(e586DX#?|e586SX#?)")
          (confirm)
     )
)

(complete 60)

;create Video_Drivers directory
   
(set VideoDrvr_dir
(cat EMU_dir)
)
(set VideoDrvr_dir
(tackon VideoDrvr_dir "Video_Drivers")
)

(makedir VideoDrvr_dir
(infos)
)

(working omp "...Please Wait...")

(copyfiles
     (prompt "Select file(s) to be copied into your Video_Drivers directory:")
     (help "\n\n\n\n\nThis will copy the video drivers to the proper "
     "directory.  ALL e586DX video drivers must reside in your "
     "'\EMPLANT:PC/Video_Drivers\' directory.\n\n\n\n\n\n"
     @copyfiles-help)
     (source Src_video)
     (dest VideoDrvr_dir)
     (pattern "(#?)")
     (confirm)
)

(complete 70)

;create Fonts directory
   
(set OurFonts_dir
(cat EMU_dir)
)
(set OurFonts_dir
(tackon OurFonts_dir "Fonts")
)

(makedir OurFonts_dir
(infos)
)

(working omp "...Please Wait...")

(copyfiles
     (prompt "Select font(s) to be copied into your Fonts directory:")
     (help "\n\n\n\n\nThis will copy the necessary fonts to the proper "
     "directory.  ALL e586DX fonts must reside in your "
     "'\EMPLANT:PC/Fonts\' directory.\n\n\n\n\n\n"
     @copyfiles-help)
     (source Src_Fonts)
     (dest OurFonts_dir)
     (pattern "(#?)")
     (confirm)
)

(complete 70)

;create ExtIO directory

(set ExtIODrvr_dir
(cat EMU_dir)
)
(set ExtIODrvr_dir
(tackon ExtIODrvr_dir "Ext_IO")
)
 
(makedir ExtIODrvr_dir
(infos)
)

(working omp "...Please Wait...")

(copyfiles
(prompt "Select file(s) to be copied into your Ext_IO directory:")
     (help "\n\n\n\n\nThis will copy the external I/O drivers to the proper "
     "directory.  ALL e586DX external I/O drivers must reside in your "
     "'\EMPLANT:PC/Ext_IO\' directory.\n\n\n\n\n\n"
     @copyfiles-help)
     (source Src_ExtIO)
     (dest ExtIODrvr_dir)
     (pattern "(#?)")
     (confirm)
)

(complete 80)

;create Logos directory
;
;(set Logos_dir
;(cat EMU_dir)
;)
;(set Logos_dir
;(tackon Logos_dir "Logos")
;)
; 
;(makedir Logos_dir
;(infos)
;)
;
;(working omp "...Please Wait...")
;
;(copyfiles
;     (prompt "Select file(s) to be copied into your Logos directory:")
;     (help "\n\n\n\n\nThis will copy the boot logos to the proper "
;     "directory.  ALL e586DX logos must reside in your "
;     "'\EMPLANT:PC/Logos\' directory.\n\n\n\n\n\n"
;     @copyfiles-help)
;     (source Src_logo)
;     (dest logos_dir)
;     (pattern "(#?logo#?)")
;     (confirm)
;)

(complete 90)

;create Documentation directory

(set Docs_dir
(cat EMU_dir)
)
(set Docs_dir
(tackon Docs_dir "Documentation")
)

(makedir Docs_dir
(infos)
)

(working omp "...Please Wait...")

(copyfiles
     (prompt "Select file(s) to be copied Documentation directory:")
     (help "\n\n\n\nThis will copy various documentation and "
     "IFF pictures to your documentation directory.  ALL e586DX emulation "
     "documentation should reside in your "
     "'\EMPLANT:PC/Documenation\' directory.\n\n\n\n\n\n"
     @copyfiles-help)
     (source Src_docs)
     (dest Docs_dir)
     (pattern "#?")
     (confirm)
)

(complete 95)

;create ROM_Images directory

(set ROM_dir
(cat EMU_dir)
)
(set ROM_dir
(tackon ROM_dir "ROM_Images")
)

(makedir ROM_dir
(infos)
)

(working omp "...Please Wait...")

(copyfiles
     (prompt "Select ROM Image(s) and Related Files:")
     (help "\n\n\n\n\nThis will copy your ROM image(s) from your "
     "original installation (if applicable).  ALL ROM image files "
     "must be in your '\EMPLANT:PC/ROM_Images\' directory.\n\n\n\n\n\n"
     @copyfiles-help)
     (source Src_ROMS)
     (dest ROM_dir)
     (pattern "#?")
     (confirm)
)

(complete 100)

(message "\n\n\n\n\n\n"
"Installation of emulation software is complete."
)

(exit)
