home *** CD-ROM | disk | FTP | other *** search
/ Dave Lowe: Disk Number 4 / Lowe_DiskNumber4.img / PATT2BIN.BAS < prev    next >
Encoding:
BASIC Source File  |  1994-09-05  |  2.6 KB  |  109 lines

  1.               
  2.  
  3.         REM      currently converting spawn5.snd
  4.  
  5.         REM      PRESS F5 TO CONVERT PATTERNS
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.                 COMMON c AS INTEGER
  22.                 COMMON b AS INTEGER
  23.                 COMMON a AS INTEGER
  24.                 COMMON dur AS INTEGER
  25.                 COMMON note AS INTEGER
  26.                 COMMON p AS INTEGER
  27.                 COMMON g AS INTEGER
  28.                 COMMON x AS INTEGER
  29.                 COMMON y AS INTEGER
  30.                 COMMON hi AS LONG
  31.                 COMMON lo AS LONG
  32.                 COMMON t AS LONG
  33.                 COMMON temp AS INTEGER
  34.                 COMMON temp1 AS INTEGER
  35.                 pattlen = 128
  36.        
  37.        
  38.         CLS
  39.         g = 1: REM, start pos to read in file
  40.         OPEN "c:/martin/megadriv/spawn/spawn.bin" FOR BINARY AS #2
  41.         OPEN "c:/martin/megadriv/spawn/spawn5.snd" FOR BINARY AS #1
  42.        
  43.        
  44. nextpatt:
  45.         GET #2, g, a:    REM  which pattern number to create
  46.         IF a = 255 THEN GOTO endpatts
  47.        
  48.         PRINT "                 creating pattern no. "; a
  49.         a = a * 2:       REM index into word table
  50.         GET #1, 1, x:     REM length of voices
  51.         GOSUB splitt: x = t
  52.         x = x + 12:    REM x = start of sub table
  53.         temp = x:        REM store in temp
  54.         GET #1, 3, x:
  55.         GOSUB splitt: y = t
  56.         temp1 = temp + y:       REM temp1 = start of subroutines
  57.         x = temp + a:      REM x = pointer to sub offset in table
  58.         x = x + 1
  59.         GET #1, x, p
  60.         x = p: GOSUB splitt: p = t
  61.         p = p + temp1:       REM actual pattern offset
  62.         p = p + 1:              REM this stupid basic cant do zeros
  63.         g = g + 2:       REM step over patt number
  64.  
  65. readloop:
  66.         GET #2, g, a
  67.         GOSUB split
  68.         PUT #1, p, a:            REM   write note and duration to file
  69.         IF note = -1 THEN GOTO endpatt
  70.         p = p + 2
  71.         g = g + 2
  72.         GOTO readloop:
  73.  
  74. endpatt:
  75.         g = g + 2
  76.         GOTO nextpatt
  77.  
  78. endpatts:               : REM end of all patterns
  79.  
  80.         CLOSE
  81.        
  82.         PRINT "                 All patterns converted  "
  83.  
  84.         END
  85.        
  86.         REM ***************  SUBROUTINES ***************
  87.        
  88.         REM input word value output switches high/low
  89. split:
  90.         dur = a / 256: note = a - (256 * dur)
  91.        
  92.         RETURN
  93.       
  94.  
  95. splitt:
  96.        
  97.         IF x < 0 THEN
  98.         t = 65536 + x
  99.         ELSE t = x
  100.         END IF
  101.         hi = INT(t / 256): lo = t - (256 * hi)
  102.         t = lo * 256 + hi
  103.         RETURN
  104.  
  105.         REM-----------------------------------------------
  106.  
  107.  
  108.  
  109.