# File: runstr.src
#
#-------------------
# Executes procedures to construct and downlink observables(velocity, 
# line depth and continuum).
# 
# Note: 1. mkobstbl, 5ktst and strdp control files must have been executed 
#          before running this procedure
#       2. !GI9 must contain the address of entry point into strdp
#          !GI8 must contain the address of entry point in 5ktst
#
# V6 - Change Prime60 and Prime30 addresses
#	12-Dec-95 (MDM) - Commented out setting IPvector for 2,3, and 6
# Modified to v04 by CED 12/17/95
#  --removed VC flag commands (those are handled for us by the FOT
#  when they run k_mmtoidl and k_idltomm).
# 11-Jan-96 (MDM) - Replace clearing R4 campaign flag (CED had removed
#		    it on 17-Dec-95)
# 31-Jan-96 Dnyanesh Mathur
#    1. Removed all waits!!
#    2. Clear R81 (Bad HK board indicator)
# 31-Jan-96 (MDM) - Added setting of all campaign addresses since it is
#		    being removed from the sequence startup
#		  - Removed the setting of the IP vectors (into set_ipvec_str.src)
#  6-Feb-96 (MDM) - Made setting of the ALT flag the default
#
# 27 Mar 96 (DPM) - Initialize register lists for str/mag
# 28-Mar-96 (MDM) - Changed the MAG_TELEM default setting to 0 (from 1) (reg 5)
#                
#  9-Apr-96 (DPM) - IP Register setup occurs in str_setup routine
# 23-Apr-96 (MDM) - Put wait before execution of STRDPC
# 30-Apr-96 (DPM) - Removed wait before execution of STRDPC and figured out
#                   the real problem. STRDPC is now called first and STR_RLINIT
#                   has been modified to be consistant.
# 17-May-96 (MDM) - Added call to set_alt_time control file at the end
#
# 24-May-96 (DPM) - STRDPC is again called last!! 
#
# 26-Jul-96 (DPM) - Set Mag D/L Reg (R5) to 1
#                   Set Chain Address to 88 using R151; Clear R152-R158
# 12-Aug-96 (DPM) - Set chain addresses to 88.
# 13-Aug-96 (DPM) - Initialize DEP registers by memory load commands to
#                   cut down on number of telecommands required.
#  3-Oct-96 (DPM) - Changed address of initmag due to change to mag30.
#
program "%Z% MODULE: %M% RELEASE: %R%.%L% CREATED: %G% %U%"
source "/mdisw/cfl/flight/src/runstr_v24.src"
descr "runstr - execute macros from mkstr."

display "Executing procedure  runstr."

tcblock mbipldin 0x136            ## Enable Queue
tcblock mbdpmod 3                 ## Set 5k mode
tcblock mbipldin 0x134            ## Enable interrupts

tcblock mbipldin 0x11C              ## Initialize subroutine stack

# Initialize Error Log
tcblock mbipldin 0x1b2 464 3  0x0000  0x2011 4800
tcblock mbipldin 0x01EC  464
#
# Initialize Register Lists and data buffers
tcblock mbipldin 0x152 0x0F00       ## Call QSR_STR_SETUP 
tcblock mbipldin 0x152 0x0600       ## Call QSR_STR_RLINIT 
tcblock mbipldin 0x152 0x0A38       ## Call QSR_MAG_INITMAG
tcblock mbipldin 0x152 0x0F80       ## Call QSR_STR_SETDPC

# Initialize DEP Registers - 
#   (DEP registers are located at 1000:8CB4 in DFC100a)

# Set DEP Registers 4 (Cmpg Status) and 5 (MagHR)
tcblock mbdpml 0x1000 0x8cbc  0  0

# Set DEP Registers 65 - 73 
#   (ALTF, CmpgF, CmpgA, NewCmpgF, NewCmpgA, IIF, IIA, ChainF, ChainA)
tcblock mbdpml 0x1000 0x8d36  1  0  0  0 88  0 88  0 88

# Set DEP Registers 151 - 158 (Chain Addresses)
tcblock mbdpml 0x1000 0x8de2 88 88 88 88 88 88 88 88 

# Disable Alternate 2nd data product downlinks
#   (Mag, CBv, CBi, Mem)
tcblock mbipldin 0x1b2 1801 8 0 0 0 0 0 0 0 0 

tcblock mbdpflgs 16 0xffff 0        ## Clear IP Error count

# Run DEP sequence 
tcblock mbsqreg 247 0x7FFF          ## Use Frame List Que pointer only
tcblock mbsqstr 0

wait time 120			    ## wait 2 minutes for seq startup
perf set_alt_time_v08

display "Finished procedure runstr"
return
