# 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
#
# Modifications:  
#       20-Sep-95  Dnyanesh Mathur
#          Clear ALT and Campaign Flags;
#          Patch mkstr code to set length of DPC98 to 1
#
#.................................................................
#
program "%Z% MODULE: %M% RELEASE: %R%.%L% CREATED: %G% %U%"
source "/mdisw/cfl/eof/src/runstr1.src"
descr "runstr1 -  Sets up structure program environment."

display "Executing procedure  runstr."

tcblock mbdpmod 1              ## Set 5k mode

perf mag30obs

# Set up Flat Field in page 10. 
# Flat field must in in LIST (8-Byte EDAC) memory. It is loaded at 0x20000
# to allow for intermediate headers to be saved at 0x00000.
tcblock mbipldin 0x118 0x5000 144                           ## Purge Page 10
#tcblock mbipldin 0x16c 0x0000 0x5002 0x0000 0x0010 0x0001  ##Pseudo Flat Field 
wait time 5
tcblock mbipldin 0x16c 0x0000 0x5800 0x0000 0x0010 0x0020   ##LF #1
wait time 5
tcblock mbipldin 0x16c 0x0000 0x6000 0x0000 0x0010 0x0050   ##MP #1
wait time 5
tcblock mbipldin 0x16c 0x0000 0x6800 0x0000 0x0010 0x0068   ##MP #2
wait time 5
tcblock mbipldin 0x16c 0x0000 0x7000 0x0000 0x0010 0x0070   ##FB #1
wait time 5
tcblock mbipldin 0x16c 0x0000 0x7800 0x0000 0x0010 0x0088   ##FB #2
wait time 5
#
tcblock mbipldin 0x140 26  0      ## Set SAVEMODE enable flag
tcblock mbipldin 0x140 28  1      ## Clear SAVEMODE execute flag
tcblock mbipldin 0x1b2 69  2 0 0
tcblock mbipldin 0x1b2 560 2 0 0  ## R550-R551 set DPC len = 1
wait time 5

tcblock mbipldin 0x140 1130  1    ## Set initialization flag for REGDP
tcblock mbipldin 0x140 1134  1420
tcblock mbipldin 0x140 1135  0
tcblock mbipldin 0x140 1138  1467
tcblock mbipldin 0x140 1139  0
tcblock mbipldin 0x11C            ## Initialize subroutine stack

# Set IP vectors 
tcblock  mbipldin 0x154
 
tcblock mbipcmd 0x91 0 0x1F00     ## Heritage Load Replacement Programs
tcblock mbipcmd 0x91 1 0x0100     ## Prime60 / Prime30
tcblock mbipcmd 0x91 2 0x0100
tcblock mbipcmd 0x91 3 0x0100
tcblock mbipcmd 0x91 4 0x0132
tcblock mbipcmd 0x91 5 0x0900     ## ALT30
tcblock mbipcmd 0x91 6 0x0E83
tcblock mbipcmd 0x91 7 0x0B00     ## HDR
tcblock mbipcmd 0x91 8 0x0B04     ## TAIL

# Patch mkstr code to set the length of the data product cfffff98 to 1.
tcblock mbipcmd 0x91 0x0434 1
tcblock mbipcmd 0x91 0x0459 1

# DEP Sequence Buffer Patches

tcblock mbdpml  0x1000 0x3EF2 0x0101   ## Patch STR60 IP Q Ptr
tcblock mbdpml  0x1000 0x3D2A 0x0404   ## Patch STR30 IP Q Ptr
tcblock mbdpml  0x1000 0x3CA6 0x0505   ## Patch ALT30 IP Q Ptr
tcblock mbdpml  0x1000 0x3C5E 0x0707   ## Patch HDR15 IP Q Ptr
tcblock mbdpml  0x1000 0x3C54 0x0005   ## Patch HDR15 IP Q Ptr

tcblock mbdpml  0x1000 0x3CB0 0x4343 0x4343

wait time 3

tcblock mbipldin 0x136

tcblock mbdpmod 3              ## Set 5k mode
wait time 3

tcblock mbipldin 0x134         ## Enable interrupts
wait time 3

tcblock mbipldin 0x1b2 96 2 0x0000 0x2800   ## Pixel Alignment of RVel and LVel
tcblock mbipldin 0x1b2 98 2 0x0000 0x0000   ## Fractional pixel alignment

tcblock mbipldin 0x140 1212 0x0102
# tcblock mbipldin 0x140 1213 0x0134

# tcblock mbipldin 0x140 1268 0x0102  ## IPRL_STR_STRT60 = &INIT60
tcblock mbipldin 0x140 1267 0x0134  ## IPRL_STR_STRT60 = &INIT30 
tcblock mbipldin 0x140 3016 0x0902  ## Set flag to do mag init
tcblock mbipldin 0x140 1348      0  ## Clear ALT repts counter
tcblock mbipldin 0x140 1349      3  ## Set ALT Repeats value
tcblock mbipldin 0x140 1377      0  ## Set 5K Magnetogram size to zero 
tcblock mbipldin 0x1b2 1378 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
tcblock mbipldin 0x140 1448      0  ## Mag DL not active
tcblock mbipldin 0x140 1449      0  ## Campaign not active 

tcblock mbsqreg  3     1       ## Set VC Flag
tcblock mbsqreg  5     1       ## Set MagHR Flag
tcblock mbsqreg 65     0       ## Disable ALT
tcblock mbsqreg 66     0       ## Disbale Campaign Mode

wait time 3

# Initialize Error Log
tcblock mbipldin 0x1b2 464 3  0x0000  0x2011 4800
tcblock mbipldin 0x01EC  464

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

display "Finished procedure runstr"
return
