# File: fmt_bin.src
#
program "%Z% MODULE: %M% RELEASE: %R%.%L% CREATED: %G% %U%"
source "fmt_bin.ips"
descr "fmt_4x4bin.ips - Performs a 4x4 binning of an image"
#
# DSBQUE                ; Disable Queue
tcblock mbipldin 0x0154 
#
#=======================================================
#
#
#; FILE:    fmt_4x4bin.ips
#; PURPOSE: To perform a 4x4 binning of an image
#; METHOD:
#;       Inputs
#;               $IPRL_BIN_PARAM      - Holds:   source page(l,h) 
#;	Pages:
#;		19	== the intermediate 4x4 binning product
#; RESTRICTION:
#;	The 1024x1024 extract needs to have already been performed
#; HISTORY: Written 5-Sep-95 by M.Morrison
#;	16-Oct-95 (MDM) - Changed to use page 14 for 4x4 bin list
#;	19-Oct-95 (MDM) - Modified to not use R168 or R170 
#;	19-Oct-95 (MDM0 - Major reconstruction to be more general
#;			  TODO - look at the scaling factors of the ROWBIN instructio
#;	20-Oct-95 (MDM) - Corrected the logic - it wasn't counting loop
#;	24-Oct-95 (MDM) - Removed fixed register reference to R6000
#;
#QSR_FMT_2X2BIN::
#    SETREGS $IPRL_BIN_ROWBIN+2 9   19:0x0000 1024 2 1024 512 16 1
tcblock mbipcmd 0x0091 0x11CD   0x01B2 0x115A 0x0009 0x0000 \
                                0x9800 0x0400 0x0002 0x0400 \
                                0x0200 0x0010 0x0001 0x10E5 
#    SETREGS $IPRL_BIN_LRBIN+3 5    0 4 14:0xffe60 $IPRL_BIN_LR_OF
tcblock mbipcmd 0x0091 0x11D9   0x01B2 0x1166 0x0005 0x0000 \
                                0x0004 0xFE60 0x700F 0x116D 
#    SETREGS $IPRL_BIN_LR_NWORDS 2  0x4000L			;number of input pix
tcblock mbipcmd 0x0091 0x11E1   0x01B2 0x116B 0x0002 0x4000 \
                                0x0000 
#    SETREG  $IPRL_BIN_DPC 0x1001
tcblock mbipcmd 0x0091 0x11E6   0x0140 0x116F 0x1001 
#    SETREGS $IPRL_BIN_NWORDS 2 0x40000L
tcblock mbipcmd 0x0091 0x11E9   0x01B2 0x1170 0x0002 0x0000 \
                                0x0004 
#    SETREG  $IPRL_BIN_DONE_ADDR 0x0008				;address of source page
tcblock mbipcmd 0x0091 0x11EE   0x0140 0x1172 0x0008 
#    GOTO &COMMON_CODE
tcblock mbipcmd 0x0091 0x11F1   0x0156 0x123F 
#
#QSR_FMT_4X4BIN::
#    SETREGS $IPRL_BIN_ROWBIN+2 9   19:0x0000 1024 4 1024 256 16 1
tcblock mbipcmd 0x0091 0x11F3   0x01B2 0x115A 0x0009 0x0000 \
                                0x9800 0x0400 0x0004 0x0400 \
                                0x0100 0x0010 0x0001 0x10E5 
#    SETREGS $IPRL_BIN_LRBIN+3 5    0 4 14:0xffe00 $IPRL_BIN_LR_OF
tcblock mbipcmd 0x0091 0x11FF   0x01B2 0x1166 0x0005 0x0000 \
                                0x0004 0xFE00 0x700F 0x116D 
#    SETREGS $IPRL_BIN_LR_NWORDS 2  0x8000L			;number of input pix
tcblock mbipcmd 0x0091 0x1207   0x01B2 0x116B 0x0002 0x8000 \
                                0x0000 
#    SETREG  $IPRL_BIN_DPC 0x1002
tcblock mbipcmd 0x0091 0x120C   0x0140 0x116F 0x1002 
#    SETREGS $IPRL_BIN_NWORDS 2 0x10000L
tcblock mbipcmd 0x0091 0x120F   0x01B2 0x1170 0x0002 0x0000 \
                                0x0001 
#    SETREG  $IPRL_BIN_DONE_ADDR 0x0004				;address of source page
tcblock mbipcmd 0x0091 0x1214   0x0140 0x1172 0x0004 
#    GOTO &COMMON_CODE
tcblock mbipcmd 0x0091 0x1217   0x0156 0x123F 
#
#QSR_FMT_8X8BIN::
#    SETREGS $IPRL_BIN_ROWBIN+2 9   19:0x0000 1024 8 1024 128 16 1
tcblock mbipcmd 0x0091 0x1219   0x01B2 0x115A 0x0009 0x0000 \
                                0x9800 0x0400 0x0008 0x0400 \
                                0x0080 0x0010 0x0001 0x10E5 
#    SETREGS $IPRL_BIN_LRBIN+3 5    0 4 14:0xffe30 $IPRL_BIN_LR_OF
tcblock mbipcmd 0x0091 0x1225   0x01B2 0x1166 0x0005 0x0000 \
                                0x0004 0xFE30 0x700F 0x116D 
#    SETREGS $IPRL_BIN_LR_NWORDS 2  0x8000L			;number of input pix
tcblock mbipcmd 0x0091 0x122D   0x01B2 0x116B 0x0002 0x8000 \
                                0x0000 
#    SETREG  $IPRL_BIN_DPC 0x1003
tcblock mbipcmd 0x0091 0x1232   0x0140 0x116F 0x1003 
#    SETREGS $IPRL_BIN_NWORDS 2 0x4000L
tcblock mbipcmd 0x0091 0x1235   0x01B2 0x1170 0x0002 0x4000 \
                                0x0000 
#    SETREG  $IPRL_BIN_DONE_ADDR 0x0002				;address of source page
tcblock mbipcmd 0x0091 0x123A   0x0140 0x1172 0x0002 
#    GOTO &COMMON_CODE
tcblock mbipcmd 0x0091 0x123D   0x0156 0x123F 
#
#COMMON_CODE:
#
#    GETQADR  $IPRL_DEBUG_ADDR
tcblock mbipcmd 0x0091 0x123F   0x015C 0x1FFD 
#    CALLQUE  $QSR_DUMP_IPREG                                    ;
tcblock mbipcmd 0x0091 0x1241   0x01F8 0x1028 
#
#
#    COPYREG  $IPRL_BIN_PARAM   $IPRL_BIN_ROWBIN			;copy the sourc
tcblock mbipcmd 0x0091 0x1243   0x0142 0x1153 0x1158 
#    COPYREG  $IPRL_BIN_PARAM+1 $IPRL_BIN_ROWBIN+1		;copy the sour
tcblock mbipcmd 0x0091 0x1246   0x0142 0x1154 0x1159 
#    ROWBIN   $IPRL_BIN_ROWBIN					;do the binning in one directio
tcblock mbipcmd 0x0091 0x1249   0x01D4 0x1158 
#
#
#    COPYREG  $IPRL_BIN_PARAM+2 $IPRL_BIN_LRBIN+1		;copy the low w
tcblock mbipcmd 0x0091 0x124B   0x0142 0x1155 0x1164 
#    COPYREG  $IPRL_BIN_PARAM+3 $IPRL_BIN_LRBIN+2		;copy the high 
tcblock mbipcmd 0x0091 0x124E   0x0142 0x1156 0x1165 
#    GETQADR  $IPRL_DEBUG_ADDR
tcblock mbipcmd 0x0091 0x1251   0x015C 0x1FFD 
#    CALLQUE  $QSR_DUMP_IPREG                                    ;
tcblock mbipcmd 0x0091 0x1253   0x01F8 0x1028 
#
#    SETREGS  $IPRL_BIN_LR_OFFSET 2 0 0				;initialize the offset
tcblock mbipcmd 0x0091 0x1255   0x01B2 0x116D 0x0002 0x0000 \
                                0x0000 
#RPT:
#	SETREG    $IPRL_BIN_LRBIN+3 0 				;set list pointer to zero
tcblock mbipcmd 0x0091 0x125A   0x0140 0x1166 0x0000 
#
#        LRBIN     $IPRL_BIN_LRBIN				;do one set of binning
tcblock mbipcmd 0x0091 0x125D   0x01D0 0x1163 
#        ADDADR    $IPRL_BIN_LR_OFFSET $IPRL_BIN_LR_NWORDS $IPRL_B
tcblock mbipcmd 0x0091 0x125F   0x0148 0x116D 0x116B 0x116D 
#	REGSUB    $IPRL_BIN_DONE_ADDR $IPRL_BIN_LR_OFFSET+1 $IPRL_BIN_DO
tcblock mbipcmd 0x0091 0x1263   0x2146 0x1172 0x116E 0x1173 
#        ;;BRANCHNE  $IPRL_BIN_LR_OFFSET+1 0x0008 &RPT
#	BRANCHNE  $IPRL_BIN_DONE_ADDR+1 0 &RPT
tcblock mbipcmd 0x0091 0x1267   0x01B0 0x1173 0x0000 0x125A 
#
#    ;--- do the decoding of the destination page
#    GETQADR  $IPRL_DEBUG_ADDR
tcblock mbipcmd 0x0091 0x126B   0x015C 0x1FFD 
#    CALLQUE  $QSR_DUMP_IPREG                                    ;
tcblock mbipcmd 0x0091 0x126D   0x01F8 0x1028 
#
#    COPYREG  $IPRL_BIN_PARAM+1 $IPRL_HDECODE_PARAM          ;copy
tcblock mbipcmd 0x0091 0x126F   0x0142 0x1154 0x10C8 
#    COPYREG  $IPRL_BIN_PARAM+3 $IPRL_HDECODE_PARAM+1        ;copy
tcblock mbipcmd 0x0091 0x1272   0x0142 0x1156 0x10C9 
#    CALLQUE  $QSR_DO_HDECODE                                ;deco
tcblock mbipcmd 0x0091 0x1275   0x01F8 0x1068 
#
#    ;--- now copy the relevant info to the hrdinit slot
#    COPYRI2D $IPRP_HDECODE_ADDR+1  $IPRL_HEAD_WORK 10       ;copy
tcblock mbipcmd 0x0091 0x1277   0x01AC 0x10CD 0x10CF 0x000A 
#    COPYREG  $IPRL_BIN_PARAM+2     $IPRL_HEAD_WORK+6        ;copy
tcblock mbipcmd 0x0091 0x127B   0x0142 0x1155 0x10D5 
#    COPYREG  $IPRL_BIN_PARAM+3     $IPRL_HEAD_WORK+7        ;copy
tcblock mbipcmd 0x0091 0x127E   0x0142 0x1156 0x10D6 
#    COPYREG  $IPRL_BIN_DPC         $IPRL_HEAD_WORK+5        ;over
tcblock mbipcmd 0x0091 0x1281   0x0142 0x116F 0x10D4 
#    COPYREG  $IPRL_BIN_NWORDS	   $IPRL_HEAD_WORK+8	    ;set the o
tcblock mbipcmd 0x0091 0x1284   0x0142 0x1170 0x10D7 
#    COPYREG  $IPRL_BIN_NWORDS+1	   $IPRL_HEAD_WORK+9	    ;
tcblock mbipcmd 0x0091 0x1287   0x0142 0x1171 0x10D8 
#    COPYRD2I $IPRL_HEAD_WORK $IPRP_HDECODE_ADDR+1 10        ;copy
tcblock mbipcmd 0x0091 0x128A   0x01AA 0x10CF 0x10CD 0x000A 
#
#    GETQADR  $IPRL_DEBUG_ADDR
tcblock mbipcmd 0x0091 0x128E   0x015C 0x1FFD 
#    CALLQUE  $QSR_DUMP_IPREG                                    ;
tcblock mbipcmd 0x0091 0x1290   0x01F8 0x1028 
#    CALLQUE  $QSR_DO_HEADER
tcblock mbipcmd 0x0091 0x1292   0x01F8 0x1125 
#
#    RTNQUE
tcblock mbipcmd 0x0091 0x1294   0x01FA 
#=======================================================
#
# ENBQUE                ; Enable Queue
tcblock mbipldin 0x0136
#
#
return
#
#=======================================================
