home *** CD-ROM | disk | FTP | other *** search
/ Large Pack of OldSkool DOS MOD Trackers / cdfm.zip / DFMPM.BAK < prev    next >
Text File  |  1997-07-06  |  96KB  |  2,602 lines

  1. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2. ; DFM32 PMODE 2.5 Conversion
  3. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  4.  
  5. ; Uses memory at and above 9FDD0
  6.         .386p
  7. ; SBSFXS0       = 1
  8. ; SBSFXS1       = 1
  9. ; SBSFXM0       = 1
  10. ; SBSFXM1       = 1
  11. ; FMSFX0        = 1
  12. ; FMSFX1        = 1
  13. ; PCSFX0        = 1
  14. ; PCSFX1        = 1
  15.  FMNOTE        = 1
  16.  SBNOTE        = 1
  17. ; ADJSMP        = 1
  18.  
  19. DBUFLEN         equ     380
  20. SBRATE          equ     0d2h
  21. SBPRATE         equ     0e9h
  22.  
  23. code32  segment para public use32
  24.         assume cs:code32, ds:code32, ss:code32
  25.  
  26. include pmode.inc
  27.  
  28. public  _dfmcounter, _dfmfunc, _scard, _sbirq, _sbport, _dspout
  29. public  _pcsfxtblptr, _fmsfxtblptr, _sbsfxtblptr, _sbsfxchl, _sbsfxchh
  30. public  _sbsfxch, _fmsfxchl, _fmsfxchh, _fmsfxch
  31. public  muztempo, muzordern, muzorderl, muzordptr, muzpatoffptr
  32. public  muzsbinsptr, muzfminsptr, muzpatbase, modebitmap, _voicehit
  33. public  nodetectsb
  34. public  muzorderc
  35.  
  36. public  _install_dfm, _uninstall_dfm, _detect_scard
  37. public  _stopsmp, _stopmuzik, _setmuzik, _muzik, _phademuzik, _mixahead
  38.  
  39. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  40. ; DATA
  41. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  42. sbcvol  db      -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2
  43.         db      -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2
  44.         db      -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2
  45.         db      -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2
  46.         db      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  47.         db      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  48.         db      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  49.         db      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  50.         db      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  51.         db      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  52.         db      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  53.         db      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  54.         db      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
  55.         db      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
  56.         db      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
  57.         db      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
  58.         db      -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4
  59.         db      -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4
  60.         db      -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3
  61.         db      -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3
  62.         db      -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2
  63.         db      -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2
  64.         db      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  65.         db      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  66.         db      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  67.         db      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  68.         db      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
  69.         db      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
  70.         db      2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
  71.         db      2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
  72.         db      3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
  73.         db      3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
  74.         db      -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6
  75.         db      -6, -6, -6, -6, -6, -6, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5
  76.         db      -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -4, -4, -4, -4, -4
  77.         db      -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4
  78.         db      -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3
  79.         db      -3, -3, -3, -3, -3, -3, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2
  80.         db      -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1
  81.         db      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  82.         db      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  83.         db      0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
  84.         db      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2
  85.         db      2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
  86.         db      3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
  87.         db      3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
  88.         db      4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5
  89.         db      5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
  90.         db      -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8
  91.         db      -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7
  92.         db      -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6
  93.         db      -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5
  94.         db      -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4
  95.         db      -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3
  96.         db      -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2
  97.         db      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  98.         db      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  99.         db      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
  100.         db      2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
  101.         db      3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
  102.         db      4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
  103.         db      5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
  104.         db      6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6
  105.         db      7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
  106.         db      -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -9, -9, -9
  107.         db      -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -8, -8, -8, -8, -8, -8
  108.         db      -8, -8, -8, -8, -8, -8, -8, -7, -7, -7, -7, -7, -7, -7, -7, -7
  109.         db      -7, -7, -7, -7, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6
  110.         db      -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -4, -4, -4
  111.         db      -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -3, -3, -3, -3, -3, -3
  112.         db      -3, -3, -3, -3, -3, -3, -3, -2, -2, -2, -2, -2, -2, -2, -2, -2
  113.         db      -2, -2, -2, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  114.         db      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1
  115.         db      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2
  116.         db      2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3
  117.         db      3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
  118.         db      5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6
  119.         db      6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7
  120.         db      7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8
  121.         db      8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9
  122.         db      -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -11, -11, -11, -11, -11
  123.         db      -11, -11, -11, -11, -11, -11, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10
  124.         db      -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -8, -8, -8, -8, -8
  125.         db      -8, -8, -8, -8, -8, -8, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7
  126.         db      -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -5, -5, -5, -5, -5
  127.         db      -5, -5, -5, -5, -5, -5, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4
  128.         db      -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -2, -2, -2, -2, -2
  129.         db      -2, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  130.         db      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1
  131.         db      1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
  132.         db      3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4
  133.         db      4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
  134.         db      6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7
  135.         db      7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
  136.         db      9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10
  137.         db      10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11
  138.         db      -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, -13, -13, -13, -13, -13, -13
  139.         db      -13, -13, -13, -12, -12, -12, -12, -12, -12, -12, -12, -12, -11, -11, -11, -11
  140.         db      -11, -11, -11, -11, -11, -10, -10, -10, -10, -10, -10, -10, -10, -10, -9, -9
  141.         db      -9, -9, -9, -9, -9, -9, -9, -8, -8, -8, -8, -8, -8, -8, -8, -8
  142.         db      -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -6, -6, -6, -6, -6, -6
  143.         db      -6, -6, -6, -5, -5, -5, -5, -5, -5, -5, -5, -5, -4, -4, -4, -4
  144.         db      -4, -4, -4, -4, -4, -3, -3, -3, -3, -3, -3, -3, -3, -3, -2, -2
  145.         db      -2, -2, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1
  146.         db      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1
  147.         db      1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3
  148.         db      3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5
  149.         db      5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6
  150.         db      7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8
  151.         db      8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10
  152.         db      10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12
  153.         db      12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13
  154.         db      -16, -16, -16, -16, -16, -16, -16, -16, -15, -15, -15, -15, -15, -15, -15, -15
  155.         db      -14, -14, -14, -14, -14, -14, -14, -14, -13, -13, -13, -13, -13, -13, -13, -13
  156.         db      -12, -12, -12, -12, -12, -12, -12, -12, -11, -11, -11, -11, -11, -11, -11, -11
  157.         db      -10, -10, -10, -10, -10, -10, -10, -10, -9, -9, -9, -9, -9, -9, -9, -9
  158.         db      -8, -8, -8, -8, -8, -8, -8, -8, -7, -7, -7, -7, -7, -7, -7, -7
  159.         db      -6, -6, -6, -6, -6, -6, -6, -6, -5, -5, -5, -5, -5, -5, -5, -5
  160.         db      -4, -4, -4, -4, -4, -4, -4, -4, -3, -3, -3, -3, -3, -3, -3, -3
  161.         db      -2, -2, -2, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, -1, -1, -1
  162.         db      0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1
  163.         db      2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3
  164.         db      4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5
  165.         db      6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7
  166.         db      8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9
  167.         db      10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11
  168.         db      12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13
  169.         db      14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15
  170.         db      -18, -18, -18, -18, -18, -18, -18, -18, -17, -17, -17, -17, -17, -17, -17, -16
  171.         db      -16, -16, -16, -16, -16, -16, -15, -15, -15, -15, -15, -15, -15, -14, -14, -14
  172.         db      -14, -14, -14, -14, -13, -13, -13, -13, -13, -13, -13, -12, -12, -12, -12, -12
  173.         db      -12, -12, -11, -11, -11, -11, -11, -11, -11, -10, -10, -10, -10, -10, -10, -10
  174.         db      -9, -9, -9, -9, -9, -9, -9, -9, -8, -8, -8, -8, -8, -8, -8, -7
  175.         db      -7, -7, -7, -7, -7, -7, -6, -6, -6, -6, -6, -6, -6, -5, -5, -5
  176.         db      -5, -5, -5, -5, -4, -4, -4, -4, -4, -4, -4, -3, -3, -3, -3, -3
  177.         db      -3, -3, -2, -2, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, -1, -1
  178.         db      0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2
  179.         db      2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4
  180.         db      4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6
  181.         db      6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8
  182.         db      9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 11
  183.         db      11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13
  184.         db      13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15
  185.         db      15, 15, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17
  186.         db      -20, -20, -20, -20, -20, -20, -20, -19, -19, -19, -19, -19, -19, -18, -18, -18
  187.         db      -18, -18, -18, -18, -17, -17, -17, -17, -17, -17, -16, -16, -16, -16, -16, -16
  188.         db      -15, -15, -15, -15, -15, -15, -15, -14, -14, -14, -14, -14, -14, -13, -13, -13
  189.         db      -13, -13, -13, -13, -12, -12, -12, -12, -12, -12, -11, -11, -11, -11, -11, -11
  190.         db      -10, -10, -10, -10, -10, -10, -10, -9, -9, -9, -9, -9, -9, -8, -8, -8
  191.         db      -8, -8, -8, -8, -7, -7, -7, -7, -7, -7, -6, -6, -6, -6, -6, -6
  192.         db      -5, -5, -5, -5, -5, -5, -5, -4, -4, -4, -4, -4, -4, -3, -3, -3
  193.         db      -3, -3, -3, -3, -2, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, -1
  194.         db      0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2
  195.         db      2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4
  196.         db      5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7
  197.         db      7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9
  198.         db      10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 12, 12, 12
  199.         db      12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14
  200.         db      15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 17, 17, 17
  201.         db      17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19
  202.         db      -22, -22, -22, -22, -22, -22, -21, -21, -21, -21, -21, -21, -20, -20, -20, -20
  203.         db      -20, -20, -19, -19, -19, -19, -19, -19, -18, -18, -18, -18, -18, -18, -17, -17
  204.         db      -17, -17, -17, -16, -16, -16, -16, -16, -16, -15, -15, -15, -15, -15, -15, -14
  205.         db      -14, -14, -14, -14, -14, -13, -13, -13, -13, -13, -13, -12, -12, -12, -12, -12
  206.         db      -11, -11, -11, -11, -11, -11, -10, -10, -10, -10, -10, -10, -9, -9, -9, -9
  207.         db      -9, -9, -8, -8, -8, -8, -8, -8, -7, -7, -7, -7, -7, -7, -6, -6
  208.         db      -6, -6, -6, -5, -5, -5, -5, -5, -5, -4, -4, -4, -4, -4, -4, -3
  209.         db      -3, -3, -3, -3, -3, -2, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1
  210.         db      0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2
  211.         db      2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5
  212.         db      5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8
  213.         db      8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10
  214.         db      11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13
  215.         db      13, 13, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 16, 16
  216.         db      16, 16, 16, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 19
  217.         db      19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21
  218.         db      -24, -24, -24, -24, -24, -24, -23, -23, -23, -23, -23, -22, -22, -22, -22, -22
  219.         db      -21, -21, -21, -21, -21, -21, -20, -20, -20, -20, -20, -19, -19, -19, -19, -19
  220.         db      -18, -18, -18, -18, -18, -18, -17, -17, -17, -17, -17, -16, -16, -16, -16, -16
  221.         db      -15, -15, -15, -15, -15, -15, -14, -14, -14, -14, -14, -13, -13, -13, -13, -13
  222.         db      -12, -12, -12, -12, -12, -12, -11, -11, -11, -11, -11, -10, -10, -10, -10, -10
  223.         db      -9, -9, -9, -9, -9, -9, -8, -8, -8, -8, -8, -7, -7, -7, -7, -7
  224.         db      -6, -6, -6, -6, -6, -6, -5, -5, -5, -5, -5, -4, -4, -4, -4, -4
  225.         db      -3, -3, -3, -3, -3, -3, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1
  226.         db      0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2
  227.         db      3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5
  228.         db      6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8
  229.         db      9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11
  230.         db      12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14
  231.         db      15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17
  232.         db      18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20
  233.         db      21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23
  234.         db      -26, -26, -26, -26, -26, -25, -25, -25, -25, -25, -24, -24, -24, -24, -24, -23
  235.         db      -23, -23, -23, -23, -22, -22, -22, -22, -22, -21, -21, -21, -21, -21, -20, -20
  236.         db      -20, -20, -20, -19, -19, -19, -19, -19, -18, -18, -18, -18, -18, -17, -17, -17
  237.         db      -17, -17, -16, -16, -16, -16, -16, -15, -15, -15, -15, -15, -14, -14, -14, -14
  238.         db      -13, -13, -13, -13, -13, -12, -12, -12, -12, -12, -11, -11, -11, -11, -11, -10
  239.         db      -10, -10, -10, -10, -9, -9, -9, -9, -9, -8, -8, -8, -8, -8, -7, -7
  240.         db      -7, -7, -7, -6, -6, -6, -6, -6, -5, -5, -5, -5, -5, -4, -4, -4
  241.         db      -4, -4, -3, -3, -3, -3, -3, -2, -2, -2, -2, -2, -1, -1, -1, -1
  242.         db      0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3
  243.         db      3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6
  244.         db      6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9
  245.         db      9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12
  246.         db      13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16
  247.         db      16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 19, 19
  248.         db      19, 19, 19, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 22, 22, 22
  249.         db      22, 22, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 25, 25, 25, 25
  250.         db      -28, -28, -28, -28, -28, -27, -27, -27, -27, -27, -26, -26, -26, -26, -25, -25
  251.         db      -25, -25, -25, -24, -24, -24, -24, -23, -23, -23, -23, -23, -22, -22, -22, -22
  252.         db      -21, -21, -21, -21, -21, -20, -20, -20, -20, -20, -19, -19, -19, -19, -18, -18
  253.         db      -18, -18, -18, -17, -17, -17, -17, -16, -16, -16, -16, -16, -15, -15, -15, -15
  254.         db      -14, -14, -14, -14, -14, -13, -13, -13, -13, -13, -12, -12, -12, -12, -11, -11
  255.         db      -11, -11, -11, -10, -10, -10, -10, -9, -9, -9, -9, -9, -8, -8, -8, -8
  256.         db      -7, -7, -7, -7, -7, -6, -6, -6, -6, -6, -5, -5, -5, -5, -4, -4
  257.         db      -4, -4, -4, -3, -3, -3, -3, -2, -2, -2, -2, -2, -1, -1, -1, -1
  258.         db      0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3
  259.         db      3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6
  260.         db      7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10
  261.         db      10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13
  262.         db      14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17
  263.         db      17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 19, 20, 20, 20, 20
  264.         db      21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 23, 23, 23, 23, 24, 24
  265.         db      24, 24, 24, 25, 25, 25, 25, 26, 26, 26, 26, 26, 27, 27, 27, 27
  266.         db      -30, -30, -30, -30, -30, -29, -29, -29, -29, -28, -28, -28, -28, -27, -27, -27
  267.         db      -27, -27, -26, -26, -26, -26, -25, -25, -25, -25, -24, -24, -24, -24, -23, -23
  268.         db      -23, -23, -23, -22, -22, -22, -22, -21, -21, -21, -21, -20, -20, -20, -20, -19
  269.         db      -19, -19, -19, -19, -18, -18, -18, -18, -17, -17, -17, -17, -16, -16, -16, -16
  270.         db      -15, -15, -15, -15, -15, -14, -14, -14, -14, -13, -13, -13, -13, -12, -12, -12
  271.         db      -12, -12, -11, -11, -11, -11, -10, -10, -10, -10, -9, -9, -9, -9, -8, -8
  272.         db      -8, -8, -8, -7, -7, -7, -7, -6, -6, -6, -6, -5, -5, -5, -5, -4
  273.         db      -4, -4, -4, -4, -3, -3, -3, -3, -2, -2, -2, -2, -1, -1, -1, -1
  274.         db      0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3
  275.         db      3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7
  276.         db      7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11
  277.         db      11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14
  278.         db      15, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18
  279.         db      18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22
  280.         db      22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 25, 26
  281.         db      26, 26, 26, 26, 27, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29
  282.         db      -32, -32, -32, -32, -31, -31, -31, -31, -30, -30, -30, -30, -29, -29, -29, -29
  283.         db      -28, -28, -28, -28, -27, -27, -27, -27, -26, -26, -26, -26, -25, -25, -25, -25
  284.         db      -24, -24, -24, -24, -23, -23, -23, -23, -22, -22, -22, -22, -21, -21, -21, -21
  285.         db      -20, -20, -20, -20, -19, -19, -19, -19, -18, -18, -18, -18, -17, -17, -17, -17
  286.         db      -16, -16, -16, -16, -15, -15, -15, -15, -14, -14, -14, -14, -13, -13, -13, -13
  287.         db      -12, -12, -12, -12, -11, -11, -11, -11, -10, -10, -10, -10, -9, -9, -9, -9
  288.         db      -8, -8, -8, -8, -7, -7, -7, -7, -6, -6, -6, -6, -5, -5, -5, -5
  289.         db      -4, -4, -4, -4, -3, -3, -3, -3, -2, -2, -2, -2, -1, -1, -1, -1
  290.         db      0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3
  291.         db      4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7
  292.         db      8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11
  293.         db      12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15
  294.         db      16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19
  295.         db      20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23
  296.         db      24, 24, 24, 24, 25, 25, 25, 25, 26, 26, 26, 26, 27, 27, 27, 27
  297.         db      28, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 30, 31, 31, 31, 31
  298. sbpvol  db      -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4
  299.         db      -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4
  300.         db      -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3
  301.         db      -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3
  302.         db      -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2
  303.         db      -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2
  304.         db      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  305.         db      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  306.         db      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  307.         db      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  308.         db      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
  309.         db      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
  310.         db      2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
  311.         db      2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
  312.         db      3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
  313.         db      3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
  314.         db      -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8
  315.         db      -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7
  316.         db      -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6
  317.         db      -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5
  318.         db      -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4
  319.         db      -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3
  320.         db      -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2
  321.         db      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  322.         db      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  323.         db      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
  324.         db      2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
  325.         db      3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
  326.         db      4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
  327.         db      5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
  328.         db      6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6
  329.         db      7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
  330.         db      -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -11, -11, -11, -11, -11
  331.         db      -11, -11, -11, -11, -11, -11, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10
  332.         db      -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -8, -8, -8, -8, -8
  333.         db      -8, -8, -8, -8, -8, -8, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7
  334.         db      -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -5, -5, -5, -5, -5
  335.         db      -5, -5, -5, -5, -5, -5, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4
  336.         db      -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -2, -2, -2, -2, -2
  337.         db      -2, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  338.         db      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1
  339.         db      1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
  340.         db      3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4
  341.         db      4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
  342.         db      6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7
  343.         db      7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
  344.         db      9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10
  345.         db      10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11
  346.         db      -16, -16, -16, -16, -16, -16, -16, -16, -15, -15, -15, -15, -15, -15, -15, -15
  347.         db      -14, -14, -14, -14, -14, -14, -14, -14, -13, -13, -13, -13, -13, -13, -13, -13
  348.         db      -12, -12, -12, -12, -12, -12, -12, -12, -11, -11, -11, -11, -11, -11, -11, -11
  349.         db      -10, -10, -10, -10, -10, -10, -10, -10, -9, -9, -9, -9, -9, -9, -9, -9
  350.         db      -8, -8, -8, -8, -8, -8, -8, -8, -7, -7, -7, -7, -7, -7, -7, -7
  351.         db      -6, -6, -6, -6, -6, -6, -6, -6, -5, -5, -5, -5, -5, -5, -5, -5
  352.         db      -4, -4, -4, -4, -4, -4, -4, -4, -3, -3, -3, -3, -3, -3, -3, -3
  353.         db      -2, -2, -2, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, -1, -1, -1
  354.         db      0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1
  355.         db      2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3
  356.         db      4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5
  357.         db      6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7
  358.         db      8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9
  359.         db      10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11
  360.         db      12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13
  361.         db      14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15
  362.         db      -20, -20, -20, -20, -20, -20, -20, -19, -19, -19, -19, -19, -19, -18, -18, -18
  363.         db      -18, -18, -18, -18, -17, -17, -17, -17, -17, -17, -16, -16, -16, -16, -16, -16
  364.         db      -15, -15, -15, -15, -15, -15, -15, -14, -14, -14, -14, -14, -14, -13, -13, -13
  365.         db      -13, -13, -13, -13, -12, -12, -12, -12, -12, -12, -11, -11, -11, -11, -11, -11
  366.         db      -10, -10, -10, -10, -10, -10, -10, -9, -9, -9, -9, -9, -9, -8, -8, -8
  367.         db      -8, -8, -8, -8, -7, -7, -7, -7, -7, -7, -6, -6, -6, -6, -6, -6
  368.         db      -5, -5, -5, -5, -5, -5, -5, -4, -4, -4, -4, -4, -4, -3, -3, -3
  369.         db      -3, -3, -3, -3, -2, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, -1
  370.         db      0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2
  371.         db      2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4
  372.         db      5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7
  373.         db      7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9
  374.         db      10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 12, 12, 12
  375.         db      12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14
  376.         db      15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 17, 17, 17
  377.         db      17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19
  378.         db      -24, -24, -24, -24, -24, -24, -23, -23, -23, -23, -23, -22, -22, -22, -22, -22
  379.         db      -21, -21, -21, -21, -21, -21, -20, -20, -20, -20, -20, -19, -19, -19, -19, -19
  380.         db      -18, -18, -18, -18, -18, -18, -17, -17, -17, -17, -17, -16, -16, -16, -16, -16
  381.         db      -15, -15, -15, -15, -15, -15, -14, -14, -14, -14, -14, -13, -13, -13, -13, -13
  382.         db      -12, -12, -12, -12, -12, -12, -11, -11, -11, -11, -11, -10, -10, -10, -10, -10
  383.         db      -9, -9, -9, -9, -9, -9, -8, -8, -8, -8, -8, -7, -7, -7, -7, -7
  384.         db      -6, -6, -6, -6, -6, -6, -5, -5, -5, -5, -5, -4, -4, -4, -4, -4
  385.         db      -3, -3, -3, -3, -3, -3, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1
  386.         db      0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2
  387.         db      3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5
  388.         db      6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8
  389.         db      9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11
  390.         db      12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14
  391.         db      15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17
  392.         db      18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20
  393.         db      21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23
  394.         db      -28, -28, -28, -28, -28, -27, -27, -27, -27, -27, -26, -26, -26, -26, -25, -25
  395.         db      -25, -25, -25, -24, -24, -24, -24, -23, -23, -23, -23, -23, -22, -22, -22, -22
  396.         db      -21, -21, -21, -21, -21, -20, -20, -20, -20, -20, -19, -19, -19, -19, -18, -18
  397.         db      -18, -18, -18, -17, -17, -17, -17, -16, -16, -16, -16, -16, -15, -15, -15, -15
  398.         db      -14, -14, -14, -14, -14, -13, -13, -13, -13, -13, -12, -12, -12, -12, -11, -11
  399.         db      -11, -11, -11, -10, -10, -10, -10, -9, -9, -9, -9, -9, -8, -8, -8, -8
  400.         db      -7, -7, -7, -7, -7, -6, -6, -6, -6, -6, -5, -5, -5, -5, -4, -4
  401.         db      -4, -4, -4, -3, -3, -3, -3, -2, -2, -2, -2, -2, -1, -1, -1, -1
  402.         db      0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3
  403.         db      3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6
  404.         db      7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10
  405.         db      10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13
  406.         db      14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17
  407.         db      17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 19, 20, 20, 20, 20
  408.         db      21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 23, 23, 23, 23, 24, 24
  409.         db      24, 24, 24, 25, 25, 25, 25, 26, 26, 26, 26, 26, 27, 27, 27, 27
  410.         db      -32, -32, -32, -32, -31, -31, -31, -31, -30, -30, -30, -30, -29, -29, -29, -29
  411.         db      -28, -28, -28, -28, -27, -27, -27, -27, -26, -26, -26, -26, -25, -25, -25, -25
  412.         db      -24, -24, -24, -24, -23, -23, -23, -23, -22, -22, -22, -22, -21, -21, -21, -21
  413.         db      -20, -20, -20, -20, -19, -19, -19, -19, -18, -18, -18, -18, -17, -17, -17, -17
  414.         db      -16, -16, -16, -16, -15, -15, -15, -15, -14, -14, -14, -14, -13, -13, -13, -13
  415.         db      -12, -12, -12, -12, -11, -11, -11, -11, -10, -10, -10, -10, -9, -9, -9, -9
  416.         db      -8, -8, -8, -8, -7, -7, -7, -7, -6, -6, -6, -6, -5, -5, -5, -5
  417.         db      -4, -4, -4, -4, -3, -3, -3, -3, -2, -2, -2, -2, -1, -1, -1, -1
  418.         db      0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3
  419.         db      4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7
  420.         db      8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11
  421.         db      12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15
  422.         db      16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19
  423.         db      20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23
  424.         db      24, 24, 24, 24, 25, 25, 25, 25, 26, 26, 26, 26, 27, 27, 27, 27
  425.         db      28, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 30, 31, 31, 31, 31
  426.         db      -36, -36, -36, -36, -35, -35, -35, -35, -34, -34, -34, -33, -33, -33, -33, -32
  427.         db      -32, -32, -31, -31, -31, -31, -30, -30, -30, -29, -29, -29, -29, -28, -28, -28
  428.         db      -27, -27, -27, -27, -26, -26, -26, -26, -25, -25, -25, -24, -24, -24, -24, -23
  429.         db      -23, -23, -22, -22, -22, -22, -21, -21, -21, -20, -20, -20, -20, -19, -19, -19
  430.         db      -18, -18, -18, -18, -17, -17, -17, -17, -16, -16, -16, -15, -15, -15, -15, -14
  431.         db      -14, -14, -13, -13, -13, -13, -12, -12, -12, -11, -11, -11, -11, -10, -10, -10
  432.         db      -9, -9, -9, -9, -8, -8, -8, -8, -7, -7, -7, -6, -6, -6, -6, -5
  433.         db      -5, -5, -4, -4, -4, -4, -3, -3, -3, -2, -2, -2, -2, -1, -1, -1
  434.         db      0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4
  435.         db      4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8
  436.         db      9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 12, 13
  437.         db      13, 13, 14, 14, 14, 14, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17
  438.         db      18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 21, 21, 21, 21, 22
  439.         db      22, 22, 23, 23, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 26
  440.         db      27, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 30, 30, 30, 30, 31
  441.         db      31, 31, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 35, 35, 35
  442.         db      -40, -40, -40, -40, -39, -39, -39, -38, -38, -38, -37, -37, -37, -36, -36, -36
  443.         db      -35, -35, -35, -35, -34, -34, -34, -33, -33, -33, -32, -32, -32, -31, -31, -31
  444.         db      -30, -30, -30, -30, -29, -29, -29, -28, -28, -28, -27, -27, -27, -26, -26, -26
  445.         db      -25, -25, -25, -25, -24, -24, -24, -23, -23, -23, -22, -22, -22, -21, -21, -21
  446.         db      -20, -20, -20, -20, -19, -19, -19, -18, -18, -18, -17, -17, -17, -16, -16, -16
  447.         db      -15, -15, -15, -15, -14, -14, -14, -13, -13, -13, -12, -12, -12, -11, -11, -11
  448.         db      -10, -10, -10, -10, -9, -9, -9, -8, -8, -8, -7, -7, -7, -6, -6, -6
  449.         db      -5, -5, -5, -5, -4, -4, -4, -3, -3, -3, -2, -2, -2, -1, -1, -1
  450.         db      0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4
  451.         db      5, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9
  452.         db      10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14
  453.         db      15, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19
  454.         db      20, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24
  455.         db      25, 25, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29
  456.         db      30, 30, 30, 30, 31, 31, 31, 32, 32, 32, 33, 33, 33, 34, 34, 34
  457.         db      35, 35, 35, 35, 36, 36, 36, 37, 37, 37, 38, 38, 38, 39, 39, 39
  458.         db      -44, -44, -44, -43, -43, -43, -42, -42, -42, -41, -41, -41, -40, -40, -40, -39
  459.         db      -39, -39, -38, -38, -38, -37, -37, -37, -36, -36, -36, -35, -35, -35, -34, -34
  460.         db      -33, -33, -33, -32, -32, -32, -31, -31, -31, -30, -30, -30, -29, -29, -29, -28
  461.         db      -28, -28, -27, -27, -27, -26, -26, -26, -25, -25, -25, -24, -24, -24, -23, -23
  462.         db      -22, -22, -22, -21, -21, -21, -20, -20, -20, -19, -19, -19, -18, -18, -18, -17
  463.         db      -17, -17, -16, -16, -16, -15, -15, -15, -14, -14, -14, -13, -13, -13, -12, -12
  464.         db      -11, -11, -11, -10, -10, -10, -9, -9, -9, -8, -8, -8, -7, -7, -7, -6
  465.         db      -6, -6, -5, -5, -5, -4, -4, -4, -3, -3, -3, -2, -2, -2, -1, -1
  466.         db      0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5
  467.         db      5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10
  468.         db      11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16
  469.         db      16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21
  470.         db      22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27
  471.         db      27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31, 32, 32
  472.         db      33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 38
  473.         db      38, 38, 39, 39, 39, 40, 40, 40, 41, 41, 41, 42, 42, 42, 43, 43
  474.         db      -48, -48, -48, -47, -47, -47, -46, -46, -45, -45, -45, -44, -44, -44, -43, -43
  475.         db      -42, -42, -42, -41, -41, -41, -40, -40, -39, -39, -39, -38, -38, -38, -37, -37
  476.         db      -36, -36, -36, -35, -35, -35, -34, -34, -33, -33, -33, -32, -32, -32, -31, -31
  477.         db      -30, -30, -30, -29, -29, -29, -28, -28, -27, -27, -27, -26, -26, -26, -25, -25
  478.         db      -24, -24, -24, -23, -23, -23, -22, -22, -21, -21, -21, -20, -20, -20, -19, -19
  479.         db      -18, -18, -18, -17, -17, -17, -16, -16, -15, -15, -15, -14, -14, -14, -13, -13
  480.         db      -12, -12, -12, -11, -11, -11, -10, -10, -9, -9, -9, -8, -8, -8, -7, -7
  481.         db      -6, -6, -6, -5, -5, -5, -4, -4, -3, -3, -3, -2, -2, -2, -1, -1
  482.         db      0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5
  483.         db      6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11
  484.         db      12, 12, 12, 13, 13, 13, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17
  485.         db      18, 18, 18, 19, 19, 19, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23
  486.         db      24, 24, 24, 25, 25, 25, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29
  487.         db      30, 30, 30, 31, 31, 31, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35
  488.         db      36, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 41
  489.         db      42, 42, 42, 43, 43, 43, 44, 44, 45, 45, 45, 46, 46, 46, 47, 47
  490.         db      -52, -52, -52, -51, -51, -50, -50, -50, -49, -49, -48, -48, -48, -47, -47, -46
  491.         db      -46, -46, -45, -45, -44, -44, -44, -43, -43, -42, -42, -42, -41, -41, -40, -40
  492.         db      -39, -39, -39, -38, -38, -37, -37, -37, -36, -36, -35, -35, -35, -34, -34, -33
  493.         db      -33, -33, -32, -32, -31, -31, -31, -30, -30, -29, -29, -29, -28, -28, -27, -27
  494.         db      -26, -26, -26, -25, -25, -24, -24, -24, -23, -23, -22, -22, -22, -21, -21, -20
  495.         db      -20, -20, -19, -19, -18, -18, -18, -17, -17, -16, -16, -16, -15, -15, -14, -14
  496.         db      -13, -13, -13, -12, -12, -11, -11, -11, -10, -10, -9, -9, -9, -8, -8, -7
  497.         db      -7, -7, -6, -6, -5, -5, -5, -4, -4, -3, -3, -3, -2, -2, -1, -1
  498.         db      0, 0, 0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6
  499.         db      6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 12, 12
  500.         db      13, 13, 13, 14, 14, 15, 15, 15, 16, 16, 17, 17, 17, 18, 18, 19
  501.         db      19, 19, 20, 20, 21, 21, 21, 22, 22, 23, 23, 23, 24, 24, 25, 25
  502.         db      26, 26, 26, 27, 27, 28, 28, 28, 29, 29, 30, 30, 30, 31, 31, 32
  503.         db      32, 32, 33, 33, 34, 34, 34, 35, 35, 36, 36, 36, 37, 37, 38, 38
  504.         db      39, 39, 39, 40, 40, 41, 41, 41, 42, 42, 43, 43, 43, 44, 44, 45
  505.         db      45, 45, 46, 46, 47, 47, 47, 48, 48, 49, 49, 49, 50, 50, 51, 51
  506.         db      -56, -56, -56, -55, -55, -54, -54, -53, -53, -53, -52, -52, -51, -51, -50, -50
  507.         db      -49, -49, -49, -48, -48, -47, -47, -46, -46, -46, -45, -45, -44, -44, -43, -43
  508.         db      -42, -42, -42, -41, -41, -40, -40, -39, -39, -39, -38, -38, -37, -37, -36, -36
  509.         db      -35, -35, -35, -34, -34, -33, -33, -32, -32, -32, -31, -31, -30, -30, -29, -29
  510.         db      -28, -28, -28, -27, -27, -26, -26, -25, -25, -25, -24, -24, -23, -23, -22, -22
  511.         db      -21, -21, -21, -20, -20, -19, -19, -18, -18, -18, -17, -17, -16, -16, -15, -15
  512.         db      -14, -14, -14, -13, -13, -12, -12, -11, -11, -11, -10, -10, -9, -9, -8, -8
  513.         db      -7, -7, -7, -6, -6, -5, -5, -4, -4, -4, -3, -3, -2, -2, -1, -1
  514.         db      0, 0, 0, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6
  515.         db      7, 7, 7, 8, 8, 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13
  516.         db      14, 14, 14, 15, 15, 16, 16, 17, 17, 17, 18, 18, 19, 19, 20, 20
  517.         db      21, 21, 21, 22, 22, 23, 23, 24, 24, 24, 25, 25, 26, 26, 27, 27
  518.         db      28, 28, 28, 29, 29, 30, 30, 31, 31, 31, 32, 32, 33, 33, 34, 34
  519.         db      35, 35, 35, 36, 36, 37, 37, 38, 38, 38, 39, 39, 40, 40, 41, 41
  520.         db      42, 42, 42, 43, 43, 44, 44, 45, 45, 45, 46, 46, 47, 47, 48, 48
  521.         db      49, 49, 49, 50, 50, 51, 51, 52, 52, 52, 53, 53, 54, 54, 55, 55
  522.         db      -60, -60, -60, -59, -59, -58, -58, -57, -57, -56, -56, -55, -55, -54, -54, -53
  523.         db      -53, -53, -52, -52, -51, -51, -50, -50, -49, -49, -48, -48, -47, -47, -46, -46
  524.         db      -45, -45, -45, -44, -44, -43, -43, -42, -42, -41, -41, -40, -40, -39, -39, -38
  525.         db      -38, -38, -37, -37, -36, -36, -35, -35, -34, -34, -33, -33, -32, -32, -31, -31
  526.         db      -30, -30, -30, -29, -29, -28, -28, -27, -27, -26, -26, -25, -25, -24, -24, -23
  527.         db      -23, -23, -22, -22, -21, -21, -20, -20, -19, -19, -18, -18, -17, -17, -16, -16
  528.         db      -15, -15, -15, -14, -14, -13, -13, -12, -12, -11, -11, -10, -10, -9, -9, -8
  529.         db      -8, -8, -7, -7, -6, -6, -5, -5, -4, -4, -3, -3, -2, -2, -1, -1
  530.         db      0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7
  531.         db      7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14
  532.         db      15, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22
  533.         db      22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29
  534.         db      30, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37
  535.         db      37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44
  536.         db      45, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50, 51, 51, 52
  537.         db      52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59
  538.         db      -64, -64, -63, -63, -62, -62, -61, -61, -60, -60, -59, -59, -58, -58, -57, -57
  539.         db      -56, -56, -55, -55, -54, -54, -53, -53, -52, -52, -51, -51, -50, -50, -49, -49
  540.         db      -48, -48, -47, -47, -46, -46, -45, -45, -44, -44, -43, -43, -42, -42, -41, -41
  541.         db      -40, -40, -39, -39, -38, -38, -37, -37, -36, -36, -35, -35, -34, -34, -33, -33
  542.         db      -32, -32, -31, -31, -30, -30, -29, -29, -28, -28, -27, -27, -26, -26, -25, -25
  543.         db      -24, -24, -23, -23, -22, -22, -21, -21, -20, -20, -19, -19, -18, -18, -17, -17
  544.         db      -16, -16, -15, -15, -14, -14, -13, -13, -12, -12, -11, -11, -10, -10, -9, -9
  545.         db      -8, -8, -7, -7, -6, -6, -5, -5, -4, -4, -3, -3, -2, -2, -1, -1
  546.         db      0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7
  547.         db      8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15
  548.         db      16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23
  549.         db      24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31
  550.         db      32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39
  551.         db      40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47
  552.         db      48, 48, 49, 49, 50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55
  553.         db      56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 62, 62, 63, 63
  554.  
  555. sbnotefreq      dw      24, 25, 27, 29, 30, 32, 34, 36, 38, 41, 43, 46
  556.                 dw      49, 51, 55, 58, 61, 65, 69, 73, 77, 82, 87, 92
  557.                 dw      98, 103, 110, 116, 123, 130, 138, 146, 155, 164, 174, 185
  558.                 dw      196, 207, 220, 233, 247, 261, 277, 293, 311, 329, 349, 370
  559.                 dw      392, 415, 440, 466, 494, 523, 554, 587, 622, 659, 699, 740
  560.  
  561. voice   struc
  562. poff    dd      0
  563. addx    dd      ?
  564. end     dd      ?
  565. lbeg    dd      ?
  566. lend    dd      ?
  567. vol     db      ?
  568. notem   dd      ?
  569. freqf   dw      ?
  570. freqw   db      ?
  571. ends
  572.  
  573. _dfmcounter     db      0       ; counter
  574. _dfmfunc        dd      _ret    ; function to call on every tick
  575. _scard        db    0    ; soundcard option bits
  576. _sbirq          db      ?       ; IRQ of SB
  577. _sbport         dw      ?       ; SB base port + 0Ch
  578. _dspout         db      0       ; DSP out in progress (for single digital)
  579. _pcsfxtblptr    dd    ?    ; ptr to PC SFX table
  580. _fmsfxtblptr    dd    ?    ; ptr to FM SFX table
  581. _sbsfxtblptr    dd    ?    ; ptr to SB SFX table
  582. _sbsfxchl       db      0       ; SB mixing SFX channel low limit
  583. _sbsfxchh       db      0       ; SB mixing SFX channel high limit
  584. _sbsfxch        db      0       ; SB mixing SFX current channel
  585. _fmsfxchl       db      0       ; FM mixing SFX channel low limit
  586. _fmsfxchh       db      0       ; FM mixing SFX channel high limit
  587. _fmsfxch        db      0       ; FM mixing SFX current channel
  588.  
  589. from_irq        dd      ?       ; jump to from IRQ entry
  590. from_sbout      dd      ?       ; jump to from sb muzik output sequence
  591. from_fmout      dd      ?       ; jump to from fm muzik output sequence
  592. from_sequence   dd      ?       ; jump to from muzik sequencing
  593.  
  594. v0      voice   <>
  595. v1      voice   <>
  596. v2      voice   <>
  597. v3      voice   <>
  598.  
  599. dhoutaddx       dw      ?       ; digital current hard out addx
  600. dsoutaddx       dd      ?       ; digital current soft out addx
  601. dmaolen         dd      ?       ; DMA straight out length to go
  602. dmaoaddx        dw      ?       ; DMA out addx low 16 bits
  603. dmaopage        db      ?       ; DMA out page
  604.  
  605. fmnotefreq      dw      343, 364, 386, 409, 433, 459, 486, 515, 546, 579, 613, 650
  606. fmoperoff       db      20h,21h,22h,23h,24h,25h,28h,29h,2ah,2bh,2ch,2dh,30h,31h,32h,33h,34h,35h
  607. fmoper1         db      0,1,2,6,7,8,12,13,14
  608. fmoper2         db      3,4,5,9,10,11,15,16,17
  609. fmoldv1         db      18 dup(?)
  610. fmoldv2         db      18 dup(?)
  611. fmsyntv         db      18 dup(?)
  612. fmlasti         db      18 dup(?)
  613. fmlastv         db      18 dup(?)
  614. fmschedn        db      18 dup(?)
  615. fmschedi        db      18 dup(?)
  616. fmschedv        db      18 dup(?)
  617. ;fmvoltbl        db      3fh,3bh,37h,33h, 2eh,2ah,26h,22h
  618. ;                db      1dh,19h,15h,11h, 0ch,08h,04h,00h
  619. fmvoltbl        db      38h,30h,28h,20h, 18h,14h,10h,0ch
  620.                 db      0ah,08h,06h,04h, 03h,02h,01h,00h
  621.  
  622. muzdelay        db      ?       ; muzik delay till next note
  623. muztempoc       db      ?       ; muzik tempo counter
  624. muztempo        db      ?       ; muzik master tempo
  625. muzorderc       db      ?       ; muzik current order
  626. muzordern       db      ?       ; muzik number of orders
  627. muzorderl       db      ?       ; muzik loop to order
  628. muzcurptr       dd      ?       ; muzik ptr to current place
  629. muzordptr       dd      ?       ; muzik ptr to order list
  630. muzpatoffptr    dd      ?       ; muzik ptr to pattern offsets
  631. muzsbinsptr     dd      ?       ; muzik ptr to SB instrument table
  632. muzfminsptr     dd      ?       ; muzik ptr to FM instrument data
  633. muzpatbase      dd      ?       ; muzik ptr to patterns base
  634. muzspecial      db      60h     ; muzik special terminate byte
  635. sequencetbl     dd      sequencenote,sequencevol,sequencewait,sequencebreak
  636.  
  637. mixedahead      db      ?       ; number of buffers mixed ahead
  638. mixaheadtbl     dd      sequencenote,sequencevol,mixaheadwait,mixaheadbreak
  639. mixcall         dd      ?
  640.  
  641. nodetectsb      db      0       ; allow SB detection?
  642. fmport          dw      ?       ; FM port base addx (388||220||240)
  643. pcsfxptr        dd      ?       ; ptr to current PCSFX out
  644. modebitmap    db    ?    ; output mode bitmap, bits:
  645.                                 ;  0 - sb single out allowable
  646.                                 ;  1 - muzik playing
  647.                                 ;  2 - dont play digital muzik
  648.                                 ;  3 - digital mixing is in use
  649.                                 ;  4 - allow FM stereo output
  650.                                 ;  5 - buffer is mixed ahead
  651. detected        db      0       ; already detected soundcard?
  652. installed       db      0       ; already installed driver?
  653. installfm       db      ?       ; install FM driver?
  654. installsb       db      ?       ; install SB driver?
  655. installmixtbl   dd      installsbm,installsbs
  656.  
  657. phademul        db      ?
  658. phadeon         db      ?
  659. phadefmvols     db      9 dup(?)
  660. phadedelay      db      ?
  661. phadedelayc     db      ?
  662.  
  663. _voicehit       db      13 dup(0)
  664.  
  665. _rmirqbuf       db      21 dup(0)       ;******************************
  666. _rmirqvect      dd      ?               ;******************************
  667.  
  668. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  669. ; BASIC DRIVER AND LOW CODE
  670. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  671.  
  672. ;─────────────────────────────────────────────────────────────────────────────
  673. fmportout:                              ; FM portout, AH to reg AL at DX
  674.         push ax
  675.         out dx,al
  676.         db 6 dup(0ech)
  677.         inc edx
  678.         mov al,ah
  679.         out dx,al
  680.         dec edx
  681.         db 35 dup(0ech)
  682.         pop ax
  683.         ret
  684. ;─────────────────────────────────────────────────────────────────────────────
  685. writedsp:                               ; write AH to DSP on DX
  686.         in al,dx
  687.         or al,al
  688.         js $-3
  689.         mov al,ah
  690.         out dx,al
  691.         ret
  692. ;─────────────────────────────────────────────────────────────────────────────
  693. writedspt:                              ; write AH to DSP on DX within time
  694.         push ecx
  695.         mov ecx,400000h
  696. writedsptl0:
  697.         in al,dx
  698.         or al,al
  699.         jns short writedsptf0
  700.         loop writedsptl0
  701.         pop ecx
  702.         stc
  703.         ret
  704. writedsptf0:
  705.         mov al,ah
  706.         out dx,al
  707.         pop ecx
  708.         clc
  709.         ret
  710. ;─────────────────────────────────────────────────────────────────────────────
  711. resetdsp:                               ; reset DSP on DX then read
  712.         sub dl,6
  713.         mov al,1
  714.         out dx,al
  715.         push ecx
  716.         mov ecx,4000h
  717. resetdl1:
  718.         in al,dx
  719.         loop resetdl1
  720.         pop ecx
  721.         xor al,al
  722.         out dx,al
  723.         add dl,6
  724. ;─────────────────────────────────────────────────────────────────────────────
  725. readdspt:                               ; read AL from DSP on DX within time
  726.         push ecx
  727.         mov ecx,400000h
  728.         add dl,2
  729. readdsptl0:
  730.         in al,dx
  731.         or al,al
  732.         js short readdsptf0
  733.         loop readdsptl0
  734.         sub dl,2
  735.         pop ecx
  736.         stc
  737.         ret
  738. readdsptf0:
  739.         sub dl,4
  740.         in al,dx
  741.         add dl,2
  742.         pop ecx
  743.         clc
  744.         ret
  745.  
  746. ;─────────────────────────────────────────────────────────────────────────────
  747. init_FMchip:                            ; init FM chip on DX
  748.         mov ax,02001h
  749.         call fmportout
  750.         mov ax,0bdh
  751.         call fmportout
  752.         mov ax,8
  753.         call fmportout
  754. reset_FMchip:                           ; reset FM chip on DX entry
  755.         mov ax,0b0h
  756. init_FMchipl0:
  757.         call fmportout
  758.         inc al
  759.         cmp al,0b9h
  760.         jb init_FMchipl0
  761.         xor ebx,ebx
  762.         mov ah,3fh
  763. init_FMchipl1:
  764.         mov al,fmoperoff[ebx]
  765.         add al,20h
  766.         call fmportout
  767.         inc ebx
  768.         cmp ebx,18
  769.         jb init_FMchipl1
  770.         ret
  771.  
  772. ;─────────────────────────────────────────────────────────────────────────────
  773. fmsettimbre:                            ; set timbre at ESI to FM voice AL at DX
  774.         add bl,al                       ; BL=offset in tables
  775.         movzx edi,bl
  776.         movzx ebp,al
  777.         add al,0c0h
  778.         mov ah,[esi]
  779.         mov fmsyntv[edi],ah
  780.         call fmportout
  781.         movzx ebx,ds:fmoper1[ebp]
  782.         mov al,fmoperoff[ebx]
  783.         mov ah,[esi+1]
  784.         call fmportout
  785.         add al,20h
  786.         mov ah,[esi+2]
  787.         mov fmoldv1[edi],ah
  788.         call fmportout
  789.         add al,20h
  790.         mov ah,[esi+3]
  791.         call fmportout
  792.         add al,20h
  793.         mov ah,[esi+4]
  794.         call fmportout
  795.         add al,60h
  796.         mov ah,[esi+5]
  797.         call fmportout
  798.         movzx ebx,ds:fmoper2[ebp]
  799.         mov al,fmoperoff[ebx]
  800.         mov ah,[esi+6]
  801.         call fmportout
  802.         add al,20h
  803.         mov ah,[esi+7]
  804.         mov fmoldv2[edi],ah
  805.         call fmportout
  806.         add al,20h
  807.         mov ah,[esi+8]
  808.         call fmportout
  809.         add al,20h
  810.         mov ah,[esi+9]
  811.         call fmportout
  812.         add al,60h
  813.         mov ah,[esi+10]
  814.         jmp fmportout
  815. ;─────────────────────────────────────────────────────────────────────────────
  816. fmsetvolume:                            ; set volume AH to FM voice AL at DX
  817.         add bl,al                       ; BL=offset in tables
  818.         movzx edi,bl
  819.         movzx ebp,al
  820.         mov ch,ah
  821.         mov ah,fmoldv2[edi]
  822.         and ah,0c0h
  823.         or ah,ch
  824.         mov fmoldv2[edi],ah
  825.         movzx ebx,ds:fmoper2[ebp]
  826.         mov al,fmoperoff[ebx]
  827.         add al,20h
  828.         call fmportout
  829.         test fmsyntv[edi],1
  830.         jz fmsetvolumed
  831.         mov ah,fmoldv1[edi]
  832.         and ah,11000000b
  833.         or ah,ch
  834.         mov fmoldv1[edi],ah
  835.         movzx ebx,ds:fmoper1[ebp]
  836.         mov al,fmoperoff[ebx]
  837.         add al,20h
  838.         call fmportout
  839. fmsetvolumed:
  840.         ret
  841. ;─────────────────────────────────────────────────────────────────────────────
  842. fmplaynote:                             ; play note BX on FM voice AL at DX
  843.         add al,0b0h
  844.         xor ah,ah
  845.         call fmportout
  846.         sub al,10h
  847.         mov ah,bl
  848.         call fmportout
  849.         add al,10h
  850.         mov ah,bh
  851.         or ah,20h
  852.         jmp fmportout
  853.  
  854. ;═════════════════════════════════════════════════════════════════════════════
  855. irq:                                    ; basic IRQ entry
  856.         push ax
  857.         mov al,20h
  858.         out 20h,al
  859.         sti
  860.         pop ax
  861.         cld
  862.         pushad
  863.         push ds
  864.         push es
  865.         mov ax,cs:_seldata
  866.         mov ds,ax
  867.         mov es,ax
  868.  
  869. ;        push edi
  870. ;        @rlp edi,0b8000h
  871. ;        inc byte ptr [edi]
  872. ;        pop edi
  873.  
  874.         and modebitmap,0dfh
  875.         cmp phadeon,0
  876.         jne short irqphade
  877. irqphaded:
  878.         jmp from_irq
  879. irqphade:                               ; phade muzik routine
  880.         dec phadedelayc
  881.         jnz irqphaded
  882.         mov al,phadedelay
  883.         mov phadedelayc,al
  884.         sub phademul,1
  885.         jc short irqphaded2
  886.         mov ebx,offset v0.vol
  887.         mov ecx,4
  888. irqphadel0:
  889.         mov al,[ebx]
  890.         sub al,1
  891.         adc al,0
  892.         mov [ebx],al
  893.         add ebx,size voice
  894.         loop irqphadel0
  895.         mov esi,offset phadefmvols
  896.         mov edi,esi
  897.         xor ebx,ebx
  898.         mov ecx,9
  899. irqphadel1:
  900.         lodsb
  901.         sub al,1
  902.         adc al,0
  903.         stosb
  904.         movzx eax,al
  905.         mov al,fmvoltbl[eax]
  906.         mov fmschedv[ebx],al
  907.         cmp fmschedn[ebx],-1
  908.         jne short irqphadel1c
  909.         mov fmschedn[ebx],-2
  910. irqphadel1c:
  911.         inc ebx
  912.         loop irqphadel1
  913.         jmp from_irq
  914. irqphaded2:
  915.         call _stopmuzik
  916.         jmp from_irq
  917.  
  918. ;═════════════════════════════════════════════════════════════════════════════
  919. sbsingleirq:                            ; Single output IRQ
  920.         push ax
  921.         push bx
  922.         push ecx
  923.         push dx
  924.         push ds
  925.         mov ax,cs:_seldata
  926.         mov ds,ax
  927.         mov dx,_sbport
  928.         add dl,2
  929.         in al,dx
  930.         sub dl,2
  931.         xor al,al
  932.         cmp dmaolen,0
  933.         je sbsingleirqd
  934.         mov al,5
  935.         out 0ah,al
  936.         mov ecx,0ffffh
  937.         mov bx,dmaoaddx
  938.         sub cx,bx
  939.         cmp ecx,dmaolen
  940.         jbe short sbsingleirqf1
  941.         mov ecx,dmaolen
  942.         dec ecx
  943. sbsingleirqf1:
  944.         mov al,bl
  945.         out 2,al
  946.         mov al,bh
  947.         out 2,al
  948.         mov al,cl
  949.         out 3,al
  950.         mov al,ch
  951.         out 3,al
  952.         mov al,dmaopage
  953.         out 83h,al
  954.         mov al,1
  955.         out 0ah,al
  956.         mov ah,14h
  957.         call writedsp
  958.         mov ah,cl
  959.         call writedsp
  960.         mov ah,ch
  961.         call writedsp
  962.         inc ecx
  963.         mov al,1
  964.         sub dmaolen,ecx
  965.         jz sbsingleirqd
  966.         inc dmaopage
  967.         mov dmaoaddx,0
  968. sbsingleirqd:
  969.         mov _dspout,al
  970.         pop ds
  971.         pop dx
  972.         pop ecx
  973.         pop bx
  974.         mov al,20h
  975.         out 20h,al
  976.         pop ax
  977.         iretd
  978.  
  979. ;═════════════════════════════════════════════════════════════════════════════
  980. sbnout:                                 ; SB mono out module
  981.         mov dx,_sbport
  982.         add dl,2
  983.         in al,dx
  984.         sub dl,2
  985.         mov al,5
  986.         out 0ah,al
  987.         mov ax,dhoutaddx
  988.         add ax,DBUFLEN*2
  989.         jnc short sbnoutf0
  990.         sub ax,DBUFLEN*6
  991. sbnoutf0:
  992.         mov dhoutaddx,ax
  993.         out 2,al
  994.         mov al,ah
  995.         out 2,al
  996.         mov al,LOW(DBUFLEN-1)
  997.         out 3,al
  998.         mov al,HIGH(DBUFLEN-1)
  999.         out 3,al
  1000.         mov ah,14h
  1001.         call writedsp
  1002.         mov ah,LOW(DBUFLEN-1)
  1003.         call writedsp
  1004.         mov ah,HIGH(DBUFLEN-1)
  1005.         call writedsp
  1006.         mov al,1
  1007.         out 0ah,al
  1008.         jmp from_sbout
  1009.  
  1010. ;═════════════════════════════════════════════════════════════════════════════
  1011. sbpout:                                 ; SBP stereo out module
  1012.         mov dx,_sbport
  1013.         add dl,2
  1014.         in al,dx
  1015.         sub dl,2
  1016.         mov al,5
  1017.         out 0ah,al
  1018.         mov ax,dhoutaddx
  1019.         add ax,DBUFLEN*2
  1020.         jnc short sbpoutf0
  1021.         sub ax,DBUFLEN*6
  1022. sbpoutf0:
  1023.         mov dhoutaddx,ax
  1024.         out 2,al
  1025.         mov al,ah
  1026.         out 2,al
  1027.         mov al,LOW((DBUFLEN*2)-1)
  1028.         out 3,al
  1029.         mov al,HIGH((DBUFLEN*2)-1)
  1030.         out 3,al
  1031.         mov ah,48h
  1032.         call writedsp
  1033.         mov ah,LOW((DBUFLEN*2)-1)
  1034.         call writedsp
  1035.         mov ah,HIGH((DBUFLEN*2)-1)
  1036.         call writedsp
  1037.         mov ah,91h
  1038.         call writedsp
  1039.         mov al,1
  1040.         out 0ah,al
  1041.         jmp from_sbout
  1042.  
  1043. ;═════════════════════════════════════════════════════════════════════════════
  1044. fmmout:                                 ; FM mono sound out routine
  1045.         xor ebp,ebp
  1046.         mov dx,fmport
  1047. fmmoutl0:
  1048.         cmp ds:fmschedn[ebp],0feh          ; note or volume change scheduled?
  1049.         ja fmmoutl0c
  1050.         je fmmoutl0f0
  1051.         mov al,ds:fmschedi[ebp]            ; instrument different?
  1052.         cmp al,ds:fmlasti[ebp]
  1053.         je short fmmoutl0f1
  1054.         mov ds:fmlasti[ebp],al             ; change instrument
  1055.         movzx esi,al
  1056.         imul esi,11
  1057.         add esi,muzfminsptr
  1058.         mov bl,[esi+7]
  1059.         and bl,3fh
  1060.         mov ds:fmlastv[ebp],bl
  1061.         mov eax,ebp
  1062.         xor bl,bl
  1063.         push ebp
  1064.         call fmsettimbre
  1065.         pop ebp
  1066. fmmoutl0f1:
  1067.         mov ah,ds:fmschedv[ebp]            ; volume different?
  1068.         cmp ah,ds:fmlastv[ebp]
  1069.         je short fmmoutl0f2
  1070.         mov ds:fmlastv[ebp],ah             ; set new volume
  1071.         mov ebx,ebp
  1072.         mov al,bl
  1073.         xor bl,bl
  1074.         push ebp
  1075.         call fmsetvolume
  1076.         pop ebp
  1077. fmmoutl0f2:                             ; play note
  1078.         mov al,ds:fmschedn[ebp]
  1079.         movzx ecx,al
  1080.         and cl,0fh
  1081.         mov bx,fmnotefreq[ecx*2]
  1082.         mov ecx,ebp
  1083.         and cx,3
  1084.         add bx,cx
  1085.         and al,70h
  1086.         shr al,2
  1087.         or bh,al
  1088.         mov eax,ebp
  1089.         call fmplaynote
  1090.         mov ds:fmschedn[ebp],0ffh
  1091. fmmoutl0c:
  1092.         inc ebp
  1093.         cmp ebp,9
  1094.         jb fmmoutl0
  1095.         jmp from_fmout
  1096. fmmoutl0f0:                             ; volume change only
  1097.         mov eax,ebp
  1098.         mov ah,ds:fmschedv[ebp]
  1099.         cmp ah,ds:fmlastv[ebp]
  1100.         je short fmmoutl0c
  1101.         mov ds:fmlastv[ebp],ah
  1102.         xor bl,bl
  1103.         push ebp
  1104.         call fmsetvolume
  1105.         pop ebp
  1106.         jmp short fmmoutl0c
  1107.  
  1108. ;═════════════════════════════════════════════════════════════════════════════
  1109. sequence:                               ; actual muzik sequencing
  1110.         test modebitmap,2               ; muzik playing?
  1111.         jz sequencedone
  1112.         dec muztempoc                   ; yup, decrement tempo and delay
  1113.         jnz sequencedone
  1114.         mov al,muztempo
  1115.         mov muztempoc,al
  1116.         dec muzdelay
  1117.         jnz sequencedone
  1118.         cmp mixedahead,2
  1119.         setnc al
  1120.         shl al,5
  1121.         or modebitmap,al
  1122.         mov esi,muzcurptr               ; time to sequence again
  1123. sequenceml:
  1124.         lodsb
  1125.         movzx ebx,al
  1126.         shr bl,5
  1127.         and al,1fh
  1128.         push offset sequenceml
  1129.         jmp sequencetbl[ebx*4]
  1130. sequencebreak:                          ; break pattern
  1131.         mov al,muzorderc
  1132.         inc al
  1133.         cmp al,muzordern
  1134.         jb short sequencebreakf0
  1135.         mov al,muzorderl
  1136. sequencebreakf0:
  1137.         mov muzorderc,al
  1138.         movzx ebx,al
  1139.         add ebx,muzordptr
  1140.         mov al,[ebx]
  1141.         movzx ebx,al
  1142.         shl ebx,2
  1143.         add ebx,muzpatoffptr
  1144.         movzx esi,word ptr [ebx]
  1145.         add esi,muzpatbase
  1146.         ret
  1147. sequencenote:                           ; a note
  1148.         movzx ebp,al
  1149.         cmp al,3
  1150.         ja sequencenotefm
  1151.         test modebitmap,24h             ;  sb muzik allowed?
  1152.         stc
  1153.         jnz sequenceskip
  1154.         movzx ebx,al
  1155.         imul ebx,size voice
  1156.         lodsb
  1157.         mov ah,al
  1158.         movzx ecx,al
  1159.         and al,0fh
  1160.         and cl,70h
  1161.         shr cl,2
  1162.         lea ecx,[ecx*2+ecx]
  1163.         add cl,al
  1164.         movzx ecx,sbnotefreq[ecx*2]
  1165.         mov v0[ebx].notem,ecx
  1166.         dec ch
  1167.         mov v0[ebx].freqw,ch
  1168.         xor ch,ch
  1169.         mov v0[ebx].freqf,cx
  1170.         lodsb
  1171.         mov ch,al
  1172.         and al,0fh
  1173.         mov dx,ax
  1174.         shr dx,15
  1175.         mul phademul
  1176.         shr al,4
  1177.         mov ds:_voicehit[ebp],al
  1178.         mov v0[ebx].vol,al
  1179.         shrd cx,dx,4
  1180.         movzx ecx,ch
  1181.         shl ecx,4
  1182.         add ecx,muzsbinsptr
  1183.         mov eax,[ecx]
  1184.         mov v0[ebx].addx,eax
  1185.         mov eax,[ecx+4]
  1186.         mov v0[ebx].end,eax
  1187.         mov eax,[ecx+8]
  1188.         mov v0[ebx].lbeg,eax
  1189.         mov eax,[ecx+12]
  1190.         mov v0[ebx].lend,eax
  1191.         ret
  1192. sequencenotefm:
  1193.         sub al,4
  1194.         movzx ebx,al
  1195.         lodsb
  1196.         mov ah,al
  1197.         and al,7fh
  1198.         mov fmschedn[ebx],al
  1199.         mov fmschedn[ebx+9],al
  1200.         lodsb
  1201.         mov ch,al
  1202.         and al,0fh
  1203.         mov dx,ax
  1204.         shr dx,15
  1205.         mul phademul
  1206.         shr al,4
  1207.         mov ds:_voicehit[ebp],al
  1208.         mov ds:phadefmvols[ebp-4],al
  1209.         movzx eax,al
  1210.         mov al,fmvoltbl[eax]
  1211.         mov fmschedv[ebx],al
  1212.         shrd cx,dx,4
  1213.         mov fmschedi[ebx],ch
  1214.         ret
  1215. sequencevol:                            ; a volume change
  1216.         movzx ebp,al
  1217.         cmp al,3
  1218.         ja short sequencevolfm
  1219.         test modebitmap,4               ;  sb muzik allowed?
  1220.         clc
  1221.         jnz short sequenceskip
  1222.         movzx ebx,al
  1223.         imul ebx,size voice
  1224.         lodsb
  1225.         mul phademul
  1226.         shr al,4
  1227.         mov v0[ebx].vol,al
  1228.         ret
  1229. sequencevolfm:                          ;  fm volume change
  1230.         sub al,4
  1231.         movzx ebx,al
  1232.         lodsb
  1233.         mul phademul
  1234.         shr al,4
  1235.         mov ds:phadefmvols[ebp-4],al
  1236.         movzx eax,al
  1237.         mov al,fmvoltbl[eax]
  1238.         mov fmschedn[ebx],-2
  1239.         mov fmschedv[ebx],al
  1240.         ret
  1241. sequencewait:                           ; delay command
  1242.         lodsb
  1243.         mov muzdelay,al
  1244.         mov muzcurptr,esi
  1245.         add esp,4
  1246. sequencedone:                           ; done
  1247.         jmp from_sequence
  1248. sequenceskip:                           ; no sb muzik allowed, skip bytes
  1249.         adc esi,1
  1250.         ret
  1251.  
  1252. ;═════════════════════════════════════════════════════════════════════════════
  1253. mix:                                    ; digital mix routine
  1254.         dec mixedahead
  1255.         jnz mixdone
  1256.         inc mixedahead
  1257.         push offset mixdone
  1258. mixgo:
  1259.         mov edi,dsoutaddx               ; Actual mixing
  1260.         add di,DBUFLEN*2
  1261.         jnc short mixf0
  1262.         sub di,DBUFLEN*6
  1263. mixf0:
  1264.         mov dsoutaddx,edi
  1265.         sub edi,_code32a
  1266.         mov ebx,edi
  1267.         mov eax,80808080h
  1268.         db 0b9h                 ; MOV ECX,MIXFILLLEN, DBUFLEN/4 || DBUFLEN/2
  1269. mixfilllen      dd      ?       ;
  1270.         rep stosd
  1271.         mov edi,ebx
  1272.         mov ebp,offset v0
  1273. mix2l0:
  1274.         push edi
  1275.         add edi,ds:[ebp].poff
  1276.         mov esi,ds:[ebp].addx
  1277.         mov edx,DBUFLEN
  1278. mix2l1:
  1279.         mov ecx,edx
  1280.         cmp esi,ds:[ebp].lend
  1281.         jb short mix2l1f0
  1282.         mov esi,ds:[ebp].lbeg
  1283. mix2l1f0:
  1284.         cmp esi,ds:[ebp].end
  1285.         jae mix2l0c
  1286.         mov ebx,ecx                     ;  beginning of logic
  1287.         imul ebx,ds:[ebp].notem
  1288.         shr ebx,8
  1289.         add ebx,esi
  1290.         mov eax,ds:[ebp].end
  1291.         cmp eax,ds:[ebp].lend
  1292.         jbe short mix2l1f2
  1293.         mov eax,ds:[ebp].lend
  1294. mix2l1f2:
  1295.         cmp eax,ebx
  1296.         jae short mix2l1f1
  1297.         sub eax,esi
  1298.         shl eax,8
  1299.         xor edx,edx
  1300.         div ds:[ebp].notem
  1301.         sub edx,1
  1302.         cmc
  1303.         adc eax,0
  1304.         mov edx,ecx
  1305.         mov ecx,eax
  1306. mix2l1f1:
  1307.         movzx ebx,ds:[ebp].vol
  1308.         shl bx,8
  1309.         db 81h,0c3h             ; ADD EBX,MIXVOLADDX
  1310. mixvoladdx      dd ?            ;
  1311.         sub edx,ecx
  1312.         push edx
  1313.         sub cx,DBUFLEN
  1314.         neg cx
  1315.         db 6bh,0c9h             ; IMUL CX,MIXRLEN
  1316. mixrlen db ?                    ;
  1317.         mov eax,offset mixrout
  1318.         add eax,ecx
  1319.         mov mixcall,eax
  1320.         mov cx,ds:[ebp].freqf
  1321.         movsx edx,ds:[ebp].freqw
  1322.         xor eax,eax
  1323.         call mixcall
  1324.         mov ds:[ebp].freqf,cx
  1325.         pop edx
  1326.         or edx,edx
  1327.         jnz mix2l1
  1328. mix2l0c:
  1329.         pop edi
  1330.         mov ds:[ebp].addx,esi
  1331.         add ebp,size voice
  1332.         cmp ebp,offset v3
  1333.         jbe mix2l0
  1334.         ret
  1335. mixdone:
  1336.  
  1337. ;═════════════════════════════════════════════════════════════════════════════
  1338. pcsfx:                                  ; PC SFX routine
  1339.         mov esi,pcsfxptr
  1340.         or esi,esi
  1341.         jz short irqdone
  1342.         lodsb
  1343.         or al,al
  1344.         jnz short pcsfxf0
  1345.         mov pcsfxptr,0
  1346.         in al,61h
  1347.         and al,0fch
  1348.         out 61h,al
  1349.         jmp short irqdone
  1350. pcsfxf0:
  1351.         mov ah,al
  1352.         xor al,al
  1353.         out 42h,al
  1354.         mov al,ah
  1355.         jmp $+2
  1356.         out 42h,al
  1357.         mov pcsfxptr,esi
  1358.  
  1359. ;═════════════════════════════════════════════════════════════════════════════
  1360. irqdone:                                ; IRQ done
  1361.         inc _dfmcounter
  1362.         call _dfmfunc
  1363.         pop es
  1364.         pop ds
  1365. ;       mov al,20h
  1366. ;       out 20h,al
  1367.         popad
  1368.         iretd
  1369.  
  1370. ;-----------------------------------------------------------------------------
  1371. mixrout:                        ; mixing matrix
  1372.         db      DBUFLEN*sbpmixmatrixlen+1 dup(?)
  1373. ;-----------------------------------------------------------------------------
  1374. sbnmixmatrix:
  1375.         lodsb
  1376.         mov al,[ebx+eax]
  1377.         add [edi],al
  1378.         inc edi
  1379.         add ch,cl
  1380.         adc esi,edx
  1381. sbnmixmatrixlen equ     $-sbnmixmatrix
  1382. ;-----------------------------------------------------------------------------
  1383. sbpmixmatrix:
  1384.         lodsb
  1385.         mov al,[ebx+eax]
  1386.         add [edi],al
  1387.         add edi,2
  1388.         add ch,cl
  1389.         adc esi,edx
  1390. sbpmixmatrixlen equ     $-sbpmixmatrix
  1391.  
  1392. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1393. ; SETUP AND OTHER CODE
  1394. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1395.  
  1396. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1397. ; Detect soundcard in system
  1398. ; In:
  1399. ;   None
  1400. ; Out:
  1401. ;   AL - soundcard option bits:
  1402. ;     0 - FM found
  1403. ;     1 - FM is stereo (only if bit 0 is set)
  1404. ;     2 - digital SB found
  1405. ;     3 - SB is stereo (only if bit 2 is set)
  1406. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1407. _detect_scard:
  1408.         cmp detected,0          ; already got soundcard?
  1409.         jne short detect_scard_skip
  1410.         mov detected,1
  1411.         pushad                  ; save some stuff
  1412.         pushf
  1413.         cli
  1414.         in al,21h
  1415.         push ax
  1416.         mov al,0ffh
  1417.         out 21h,al
  1418.         cmp nodetectsb,0
  1419.         jne short detect_scardf0
  1420.         call detect_SB          ; is SB present?
  1421.     jc short detect_scardf0
  1422.     or _scard,4
  1423.         call detect_SBP         ; is SBP present?
  1424.         jc short detect_scardf0
  1425.         or _scard,8
  1426. detect_scardf0:         ; is adlib present?
  1427.     mov dx,388h
  1428.         call detect_FMchip
  1429.     jnz short detect_scard_done
  1430.     or _scard,1
  1431. detect_scard_done:
  1432.     pop ax                ; restore stuff and return scard
  1433.         out 21h,al
  1434.         popf
  1435.         popad
  1436. detect_scard_skip:                      ; if already detected skip
  1437.         mov al,_scard
  1438.         ret
  1439. ;─────────────────────────────────────────────────────────────────────────────
  1440. detect_FMchip:                          ; detect FM chip on DX
  1441.         mov ax,6004h
  1442.         call fmportout
  1443.         mov ax,8004h
  1444.         call fmportout
  1445.         in al,dx
  1446.         and al,0e0h
  1447.         mov cl,al
  1448.         mov ax,0ff02h
  1449.         call fmportout
  1450.         mov ax,2104h
  1451.         call fmportout
  1452.         push cx
  1453.         mov ecx,800
  1454.         loop $
  1455.         pop cx
  1456.         in al,dx
  1457.         and al,0e0h
  1458.         mov ch,al
  1459.         mov ax,6004h
  1460.         call fmportout
  1461.         mov ax,08004h
  1462.         call fmportout
  1463.         sub cx,0c000h
  1464.         ret
  1465. ;─────────────────────────────────────────────────────────────────────────────
  1466. detect_SB:                              ; detect SB port and IRQ
  1467.         mov dx,_sbport
  1468. detect_SBl0:
  1469.         mov ah,0d3h
  1470.         call writedspt
  1471.         call resetdsp
  1472.         jc short detect_SBl0c
  1473.         mov ah,0e0h
  1474.         call writedspt
  1475.         jc short detect_SBl0c
  1476.         mov ah,0c6h
  1477.         call writedspt
  1478.         jc short detect_SBl0c
  1479.         call readdspt
  1480.         jc short detect_SBl0c
  1481.         cmp al,39h
  1482.         je short detect_SBl0d
  1483. detect_SBl0c:
  1484.         add dl,10h
  1485.         cmp dl,7ch
  1486.         jb detect_SBl0
  1487.         stc
  1488.         ret
  1489. detect_SBl0d:
  1490.         clc                             ; yup, SB here
  1491.         ret
  1492. ;─────────────────────────────────────────────────────────────────────────────
  1493. detect_SBP:                             ; detect an SBP...
  1494.         mov dx,_sbport
  1495.         sub dl,8
  1496.         mov al,0eh
  1497.         out dx,al
  1498.         inc edx
  1499.         in al,dx
  1500.         or al,2
  1501.         jmp short $+2
  1502.         out dx,al
  1503.         jmp short $+2
  1504.         in al,dx
  1505.         test al,2
  1506.         jnz short detect_SBPf0
  1507. detect_SBPno:
  1508.         stc                             ; no sbp
  1509.         ret
  1510. detect_SBPf0:
  1511.         and al,0fdh
  1512.         out dx,al
  1513.         jmp short $+2
  1514.         in al,dx
  1515.         test al,2
  1516.         jnz detect_SBPno
  1517.         clc                             ; yup, SBP
  1518.         ret
  1519.  
  1520. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1521. ; Install muzik/SFX driver(s)
  1522. ; In:
  1523. ;   AL - bitmap of what to install:
  1524. ;     0,1 - FM muzik/SFX driver to install: 0-none,1-mono,2-stereo
  1525. ;     2,3 - digital muzik/SFX driver to install: 0-none,1-single,2-mono,3-stereo
  1526. ;     4   - block out digital muzik
  1527. ; Out:
  1528. ;   None
  1529. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1530. _install_dfm:
  1531.         call _uninstall_dfm
  1532.         mov installed,1
  1533.         pushad
  1534.         pushf
  1535.         cli
  1536.         mov ah,al                       ; break up and store install request
  1537.         and al,3
  1538.         mov installfm,al
  1539.         mov al,ah
  1540.         shr al,2
  1541.         and al,3
  1542.         mov installsb,al
  1543.         test ah,10h
  1544.         setnz al
  1545.         shl al,2
  1546.         mov modebitmap,al
  1547.         mov fmport,388h
  1548.  
  1549.         call _detect_scard
  1550.  
  1551. ;        pushad                          ;***********************
  1552. ;        @rlp edi,0b8000h                ;***********************
  1553. ;        mov byte ptr [edi+2],al         ;***********************
  1554. ;        popad                           ;***********************
  1555.  
  1556.         test al,1                       ; init FM chips if any
  1557.         jz short instdfmf0
  1558.         test al,2
  1559.         jnz short instdfmf1
  1560.         mov dx,388h
  1561.         jmp short instdfmf2
  1562. instdfmf1:
  1563.         mov dx,_sbport
  1564.         sub dl,0ch
  1565.         call init_FMchip
  1566.         add dl,2
  1567. instdfmf2:
  1568.         call init_FMchip
  1569. instdfmf0:
  1570.         call _stopmuzik
  1571.  
  1572.         mov ah,_scard
  1573.         mov al,installfm                ; adjust FM request bitmap to _scard
  1574.         or al,al
  1575.         jz short instarfmd
  1576.         test ah,1
  1577.         jnz short instarfmf0
  1578.         xor al,al
  1579.         jmp short instarfmd
  1580. instarfmf0:
  1581.         cmp al,1
  1582.         je short instarfmd
  1583.         test ah,2
  1584.         jnz short instarfmf1
  1585.         mov al,1
  1586.         jmp short instarfmd
  1587. instarfmf1:
  1588.         or modebitmap,10h
  1589.         mov dx,_sbport
  1590.         sub dl,0ch
  1591.         mov fmport,dx
  1592. instarfmd:
  1593.         mov installfm,al
  1594.         mov al,installsb                ; adjust SB request bitmap to _scard
  1595.         or al,al
  1596.         jz short instarsbd
  1597.         test ah,4
  1598.         jnz short instarsbf0
  1599.         xor al,al
  1600.         jmp short instarsbd
  1601. instarsbf0:
  1602.         cmp al,3
  1603.         jb short instarsbd
  1604.         test ah,8
  1605.         jnz short instarsbd
  1606.         mov al,2
  1607. instarsbd:
  1608.         mov installsb,al
  1609.  
  1610.         cmp al,1                        ; set appropriate mode bits
  1611.         setz ah
  1612.         or modebitmap,ah
  1613.         cmp al,1
  1614.         seta ah
  1615.         shl ah,3
  1616.         or modebitmap,ah
  1617.  
  1618.         mov ebp,offset from_irq         ; trace and set irq route
  1619.         mov ah,installfm
  1620.         cmp al,2
  1621.         jb short insttrcf0
  1622.         je short insttrcf1
  1623.         mov dword ptr ds:[ebp],offset sbpout
  1624.         jmp short insttrcf2
  1625. insttrcf1:
  1626.         mov dword ptr ds:[ebp],offset sbnout
  1627. insttrcf2:
  1628.         mov ebp,offset from_sbout
  1629. insttrcf0:
  1630.         cmp ah,1
  1631.         jb short insttrcf3
  1632.         mov dword ptr ds:[ebp],offset fmmout
  1633. insttrcf5:
  1634.         mov ebp,offset from_fmout
  1635.         jmp short insttrcf7
  1636. insttrcf3:
  1637.         cmp al,2
  1638.         jb short insttrcf6
  1639.         test modebitmap,4
  1640.         jnz short insttrcf6
  1641. insttrcf7:
  1642.         mov dword ptr ds:[ebp],offset sequence
  1643.         mov ebp,offset from_sequence
  1644. insttrcf6:
  1645.         mov dword ptr ds:[ebp],offset pcsfx
  1646.         cmp al,2
  1647.         jb short insttrcd
  1648.         mov dword ptr ds:[ebp],offset mix
  1649. insttrcd:
  1650.  
  1651.         cmp al,1                        ; install single SB irq if needed
  1652.         jne short instdfmf3
  1653.         call installmisc0
  1654.         push eax edx edi
  1655.         mov edx,offset sbsingleirq
  1656.         call _setirqvect
  1657.         mov edi,offset _rmirqbuf
  1658.         call _rmpmirqset
  1659.         mov _rmirqvect,eax
  1660.         pop edi edx eax
  1661. instdfmf4:                              ; install IRQ0 call IRQ routine
  1662.         mov al,036h
  1663.         out 43h,al
  1664.         mov al,0c4h
  1665.         out 40h,al
  1666.         mov al,51h
  1667.         jmp short $+2
  1668.         out 40h,al
  1669.         in al,21h
  1670.         and al,0feh
  1671.         jmp short $+2
  1672.         out 21h,al
  1673.         push edx eax edi
  1674.         mov bl,0
  1675.         mov edx,offset irq
  1676.         call _setirqvect
  1677.         mov edi,offset _rmirqbuf
  1678.         call _rmpmirqset
  1679.         mov _rmirqvect,eax
  1680.         pop edi eax edx
  1681.         jmp short instdfmf5
  1682. instdfmf3:
  1683.         cmp al,2
  1684.         jb short instdfmf4
  1685.         movzx ebp,al                    ; install mono or stereo mixing IRQ
  1686.         sub ebp,2
  1687.         call installmisc0
  1688.         push edx edi eax
  1689.         mov edx,offset irq
  1690.         call _setirqvect
  1691.         mov edi,offset _rmirqbuf
  1692.         call _rmpmirqset
  1693.         mov _rmirqvect,eax
  1694.         pop eax edi edx
  1695. ;        mov ah,40h
  1696. ;        call writedsp
  1697.         call cs:installmixtbl[ebp*4]
  1698.         mov edi,0a0000h-6*DBUFLEN
  1699.         mov dhoutaddx,di
  1700.         lea eax,[edi+2*DBUFLEN]
  1701.         mov dsoutaddx,eax
  1702.         sub edi,_code32a
  1703.         mov ecx,DBUFLEN*3
  1704.         mov ax,8080h
  1705.         rep stosw
  1706.         mov al,9
  1707.         out 83h,al
  1708.         mov mixedahead,1
  1709.  
  1710. instdfmf5:
  1711.         mov al,0b6h                     ; reset PC squeeker output timer
  1712.         out 43h,al
  1713.         xor al,al
  1714.         out 42h,al
  1715.         jmp short $+2
  1716.         out 42h,al
  1717.         test modebitmap,8
  1718.         jz short instdfmd
  1719.         sti
  1720.         mov dx,_sbport                  ; init mixing IRQ
  1721.         mov ah,0f2h
  1722.         call writedsp
  1723. instdfmd:
  1724.         popf
  1725.         popad
  1726.         ret
  1727. ;-----------------------------------------------------------------------------
  1728. installmisc0:                           ; misc 0
  1729.         mov dx,_sbport
  1730.         call resetdsp
  1731.         mov ah,0d1h
  1732.         call writedsp
  1733.         mov cl,_sbirq
  1734.         mov bl,cl
  1735.         mov ah,0feh
  1736.         rol ah,cl
  1737.         in al,21h
  1738.         and al,ah
  1739.         jmp short $+2
  1740.         out 21h,al
  1741.         xor al,al
  1742.         out 0ch,al
  1743.         mov al,49h
  1744.         out 0bh,al
  1745.         ret
  1746. ;-----------------------------------------------------------------------------
  1747. installsbm:                             ; install SB mono mixing
  1748.  
  1749.         rept 5                          ;***********************
  1750.         mov ah,40h                      ;***********************
  1751.         call writedsp                   ;***********************
  1752.         mov ah,SBRATE                   ;***********************
  1753.         call writedsp                   ;***********************
  1754.         endm                            ;***********************
  1755.  
  1756.         mov mixrlen,sbnmixmatrixlen
  1757.         mov edx,DBUFLEN
  1758.         mov edi,offset mixrout
  1759. installsbmml:
  1760.         mov esi,offset sbnmixmatrix
  1761.         mov ecx,sbnmixmatrixlen
  1762.         rep movsb
  1763.         dec edx
  1764.         jnz installsbmml
  1765.         mov al,0c3h
  1766.         stosb
  1767.         mov mixvoladdx,offset sbcvol
  1768.         mov mixfilllen,DBUFLEN/4
  1769.         mov v0.poff,0
  1770.         mov v2.poff,0
  1771.         ret
  1772. ;-----------------------------------------------------------------------------
  1773. installsbs:                             ; install SB stereo mixing
  1774.  
  1775.         rept 5                          ;***********************
  1776.         mov ah,40h                      ;***********************
  1777.         call writedsp                   ;***********************
  1778.         mov ah,SBPRATE                  ;***********************
  1779.         call writedsp                   ;***********************
  1780.         endm                            ;***********************
  1781.  
  1782.         sub dl,8
  1783.         mov al,0eh
  1784.         out dx,al
  1785.         inc edx
  1786.         mov al,2
  1787.         jmp short $+2
  1788.         out dx,al
  1789.         mov mixrlen,sbpmixmatrixlen
  1790.         mov edx,DBUFLEN
  1791.         mov edi,offset mixrout
  1792. installsbsml:
  1793.         mov esi,offset sbpmixmatrix
  1794.         mov ecx,sbpmixmatrixlen
  1795.         rep movsb
  1796.         dec edx
  1797.         jnz installsbsml
  1798.         mov al,0c3h
  1799.         stosb
  1800.         mov mixvoladdx,offset sbpvol
  1801.         mov mixfilllen,DBUFLEN/2
  1802.         mov v0.poff,1
  1803.         mov v2.poff,1
  1804.         ret
  1805.  
  1806. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1807. ; Uninstall all drivers
  1808. ; In:
  1809. ;   None
  1810. ; Out:
  1811. ;   None
  1812. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1813. _uninstall_dfm:
  1814.         cmp installed,0
  1815.         je _ret
  1816.         mov installed,0
  1817.         call _stopmuzik
  1818.         push ax
  1819.         push cx
  1820.         push dx
  1821.         pushf
  1822.         cli
  1823.         in al,61h                       ; shuddap pc squeeker
  1824.         and al,0fch
  1825.         out 61h,al
  1826.         test modebitmap,1               ; uninstall SB handler.?
  1827.         jnz short uninstallf1
  1828.         test modebitmap,8
  1829.         jz short uninstallf0
  1830.         mov _dspout,1
  1831.         mov dx,_sbport
  1832.         sub dl,8
  1833.         mov al,0eh
  1834.         out dx,al
  1835.         inc edx
  1836.         jmp short $+2
  1837.         xor al,al
  1838.         out dx,al
  1839. uninstallf1:
  1840.         call stopsmp2
  1841.         mov dx,_sbport
  1842.         mov ah,0d3h
  1843.         call writedsp
  1844.         mov ah,1
  1845.         mov cl,_sbirq
  1846.         shl ah,cl
  1847.         in al,21h
  1848.         or al,ah
  1849.         jmp short $+2
  1850.         out 21h,al
  1851. uninstallf0:
  1852.         test modebitmap,8               ; uninstall IRQ0 handler.?
  1853.         jnz short uninstalld
  1854.         in al,21h
  1855.         or al,1
  1856.         jmp short $+2
  1857.         out 21h,al
  1858.         mov al,36h
  1859.         out 43h,al
  1860.         xor al,al
  1861.         out 40h,al
  1862.         jmp short $+2
  1863.         out 40h,al
  1864. uninstalld:
  1865.         popf
  1866.         pop dx
  1867.         pop cx
  1868.         pop ax
  1869.         ret
  1870.  
  1871. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1872. ; Set muzik at block
  1873. ; In:
  1874. ;   EDX -> 670 muzik block
  1875. ; Out:
  1876. ;   None
  1877. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1878. _muzik:
  1879.         test _scard,1
  1880.         jz _ret
  1881.         call _stopmuzik
  1882.         push eax
  1883.         push ebx
  1884.         push edx
  1885.         pushf
  1886.         cli
  1887.         mov al,[edx]
  1888.         mov muztempo,al
  1889.         mov al,[edx+5]
  1890.         mov muzorderl,al
  1891.         lea ebx,[edx+10]
  1892.         mov muzordptr,ebx
  1893.         movzx eax,byte ptr [edx+1]
  1894.         mov muzordern,al
  1895.         add ebx,eax
  1896.         mov muzpatoffptr,ebx
  1897.         mov al,[edx+2]
  1898.         lea ebx,[ebx+eax*4]
  1899.         mov muzsbinsptr,ebx
  1900.         mov al,[edx+3]
  1901.         shl eax,4
  1902.         add ebx,eax
  1903.         mov muzfminsptr,ebx
  1904.         movzx eax,byte ptr [edx+4]
  1905.         imul eax,11
  1906.         add ebx,eax
  1907.         mov muzpatbase,ebx
  1908.         mov ebx,dword ptr [edx+6]
  1909.         add ebx,edx
  1910.         mov al,[edx+3]
  1911.         mov edx,muzsbinsptr
  1912.         or al,al
  1913.         jz short muzikd
  1914. muzikl0:
  1915.         mov [edx],ebx
  1916.         add [edx+8],ebx
  1917.         add [edx+12],ebx
  1918.         add ebx,[edx+4]
  1919.         mov [edx+4],ebx
  1920.         add edx,10h
  1921.         dec al
  1922.         jnz muzikl0
  1923. muzikd:
  1924.         mov muzdelay,1
  1925.         mov muztempoc,1
  1926.         mov muzorderc,-1
  1927.         mov muzcurptr,offset muzspecial
  1928.         or modebitmap,2
  1929.         mov phademul,10h
  1930.         mov phadeon,0
  1931.         popf
  1932.         pop edx
  1933.         pop ebx
  1934.         pop eax
  1935.         ret
  1936.  
  1937. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1938. ; Set muzik as U want
  1939. ; In:
  1940. ;   all muz ptrs and values are set
  1941. ; Out:
  1942. ;   None
  1943. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1944. _setmuzik:
  1945.         call _stopmuzik
  1946.         pushf
  1947.         cli
  1948.         mov muzdelay,1
  1949.         mov muztempoc,1
  1950. ;        mov muzorderc,-1
  1951.         mov muzcurptr,offset muzspecial
  1952.         or modebitmap,2
  1953.         mov phademul,10h
  1954.         mov phadeon,0
  1955.         popf
  1956.         ret
  1957.  
  1958. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1959. ; Stop muzik and shut off all sound/muzik output
  1960. ; In:
  1961. ;   None
  1962. ; Out:
  1963. ;   None
  1964. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1965. _stopmuzik:
  1966.         push ax
  1967.         push ebx
  1968.         push dx
  1969.         pushf
  1970.         cli
  1971.         mov dx,fmport
  1972.         test _scard,1
  1973.         jz short stopmuzikf0
  1974.         call reset_FMchip
  1975.         test _scard,2
  1976.         jz short stopmuzikf0
  1977.         add dl,2
  1978.         call reset_FMchip
  1979. stopmuzikf0:
  1980.         and modebitmap,0fdh
  1981.         mov ebx,offset v0
  1982. stopmuzikl0:
  1983.         mov [ebx].addx,0
  1984.         mov [ebx].end,0
  1985.         mov [ebx].lend,-1
  1986.         add ebx,size voice
  1987.         cmp ebx,offset v3
  1988.         jbe stopmuzikl0
  1989.         xor ebx,ebx
  1990. stopmuzikl1:
  1991.         mov fmlasti[ebx],-1
  1992.         mov fmlastv[ebx],-1
  1993.         mov fmschedn[ebx],-1
  1994.         mov fmschedi[ebx],-1
  1995.         mov fmschedv[ebx],-1
  1996.         inc ebx
  1997.         cmp ebx,18
  1998.         jb stopmuzikl1
  1999.         popf
  2000.         pop dx
  2001.         pop ebx
  2002.         pop ax
  2003.         ret
  2004.  
  2005. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2006. ; Phade muzik
  2007. ; In:
  2008. ;   AL - speed of phade (lower is faster)
  2009. ; Out:
  2010. ;   None
  2011. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2012. _phademuzik:
  2013.         mov phadeon,1
  2014.         mov phadedelay,al
  2015.         mov phadedelayc,al
  2016.         ret
  2017.  
  2018. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2019. ; Mix ahead for IRQ
  2020. ; In:
  2021. ;   None
  2022. ; Out:
  2023. ;   None
  2024. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2025. _mixahead:
  2026.         pushf
  2027.         test modebitmap,8
  2028.         jz mixaheadd
  2029.         cli
  2030.         mov al,mixedahead
  2031.         cmp al,1
  2032.         ja mixaheadd
  2033.         inc al
  2034.         mov mixedahead,al
  2035.         pushad
  2036.         test modebitmap,2               ; muzik playing?
  2037.         jz mixaheadf0
  2038.         cmp muztempoc,1
  2039.         jne mixaheadf0
  2040.         cmp muzdelay,1
  2041.         jne mixaheadf0
  2042.         sti
  2043.         mov esi,muzcurptr               ; time to sequence again
  2044.         and modebitmap,0dfh
  2045. mixaheadml:
  2046.         lodsb
  2047.         movzx ebx,al
  2048.         shr bl,5
  2049.         and al,1fh
  2050.         cmp bl,1
  2051.         ja short mixaheadf2
  2052.         cmp al,3
  2053.         ja short mixaheadf1
  2054. mixaheadf2:
  2055.         push offset mixaheadml
  2056.         jmp mixaheadtbl[ebx*4]
  2057. mixaheadf1:
  2058.         cmp bl,1
  2059.         adc esi,1
  2060.         jmp mixaheadml
  2061. mixaheadbreak:                          ; break pattern
  2062.         mov al,muzorderc
  2063.         inc al
  2064.         cmp al,muzordern
  2065.         jb short mixaheadbreakf0
  2066.         mov al,muzorderl
  2067. mixaheadbreakf0:
  2068.         movzx ebx,al
  2069.         add ebx,muzordptr
  2070.         mov al,[ebx]
  2071.         movzx ebx,al
  2072.         shl ebx,2
  2073.         add ebx,muzpatoffptr
  2074.         movzx esi,word ptr [ebx]
  2075.         add esi,muzpatbase
  2076.         ret
  2077. mixaheadwait:
  2078.         add esp,4
  2079. mixaheadf0:
  2080.         sti
  2081.         call mixgo
  2082.         popad
  2083. mixaheadd:
  2084.         popf
  2085.         ret
  2086.  
  2087. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2088. ; SFX AND AUX CODE
  2089. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2090.  
  2091. ifdef   FMNOTE
  2092. public  _fmnote
  2093. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2094. ; Play an FM note
  2095. ; In:
  2096. ;   AL - channel
  2097. ;   AH - note
  2098. ;   BL - volume
  2099. ;   EDX -> timbre data
  2100. ; Out:
  2101. ;   None
  2102. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2103. _fmnote:
  2104.         test _scard,1
  2105.         jz _ret
  2106.         push ax
  2107.         push dx
  2108.         push esi
  2109.         push edi
  2110.         push ebp
  2111.         pushf
  2112.         cli
  2113.         push ebx
  2114.         movzx edi,al
  2115.         mov fmlasti[edi],-1
  2116.         mov esi,edx
  2117.         mov dx,fmport
  2118.         test modebitmap,10h
  2119.         jnz short fmnotes
  2120.         cmp al,8
  2121.         ja short fmnoted
  2122.         push ax
  2123.         xor bl,bl
  2124.         jmp short fmnotef2
  2125. fmnotes:
  2126.         shr al,1
  2127.         setc bl
  2128.         push ax
  2129.         mov bh,bl
  2130.         shl bh,1
  2131.         add dl,bh
  2132.         movzx ebx,bl
  2133.         lea ebx,[ebx*8+ebx]
  2134. fmnotef2:
  2135.         push bx
  2136.         call fmsettimbre
  2137.         pop bx
  2138.         mov al,[esp]
  2139.         movzx esi,byte ptr [esp+2]
  2140.         mov ah,fmvoltbl[esi]
  2141.         call fmsetvolume
  2142.         pop ax
  2143.         movzx esi,ah
  2144.         mov edi,esi
  2145.         and si,0fh
  2146.         mov bx,fmnotefreq[esi*2]
  2147.         and di,70h
  2148.         shl di,6
  2149.         or ebx,edi
  2150.         call fmplaynote
  2151. fmnoted:
  2152.         pop ebx
  2153.         popf
  2154.         pop ebp
  2155.         pop edi
  2156.         pop esi
  2157.         pop dx
  2158.         pop ax
  2159.         ret
  2160. endif
  2161.  
  2162. ifdef   SBNOTE
  2163. public  _sbnote
  2164. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2165. ; Play a note on SB mixing system
  2166. ; In:
  2167. ;   AL - channel
  2168. ;   AH - note   (low 4 bits are note, high 3 are octave)
  2169. ;   BL - volume
  2170. ;   ECX - loop begin
  2171. ;   EDX - loop end
  2172. ;   ESI -> sample
  2173. ;   EBP - end of sample
  2174. ; Out:
  2175. ;   None
  2176. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2177. _sbnote:
  2178.         test modebitmap,8
  2179.         jz _ret
  2180.         push eax
  2181.         push bx
  2182.         push edi
  2183.         pushf
  2184.         cli
  2185.         movzx edi,al
  2186.         imul edi,size voice
  2187.         mov v0[edi].addx,esi
  2188.         mov v0[edi].end,ebp
  2189.         mov v0[edi].vol,bl
  2190.         mov v0[edi].lbeg,ecx
  2191.         mov v0[edi].lend,edx
  2192.         movzx eax,ah
  2193.         mov ebx,eax
  2194.         and bl,0fh
  2195.         and al,70h
  2196.         shr al,2
  2197.         lea eax,[eax*2+eax]
  2198.         add eax,ebx
  2199.         mov ax,sbnotefreq[eax*2]
  2200.         mov word ptr v0[edi].notem,ax
  2201.         dec ah
  2202.         mov v0[edi].freqw,ah
  2203.         xor ah,ah
  2204.         mov v0[edi].freqf,ax
  2205.         popf
  2206.         pop edi
  2207.         pop bx
  2208.         pop eax
  2209.         ret
  2210. endif
  2211.  
  2212. ifdef   PCSFX0
  2213. public  _pcsfxd
  2214. ifdef   PCSFX1
  2215. public  _pcsfx
  2216. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2217. ; PC SFX set routine
  2218. ; In:
  2219. ;   AL - FX number to play
  2220. ; Out:
  2221. ;   None
  2222. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2223. _pcsfx:
  2224.         push eax
  2225.         push edx
  2226.         mov edx,_pcsfxtblptr
  2227.         cmp al,byte ptr [edx]
  2228.         jae short pcsfxd
  2229.         movzx eax,al
  2230.         mov edx,[edx+eax*4+1]
  2231.         call _pcsfxd
  2232. pcsfxd:
  2233.         pop edx
  2234.         pop eax
  2235.         ret
  2236. endif
  2237. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2238. ; Output a direct PC fect direct
  2239. ; In:
  2240. ;   EDX -> PC sound fect data
  2241. ; Out:
  2242. ;   None
  2243. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2244. _pcsfxd:
  2245.         push ax
  2246.         pushf
  2247.         cli
  2248.         xor al,al
  2249.         out 42h,al
  2250.         mov al,[edx]
  2251.         inc edx
  2252.         out 42h,al
  2253.         mov pcsfxptr,edx
  2254.         in al,61h
  2255.         or al,3
  2256.         out 61h,al
  2257.         popf
  2258.         pop ax
  2259.         ret
  2260. endif
  2261.  
  2262. ifdef   FMSFX0
  2263. public  _fmsfxd
  2264. ifdef   FMSFX1
  2265. public  _fmsfx
  2266. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2267. ; Set an FM fect from table
  2268. ; In:
  2269. ;   AL - FX number to play
  2270. ; Out:
  2271. ;   None
  2272. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2273. _fmsfx:
  2274.         test _scard,1
  2275.         jz _ret
  2276.         push ax
  2277.         push edx
  2278.         push esi
  2279.         push ebp
  2280.         mov ebp,_fmsfxtblptr
  2281.         cmp al,byte ptr ds:[ebp]
  2282.         jae fmsfxd
  2283.         movzx esi,al
  2284.         mov esi,ds:[ebp+esi*4+5]
  2285.         mov ebp,ds:[ebp+1]
  2286. fmsfxml:
  2287.         lodsb
  2288.         cmp al,-1
  2289.         je short fmsfxd
  2290.         movzx edx,al
  2291.         imul edx,13
  2292.         add edx,ebp
  2293.         mov ax,[edx+11]
  2294.         call _fmsfxd
  2295.         jmp fmsfxml
  2296. fmsfxd:
  2297.         pop ebp
  2298.         pop esi
  2299.         pop edx
  2300.         pop ax
  2301.         ret
  2302. endif
  2303. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2304. ; Output a FM fect direct
  2305. ; In:
  2306. ;   AX  -  FM frequency (13 bits)
  2307. ;   EDX -> timbre data for fect
  2308. ; Out:
  2309. ;   None
  2310. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2311. _fmsfxd:
  2312.         test _scard,1
  2313.         jz _ret
  2314.         push ebx
  2315.         push dx
  2316.         push esi
  2317.         push edi
  2318.         push ebp
  2319.         pushf
  2320.         cli
  2321.         push ax
  2322.         mov al,_fmsfxch
  2323.         mov ah,_fmsfxchl
  2324.         cmp al,ah
  2325.         jae short fmsfxdf0
  2326.         mov al,ah
  2327. fmsfxdf0:
  2328.         cmp al,_fmsfxchh
  2329.         jbe short fmsfxdf1
  2330.         mov al,ah
  2331. fmsfxdf1:
  2332.         movzx edi,al
  2333.         inc al
  2334.         mov _fmsfxch,al
  2335.         mov fmlasti[edi],-1
  2336.         mov esi,edx
  2337.         mov dx,fmport
  2338.         test modebitmap,10h
  2339.         jnz short fmsfxds
  2340.         cmp al,8
  2341.         ja short fmsfxdd
  2342.         push ax
  2343.         xor bl,bl
  2344.         jmp short fmsfxdf2
  2345. fmsfxds:
  2346.         shr al,1
  2347.         setc bl
  2348.         push ax
  2349.         mov bh,bl
  2350.         shl bh,1
  2351.         add dl,bh
  2352.         movzx ebx,bl
  2353.         lea ebx,[ebx*8+ebx]
  2354. fmsfxdf2:
  2355.         call fmsettimbre
  2356.         pop ax
  2357.         mov bx,[esp]
  2358.         call fmplaynote
  2359. fmsfxdd:
  2360.         pop ax
  2361.         popf
  2362.         pop ebp
  2363.         pop edi
  2364.         pop esi
  2365.         pop dx
  2366.         pop ebx
  2367.         ret
  2368. endif
  2369.  
  2370. ifdef   SBSFXM0
  2371. public  _sbsfxmd
  2372. ifdef   SBSFXM1
  2373. public  _sbsfxm
  2374. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2375. ; Set an SB mixing fect from table
  2376. ; In:
  2377. ;   AL - FX number to play
  2378. ; Out:
  2379. ;   None
  2380. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2381. _sbsfxm:
  2382.         push ax
  2383.         push bx
  2384.         push ecx
  2385.         push edx
  2386.         push esi
  2387.         push ebp
  2388.         mov edx,_sbsfxtblptr
  2389.         cmp al,byte ptr [edx]
  2390.         jae short sbsfxmd
  2391.         movzx ecx,al
  2392.         movzx ax,byte ptr [edx+ecx*2+5]
  2393.         shl ax,4
  2394.         movzx esi,byte ptr [edx+ecx*2+6]
  2395.         shl esi,2
  2396.         add esi,[edx+1]
  2397.         mov esi,[esi]
  2398.         mov ebp,[esi]
  2399.         add esi,4
  2400.         add ebp,esi
  2401.         mov bl,0fh
  2402.         xor ecx,ecx
  2403.         mov edx,-1
  2404.         call _sbsfxmd
  2405. sbsfxmd:
  2406.         pop ebp
  2407.         pop esi
  2408.         pop edx
  2409.         pop ecx
  2410.         pop bx
  2411.         pop ax
  2412.         ret
  2413. endif
  2414. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2415. ; SB SFX mixing set direct out
  2416. ; In:
  2417. ;   AX - high and low speed
  2418. ;   BL - volume
  2419. ;   ECX - loop begin
  2420. ;   EDX - loop end
  2421. ;   ESI -> sample
  2422. ;   EBP - end of sample
  2423. ; Out:
  2424. ;   None
  2425. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2426. _sbsfxmd:
  2427.         test modebitmap,8
  2428.         jz _ret
  2429.         push edi
  2430.         pushf
  2431.         cli
  2432.         push ax
  2433.         mov al,_sbsfxch
  2434.         mov ah,_sbsfxchl
  2435.         cmp al,ah
  2436.         jae short sbsfxmdf0
  2437.         mov al,ah
  2438. sbsfxmdf0:
  2439.         cmp al,_sbsfxchh
  2440.         jbe short sbsfxmdf1
  2441.         mov al,ah
  2442. sbsfxmdf1:
  2443.         movzx edi,al
  2444.         inc al
  2445.         mov _sbsfxch,al
  2446.         mov ax,[esp]
  2447.         imul edi,size voice
  2448.         mov v0[edi].addx,esi
  2449.         mov v0[edi].end,ebp
  2450.         mov v0[edi].vol,bl
  2451.         mov v0[edi].lbeg,ecx
  2452.         mov v0[edi].lend,edx
  2453.         mov word ptr v0[edi].notem,ax
  2454.         dec ah
  2455.         mov v0[edi].freqw,ah
  2456.         xor ah,ah
  2457.         mov v0[edi].freqf,ax
  2458.         pop ax
  2459.         popf
  2460.         pop edi
  2461.         ret
  2462. endif
  2463.  
  2464. ifdef   SBSFXS0
  2465. public  _sbsfxsd
  2466. ifdef   SBSFXS1
  2467. public  _sbsfxs
  2468. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2469. ; SB SFX single set routine
  2470. ; In:
  2471. ;   AL - FX number to play
  2472. ; Out:
  2473. ;   None
  2474. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2475. _sbsfxs:
  2476.         push bx
  2477.         push ecx
  2478.         push edx
  2479.         mov edx,_sbsfxtblptr
  2480.         cmp al,byte ptr [edx]
  2481.         jae short sbsfxsd
  2482.         movzx ecx,al
  2483.         mov bl,[edx+ecx*2+5]
  2484.         movzx ecx,byte ptr [edx+ecx*2+6]
  2485.         shl ecx,2
  2486.         add ecx,[edx+1]
  2487.         mov edx,[ecx]
  2488.         mov ecx,[edx]
  2489.         add edx,4
  2490.         call _sbsfxsd
  2491. sbsfxsd:
  2492.         pop edx
  2493.         pop ecx
  2494.         pop bx
  2495.         ret
  2496. endif
  2497. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2498. ; Play digital sample at EDX direct using single out
  2499. ; In:
  2500. ;   EDX -> digital data (must be in low mem)
  2501. ;   ECX - length
  2502. ;   BL - sampling rate (as for SB)
  2503. ; Out:
  2504. ;   None
  2505. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2506. _sbsfxsd:
  2507.         test modebitmap,1
  2508.         jz _ret
  2509.         call _stopsmp
  2510.         push eax
  2511.         push bx
  2512.         push edx
  2513.         mov dmaolen,ecx
  2514.         add edx,_code32a
  2515.         mov dmaoaddx,dx
  2516.         shr edx,16
  2517.         mov dmaopage,dl
  2518.         mov dx,_sbport
  2519.         mov ah,40h
  2520.         call writedsp
  2521.         mov ah,bl
  2522.         call writedsp
  2523.         mov ah,0f2h
  2524.         call writedsp
  2525.         pop edx
  2526.         pop bx
  2527.         pop eax
  2528.         ret
  2529. endif
  2530.  
  2531. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2532. ; Stop digital output
  2533. ; In:
  2534. ;   None
  2535. ; Out:
  2536. ;   None
  2537. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2538. _stopsmp:
  2539.         test modebitmap,1
  2540.         jz _ret
  2541. stopsmp2:
  2542.         jmp _ret                        ;88888888888888888888888888888888888
  2543.         pushf
  2544.         push ax
  2545.         push dx
  2546.         mov dx,_sbport
  2547. stopsmpl:
  2548.         sti
  2549.         cmp _dspout,0
  2550.         je short stopsmpd
  2551.         cli
  2552.         in al,dx
  2553.         or al,al
  2554.         jns stopsmpl
  2555.         in al,dx
  2556.         or al,al
  2557.         js $-3
  2558.         mov al,0d0h
  2559.         out dx,al
  2560.         mov al,5
  2561.         out 0ah,al
  2562.         add dl,2
  2563.         in al,dx
  2564.         mov _dspout,0
  2565.         sti
  2566. stopsmpd:
  2567.         pop dx
  2568.         pop ax
  2569.         popf
  2570.         ret
  2571.  
  2572. ifdef   ADJSMP
  2573. public  _adjsmp
  2574. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2575. ; Halve volume of digital sample
  2576. ; In:
  2577. ;   ECX - length of sample
  2578. ;   EDX -> sample
  2579. ; Out:
  2580. ;   None
  2581. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2582. _adjsmp:
  2583.         push ax
  2584.         push ecx
  2585.         push edx
  2586. adjsmpml:
  2587.         mov al,[edx]
  2588.         shr al,1
  2589.         add al,40h
  2590.         mov [edx],al
  2591.         inc edx
  2592.         loop adjsmpml
  2593.         pop edx
  2594.         pop ecx
  2595.         pop ax
  2596.         ret
  2597. endif
  2598.  
  2599. code32  ends
  2600.         end
  2601.  
  2602.