# File: dlimg.src
#
program "%Z% MODULE: %M% RELEASE: %R%.%L% CREATED: %G% %U%"
#
# DSBQUE                ; Disable Queue
tcblock mbipldin 0x0154 
#
#=======================================================
#
#
# ; Call an IP program to downlink 1 image
# ;
#     BRANCHEQ  R0032  3  &LBIC3
tcblock mbipcmd 0x0091 0x1F00   0x01AE 0x0020 0x0003 0x1F0D 
#     BRANCHEQ  R0032  4  &LBIC4
tcblock mbipcmd 0x0091 0x1F04   0x01AE 0x0020 0x0004 0x1F2C 
#     BRANCHEQ  R0032  5  &LBIC5
tcblock mbipcmd 0x0091 0x1F08   0x01AE 0x0020 0x0005 0x1F4B 
#     END
tcblock mbipcmd 0x0091 0x1F0C   0x01FC 
# ;
# ;=================================================
# ;  lbic 3  (extract standard 1024x1024 filtergram
# ;           from memory 0)
# ;=================================================
# ; Address of 1st pixel to be extracted = 252 + 1040 + 8 = 1300
# ;                       
# LBIC3:
#     SETREGS  R0168  2  0  0
tcblock mbipcmd 0x0091 0x1F0D   0x01B2 0x00A8 0x0002 0x0000 \
                                0x0000 
#     SETREGS  R0176  8 0:0x00514 7:0x00000 1024 1024 1040 R0168
tcblock mbipcmd 0x0091 0x1F12   0x01B2 0x00B0 0x0008 0x0514 \
                                0x0000 0x0000 0x3800 0x0400 \
                                0x0400 0x0410 0x00A8 
# ;
#     SETREGS   R3576  2  0xFFFF  0xFF14
tcblock mbipcmd 0x0091 0x1F1D   0x01B2 0x0DF8 0x0002 0xFFFF \
                                0xFF14 
#     EXTRACT   R0176
tcblock mbipcmd 0x0091 0x1F22   0x017A 0x00B0 
#     SETREGS   R3570  2  0x100000L
tcblock mbipcmd 0x0091 0x1F24   0x01B2 0x0DF2 0x0002 0x0000 \
                                0x0010 
#     GOTO      &DOHR
tcblock mbipcmd 0x0091 0x1F29   0x0156 0x1FA1 
#     END
tcblock mbipcmd 0x0091 0x1F2B   0x01FC 
# ;
# ;=================================================
# ;  lbic 4  (extract central 256x256 area from 
# ;           memory 0)
# ;=================================================
# ; Address of 1st pixel to be extracted 
# ;        = Header(252) + Eng_line(1040) + 
# ;          skip 384 rows (384 X 1040)   +
# ;          BLS(8) + skip 384 columns (384)
# ;        = 401044  (0x61E94)
# ;
# LBIC4:
#     SETREGS  R0168  2  0  0
tcblock mbipcmd 0x0091 0x1F2C   0x01B2 0x00A8 0x0002 0x0000 \
                                0x0000 
#     SETREGS  R0176  8 0:0x61E94 7:0x00000 256 256 1040 R0168
tcblock mbipcmd 0x0091 0x1F31   0x01B2 0x00B0 0x0008 0x1E94 \
                                0x0006 0x0000 0x3800 0x0100 \
                                0x0100 0x0410 0x00A8 
# ;
#     SETREGS   R3576  2  0xFFFF  0xFF13
tcblock mbipcmd 0x0091 0x1F3C   0x01B2 0x0DF8 0x0002 0xFFFF \
                                0xFF13 
#     EXTRACT   R0176
tcblock mbipcmd 0x0091 0x1F41   0x017A 0x00B0 
#     SETREGS   R3570  2  0x10000L
tcblock mbipcmd 0x0091 0x1F43   0x01B2 0x0DF2 0x0002 0x0000 \
                                0x0001 
#     GOTO      &DOHR
tcblock mbipcmd 0x0091 0x1F48   0x0156 0x1FA1 
#     END
tcblock mbipcmd 0x0091 0x1F4A   0x01FC 
# ;
# ;
# ;=================================================
# ;  lbic 5  (4x4 Sum of a single image in memory 0
# ;=================================================
# ; IP Program to perform 4x4 summing
# ; Memory Page Usage:
# ;    0  -  Raw Camera Image
# ;    4  -  Extracted 1024x1024 image
# ;    5  -  1024x256 rowbinned image
# ;    6  -  256 x 256 lrbinned image
# ;    8  -  Downlink page
# ;
# ;
# LBIC5:
#      SETREGS   R0168   2   0   0
tcblock mbipcmd 0x0091 0x1F4B   0x01B2 0x00A8 0x0002 0x0000 \
                                0x0000 
# ;
# ;    EXTRACT R816
# ;       Source Address         0:0x00514
# ;       Destination Address    4:0x00000
# ;       X-Length                    1024
# ;       Y-Length                    1024
# ;       Row Length                  1040
# ;       Global Offset Register      R168
# ;
#      SETREGS  R816  8  0:0x00514 4:0x00000 1024 1024 1040 R0168
tcblock mbipcmd 0x0091 0x1F50   0x01B2 0x0330 0x0008 0x0514 \
                                0x0000 0x0000 0x2000 0x0400 \
                                0x0400 0x0410 0x00A8 
#      EXTRACT  R816
tcblock mbipcmd 0x0091 0x1F5B   0x017A 0x0330 
# ;
# ;
# ;    ROWBIN  R800
# ;       Source Address         4:0x00000
# ;       Destination Address    5:0x00000
# ;       X-Length                    1024
# ;       Y-Length                       4
# ;       Row Length                  1024
# ;       Repeat Count                 256
# ;       Shift Factor                  16
# ;       Scale Factor                   1
# ;       Global Offset Register      R168
# ;
#      SETREGS  R800  11  4:0x00000 5:0x00000 1024 4 1024 256 16 1 R0168
tcblock mbipcmd 0x0091 0x1F5D   0x01B2 0x0320 0x000B 0x0000 \
                                0x2000 0x0000 0x2800 0x0400 \
                                0x0004 0x0400 0x0100 0x0010 \
                                0x0001 0x00A8 
#      ROWBIN   R800
tcblock mbipcmd 0x0091 0x1F6B   0x01D4 0x0320 
# ;
# ;....................................................
# ; LRBIN LIST
# ;      Start Address Low        0
# ;      Start Address High       0
# ;      X Length                 4
# ;      Repeat Count          2048
# ;      Shift Count             14
# ;      Scale Factor             1
# ;
# ;      Start Address Low     8192 
# ;      Start Address High       0
# ;      X Length                 4
# ;      Repeat Count          2048
# ;      Shift Count             14
# ;      Scale Factor             1
# ;
# ;      Start Address Low    16384
# ;      Start Address High       0
# ;      X Length                 4
# ;      Repeat Count          2048
# ;      Shift Count             14
# ;      Scale Factor             1
# ;
# ;      Start Address Low    24576
# ;      Start Address High       0
# ;      X Length                 4
# ;      Repeat Count          2048
# ;      Shift Count             14
# ;      Scale Factor             1
# ;....................................................
# ;
# ; Linear Rebin
# ;
# ;    LRBIN  R0176
# ;       Source Page           5
# ;       Destination Address   6:0x00000
# ;       List Pointer          0
# ;       List Count            4
# ;       List Address         17:0x00000
# ;       Global Offset Register       R2560
# ;
# ;     SETREGS   R0168   2   0  0
#      SETREGS   R0170   2   0x8000   0
tcblock mbipcmd 0x0091 0x1F6D   0x01B2 0x00AA 0x0002 0x8000 \
                                0x0000 
#      SETREGS   R0176   3   0x2800   6:0x00000  
tcblock mbipcmd 0x0091 0x1F72   0x01B2 0x00B0 0x0003 0x2800 \
                                0x0000 0x3000 
# ;
# RPT:
#      SETREGS   R0179   5   0   4  17:0xFFE00  R0168
tcblock mbipcmd 0x0091 0x1F78   0x01B2 0x00B3 0x0005 0x0000 \
                                0x0004 0xFE00 0x880F 0x00A8 
#      LRBIN     R0176
tcblock mbipcmd 0x0091 0x1F80   0x01D0 0x00B0 
#      ADDADR    R0168  R0170  R0172            ; New Offset
tcblock mbipcmd 0x0091 0x1F82   0x0148 0x00A8 0x00AA 0x00AC 
#      COPYREG   R0172  R0168
tcblock mbipcmd 0x0091 0x1F86   0x0142 0x00AC 0x00A8 
#      COPYREG   R0173  R0169
tcblock mbipcmd 0x0091 0x1F89   0x0142 0x00AD 0x00A9 
#      BRANCHNE  R0178  0x3001   &RPT
tcblock mbipcmd 0x0091 0x1F8C   0x01B0 0x00B2 0x3001 0x1F78 
# ;
#      SETREGS   R3576  2  0xFFFF  0xFF12
tcblock mbipcmd 0x0091 0x1F90   0x01B2 0x0DF8 0x0002 0xFFFF \
                                0xFF12 
#      MOVBLK    6:0x00000  7:0x00000  0x10000L
tcblock mbipcmd 0x0091 0x1F95   0x0164 0x0000 0x3000 0x0000 \
                                0x3800 0x0000 0x0001 
#      SETREGS   R3570  2  0x10000L
tcblock mbipcmd 0x0091 0x1F9C   0x01B2 0x0DF2 0x0002 0x0000 \
                                0x0001 
# ;
# ;....................................................
# ;
# DOHR:
# ;
#     BRANCHIF  R3077  &DONE
tcblock mbipcmd 0x0091 0x1FA1   0x015A 0x0C05 0x1FDD 
# ;
# ;   Replace AVGTEMPS with 4 Noops to retain same load size
# ;   and permit patching to reenable AVGTEMPS
# ;
# ;    AVGTEMPS  0:0x00134 12
#     NOOP
tcblock mbipcmd 0x0091 0x1FA4   0x01DE 
#     NOOP
tcblock mbipcmd 0x0091 0x1FA5   0x01DE 
#     NOOP
tcblock mbipcmd 0x0091 0x1FA6   0x01DE 
#     NOOP
tcblock mbipcmd 0x0091 0x1FA7   0x01DE 
#     SETREGS   R3566  2  7:0x00000  
tcblock mbipcmd 0x0091 0x1FA8   0x01B2 0x0DEE 0x0002 0x0000 \
                                0x3800 
# ;
#     BRANCHEQ  R33    0   &TLM0
tcblock mbipcmd 0x0091 0x1FAD   0x01AE 0x0021 0x0000 0x1FC7 
# ;
# TLM1:
#     SETREGS   R3568  2  12:0x00226
tcblock mbipcmd 0x0091 0x1FB1   0x01B2 0x0DF0 0x0002 0x0226 \
                                0x6000 
#     _MOVBLKI  R3566
tcblock mbipcmd 0x0091 0x1FB6   0x8166 0x0DEE 
# ;
#     SETREGS   R3572  3  0:0x00001  0x6000
tcblock mbipcmd 0x0091 0x1FB8   0x01B2 0x0DF4 0x0003 0x0001 \
                                0x0000 0x6000 
#     COPYREG   R61    R3575
tcblock mbipcmd 0x0091 0x1FBE   0x0142 0x003D 0x0DF7 
#     HRDINIT   R3572
tcblock mbipcmd 0x0091 0x1FC1   0x019C 0x0DF4 
#     START1HR   3   0x6000 R3570
tcblock mbipcmd 0x0091 0x1FC3   0x0174 0x0003 0x6000 0x0DF2 
# ;
# TLM0:
#     SETREGS   R3568  2  8:0x00226
tcblock mbipcmd 0x0091 0x1FC7   0x01B2 0x0DF0 0x0002 0x0226 \
                                0x4000 
#     _MOVBLKI  R3566
tcblock mbipcmd 0x0091 0x1FCC   0x8166 0x0DEE 
# ;
#     SETREGS   R3572  3  0:0x00001  0x4000
tcblock mbipcmd 0x0091 0x1FCE   0x01B2 0x0DF4 0x0003 0x0001 \
                                0x0000 0x4000 
#     COPYREG   R61    R3575
tcblock mbipcmd 0x0091 0x1FD4   0x0142 0x003D 0x0DF7 
#     HRDINIT   R3572
tcblock mbipcmd 0x0091 0x1FD7   0x019C 0x0DF4 
#     START1HR   3   0x4000 R3570
tcblock mbipcmd 0x0091 0x1FD9   0x0174 0x0003 0x4000 0x0DF2 
# ;
# DONE:
#     END
tcblock mbipcmd 0x0091 0x1FDD   0x01FC 
# 
# ;=============================================================
#=======================================================
#
# ENBQUE                ; Enable Queue
tcblock mbipldin 0x0136
#
#
return
#
#=======================================================
