home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 542.lha / Render24_v1.01 / RendFE.rexx < prev    next >
OS/2 REXX Batch file  |  1991-08-10  |  11KB  |  313 lines

  1. /*
  2.     A simple Intuition front-end for the Rend24 program.
  3.     
  4.     Requirements:
  5.     
  6.         o Arexx 1.10+
  7.         o Rexxarplib.Library 2.0+
  8.         o Rend24 1.0+
  9.         
  10.     Useage:
  11.     
  12.         1> Rx RendFE
  13. */
  14.  
  15. /*
  16.     The following should be configured by the user:
  17. */
  18.  
  19. /* Path and filename of the Rend24 program... */
  20. rend24 = 'Rend24'
  21.  
  22. /* Path and filename of the Arexx WaitForPort program... */
  23. waitforport = 'SYS:Rexxc/WaitForPort'
  24.  
  25. /* Default input, output, and animation filenames and directories... */
  26. inpath  = 'Pic24:*.24'        /* Input IFF24 path */
  27. infile  = ''                  /* Input IFF24 file */
  28. outpath = 'RAM:'              /* Output IFF path */
  29. outfile = '*.pic'             /* Output IFF pattern */
  30. apath   = 'RAM:'              /* Output ANIM path */
  31. afile   = ''                  /* Output ANIM file */
  32.  
  33. /*
  34.     Program starts here.
  35. */
  36.  
  37. CALL Init
  38. CALL HandleWindow
  39.  
  40. CALL Exit('Unexpected end!')
  41.  
  42. /*
  43.     Clean exit from the program with a message.  This function
  44.     does not return.
  45. */
  46.  
  47. ERROR:
  48. Exit:
  49.  
  50.     PARSE ARG msg
  51.     
  52.     CALL Quit(RendHost)
  53.     
  54.     IF SHOW('Libraries','rexxarplib.library') THEN
  55.         CALL REMLIB('rexxarplib.library')
  56.         
  57.     IF SHOW('Libraries','rexxsupport.library') THEN
  58.         CALL REMLIB('rexxsupport.library')
  59.         
  60.     IF msg ~= '' THEN say msg
  61.     
  62.     EXIT 0
  63.  
  64. /*
  65.     Init() - Initialize the Front-End program.
  66. */
  67.  
  68. Init:
  69.  
  70.     /*
  71.         Setup some variables.  These can be modified by the
  72.         user as neccessary.
  73.     */
  74.     
  75.     /* Color preferences: */
  76.     color.back   = 0
  77.     color.block  = 1
  78.     color.detail = 2
  79.     color.shine  = 2
  80.     color.shadow = 1
  81.     color.prompt = 1
  82.     
  83.     finput  = ''
  84.     foutput = ''
  85.     aoutput = ''
  86.     frames  = '0'
  87.     
  88.     /* Options Defaults (0=off, 1=on) */
  89.     tog.lo  = 10; tog.hi = 22
  90.     tog.10  = 0 ; opt.10 = '-6'     /* 18-bit */
  91.     tog.11  = 0 ; opt.11 = '-c'     /* Convert */
  92.     tog.12  = 0 ; opt.12 = '-d'     /* Dither */
  93.     tog.13  = 0 ; opt.13 = '-e'     /* HAM-E */
  94.     tog.14  = 1 ; opt.14 = '-n'     /* NoWait */
  95.     tog.15  = 0 ; opt.15 = '-p'     /* Lock Palette */
  96.     tog.16  = 0 ; opt.16 = '-r'     /* Delete Files */
  97.     tog.17  = 0 ; opt.17 = '-t'     /* NTSC Limit */
  98.     tog.18  = 1 ; opt.18 = '-v'     /* Hide View */
  99.     tog.19  = 0 ; opt.19 = '-w'     /* Wait For Files */
  100.     tog.20  = 1 ; opt.20 = '-x'     /* Scale Width */
  101.     tog.21  = 0 ; opt.21 = '-y'     /* Scale Height */
  102.     tog.22  = 0 ; opt.22 = '-z'     /* Rotate -90 */
  103.  
  104.     /* Default conversion type:  (L=Luma,G=Grey,C=Color,H=Ham) */
  105.     convert = 'C'
  106.     
  107.     /*
  108.         First open the libraries we will be needing.
  109.     */
  110.     
  111.     IF ~SHOW('Libraries','rexxsupport.library') THEN
  112.         IF ~ADDLIB('rexxsupport.library',0,-30,0) THEN
  113.             CALL Exit('Cannot open rexxsupport.library')
  114.             
  115.     IF ~SHOW('Libraries','rexxarplib.library') THEN
  116.         IF ~ADDLIB('rexxarplib.library',0,-30,0) THEN
  117.             CALL Exit('Render.REXX requires RexxArpLib.Library')
  118.             
  119.     /*
  120.         Initialize the Rexxarp stuff.
  121.     */
  122.     
  123.     CALL OPENPORT(RendPort)
  124.     
  125.     /* This next line is why we need Arexx 1.10+ */
  126.     ADDRESS AREXX "'CALL CreateHost(RendHost,RendPort)'"
  127.     ADDRESS COMMAND waitforport 'RENDHOST'
  128.     
  129.     CALL SetReqColor(RendHost,BLOCKPEN,color.block)
  130.     CALL SetReqColor(RendHost,DETAILPEN,color.detail)
  131.     CALL SetReqColor(RendHost,BACKGROUNDPEN,color.back)
  132.     CALL SetReqColor(RendHost,PROMPTPEN,color.prompt)
  133.     CALL SetReqColor(RendHost,BOXPEN,color.shine)
  134.     CALL SetReqColor(RendHost,SHADOWPEN,color.shadow)
  135.     CALL SetReqColor(RendHost,OKAYPEN,color.prompt)
  136.     CALL SetReqColor(RendHost,CANCELPEN,color.prompt)
  137.     
  138.     widcmp = 'CLOSEWINDOW+GADGETUP'
  139.     wflags = 'ACTIVATE+WINDOWCLOSE+WINDOWDEPTH+WINDOWDRAG+BACKFILL'
  140.     wtitle = 'Rend24 Arexx Front-End © 1991 TEKSoft'
  141.     wwid   = 480
  142.     wht    = 120
  143.     
  144.     CALL OpenWindow(RendHost,100,40,wwid,wht,widcmp,wflags,wtitle)
  145.  
  146.     CALL AddGadget(RendHost,10,16,1,' Source IFF24 ','INPAT')
  147.     CALL AddGadget(RendHost,10,29,2,'  Target IFF  ','OUTPAT')
  148.     CALL AddGadget(RendHost,10,42,3,' Target  ANIM ','OUTANIM')
  149.     CALL Print(140,17,color.prompt,'(None)')
  150.     CALL Print(140,30,color.prompt,'(None)')
  151.     CALL Print(140,43,color.prompt,'(None)')
  152.     
  153.     CALL Print(8,57,color.prompt,'Frames:')
  154.     CALL AddGadget(RendHost,78,56,4,frames,'FRAMES %g',48)
  155.  
  156.     CALL Print(160,57,color.prompt,'Format:')
  157.     CALL AddGadget(RendHost,232,56,30,' Luma ','MODE L')
  158.     CALL AddGadget(RendHost,292,56,31,' Grey ','MODE G')
  159.     CALL AddGadget(RendHost,352,56,32,'Color ','MODE C')
  160.     CALL AddGadget(RendHost,412,56,33,' HAM  ','MODE H')
  161.     SELECT
  162.         WHEN convert = 'L' THEN CALL SetGadget(RendHost,30,'ON')
  163.         WHEN convert = 'G' THEN CALL SetGadget(RendHost,31,'ON')
  164.         WHEN convert = 'C' THEN CALL SetGadget(RendHost,32,'ON')
  165.         WHEN convert = 'H' THEN CALL SetGadget(RendHost,33,'ON')
  166.         OTHERWISE NOP
  167.         END
  168.         
  169.     CALL AddGadget(RendHost, 10,72,10,'18-Bit ','TOGGLE %d')
  170.     CALL AddGadget(RendHost, 76,72,11,'Convert','TOGGLE %d')
  171.     CALL AddGadget(RendHost,142,72,12,'Dither ','TOGGLE %d')
  172.     CALL AddGadget(RendHost,208,72,13,' HAM-E ','TOGGLE %d')
  173.     CALL AddGadget(RendHost,274,72,14,'NoPause','TOGGLE %d')
  174.     CALL AddGadget(RendHost,340,72,15,' LockP ','TOGGLE %d')
  175.     CALL AddGadget(RendHost, 10,85,16,'Delete ','TOGGLE %d')
  176.     CALL AddGadget(RendHost, 76,85,17,' Limit ','TOGGLE %d')
  177.     CALL AddGadget(RendHost,142,85,18,' Hide  ','TOGGLE %d')
  178.     CALL AddGadget(RendHost,208,85,19,' Wait  ','TOGGLE %d')
  179.     CALL AddGadget(RendHost,274,85,20,'Scale X','TOGGLE %d')
  180.     CALL AddGadget(RendHost,340,85,21,'Scale Y','TOGGLE %d')
  181.     CALL AddGadget(RendHost,406,85,22,'Rotate ','TOGGLE %d')
  182.     
  183.     DO i = tog.lo TO tog.hi
  184.         IF tog.i THEN CALL SetGadget(RendHost,i,'ON')
  185.         END
  186.         
  187.     CALL AddGadget(RendHost,160,104,99,' Begin Conversion ','BEGIN')
  188.     
  189.     RETURN 0
  190.     
  191. /*
  192.     Wait for and handle all messages from our window.  This function
  193.     never returns, actually.  It just goes directly to Exit().
  194. */
  195.  
  196. HandleWindow:
  197.  
  198.     DO FOREVER
  199.         CALL WAITPKT(RendPort)
  200.         packet = GETPKT(RendPort)
  201.         DO WHILE packet ~= NULL()
  202.             PARSE VALUE GETARG(packet) WITH arg0 arg1 .
  203.             CALL REPLY(packet)
  204.             SELECT
  205.                 WHEN arg0 = 'CLOSEWINDOW' THEN DO
  206.                     CALL Exit('User exit.')
  207.                     END
  208.                 WHEN arg0 = 'INPAT' THEN DO
  209.                     tmp = GetFile(,,inpath,infile,'Input File Pattern:')
  210.                     IF tmp ~= '' THEN DO
  211.                         finput = tmp
  212.                         CALL Print(140,17,color.prompt,finput)
  213.                         END
  214.                     END
  215.                 WHEN arg0 = 'OUTPAT' THEN DO
  216.                     foutput = GetFile(,,outpath,outfile,'Ouput File Pattern:')
  217.                     IF fouput = '' THEN CALL Print(140,30,color.prompt,'(None)')
  218.                     ELSE CALL Print(140,30,color.prompt,foutput)
  219.                     END
  220.                 WHEN arg0 = 'OUTANIM' THEN DO
  221.                     aoutput = GetFile(,,apath,afile,'Output Animation:')
  222.                     IF aoutput = '' THEN CALL Print(140,43,color.prompt,'(None)')
  223.                     ELSE CALL Print(140,43,color.prompt,aoutput)
  224.                     END
  225.                 WHEN arg0 = 'FRAMES' THEN DO
  226.                     frames = arg1
  227.                     END
  228.                 WHEN arg0 = 'TOGGLE' THEN DO
  229.                     IF tog.arg1 THEN DO
  230.                         CALL SetGadget(RendHost,arg1,'OFF')
  231.                         tog.arg1 = 0
  232.                         END
  233.                     ELSE DO
  234.                         CALL SetGadget(RendHost,arg1,'ON')
  235.                         tog.arg1 = 1
  236.                         END
  237.                     END
  238.                 WHEN arg0 = 'MODE' THEN DO
  239.                     convert = arg1
  240.                     SELECT
  241.                         WHEN arg1 = 'L' THEN DO
  242.                             CALL SetGadget(RendHost,30,'ON')
  243.                             CALL SetGadget(RendHost,31,'OFF')
  244.                             CALL SetGadget(RendHost,32,'OFF')
  245.                             CALL SetGadget(RendHost,33,'OFF')
  246.                             END
  247.                         WHEN arg1 = 'G' THEN DO
  248.                             CALL SetGadget(RendHost,30,'OFF')
  249.                             CALL SetGadget(RendHost,31,'ON')
  250.                             CALL SetGadget(RendHost,32,'OFF')
  251.                             CALL SetGadget(RendHost,33,'OFF')
  252.                             END
  253.                         WHEN arg1 = 'C' THEN DO
  254.                             CALL SetGadget(RendHost,30,'OFF')
  255.                             CALL SetGadget(RendHost,31,'OFF')
  256.                             CALL SetGadget(RendHost,32,'ON')
  257.                             CALL SetGadget(RendHost,33,'OFF')
  258.                             END
  259.                         WHEN arg1 = 'H' THEN DO
  260.                             CALL SetGadget(RendHost,30,'OFF')
  261.                             CALL SetGadget(RendHost,31,'OFF')
  262.                             CALL SetGadget(RendHost,32,'OFF')
  263.                             CALL SetGadget(RendHost,33,'ON')
  264.                             END
  265.                         OTHERWISE NOP
  266.                         END
  267.                     END
  268.                 WHEN arg0 = 'BEGIN' THEN DO
  269.                     IF finput = '' THEN DO
  270.                         ECHO 'Need to specify an input file at least.'
  271.                         LEAVE
  272.                         END
  273.                     command = rend24
  274.                     SELECT
  275.                         WHEN convert = 'L' THEN command = command || ' -l'
  276.                         WHEN convert = 'G' THEN command = command || ' -g'
  277.                         WHEN convert = 'H' THEN command = command || ' -h'
  278.                         OTHERWISE NOP
  279.                         END
  280.                     DO i = tog.lo TO tog.hi
  281.                         IF tog.i THEN command = command||' '||opt.i
  282.                         END
  283.                     IF foutput ~= '' THEN command = command || ' -o'||foutput
  284.                     IF aoutput ~= '' THEN command = command || ' -a'||aoutput
  285.                     IF frames ~= '0' THEN command = command || ' -f'||frames
  286.                     command = command || ' '||finput
  287.                     CALL WindowToBack(RendHost)
  288.                     ECHO command
  289.                     ADDRESS COMMAND command
  290.                     CALL WindowToFront(RendHost)
  291.                     END
  292.                     
  293.                 OTHERWISE NOP
  294.                 END
  295.             packet = GETPKT(RendPort)
  296.             END
  297.         END
  298.  
  299. Print:
  300.  
  301.     xpos = ARG(1)
  302.     ypos = ARG(2) + 6
  303.     pen  = ARG(3)
  304.     text = ARG(4)
  305.     CALL SetAPen(RendHost,pen)
  306.     CALL Move(RendHost,xpos,ypos)
  307.     CALL Text(RendHost,text)
  308.  
  309.     RETURN 0
  310.     
  311. /*
  312.     All done.
  313. */