unit variab;

interface

TYPE
  Pt = record                           { makes simple pointer   }
    ofs,sgm  :  word;                   { handling possible    }
  end;

  Effect_Type = record
     p  : pointer;
     l  : longint;
     sr : word;
   end;

  Param_Table = record
    mult  : word;
    Speed : word;
    bgr   : word;
    Ab    : integer;
   end;
TYPE VocHeader = record
       IDstr   : array[0..19] of char;
       Sampoff : word;
       Verslo  : Byte;
       Vershi  : Byte;
       ID      : word;
     end;

     VoiceBlock = record
       ID       : byte;
       Leng_lo  : word;
       Leng_hi  : byte;
       SR       : byte;
       Pack     : byte;
     end;



CONST Block_Active : byte = 1;
  Incfacts : array[1..99] of longint =
    ( $0021E7,$0023EB,$00260E,$002851,$002AB7,$002D41,$002FF2,$0032CC,
      $0035D1,$003904,$003C68,$004000,$0043CE,$0047D6,$004C1C,$0050A2,
      $00556E,$005A82,$005FE4,$006598,$006BA2,$007209,$0078D0,$007FFF,
      $00879C,$008FAC,$009837,$00A144,$00AADB,$00B504,$00BFC8,$00CB2F,
      $00D744,$00E411,$00F1A1,$00FFFF,$010F39,$011F5A,$013070,$01428A,
      $0155B8,$016A09,$017F91,$01965F,$01AE89,$01C823,$01E343,$01FFFF,
      $021E72,$023EB3,$0260DF,$028514,$02AB6F,$02D413,$02FF21,$032CC0,
      $035D14,$039047,$03C686,$03FFFF,$043CE4,$047D66,$04C1BF,$050A29,
      $0556E0,$05A827,$05FE43,$06597F,$06BA27,$07208F,$078D0D,$07FFFF,
      $0879C7,$08FACC,$09837E,$0A1451,$0AADC0,$0B504F,$0BFC87,$0CB2FF,
      $0D744F,$0E411F,$0F1A1C,$0FFFFF,$10F38F,$11F59A,$1306FE,$1428A3,
      $155B81,$16A09E,$17F910,$1965FE,$1AE89F,$1C823D,$1E3438,$1FFFFF,
      $21E71E, $23EB35,$260DFC
    );

  OutFading     : boolean = false;
  OutVolume     : byte = 63;
  Msp           : longint = 0;
  ModDatSize    : longint = 0;
  Filter_Active : boolean = false;
  Balance       : byte = 12;
  MasterVolume  : byte = 29;
  StartPort     : word = $200;
  EndPort       : word = $280;
  PlaySpeed     : byte = 6;

  Detect = 55555;
  SamFreq    : word = 22;
  Force_Mono : boolean = false;
  Force_SB   : boolean = false;
  Force_IRQ  : boolean = false;
  Force_DMA  : boolean = false;
  Force_Base : boolean = false;
  PC    = 0;
  AMIGA = 1;
  M669               : boolean = false;
  Interrupt_Found    : boolean = false;
  Interrupt_Check    : boolean = false;
  Choose_Lower_Freq  : boolean = false;
  Timer_Per_Second   : word = 50;       { Number interrupts per Sec. }
  Sampling_Frequency : word = 10000;    { Samplingfreq.; Default }
  In_Retrace         : boolean = false; { Currently in Retracing-Proc ? }
  Dsp_IRQ            : byte = $5;       { SB interrupt, value will be}
                                        { changed by the Init routine     }
  DMA_Ch : byte = 1;                    { DMA channel, default  }
                                        { = 1, on SB 16 ASP other values}
                                        { also possible ...     }
  Dsp_Addr : word = $220;               { Base address of DSP.   }
                                        { Value changed by the Init   }
                                        { routine           }
  SBVersMin      : BYTE = 0;            { Version  ID     }
  SBVersMaj      : BYTE = 0;
  Stereo         : BOOLEAN = false;     { Play back in stereo        }
  SBRegDetected  : BOOLEAN = FALSE;     { normal SB present ?     }
  IRQDetected    : BOOLEAN = FALSE;
  SBRegInited    : BOOLEAN = FALSE;
  SBProDetected  : BOOLEAN = FALSE;     { SB Pro present ?         }
  SBProInited    : BOOLEAN = FALSE;
  SB16Detected   : BOOLEAN = FALSE;     { SB 16 ASP present ?      }
  SB16Inited     : BOOLEAN = FALSE;
  MixerDetected  : BOOLEAN = FALSE;     { If yes, card >= SB Pro   }
  OldTimerInt              = $71;       { Orginal Int routine of    }
                                        { deflected/bent Timer - Int.    }
  Voices         : integer = 4;         { Number of voices in the    }
                                        { MOD file                   }
  Modoctave : array[1..70] of word =
   (
    1712,1616,1525,1440,1359,1283,1211, { The values in Modoctave }
    1143,1078,961,907,856,808,763,720,  { match the values that are   }
    679,641,605,571,539,509,480,453,428,{ stored in the MOD file as }
    404,381,360,340,321,303,286,270,254,{ pitches.                            }
    240,227,214,202,191,180,170,160,151,
    143,135, 127,120,113,107,101,95,90,
    85,80,76,71,67,64,60,57,
    54,51,48,45,43,40,38,36,34,32,30);

{ PermUp_1           : byte = 0;        { Portamento Up voice ? }
{ PermUp_2           : byte = 0;
 PermUp_3            : byte = 0;
 PermUp_4            : byte = 0;
 PermUp_5            : byte = 0;
 PermUp_6            : byte = 0;
 PermUp_7            : byte = 0;
 PermUp_8            : byte = 0;
 PermDo_1            : byte = 0;        { Portamento Down voice }
 {PermDo_2           : byte = 0;
 PermDo_3            : byte = 0;
 PermDo_4            : byte = 0;
 PermDo_5            : byte = 0;
 PermDo_6            : byte = 0;
 PermDo_7            : byte = 0;
 PermDo_8            : byte = 0;
 PermDc1             : word = 0;
 PermDc2             : word = 0;
 PermDc3             : word = 0;
 PermDc4             : word = 0;
 PermDc5             : word = 0;
 PermDc6             : word = 0;
 PermDc7             : word = 0;
 PermDc8             : word = 0;}

 AUTO = 9999;                           { ID for auto detection }
 ON   = true;
 OFF  = false;
 PlayEffect   : boolean = false;
 EffectVolume : word = 7;
 ConverTeff   : byte = 0;
 Sensib       : real = 0.9;

 DMA_page : array[0..3] of byte = ($87,$83,$81,$81);
 DMA_Addr : array[0..3] of byte = (0,2,4,6);
 DMA_WC   : array[0..3] of byte = (1,3,5,7);

 SB16_OutputLength : word = 0;
 Last_Output       : boolean = false;

VAR
 OldIntCounter : word;
 Efi           : file;
 Outfile       : file;
{ ModPara : array[0..64] of Param_Table;}
 BlockSize    : word;                   { Size of sound buffer    }
 Dsp_Rdy_SB16 : boolean;                { Flag for end of data}
                                        { transfer via DMA      }
 SBVersStr    : string[5];              { SB version as string  }
 Speed        : word;                   { Playback speed     }
 OldInt       : pointer;                { For storage of interrupt   }
                                        { required by SB for DMA }
                                        { transfer                 }
 IRQMsk       : byte;                   { for interrupt handling    }
 Mix_Proc     : pointer;                { pointer at routines that }
 Nmw_Proc     : pointer;                { are executed depending on the }
 Inside_Proc  : pointer;                { number of available voices  }
 Notes_Struck : array[1..8]             { Time since last note struck }
                of integer;
 Rm_Song      : Array[1..64,1..8,       { A pattern                }
                      1..4] of Byte;
 Rm           : array[0..128]           { The individual patterns      }
                of pointer;
 Song         : array[1..128]           { Arrangement of song     }
                of byte;
 Blk          : pointer;                { Pointer to data - buffer }
 Inst         : array[1..8] of pointer;
 Samp         : Array[1..64]            { Field with pointers to       }
                of pointer;             { samples                    }
 Sam_l        : Array[1..64]            { Sample length      }
                of word;
 Loop_s       : array[1..64]            { Loop start of sample     }
                of word;
 Loop_l       : array[1..64]            { Loop length of sample     }
                of word;
 i1,i2,i3,i4,                           { Pointer to active sample }
 i5,i6,i7,i8  : pt;                     { in "pt" form               }
 inl          : array[1..8] of word;
 inp          : array[1..8] of word;
 I            : word;
 mlj          : word;                   { Loop counter, current }
                                        { pattern                    }
 mli          : word;                   { Loop counter, current  }
                                        { line in pattern           }
{ Ig1,Ig2,Ig3,                          { Integral value of factor,  }
{ Ig4,Igh,Ig5,                          { by which the pos. in the sample}
{ Ig6,Ig7,Ig8         : word;           { data must be incremented }
{ Dc1,Dc2,Dc3,                          { Decimal value of factor,  }
{ Dc4,Dch,Dc5,                          { by which the pos. in the sample}
{ Dc6,Dc7,Dc8           : byte;         { data must be incremented}
{ Dif1,Dif2,Dif3,
 Dif4,Dif5,Dif6,
 Dif7,Dif8              : byte;
 Difb1,Difb2,Difb3,
 Difb4,Difb5,Difb6,
 Difb7,Difb8            : byte;}
{ Inst1Ig               : word;         { Points to current sample }
{ Inst2Ig               : word;         { byte in the data               }
{ Inst3Ig               : word;
 Inst4Ig                : word;
 Inst5Ig                : word;
 Inst6Ig                : word;
 Inst7Ig                : word;
 Inst8Ig                : word;
 Inst1dc                : byte;         { Decimal part of sample  }
{ Inst2dc               : byte;         { byte                      }
{ Inst3dc               : byte;
 Inst4dc                : byte;
 Inst5dc                : byte;
 Inst6dc                : byte;
 Inst7dc                : byte;
 Inst8dc                : byte;}
 In_St            : array[1..8] of byte;
 Sam_Num          : byte;               { Number of sample          }
 Pat_Num          : byte;               { Number of pattern         }
 M_Played         : boolean;            { Music played ???  }
 Sound_Loops      : word;               { Number of passes of   }
                                        { the mix procedure             }
 Sampling_Rate    : byte;               { value passed to DSP for}
                                        { frequency               }
 Mod_Name         : string;             { DOS name of Mod file     }
 Tpw              : integer;            { Transposer - value          }
 Loop_Pos         : word;               { runvar., from 0 to speed  }
 Phase_1,                               { The two phases of the interrupt }
 Phase_2          : boolean;            { mix procedure         }
 Sample1,Sample2,                       { The active samples        }
 Sample3,Sample4,
 Sample5,Sample6,
 Sample7,Sample8  : pointer;
 Sasz1,Sasz2,                           { Size of the active sample  }
 Sasz3,Sasz4,
 Sasz5,Sasz6,
 Sasz7,Sasz8      : word;
 MAutoDet         : boolean;            { If TRUE, the speed specifications }
                                        { in the song are observed   }
 ModMultiply      : word;               { Speed specification in Song * Mod-}
                                        { multiply = Speed           }
 MLoop            : boolean;            { If TRUE, the MOD starts over  }
                                        { after playback}
 Periodic_Pause   : pointer;            { Pointer to Stop_Procedure  }
                                        { for output                }
 Music_Off        : boolean;            { If TRUE, no music will be }
                                        { played ...               }
 Notvol1,Notvol2,                       { Volume of the   }
 Notvol3,Notvol4,                       { channels           }
 Notvol5,Notvol6,
 Notvol7,Notvol8  : byte;
 Pnk              : array[1..8] of byte;
 Old_TCounter     : word;               { For synchronization of     }
                                        { old timer interrupt      }
 Dma_Counter      : integer;            { For intercepting the DMA_Ready }
                                        { interrupt                 }
 DMA_Termination  : integer;            { Termination value for Dma_Counter}
 Mod_Terminated   : boolean;            { Mod output terminated        }
 Ls               : array[1..8] of word;
 Ll               : array[1..8] of word;
 Eff              : array[1..8] of byte;
 SongName         : string[20];         { Name of Mod file      }
 InstNames        : array[1..31]        { Names of instruments      }
                    of string[22];
 Inst_Vol         : array[1..31]
                    of byte;
 SongLength       : byte;               { Length of song           }
 SecCounter       : word;               { for determining time         }
 RunSec,RunMin    : byte;               { Runtime of song        }
 PattSize         : integer;            { Pattern size of the Mod type }
 XMSMaxFree       : word;               { Max. free XMS memory   }
 MinXMS           : word;               { If XMSMaxFree < MinXms   }
 XMSHandles       : array[1..32]
                    of word;            { Handles for XMS            }
 SounDeff         : pointer;
 EffectSize       : word;
 EffectPosi       : word;
 EffLg            : word;
 EffDc            : byte;
 EffIsLg          : word;
 EffIsDc          : byte;
 Effect           : pt;
 Effect_Delete    : boolean;
 PitchValue       : byte;
 {tempolist       : array[1..128] of byte;
 breaklist        : array[1..128] of byte;}
 Destination      : pt;                 { playback buffer in pt format }
 ModP             : pointer;            { Pointer to Rm_Song        }
 Note1,Note2,                           { Active instument of the      }
 Note3,Note4,                           { voice                     }
 Note5,Note6,
 Note7,Note8      : byte;

 FadePos1,FadePos2,
 FadePos3,FadePos4,
 FadePos5,FadePos6,
 FadePos7,FadePos8 : word;

 IntBack : pointer;
 Port21  : byte;

 VocF        : file;
 Fsz         : longint;
 Blk1,Blk2   : pointer;
 VocH        : vocheader;
 VBlock      : voiceblock;
 IntPointer  : pointer;
 Dsp_Rdy_Voc : boolean;
 BlockSz     : word;
 Playing_Mod : boolean;
 Playing_Voc : boolean;
 DummArray   : array[1..20] of byte;
 LastOne     : boolean;
 Voc_Ready   : boolean;
 InRead      : array[1..25] of byte;
 VocsStereo  : boolean;
 Mod_At_End  : boolean;

implementation

begin;
end.



