program setup;

var f:text;
    n1,n2,n3,n4:char;
    exit:boolean;
    c:char;

Function GetKey (Var Key : Word) : Boolean; Assembler;
{ determine if key pressed and return it as a Word }
{ if Lo(key) = 0 and Hi(key) <> 0 then we have a FN key ! }
Asm
  MOV     AH, 1
  INT     16H
  MOV     AL, 0
  JE      @@1
  xor     AH, AH
  INT     16H
  LES     DI, Key
  MOV     Word PTR ES : [DI], AX
  MOV     AL, 1
 @@1 :
end;

Function GetChar (Var Key : Char) : Boolean;
{ determine if key pressed and return it as a Char}
Var
  c : Word;
begin
  Key := #0;
  if GetKey (c) then
  begin
    GetChar := True;
    if (LO (c) = 0) and (HI (c) <> 0) then
      Key := CHR ( HI (c) + 128 )  { add 128 For FN keys }
    else
      Key := CHR (LO (c) );
  end
  else
    GetChar := False;
end;


begin
     exit:=false;

     n1:='0';
     n2:='0';
     n3:='0';
     n4:='0';

     repeat
{           clrscr;}
  Writeln;
  Writeln('select soundcard thingie... ');
  Writeln('0. What is a sound card? ');
  Writeln('1. Gravis something');
  Writeln('2. Sound Blaster old one');
  Writeln('3. Sound Blaster old but not as old');
  Writeln('4. Sound Blaster professionaly old');
  Writeln('5. Sound Blaster 16 bits');
  Writeln('6. professional ZX-spectrum');
  repeat until getchar(n1)=true;

  if n1<>'0' then
     begin
  Writeln;
  Writeln('select I/O thingie... ');
  Writeln('1. 210h');
  Writeln('2. 220h');
  Writeln('3. 230h');
  Writeln('4. 240h');
  Writeln('5. 250h');
  Writeln('6. 260h');
  repeat until getchar(n2)=true;

  Writeln;
  Writeln('select number of IRQs per second: ');
  Writeln('1. 2 IRQ''s');
  Writeln('2. 3 IRQ''s');
  Writeln('3. 5 IRQ''s');
  Writeln('4. 7 IRQ''s');
  Writeln('5. 11 IRQ''s');
  Writeln('6. 12 IRQ''s');
  repeat until getchar(n3)=true;

  Writeln;
  Writeln('select DMA channel: ');
  Writeln('1. DMA Channel 1');
  Writeln('2. DMA Channel 2');
  Writeln('3. DMA Channel 3');
  Writeln('4. DMA Channel 5');
  repeat until getchar(n4)=true;


           {clrscr;}
           writeln (' Right now your choices are set to:');
           writeln (n1);
           writeln (n2);
           writeln (n3);
           writeln (n4);

  end
  else begin
            writeln ('no sound?!?!');
            writeln ('you sure?!?! y/n');
       end;

           writeln (' If your happy with present choices press y');
           repeat until getchar(c)=true;

           if c='y' then
              begin
              exit:=true;
              assign (f,'sound.dat');
              rewrite (f);
              writeln (f,n1);
              writeln (f,n2);
              writeln (f,n3);
              writeln (f,n4);
              writeln (f,'replace this line by a word and you get a response!');
              close (f);
              end;

     until exit=true;

end.