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

  1. on newseg track, pos, len, col, cast, idx
  2.   global maxsegs, objectCount, theObjects
  3.   if objectCount < maxsegs then
  4.     set objectCount to objectCount + 1
  5.     theObjects(mput, objectCount, SEGMENTS(mnew, track, pos, len, col, cast, idx))
  6.     return 1
  7.   else
  8.     alert("No more free casts !")
  9.     return 0
  10.   end if
  11. end
  12.  
  13. on displaysegs
  14.   global gTrack, gPos, GLen, gcast, gXp, gYp, vTSprite, stepaction, sel_idx, objectCount, theObjects, minsegs, maxsegs, segsprite, segcurrent, firstsound
  15.   if objectp(theObjects) = 0 then
  16.     exit
  17.   end if
  18.   repeat with i = minsegs + 1 to objectCount
  19.     set ithObject to theObjects(mget, i)
  20.     if objectp(ithObject) then
  21.       ithObject(mrelease)
  22.       ithObject(mdispose)
  23.     end if
  24.   end repeat
  25.   set objectCount to minsegs
  26.   set i to 1
  27.   repeat with i = 1 to 24
  28.     if AR1idx(mget, i) > 0 then
  29.       if i > 12 then
  30.         set track to 2
  31.         set s to "2"
  32.       else
  33.         set track to 1
  34.         set s to "1"
  35.       end if
  36.       set pos to ar1pos(mget, i)
  37.       set len to ar1seg(mget, i)
  38.       getsegment(track, pos, len)
  39.       newseg(gTrack, gPos, GLen, Ar1col(mget, i), gcast, i)
  40.     end if
  41.   end repeat
  42.   timeline(sel_idx)
  43. end
  44.  
  45. on getsegment track, pos, len
  46.   global gTrack, gPos, GLen, gcast, gXp, gYp, sl_str, sl_x, sl_y
  47.   if track = 2 then
  48.     set str to "2"
  49.   else
  50.     set str to "1"
  51.   end if
  52.   set str to str & lzero(integer(value(pos)))
  53.   set str to str & lzero(integer(value(len)))
  54.   if not (length(str) >= 5) then
  55.     set str to lzero(integer(value(str)))
  56.   end if
  57.   set chk_sl to getPos(sl_str, str)
  58.   if chk_sl = 0 then
  59.     alertrd("ELEMENT >" & string(tmp) & "< not in list T>" & string(track) & "<P>" & string(pos) & "<L>" & string(len) & "<STR>" & str & "<", "ELEMENT >" & string(tmp) & "< not in list T>" & string(track) & "<P>" & string(pos) & "<L>" & string(len) & "<STR>" & str & "<")
  60.   else
  61.     set gTrack to value(chars(str, 1, 1))
  62.     set gPos to value(chars(str, 2, 3))
  63.     set GLen to value(chars(str, 4, 5))
  64.     set gcast to chars(str, 1, 5)
  65.     set gXp to getAt(sl_x, chk_sl)
  66.     set gYp to getAt(sl_y, chk_sl)
  67.   end if
  68. end
  69.  
  70. on sl_create
  71.   global sl_str, sl_x, sl_y
  72.   set sl_str to []
  73.   set sl_x to []
  74.   set sl_y to []
  75.   set lin to 0
  76.   set s to EMPTY
  77.   repeat while 1
  78.     set s to line lin of field "TSEG"
  79.     if s = "END" then
  80.       exit repeat
  81.     end if
  82.     if chars(s, 1, 1) <> "-" then
  83.       append(sl_str, chars(s, 1, 5))
  84.       append(sl_x, value(chars(s, 6, 8)))
  85.       append(sl_y, value(chars(s, 9, 11)))
  86.     end if
  87.     set lin to lin + 1
  88.   end repeat
  89. end
  90.  
  91. on sl_search pos
  92.   global ltl_len, ltl_time, ltl_scast
  93.   set ret_time to 0
  94.   repeat with i = pos to 12
  95.     set ret_time to ret_time + getAt(ltl_time, i)
  96.   end repeat
  97.   return ret_time
  98. end
  99.