home *** CD-ROM | disk | FTP | other *** search
/ Sound, Music & MIDI Collection 2 / SMMVOL2.bin / DEMO / PRG / CIRCLES.ZIP / CI_MAIN.DIX / 00016_MISC.ls < prev    next >
Encoding:
Text File  |  1995-05-01  |  15.8 KB  |  722 lines

  1. on filenameMAC s
  2.   global dir_sep
  3.   set slen to length(string(s))
  4.   repeat while slen >= 1
  5.     if chars(s, slen, slen) = dir_sep then
  6.       set szstr to chars(s, slen + 1, length(string(s)))
  7.       exit repeat
  8.     end if
  9.     set slen to slen - 1
  10.   end repeat
  11.   return szstr
  12. end
  13.  
  14. on frompath s, cnt
  15.   global up_load, fl_search, up_cload, dir_sep
  16.   set slen to length(string(s))
  17.   set ac_cnt to 0
  18.   set szstr to EMPTY
  19.   repeat with i = 1 to slen
  20.     if chars(s, i, i) = dir_sep then
  21.       set ac_cnt to ac_cnt + 1
  22.       if ac_cnt = cnt then
  23.         set szstr to chars(s, 1, i)
  24.         set v_frompath to chars(s, i + 1, length(s))
  25.         exit repeat
  26.       end if
  27.     end if
  28.   end repeat
  29.   if fl_search = "CIRCLE" then
  30.     set up_l to up_cload
  31.   else
  32.     set up_l to up_load
  33.   end if
  34.   if szstr = up_l then
  35.     return EMPTY
  36.   else
  37.     return szstr
  38.   end if
  39. end
  40.  
  41. on calccolold calcsound
  42.   global namepause
  43.   set tmpstr to filenameMAC(calcsound)
  44.   if tmpstr <> namepause then
  45.     set cic to charToNum(chars(tmpstr, 1, 1))
  46.     if cic >= 96 then
  47.       set cic to cic - 32
  48.     end if
  49.     set TCol to 0
  50.     if (cic >= 65) and (cic <= (65 + 2)) then
  51.       set TCol to 138
  52.     end if
  53.     if (cic >= 68) and (cic <= (68 + 2)) then
  54.       set TCol to 131
  55.     end if
  56.     if (cic >= 71) and (cic <= (71 + 2)) then
  57.       set TCol to 32
  58.     end if
  59.     if (cic >= 74) and (cic <= (74 + 2)) then
  60.       set TCol to 27
  61.     end if
  62.     if (cic >= 77) and (cic <= (77 + 2)) then
  63.       set TCol to 124
  64.     end if
  65.     if (cic >= 80) and (cic <= (80 + 2)) then
  66.       set TCol to 125
  67.     end if
  68.     if (cic >= 83) and (cic <= (83 + 2)) then
  69.       set TCol to 217
  70.     end if
  71.     if (cic >= 85) and (cic <= (85 + 2)) then
  72.       set TCol to 214
  73.     end if
  74.     if (cic >= 88) and (cic <= (88 + 2)) then
  75.       set TCol to 234
  76.     end if
  77.     if (cic >= 91) and (cic <= (91 + 2)) then
  78.       set TCol to 3
  79.     end if
  80.     if (cic >= 94) and (cic <= (94 + 2)) then
  81.       set TCol to 65
  82.     end if
  83.   else
  84.     set TCol to 255
  85.   end if
  86.   return TCol
  87. end
  88.  
  89. on calccol calcsound
  90.   global namepause
  91.   set tmpstr to filenameMAC(calcsound)
  92.   if tmpstr <> namepause then
  93.     set found to 0
  94.     repeat while 1
  95.       set cic to random(24)
  96.       if cic = 1 then
  97.         set TCol to 27
  98.       end if
  99.       if cic = 2 then
  100.         set TCol to 35
  101.       end if
  102.       if cic = 3 then
  103.         set TCol to 48
  104.       end if
  105.       if cic = 4 then
  106.         set TCol to 65
  107.       end if
  108.       if cic = 5 then
  109.         set TCol to 94
  110.       end if
  111.       if cic = 6 then
  112.         set TCol to 98
  113.       end if
  114.       if cic = 7 then
  115.         set TCol to 123
  116.       end if
  117.       if cic = 8 then
  118.         set TCol to 118
  119.       end if
  120.       if cic = 9 then
  121.         set TCol to 128
  122.       end if
  123.       if cic = 10 then
  124.         set TCol to 138
  125.       end if
  126.       if cic = 11 then
  127.         set TCol to 149
  128.       end if
  129.       if cic = 12 then
  130.         set TCol to 131
  131.       end if
  132.       if cic = 13 then
  133.         set TCol to 155
  134.       end if
  135.       if cic = 14 then
  136.         set TCol to 162
  137.       end if
  138.       if cic = 15 then
  139.         set TCol to 167
  140.       end if
  141.       if cic = 16 then
  142.         set TCol to 184
  143.       end if
  144.       if cic = 17 then
  145.         set TCol to 205
  146.       end if
  147.       if cic = 18 then
  148.         set TCol to 217
  149.       end if
  150.       if cic = 19 then
  151.         set TCol to 239
  152.       end if
  153.       if cic = 20 then
  154.         set TCol to 246
  155.       end if
  156.       if cic = 21 then
  157.         set TCol to 251
  158.       end if
  159.       if cic = 22 then
  160.         set TCol to 125
  161.       end if
  162.       if cic = 23 then
  163.         set TCol to 18
  164.       end if
  165.       if cic = 24 then
  166.         set TCol to 56
  167.       end if
  168.       repeat with i = 1 to 24
  169.         set vcol to value(Ar1col(mget, i))
  170.         if vcol = TCol then
  171.           set found to 0
  172.           exit repeat
  173.         end if
  174.         if i = 24 then
  175.           set found to 1
  176.         end if
  177.       end repeat
  178.       if found = 1 then
  179.         exit repeat
  180.       end if
  181.     end repeat
  182.   else
  183.     set TCol to 255
  184.   end if
  185.   return TCol
  186. end
  187.  
  188. on calcsize psize, tmp_qua
  189.   global circle_qua
  190.   if the paramCount < 2 then
  191.     if circle_qua = "16" then
  192.       set psize to psize
  193.       set s_rat to 44100
  194.     else
  195.       set s_rat to 22050
  196.     end if
  197.   else
  198.     if tmp_qua = "16" then
  199.       set psize to psize
  200.       set s_rat to 44100
  201.     else
  202.       set s_rat to 22050
  203.     end if
  204.   end if
  205.   set tmpsize to psize
  206.   set minsize to tmpsize / (s_rat * 60)
  207.   set m to lzero(minsize)
  208.   set deltasize to tmpsize mod (s_rat * 60)
  209.   set secsize to deltasize / s_rat
  210.   if the paramCount < 2 then
  211.     set s to lzero(secsize)
  212.   else
  213.     set s to string(secsize)
  214.   end if
  215.   set deltasize to tmpsize mod s_rat
  216.   set msecsize to deltasize / float(s_rat)
  217.   set ms to string(msecsize)
  218.   if chars(ms, 1, 2) = "0." then
  219.     set ms to chars(ms, 3, 5)
  220.   end if
  221.   if length(ms) = 1 then
  222.     set ms to ms & "0"
  223.   end if
  224.   if length(ms) = 2 then
  225.     set ms to ms & "0"
  226.   end if
  227.   if the paramCount < 2 then
  228.     return m & ":" & s & ":" & ms
  229.   else
  230.     return s & ":" & chars(ms, 1, 2)
  231.   end if
  232. end
  233.  
  234. on alertrd texte, textg, wait
  235.   global fcommand, spritecount, up_lang
  236.   sprite_save(47)
  237.   sprite_save(48)
  238.   set the castNum of sprite 47 to the number of cast "WINMSG"
  239.   set the ink of sprite 47 to 0
  240.   sprite_show(47, 235, 250)
  241.   puppetTransition(9, 1, 5)
  242.   if up_lang = 1 then
  243.     put texte into field "MSGTXT"
  244.   else
  245.     put textg into field "MSGTXT"
  246.   end if
  247.   setfont("MSGTXT")
  248.   set the castNum of sprite 48 to the number of cast "MSGTXT"
  249.   set the ink of sprite 48 to 1
  250.   set the editableText of sprite 48 to 0
  251.   setfont("MSGTXT")
  252.   sprite_show(48, 110, 220)
  253.   updateStage()
  254.   if wait <> 1 then
  255.     repeat while the mouseDown
  256.       nothing()
  257.     end repeat
  258.     repeat while 1
  259.       if the mouseDown then
  260.         exit repeat
  261.       end if
  262.     end repeat
  263.     alertrdremove()
  264.   end if
  265. end
  266.  
  267. on alertrdremove
  268.   global spritecount
  269.   puppetTransition(10, 1, 5)
  270.   sprite_blank(47)
  271.   sprite_blank(48)
  272.   updateStage()
  273.   sprite_rest()
  274.   sprite_rest()
  275. end
  276.  
  277. on lzero val
  278.   set ts to string(val)
  279.   if length(ts) < 2 then
  280.     set ts to "0" & ts
  281.   end if
  282.   return ts
  283. end
  284.  
  285. on lzero2 val
  286.   set ts to string(val)
  287.   if length(ts) < 2 then
  288.     set ts to "0" & ts
  289.   end if
  290.   if length(ts) < 3 then
  291.     set ts to "0" & ts
  292.   end if
  293.   return ts
  294. end
  295.  
  296. on isdemo
  297.   global demo
  298.   if demo then
  299.     alertrd(" This demo version does not support this function.", " Diese Funktion ist in dieser Demoversion nicht implementiert.")
  300.     return 1
  301.   else
  302.     return 0
  303.   end if
  304. end
  305.  
  306. on isdemosegs demoval
  307.   global demo, demosegs
  308.   if demoval <= demosegs then
  309.     return 0
  310.   else
  311.     alertrd(" This Demoversion supports only 12 elements.", "Diese Demoversion verarbeitet nur 12 Elemente")
  312.     return 1
  313.   end if
  314. end
  315.  
  316. on demobit
  317.   global demo
  318.   if not demo then
  319.     return 0
  320.   else
  321.     cur_on()
  322.     alertrd(" This Demoversion supports only 8 Bit Sounds.", "Diese Demoversion verarbeitet nur 8 Bit Sounds")
  323.     return 1
  324.   end if
  325. end
  326.  
  327. on demowin qsw
  328.   global fcommand, spritecount, up_lang, idsw
  329.   sprite_save(47)
  330.   sprite_save(48)
  331.   cur_on()
  332.   set text to "This is a DEMO version of Circle Elements."
  333.   set the castNum of sprite 47 to the number of cast "DEMOWINR"
  334.   set the ink of sprite 47 to 32
  335.   sprite_show(47, 235, 243)
  336.   if qsw <> 1 then
  337.     if up_lang = 1 then
  338.       set wincast to "DEMOE"
  339.     else
  340.       set wincast to "DEMOG"
  341.       if idsw then
  342.         set wincast to "DEMOID"
  343.       end if
  344.     end if
  345.   else
  346.     if up_lang = 1 then
  347.       set wincast to "QUITTXE"
  348.     else
  349.       set wincast to "QUITTXG"
  350.     end if
  351.   end if
  352.   puppetTransition(9, 1, 5)
  353.   put text into field "MSGTXT"
  354.   set the castNum of sprite 48 to the number of cast wincast
  355.   set the ink of sprite 48 to 1
  356.   setfont(wincast)
  357.   set the editableText of sprite 48 to 0
  358.   if qsw = 0 then
  359.     if the machineType = 256 then
  360.       set the textSize of field wincast to 12
  361.       set the textHeight of field wincast to 14
  362.     else
  363.       set the textSize of field wincast to 12
  364.       set the textHeight of field wincast to 14
  365.     end if
  366.   else
  367.     if the machineType = 256 then
  368.       set the textSize of field wincast to 12
  369.       set the textHeight of field wincast to 14
  370.     else
  371.       set the textSize of field wincast to 12
  372.       set the textHeight of field wincast to 14
  373.     end if
  374.   end if
  375.   sprite_show(48, 30, 80)
  376.   updateStage()
  377.   if qsw = 1 then
  378.     set showwalk to 1
  379.     repeat while 1
  380.       if the mouseDown then
  381.         exit repeat
  382.       end if
  383.       WALK(mnew, showwalk)
  384.       updateStage()
  385.       set showwalk to showwalk + 1
  386.       if showwalk = 13 then
  387.         set showwalk to 1
  388.       end if
  389.     end repeat
  390.     WALK(mrelease)
  391.   end if
  392.   repeat while the mouseDown
  393.     nothing()
  394.   end repeat
  395.   if qsw = 0 then
  396.     repeat while 1
  397.       if the mouseDown then
  398.         exit repeat
  399.       end if
  400.     end repeat
  401.   end if
  402.   alertrdremove()
  403. end
  404.  
  405. on getmix_area dummy
  406.   global getmix_inst, ltl_len, ltl_time, ltl_scast, ltl_mix
  407.   set mixstart to 0
  408.   set slash to 0
  409.   repeat with i = getmix_inst to 12
  410.     if slash > 0 then
  411.       if getAt(ltl_mix, i) = "-" then
  412.         set slash to slash + 1
  413.       else
  414.         set s to string(mixstart) & "-" & string(mixstart + (slash - 1))
  415.         return s
  416.       end if
  417.     end if
  418.     if getAt(ltl_mix, i) = "M" then
  419.       set mixstart to i
  420.       set slash to slash + 1
  421.     end if
  422.   end repeat
  423.   return EMPTY
  424. end
  425.  
  426. on getmix_idx ac_inst
  427.   global getmix_inst, ltl_len, ltl_time, ltl_scast, ltl_mix
  428.   repeat with i = ac_inst to 12
  429.     if getAt(ltl_mix, i) = "M" then
  430.       set getmix_inst to i + 1
  431.       return i
  432.     end if
  433.   end repeat
  434.   return 0
  435. end
  436.  
  437. on chkmix_idx ac_inst
  438.   global getmix_inst, ltl_len, ltl_time, ltl_scast, ltl_mix
  439.   repeat with i = ac_inst to 12
  440.     if getAt(ltl_mix, i) = "M" then
  441.       return i
  442.     end if
  443.   end repeat
  444.   return 0
  445. end
  446.  
  447. on chkfn s
  448.   set sz to trim(s)
  449.   if the machineType = 256 then
  450.     repeat with i = 1 to 10
  451.       if i > 9 then
  452.         return 0
  453.       end if
  454.       if not (chars(sz, i, i) = EMPTY) then
  455.         set cn to charToNum(chars(sz, i, i))
  456.         if cn < 48 then
  457.           return 0
  458.         end if
  459.         if not (cn < 58) then
  460.           if cn < 65 then
  461.             return 0
  462.           end if
  463.           if not (cn < 91) then
  464.             if cn < 95 then
  465.               return 0
  466.             end if
  467.             if not (cn < 96) then
  468.               if cn < 97 then
  469.                 return 0
  470.               end if
  471.               if not (cn < 123) then
  472.                 return 0
  473.               end if
  474.             end if
  475.           end if
  476.         end if
  477.         next repeat
  478.       end if
  479.       if i = 1 then
  480.         return 0
  481.       end if
  482.       return 1
  483.     end repeat
  484.   else
  485.     repeat with i = 1 to 21
  486.       if i > 20 then
  487.         return 0
  488.       end if
  489.       if not (chars(sz, i, i) = EMPTY) then
  490.         next repeat
  491.       end if
  492.       if i = 1 then
  493.         return 0
  494.       end if
  495.       return 1
  496.     end repeat
  497.   end if
  498. end
  499.  
  500. on chkfexist s
  501.   global up_save, up_csave, fl_search
  502.   if fl_search = "CIRCLE" then
  503.     set up_s to up_csave
  504.   else
  505.     set up_s to up_save
  506.   end if
  507.   set fn to up_s & s
  508.   set file to FileIO(mnew, "read", fn)
  509.   if not objectp(file) then
  510.     return 1
  511.   else
  512.     file(mdispose)
  513.     return 0
  514.   end if
  515. end
  516.  
  517. on doesfexist s
  518.   global FileIO
  519.   set file to FileIO(mnew, "read", s)
  520.   if not objectp(file) then
  521.     return 0
  522.   else
  523.     file(mdispose)
  524.     return 1
  525.   end if
  526. end
  527.  
  528. on chkfis s
  529.   set file to FileIO(mnew, "read", s)
  530.   if not objectp(file) then
  531.     return 0
  532.   else
  533.     file(mdispose)
  534.     return 1
  535.   end if
  536. end
  537.  
  538. on sprite_save no
  539.   global nn_sprite, Sp_idx, Sp_cast, Sp_locH, Sp_locV, Sp_ink, Sp_visib, Sp_name, Sp_fore, Sp_back, Sp_stch, Sp_stcv
  540.   set testcast to the castNum of sprite no
  541.   if testcast > 0 then
  542.     setAt(Sp_idx, nn_sprite, no)
  543.     setAt(Sp_cast, nn_sprite, the castNum of sprite no)
  544.     setAt(Sp_name, nn_sprite, the name of cast the castNum of sprite no)
  545.     setAt(Sp_locH, nn_sprite, the locH of sprite no)
  546.     setAt(Sp_locV, nn_sprite, the locV of sprite no)
  547.     setAt(Sp_ink, nn_sprite, the ink of sprite no)
  548.     setAt(Sp_visib, nn_sprite, the visible of sprite no)
  549.     setAt(Sp_fore, nn_sprite, the foreColor of sprite no)
  550.     setAt(Sp_back, nn_sprite, the backColor of sprite no)
  551.     set nn_sprite to nn_sprite + 1
  552.     sprite_blank(no)
  553.   else
  554.   end if
  555. end
  556.  
  557. on sprite_rest
  558.   global nn_sprite, Sp_idx, Sp_cast, Sp_locH, Sp_locV, Sp_ink, Sp_visib, Sp_name, Sp_fore, Sp_back, Sp_stch, Sp_stcv
  559.   if (nn_sprite - 1) > 0 then
  560.     set nn_sprite to nn_sprite - 1
  561.     set nn to getAt(Sp_idx, nn_sprite)
  562.     set the castNum of sprite nn to the number of cast getAt(Sp_name, nn_sprite)
  563.     set the locH of sprite nn to getAt(Sp_locH, nn_sprite)
  564.     set the locV of sprite nn to getAt(Sp_locV, nn_sprite)
  565.     set the ink of sprite nn to getAt(Sp_ink, nn_sprite)
  566.     set the visible of sprite nn to getAt(Sp_visib, nn_sprite)
  567.     set the foreColor of sprite nn to getAt(Sp_fore, nn_sprite)
  568.     set the backColor of sprite nn to getAt(Sp_back, nn_sprite)
  569.     puppetSprite(nn, 1)
  570.   end if
  571. end
  572.  
  573. on sprite_allsave
  574.   repeat with i = 1 to 48
  575.     sprite_save(i)
  576.   end repeat
  577. end
  578.  
  579. on sprite_allrest
  580.   repeat with i = 1 to 48
  581.     sprite_rest()
  582.   end repeat
  583. end
  584.  
  585. on sprite_blank no
  586.   set the locH of sprite no to 1500
  587.   set the locV of sprite no to 1500
  588.   set the visible of sprite no to 0
  589. end
  590.  
  591. on sprite_show no, x, y
  592.   set the locH of sprite no to x
  593.   set the locV of sprite no to y
  594.   set the visible of sprite no to 1
  595. end
  596.  
  597. on macstripcrtlchars varpsound
  598.   set psound to string(varpsound)
  599.   set retstr to EMPTY
  600.   set sndlen to length(psound)
  601.   repeat with i = sndlen down to 1
  602.     set cnum to charToNum(chars(psound, i, i))
  603.     if cnum > 32 then
  604.       if cnum < 200 then
  605.         if cnum <> 58 then
  606.           exit repeat
  607.         end if
  608.       end if
  609.     end if
  610.   end repeat
  611.   repeat with j = 1 to sndlen
  612.     set cnum to charToNum(chars(psound, j, j))
  613.     if cnum > 32 then
  614.       if cnum < 200 then
  615.         exit repeat
  616.       end if
  617.     end if
  618.   end repeat
  619.   repeat with k = 1 to sndlen
  620.     set cnum to charToNum(chars(psound, k, k))
  621.     if cnum < 32 then
  622.       exit repeat
  623.       next repeat
  624.     end if
  625.     if cnum > 200 then
  626.       exit repeat
  627.     end if
  628.   end repeat
  629.   set retstr to chars(psound, j, k - 1)
  630.   put "macstrip>" & string(length(retstr)) & "< >" & retstr & "<"
  631.   return retstr
  632. end
  633.  
  634. on stripcrtlchars psound
  635.   set sndlen to length(psound)
  636.   if chars(psound, sndlen, sndlen) < " " then
  637.     set psound to chars(psound, 1, sndlen - 1)
  638.   end if
  639.   return psound
  640. end
  641.  
  642. on cur_on
  643.   global my_cursor, my_cursor_on, my_cursor_busy
  644.   if not (my_cursor = my_cursor_on) then
  645.     cursor(my_cursor_on)
  646.     set my_cursor to my_cursor_on
  647.   end if
  648. end
  649.  
  650. on cur_busy
  651.   global my_cursor, my_cursor_on, my_cursor_busy
  652.   if not (my_cursor = my_cursor_busy) then
  653.     cursor(my_cursor_busy)
  654.     set my_cursor to my_cursor_busy
  655.   end if
  656. end
  657.  
  658. on calcticks time
  659.   global circle_qua, ticks_ps
  660.   set the floatPrecision to 16
  661.   set ss to float(time)
  662.   if circle_qua = "16" then
  663.     set sample_rate to 44100
  664.   else
  665.     set sample_rate to 22050
  666.   end if
  667.   set waittime to float(ss / sample_rate * ticks_ps)
  668.   return waittime
  669. end
  670.  
  671. on get_randfnmx leadname
  672.   global up_save, up_temp
  673.   repeat while 1
  674.     set fn to leadname & fncnt()
  675.     if the machineType = 256 then
  676.       set dest to up_temp & fn & ".WAV"
  677.     else
  678.       set dest to up_temp & fn & ".AIF"
  679.     end if
  680.     if chkfexist(dest) then
  681.       exit repeat
  682.     end if
  683.   end repeat
  684.   return dest
  685. end
  686.  
  687. on fncnt
  688.   global up_svcnt, up_rncnt
  689.   set up_svcnt to up_svcnt + 1
  690.   if up_svcnt > 999 then
  691.     set up_svcnt to 0
  692.   end if
  693.   set name to lzero2(up_rncnt) & lzero2(up_svcnt)
  694.   set up_svcnt to up_svcnt + 1
  695.   if up_svcnt > 999 then
  696.     set up_svcnt to 0
  697.   end if
  698.   return name
  699. end
  700.  
  701. on backpath s
  702.   global dir_sep
  703.   set slen to length(string(s))
  704.   set chkchar to dir_sep
  705.   repeat with i = slen - 1 down to 1
  706.     if chars(s, i, i) = chkchar then
  707.       return chars(s, 1, i)
  708.     end if
  709.   end repeat
  710.   return EMPTY
  711. end
  712.  
  713. on setfont fnfield
  714.   if the machineType = 256 then
  715.     set the textFont of field fnfield to "ARIAL"
  716.     set the textStyle of field fnfield to "bold"
  717.   else
  718.     set the textFont of field fnfield to "CHICAGO"
  719.     set the textStyle of field fnfield to "plain"
  720.   end if
  721. end
  722.