PROMPT  "Processing, please wait..."

data var025 ""	;#4 package will be defined in product.txt if extant

macro "product.txt"
;
data DFLT_PROD  "HP64000-PC"    ;Software package name if no volume label
;
;Set up default values:
data DFLT_DRIVE "A:"            ;Drive to install software upon
data DFLT_DIR   "HP64700"       ;Top level directory for this software
data EXE_DIR	"BIN"    ;Sub-directory for executables
data TABLE_DIR	"TABLES" ;Sub-directory for config, assm, & link tables
;
data SRC_ROOT   "\HP64700"
data SRC_BIN    "\HP64700\BIN"
data SRC_TABLES "\HP64700\TABLES"
data FUI_CFG	"64700TAB"	;FUI configuration file.
data ENV_ROOT   "HPTABLES"	;Environment variable name to point to root
;
;Get constant messages -
data MSG01 "!1 (!6) software installation aborted#!"
data MSG02 "Copying Files to !3"
data MSG04 "UNABLE TO ACCESS DISC DRIVE. CONTINUE? (Y/N)"
data MSG05 "Do you really want to abort? (Y/N)"
data MSG07 "Press any key when ready..."
data MSG09 "File copying routine interrupted, bad directory, or out of disc space#!"
data blankline "                                                                              ~"
data YES_KEY  "Y"
data YES_LOW  "y"
data NO_KEY   "N"
data NO_LOW   "n"

data in_brk 0		;Initially not in break routine!

;Main code block starts here:
  onbreak gosub break_key
  onerror gosub door_ajar
main
  whichdrive var009		;Remember where we started
  set var002   DFLT_DRIVE
  set dest_dir DFLT_DIR
  set cur_prod DFLT_PROD

main0
  set var001 cur_prod
  echo on
  gosub new_page
  print "This is the installation program for your !1 software.~~"
  print "This program will guide you through the steps of the installation.~~"
  print "The software provided will reside in its own subdirectory  upon your disc.~"
  print "The default disc drive and directory for installation of these products is~"
  print "'" var002 "\" dest_dir "'.   All of your !1 type software (assemblers, linkers,~"
  print "emulators, etc.) may be put into the same directory. You will be given the~"
  print "option of changing the default drive and/or subdirectory for installation.~~"
  print "Your target software may reside anywhere.~~"
  print "You may use the Cntl-C key combination to abort at any time.~~"
  print "Do you wish to continue this installation procedure? (Y/N)"
  gosub yesno
  if result != 2 goto abort

main1
  gosub new_page
  gosub get_path

  ;Root directory has been set up and is ok.  Build sub-directories.
  set var004 var003	;Executables directory
  strcat var004 "\"
  strcat var004 EXE_DIR
  mkdir var004 status
  ;
  set var005 var003	;Tables directory
  strcat var005 "\"
  strcat var005 TABLE_DIR
  mkdir var005 status
  ;
  gosub new_page
  ;Check to see if more than one section, don't print if only one
  if var019 = "" goto do_ei1
    print "Your !1 software is provided as separate packages:~~"
    print "  1) !17.~"
    print "  2) !16.~"
    print "  3) !15.~"
    if var025 = "" goto do_ei0
    print "  4) !26.~"
do_ei0
    print "~"
    print "Each of these is a separately installable product.   This  install program~"
    print "will allow you to choose whether to install each of these sections. Unless~"
    print "you have a specific reason not to,  it is  recommended  that  you  install~"
    print "all of the sections.   They are  distributed separately so that any future~"
    print "updates may be easily accomplished.~~"
  ;
do_ei1
  ;Is there an emulator user interface?
  if var014 = "" goto do_ei7
  ;Shall we install the emulator user interface?
  print "Do you wish to install the !17? (Y/N)"
  gosub yesno
  if result = 3 goto do_ei7
    gosub new_page
    print "Installing !17.~~"
    ;Install the emulator user interface
    set fui var018       ;Build FUI names for part 1, 2, and .exe
    strcat fui ".exe"
    changedrive var002  ;Delete old parts 1 & 2
    cd var004
    delete fui
    changedrive var009
    set var010 fui 	;set up to copy all files
    set var011 SRC_BIN	;from executable directory of current disc to
    set var012 var004	;destination
    gosub copy_file
    changedrive var009
    ;Check for FUI config file
    set temp var005
    strcat temp "\"
    strcat temp FUI_CFG
    set result 2		;Yes for install config file
    set status 0
    exist temp status
    if status = -1 goto do_ei3
      print "~"
      print "The emulator device table file already exists.  This file specifies~"
      print "communication parameters (baud rate, etc.) for the emulator device.~"
      print "If you have not previously customized this  file for your hardware,~"
      print "it is suggested that you replace it with the default configuration.~"
      print "If you have doubts, it is suggested that you do not replace it.  Do~"
      print "you wish to replace the existing file with the default? (Y/N)"
      gosub yesno
      print "~~"
do_ei3
    if result != 2 goto do_ei5	;Don't do it
      set var010 FUI_CFG    ;set up to copy configuration file
      set var011 SRC_TABLES ;from tables directory of current disc to
      set var012 var005	  ;destination tables directory
      gosub copy_file
      pause 2
do_ei5
    print "~!17 installation complete.~"
    pause 3
    ;
do_ei7
  ;Are there processor specific tables?
  if var019 = "" goto do_ps7
  gosub new_page
  ;Shall we install the processor specific tables?
  print "Do you wish to install the !16? (Y/N)"
  gosub yesno
  print "~~"
  if result = 3 goto do_ps7
    ;Install the processor specific tables
    print "~"
    set var021 var016
    set var020 "1"	;Load up CROSS ASSEMBELER disk 1
    gosub load_disc
    gosub new_page
    print "Installing !16.~~"
    ;
    ; Copy the files in the tables directory to dest.
    set var010 "*.*"	;set up to copy all files
    set var011 SRC_TABLES	;from tables directory of current disc to
    set var012 var005	;to destination
    gosub copy_file
    ; Get revision information
    set var021 var019
    gosub get_revision
    ;
    print "~!16 installation complete.~"
    pause 3
    ;
do_ps7
  ;Is there a UDA to install?
  if var013 = "" goto do_ud7
  gosub new_page
  ;Shall we install the user definable assembler/linker?
  print "Do you wish to install the !15? (Y/N)"
  gosub yesno
  if result = 3 goto do_ud7
    ;Install the user definable assembler files
    print "~"
    set var020 "1"	;Load up USER DEFINABLE ASSEMBLER disc
    set var021 var015
    gosub load_disc
    gosub new_page
    print "Installing !15.~~"
    ;
    ; Copy the files in the bin directory to dest.
    set var010 "*.*"	;set up to copy all files
    set var011 SRC_BIN	;from executable directory of current disc to
    set var012 var004	;to destination
    gosub copy_file
    ; Get revision information
    set var021 var013
    gosub get_revision
    ;
    print "~!15 installation complete.~"
    pause 3
    ;
do_ud7
  ;Is there a optional fourth package to install?
  if var025 = "" goto do_fp7
  gosub new_page
  ;Shall we install the optional fourth package?
  print "Do you wish to install the !26? (Y/N)"
  gosub yesno
  if result = 3 goto do_fp7
    print "~"
    set var020 "1"	;Load up disc
    set var021 var026
    gosub load_disc
    gosub new_page
    print "Installing !26.~~"
    ;
    ; Copy the files in the bin directory to dest.
    set var010 "*.*"	;set up to copy all files
    set var011 SRC_BIN	;from executable directory of current disc to
    set var012 var004	;to destination
    gosub copy_file
    ;
    ; Get revision information
    set var021 var025
    gosub get_revision
    ;
    print "~!26 installation complete.~"
    pause 3
    ;
do_fp7
  ;
  cd "\"
  gosub new_page
  bell
  print "Please remove disc from drive !9:.  At this point you may wish to install any~"
  print "other !1 type software that you have purchased.  To do so, place the~"
  print "first disc of that package into drive !9: and type 'install'.~~"
  print "To allow your !1 software to run,  your 'PATH' list must include the~"
  print "execution path '!4', the environment variable '" ENV_ROOT "' must be~"
  print "set to the path '!5', and the  '\config.sys' file must have a~"
  print "'FILES='  command for at least  12 concurrent files.  These variables should~"
  print "be set up at  power on time.   To accomplish this, you will need to edit the~"
  print "files: '\AUTOEXEC.BAT' and '\CONFIG.SYS' on the hard disc you will boot from.~"
  print "See your MS-DOS manual for examples of these files and the commands: 'PATH',~"
  print "'SET', and 'FILES'.   Use your  favorite editor to update these files.   The~"
  print "root  directory  of the  'MASTER  APPLICATION  DISC' contains  example files~"
  print "named: AUTOEXEC.EX  and  CONFIG.EX for the default variable values.~~"
  print "Once you have completed installing all of your !1 packages, and have~"
  print "edited the necessary files, please reset the computer to set up the required~"
  print "environment variables.  (Press: [RESET] button to reset.)~"
  stop
;
;
new_page
  cls 
  print "!1 (!6) software installation.  (C) 1988 Hewlett-Packard Co.~~~"
  return
;
;
load_disc ;Ask user to put prod var021 disc #var020 into drive var9 and verify correct
  print "~"
load_disc1
  set status 0
  print "Please put !21 disc !20 into drive !9:"
  gosub any_key
  print "~"
  return
;
;
get_path  ;Determine disc and directory to copy to
;Prompts user for drive and directory, creates dir if needed
;Inputs  - var002 = Default disc id
;          dest_dir = Default directory
;Outputs - var002 = Disc identifier for path (C:)
;          var003 = Full path to directory (C:\hp64700)
;          dest_dir= Root directory name on destination (\hp64700)
  cursor get_px,get_py
get_path1
  pos   get_px,get_py
  gosub get_drive
get_path2
  pos   get_px,get_py
  move  0,1
  print  blankline
  pos   get_px,get_py
  move  0,1
  print "Select destination path  = !2\"
  set status 0
  input 50 dest_dir dest_dir
  if status = -23 goto get_path2 ;Repeat if break and continue
  print "~"
  upshift dest_dir
  
  set var003 var002		;Build directory path
  strcat var003 "\"
  strcat var003 dest_dir

  gosub get_dir		;Check for previous existance of this directory
  if status = -1 goto get_path1
  gosub status_clear	;Clear any error message
  return
;
;
get_drive	;Prompt user for drive ID (ex: C:) return in var002
  print "Select destination drive = "
  cursor get_dx,get_dy
get_drive2
  pos get_dx,get_dy
  set status 0
  input 2 var002 var002
  if status = -23 goto get_drive2	;Repeat if break and continue
  upshift var002
  set errmsg "Improper drive specifier. Must be a letter followed by a colon."
  mid temp var002 2 1	;Verify presence of colon
  if temp = ":" goto get_drive3
    gosub status_bar
    goto get_drive2
get_drive3
  gosub status_clear
  set temp var002	;Check accessability of this drive.
  strcat temp "\"
  exist temp status
  if status = 2  goto get_drive5
    set errmsg "Improper drive specifier"
    gosub status_bar
    goto get_drive2
get_drive5
  free var002 space_avail
  if space_avail >= SPACE_NEEDED goto get_drive7
    set errmsg "Not enough room on selected drive.  Select another or abort."
    gosub status_bar
    goto get_drive2
get_drive7
  print "~"
  return
;
;
get_dir		;Check & build directory if needed.  Will check for existance
		;of directory and do a makdir if needed, error messages will
		;be displayed if encountered.
		;Inputs - var003 = directory path name (Drive & name)
		;Output - status = 0 if Directory ok, -1 if not
  exist var003 status	;Check for previous existance of this directory
  if status != 1 goto get_dir2
    set errmsg "The specified path (!3) leads to a file, NOT a valid directory."
    gosub status_bar
    set status -1
    bell
    return
get_dir2
  if status != 2 goto get_dir4
    print "~"
    print "The specifed directory already exists.  This indicates that this package,~"
    print "or another !1 series package may have already been installed.  No~"
    print "harm should arise from installing twice, and adding packages is fine, but~"
    print "if you thought that this was the FIRST !1 package to be installed~"
    print "on this machine, you may wish to stop this procedure and investigate.~~"
    print "Do you wish to continue with this procedure? (Y/N)"
    gosub yesno
    print "~~"
    if result = 3 goto abort
    set status 0
    return
get_dir4
  if status != -1 goto get_dir9
    set errmsg "Creating directory (!3)"
    gosub status_bar
    pause 2	;give a sec to allow reading
    mkdir var003 status
    if status != -1 goto get_dir6
      set errmsg "Unable to create directory !3. Verify disc and name are valid."
      gosub status_bar
      bell
      return
get_dir6
  set status 0
  return
get_dir9
  bell
  set status -1
  return
;
;
copy_file	;Copy var010 file(s) from dir var011 to dir var012
  cd var011
  print "Copying !10 from !9:!11 to !12.~Copying file: "
copy_file2
  fcount 1
  set status 0
  copy var010 var012 status
  if status = -23 goto copy_file2
  if status = -24 goto copy_file2
  ;
  if status = 1 goto copy_file4
    print "~~Error while copying !10 from !9:!11 to !12~"
    print "Bad directory, file not found, disc error, or interrupted!~"
    bell
    goto abort
copy_file4
  print "~"
  return
;
;
get_revision ;Get revison info for product var021
  changedrive var002
  cd var003
  delete "productr"    ;get rid of any current revison file this product
  set rev var021
  strcat rev ".rev"
  delete rev
  changedrive var009
  ;Now to get info
  set    temp "\system\"
  strcat temp var021
  cd temp
  echo off
get_rev2
  set status 0
  copy "productr" var003 status
  if status = -23 goto get_rev2
  if status = -24 goto get_rev2
  ;
  if status = 1 goto get_rev4
    print "~Bad directory, file not found, disc error, or interrupted!~"
    bell
    goto abort
get_rev4
  echo on 
  set temp var003
  strcat temp "\PRODUCTR"
  set new var003
  strcat new "\"
  strcat new rev
  rename temp new
  return
;
;
break_key		;Executed in case of Cntl-C
  if in_brk = 1 return	;Second cntl-C, ignore
  set in_brk 1
  cursor x_brk,y_brk 
  pos 0,19
  savline brk1
  print "~"
  savline brk2
  print "~"
  savline brk3
  box 23,19 60,21
  pos 25,20
  print MSG05
break_2
  echo off
  set status 0 
  input 1 temp 
  set result 0
  if temp  = YES_KEY set result 2
  if temp  = YES_LOW set result 2
  if temp  = NO_KEY set result 3
  if temp  = NO_LOW set result 3
  if result = 0 goto break_2
  echo on	
  pos 0,19
  print BRK1 "~"
  print BRK2 "~"
  print BRK3 "~"
  pos x_brk,y_brk
  if result = 2 goto abort
  set status -23
  set in_brk 0
  return

abort
  print "~~~"
  print MSG01 "~~~~"
  cd "\"
  stop

door_ajar 	;Sets status to -24 if door found open
  cursor x_aja,y_aja 
  pos 0,19
  savline aja1
  print "~"
  savline aja2
  print "~"
  savline aja3
  box 23,19 70,21
  pos 25,20
  print MSG04
ajar_2
  echo off
  set status 0 
  input 1 temp 
  set result 0
  if temp  = YES_KEY set result 2
  if temp  = YES_LOW set result 2
  if temp  = NO_KEY set result 3
  if temp  = NO_LOW set result 3
  if result = 0 goto ajar_2
  echo on	
  pos 0,19
  print aja1 "~"
  print aja2 "~"
  print aja3 "~"
  pos x_aja,y_aja
  if result = 3 goto abort
  set status -24
  return		 

any_key
  cursor any_x,any_y
  pos 43,22
  print MSG07
  echo off
  set status 0
  input 1 dummy
  echo on
  if status = -23 goto any_key
  pos 1,22
  print blankline
  pos any_x,any_y
  return

status_bar
  cursor status_x,status_y
  pos 0,22
  print errmsg
  pos status_x,status_y
  return

status_clear
  cursor status_x,status_y
  pos 0,22
  print blankline
  pos status_x,status_y
  return

yesno		;Return result= 1-No input, 2-Yes, 3-No
  cursor yes_x,yes_y
  echo off
  set status 0 
  input 1 temp 
  pos yes_x,yes_y
  set result 0
  if status = -23 goto yesno
  if temp  = YES_KEY set result 2
  if temp  = YES_LOW set result 2
  if temp  = NO_KEY set result 3
  if temp  = NO_LOW set result 3
  if temp  = "" set result 1
  if result = 0 goto yesno
  echo on	
  return
