# File: fltgram_v05.src
#
program "%Z% MODULE: %M% RELEASE: %R%.%L% CREATED: %G% %U%"
source "fltgram_v05.ips"
descr "Loads IP queue instructions"
#=======================================================
#
#
#; 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 mbipmacl 0x146A    0x0140 0x124F 0x0001 
#    GOTO &QPROG_FLTGRAM
tcblock mbipmacl 0x146D    0x0156 0x1474 
#
#QPROG_FLTGRAM_EXT256::
#    SETREG $IPRL_10FLTGRAM_TYPE 2
tcblock mbipmacl 0x146F    0x0140 0x124F 0x0002 
#    GOTO &QPROG_FLTGRAM
tcblock mbipmacl 0x1472    0x0156 0x1474 
#
#QPROG_FLTGRAM:
#
#;---------------- Optional Downlink Portion
#OPTIONAL_DL:
#    BRANCHEQ R3072   4 &DL_FRM04
tcblock mbipmacl 0x1474    0x01AE 0x0C00 0x0004 0x147E 
#    BRANCHEQ R3072   8 &DL_FRM08
tcblock mbipmacl 0x1478    0x01AE 0x0C00 0x0008 0x1487 
#    GOTO &INCOMING_IMG
tcblock mbipmacl 0x147C    0x0156 0x1490 
#
#DL_FRM04:
#    SETREGS $IPRL_DL_PARAM 2 0x7800 0x7804			;downlink the images
tcblock mbipmacl 0x147E    0x01B2 0x11D0 0x0002 0x7800 \
                                0x7804 
#    CALLQUE $QSR_DL_2PAGE 
tcblock mbipmacl 0x1483    0x01F8 0x0DA5 
#    GOTO &INCOMING_IMG
tcblock mbipmacl 0x1485    0x0156 0x1490 
#
#DL_FRM08:
#    SETREGS $IPRL_DL_PARAM 2 0x7808 0x780C			;downlink the images
tcblock mbipmacl 0x1487    0x01B2 0x11D0 0x0002 0x7808 \
                                0x780C 
#    CALLQUE $QSR_DL_2PAGE 
tcblock mbipmacl 0x148C    0x01F8 0x0DA5 
#    GOTO &INCOMING_IMG
tcblock mbipmacl 0x148E    0x0156 0x1490 
#
#;---------------- The work for this page
#
#INCOMING_IMG:
#    BRANCHEQ R3072   1 &FRM01
tcblock mbipmacl 0x1490    0x01AE 0x0C00 0x0001 0x14B8 
#    BRANCHEQ R3072   2 &FRM02
tcblock mbipmacl 0x1494    0x01AE 0x0C00 0x0002 0x14BE 
#    BRANCHEQ R3072   3 &FRM03
tcblock mbipmacl 0x1498    0x01AE 0x0C00 0x0003 0x14C4 
#    BRANCHEQ R3072   4 &FRM04
tcblock mbipmacl 0x149C    0x01AE 0x0C00 0x0004 0x14CA 
#    BRANCHEQ R3072   5 &FRM05
tcblock mbipmacl 0x14A0    0x01AE 0x0C00 0x0005 0x14D0 
#    BRANCHEQ R3072   6 &FRM06
tcblock mbipmacl 0x14A4    0x01AE 0x0C00 0x0006 0x14D6 
#    BRANCHEQ R3072   7 &FRM07
tcblock mbipmacl 0x14A8    0x01AE 0x0C00 0x0007 0x14DC 
#    BRANCHEQ R3072   8 &FRM08
tcblock mbipmacl 0x14AC    0x01AE 0x0C00 0x0008 0x14E2 
#    BRANCHEQ R3072   9 &FRM09
tcblock mbipmacl 0x14B0    0x01AE 0x0C00 0x0009 0x14B8 
#    BRANCHEQ R3072  10 &FRM10
tcblock mbipmacl 0x14B4    0x01AE 0x0C00 0x000A 0x14BE 
#
#FRM01:
#FRM09:
#    COPYRD2D $IPRP_HDECODE_PAGE15  $IPRL_10FLTGRAM_ADDR 3	;put it
tcblock mbipmacl 0x14B8    0x0144 0x10C8 0x124C 0x0003 
#    GOTO &DO_THE_WORK
tcblock mbipmacl 0x14BC    0x0156 0x14E8 
#FRM02:
#FRM10:
#    COPYRD2D $IPRP_HDECODE_PAGE15B $IPRL_10FLTGRAM_ADDR 3	;put it
tcblock mbipmacl 0x14BE    0x0144 0x10D2 0x124C 0x0003 
#    GOTO &DO_THE_WORK
tcblock mbipmacl 0x14C2    0x0156 0x14E8 
#FRM03:
#    COPYRD2D $IPRP_HDECODE_PAGE15C $IPRL_10FLTGRAM_ADDR 3	;put it
tcblock mbipmacl 0x14C4    0x0144 0x10DC 0x124C 0x0003 
#    GOTO &DO_THE_WORK
tcblock mbipmacl 0x14C8    0x0156 0x14E8 
#FRM04:
#    COPYRD2D $IPRP_HDECODE_PAGE15D $IPRL_10FLTGRAM_ADDR 3	;put it
tcblock mbipmacl 0x14CA    0x0144 0x10E6 0x124C 0x0003 
#    GOTO &DO_THE_WORK
tcblock mbipmacl 0x14CE    0x0156 0x14E8 
#FRM05:
#    COPYRD2D $IPRP_HDECODE_PAGE11  $IPRL_10FLTGRAM_ADDR 3	;put it
tcblock mbipmacl 0x14D0    0x0144 0x106E 0x124C 0x0003 
#    GOTO &DO_THE_WORK
tcblock mbipmacl 0x14D4    0x0156 0x14E8 
#FRM06:
#    COPYRD2D $IPRP_HDECODE_PAGE11B $IPRL_10FLTGRAM_ADDR 3	;put it
tcblock mbipmacl 0x14D6    0x0144 0x1078 0x124C 0x0003 
#    GOTO &DO_THE_WORK
tcblock mbipmacl 0x14DA    0x0156 0x14E8 
#FRM07:
#    COPYRD2D $IPRP_HDECODE_PAGE11C $IPRL_10FLTGRAM_ADDR 3	;put it
tcblock mbipmacl 0x14DC    0x0144 0x1082 0x124C 0x0003 
#    GOTO &DO_THE_WORK
tcblock mbipmacl 0x14E0    0x0156 0x14E8 
#FRM08:
#    COPYRD2D $IPRP_HDECODE_PAGE11D $IPRL_10FLTGRAM_ADDR 3	;put it
tcblock mbipmacl 0x14E2    0x0144 0x108C 0x124C 0x0003 
#    GOTO &DO_THE_WORK
tcblock mbipmacl 0x14E6    0x0156 0x14E8 
#
#DO_THE_WORK:
#    SETREG $IPRL_CB_ADDR &QCB_10FLTGRAM				;set the callback regi
tcblock mbipmacl 0x14E8    0x0140 0x0C20 0x1520 
#
#    ;---- Make the filtergram (1024x1024)
#    SETREGS  $IPRL_FLTGRAM_PARAM 4 0:0x0000 17:0x0726		;set sourc
tcblock mbipmacl 0x14EB    0x01B2 0x1238 0x0004 0x0000 \
                                0x0000 0x0726 0x8800 
#    COPYRD2D $IPRL_FLTGRAM_GEN $IPRL_FLTGRAM_PARAM+8 3		;last thr
tcblock mbipmacl 0x14F2    0x0144 0x1243 0x1240 0x0003 
#    CALLQUE  $QSR_MK_FLTGRAM
tcblock mbipmacl 0x14F6    0x01F8 0x11E3 
#
#    ;---- See what type of formatting to perform
#    BRANCHEQ $IPRL_10FLTGRAM_TYPE 1 &DO_4X4BIN
tcblock mbipmacl 0x14F8    0x01AE 0x124F 0x0001 0x1501 
#    BRANCHEQ $IPRL_10FLTGRAM_TYPE 2 &DO_EXT256
tcblock mbipmacl 0x14FC    0x01AE 0x124F 0x0002 0x150E 
#    END
tcblock mbipmacl 0x1500    0x01FC 
#
#DO_4X4BIN:
#    SETREGS  $IPRL_BIN_PARAM 2 17:0x0726			;setup source page of 
tcblock mbipmacl 0x1501    0x01B2 0x11E9 0x0002 0x0726 \
                                0x8800 
#    COPYRD2D $IPRL_10FLTGRAM_ADDR $IPRL_BIN_PARAM+2 3		;copy the 
tcblock mbipmacl 0x1506    0x0144 0x124C 0x11EB 0x0003 
#    CALLQUE  $QSR_FMT_4X4BIN
tcblock mbipmacl 0x150A    0x01F8 0x114B 
#    GOTO &DONE
tcblock mbipmacl 0x150C    0x0156 0x151F 
#
#DO_EXT256:
#    ;---- Do the extract and saving of the image
#    COPYRD2D $IPRL_EXTRACT_256 $IPRL_EXTRACT_PARAM 6            ;
tcblock mbipmacl 0x150E    0x0144 0x1185 0x1173 0x0006 
#    SETREGS  $IPRL_EXTRACT_INST 2 17:0x0726			;setup source page 
tcblock mbipmacl 0x1512    0x01B2 0x116B 0x0002 0x0726 \
                                0x8800 
#    COPYRD2D $IPRL_10FLTGRAM_ADDR $IPRL_EXTRACT_INST+2 3	;copy th
tcblock mbipmacl 0x1517    0x0144 0x124C 0x116D 0x0003 
#    CALLQUE  $QSR_FMT_EXTRACT                                   ;
tcblock mbipmacl 0x151B    0x01F8 0x10E8 
#    GOTO &DONE
tcblock mbipmacl 0x151D    0x0156 0x151F 
#
#DONE:
#END
tcblock mbipmacl 0x151F    0x01FC 
#
#;----------------------- Start of callback code
#QCB_10FLTGRAM::
#    BRANCHEQ R3072   2 &CB_FRM02
tcblock mbipmacl 0x1520    0x01AE 0x0C00 0x0002 0x152E 
#    BRANCHEQ R3072   6 &CB_FRM06
tcblock mbipmacl 0x1524    0x01AE 0x0C00 0x0006 0x1537 
#    BRANCHEQ R3072  10 &CB_FRM10
tcblock mbipmacl 0x1528    0x01AE 0x0C00 0x000A 0x1540 
#    GOTO &QSR_CB_DONE_ADDR
tcblock mbipmacl 0x152C    0x0156 0x0FFF 
#
#CB_FRM02:
#    SETREGS $IPRL_DL_PARAM 2 0x5800 0x5804			;downlink the images
tcblock mbipmacl 0x152E    0x01B2 0x11D0 0x0002 0x5800 \
                                0x5804 
#    CALLQUE $QSR_DL_2PAGE 
tcblock mbipmacl 0x1533    0x01F8 0x0DA5 
#    GOTO &QSR_CB_DONE_ADDR
tcblock mbipmacl 0x1535    0x0156 0x0FFF 
#
#CB_FRM06:
#    SETREGS $IPRL_DL_PARAM 2 0x5808 0x580C			;downlink the images
tcblock mbipmacl 0x1537    0x01B2 0x11D0 0x0002 0x5808 \
                                0x580C 
#    CALLQUE $QSR_DL_2PAGE 
tcblock mbipmacl 0x153C    0x01F8 0x0DA5 
#    GOTO &QSR_CB_DONE_ADDR
tcblock mbipmacl 0x153E    0x0156 0x0FFF 
#
#CB_FRM10:
#    SETREGS $IPRL_DL_PARAM 2 0x7800 0x7804			;downlink the images
tcblock mbipmacl 0x1540    0x01B2 0x11D0 0x0002 0x7800 \
                                0x7804 
#    CALLQUE $QSR_DL_2PAGE 
tcblock mbipmacl 0x1545    0x01F8 0x0DA5 
#    SETREG $IPRL_CB_ADDR 0					;clear the callback register
tcblock mbipmacl 0x1547    0x0140 0x0C20 0x0000 
#    GOTO &QSR_CB_DONE_ADDR
tcblock mbipmacl 0x154A    0x0156 0x0FFF 
#
#END
tcblock mbipmacl 0x154C    0x01FC 
#=======================================================
#
return
#
#=======================================================
