# File: mag_dl_setup_v09.src
#
program "%Z% MODULE: %M% RELEASE: %R%.%L% CREATED: %G% %U%"
source "/mdisw/cfl/flight/src/mag_dl_setup_v09.src"
descr "Loads IP queue instructions"
#=======================================================
#
#
#; MAG_DL_SETUP
#;
#; Routine to downlink stored magnetograms. This routine should be
#; by the VC2 campaign observation. The VC2 campaign observation g
#; a High-Resolution magnetogram.
#;
#; The downlink is started on the first frame of the VC2 OBS. At t
#; the velocity created by the Prime30 program is available in Pag
#; continuum in Page 6.
#;
#; The Call Number is incremented by the routine. It is reset by t
#; program.  
#;
#;
#; Call Number        Page 1                   Page 2
#;  (Minute)
#;     1           Stored Mag 1              Velocity-CB
#;                  (Velocity)
#;
#;     2           Stored Mag 2              Ic-CB
#;                  (Velocity)
#;
#;     3           Stored Mag 3
#;                 (No Mag Flag)
#;
#;     4           Stored Mag 4
#;                 (No Mag Flag)
#;
#;     5           Stored Mag 5
#;                 (No Mag Flag)
#;
#;     6            No Mag Flag 
#;
#;     7            No Mag Flag 
#;
#;     .                .
#;
#;......................
#;
#;  Calling Sequence:
#;      CALLQUE    &MAG_DL_SET
#;
#;      The call updates the following registers:
#;          $IPRL_MAG_DLPAGES      1st Page Number 
#;
#;          $IPRL_MAG_DLPAGES+1    2nd Page Number  
#;
#;          $IPRL_MAG_PGLEN1    LS word of length of Page 1
#;          $IPRL_MAG_PGLEN1+1  MS word of length of page 1
#;
#;          $IPRL_MAG_PGLEN2    LS word of length of Page 2 (= 0 i
#;          $IPRL_MAG_PGLEN2+1  MS word of length of Page 2 (= 0 i
#;
#; Notes:
#;  1. $IPRL_MAG_PAGE   = 0xA000 to indicate "No Mag Page" Conditi
#;  2. $IPRL_MAG_PAGE+1 = 0xFFFF if only 1 page is to be downlinke
#;  3. $IPRL_MAG_DLC is incremented by 1 on each call
#;  4. The LS Word for $IPRL_MAG_PAGE+1 is 0 for min1 and min2.
#;
#; HISTORY:
#;	Written Nov-95 by D.Mathur
#;	16-Nov-95 (MDM) - Modified how the $IPRL_MAG_PGLEN1 registers
#;			  are set for stored magnetogram.  Copy the value
#;			  from R71-72 instead of from $IPRL_MAG_DLPLEN
#;			  (where it wasn't being set ever).
#;        7-Feb-96 (DPM) - Changed downlink length for 800 minute 
#;                         buffers.
#;	14-May-96 (MDM) - Changed source page for circular buffer from
#;			  6001 to 7008 (LOI-V) and
#;			  6005 to 7006 (LOI-C)
#;......................
#;
#QSR_MAG_STORD_PG::
#;
#     ADDREGD   $IPRL_MAG_DLC        1
tcblock mbipmacl 0x15C9    0x01BC 0x05BB 0x0001 
#     BRANCHEQ $IPRL_MAG_DLC 1 &MIN_1
tcblock mbipmacl 0x15CC    0x01AE 0x05BB 0x0001 0x15D6 
#     BRANCHEQ $IPRL_MAG_DLC 2 &MIN_2
tcblock mbipmacl 0x15D0    0x01AE 0x05BB 0x0002 0x15E4 
#     GOTO &MIN_3
tcblock mbipmacl 0x15D4    0x0156 0x15F2 
#;
#;......................
#;
#MIN_1:
#     SETREG    $IPRL_MAG_DLPAGES+1     0x7008     ; $VEL_CB_PAGE
tcblock mbipmacl 0x15D6    0x0140 0x1251 0x7008 
#     SETREGS   $IPRL_MAG_PGLEN2     2       0x23F00L   ; $VEL_CB_
tcblock mbipmacl 0x15D9    0x01B2 0x1254 0x0002 0x3F00 \
                                0x0002 
#     SETREG    $IPRL_MAG_P1DP       &DL_VEL
tcblock mbipmacl 0x15DE    0x0140 0x1256 0x1612 
#     CALLQUE   &SETP1
tcblock mbipmacl 0x15E1    0x01F8 0x1600 
#     RTNQUE
tcblock mbipmacl 0x15E3    0x01FA 
#;
#MIN_2:
#     SETREG    $IPRL_MAG_DLPAGES+1     0x7006     ; $IC_CB_PAGE
tcblock mbipmacl 0x15E4    0x0140 0x1251 0x7006 
#     SETREGS   $IPRL_MAG_PGLEN2     2       0x23F00L   ; $LEN_IC_
tcblock mbipmacl 0x15E7    0x01B2 0x1254 0x0002 0x3F00 \
                                0x0002 
#     SETREG    $IPRL_MAG_P1DP       &DL_VEL
tcblock mbipmacl 0x15EC    0x0140 0x1256 0x1612 
#     CALLQUE   &SETP1
tcblock mbipmacl 0x15EF    0x01F8 0x1600 
#     RTNQUE
tcblock mbipmacl 0x15F1    0x01FA 
#;
#MIN_3:
#     SETREG    $IPRL_MAG_P1DP       &DL_HRMAG
tcblock mbipmacl 0x15F2    0x0140 0x1256 0x161C 
#     CALLQUE   &SETP1
tcblock mbipmacl 0x15F5    0x01F8 0x1600 
#;
#     SETREG    $IPRL_MAG_DLPAGES+1     0xFFFF
tcblock mbipmacl 0x15F7    0x0140 0x1251 0xFFFF 
#     SETREGS   $IPRL_MAG_PGLEN2     2       0L
tcblock mbipmacl 0x15FA    0x01B2 0x1254 0x0002 0x0000 \
                                0x0000 
#     RTNQUE
tcblock mbipmacl 0x15FF    0x01FA 
#;
#;......................
#;
#SETP1:
#;
#     CALLQUE   &QSR_MAG_CKMAG
tcblock mbipmacl 0x1600    0x01F8 0x1625 
#     BRANCHNE  $IPRL_MAG_DLPAGE     0xFFFF  &DL_STOR_MAG
tcblock mbipmacl 0x1602    0x01B0 0x1258 0xFFFF 0x1608 
#;
#     GOTOREG   $IPRL_MAG_P1DP
tcblock mbipmacl 0x1606    0x0158 0x1256 
#;
#DL_STOR_MAG:
#     COPYREG   $IPRL_MAG_DLPAGE     $IPRL_MAG_DLPAGES
tcblock mbipmacl 0x1608    0x0142 0x1258 0x1250 
#;     COPYREG   $IPRL_MAG_DLPLEN     $IPRL_MAG_PGLEN1
#;     COPYREG   $IPRL_MAG_DLPLEN+1   $IPRL_MAG_PGLEN1+1
#     COPYREG   R71                  $IPRL_MAG_PGLEN1
tcblock mbipmacl 0x160B    0x0142 0x0047 0x1252 
#     COPYREG   R72                  $IPRL_MAG_PGLEN1+1
tcblock mbipmacl 0x160E    0x0142 0x0048 0x1253 
#     RTNQUE
tcblock mbipmacl 0x1611    0x01FA 
#;     
#DL_VEL:
#     SETREG    $IPRL_MAG_DLPAGES 0x2800     ; $VEL_PAGE
tcblock mbipmacl 0x1612    0x0140 0x1250 0x2800 
#     COPYREG   R71                  $IPRL_MAG_PGLEN1
tcblock mbipmacl 0x1615    0x0142 0x0047 0x1252 
#     COPYREG   R72                  $IPRL_MAG_PGLEN1+1
tcblock mbipmacl 0x1618    0x0142 0x0048 0x1253 
#     RTNQUE
tcblock mbipmacl 0x161B    0x01FA 
#;
#DL_HRMAG:
#     SETREG    $IPRL_MAG_DLPAGES       0xA000
tcblock mbipmacl 0x161C    0x0140 0x1250 0xA000 
#     SETREGS   $IPRL_MAG_PGLEN1     2       0L 
tcblock mbipmacl 0x161F    0x01B2 0x1252 0x0002 0x0000 \
                                0x0000 
#     RTNQUE
tcblock mbipmacl 0x1624    0x01FA 
#;......................
#;
#; Subroutine to downlink stored magnetograms
#;
#; The MAG30 routine sets a register for each page which contains 
#; completed magnetogram. This routine examines each register in t
#; and copies the first magnetogram found to the downlink page. 
#;
#;
#QSR_MAG_CKMAG::
#;
#    SETREG    $IPRL_MAG_DLPAGE  0xFFFF
tcblock mbipmacl 0x1625    0x0140 0x1258 0xFFFF 
#;
#CKMAG:
#    BRANCHIF  $IPRL_MAG_DONE1   &CKMAG2
tcblock mbipmacl 0x1628    0x015A 0x058C 0x1632 
#    COPYREG   $IPRL_MAG_DONE1   $IPRL_MAG_DLPAGE      
tcblock mbipmacl 0x162B    0x0142 0x058C 0x1258 
#    SETREG    $IPRL_MAG_DONE1   0
tcblock mbipmacl 0x162E    0x0140 0x058C 0x0000 
#    RTNQUE    
tcblock mbipmacl 0x1631    0x01FA 
#;
#CKMAG2:    
#    BRANCHIF  $IPRL_MAG_DONE1+1 &CKMAG3
tcblock mbipmacl 0x1632    0x015A 0x058D 0x163C 
#    COPYREG   $IPRL_MAG_DONE1+1 $IPRL_MAG_DLPAGE      
tcblock mbipmacl 0x1635    0x0142 0x058D 0x1258 
#    SETREG    $IPRL_MAG_DONE1+1 0
tcblock mbipmacl 0x1638    0x0140 0x058D 0x0000 
#    RTNQUE      
tcblock mbipmacl 0x163B    0x01FA 
#;
#CKMAG3:    
#    BRANCHIF  $IPRL_MAG_DONE1+2 &CKMAG4
tcblock mbipmacl 0x163C    0x015A 0x058E 0x1646 
#    COPYREG   $IPRL_MAG_DONE1+2 $IPRL_MAG_DLPAGE      
tcblock mbipmacl 0x163F    0x0142 0x058E 0x1258 
#    SETREG    $IPRL_MAG_DONE1+2 0
tcblock mbipmacl 0x1642    0x0140 0x058E 0x0000 
#    RTNQUE      
tcblock mbipmacl 0x1645    0x01FA 
#;
#CKMAG4:    
#    BRANCHIF  $IPRL_MAG_DONE1+3 &CKMAG5
tcblock mbipmacl 0x1646    0x015A 0x058F 0x1650 
#    COPYREG   $IPRL_MAG_DONE1+3 $IPRL_MAG_DLPAGE      
tcblock mbipmacl 0x1649    0x0142 0x058F 0x1258 
#    SETREG    $IPRL_MAG_DONE1+3 0
tcblock mbipmacl 0x164C    0x0140 0x058F 0x0000 
#    RTNQUE      
tcblock mbipmacl 0x164F    0x01FA 
#;
#CKMAG5:    
#    BRANCHIF  $IPRL_MAG_DONE1+4 &MAG_DL_END
tcblock mbipmacl 0x1650    0x015A 0x0590 0x165A 
#    COPYREG   $IPRL_MAG_DONE1+4 $IPRL_MAG_DLPAGE      
tcblock mbipmacl 0x1653    0x0142 0x0590 0x1258 
#    SETREG    $IPRL_MAG_DONE1+4 0
tcblock mbipmacl 0x1656    0x0140 0x0590 0x0000 
#    RTNQUE      
tcblock mbipmacl 0x1659    0x01FA 
#;
#MAG_DL_END:
#    RTNQUE
tcblock mbipmacl 0x165A    0x01FA 
#=======================================================
#
return
#
#=======================================================
