home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / GFX / ADPro251-3.DMS / ADPro251-3.adf / FREDScripts.lha / FREDSavers / FrameBuilder.fred < prev    next >
Encoding:
Text File  |  1994-01-31  |  8.0 KB  |  377 lines

  1. /*
  2. ** FrameBuilder.fred
  3. **
  4. ** $VER: FrameBuilder.fred 1.2.1 (17.1.94)
  5. **
  6. ** This program can be run from an InvokeADPro list to build a full frame
  7. ** from two fields (entered into a sequence as adjacent cells).
  8. **
  9. ** Clips Imported:
  10. **    FREDNumberOfFrames    -    Total frames selected
  11. **    FREDSameBaseName    -    ~0 if field 0 and 1 basenames are the same
  12. **                    0 if they are different
  13. **    FREDUsesFieldExt    -    ~0 if field 0 and 1 have extensions
  14. **                    0 if they don't
  15. **    FREDEvenFieldExt    -    Filename extension for even fields
  16. **    FREDOddFieldExt        -    Filename extension for odd fields
  17. **    FREDFieldBaseNameToUse    -    0 if the even field's base name
  18. **                    should be used for the new frame
  19. **                    1 if the odd field's base name
  20. **                    should be used
  21. **    FREDNextFieldFlag    -    0 if ready for new field pair
  22. **                    1 if ready to work on second field
  23. **    FREDEvenFieldWidth    -    Width of the even (first) field
  24. **    FREDEvenFieldHeight    -    Height of the even (first) field
  25. **    FREDEvenFieldBaseName    -    Basename of the even (first) field
  26. **
  27. ** Clips Exported:
  28. **    FREDNextFieldFlag    -    0 if ready for new field pair
  29. **                    1 if ready to work on second field
  30. **    FREDEvenFieldWidth    -    Width of the even (first) field
  31. **    FREDEvenFieldHeight    -    Height of the even (first) field
  32. **    FREDEvenFieldBaseName    -    Basename of the even (first) field
  33. **
  34. ** NOTE: Clip names are case sensitive.
  35. **
  36. ** This script requires FRED v1.4.0 (or higher) to run.  Also required is
  37. ** ADPro v2.5.0 (or higher).
  38. **
  39. ** Copyright © 1992-1993 ASDG, Incorporated
  40. ** All Rights Reserved
  41. */
  42.  
  43.  
  44. ADDRESS "ADPro"
  45. OPTIONS RESULTS
  46.  
  47. PARSE ARG FrameNum FrameFName Length LoadFlag FirstCallSeq FirstCallCell
  48.  
  49. NL = '0A'X
  50. SQ = '27'X
  51. DQ = '22'X
  52. TRUE  = 1
  53. FALSE = 0
  54. TempEvenField = "T:TempEvenField"
  55. TempOddField = "T:TempOddField"
  56.  
  57.  
  58. /*
  59. ** Get the required clips.  Error if any are missing.
  60. */
  61.  
  62. NumberOfFrames = GETCLIP( "FREDNumberOfFrames" )
  63. IF (NumberOfFrames = "") THEN DO
  64.     ADPRO_TO_FRONT
  65.     OKAY1 "Required clip, FREDNumberOfFrames," || NL ||,
  66.         "is not specified."
  67.     SCREEN_TO_FRONT "FRED"
  68.     EXIT 10
  69. END
  70.  
  71. SameBaseName = GETCLIP( "FREDSameBaseName" )
  72. IF (SameBaseName = "") THEN DO
  73.     ADPRO_TO_FRONT
  74.     OKAY1 "Required clip, FREDSameBaseName," || NL ||,
  75.         "is not specified."
  76.     SCREEN_TO_FRONT "FRED"
  77.     EXIT 10
  78. END
  79.  
  80. IF (SameBaseName = 0) THEN DO
  81.     FieldBaseNameToUse = GETCLIP( "FREDFieldBaseNameToUse" )
  82.     IF (FieldBaseNameToUse = "") THEN DO
  83.         ADPRO_TO_FRONT
  84.         OKAY1 "Required clip, FREDFieldBaseNameToUse," || NL ||,
  85.             "is not specified."
  86.         SCREEN_TO_FRONT "FRED"
  87.         EXIT 10
  88.     END
  89. END
  90.  
  91. UsesFieldExt = GETCLIP( "FREDUsesFieldExt" )
  92. IF (UsesFieldExt = "") THEN DO
  93.     ADPRO_TO_FRONT
  94.     OKAY1 "Required clip, FREDUsesFieldExt," || NL ||,
  95.         "is not specified."
  96.     SCREEN_TO_FRONT "FRED"
  97.     EXIT 10
  98. END
  99.  
  100. IF (UsesFieldExt ~= 0) THEN DO
  101.     EvenFieldExt = GETCLIP( "FREDEvenFieldExt" )
  102.     IF (EvenFieldExt = "") THEN DO
  103.         ADPRO_TO_FRONT
  104.         OKAY1 "Required clip, FREDEvenFieldExt," || NL ||,
  105.             "is not specified."
  106.         SCREEN_TO_FRONT "FRED"
  107.         EXIT 10
  108.     END
  109.  
  110.     OddFieldExt = GETCLIP( "FREDOddFieldExt" )
  111.     IF (OddFieldExt = "") THEN DO
  112.         ADPRO_TO_FRONT
  113.         OKAY1 "Required clip, FREDOddFieldExt," || NL ||,
  114.             "is not specified."
  115.         SCREEN_TO_FRONT "FRED"
  116.         EXIT 10
  117.     END
  118. END
  119.  
  120. NextFieldFlag = GETCLIP( "FREDNextFieldFlag" )
  121. IF (NextFieldFlag = "") THEN DO
  122.     ADPRO_TO_FRONT
  123.     OKAY1 "Required clip, FREDNextFieldFlag," || NL ||,
  124.         "is not specified."
  125.     SCREEN_TO_FRONT "FRED"
  126.     EXIT 10
  127. END
  128.  
  129.  
  130. /*
  131. ** See what type of data is loaded in ADPro/MorphPlus.
  132. */
  133.  
  134. CALL "FREDSCRIPTS:FREDFunctions/CheckForRawImageData" TRUE
  135. IF (RESULT ~= 0) THEN
  136.     EXIT 10
  137.  
  138.  
  139. /*
  140. ** Build the new frame from the even (first) and odd (second) field.
  141. */
  142.  
  143. IF (NextFieldFlag = 0) THEN DO
  144.     /*
  145.     ** Get the even field's width and height.
  146.     */
  147.  
  148.     XSIZE
  149.     SETCLIP( "FREDEvenFieldWidth", ADPRO_RESULT )
  150.  
  151.     YSIZE
  152.     SETCLIP( "FREDEvenFieldHeight", ADPRO_RESULT )
  153.  
  154.  
  155.     /*
  156.     ** Strip off the even field basename, if needed.
  157.     */
  158.  
  159.     IF (SameBaseName = 0) THEN
  160.         IF (FieldBaseNameToUse = 0) THEN DO
  161.             FileExtPos = LASTPOS( EvenFieldExt, FrameFName )
  162.             IF (FileExtPos ~= 0) THEN DO
  163.                 EvenFieldBaseName = LEFT( FrameFName, FileExtPos-1 ) || '"'
  164.             END
  165.             ELSE
  166.                 EvenFieldBaseName = FrameFName
  167.  
  168.             SETCLIP( "FREDEvenFieldBaseName", EvenFieldBaseName )
  169.         END
  170.  
  171.  
  172.     /*
  173.     ** Temporarily save this field.
  174.     */
  175.  
  176.     SAVER "IFF" TempEvenField "RAW"
  177.     IF (RC ~= 0) THEN DO
  178.         ADPRO_TO_FRONT
  179.         OKAY1 "The IFF saver failed to save" || NL ||,
  180.             "the temp even field." || NL ||,
  181.             "Argument Information:" || NL ||,
  182.             "Filename = " || TempEvenField || NL ||,
  183.             "Type = " || "RAW"
  184.         SCREEN_TO_FRONT "FRED"
  185.         EXIT 10
  186.     END
  187.  
  188.  
  189.     /*
  190.     ** Tell this script that we're ready for the odd field.
  191.     */
  192.  
  193.     NextFieldFlag = 1
  194. END
  195. ELSE DO
  196.     /*
  197.     ** Get the even field's width and height.
  198.     */
  199.  
  200.     EvenFieldWidth = GETCLIP( "FREDEvenFieldWidth" )
  201.     IF (EvenFieldWidth = "") THEN DO
  202.         ADPRO_TO_FRONT
  203.         OKAY1 "Required clip, FREDEvenFieldWidth," || NL ||,
  204.             "is not specified."
  205.         SCREEN_TO_FRONT "FRED"
  206.         EXIT 10
  207.     END
  208.  
  209.     EvenFieldHeight = GETCLIP( "FREDEvenFieldHeight" )
  210.     IF (EvenFieldHeight = "") THEN DO
  211.         ADPRO_TO_FRONT
  212.         OKAY1 "Required clip, FREDEvenFieldHeight," || NL ||,
  213.             "is not specified."
  214.         SCREEN_TO_FRONT "FRED"
  215.         EXIT 10
  216.     END
  217.  
  218.  
  219.     /*
  220.     ** Get the new basename to use.
  221.     */
  222.  
  223.     IF (SameBaseName = 0) & (FieldBaseNameToUse = 0) THEN DO
  224.         NewFrameFName = GETCLIP( "FREDEvenFieldBaseName" )
  225.         IF (NewFrameFName = "") THEN DO
  226.             ADPRO_TO_FRONT
  227.             OKAY1 "Required clip, FREDEvenFieldBaseName," || NL ||,
  228.                 "is not specified."
  229.             SCREEN_TO_FRONT "FRED"
  230.             EXIT 10
  231.         END
  232.     END
  233.     ELSE DO
  234.         FileExtPos = LASTPOS( OddFieldExt, FrameFName )
  235.         IF (FileExtPos ~= 0) THEN DO
  236.             NewFrameFName = LEFT( FrameFName, FileExtPos - 1 ) || '"'
  237.         END
  238.         ELSE
  239.             NewFrameFName = FrameFName
  240.     END
  241.  
  242.  
  243.     /*
  244.     ** Get the odd field's width and height.
  245.     */
  246.  
  247.     XSIZE
  248.     OddFieldWidth = ADPRO_RESULT
  249.  
  250.     YSIZE
  251.     OddFieldHeight = ADPRO_RESULT
  252.  
  253.  
  254.     /*
  255.     ** The even and odd fields' width must be the same.
  256.     */
  257.  
  258.     IF (EvenFieldWidth ~= OddFieldWidth) THEN DO
  259.         ADPRO_TO_FRONT
  260.         OKAY1 "Fields are of different widths." || NL ||,
  261.             "They must be the same."
  262.         SCREEN_TO_FRONT "FRED"
  263.         EXIT 10
  264.     END
  265.  
  266.  
  267.     /*
  268.     ** Temporarily save the odd field.
  269.     */
  270.  
  271.     SAVER "IFF" TempOddField "RAW"
  272.     IF (RC ~= 0) THEN DO
  273.         ADPRO_TO_FRONT
  274.         OKAY1 "The IFF saver failed to save" || NL ||,
  275.             "the temp odd field." || NL ||,
  276.             "Argument Information:" || NL ||,
  277.             "Filename = " || TempOddField || NL ||,
  278.             "Type = " || "RAW"
  279.         SCREEN_TO_FRONT "FRED"
  280.         EXIT 10
  281.     END
  282.  
  283.  
  284.     /*
  285.     ** Create a backdrop that will hold both fields.
  286.     */
  287.  
  288.     LOADER "BACKDROP" "XXX" "WIDTH" EvenFieldWidth "HEIGHT" (EvenFieldHeight + OddFieldHeight) "COLOR"
  289.     IF (RC ~= 0) THEN DO
  290.         ADPRO_TO_FRONT
  291.         OKAY1 "The BACKDROP loader failed" || NL ||,
  292.             "to make the backdrop." || NL ||,
  293.             "Argument Information:" || NL ||,
  294.             "Width = " || EvenFieldWidth || NL ||,
  295.             "Height = " || (EvenFieldHeight + OddFieldHeight) || NL ||,
  296.             "Type = " || "COLOR"
  297.         SCREEN_TO_FRONT "FRED"
  298.         EXIT 10
  299.     END
  300.  
  301.  
  302.     /*
  303.     ** Composite the even field above the odd field.
  304.     */
  305.  
  306.     LOADER "IFF" TempEvenField 0 0 100
  307.     IF (RC ~= 0) THEN DO
  308.         ADPRO_TO_FRONT
  309.         OKAY1 "Compositing the even field failed." || NL ||,
  310.             "Argument Information:" || NL ||,
  311.             "Filename = " || TempEvenField || NL ||,
  312.             "X = " || 0 || NL ||,
  313.             "Y = " || 0 || NL ||,
  314.             "Mix = " || 100
  315.         SCREEN_TO_FRONT "FRED"
  316.         EXIT 10
  317.     END
  318.  
  319.     LOADER "IFF" TempOddField 0 EvenFieldHeight 100
  320.     IF (RC ~= 0) THEN DO
  321.         ADPRO_TO_FRONT
  322.         OKAY1 "Compositing the odd field failed." || NL ||,
  323.             "Argument Information:" || NL ||,
  324.             "Filename = " || TempOddField || NL ||,
  325.             "X = " || 0 || NL ||,
  326.             "Y = " || EvenFieldHeight || NL ||,
  327.             "Mix = " || 100
  328.         SCREEN_TO_FRONT "FRED"
  329.         EXIT 10
  330.     END
  331.  
  332.  
  333.     /*
  334.     ** Interlace the image.
  335.     */
  336.  
  337.     OPERATOR "INTERLACE"
  338.     IF (RC ~= 0) THEN DO
  339.         ADPRO_TO_FRONT
  340.         OKAY1 "The INTERLACE operator failed."
  341.         SCREEN_TO_FRONT "FRED"
  342.         EXIT 10
  343.     END
  344.  
  345.  
  346.     /*
  347.     ** Save the generated frame.
  348.     */
  349.  
  350.     SAVER "IFF" NewFrameFName "RAW"
  351.     IF (RC ~= 0) THEN DO
  352.         ADPRO_TO_FRONT
  353.         OKAY1 "Saving generated frame failed." || NL ||,
  354.             "Argument Information:" || NL ||,
  355.             "Filename = " || NewFrameFName || NL ||,
  356.             "Type = " || "RAW"
  357.         SCREEN_TO_FRONT "FRED"
  358.         EXIT 10
  359.     END
  360.  
  361.  
  362.     /*
  363.     ** Tell this script that we're ready for a new frame.
  364.     */
  365.  
  366.     NextFieldFlag = 0
  367. END
  368.  
  369.  
  370. /*
  371. ** Update the clips.
  372. */
  373.  
  374. SETCLIP( "FREDNextFieldFlag", NextFieldFlag )
  375.  
  376. EXIT 0
  377.