home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / AMOD095.ZIP / MODTEST.PAS < prev    next >
Pascal/Delphi Source File  |  1995-12-21  |  2KB  |  78 lines

  1. uses modunit,dos,crt;
  2. const
  3. hex_tbl : array[0..15] of char = ('0','1','2','3','4','5','6','7',
  4.                                   '8','9','A','B','C','D','E','F');
  5.  
  6. function findgus : word;
  7. {Returns Base address and sets GUS IRQ if ULTRASND environment found}
  8. var
  9. n,c,i : word;
  10. s : string;
  11. begin
  12.   s := getenv('ultrasnd');
  13.   if s = '' then begin
  14.     findgus := 0;
  15.     exit;
  16.   end;
  17.   val(copy(s,1,3),n,c);
  18.   if c <> 0 then begin
  19.     findgus := 0;
  20.     exit;
  21.   end;
  22.   case n of
  23.     210 : i := $210;
  24.     220 : i := $220;
  25.     230 : i := $230;
  26.     240 : i := $240;
  27.     250 : i := $250;
  28.     260 : i := $260;
  29.     270 : i := $270;
  30.     else begin
  31.       findgus := 0;
  32.       exit;
  33.     end;
  34.   end;
  35.   for n := 1 to 3 do delete(s,1,pos(',',s));
  36.   if gus_irq = 0 then begin
  37.     val(copy(s,1,pos(',',s)-1),gus_irq,c); {Set IRQ}
  38.     if c <> 0 then gus_irq := 0;
  39.   end;
  40.   findgus := i;
  41. end;
  42.  
  43. begin
  44.   if paramcount < 1 then halt(1);
  45.  
  46.   gus_base := findgus;  {Look for ULTRASND environment. Set base port & IRQ}
  47.   gusfind;  {This HARDWARE DETECTS your GUS. It DOES NOT look for ULTRASND
  48.              environment. You MUST call this even if you set base address
  49.              directly!}
  50.   gusreset; {Reset GUS}
  51.   writeln('GUS found at ',gus_base,' IRQ ',gus_irq,
  52.           ' with ',gusfindmem,' bytes of memory');
  53.  
  54.   {gus_irq := 0}  {If you want to use system timer}
  55.   {gus_irq := 11} {If you want to use GUS's irq (11 in this case)}
  56.   init_mod;  {Initialises mod routines and sets up interrupt}
  57.  
  58.   load_mod(paramstr(1));  {Loads mod/s3m}
  59.   if mod_error <> 0 then begin
  60.     writeln('Load error!');
  61.     halt(1);
  62.   end;
  63.   start_playing;  {Starts playing}
  64.  
  65.   writeln('Playing ',paramstr(1));
  66.   repeat
  67.     write(#13,'POS:',cur_ptn:2,' ROW:',cur_row:2);
  68.   until keypressed;
  69.   readkey;
  70.   writeln;
  71.  
  72.   stop_playing; {Stops playing}
  73.   free_mod;     {Frees memory taken by mod}
  74.   done_mod;     {Restores interrupt and deinit's GUS. You MUST call this at
  75.                  the end of your program!}
  76. end.
  77.  
  78.