{$F+}
{$M $4000,500000,650000}
program passwordquery;

uses crt,design;
const Passwords : array[1..10] of string =
        ('Abacus','Underground','Graphics','Sprites',
         'Dimension','Protection','Mode X','Assembly','Glass','VGA');
      Pw_Pages : array[1..10] of word =
        (17,47,94,158,167,211,89,29,181,35);

Var pw_no : byte;
    remaining_passes : byte;
    Password_correct : word;
    New_Pass : string;
    PNew_Password_select : pointer;
    PInput_Box_draw : pointer;
    PPassword_query : pointer;
    PSystem_stop : pointer;
    unnecessary_Variable1 : word;
    unnecessary_Variable2 : word;

{$L Pwmodul}
procedure Query_Loop; far; external;

procedure New_Password_select;
begin;
  pw_no := random(10)+1;
  unnecessary_Variable1 := 1;
  unnecessary_Variable2 := 2;
end;

procedure Input_Box_draw;
var pws : string;
begin;
  str(Pw_Pages[pw_no]:2,pws);
  asm int 3; end;
  Window1(6,10,52,6,'Please type the password on page '+pws+' of the manual',black,7);
  unnecessary_Variable1 := 1;
  unnecessary_Variable2 := 2;
  gotoxy(23,12);
end;

procedure Password_query;
begin;
  readln(New_Pass);
  unnecessary_Variable1 := 1;
  unnecessary_Variable2 := 2;
  if New_Pass = Passwords[pw_no] then
    Password_correct := 1
  else
    Password_correct := 0;
end;

procedure System_stop;
begin;
  textbackground(black);
  textcolor(7);
  clrscr;
  writeln('We probably would have been better off buying an original ...');
  halt(0);
end;


procedure Main_Program;
begin;
  textbackground(black);
  textcolor(7);
  clrscr;
  gotoxy(20,12);
  writeln('Welcome to the main program !');
  gotoxy(20,22);
  write('Enter to exit ... ');
  readln;
  halt(0);
end;

begin;
  textbackground(black);
  textcolor(7);
  clrscr;
  remaining_passes := 57;
  PNew_Password_select := @New_Password_select;
  PInput_Box_draw   := @Input_Box_draw;
  PPassword_query      := @Password_query;
  PSystem_stop        := @System_stop;
  randomize;
  Query_Loop;
end.
