home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Aktief 1995 #3 / CDA3.iso / sound / tnypl211.zip / MODPLAY.ASM < prev    next >
Assembly Source File  |  1994-06-21  |  63KB  |  2,097 lines

  1. ;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  2. ;                Tiny MOD Player for Watcom C/C++32 and DOS/4GW
  3. ;                      Version 2.11a  June 5th, 1994
  4. ;
  5. ;                      Copyright 1993,94 Carlos Hasan
  6. ;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  7.  
  8. ideal
  9. p386
  10. model   flat,c
  11. smart
  12.  
  13. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  14. ; EQUATES AND PUBLICS
  15. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  16.  
  17. MAXVOICES = 8                           ; number of voices
  18. DMABUFLEN = 1024                        ; DMA buffer length (multiple of 64)
  19. VOLBUFLEN = 66*256                      ; volume table length
  20. MIXBUFLEN = 2*DMABUFLEN+2048            ; mixing/boosting buffer length
  21. TIMERRATE = 17000                       ; timer interrupt rate in ticks
  22.  
  23. global  MODPlayModule:proc
  24. global  MODStopModule:proc
  25. global  MODPlaySample:proc
  26. global  MODStopSample:proc
  27. global  MODSetPeriod:proc
  28. global  MODSetVolume:proc
  29. global  MODSetMusicVolume:proc
  30. global  MODSetSampleVolume:proc
  31. global  MODDetectCard:proc
  32. global  MODPoll:proc
  33. global  MODVoiceTable:dword
  34.  
  35. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  36. ; STRUCTURES
  37. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  38.  
  39. struc   module                          ; module structure
  40.   numtracks     dw      ?               ; number of tracks
  41.   orderlen      dw      ?               ; order length
  42.   orders        db      128 dup (?)     ; order list
  43.   patterns      dd      128 dup (?)     ; pattern addresses
  44.   sampptr       dd      32 dup (?)      ; sample start addresses
  45.   sampend       dd      32 dup (?)      ; sample end addresses
  46.   samploop      dd      32 dup (?)      ; sample loop point addresses
  47.   sampvolume    db      32 dup (?)      ; sample default volumes
  48. ends    module
  49.  
  50. struc   sample                          ; sample structure
  51.   period        dw      ?               ; default period
  52.   volume        dw      ?               ; default volume
  53.   datalen       dd      ?               ; sample data length
  54.   dataptr       dd      ?               ; sample data address
  55. ends    sample
  56.  
  57. struc   track                           ; track structure
  58.   note          dw      ?               ; note index
  59.   period        dw      ?               ; period value
  60.   inst          db      ?               ; instrument
  61.   volume        db      ?               ; volume
  62.   effect        dw      ?               ; effect
  63.   destperiod    dw      ?               ; toneporta wanted period
  64.   tonespeed     db      ?               ; toneporta speed
  65.   vibparm       db      ?               ; vibrato depth/rate
  66.   vibpos        db      ?               ; vibrato wave position
  67.   tremparm      db      ?               ; tremolo depth/rate
  68.   trempos       db      ?               ; tremolo wave position
  69.                 db      ?               ; alignment
  70.   arptable      dw      3 dup (?)       ; arpeggio periods
  71. ends    track
  72.  
  73. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  74. ; DATA
  75. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  76.  
  77. ;░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒
  78. ; Module Player data
  79. ;░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒
  80. udataseg
  81.  
  82. moduleptr       dd      ?               ; current module address
  83. pattptr         dd      ?               ; current playing pattern address
  84. orderpos        db      ?               ; order position
  85. orderlen        db      ?               ; order length
  86. pattrow         db      ?               ; pattern row
  87. tempo           db      ?               ; tempo
  88. tempocount      db      ?               ; tempo counter
  89. bpm             db      ?               ; beats per minute
  90. musicvolume     db      ?               ; music channels volume
  91. samplevolume    db      ?               ; sample channels volume
  92. numtracks       dw      ?               ; number of tracks
  93. tracks          track   MAXVOICES dup (?)
  94.  
  95. pitchtable      dd      3425 dup (?)    ; period to pitch table
  96.  
  97. ; Amiga period table
  98. dataseg
  99.  
  100. periodtable     dw      0
  101.                 dw      3424,3232,3048,2880,2712,2560,2416,2280,2152,2032,1920,1812
  102.                 dw      1712,1616,1524,1440,1356,1280,1208,1140,1076,1016,960,906
  103.                 dw      856,808,762,720,678,640,604,570,538,508,480,453
  104.                 dw      428,404,381,360,339,320,302,285,269,254,240,226
  105.                 dw      214,202,190,180,170,160,151,143,135,127,120,113
  106.                 dw      107,101,95,90,85,80,75,71,67,63,60,56
  107.                 dw      53,50,47,45,42,40,37,35,33,31,30,28
  108.  
  109. ; Sinus wave table
  110.  
  111. sintable        db      0,25,50,74,98,120,142,162,180,197,212,225
  112.                 db      236,244,250,254,255,254,250,244,236,225
  113.                 db      212,197,180,162,142,120,98,74,50,25
  114.  
  115. ;░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒
  116. ; Sound Blaster driver data
  117. ;░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒
  118. udataseg
  119.  
  120. ; Voices programmable parameters
  121.  
  122. label MODVoiceTable dword
  123.  
  124. voicepos        dd      MAXVOICES dup (?)
  125. voiceend        dd      MAXVOICES dup (?)
  126. voiceloop       dd      MAXVOICES dup (?)
  127. voicefrac       dd      MAXVOICES dup (?)
  128. voicepitch      dd      MAXVOICES dup (?)
  129. voicevolume     dd      MAXVOICES dup (?)
  130.  
  131. ; Internal driver data
  132. dataseg
  133.  
  134. mixbuffer       dd      ?               ; mixing buffer address
  135. boosttable      dd      ?               ; boosting table address
  136. voltable        dd      ?               ; volume table address
  137. numvoices       dw      ?               ; number of active voices
  138. mixfreq         dw      ?               ; playback frequency
  139. ioaddr          dw      ?               ; card I/O port address
  140. irqnum          db      ?               ; card IRQ level
  141. drqnum          db      ?               ; card DMA channel
  142. timerproc       dd      ?               ; timer callback address
  143. timeracc        dd      ?               ; timer callback accumulator
  144. timerspeed      dd      ?               ; timer callback speed
  145. datasel         dw      ?               ; flat model data selector
  146. bufsel          dw      ?               ; DOS memory block selector
  147. bufptr          dd      ?               ; DMA buffer address
  148. bufoff          dd      ?               ; double buffer offset
  149. oldirqoff       dd      ?               ; old IRQ vector address
  150. oldirqsel       dw      ?
  151. oldtimeroff     dd      ?               ; old timer IRQ0 vector address
  152. oldtimersel     dw      ?
  153. oldtimeracc     dw      ?               ; old timer accumulator
  154. manualmode      db      ?               ; timer/manual polling mode
  155. playing         db      0               ; playing/stopped status
  156.  
  157.  
  158. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  159. ; CODE
  160. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  161. codeseg
  162.  
  163. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  164. ; Copyright Strings
  165. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  166.  
  167. db      'Tiny MOD Player V2.11 Copyright 1993,94 Carlos Hasan',0
  168. db      'Compiled on: ',??date,' ',??time,0
  169.  
  170. ;░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒
  171. ; Module Player stuff
  172. ;░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒░▒
  173.  
  174. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  175. ; MODPlayModule - start playing a music module
  176. ; In:
  177. ;  Song  = module address
  178. ;  Chans = number of channels
  179. ;  Rate  = playback rate
  180. ;  Port  = port address
  181. ;  irq   = irq number
  182. ;  dma   = dma channel
  183. ;  mode  = polling mode
  184. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  185. proc    MODPlayModule Song:dword,Chans:dword,Rate:dword,Port:dword,IRQ:dword,DRQ:dword,Mode:dword
  186.         pushad
  187.  
  188. ; setup th