home *** CD-ROM | disk | FTP | other *** search
/ Dave Lowe: Spawn SNES Backup Files Samples / Lowe_SpawnSNESBackupFilesSamples.img / PATTSBIN.BAS < prev    next >
Encoding:
BASIC Source File  |  1994-09-16  |  2.6 KB  |  117 lines

  1.               
  2.  
  3.         REM      currently converting snes spawn1sn.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/snes/spawnfx.bin" FOR BINARY AS #2
  41.         OPEN "c:/martin/snes/spawn1sn.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.  
  49.         
  50.  
  51.         PRINT "                 creating pattern no. "; a
  52.         a = a * 2:       REM index into word table
  53.         GET #1, 5, x:     REM length of voices
  54.        
  55.  
  56.         GOSUB splitt: x = t
  57.        
  58.        
  59.         x = x + 20:    REM x = start of sub table
  60.         temp = x:        REM store in temp
  61.        
  62.        
  63.         GET #1, 7, x:
  64.        
  65.        
  66.         GOSUB splitt: y = t
  67.         temp1 = temp + y:       REM temp1 = start of subroutines
  68.         x = temp + a:      REM x = pointer to sub offset in table
  69.         x = x + 1
  70.         GET #1, x, p
  71.         x = p: GOSUB splitt: p = t
  72.         p = p + temp1:       REM actual pattern offset
  73.         p = p + 1:              REM this stupid basic cant do zeros
  74.         g = g + 2:       REM step over patt number
  75.  
  76. readloop:
  77.         GET #2, g, a
  78.         GOSUB split
  79.         PUT #1, p, a:            REM   write note and duration to file
  80.         IF note = -1 THEN GOTO endpatt
  81.         p = p + 2
  82.         g = g + 2
  83.         GOTO readloop:
  84.  
  85. endpatt:
  86.         g = g + 2
  87.         GOTO nextpatt
  88.  
  89. endpatts:               : REM end of all patterns
  90.  
  91.         CLOSE
  92.        
  93.         PRINT "                 All patterns converted  "
  94.  
  95.         END
  96.        
  97.         REM ***************  SUBROUTINES ***************
  98.        
  99.         REM input word value output switches high/low
  100. split:
  101.         dur = a / 256: note = a - (256 * dur)
  102.        
  103.         RETURN
  104.       
  105.  
  106. splitt:
  107.  
  108.         t = x
  109.         hi = INT(t / 256): low = t - (256 * hi)
  110.         t = hi * 256 + low
  111.         RETURN
  112.  
  113.         REM-----------------------------------------------
  114.  
  115.  
  116.  
  117.