home *** CD-ROM | disk | FTP | other *** search
/ DTP Toolbox / DTPToolbox.iso / utilities / propage_pdraw / donsgenies / adproscripts.lha / FLICtoAnim.ADPro < prev    next >
Encoding:
Text File  |  1994-06-09  |  12.1 KB  |  498 lines

  1. /*
  2. ** FLICtoANIM.adpro
  3. **
  4. ** $VER: FLICtoANIM.adpro June 94
  5. **
  6. ** This AREXX program will take an existing FLIC file and rerender it as an
  7. ** anim according to the user's specifications.
  8. **
  9. ** Example ARexx program for controlling MorphPlus/ADPro by ASDG Incorporated.
  10. **
  11. ** Copyright © 1993 ASDG Incorporated  All Rights Reserved
  12. */
  13.  
  14. call open("STDERR","ram:trace","W")
  15. trace r
  16.  
  17. ADDRESS "ADPro"
  18. OPTIONS RESULTS
  19.  
  20. NL = '0A'X
  21. SQ = '27'X
  22. DQ = '22'X
  23. TRUE = 1
  24. FALSE = 0
  25. TempDefaults = "T:TempADProDefaults"
  26.  
  27. SAVE_DEFAULTS TempDefaults
  28.  
  29. PSTATUS
  30. oldPSTATUS = ADPRO_RESULT
  31. PSTATUS "UNLOCKED"
  32.  
  33. CALL "FREDSCRIPTS:FREDFunctions/GetAFile" '"Enter FLIC To Convert"' '"ADPRO:"' '""""' TRUE
  34. IF (RESULT = (DQ || DQ)) THEN DO
  35.     ADPRO_TO_FRONT
  36.     OKAY1 "Error, no source ANIM specified."
  37.     ADPRO_TO_BACK
  38.     CALL ErrorOut 10
  39. END
  40. SrcANIMFName = RESULT
  41.  
  42. /*
  43. ** Select the horizontal resolution.
  44. */
  45. HorizSize.1  = "Low Res"
  46. HorizSize.2  = "High Res"
  47. HorizSize.3  = "Super High Res"
  48. MinHorizSize = 1
  49. MaxHorizSize = 3
  50. DefHorizSize = 1
  51.  
  52. String = '"' || HorizSize.DefHorizSize || '"'
  53. DO LoopCounter = MinHorizSize TO MaxHorizSize
  54.     String = String '"' || HorizSize.LoopCounter || '"'
  55. END
  56.  
  57. ADPRO_TO_FRONT
  58.  
  59. continue = 0
  60. DO UNTIL (continue = 1)
  61.     LISTVIEW '"Horiz. Resolutions:"' (MaxHorizSize-MinHorizSize+1) ITEMS String
  62.     LISTVIEW_RC = RC
  63.     PARSE VAR ADPRO_RESULT '"'HorizSizeStr'"' scratch
  64.  
  65.     HorizRes = MinHorizSize
  66.     DO WHILE (HorizRes <= MaxHorizSize) & (COMPARE( HorizSizeStr, HorizSize.HorizRes ) ~= 0)
  67.         HorizRes = HorizRes + 1
  68.     END
  69.  
  70.     IF (LISTVIEW_RC ~= 0) & (LISTVIEW_RC ~= 1) THEN DO
  71.         OKAY2 "This value is required." || NL || NL ||,
  72.             "Select OK to Retry" || NL ||,
  73.             "or CANCEL to Abort."
  74.  
  75.         IF (RC = 0) THEN
  76.             CALL ErrorOut 10
  77.     END
  78.     ELSE
  79.         continue = 1
  80. END
  81.  
  82. HorizOscan = 0
  83. OKAY2 "Horizontal Overscan?" || NL || NL ||,
  84.     "Select OK to enable it" || NL ||,
  85.     "or CANCEL to disable it."
  86. IF (RC ~= 0) THEN
  87.     HorizOscan = 1
  88.  
  89.     /*
  90.     ** Select the monitor.
  91.     */
  92. GETLIST MONITORS
  93. String = ADPRO_RESULT
  94. IF (RC ~= 0) THEN DO
  95.     ADPRO_TO_FRONT
  96.     OKAY1 "Could not retrieve" || NL ||,
  97.         "monitor list."
  98.     ADPRO_TO_BACK
  99.     CALL ErrorOut 10
  100. END
  101.  
  102. continue = 0
  103. DO UNTIL (continue = 1)
  104.     LISTVIEW '"Monitors Available:"' 10 ITEMS String
  105.     LISTVIEW_RC = RC
  106.     PARSE VAR ADPRO_RESULT '"'Monitor'"' scratch
  107.  
  108.     IF (LISTVIEW_RC ~= 0) & (LISTVIEW_RC ~= 1) THEN DO
  109.         OKAY2 "This value is required." || NL || NL ||,
  110.             "Select OK to Retry" || NL ||,
  111.             "or CANCEL to Abort."
  112.  
  113.         IF (RC = 0) THEN
  114.             CALL ErrorOut 10
  115.     END
  116.     ELSE
  117.         continue = 1
  118. END
  119.  
  120. VertLace = 0
  121. OKAY2 "Interlace?" || NL || NL ||,
  122.     "Select OK for interlace" || NL ||,
  123.     "or CANCEL for non-interlace."
  124. IF (RC ~= 0) THEN
  125.     VertLace = 1
  126.  
  127. VertOscan = 0
  128. OKAY2 "Vertical Overscan?" || NL || NL ||,
  129.     "Select OK to enable it" || NL ||,
  130.     "or CANCEL to disable it."
  131. IF (RC ~= 0) THEN
  132.     VertOscan = 1
  133.  
  134.     /*
  135.     ** Now build the SCREEN_TYPE value.
  136.     */
  137. ScreenType = 0
  138.  
  139. IF (HorizRes = 2) THEN              /* High Res */
  140.     ScreenType = ScreenType + 1
  141. ELSE IF (HorizRes = 3) THEN         /* Super High Res */
  142.     ScreenType = ScreenType + 64
  143.  
  144. IF (HorizOscan = 1) THEN            /* Horizontal Overscan */
  145.     ScreenType = ScreenType + 8
  146.  
  147. IF (Monitor = "DFLT") THEN          /* DFLT */
  148.     ScreenType = ScreenType + 256
  149. ELSE IF (Monitor = "PAL") THEN          /* PAL */
  150.     ScreenType = ScreenType + 4
  151. ELSE IF (Monitor = "VGA") THEN          /* VGA */
  152.     ScreenType = ScreenType + 32
  153. ELSE IF (Monitor = "SUP72") THEN        /* SUP72 */
  154.     ScreenType = ScreenType + 128
  155.  
  156. IF (VertLace = 1) THEN              /* Interlace */
  157.     ScreenType = ScreenType + 2
  158.  
  159. IF (VertOscan = 1) THEN             /* Vertical Overscan */
  160.     ScreenType = ScreenType + 16
  161.  
  162.  
  163. /*
  164. ** Ask the user to select the number of colors to use.
  165. */
  166.  
  167. GETLIST COLORS
  168. String = ADPRO_RESULT
  169. IF (RC ~= 0) THEN DO
  170.     ADPRO_TO_FRONT
  171.     OKAY1 "Could not retrieve" || NL ||,
  172.         "colors list."
  173.     ADPRO_TO_BACK
  174.     CALL ErrorOut 10
  175. END
  176.  
  177. continue = 0
  178. DO UNTIL (continue = 1)
  179.     LISTVIEW '"Colors Available:"' 10 ITEMS String
  180.     LISTVIEW_RC = RC
  181.     PARSE VAR ADPRO_RESULT '"'NumberOfColors'"' scratch
  182.  
  183.     IF (LISTVIEW_RC ~= 0) & (LISTVIEW_RC ~= 1) THEN DO
  184.         OKAY2 "This value is required." || NL || NL ||,
  185.             "Select OK to Retry" || NL ||,
  186.             "or CANCEL to Abort."
  187.  
  188.         IF (RC = 0) THEN
  189.             CALL ErrorOut 10
  190.     END
  191.     ELSE
  192.         continue = 1
  193. END
  194.  
  195. NumColors = VALUE( NumberOfColors )
  196. IF (VALUE( NumColors ) <= 256) THEN
  197.     RenderType = VALUE( NumColors )
  198. ELSE
  199.     RenderType = NumberOfColors
  200.  
  201.  
  202. /*
  203. ** Ask the user to select the dither mode to use.
  204. */
  205.  
  206. GETLIST DITHERS
  207. String = ADPRO_RESULT
  208. IF (RC ~= 0) THEN DO
  209.     ADPRO_TO_FRONT
  210.     OKAY1 "Could not retrieve" || NL ||,
  211.         "dither list."
  212.     ADPRO_TO_BACK
  213.     CALL ErrorOut 10
  214. END
  215.  
  216. continue = 0
  217. DO UNTIL (continue = 1)
  218.     LISTVIEW '"Dithers Available:"' 10 ITEMS String
  219.     LISTVIEW_RC = RC
  220.     PARSE VAR ADPRO_RESULT '"'DitherModeStr'"' scratch
  221.  
  222.     IF (LISTVIEW_RC ~= 0) & (LISTVIEW_RC ~= 1) THEN DO
  223.         OKAY2 "This value is required." || NL || NL ||,
  224.             "Select OK to Retry" || NL ||,
  225.             "or CANCEL to Abort."
  226.  
  227.         IF (RC = 0) THEN
  228.             CALL ErrorOut 10
  229.     END
  230.     ELSE
  231.         continue = 1
  232. END
  233.  
  234. IF (DitherModeStr = "Off") THEN         /* Off */
  235.     DitherMode = 0
  236. ELSE IF (DitherModeStr = "Floyd (1)") THEN  /* Floyd (1) */
  237.     DitherMode = 1
  238. ELSE IF (DitherModeStr = "Burkes (2)") THEN /* Burkes (2) */
  239.     DitherMode = 2
  240. ELSE IF (DitherModeStr = "Sierra (3)") THEN /* Sierra (3) */
  241.     DitherMode = 3
  242. ELSE IF (DitherModeStr = "Jarvis (4)") THEN /* Jarvis (4) */
  243.     DitherMode = 4
  244. ELSE IF (DitherModeStr = "Stucki (5)") THEN /* Stucki (5) */
  245.     DitherMode = 5
  246. ELSE IF (DitherModeStr = "Random (6)") THEN /* Random (6) */
  247.     DitherMode = 6
  248. ELSE IF (DitherModeStr = "Lg Ord (7)") THEN /* Lg Ord (7) */
  249.     DitherMode = 7
  250. ELSE IF (DitherModeStr = "Sm Ord (8)") THEN /* Sm Ord (8) */
  251.     DitherMode = 8
  252. ELSE
  253.     DitherMode = 0
  254.  
  255.  
  256. /*
  257. ** If dither is Random or Ordered, get the Dither Amount.
  258. */
  259.  
  260. IF (DitherMode = 6) | (DitherMode = 7) | (DitherMode = 8) THEN DO
  261.     continue = 0
  262.     DO UNTIL (continue = 1)
  263.         GETNUMBER '"Enter Dither Amount"' 16 1 256
  264.         DitherAmt = ADPRO_RESULT
  265.  
  266.         IF (RC ~= 0) THEN DO
  267.             OKAY2 "This value is required." || NL || NL ||,
  268.                 "Select OK to Retry" || NL ||,
  269.                 "or CANCEL to Abort."
  270.  
  271.             IF (RC = 0) THEN
  272.                 CALL ErrorOut 10
  273.         END
  274.         ELSE
  275.             continue = 1
  276.     END
  277. END
  278.  
  279. CALL "FREDSCRIPTS:FREDFunctions/GetSaver" "ANIM"
  280. IF (RESULT ~= 0) THEN
  281.     CALL ErrorOut RESULT
  282.  
  283. CALL "FREDSCRIPTS:FREDFunctions/GetLoader" "FLC"
  284. IF (RESULT ~= 0) THEN
  285.     CALL ErrorOut RESULT
  286.  
  287. CALL "FREDSCRIPTS:FREDFunctions/GetAFile" '"Enter name of ANIM file to create"' '"ADPRO:"' '""""' TRUE
  288. IF (RESULT = (DQ || DQ)) THEN DO
  289.     ADPRO_TO_FRONT
  290.     OKAY1 "Error, no dest ANIM specified."
  291.     ADPRO_TO_BACK
  292.     CALL ErrorOut 10
  293. END
  294. DestANIMFName = RESULT
  295.  
  296. IF (EXISTS( DestANIMFName )) THEN DO
  297.     CALL "FREDSCRIPTS:FREDFunctions/GetABool" '"Truncate Destination ANIM?"' '"to start a new file"' '"to append to it"'
  298.     IF (RESULT ~= 0) THEN DO
  299.         IMAGE_TYPE
  300.         ImageType = ADPRO_RESULT
  301.         IF (WORD( ImageType, 1 ) = "NONE") THEN DO
  302.             CALL "FREDSCRIPTS:FREDFunctions/GetLoader" "BACKDROP"
  303.             IF (RESULT ~= 0) THEN
  304.                 CALL ErrorOut RESULT
  305.  
  306.             LOAD "XXX" 10 10 "COLOR"
  307.             IF (RC ~= 0) THEN DO
  308.                 ADPRO_TO_FRONT
  309.                 OKAY1 "Unable to create temp image." || NL ||,
  310.                     "Argument Information:" || NL||,
  311.                     "Width = " || 10 || NL ||,
  312.                     "Height = " || 10 || NL ||,
  313.                     "Type = " || "COLOR"
  314.                 ADPRO_TO_BACK
  315.                 CALL ErrorOut 10
  316.             END
  317.         END
  318.  
  319.         IF (WORD( ImageType, 1 ) ~= "BITPLANE") THEN DO
  320.             EXECUTE
  321.             IF (RC ~= 0) THEN DO
  322.                 ADPRO_TO_FRONT
  323.                 OKAY1 "Unable to create temp rendered data."
  324.                 ADPRO_TO_BACK
  325.                 CALL ErrorOut 10
  326.             END
  327.         END
  328.  
  329.         CALL "FREDSCRIPTS:FREDFunctions/GetSaver" "ANIM"
  330.         IF (RESULT ~= 0) THEN
  331.             CALL ErrorOut RESULT
  332.  
  333.         SAVE DestANIMFName "IMAGE" "QUIT"
  334.         IF (RC ~= 0) THEN DO
  335.             ADPRO_TO_FRONT
  336.             OKAY1 "Could not close current ANIM file." || NL ||,
  337.                 "Argument Information:" || NL ||,
  338.                 "Filename = " || '"'DestANIMFName'"' || NL ||,
  339.                 "Type = " || "IMAGE" || NL ||,
  340.                 "Flags = " || "QUIT"
  341.             ADPRO_TO_BACK
  342.             CALL ErrorOut 10
  343.         END
  344.  
  345.         ADDRESS COMMAND "Delete >NIL:" '"'DestANIMFName'"'
  346.     END
  347. END
  348.  
  349. LFORMAT "FLC"
  350. SFORMAT "ANIM"
  351.  
  352. LOAD "'"SrcANIMFName"'" "COUNT"
  353. IF (RC ~= 0) THEN DO
  354.     ADPRO_TO_FRONT
  355.     OKAY1 "Can't find FLIC file."
  356.     ADPRO_TO_BACK
  357.     CALL ErrorOut 10
  358. END
  359.  
  360. NumFrames = ADPRO_RESULT
  361.  
  362. LOAD '"'SrcANIMFName'"' 1
  363. IF (RC ~= 0) THEN DO
  364.     ADPRO_TO_FRONT
  365.     OKAY1 "Cannot find source FLIC."
  366.     ADPRO_TO_BACK
  367.     CALL ErrorOut 10
  368. END
  369.  
  370. PSTATUS "LOCKED"
  371. SCREEN_TYPE
  372. oldSType = ADPRO_RESULT
  373. SCREEN_TYPE ADPRO_RESULT
  374.  
  375. CurrFrameNum = 1
  376. continue = FALSE
  377. DO WHILE (continue = FALSE)
  378.     LOAD '"'SrcANIMFName'"' CurrFrameNum
  379.     IF (RC ~= 0) THEN DO
  380.         ADPRO_TO_FRONT
  381.         OKAY1 "Error during load" || NL ||,
  382.             "of frame " || CurrFrameNum || "."
  383.         ADPRO_TO_BACK
  384.         CALL ErrorOut 10
  385.     END
  386.  
  387.     SCREEN_TYPE ScreenType
  388.     IF (RC ~= 0) THEN DO
  389.         ADPRO_TO_FRONT
  390.         OKAY1 "Screen mode not supported." || NL || ADPRO_RESULT
  391.         ADPRO_TO_BACK
  392.         CALL ErrorOut 10
  393.     END
  394.  
  395.     RENDER_TYPE RenderType
  396.     IF (RC ~= 0) THEN DO
  397.         ADPRO_TO_FRONT
  398.         OKAY1 "Render mode not supported." || NL || ADPRO_RESULT
  399.         ADPRO_TO_BACK
  400.         CALL ErrorOut 10
  401.     END
  402.  
  403.     DITHER DitherMode
  404.     IF (RC ~= 0) THEN DO
  405.         ADPRO_TO_FRONT
  406.         OKAY1 "Dither mode not supported." || NL || ADPRO_RESULT
  407.         ADPRO_TO_BACK
  408.         CALL ErrorOut 10
  409.     END
  410.  
  411.     IF (DitherMode = 6) | (DitherMode = 7) | (DitherMode = 8) THEN DO
  412.         DITHER_AMOUNT DitherAmt
  413.         IF (RC ~= 0) THEN DO
  414.             ADPRO_TO_FRONT
  415.             OKAY1 "Dither amount not supported." || NL || ADPRO_RESULT
  416.             ADPRO_TO_BACK
  417.             CALL ErrorOut 10
  418.         END
  419.     END
  420.  
  421.     EXECUTE
  422.     IF (RC ~= 0) THEN DO
  423.         ADPRO_TO_FRONT
  424.         OKAY1 "Error creating rendered data."
  425.         ADPRO_TO_BACK
  426.         CALL ErrorOut 10
  427.     END
  428.  
  429.     SAVE DestANIMFName "APPEND" "IMAGE"
  430.     IF (RC ~= 0) THEN DO
  431.         ADPRO_TO_FRONT
  432.         OKAY1 "Error during load" || NL ||,
  433.             "of frame " || CurrFrameNum || "."
  434.         ADPRO_TO_BACK
  435.         CALL ErrorOut 10
  436.     END
  437.  
  438.     CurrFrameNum = CurrFrameNum + 1
  439.     IF (CurrFrameNum > NumFrames) THEN
  440.         continue = TRUE
  441. END
  442.  
  443. SAVE DestANIMFName "QUIT" "IMAGE"
  444. IF (RC ~= 0) THEN DO
  445.     ADPRO_TO_FRONT
  446.     OKAY1 "Error closing dest ANIM."
  447.     ADPRO_TO_BACK
  448.     CALL ErrorOut 10
  449. END
  450.  
  451. PSTATUS oldPSTATUS
  452. SCREEN_TYPE oldSType
  453.  
  454. CALL ErrorOut 0
  455.  
  456.  
  457.  
  458.  
  459. ErrorOut:
  460.     PARSE ARG ErrorCode
  461.  
  462.     IF (EXISTS( SrcANIMFName )) & (ErrorCode ~= 0) THEN DO
  463.         LOADER "ANIM" '"'SrcANIMFName'"' "QUIT"
  464.         IF (RC ~= 0) THEN DO
  465.             ADPRO_TO_FRONT
  466.             OKAY1 "Error closing source ANIM:" || NL ||,
  467.                 SrcANIMFName || NL || NL ||,
  468.                 "You need to close it" || NL ||,
  469.                 "manually."
  470.             ADPRO_TO_BACK
  471.         END
  472.     END
  473.  
  474.     IF (EXISTS( DestANIMFName )) & (ErrorCode ~= 0) THEN DO
  475.         SAVER "ANIM" '"'DestANIMFName'"' "IMAGE" "QUIT"
  476.         IF (RC ~= 0) THEN DO
  477.             ADPRO_TO_FRONT
  478.             OKAY1 "Error closing dest ANIM:" || NL ||,
  479.                 DestANIMFName || NL || NL ||,
  480.                 "You need to close it" || NL ||,
  481.                 "manually."
  482.             ADPRO_TO_BACK
  483.         END
  484.     END
  485.  
  486.     IF (EXISTS( TempDefaults )) THEN DO
  487.         LOAD_DEFAULTS TempDefaults
  488.         IF (RC ~= 0) THEN DO
  489.             ADPRO_TO_FRONT
  490.             OKAY1 "Error restoring settings."
  491.             ADPRO_TO_BACK
  492.         END
  493.  
  494.         ADDRESS COMMAND "Delete >NIL:" TempDefaults
  495.     END
  496.  
  497.     EXIT ErrorCode
  498.