# HISTORY:
#       Written 13-Mar-96 by M.Morrison
#
#
program "%Z% MODULE: %M% RELEASE: %R%.%L% CREATED: %G% %U%"
source "/mdisw/cfl/dev2/src/set_offset.src"
descr "SET_OFFSET - Update the offset table for extract location"

for !LI9 = 0 to 32000
    menu !LS0 "Seq Options" \
        "Set value manually" \
	"Set to center of disk for given HR extract size" \
        "QUIT"

    exit if !LS0 = "QUIT"

    if !LS0 = "Set value manually" then
	ask !LI1 "Enter the table entry number (generally 8, 9, 10 or 11)"
	ask !LI2 "Enter the column of lower-left corner to extract"
	ask !LI3 "Enter the line of lower-left corner to extract"
    end if

    if !LS0 = "Set to center of disk for given HR extract size" then
	ask !LI1 "Enter the table entry number (generally 8, 9, 10 or 11)"
	ask !LI4 "Enter the extract field of view size in pixels"
	set !LI5 = !LI4 / 2
	set !LI2 = 490 - !LI5
	set !LI3 = 310 - !LI5
    end if

    if !LI2 < 0 then
	set !LI2 = 0
    end if
    if !LI3 < 0 then
	set !LI3 = 0
    end if

    set !LI7 = !LI1 * 4
    set !LI7 = 0x4098 + !LI7		## address of location to patch

    set !LI4 = 1024 * !LI3
    set !LI4 = !LI4 + !LI2		## long word offset

    set !LI5 = !LI4 / 65536		## high word offset
    set !LI6 = !LI5 * 65536
    set !LI6 = !LI4 - !LI6		## low word offset


    display "                                               "
    display "Entry %d updated to (" !LI1 to 0
    display                      "%d," !LI2 to 22
    display                          "%d) == " !LI3 to 27
    display                                  "%d " !LI6 to 35
    display                                      "%d" !LI5 to 42

    menu !LS2 "OK To Send Command" "YES" "NO"
    if !LS2 = "YES" then
	tcb mbdpml 0x1000 !LI7 !LI6 !LI5
    end if
end for
