; Program:  startup-sequence
; Version:  1.2
; Project:  "Wing Commander", Commodore Amiga conversion, English version
; Author:   Nick Pelling
; Function: Set Wing Commander going...
type menu
mouse
cls
cd c
echo " "
echo " "
echo "                     Wing Commander for the Commodore Amiga"

; Use fast memory first!...
FastMemFirst

; Fix OS-incompatibilities etc  (for "setpatch" read "bugfixorama")
version >NIL: graphics.library 36
if warn
  setpatch >NIL:
else
  setpatchV38.31 >NIL:
endif


; Check to see if player only has 512K of RAM...
memavail 600000
if warn
  echo "Sorry - this game needs at least a megabyte of memory to run"
  skip EXIT
endif

; If (memavail < 2Mb), shut down all non-essential devices (esp. on 1Mb A600)
; Extend this idea to all non-essential devices (see L+R mousebutton boot-menu)
memavail 2000000
if warn
  multidie >NIL: CC0: DH0:
  remove   >NIL: carddisk.device ramdrive.device
  wipeout  >NIL: carddisk.device ramdrive.device
else
  isdosdev >NIL: DF0:
  if not warn
    addbuffers DF0: 20
  endif
  isdosdev >NIL: DF1:
  if not warn
    addbuffers DF1: 20
  endif
  isdosdev >NIL: DF2:
  if not warn
    addbuffers DF2: 20
  endif
  isdosdev >NIL: DF3:
  if not warn
    addbuffers DF3: 20
  endif
endif


; If (memavail < 1Mb), shut down external drives
; I'm sorry! Wing Commander has been heavily squeezed to fit inside 1Mb at all!
memavail 1100000
if warn
  isdosdev >NIL: DF1:
  if not warn
    echo "       Please disconnect DF1: and reboot"
    skip EXIT
  endif
  isdosdev >NIL: DF2:
  if not warn
    echo "       Please disconnect DF2: and reboot"
    skip EXIT
  endif
  isdosdev >NIL: DF3:
  if not warn
    echo "       Please disconnect DF3: and reboot"
    skip EXIT
  endif
  remove  >NIL: mathffp.library expansion.library
  wipeout >NIL: mathffp.library expansion.library
endif


; Use gb keyboard (for English code release...)
setmap gb

; Describe what's going on...
echo " "
echo "                            Main game now loading..."

; Run Wing Commander: it will detach itself from the CLI and return here...
; Note: no need to run <stack>: the detached process allocates this itself.
cd /
Wing h0

; Finish up, ends CLI session: *should* allow Wing to claim WorkBench memory
endcli

lab EXIT
