# File: fltgram_v04.src
#
program "%Z% MODULE: %M% RELEASE: %R%.%L% CREATED: %G% %U%"
source "fltgram_v04.ips"
descr "Loads IP queue instructions"
#
# DSBQUE                ; Disable Queue
tcblock mbipldin 0x0154 
#
#=======================================================
#
#
#; FILE:    fltgram.ips
#; PURPOSE: To take 9-10 filtergram images over 30 seconds and to 
#;	   60 seconds.  The formattting options are:
#;		1) 4x4 rebin (to 256x256 downlinked image)
#;		2) 256x256 extract
#; METHOD:
#;	Input:
#;		$IPRL_10FLTGRAM_TYPE is set to 1 or 2
#;	Pages:
#;		0 	== all CCD frames are written there
#;		1 	== the 1024x1024 extract and filterfram header 
#;		11 & 15	== the stored images (waiting for downlink)
#;		18	== (OPTIONALLY) the intermediate 4x4 binning product
#; HISTORY: Written 5-Sep-95 by M.Morrison
#;	16-Oct-95 (MDM) - Changed callback address label
#;			- Corrected numerous errors (it hadn't been debugged yet)
#;	16-Oct-95 (MDM) - Shifted downlink by 2 frames to avoid conflic
#;			  the ALT30 downlink from the previous minute
#;			  (during transitions from ALT back to CAM)
#;       19-Oct-95 (MDM) - Changed how FLTGRAM_PARAM is used
#;	20-Oct-95 (MDM) - Replaced patch which was running 128x128 extr
#;			  of the 256x256
#;	24-Oct-95 (MDM) - Modified to do the optional downlink BEFORE m
#;			  storing the data product for that frame
#;	25-Oct-95 (MDM) - Corrected 24-Oct modification
#;	17-Nov-95 (MDM) - Modified to use 0x0500 offsets instead of 0x0
#;	17-Nov-95 (MDM) - Modified to use 0x0226 offsets instead of 0x0
#;	 5-Dec-95 (MDM) - Changed IPCB_10FLTGRAM to be QCB_10FLTGRAM
#;       17-Jan-96 (MDM) - Modified to use page 17 for storing, no
#
#
#QPROG_FLTGRAM_4X4BIN::
#    SETREG $IPRL_10FLTGRAM_TYPE 1
tcblock mbipcmd 0x0091 0x14B2   0x0140 0x124F 0x0001 
#    GOTO &QPROG_FLTGRAM
tcblock mbipcmd 0x0091 0x14B5   0x0156 0x14BC 
#
#QPROG_FLTGRAM_EXT256::
#    SETREG $IPRL_10FLTGRAM_TYPE 2
tcblock mbipcmd 0x0091 0x14B7   0x0140 0x124F 0x0002 
#    GOTO &QPROG_FLTGRAM
tcblock mbipcmd 0x0091 0x14BA   0x0156 0x14BC 
#
#QPROG_FLTGRAM:
#
#;---------------- Optional Downlink Portion
#OPTIONAL_DL:
#    BRANCHEQ R3072   4 &DL_FRM04
tcblock mbipcmd 0x0091 0x14BC   0x01AE 0x0C00 0x0004 0x14C6 
#    BRANCHEQ R3072   8 &DL_FRM08
tcblock mbipcmd 0x0091 0x14C0   0x01AE 0x0C00 0x0008 0x14CF 
#    GOTO &INCOMING_IMG
tcblock mbipcmd 0x0091 0x14C4   0x0156 0x14D8 
#
#DL_FRM04:
#    SETREGS $IPRL_DL_PARAM 2 0x7800 0x7804			;downlink the images
tcblock mbipcmd 0x0091 0x14C6   0x01B2 0x11D0 0x0002 0x7800 \
                                0x7804 
#    CALLQUE $QSR_DL_2PAGE 
tcblock mbipcmd 0x0091 0x14CB   0x01F8 0x10DB 
#    GOTO &INCOMING_IMG
tcblock mbipcmd 0x0091 0x14CD   0x0156 0x14D8 
#
#DL_FRM08:
#    SETREGS $IPRL_DL_PARAM 2 0x7808 0x780C			;downlink the images
tcblock mbipcmd 0x0091 0x14CF   0x01B2 0x11D0 0x0002 0x7808 \
                                0x780C 
#    CALLQUE $QSR_DL_2PAGE 
tcblock mbipcmd 0x0091 0x14D4   0x01F8 0x10DB 
#    GOTO &INCOMING_IMG
tcblock mbipcmd 0x0091 0x14D6   0x0156 0x14D8 
#
#;---------------- The work for this page
#
#INCOMING_IMG:
#    BRANCHEQ R3072   1 &FRM01
tcblock mbipcmd 0x0091 0x14D8   0x01AE 0x0C00 0x0001 0x1500 
#    BRANCHEQ R3072   2 &FRM02
tcblock mbipcmd 0x0091 0x14DC   0x01AE 0x0C00 0x0002 0x1506 
#    BRANCHEQ R3072   3 &FRM03
tcblock mbipcmd 0x0091 0x14E0   0x01AE 0x0C00 0x0003 0x150C 
#    BRANCHEQ R3072   4 &FRM04
tcblock mbipcmd 0x0091 0x14E4   0x01AE 0x0C00 0x0004 0x1512 
#    BRANCHEQ R3072   5 &FRM05
tcblock mbipcmd 0x0091 0x14E8   0x01AE 0x0C00 0x0005 0x1518 
#    BRANCHEQ R3072   6 &FRM06
tcblock mbipcmd 0x0091 0x14EC   0x01AE 0x0C00 0x0006 0x151E 
#    BRANCHEQ R3072   7 &FRM07
tcblock mbipcmd 0x0091 0x14F0   0x01AE 0x0C00 0x0007 0x1524 
#    BRANCHEQ R3072   8 &FRM08
tcblock mbipcmd 0x0091 0x14F4   0x01AE 0x0C00 0x0008 0x152A 
#    BRANCHEQ R3072   9 &FRM09
tcblock mbipcmd 0x0091 0x14F8   0x01AE 0x0C00 0x0009 0x1500 
#    BRANCHEQ R3072  10 &FRM10
tcblock mbipcmd 0x0091 0x14FC   0x01AE 0x0C00 0x000A 0x1506 
#
#FRM01:
#FRM09:
#    COPYRD2D $IPRP_HDECODE_PAGE15  $IPRL_10FLTGRAM_ADDR 3	;put it
tcblock mbipcmd 0x0091 0x1500   0x0144 0x10C8 0x124C 0x0003 
#    GOTO &DO_THE_WORK
tcblock mbipcmd 0x0091 0x1504   0x0156 0x1530 
#FRM02:
#FRM10:
#    COPYRD2D $IPRP_HDECODE_PAGE15B $IPRL_10FLTGRAM_ADDR 3	;put it
tcblock mbipcmd 0x0091 0x1506   0x0144 0x10D2 0x124C 0x0003 
#    GOTO &DO_THE_WORK
tcblock mbipcmd 0x0091 0x150A   0x0156 0x1530 
#FRM03:
#    COPYRD2D $IPRP_HDECODE_PAGE15C $IPRL_10FLTGRAM_ADDR 3	;put it
tcblock mbipcmd 0x0091 0x150C   0x0144 0x10DC 0x124C 0x0003 
#    GOTO &DO_THE_WORK
tcblock mbipcmd 0x0091 0x1510   0x0156 0x1530 
#FRM04:
#    COPYRD2D $IPRP_HDECODE_PAGE15D $IPRL_10FLTGRAM_ADDR 3	;put it
tcblock mbipcmd 0x0091 0x1512   0x0144 0x10E6 0x124C 0x0003 
#    GOTO &DO_THE_WORK
tcblock mbipcmd 0x0091 0x1516   0x0156 0x1530 
#FRM05:
#    COPYRD2D $IPRP_HDECODE_PAGE11  $IPRL_10FLTGRAM_ADDR 3	;put it
tcblock mbipcmd 0x0091 0x1518   0x0144 0x106E 0x124C 0x0003 
#    GOTO &DO_THE_WORK
tcblock mbipcmd 0x0091 0x151C   0x0156 0x1530 
#FRM06:
#    COPYRD2D $IPRP_HDECODE_PAGE11B $IPRL_10FLTGRAM_ADDR 3	;put it
tcblock mbipcmd 0x0091 0x151E   0x0144 0x1078 0x124C 0x0003 
#    GOTO &DO_THE_WORK
tcblock mbipcmd 0x0091 0x1522   0x0156 0x1530 
#FRM07:
#    COPYRD2D $IPRP_HDECODE_PAGE11C $IPRL_10FLTGRAM_ADDR 3	;put it
tcblock mbipcmd 0x0091 0x1524   0x0144 0x1082 0x124C 0x0003 
#    GOTO &DO_THE_WORK
tcblock mbipcmd 0x0091 0x1528   0x0156 0x1530 
#FRM08:
#    COPYRD2D $IPRP_HDECODE_PAGE11D $IPRL_10FLTGRAM_ADDR 3	;put it
tcblock mbipcmd 0x0091 0x152A   0x0144 0x108C 0x124C 0x0003 
#    GOTO &DO_THE_WORK
tcblock mbipcmd 0x0091 0x152E   0x0156 0x1530 
#
#DO_THE_WORK:
#    SETREG $IPRL_CB_ADDR &QCB_10FLTGRAM				;set the callback regi
tcblock mbipcmd 0x0091 0x1530   0x0140 0x0C20 0x1568 
#
#    ;---- Make the filtergram (1024x1024)
#    SETREGS  $IPRL_FLTGRAM_PARAM 4 0:0x0000 17:0x0726		;set sourc
tcblock mbipcmd 0x0091 0x1533   0x01B2 0x1238 0x0004 0x0000 \
                                0x0000 0x0726 0x8800 
#    COPYRD2D $IPRL_FLTGRAM_GEN $IPRL_FLTGRAM_PARAM+8 3		;last thr
tcblock mbipcmd 0x0091 0x153A   0x0144 0x1243 0x1240 0x0003 
#    CALLQUE  $QSR_MK_FLTGRAM
tcblock mbipcmd 0x0091 0x153E   0x01F8 0x1334 
#
#    ;---- See what type of formatting to perform
#    BRANCHEQ $IPRL_10FLTGRAM_TYPE 1 &DO_4X4BIN
tcblock mbipcmd 0x0091 0x1540   0x01AE 0x124F 0x0001 0x1549 
#    BRANCHEQ $IPRL_10FLTGRAM_TYPE 2 &DO_EXT256
tcblock mbipcmd 0x0091 0x1544   0x01AE 0x124F 0x0002 0x1556 
#    END
tcblock mbipcmd 0x0091 0x1548   0x01FC 
#
#DO_4X4BIN:
#    SETREGS  $IPRL_BIN_PARAM 2 17:0x0726			;setup source page of 
tcblock mbipcmd 0x0091 0x1549   0x01B2 0x11E9 0x0002 0x0726 \
                                0x8800 
#    COPYRD2D $IPRL_10FLTGRAM_ADDR $IPRL_BIN_PARAM+2 3		;copy the 
tcblock mbipcmd 0x0091 0x154E   0x0144 0x124C 0x11EB 0x0003 
#    CALLQUE  $QSR_FMT_4X4BIN
tcblock mbipcmd 0x0091 0x1552   0x01F8 0x129C 
#    GOTO &DONE
tcblock mbipcmd 0x0091 0x1554   0x0156 0x1567 
#
#DO_EXT256:
#    ;---- Do the extract and saving of the image
#    COPYRD2D $IPRL_EXTRACT_256 $IPRL_EXTRACT_PARAM 6            ;
tcblock mbipcmd 0x0091 0x1556   0x0144 0x1185 0x1173 0x0006 
#    SETREGS  $IPRL_EXTRACT_INST 2 17:0x0726			;setup source page 
tcblock mbipcmd 0x0091 0x155A   0x01B2 0x116B 0x0002 0x0726 \
                                0x8800 
#    COPYRD2D $IPRL_10FLTGRAM_ADDR $IPRL_EXTRACT_INST+2 3	;copy th
tcblock mbipcmd 0x0091 0x155F   0x0144 0x124C 0x116D 0x0003 
#    CALLQUE  $QSR_FMT_EXTRACT                                   ;
tcblock mbipcmd 0x0091 0x1563   0x01F8 0x1239 
#    GOTO &DONE
tcblock mbipcmd 0x0091 0x1565   0x0156 0x1567 
#
#DONE:
#END
tcblock mbipcmd 0x0091 0x1567   0x01FC 
#
#;----------------------- Start of callback code
#QCB_10FLTGRAM::
#    BRANCHEQ R3072   2 &CB_FRM02
tcblock mbipcmd 0x0091 0x1568   0x01AE 0x0C00 0x0002 0x1576 
#    BRANCHEQ R3072   6 &CB_FRM06
tcblock mbipcmd 0x0091 0x156C   0x01AE 0x0C00 0x0006 0x157F 
#    BRANCHEQ R3072  10 &CB_FRM10
tcblock mbipcmd 0x0091 0x1570   0x01AE 0x0C00 0x000A 0x1588 
#    GOTO &QSR_CB_DONE_ADDR
tcblock mbipcmd 0x0091 0x1574   0x0156 0x0FFF 
#
#CB_FRM02:
#    SETREGS $IPRL_DL_PARAM 2 0x5800 0x5804			;downlink the images
tcblock mbipcmd 0x0091 0x1576   0x01B2 0x11D0 0x0002 0x5800 \
                                0x5804 
#    CALLQUE $QSR_DL_2PAGE 
tcblock mbipcmd 0x0091 0x157B   0x01F8 0x10DB 
#    GOTO &QSR_CB_DONE_ADDR
tcblock mbipcmd 0x0091 0x157D   0x0156 0x0FFF 
#
#CB_FRM06:
#    SETREGS $IPRL_DL_PARAM 2 0x5808 0x580C			;downlink the images
tcblock mbipcmd 0x0091 0x157F   0x01B2 0x11D0 0x0002 0x5808 \
                                0x580C 
#    CALLQUE $QSR_DL_2PAGE 
tcblock mbipcmd 0x0091 0x1584   0x01F8 0x10DB 
#    GOTO &QSR_CB_DONE_ADDR
tcblock mbipcmd 0x0091 0x1586   0x0156 0x0FFF 
#
#CB_FRM10:
#    SETREGS $IPRL_DL_PARAM 2 0x7800 0x7804			;downlink the images
tcblock mbipcmd 0x0091 0x1588   0x01B2 0x11D0 0x0002 0x7800 \
                                0x7804 
#    CALLQUE $QSR_DL_2PAGE 
tcblock mbipcmd 0x0091 0x158D   0x01F8 0x10DB 
#    SETREG $IPRL_CB_ADDR 0					;clear the callback register
tcblock mbipcmd 0x0091 0x158F   0x0140 0x0C20 0x0000 
#    GOTO &QSR_CB_DONE_ADDR
tcblock mbipcmd 0x0091 0x1592   0x0156 0x0FFF 
#
#END
tcblock mbipcmd 0x0091 0x1594   0x01FC 
#=======================================================
#
# ENBQUE                ; Enable Queue
tcblock mbipldin 0x0136
#
#
return
#
#=======================================================
