(set @appname "COINMANIA")
;(set @user-level 2)
(complete 0)
(set NoHD 0)
(set GotHD (exists "dh0:" (noreq)))
(if (= GotHD NoHD)
 ((message "\n\n\n\nUnable To Install\n\nCOINMANIA\n\nAs No Hard Disk Attached")
   (exit (quiet)
  )
 )
)
(set D_Space 0)
(set D_Space_Needed 500000)
(while (< D_Space D_Space_Needed)
 (set CM_Dest (askdir
                (prompt "Please Choose Where You Would Like\n"
		 "COIN MANIA - THE GAME\n"
		 "To Be Installed")
		(help "      This Part Will Make A Directory Called:-\n"
		 "                      COINMANIA\n"
		 "            In The Directory You Select.\n\n"
		 "                 e.g If You Select:-\n"
		 "                         DH0:\n"
		 "              Then A Directory Called:\n"
		 "                    DH0:COINMANIA\n\n"
		 "Will Be Created And  COINMANIA - THE GAME And Most Of "
		 "The Files Related To It  Will Be Placed In This Newly "
		 "Created Directory So They Are Not Spread All Over The "
		 "            Device You Wish To Install To.")
		(default @default-dest)
	      )
 )
 (set CM_Path (pathonly CM_Dest))
 (set D_Space (getdiskspace CM_Path))
 (if (< D_Space D_Space_Needed)
  ((set Flag (askbool
	     (prompt "\n\n\n\nNot Enought Free Space On Device\n"
            	     "You Wish To Install To.\n\n"
            	     "Would You Like To Select Another Device?")
	     (help "")
	     )
   )
   (if (not Flag)
        (exit (quiet))
   )
  )
 )
)

(set memneeded "700000")
(set memneededone "1000000")
(set freechip (database "graphics-mem"))
(set allfreemem (database "total-mem"))
(set diff (- freechip memneeded))
(set diff1 (- freechip memneededone))
(set diff2 (- allfreemem freechip))
(set XtraSFX 0)
(set Own_Music (askoptions
  		(prompt "Would You Like Your Own InGame Music\n"
		 	"It Must Be In NOISETRACKER Format")
		(help "\n  Select A Music File Which Will Replace The Default "
		      "    COINMANIA InGame Music, But Please Note That The\n"
		      "  Module Must Be In Noise/ProTracker !VBlank! Format\n"
		      "          ----------------------------------\n\n\n\n"
		      "   -----------------------------------------------\n"
		      " IMPORTANT: No Checking Is Done On The Module Format\n"
		      "  Until It Has Been Loaded  So If The Module Is Not\n"
		      " A NOISETRACKER Module Then It Will Not Play InGame.")		(choices " Use DEFAULT Game Music")
	       )
)
(set REPEAT_FLAG 0)
(set YES 0)
(set NO 1)
(set Module_Name1 "")
(set No_Module_Name "")
(if (= Own_Music YES)
 (while (= REPEAT_FLAG YES)
  (set Module_Name (askfile
		     (prompt "Select Music File To Save As The New\nINGAME Music")
		     (help "\n  Select A Music File Which Will Replace The Default "
			   "    COINMANIA InGame Music, But Please Note That The\n"
			   "  Module Must Be In Noise/ProTracker !VBlank! Format\n"
			   "          ----------------------------------\n\n\n\n"
			   "   -----------------------------------------------\n"
			   " IMPORTANT: No Checking Is Done On The Module Format\n"
			   "  Until It Has Been Loaded  So If The Module Is Not\n"
			   " A NOISETRACKER Module Then It Will Not Play InGame.")
		     (default @default-dest)
		    )
  )
  (set Mod_Okay (exists (Module_Name) (noreq)))
  (if (= Mod_Okay YES)
   ((message "\n\n\nFile:\n\n\"" Module_Name ":" Module_Name1 "\"\n\nNot Found\n\n----------\nSelect Another File?")
    (set REPEAT_FLAG YES)
   )
   (set REPEAT_FLAG NO)
  )
  (if (= REPEAT_FLAG NO)
   (set Mod_Size (getsize Module_Name))
   (set New_DFree (- D_Space_Needed 178000))
   (set New_Size (+ New_DFree Mod_Size))
   (set Max_Mod (- D_Space New_DFree))
   (if (> New_Size D_Space)
    (message "\n\nModule Name:\n" Module_Name "\n\nModule Size:\n" Mod_Size "\n\n"
             "-------------\n"
	     "Not Enought Room On Device:\n" CM_Path "\n\nMax File Size Allowed Approx: " Max_Mod)
    (set REPEAT_FLAG NO)
   )
  )
 )
)
(set @default-dest CM_Dest)
(if (= Own_Music YES)
  (message "\nAre You Sure You Wish To Install\n\nC-O-I-N-M-A-N-I-A\n---------\nIn The Directory:\n\n " CM_Dest "\n-----"
	   "\n\nWith Your Own Music"
	   "\n\n** This Is Your LAST Chance To QUIT Before The **\n** Installation Process Is Started **")
  (message "\n\nAre You Sure You Wish To Install\n\nC-O-I-N-M-A-N-I-A\n---------\nIn The Directory:\n\n " CM_Dest "\n-----"
	   "\n\n** This Is Your LAST Chance To QUIT Before The **\n** Installation Process Is Started **")
)
(askdisk (prompt "\n\n\n\n\nPlease Insert The Disk\nCheapware:\nInto Any Drive")
 (help "")
 (dest "CheapWare")
)
(set CM_CoinDir (tackon CM_Dest "Coinmania"))
(set CM_Source ("Cheapware:Coinmania"))
(set Mod_Okay (exists (CM_Source) (noreq)))
(set IS_ERROR 0)
(If (= Mod_Okay IS_ERROR)
 ((message "\n\n\n\nSource Disk Is Not Set Up Correctly\n\n------------\n\nAborting Installation")
  (exit (quiet))
 )
)
(set Number_Of_Files 15)
(set Current_File 0)
(set File_Found 1)
(set ERRORS 0)
(Set File_Name "Nothing")
(working "\nChecking Files For Existance:")
(while (<> Current_File Number_Of_Files)
 (set Current_File (+ Current_File 1))
  (if (= Current_File 1)(set File_Name "Cheapware:Coinmania/Data/CMAbout1.PAK"))
  (if (= Current_File 2)(set File_Name "Cheapware:Coinmania/Data/CMAbout2.PAK"))
  (if (= Current_File 3)(set File_Name "Cheapware:Coinmania/Data/CMExtraMem.PAK"))
  (if (= Current_File 4)(set File_Name "Cheapware:Coinmania/Data/CMCongratulations.PAK"))
  (if (= Current_File 5)(set File_Name "Cheapware:Coinmania/Data/CMHelpPage.PAK"))

  (if (= Current_File 6)(set File_Name "Cheapware:Coinmania/Banks/GameB.BANK"))
  (if (= Current_File 7)(set File_Name "Cheapware:Coinmania/Banks/GameI.BANK"))
  (if (= Current_File 8)(set File_Name "Cheapware:Coinmania/Banks/HelpB.BANK"))
  (if (= Current_File 9)(set File_Name "Cheapware:Coinmania/Banks/MenuB.BANK"))
  (if (= Current_File 10)(set File_Name "Cheapware:Coinmania/Banks/MenuI.BANK"))
  (if (= Current_File 11)
   (if (= Own_Music YES)
    (set File_Name Module_Name)
    (set File_Name "Cheapware:Coinmania/Sounds/InGame.MUSIC")
   )
  )
  (if (= Current_File 12)
    (set File_Name "Cheapware:Coinmania/Sounds/Coinmania.SFX")
  )
  (if (= Current_File 13)
    (set File_Name "Cheapware:Coinmania/Sounds/EndGame.MUSIC")
  )
  (if (= Current_File 14)
    (set File_Name "Cheapware:Coinmania/Sounds/High.MUSIC")
  )
  (if (= Current_File 15)
    (set File_Name "Cheapware:Fonts/Coinmania.font")
  )
  (set Flag (exists File_Name))
  (if (<> Flag File_Found)
   ((message "\n\n\nChecking Files For Existance:\n\nERROR: File Not Found\n\n"
	     "-----\n\nFileName: " File_Name)
    (set ERRORS (+ ERRORS 1)
   )
   (working "\nChecking Files For Existance:\n\n\n"
	     "------------\n\n"
	    ERRORS " Error(s) Detected")
  )
 )
)
(if (>= ERRORS 1)
 (abort ERRORS " File(s) Not Found!!!\n"
	       "Unable To Complete Installation Of\n\n"
	       "-- COINMANIA --\n\n"
	       "To\n\n" CM_CoinDir)
)
(complete 5)
(set CM_Root (getdevice CM_CoinDir))
(if (= CM_Root "DH0")
    (set CM_Root ("DH0:"))
)
(if (= CM_Root "DH1")
    (set CM_Root ("DH1:"))
)
(if (= CM_Root "RAM")
    (set CM_Root ("RAM:"))
)
(set CM_DataDir (tackon CM_CoinDir "Data"))
(set CM_BanksDir (tackon CM_CoinDir "Banks"))
(set CM_SoundsDir (tackon CM_CoinDir "Sounds"))
(set CM_Libs (tackon CM_Root "Libs"))
(set CM_Fonts (tackon CM_Root "Fonts"))
(complete 6)
(makedir CM_CoinDir
	 (prompt "")
	 (help "")
)
(complete 8)
(copyfiles (prompt "")
	   (infos)
	   (help "")
	   (source "Cheapware:Coinmania/Coinmania")
	   (dest CM_CoinDir)
)
(copyfiles (prompt "")
	   (infos)
	   (help "")
	   (source "Cheapware:Coinmania/Data")
	   (dest CM_DataDir)
	   (all)
)
(complete 10)
(copyfiles (prompt "")
	   (infos)
	   (help "")
	   (source "Cheapware:Coinmania/Banks")
	   (dest CM_BanksDir)
	   (all)
)
(complete 20)
(if (exists "Cheapware:Coinmania/Coinmania.High")
 (copyfiles (prompt "")
	    (help "")
	    (source "Cheapware:Coinmania/Coinmania.High")
	    (dest CM_CoinDir)
 )
)
(complete 25)
(copylib (prompt "")
	 (help "")
	 (source "CheapWare:Libs/Amos.Library")
	 (dest CM_Libs)
)
(copyfiles (prompt "")
	   (help "")
	   (source "Cheapware:Fonts")
	   (dest CM_Fonts)
	   (all)
)
(complete 40)
(copyfiles (prompt "")
	   (help "")
	   (source "Cheapware:Coinmania/Sounds/EndGame.Music")
	   (dest CM_SoundsDir)
)
(complete 50)
(copyfiles (prompt "")
	   (help "")
	   (source "Cheapware:Coinmania/Sounds/High.Music")
	   (dest CM_SoundsDir)
)
(complete 60)
(if (= Own_Music YES)
 (copyfiles (prompt "")
	    (help "")
	    (source Module_Name)
	    (dest CM_SoundsDir)
	    (newname "InGame.MUSIC")
 )
 (copyfiles (prompt "")
	    (help "")
	    (source "Cheapware:Coinmania/Sounds/InGame.MUSIC")
	    (dest CM_SoundsDir)
 )
)
(complete 70)
(copyfiles (prompt "")
	   (help "")
	   (source "Cheapware:Coinmania/Sounds/Coinmania.SFX")
	   (dest CM_SoundsDir)
)
(complete 80)
(copyfiles (prompt "")
	   (help "")
	   (source "Cheapware:Coinmania/Sounds/Intro.MUSIC")
	   (dest CM_SoundsDir)
)
(complete 90)
(if (exists "Cheapware:Coinmania/Coinmania.Guide")
 ((if (exists "Cheapware:Coinmania/CoinmaniaInstaller")
  (set CopyExtras (askoptions
  		(prompt "Would You Like Any Other Of The\n"
			"COINMANIA\n"
			"Bits Copied To Your Hard Drive")
		(help "")
		(choices " COINMANIA Guide"
			 " HARD DRIVE Installer")))
  (set CopyExtras (askoptions
  		(prompt "Would You Like Any Other Of The\n"
			"COINMANIA\n"
			"Bits Copied To Your Hard Drive")
		(help "")
		(choices " COINMANIA Guide")))))
 (if (exists "Cheapware:Coinmania/CoinmaniaInstaller")
  (set CopyExtras (askoptions
  		(prompt "Would You Like Any Other Of The\n"
			"COINMANIA\n"
			"Bits Copied To Your Hard Drive")
		(help "")
		(choices " HARD DRIVE Installer")))))
(if (in CopyExtras 0)
 (if (exists "Cheapware:Coinmania/Coinmania.guide")
  (copyfiles (prompt "")
	     (help "")
	     (infos)
	     (source "Cheapware:Coinmania/Coinmania.Guide")
	     (dest CM_CoinDir))))
(if (in CopyExtras 1)
 (if (exists "Cheapware:Coinmania/CoinmaniaInstaller")
  (copyfiles (prompt "")
	     (infos)
	     (help "")
	     (source "Cheapware:Coinmania/CoinmaniaInstaller")
	     (dest CM_CoinDir))))
(complete 99)
(message "\n\nNow Attempting To Edit File\n\n"
	 "--------\n"
	 "S:User-Startup\n"
	 "---------\n\n"
	 "To Include The Line\n\n"
	 "--------------------------\n"
	 "ASSIGN CoinMania: " CM_CoinDir)
(startup "COINMANIA"
	 (prompt "Editing Startup-Sequence To Include Assign")
	 (help "")
	 (command "Assign Coinmania: " CM_CoinDir))
(complete 100)
(message "\n\n\n\nNow Please REBOOT Your Computer\n\n"
	 "To Play\n\n"
	 "<==---   ---==>\n"
	 "<-- COIN MANIA - The Game -->\n"
	 "<==---   ---==>")
