# File: seq_options.src
# HISTORY:
#	Written 11-Jan-96 by M.Morrison
#	22-Jan-96 (MDM) - Added sub-menu option to access the ALT and NEW
#			  options
#	14-May-96 (MDM) - Added DYNAMICS OPTIONS to set the Mag5k flag
#			  and the CONTINUUM/LINEDEPTH option
#			- Added GOTO statements to speed things up
#			- Added New addr AND new flag button
#	25-Jul-96 (DPM) - Modified to handle multiple chain option
#			- Added TERMINATE CAM flag option
#	30-Jul-96 (MDM) - Modified multiple chain to fill 8 chain
#			  addresses with the same thing (instead of
#			  NOOP)
#	
#
program "%Z% MODULE: %M% RELEASE: %R%.%L% CREATED: %G% %U%"
source "/mdisw/cfl/flight/src/seq_options_v05.src"
descr "A menu tool to allow the user to adjust the sequence options"


display " "

for !LI9 = 0 to 32000

top:
    menu !LS0 "Seq Options" \
	"Set cam addr"   "Set cam flag"   "Clr cam flag" \
	"Set cam addr and flag" \
        "Enable auto cam terminate" "Disable auto cam terminate" \
	"ALT Options" "New/Chain Options" "Dynamics Options" \
	"QUIT SEQ_OPTIONS"


    exit if !LS0 = "QUIT SEQ_OPTIONS"

    ## ------------- Dynamics stuff

    if !LS0 = "Dynamics Options" then
opt_dyn:
	menu !LS1 "Seq Options (cont)" \
	    "D/L Line-Depth" "D/L Continuum" "D/L Mag in 160K" \
		"D/L Mag in 5K" "QUIT SEQ_OPTIONS" "RETURN"

        exit if !LS1 = "QUIT SEQ_OPTIONS"
	if !LS1 = "RETURN" then
	    goto top
	end if

        if !LS1 = "D/L Line-Depth" then
	    tcblock mbipldin 0x140 1683 1		## D/L line-depth
	    goto opt_dyn
        end if

        if !LS1 = "D/L Continuum" then
	    tcblock mbipldin 0x140 1683 0		## D/L continuum
	    goto opt_dyn
        end if

        if !LS1 = "D/L Mag in 160K" then
	    tcblock mbsqreg 5 1				## D/L mag in 160K
	    goto opt_dyn
        end if

        if !LS1 = "D/L Mag in 5K" then
	    tcblock mbsqreg 5 0				## D/L mag in 5K
	    goto opt_dyn
        end if

	if !LS1 <> "RETURN" then
	    goto opt_dyn
	end if
    end if


    ## ------------- New campaign stuff

    if !LS0 = "New/Chain Options" then
opt_new:
	menu !LS1 "Seq Options (cont)" \
	    "Set chain addr" "Set chain flag" "Clr chain flag" \
	    "Set new cam addr" "Set new cam flag" "Clr new cam flag" \
	    "Set new addr and flag" "QUIT SEQ_OPTIONS" "RETURN"

        exit if !LS1 = "QUIT SEQ_OPTIONS"
	if !LS1 = "RETURN" then
	    goto top
	end if

        if !LS1 = "Set new cam addr" then
	    ask !LI0 "Enter the campaign address"
	    tcblock mbsqreg 69 !LI0		## set new cam address
	    goto opt_new
        end if

        if !LS1 = "Clr new cam flag" then
	    tcblock mbsqreg 68     0	## Disable new Flag
	    goto opt_new
        end if

        if !LS1 = "Set new cam flag" then
	    tcblock mbsqreg 68     1	## enable new Flag
	    goto opt_new
        end if

        if !LS1 = "Set new addr and flag" then
	    ask !LI0 "Enter the campaign address"
	    tcblock mbsqreg 69 !LI0		## set new cam address
	    tcblock mbsqreg 68     1	## enable new Flag
	    goto opt_new
        end if

        ## ------------- Chain campaign stuff
        if !LS1 = "Set chain addr" then
   	    ask !LI0 "Enter the campaign address"
	    tcblock mbsqreg 151 !LI0		## set chain address
	    tcblock mbsqreg 73  !LI0		## copy of chain address
            for !LI1 = 152 to 159
                ## tcblock mbsqreg !LI1 0xffff
                tcblock mbsqreg !LI1 !LI0
            end for
	    goto opt_new
        end if

        if !LS1 = "Clr chain flag" then
	    tcblock mbsqreg 72     0	## Disable chain Flag
	    goto opt_new
        end if

        if !LS1 = "Set chain flag" then
	    tcblock mbsqreg 72     1	## enable chain Flag
	    goto opt_new
        end if

	if !LS1 <> "RETURN" then
	    goto opt_new
	end if
    end if

    ## ------------- Alternate seq stuff
    if !LS0 = "ALT Options" then
opt_alt:
	menu !LS1 "Seq Options (cont)" \
	    "Enable Alt Seq" "Disable Alt Seq" \
	    "Change Alt Cadence" "Change Alt Repeat Count" \
	    "QUIT SEQ_OPTIONS" "RETURN"

        exit if !LS1 = "QUIT SEQ_OPTIONS"
	if !LS1 = "RETURN" then
	    goto top
	end if

        display "%s" !LS1

        if !LS1 = "Enable Alt Seq" then
	    tcblock mbsqreg 65     1	## Enable ALT 
	    goto opt_alt
        end if

        if !LS1 = "Disable Alt Seq" then
	    tcblock mbsqreg 65     0        ## Disable ALT 
	    goto opt_alt
        end if

        if !LS1 = "Change Alt Cadence" then
	    ask !LI0 "Enter the new cadence in minutes"
	    tcblock mbsqreg 54 !LI0		## ALT cadence
	    tcblock mbsqreg 64 1		## new prime flag
	    goto opt_alt
        end if

        if !LS1 = "Change Alt Repeat Count" then
	    ask !LI0 "Enter the new repeat count (ie 5)"
	    tcblock mbsqreg 53 !LI0   	## ALT repeats (DEP Reg)
	    tcblock mbsqreg 64 1		## new prime flag
	    tcblock mbipldin 0x140 1349 !LI0  ## ALT repeats (IP Reg)
	    goto opt_alt
        end if

	if !LS1 <> "RETURN" then
	    goto opt_alt
	end if
    end if


    ## ------------- Main campaign stuff
    if !LS0 = "Set cam addr" then
	ask !LI0 "Enter the campaign address"
	tcblock mbsqreg 67 !LI0		## set campaign address
	goto top
    end if

    if !LS0 = "Clr cam flag" then
	tcblock mbsqreg 66     0	## Disable Campaign Flag
	goto top
    end if

    if !LS0 = "Set cam flag" then
	tcblock mbsqreg 66     1	## enable Campaign Flag
	goto top
    end if

    if !LS0 = "Set cam addr and flag" then
	ask !LI0 "Enter the campaign address"
	tcblock mbsqreg 67 !LI0		## set campaign address
	tcblock mbsqreg 66     1	## enable Campaign Flag
	goto top
    end if

    if !LS0 = "Enable auto cam terminate" then
        tcblock mbsqreg 76 1            ## enable auto campaign termination
    end if

    if !LS0 = "Disable auto cam terminate" then
        tcblock mbsqreg 76 0            ## disable auto campaign termination
    end if

end for
