{$R-}    {Range checking off}
{$B+}    {Boolean complete evaluation on}
{$S+}    {Stack checking on}
{$I+}    {I/O checking on}
{$N-}    {No numeric coprocessor}
{$M 65500,16384,655360} {Turbo 3 default stack and heap}

PROGRAM RuneCasterUserSupported;

uses dos, crt, gdriver, printer, gkernel, gwindow, wrt, rhub;

const
  LM : integer = 2;  {left margin for text}
  ColumnWidth : integer = 44;  {width of text}

var
  C, L, N, M, X, Y : integer; {C # of Rune; L # of text lines; N, M counters}
                              { X, Y where to begin writing}
  V : real;
  SB, MC : char;

PROCEDURE Menu;  forward;

{-----------------------------}

PROCEDURE Definitions;
begin                        {max windows = 30}
                             {ymaxglb = 349 pixels; xmaxglb = 89 bytes}
  definewindow(1,2,15,11,106);      {windows 1-24 = rune #s}
  definewindow(2,13,15,22,106);
  definewindow(3,24,15,33,106);
  definewindow(4,35,15,44,106);
  definewindow(5,46,15,55,106);
  definewindow(6,57,15,66,106);
  definewindow(7,68,15,77,106);
  definewindow(8,79,15,88,106);
  definewindow(9,2,112,11,203);
  definewindow(10,13,112,22,203);
  definewindow(11,24,112,33,203);
  definewindow(12,35,112,44,203);
  definewindow(13,46,112,55,203);
  definewindow(14,57,112,66,203);
  definewindow(15,68,112,77,203);
  definewindow(16,79,112,88,203);
  definewindow(17,2,209,11,300);
  definewindow(18,13,209,22,300);
  definewindow(19,24,209,33,300);
  definewindow(20,35,209,44,300);
  definewindow(21,46,209,55,300);
  definewindow(22,57,209,66,300);
  definewindow(23,68,209,77,300);
  definewindow(24,79,209,88,300);
  definewindow(25,1,1,xmaxglb,ymaxglb);                 {whole screen}
  definewindow(26,2,316,88,342);                   {bottom input area}
  definewindow(27,8,trunc(ymaxglb/10),82,trunc(ymaxglb/3));    {title}
  defineheader(1,'1. MEANS');
  defineheader(2,'2. MOMENTUM');
  defineheader(3,'3. THORN');
  defineheader(4,'4. SPEECH');
  defineheader(5,'5. PATH');
  defineheader(6,'6. TORCH');
  defineheader(7,'7. GIVING');
  defineheader(8,'8. JOY');
  defineheader(9,'9. HAIL');
  defineheader(10,'10. NEED');
  defineheader(11,'11. ICE');
  defineheader(12,'12. HARVEST');
  defineheader(13,'13. FIR');
  defineheader(14,'14. LOT CUP');
  defineheader(15,'15. SUPPORT');
  defineheader(16,'16. SUN');
  defineheader(17,'17. STAR');
  defineheader(18,'18. SPROUTS');
  defineheader(19,'19. HORSE');
  defineheader(20,'20. PEOPLE');
  defineheader(21,'21. WATER');
  defineheader(22,'22. AWAKEN');
  defineheader(23,'23. DAY');
  defineheader(24,'24. HOME');
  defineworld(1,0,0,22,11);
  defineworld(2,0,0,6,11);
  defineworld(3,0,0,60,3);
  defineworld(4,0,0,31,7);
end;  {procedure Definitions}

{-----------------------------}

PROCEDURE DrawMainWindow(C : byte);
begin
  clearscreen;
  case C of
    0 : defineheader(25,'R  U  N  E  -  C  A  S  T  E  R');
    1 : defineheader(25,'R  U  N  E  -  C  A  S  T  E  R    /\/\/\    C  A  S  T     O  F    O  N  E');
    3 : defineheader(25,'R  U  N  E  -  C  A  S  T  E  R    /\/\/\    T  H  R  E  E     S  T  E  P  S');
    7 : defineheader(25,'R  U  N  E  -  C  A  S  T  E  R    /\/\/\    S  P  I  R  A  L     F  I  V  E');
    10 : defineheader(25,'R  U  N  E  -  C  A  S  T  E  R    /\/\/\    S  E  E     R  U  N  E  S');
    12 : defineheader(25,'R  U  N  E  -  C  A  S  T  E  R    /\/\/\    I  N  S  T  R  U  C  T  I  O  N  S');
    15 : defineheader(25,'R  U  N  E  -  C  A  S  T  E  R    /\/\/\    R  U  N  E     H  I  S  T  O  R  Y');
    20 : defineheader(25,'R  U  N  E  -  C  A  S  T  E  R    /\/\/\    B  O  O  K  S');
    end;  {case C}
  selectworld(1);
  selectwindow(25);
  setheaderon;
  setbackground(0);
  drawborder;
end;  {procedure DrawMainWindow}

{-----------------------------}

PROCEDURE DrawR(C : byte);

  PROCEDURE LeftL;
  begin
    drawline(2,2,2,10);
  end;  {subprocedure LeftL}

  PROCEDURE CenterL;
  begin
    drawline(3,2,3,10);
  end;  {subprocedure CenterL}

  PROCEDURE FarL;
  begin
    drawline(1,2,1,10);
  end;   {subprocedure FarL}

  PROCEDURE FarR;
  begin
    drawline(5,2,5,10);
  end;   {subprocedure FarR}

  PROCEDURE AngleUp;
  begin
    drawline(2,6,4,4);
  end;   {subprocedure AngleUp}

  PROCEDURE AngleDown;
  begin
    drawline(2,6,4,8);
  end;   {subprocedure AngleDown}

  PROCEDURE TopDown;
  begin
    drawline(2,2,4,4);
  end;   {subprocedure TopDown}

  PROCEDURE SecondDown;
  begin
    drawline(2,4,4,6);
  end;   {subprocedure SecondDown}

begin
  case C of
    1 : begin
      LeftL;
      drawline(2,4,4,2);
      AngleUp;
      end;  {1}
    2 : begin
      LeftL;
      TopDown;
      drawline(4,4,4,9);
      end;  {2}
    3 : begin
      LeftL;
      SecondDown;
      drawline(4,6,2,8);
      end;  {3}
    4 : begin
      LeftL;
      TopDown;
      SecondDown;
      end;  {4}
    5 : begin
      LeftL;
      TopDown;
      AngleUp;
      drawline(2,6,4,9);
      end;  {5}
    6 : begin
      AngleUp;
      AngleDown;
      end;  {6}
    7 : begin
      drawline(1,2,5,10);
      drawline(5,2,1,10);
      end;  {7}
    8 : begin
      LeftL;
      TopDown;
      AngleUp;
      end;  {8}
    9 : begin
      FarL;
      FarR;
      drawline(1,4,5,8);
      end;  {9}
    10 : begin
       CenterL;
       drawline(2,4,4,6);
       end;  {10}
    11 : begin
       CenterL;
       end;  {11}
    12 : begin
       drawline(3,3,1,5);
       drawline(1,5,3,7);
       drawline(3,5,5,7);
       drawline(5,7,3,9);
       end;  {12}
    13 : begin
       CenterL;
       drawline(3,2,4,3);
       drawline(3,10,2,9);
       end;  {13}
    14 : begin
       FarL;
       drawline(1,2,3,3);
       drawline(3,3,5,2);
       drawline(1,10,3,9);
       drawline(3,9,5,10);
       end;  {14}
    15 : begin
       CenterL;
       drawline(1,2,3,4);
       drawline(3,4,5,2);
       end;  {15}
    16 : begin
       drawline(4,2,2,4);
       drawline(2,4,4,8);
       drawline(4,8,2,10);
       end;  {16}
    17 : begin
       CenterL;
       drawline(1,4,3,2);
       drawline(3,2,5,4);
       end;  {17}
    18 : begin
       LeftL;
       TopDown;
       AngleUp;
       AngleDown;
       drawline(4,8,2,10);
       end;  {18}
    19 : begin
       FarL;
       drawline(1,2,3,3);
       drawline(3,3,5,2);
       FarR;
       end;  {19}
    20 : begin
       FarL;
       drawline(1,2,5,4);
       drawline(1,4,5,2);
       FarR;
       end;  {20}
    21 : begin
       LeftL;
       TopDown;
       end;  {21}
    22 : begin
       drawline(3,7,2,5);
       drawline(2,5,3,3);
       drawline(3,3,4,5);
       drawline(4,5,3,7);
       end;  {22}
    23 : begin
       FarL;
       FarR;
       drawline(1,2,5,10);
       drawline(5,2,1,10);
       end;  {23}
    24 : begin
       drawline(3,2,2,4);
       drawline(2,4,4,10);
       drawline(3,2,4,4);
       drawline(4,4,2,10);
       end;  {24}
    end;  {case C}
end;  {procedure DrawR}

{-----------------------------}

PROCEDURE TitleScreen;
begin
  selectworld(1);
  selectwindow(25);
  drawborder;
  selectworld(4);
  selectwindow(27);
  sound(131);
  drawline(0,7,0,0);  {R}
  drawline(0,0,2,2);
  drawline(2,2,0,4);
  drawline(0,4,2,6);
  sound(147);
  drawline(3,0,3,7);  {U}
  drawline(3,7,5,6);
  drawline(5,6,5,0);
  sound(165);
  drawline(6,7,6,0);  {N}
  drawline(6,1,8,6);
  drawline(8,7,8,0);
  sound(175);
  drawline(11,1,9,0);  {E}
  drawline(9,0,9,7);
  drawline(9,7,11,6);
  drawline(9,3,11,3);
  sound(196);
  drawline(12,3,13,3);  {-}
  delay(15); sound(220);
  drawline(16,0,14,3);  {C}
  drawline(14,3,16,7);
  sound(247);
  drawline(17,7,17,0);  {A}
  drawline(17,0,19,1);
  drawline(19,1,19,7);
  drawline(17,2,19,3);
  sound(262);
  drawline(22,0,20,2);  {S}
  drawline(20,2,22,5);
  drawline(22,5,20,7);
  sound(294);
  drawline(23,1,24,0);  {T}
  drawline(24,0,25,1);
  drawline(24,0,24,7);
  sound(330);
  drawline(28,1,26,0);  {E}
  drawline(26,0,26,7);
  drawline(26,7,28,6);
  drawline(26,3,28,3);
  sound(349);
  drawline(29,7,29,0);  {R}
  drawline(29,0,31,2);
  drawline(31,2,29,4);
  drawline(29,4,31,6);
  sound(523); delay(100); nosound;
  gotoxy(28,10);
  write('User Supported Version 1.01');
  gotoxy(27,12);
  write('Copyright 1988 by Eric Meller');
  selectworld(1);
  selectwindow(25);
  setlinestyle(3);
  drawsquare(2,6,20,9,false);
  setlinestyle(0);
  drawtextw(3,7,2,'An Ancient Tool of Divination in Modern Form');
  drawtextw(4,8,2,'for Personal Understanding and Growth');
  selectworld(3);
  selectwindow(26);
  drawborder;
  gotoxy(28,24);
  write('Press space bar to begin...');
  repeat
    SB := readkey;
  until SB = ' ';
  sound(2000); delay(145); nosound;
end;  {procedure TitleScreen)

{-----------------------------}

PROCEDURE FlashAllRunes; {right after TitleScreen only}
var  J, I : word;
begin
  DrawMainWindow(0);
  setbackground(85);
  selectworld(2);
  for C := 1 to 24 do begin
    randomize;
    selectwindow(C);
    drawborder;
    setbackground(0);
    sound(400 + random(20));
    delay(10);
    for J := 1 to (10 + random(40)) do begin
      sound(random(100));
      delay(1);
      end;
    nosound;
    DrawR(C);
    delay(30 + random(10));
    end;  {for C}
  copyscreen;            {saved for SeeIndivRunes}
  selectworld(3);
  selectwindow(26);
  drawborder;
  setbackground(0);
  for J := 1 to 2 do begin
    gotoxy(21,24);
    write('W e l c o m e  t o  R u n e - C a s t e r');
    sound(1800); delay(145);
    nosound; delay(400);
    gotoxy(21,24); clreol;
    delay(300);
    end;  {for J}
  gotoxy(21,24);
  write('W e l c o m e  t o  R u n e - C a s t e r');
    sound(1800); delay(225);
    nosound; delay(2000);
end;  {procedure FlashAllRunes}

{-----------------------------}
(*
PROCEDURE WriteRuneText(C : integer);
var
  RuneText : text;
  RF : string[7];
  Line : string[90];
  Holder : string[44];  {must = ColumnWidth}
  Ch : string[1];
  LineFull : boolean;
  HoldEmpty : integer;   {HoldEmpty empty part of Holder}

  PROCEDURE PadHolder;  {to write flush right}
  var T : integer;
  begin
    repeat
      Ch := copy(Holder,length(Holder),1);
      if (Ch = ' ') then delete(Holder,length(Holder),1);
    until Ch <> ' ';
    T := length(Holder);
    for N := 1 to (ColumnWidth - T) do insert(' ',Holder,1);
  end;  {subprocedure PadHolder}

BEGIN   {main statement part of procedure WriteRuneText}
  case C of
    1  : RF := 'R1.TXT';
    2  : RF := 'R2.TXT';
    3  : RF := 'R3.TXT';
    4  : RF := 'R4.TXT';
    5  : RF := 'R5.TXT';
    6  : RF := 'R6.TXT';
    7  : RF := 'R7.TXT';
    8  : RF := 'R8.TXT';
    9  : RF := 'R9.TXT';
    10 : RF := 'R10.TXT';
    11 : RF := 'R11.TXT';
    12 : RF := 'R12.TXT';
    13 : RF := 'R13.TXT';
    14 : RF := 'R14.TXT';
    15 : RF := 'R15.TXT';
    16 : RF := 'R16.TXT';
    17 : RF := 'R17.TXT';
    18 : RF := 'R18.TXT';
    19 : RF := 'R19.TXT';
    20 : RF := 'R20.TXT';
    21 : RF := 'R21.TXT';
    22 : RF := 'R22.TXT';
    23 : RF := 'R23.TXT';
    24 : RF := 'R24.TXT';
    end;  {case C}
  assign(RuneText,RF);
  reset(RuneText);
  readln(RuneText,Line);   {sequence before repeat is for title}
  X := LM;  Y := 2;
  setwindowmodeoff;
  gotoxy(X,Y);
  Holder := Line;
  PadHolder;
  write(Holder);
  L := 1;
  Y := Y + 1;
  Holder := '';
  Line := '';
  repeat
    if Line = '' then readln(RuneText,Line);
    HoldEmpty := ColumnWidth - length(Holder);
    LineFull := false;
    if length(Line) > HoldEmpty then begin
      if HoldEmpty > 0 then repeat
        Ch := copy(Line,HoldEmpty,1);
        if (Ch <> ' ') then HoldEmpty := HoldEmpty - 1;
      until (Ch = ' ') or (HoldEmpty = 0);
      if HoldEmpty > 0 then begin
        Holder := Holder + ' ' + copy(Line,1,HoldEmpty);
        delete(Line,1,HoldEmpty);
        end;  {if HoldEmpty > 0}
      LineFull := true;
      end {if length(Line) > }
    else begin  {ie if length(Line) <= HoldEmpty}
      Holder := Holder + ' ' + Line;
      if length(Line) = HoldEmpty then LineFull := true;
      if (length(Line) < HoldEmpty) and (eof(RuneText)) then LineFull := true;
      Line := '';
      end;  {else, ie if length(Line) <= HoldEmpty}
    if LineFull = true then begin
      gotoxy(X,Y);
      PadHolder;
      write(Holder);
      L := L + 1;
      Y := Y + 1;
      Holder := '';
      end;  {if LineFull true}
  until (eof(RuneText)) and (Line = '');
  close(RuneText);
  setwindowmodeon;
end;  {procedure WriteRuneText}
*)
{-----------------------------}

PROCEDURE GetRandomRune(var C : integer);
var
  Z : char;
  D : integer;
  J : word;
begin
  D := 0;
  randomize;
  selectworld(2);
  setheaderoff;
  repeat
    C := random(24) + 1;
    redefinewindow(C,40,34,49,109);
    if D > 0 then begin        {erase}
      setcolorblack;
      drawR(D);
      setcolorwhite;
      end;  {if D}
    selectwindow(C);
    drawborder;
    for J := 1 to 10 do begin
      sound(random(100));
      delay(1);
      end;
    nosound;
    drawR(C);
    D := C;
  until keypressed;
  C := random(24) + 1;
  Z := readkey;  {protects later kbd reads from getting this keypressed}
  setcolorblack;
    drawR(D);
    drawborder;
    setcolorwhite;
  setheaderon;
  sound(1047); delay(100); nosound;
end;  {procedure GetRandomRune}

{-----------------------------}
(*
PROCEDURE EraseText;
begin
  Y := 2;
  gotoxy(LM,Y);
  for N := 1 to L do begin
    for M := 1 to ColumnWidth do write(' ');
    if N < L then begin
      Y := Y + 1;
      gotoxy(LM,Y);
      end;  {if N < }
    end;  {for N}
end;  {procedure EraseText}
*)
{-----------------------------}

PROCEDURE CastOne;
var  QA : char;
begin
  DrawMainWindow(1);
  gotoxy(9,10);
  write('Runes are being constantly shuffled.  Have your question in mind.');
  gotoxy(21,12);
  write('Then select one Rune by pressing any key...');
  GetRandomRune(C);
  gotoxy(8,10); clreol; gotoxy(21,12); clreol;
  redefinewindow(C,trunc(3*(xmaxglb/5)),26,87,298);
  selectworld(2);
  selectwindow(C);
  drawborder;
  DrawR(C);
  WriteRuneText(C);
  selectworld(3);
  selectwindow(26);
  drawborder;
  gotoxy(29,24);
  write('PRESS: Space Bar to leave');
  invertwindow;
  repeat
    QA := readkey;
  until QA = ' ';
  sound(131); delay(100); nosound;
  Menu;
end;   {procedure CastOne}

{-----------------------------}

PROCEDURE ThreeSpread;
var
  QA : char;
  C1, C2, C3 : integer;  {Runes selected}
  Location, OldLocation : byte;  {which Rune}

  PROCEDURE ShiftRune;  {part of ThreeSpread}
  begin
(*    EraseText;  *)
    case OldLocation of
      1 : C := C1;
      2 : C := C2;
      3 : C := C3;
      end;  {case OldLocation}
    selectwindow(C);
    invertwindow;
    case Location of
      1 : C := C1;
      2 : C := C2;
      3 : C := C3;
    end;  {case Location}
    selectwindow(C);
    invertwindow;
    OldLocation := Location;
    WriteRuneText(C);
  end;  {subprocedure ShiftRune}

BEGIN  {main statement section of procedure ThreeSpread}
  DrawMainWindow(3);
  gotoxy(9,10);
  write('Runes are being constantly shuffled.  Have your question in mind.');
  gotoxy(12,12);
  write('Then select the FIRST of THREE Runes by pressing any key...');
  gotoxy(18,15);
  write('(The FIRST Rune represents ''PRESENT SITUATION'')');
  GetRandomRune(C1);
  gotoxy(8,10); clreol; gotoxy(12,12); clreol; gotoxy(18,15); clreol;
  gotoxy(17,12);
  write('Now select the SECOND Rune by pressing any key...');
  gotoxy(15,15);
  write('(The SECOND Rune represents ''SITUATION''S CHALLENGE'')');
  GetRandomRune(C2);
  if C2 = C1 then repeat C2 := random(24) + 1; until C2 <> C1;
  gotoxy(17,12); clreol;  gotoxy(15,15); clreol;   gotoxy(20,12);
  write('Select the THIRD Rune by pressing any key...');
  gotoxy(19,15);
  write('(The THIRD Rune represents ''FUTURE POTENTIAL'')');
  GetRandomRune(C3);
  if (C3 = C2) or (C3 = C1) then repeat C3 := random(24) + 1;
    until (C3 <> C2) and (C3 <> C1);
  gotoxy(20,12); clreol; gotoxy(19,15); clreol;
  C := C1;
  redefinewindow(C,53,104,63,218);
  selectworld(2);            selectwindow(C);
  drawborder;
  DrawR(C);
  selectworld(1);
  selectwindow(25);
  drawtext(441,65,1,'    1.');
  drawtext(441,75,1,' PRESENT');
  drawtext(441,85,1,'SITUATION');
  C := C2;
  redefinewindow(C,65,104,75,218);
  selectworld(2);
  selectwindow(C);
  drawborder;
  DrawR(C);
  selectworld(1);
  selectwindow(25);
  drawtext(532,65,1,'     2.');
  drawtext(532,75,1,'SITUATION''S');
  drawtext(532,85,1,' CHALLENGE');
  C := C3;
  redefinewindow(C,77,104,87,218);
  selectworld(2);
  selectwindow(C);
  drawborder;
  DrawR(C);
  selectworld(1);
  selectwindow(25);
  drawtext(634,65,1,'   3.');
  drawtext(634,75,1,' FUTURE');
  drawtext(634,85,1,'POTENTIAL');
  C := C1;
  selectwindow(C);
  invertwindow;
  WriteRuneText(C);
  selectworld(3);
  selectwindow(26);
  drawborder;
  gotoxy(5,24);
  write('PRESS: -> to read next Rune; <- to read previous Rune; Space Bar to leave');
  invertwindow;
  OldLocation := 1;
  repeat
    repeat
      QA := readkey;
    until QA in [#75,#77,' '];   {75 <-, 77 ->}
    case QA of
      #75 : begin
          if OldLocation > 1 then Location := OldLocation - 1
            else Location := 3;
          ShiftRune;
          end;  {#75}
      #77 : begin
          if OldLocation < 3 then Location := OldLocation + 1
            else Location := 1;
          ShiftRune;
          end;  {#77}
      ' ' : begin
          sound(131); delay(100); nosound;
          Menu;
          end;  {' '}
      end;  {case QA}
  until QA = ' ';
end;   {procedure ThreeSpread}

{-----------------------------}
(*
PROCEDURE SpiralFive;
var
  QA : char;
  C1, C2, C3, C4, C5 : integer;  {Runes selected}
  Location, OldLocation : byte;  {which Rune}

  PROCEDURE ShiftRune;  {part of SpiralFive}
  begin
    case OldLocation of
      1 : C := C1;
      2 : C := C2;
      3 : C := C3;
      4 : C := C4;
      5 : C := C5;
      end;  {case OldLocation}
    selectwindow(C);
    invertwindow;
    case Location of
      1 : C := C1;
      2 : C := C2;
      3 : C := C3;
      4 : C := C4;
      5 : C := C5;
    end;  {case Location}
    selectwindow(C);
    invertwindow;
    OldLocation := Location;
    WriteRuneText(C);
  end;  {subprocedure ShiftRune}

BEGIN  {main statement section of procedure SpirallFive}
  DrawMainWindow(5);
  gotoxy(9,10);
  write('Runes are being constantly shuffled.  Have your question in mind.');
  gotoxy(12,12);
  write('Then select the FIRST of FIVE Runes by pressing any key...');
  gotoxy(16,15);
  write('(The FIRST Rune represents ''THE UNDERLYING VIEW'')');
  GetRandomRune(C1);
  gotoxy(8,10); clreol; gotoxy(12,12); clreol; gotoxy(16,15); clreol;
  gotoxy(17,12);
  write('Now select the SECOND Rune by pressing any key...');
  gotoxy(12,15);
  write('(The SECOND Rune represents ''ACTION ARISING FROM THE VIEW'')');
  GetRandomRune(C2);
  if C2 = C1 then repeat C2 := random(24) + 1; until C2 <> C1;
  gotoxy(17,12); clreol;  gotoxy(12,15); clreol;   gotoxy(20,12);
  write('Select the THIRD Rune by pressing any key...');
  gotoxy(17,15);
  write('(The THIRD Rune represents ''RESOURCES AVAILABLE'')');
  GetRandomRune(C3);
  if (C3 = C2) or (C3 = C1) then repeat C3 := random(24) + 1;
    until (C3 <> C2) and (C3 <> C1);
  gotoxy(20,12); clreol; gotoxy(17,15); clreol;  gotoxy(20,12);
  write('Select the FOURTH Rune by pressing any key...');
  gotoxy(18,15);
  write('(The FOURTH Rune represents ''MEETING OBSTACLES'')');
  GetRandomRune(C4);
  if (C4 = C3) or (C4 = C2) or (C4 = C1) then repeat C4 := random(24) + 1;
    until (C4 <> C3) and (C4 <> C2) and (C4 <> C1);
  gotoxy(20,12); clreol;  gotoxy(18,15); clreol;   gotoxy(20,12);
  write('Select the FIFTH Rune by pressing any key...');
  gotoxy(15,15);
  write('(The FIFTH Rune represents ''POTENTIAL ACCOMPLISHMENT'')');
  GetRandomRune(C5);
  if (C5 = C4) or (C5 = C3) or (C5 = C2) or (C5 <> C1) then repeat C5 := random(24) + 1;
    until (C5 <> C4) and (C5 <> C3) and (C5 <> C2) and (C5 <> C1);
  gotoxy(20,12); clreol; gotoxy(15,15); clreol;
  C := C1;
  redefinewindow(C,66,134,74,209);
  selectworld(2);
  selectwindow(C);
  drawborder;
  DrawR(C);
  selectworld(1);
  selectwindow(25);
  drawtext(525,118,1,'1. UNDERLYING');
  drawtext(525,126,1,'     VIEW');
  C := C2;
  redefinewindow(C,66,234,74,309);
  selectworld(2);
  selectwindow(C);
  drawborder;
  DrawR(C);
  selectworld(1);
  selectwindow(25);
  drawtext(512,218,1,'2. ACTION ARISING');
  drawtext(514,226,1,'  FROM THE VIEW');
  C := C3;
  redefinewindow(C,54,134,62,209);
  selectworld(2);
  selectwindow(C);
  drawborder;
  DrawR(C);
  selectworld(1);
  selectwindow(25);
  drawtext(433,118,1,'3. RESOURCES');
  drawtext(432,126,1,'  AVAILABLE');
  C := C4;
  redefinewindow(C,66,34,74,109);
  selectworld(2);
  selectwindow(C);
  drawborder;
  DrawR(C);
  selectworld(1);
  selectwindow(25);
  drawtext(522,18,1,'  4. MEETING');
  drawtext(521,26,1,'   OBSTACLES');
  C := C5;
  redefinewindow(C,78,134,86,209);
  selectworld(2);
  selectwindow(C);
  drawborder;
  DrawR(C);
  selectworld(1);
  selectwindow(25);
  drawtext(614,118,1,'  5. POTENTIAL');
  drawtext(610,126,1,'  ACCOMPLISHENT');
  C := C1;
  selectwindow(C);
  invertwindow;
  WriteRuneText(C);
  selectworld(3);
  selectwindow(26);
  drawborder;
  gotoxy(5,24);
  write('PRESS: -> to read next Rune; <- to read previous Rune; Space Bar to leave');
  invertwindow;
  OldLocation := 1;
  repeat
    repeat
      QA := readkey;
    until QA in [#75,#77,' '];   {75 <-, 77 ->}
    case QA of
      #75 : begin
          if OldLocation > 1 then Location := OldLocation - 1
            else Location := 5;
          ShiftRune;
          end;  {#75}
      #77 : begin
          if OldLocation < 5 then Location := OldLocation + 1
            else Location := 1;
          ShiftRune;
          end;  {#77}
      ' ' : begin
          sound(131); delay(100); nosound;
          Menu;
          end; {' '}
      end;  {case QA}
  until QA = ' ';
end;   {procedure SpiralFive}
*)
{-----------------------------}
(*
PROCEDURE SeeRunes;
var
  SA : char;
  J, ErrCode : integer;
  CS : string[2];

BEGIN  {main statement section of procedure SeeRunes}
  swapscreen;
  copyscreen;              {re-saved for future runs of this procedure}
  selectworld(3);
  selectwindow(26);
  drawborder;
  setbackground(0);
  gotoxy(19,24);
  C := 0;
  write('To make choice, enter number (1 through 24) ...');
  repeat
    CS := '';
    readln(CS);
    val(CS,C,ErrCode);
    if ErrCode = 0 then
      if not ((C >= 1) and (C <= 24)) then ErrCode := 1;
  until ErrCode = 0;
  DrawMainWindow(10);
  redefinewindow(C,trunc(3*(xmaxglb/5)),trunc(ymaxglb/10),xmaxglb - trunc(xmaxglb/20),trunc(5*(ymaxglb/6)));
  selectworld(2);
  selectwindow(C);
  drawborder;
  DrawR(C);
  WriteRuneText(C);
  selectworld(3);
  selectwindow(26);
  drawborder;
  gotoxy(12,24);
  C := 0;
  write('Would you like to see and read about another Rune?  (Y/N)...');
  repeat
    SA := readkey;
    SA := upcase(SA);
  until SA in ['Y','N'];
  write(SA);
  if SA = 'Y' then SeeRunes else Menu;
end;   {procedure SeeRunes}
*)
{-----------------------------}

PROCEDURE HowTo;
var
  How: text;
  HLine : string[75];
  N : integer;
begin
(*  assign(How,'RU.TXT');
  reset(How);         *)
  DrawMainWindow(12);
(*  N :=  1;
  repeat
    readln(How,HLine);
    N := N + 1;
    gotoxy(5,N);
    writeln(HLine);
  until eof(How);
  close(How);      *)
  WriteRuneExplanation(2);
  invertwindow;
  selectworld(3);
  selectwindow(26);
  invertwindow;
  drawborder;
  gotoxy(28,24);
  write('Press space bar to leave...');
  repeat
    SB := readkey;
  until SB = ' ';
  sound(131); delay(100); nosound;
  Menu;
end;   {procedure HowTo}

{-----------------------------}

PROCEDURE AboutRunes;
var
  History : text;
  HLine : string[75];
  N : integer;
begin
(*  assign(History,'RH.TXT');
  reset(History);       *)
  DrawMainWindow(15);
(*  N :=  1;
  repeat
    readln(History,HLine);
    N := N + 1;
    gotoxy(5,N);
    writeln(HLine);
  until eof(History);
  close(History);         *)
  WriteRuneExplanation(1);
  invertwindow;
  selectworld(3);
  selectwindow(26);
  invertwindow;
  drawborder;
  gotoxy(28,24);
  write('Press space bar to leave...');
  repeat
    SB := readkey;
  until SB = ' ';
  sound(131); delay(100); nosound;
  Menu;
end;   {procedure AboutRunes}

{-----------------------------}

PROCEDURE RuneBooks;
var
  Books: text;
  HLine : string[75];
  N : integer;
begin
(*  assign(Books,'RB.TXT');
  reset(Books);     *)
  DrawMainWindow(20);
(*  N :=  1;
  repeat
    readln(Books,HLine);
    N := N + 1;
    gotoxy(5,N);
    writeln(HLine);
  until eof(Books);
  close(Books);      *)
  WriteRuneExplanation(3);
  invertwindow;
  selectworld(3);
  selectwindow(26);
  invertwindow;
  drawborder;
  gotoxy(28,24);
  write('Press space bar to leave...');
  repeat
    SB := readkey;
  until SB = ' ';
  sound(131); delay(100); nosound;
  Menu;
end;   {procedure RuneBooks}

{-----------------------------}

PROCEDURE Menu;
begin
  DrawMainWindow(0);
  drawtext(175,trunc(ymaxglb/8),4,'RUNE-CASTER MENU');
  setlinestyle(3);
  drawsquare(3,2,19,9,false);
  setlinestyle(0);
  gotoxy(20,8);  sound(131); delay(10); nosound;
  writeln('1.  Rune Cast #1: Cast of ONE');
  gotoxy(20,9);  sound(147); delay(10); nosound;
  writeln('2.  Rune Cast #2: THREE Steps');
  gotoxy(18,10); sound(165); delay(10); nosound;
  writeln('* 3.  Rune Cast #3: Spiral FIVE');
  gotoxy(18,12); sound(175); delay(10); nosound;
  writeln('* 4.  See individual Runes with their meanings');
  gotoxy(20,14); sound(196); delay(10); nosound;
  writeln('5.  How to use RuneCaster');
  gotoxy(20,15); sound(220); delay(10); nosound;
  writeln('6.  Rune history');
  gotoxy(20,16); sound(247); delay(10); nosound;
  writeln('7.  Books you could read');
  gotoxy(20,18); sound(262); delay(20); nosound;
  writeln('8.  Exit from RuneCaster');
  gotoxy(18,20);
  write('* Version with these features available for $10');
  selectworld(3);
  selectwindow(26);
  drawborder;
  gotoxy(20,24);
  write('Enter number [1 through 8] of your choice...');
  invertwindow;
  repeat
    MC := readkey;
  until MC in ['1','2','5'..'8'];
  if MC <> '8' then begin sound(1568); delay(80); nosound; end
  else begin
    sound(131); delay(70); sound(196); delay(70); sound(262); delay(70); nosound;
    end;
  case MC of
    '1' : CastOne;
    '2' : ThreeSpread;
(*    '3' : SpiralFive;    *)
(*    '4' : SeeRunes;      *)
    '5' : HowTo;
    '6' : AboutRunes;
    '7' : RuneBooks;
    '8' : begin
        leavegraphic;
        clrscr; lowvideo;
        gotoxy(1,1);
        writeln('        You may copy and distribute this version of Rune-Caster freely');
        writeln('                so long as you do not charge over $10 per copy.');
        writeln;
        writeln;
        writeln;
        writeln('                This version of Rune-Caster is ''User-Supported''.');
        highvideo;
        writeln('            In appreciation for a donation of $10, you will receive');
        writeln('            another version which includes two additional features.');
        writeln;  lowvideo;
        writeln('                Eric Meller, 1211 Virginia, Berkeley, CA 94702');
        writeln;
        writeln('                                   Thanks!');
        gotoxy(10,4);  write(#201);                      {upper left corner}
        gotoxy(11,4); for N := 1 to 59 do write(#205);   {top line}
        gotoxy(70,4);  write(#187);                      {upper right corner}
        for N := 5 to 13 do begin
          gotoxy(70,N); write(#186); end;                {right line}
        gotoxy(70,14); write(#188);                      {lower right corner}
        for N := 69 downto 11 do begin
          gotoxy(N,14); write(#205); end;                {bottom line}
        gotoxy(10,14); write(#200);                      {lower left corner}
        for N := 13 downto 5 do begin
          gotoxy(10,N); write(#186); end;                {left line}
        gotoxy(1,17);
        halt;
        end;  {8}
    end;  {case MC}
end;  {procedure Menu}

{-----------------------------}

BEGIN       {main statement part of program}
  initgraphic;
  Definitions;
  TitleScreen;
  FlashAllRunes;
  Menu;
end.
