unit ProcMenu;

      {=================================================================}
      {                                                                 }
      {  Obsluha TERM10                       V1.0   17.05.1996         }
      {                                                                 }
      {                                                                 }
      {=================================================================}

{$I Sets.inc}

interface

uses
   GO240128,
   uTermGr;


var
  rt,vt :real;
  MyGrArea     :tGraphicArea;

procedure UserMenu;


{#############################################################################}
implementation
uses
  Logo,        { SofCon s.r.o. AUTOMATIZACNI TECHNIKA     }

  F8x8c,       { font 8x8                      }
  F6x8cr,      { Font 6x8   proporcionalni     }
  F1216WCR,    { font 12x16 bold proporcionalni}
  F16x32c,     { font 16x32                    }
  F24x64n,     { font 24x64 pouze cisla        }
  F6x8c,       { Font 6x8                      }

  NumToStr,
 {$ifdef VerMC}
  AtmFlash,
  uNmInt,
 {$endif}
  uString,
  Kernel,
  uAMenu,
  uMenuChr,
  uMenuGr,
  uCharBuf,
  uATerm,
  G240x128,
  uFont,
  uTermT10,
  SetUpT10,
 {$IFDEF SimPC}       { je zapnut simulator TERM10 }
  uSimT10,
 {$ELSE}
  uDispT10,
  uKeybT10,
 {$ENDIF}
  LocGlb,
  SpolGlb,
{$ifdef VerMc}
  RtcTime,
{$endif}
  Dos,
  uMake,
  uInit;


const
 { identifikatory typu pouzitych fontu - implem. viz tCFontArrayIndx }
  cF6x8c    = 0;
  cF6x8cr   = 1;
  cF8x8c    = 2;
  cF12x16WCR= 3;
  cF16x32c  = 4;
  cF24x64n  = 5;

const
  PomStr : String='';
  BufNula: tString5 ='     ';    { Pomocne pro zad.slova NULUJ,RESET}
  TimeStr: tString11='00:00:00';{ Editacni promenna casu           }
  DateStr: tString11=' 1. 1.1997';{ Editacni promanna data         }


type
   Bit  = (b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15);
   tSet = set of Bit;

var
  DispStr    : String; {string pro vypis textu na display}
  HlpStr     : String; {string pro help}
  GraphStr   : String; {string pro help}
  BkBMP      : integer;
  ViewRst    : Byte;   { Cislo vybraneho restartu         }


function TimeStrDec(X:Word):tString2;
var S:tString2;
begin
  S:=WordStrDec(X,2);
  if S[1]=' ' then S[1]:='0';
  TimeStrDec:=S;
end;



{----------------------------------------}
type
  tSelector=(
             tUvod,
             tFirstMenu,
             tMServMenu,
             tMTimeDate,
               tNastTime,
               tNastDate,
             tNastavHeslo,
             tMSofconDoMas,
             tMSofconDoSl,
             tErrorM7,
             tErrorM6,
             tErrorM5,
             tErrorM4,
             tErrorM3,
             tErrorM2,
             tErrorM1,
             tErrorM0
             );

{----------------------------------------}
{$ifdef SimHW}
procedure SimHWKlav(P:pAmenu); far;
begin
  with P^ do
  begin
    case ActChar of

    zF2 :begin          {nejaka cinnost}
         end;
    zF3 :begin          {nejaka cinnost}
         end;
    zF4 :begin          {nejaka cinnost}
         end;
    end;
  end;
end;
{$endif}
{----------------------------------------}
procedure pUvod(P: pMenuGr); far;      {UVODNI NAPIS}
begin
  with P^ do
  begin
    if ChangeMenu then
    begin
      DispStr:='';

      GraphStr:='';

      HlpStr :=zESC+'F3,60,12;'+'NÁPOVĚDA'+
               zESC+'F1,20,55;'+'K pohybu mezi obrazovkami'+
               zESC+'F1,20,65;'+'pouRívejte klávesy Lipek.'+
               zESC+'F1,8,80;'+ 'Klávesou F1 je moRné vyvolat'+
               zESC+'F1,84,90;'+'nápovědu.'+
               zESC+'F1,100,110;'+'[ESC]';
      BkBMP   :=1;

      EditWaitPress(2000);
      SetCtrlTab([iUp],word(tMServMenu));     {Up}
      SetCtrlTab([iDn],word(tFirstMenu));     {Dn}
      pMenuChr(p)^.Term^.FlIns:=false;
    end;
  end;
end;

{----------------------------------------}
procedure pMFirstMenuThirth(P: pMenuGr); far;
begin
   with P^,Glb^ do
   begin
     case  ActChar of
       zLe : OdesliPRT(idR2);
       zRi : OdesliPRT(idR3);
     end;
   end;
end;
{------------}
procedure pFirstMenu(P: pMenuGr); far;   {PRVNI MENU}
begin
  with P^ do
  begin
    LockKernel;
    MyGrArea.ClearImage;
    mTextOutXY(10,30,'Data: '+WordStrDec(PomocWord,5),b_OR,MyGrArea.Img,cF8x8c);
    mTextOutXY(10,50,'sipka <- ->  = zmena posilanych dat',b_OR,MyGrArea.Img,cF6x8cr);

    mTextOutXY(3,117,'Pam. ediT. Nuluj Rel/abs. Kalib. Setup Inch',b_OR,MyGrArea.Img,cF6x8cr);
    mFillBox(1,115,238,126,b_XOR,MyGrArea.Img);
    UnLockKernel;
    if ChangeMenu then
    begin
      DispStr:=zEsc+'F3,10,10;'+'Prvni obrazovka';
      BkBmp:=2;
      GraphStr:='';                                {12345678901234567890}
      HlpStr :=zEsc+'F2,0,0;'+  '      NÁPOVĚDA      '+
                                '                    '+
                                ' Prvni obrazovka    ';
      SetCtrlTab([iUp],word(tMServMenu));     {Up}
      SetUserThird(Addr(pMFirstMenuThirth));  { instalace procedury pro test hesla }
    end;
  end;
end;

{----------------------------------------}
procedure pMServMenuThirth(P: pMenuGr); far;
begin
   with P^,Glb^ do
   begin
     if ActChar=zCr then
     begin
       OdesliPRT(idRRestart);
{$ifndef Weber}
       if (PomStr<>gHeslo)and(PomStr<>cUnivHeslo)
         then begin PomStr:='';
                    SetActMenu(StackMenu.PopMenu);
              end;
{$endif}
     end;
   end;
end;
{-------------}
procedure pMServMenu(P: pMenuGr); far;   { VSTUP DO SERVISNIHO MENU }
begin
  with P^ do
  begin
    DispStr:='          '+zESC+'F4,40,60;';
    if ChangeMenu then
    begin
      LockKernel;
      MyGrArea.ClearImage;
      mTextOutXY(70,4 ,'Servisní menu:',b_OR,MyGrArea.Img,cF8x8c);
      mTextOutXY(3,117,'po Enter zadej heslo,  F1=help',b_OR,MyGrArea.Img,cF6x8cr);
      mFillBox(1,115,238,126,b_XOR,MyGrArea.Img);
      mDrawBox(35,55,205,93,b_XOR,MyGrArea.Img);
      mDrawLine(1,21,238,21,b_XOR,MyGrArea.Img);
      UnLockKernel;
      PomStr:='';
      BkBmp:=2;
      GraphStr:='';
      HlpStr :=zEsc+'F2,85,0;NÁPOVĚDA'+
               zEsc+'F1,10,30;Pro vstup do servisního menu'+
               zEsc+'F1,10,40;stiskni [ENTER], zadej'+
               zEsc+'F1,10,50;správné heslo a stiskni opet'+
               zEsc+'F1,10,60;[ENTER]';
      SetEditWin(1,1,10,1);
      {EditEnter:=false;}{!We}
      EditPassWord(PomStr);
      SetUserThird(Addr(pMServMenuThirth));  { instalace procedury pro test hesla }
      SetCtrlTab([iDn],word(tFirstMenu));
      SetTransCtrlTab([zCr],iCall1,word(tMTimeDate));
      Term^.Disp^.UpdateDisplay;
    end;
  end;
end;

{------------------------------------------}
procedure pMTimeDate(P: pMenuGr); far; {MENU NASTAVENI DATA A CASU}
var Time:DateTime;
    X:Word;
begin
  with P^,Time do
  begin
    GetTime( Hour, Min, Sec, X);
    GetDate( Year, Month, Day, X);
    LockKernel;
    MyGrArea.ClearImage;
    mTextOutXY(30,4,'Nastavení času a data:',b_OR,MyGrArea.Img,cF8x8c);
    mDrawLine(1,21,238,21,b_OR,MyGrArea.Img);

    mTextOutXY(20,35,'čas:',b_OR,MyGrArea.Img,cF6x8cr);
    mTextOutXY(56,30,WordStrDec(Hour,2)+':'+
                     +TimeStrDec(Min)+':'+
                     +TimeStrDec(Sec),b_OR,MyGrArea.Img,cF12x16WCR);
    mTextOutXY(10,65,'datum:',b_OR,MyGrArea.Img,cF6x8cr);
    mTextOutXY(56,60,WordStrDec(Day,2)+'.'+
                     +WordStrDec(Month,0)+'.'+
                     +WordStrDec(Year,4),b_OR,MyGrArea.Img,cF12x16WCR);
    mTextOutXY(3,117,'C=čas D=datum  F1',b_OR,MyGrArea.Img,cF6x8cr);
    mDrawLine(122,116,124,119,b_OR,MyGrArea.Img);  {sipky}
    mDrawLine(122,116,120,119,b_OR,MyGrArea.Img);
    mDrawLine(143,117,143,126,b_OR,MyGrArea.Img);
    mDrawLine(122,117,122,126,b_OR,MyGrArea.Img);
    mDrawLine(141,123,143,126,b_OR,MyGrArea.Img);
    mDrawLine(145,123,143,126,b_OR,MyGrArea.Img);
    mFillBox(1,115,238,126,b_XOR,MyGrArea.Img);
    UnlockKernel;
    if ChangeMenu then
    begin
      DispStr:='';
      BkBmp:=2;
      GraphStr:='';
      HlpStr :=zEsc+'F2,0,0;'+  '      NÁPOVĚDA      '+
                                '                    '+
                                '[C] nastavení času  '+
                                '[D] nastavení data  ';
      AddTerminateChar(['C','D']);
      SetTransCtrlTab(['C'],iCall1,word(tNastTime));
      SetTransCtrlTab(['D'],iCall2,word(tNastDate));
      SetCtrlTab([iUp],word(tMSofconDoSl));
      SetCtrlTab([iDn],word(tNastavHeslo));
    end;
  end;
end;

{--------------------------------------}
procedure pNastTimeThirth(P: pMenuGr); far;
var Time:DateTime;
    CodeHour,CodeMinute,CodeSecond : Integer;
    X:Word;
begin
   with P^,Time do
   begin
     if ActChar=zCR
     then
       begin
         Val(Copy(TimeStr,1,2),Hour,CodeHour);
         Val(Copy(TimeStr,4,2),Min,CodeMinute);
         Val(Copy(TimeStr,7,2),Sec,CodeSecond);
         if (CodeHour+CodeMinute+CodeSecond=0) and
            (Hour<24) and (Min<60) and (Sec<60) and
            (TimeStr[3]=':') and (TimeStr[6]=':')
            then
              begin
                LockKernel;
                SetTime(Hour, Min, Sec, 0);
                UnLockKernel;
              end;
       end;
   end;
end;
{--------------}
procedure pNastTime(P: pMenuGr); far;  { NASTAVENI CASU}
var Time:DateTime;
    X:Word;
begin
  with P^,Time do
  begin
      GetTime( Hour, Min, Sec, X);
      GetDate( Year, Month, Day, X);
      TimeStr:=WordStrDec(Hour,2)+':'+
              +TimeStrDec(Min)+':'+
              +TimeStrDec(Sec);
      mFillBox(56,30,120,55,b_NOT,MyGrArea.Img);
      DispStr:='           '+zESC+'F3,56,30;';
      BkBmp:=2;
      HlpStr :=zEsc+'F2,0,0;'+  '      NÁPOVĚDA      '+
                                '                    '+
                                'Zadej čas ve tvaru: '+
                                '   HH : MM : SS     '+
                                '                    ';
      SetTerminateChar([zEsc,zCr]);
      SetTransTab([zCr],iRet);
      SetEditWin(1,1,8,1);
      EditEnter:=False;
      EditString(TimeStr);
      SetUserThird(Addr(pNastTimeThirth));
  end;
end;

{-------------------------------------------------}
procedure pNastDateThirth(P: pMenuGr); far;
var Time:DateTime;
    CodeDay,CodeMonth,CodeYear : Integer;
    X:word;
begin
   with P^,Time do
   begin
     if ActChar=zCR
     then
       begin
         Val(Copy(DateStr,1,2),Day,CodeDay);
         Val(Copy(DateStr,4,2),Month,CodeMonth);
         Val(Copy(DateStr,7,4),Year,CodeYear);
         if (CodeDay+CodeMonth+CodeYear=0) and
            (Day in [1..31]) and (Month in [1..12]) and
            (DateStr[3]='.') and (DateStr[6]='.')
            then
              begin
                LockKernel;
                SetDate(Year, Month, Day);
                UnLockKernel;
              end;
       end;
   end;
end;
{-------------}
procedure pNastDate(P: pMenuGr); far;    { NASTAVENI DATA}
var Time:DateTime;
    X:Word;
begin
  with P^,Time do
  begin
    GetTime( Hour, Min, Sec, X);
    GetDate( Year, Month, Day, X);
    DateStr:=WordStrDec(Day,2)+'.'+
            +WordStrDec(Month,2)+'.'+
            +WordStrDec(Year,4);
    mFillBox(56,60,140,75,b_NOT,MyGrArea.Img);
    DispStr:='            '+zESC+'F3,56,60;';
    BkBmp:=2;
    HlpStr :=zEsc+'F2,0,0;'+  '      NÁPOVĚDA      '+
                              '                    '+
                              'Zadej datum ve tvaru'+
                              '   DD . MM . RRRR   '+
                              '[ESC] pro návrat    ';
    SetTerminateChar([zEsc,zCr]);
    SetTransTab([zCr],iRet);
    SetEditWin(1,1,10,1);
    EditEnter:=False;
    EditString(DateStr);
    SetUserThird(Addr(pNastDateThirth));
  end;
end;

{------------------------------------------------}
procedure pNastavHesloThirth(P: pMenuGr); far;
var i : byte;
begin
  with P^, Glb^ do
  begin
    if ActChar=zCr then
    begin
      for i:=1 to length(gHeslo)
       do gHeslo[i]:=UpCase(gHeslo[i]);
    end;
  end;
end;
{---------}
procedure pNastavHeslo(P: pMenuGr); far;      {EDITACE HESLA}
begin
  with P^,Glb^ do
  begin
    if ChangeMenu then
    begin
      LockKernel;
      MyGrArea.ClearImage;
      mTextOutXY(60,4,'Nastavení hesla:',b_OR,MyGrArea.Img,cF8x8c);
      mDrawLine(1,21,238,21,b_OR,MyGrArea.Img);
      mDrawBox(35,55,205,93,b_XOR,MyGrArea.Img);
      mTextOutXY(3,117,'Enter=editace  F1',b_OR,MyGrArea.Img,cF6x8cr);
      mDrawLine(122,116,124,119,b_OR,MyGrArea.Img);  {sipky}
      mDrawLine(122,116,120,119,b_OR,MyGrArea.Img);
      mDrawLine(143,117,143,126,b_OR,MyGrArea.Img);
      mDrawLine(122,117,122,126,b_OR,MyGrArea.Img);
      mDrawLine(141,123,143,126,b_OR,MyGrArea.Img);
      mDrawLine(145,123,143,126,b_OR,MyGrArea.Img);
      mFillBox(1,115,238,126,b_XOR,MyGrArea.Img);
      UnLockKernel;
      DispStr:='           '+zESC+'F3,40,65;';
      BkBmp:=2;
      GraphStr:='';
      HlpStr :=zEsc+'F2,0,0;'+  '      NÁPOVĚDA      '+
                                '                    '+
                                'ENTER editace hesla '+
                                'pro vstup do        '+
                                'servisního menu.    ';
      SetEditWin(1,1,10,1);
      EditString(gHeslo);
      SetUserThird(Addr(pNastavHesloThirth));  { instalace procedury pro test hesla }
      SetCtrlTab([iUp],word(tMTimeDate));
      SetCtrlTab([iDn],word(tMSofconDoMas));
    end;
  end;
end;
{----------------------------------------}
procedure pMSofconDoMasThirth(P: pMenuGr); far;
var Vysledek : boolean;
begin
  with P^, Glb^.gRStructM do
  begin
    case ActChar of
      zLe:if ViewRst>0 then dec(ViewRst) else ViewRst:=MaxRst;
      zRi:if ViewRst<MaxRst then inc(ViewRst) else ViewRst:=0;
      '0':begin
            RstCt:=0;
            gPFICt:=0;
          end;
    end;
    if ActChar<>#0 then
    begin
      Move(BufNula[2],BufNula[1],4);
      BufNula[5]:=UpCase(ActChar);
    end;
    if BufNula='RESET' then
    begin     { Znovunastaveni Glb }
      Glb^.gRStructM.Verse:=0;
{$ifdef VerMc}
      asm cli end;
      Port[AdrTerm+4]:=$ff; { vystupy Term10 do neaktivniho stavu }
      Port[AdrTerm+5]:=$ff;
      Port[AdrTerm+6]:=$ff;
      Port[AdrTerm+7]:=$ff;
      repeat until false;   {WatchDog provede reset}
{$endif}
      RunError(0);
    end;
    if BufNula='NULUJ' then
    begin
{$ifdef VerMc}
      Port[AdrTerm+4]:=$ff; { vystupy Term10 do neaktivniho stavu }
      Port[AdrTerm+5]:=$ff;
      Port[AdrTerm+6]:=$ff;
      Port[AdrTerm+7]:=$ff;
      Vysledek:=ATMDestruct(cFlaschBase,cAppBegin); {poskozeni Flash pameti}
      asm cli end;
      repeat until false;   {WatchDog provede reset}
{$endif}
      RunError(0);
    end;
  end;
end;
{-----------}
procedure pMSofconDoMas(P: pMenuGr); far;
begin
  with P^,Glb^ do
  begin
    if ChangeMenu then ViewRst:=Glb^.gRStructM.ARst;

    with Glb^,gRStructM,Rst[ViewRst],rTime do
    begin
      LockKernel;
      MyGrArea.ClearImage;
      mTextOutXY(100,4,'Terminal:',b_OR,MyGrArea.Img,2);
      mDrawLine(1,21,238,21,b_OR,MyGrArea.Img);
      mTextOutXY(15,25,'Version          '+LongIntStrDec(Verse,8),b_OR,MyGrArea.Img,0);
      mTextOutXY(15,35,'Restart counter  '+WordStrDec(RstCt,0),b_OR,MyGrArea.Img,0);
      mTextOutXY(15,45,'PFI     counter  '+WordStrDec(gPFICt,0),b_OR,MyGrArea.Img,0);
      mTextOutXY(15,55,'Aktual restart   '+ByteStrDec(ARst,0),b_OR,MyGrArea.Img,0);
      mTextOutXY(15,65,'Restart no.      '+ByteStrDec(ViewRst,0),b_OR,MyGrArea.Img,0);
      mTextOutXY(15,75,'Time  ',b_OR,MyGrArea.Img,0);
      mTextOutXY(15,85,WordStrDec(Day,0)+'.'+
                       WordStrDec(Month,0)+'.'+
                       WordStrDec(Year,0)+'   '+
                       WordStrDec(Hour,0)+':'+
                       WordStrDec(Min,0)+':'+
                       WordStrDec(Sec,0),b_OR,MyGrArea.Img,0);
      mTextOutXY(15,95,'Error '+ByteStrDec(rErr,0)+' on addr '+
                        +WordStrHex(Seg(rAddr^))+':'+
                        +WordStrHex(Ofs(rAddr^)),b_OR,MyGrArea.Img,0);
      mTextOutXY(15,105,'Reset & Init Glb - "RESET"',b_OR,MyGrArea.Img,0);
      mTextOutXY(15,115,'Reset & Poskozeni pameti - "NULUJ"',b_OR,MyGrArea.Img,0);
      mFillBox(1,104,238,126,b_XOR,MyGrArea.Img);
      UnLockKernel;
    end;
    if ChangeMenu then
    begin
      DispStr:='';
      BkBmp:=2;
                                {12345678901234567890}
      HlpStr :=zEsc+'F2,0,0;'+  '      NÁPOVĚDA      '+
                                '<-  -> změna zobra- '+
                                'zeného restartu.    '+
                                'RESET pro init Glb. '+
                                '0 nulování Restart a'+
                                '  PFI.';
      SetCtrlTab([iDn],word(tMSofconDoSl));
      SetUserThird(Addr(pMSofconDoMasThirth));
    end;
  end;
end;

{----------------------------------------}
procedure pMSofconDoSlThirth(P: pMenuGr); far;
var Vysledek : boolean;
begin
  with P^, Glb^.gRStructS do
  begin
    case ActChar of
      zLe:if ViewRst>0 then dec(ViewRst) else ViewRst:=MaxRst;
      zRi:if ViewRst<MaxRst then inc(ViewRst) else ViewRst:=0;
      '0':begin
            RstCt:=0;
            gPFICt:=0;
          end;
    end;
    if ActChar<>#0 then
    begin
      Move(BufNula[2],BufNula[1],4);
      BufNula[5]:=UpCase(ActChar);
    end;
    if BufNula='RESET' { reset slave}
    then OdesliPRT(idReset);

    if BufNula='NULUJ' {destruct slave}
    then OdesliPRT(idRDestruct);

  end;
end;
{-----------}
procedure pMSofconDoSl(P: pMenuGr); far;
begin
  with P^,Glb^ do
  begin
    if ChangeMenu then ViewRst:=Glb^.gRStructS.ARst;

    with Glb^,gRStructS,Rst[ViewRst],rTime do
    begin
      LockKernel;
      MyGrArea.ClearImage;
      mTextOutXY(100,4,'Slave:',b_OR,MyGrArea.Img,2);
      mDrawLine(1,21,238,21,b_OR,MyGrArea.Img);
      mTextOutXY(15,25,'Version          '+LongIntStrDec(Verse,8),b_OR,MyGrArea.Img,0);
      mTextOutXY(15,35,'Restart counter  '+WordStrDec(RstCt,0),b_OR,MyGrArea.Img,0);
      mTextOutXY(15,45,'PFI     counter  '+WordStrDec(gPFICt,0),b_OR,MyGrArea.Img,0);
      mTextOutXY(15,55,'Aktual restart   '+ByteStrDec(ARst,0),b_OR,MyGrArea.Img,0);
      mTextOutXY(15,65,'Restart no.      '+ByteStrDec(ViewRst,0),b_OR,MyGrArea.Img,0);
      mTextOutXY(15,75,'Time  ',b_OR,MyGrArea.Img,0);
      mTextOutXY(15,85,WordStrDec(Day,0)+'.'+
                       WordStrDec(Month,0)+'.'+
                       WordStrDec(Year,0)+'   '+
                       WordStrDec(Hour,0)+':'+
                       WordStrDec(Min,0)+':'+
                       WordStrDec(Sec,0),b_OR,MyGrArea.Img,0);
      mTextOutXY(15,95,'Error '+ByteStrDec(rErr,0)+' on addr '+
                        +WordStrHex(Seg(rAddr^))+':'+
                        +WordStrHex(Ofs(rAddr^)),b_OR,MyGrArea.Img,0);
      mTextOutXY(15,105,'Reset & Init Glb - "RESET"',b_OR,MyGrArea.Img,0);
      mTextOutXY(15,115,'Reset & Poskozeni pameti - "NULUJ"',b_OR,MyGrArea.Img,0);
      mFillBox(1,104,238,126,b_XOR,MyGrArea.Img);
      UnLockKernel;
    end;
    if ChangeMenu then
    begin
      DispStr:='';
      BkBmp:=2;
                                {12345678901234567890}
      HlpStr :=zEsc+'F2,0,0;'+  '      NÁPOVĚDA      '+
                                '<-  -> změna zobra- '+
                                'zeného restartu.    '+
                                'RESET pro init Glb. '+
                                '0 nulování Restart a'+
                                '  PFI.';
      SetCtrlTab([iDn],word(tMTimeDate));
      SetUserThird(Addr(pMSofconDoSlThirth));
    end;
  end;
end;

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

procedure pErrorM7(P: pMenuGr); far;       {MENU INTERRUPT 7}
begin
  with P^,Glb^ do
  begin
    LockKernel;
    MyGrArea.ClearImage;
    mTextOutXY(90,0,'ERROR 7',b_OR,MyGrArea.Img,cF12x16WCR);
    mDrawLine(1,17,238,17,b_OR,MyGrArea.Img);

    mTextOutXY(3,117,'Enter Esc  F1',b_OR,MyGrArea.Img,cF6x8cr);
    mFillBox(1,115,238,126,b_XOR,MyGrArea.Img);
    UnLockKernel;

    if ChangeMenu then
    begin
      DispStr:='';
      BkBmp:=2;
      GraphStr:='';
      HlpStr :=zEsc+'F2,0,0;'+  '      NÁPOVĚDA      '+
                                '                    '+
                                ' Interrupt Menu 7   ';
      TerminateChar  :=[zCr,zEsc];
      TransTab[zCr]  :=iRet;
    end;
  end;
end;

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

procedure pErrorM6(P: pMenuGr); far;       {MENU INTERRUPT 6}
begin
  with P^,Glb^ do
  begin
    LockKernel;
    MyGrArea.ClearImage;
    mTextOutXY(90,0,'ERROR 6',b_OR,MyGrArea.Img,cF12x16WCR);
    mDrawLine(1,17,238,17,b_OR,MyGrArea.Img);

    mTextOutXY(3,117,'Enter Esc  F1',b_OR,MyGrArea.Img,cF6x8cr);
    mFillBox(1,115,238,126,b_XOR,MyGrArea.Img);
    UnLockKernel;

    if ChangeMenu then
    begin
      DispStr:='';
      BkBmp:=2;
      GraphStr:='';
      HlpStr :=zEsc+'F2,0,0;'+  '      NÁPOVĚDA      '+
                                '                    '+
                                ' Interrupt Menu 6   ';
      TerminateChar  :=[zCr,zEsc];
      TransTab[zCr]  :=iRet;
    end;
  end;
end;

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

procedure pErrorM5(P: pMenuGr); far;       {MENU INTERRUPT 5}
begin
  with P^,Glb^ do
  begin
    LockKernel;
    MyGrArea.ClearImage;
    mTextOutXY(90,0,'ERROR 5',b_OR,MyGrArea.Img,cF12x16WCR);
    mDrawLine(1,17,238,17,b_OR,MyGrArea.Img);

    mTextOutXY(3,117,'Enter Esc  F1',b_OR,MyGrArea.Img,cF6x8cr);
    mFillBox(1,115,238,126,b_XOR,MyGrArea.Img);
    UnLockKernel;

    if ChangeMenu then
    begin
      DispStr:='';
      BkBmp:=2;
      GraphStr:='';
      HlpStr :=zEsc+'F2,0,0;'+  '      NÁPOVĚDA      '+
                                '                    '+
                                ' Interrupt Menu 5   ';
      TerminateChar  :=[zCr,zEsc];
      TransTab[zCr]  :=iRet;
    end;
  end;
end;

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

procedure pErrorM4(P: pMenuGr); far;       {MENU INTERRUPT 4}
begin
  with P^,Glb^ do
  begin
    LockKernel;
    MyGrArea.ClearImage;
    mTextOutXY(90,0,'ERROR 4',b_OR,MyGrArea.Img,cF12x16WCR);
    mDrawLine(1,17,238,17,b_OR,MyGrArea.Img);

    mTextOutXY(3,117,'Enter Esc  F1',b_OR,MyGrArea.Img,cF6x8cr);
    mFillBox(1,115,238,126,b_XOR,MyGrArea.Img);
    UnLockKernel;

    if ChangeMenu then
    begin
      DispStr:='';
      BkBmp:=2;
      GraphStr:='';
      HlpStr :=zEsc+'F2,0,0;'+  '      NÁPOVĚDA      '+
                                '                    '+
                                ' Interrupt Menu 4   ';
      TerminateChar  :=[zCr,zEsc];
      TransTab[zCr]  :=iRet;
    end;
  end;
end;

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

procedure pErrorM3(P: pMenuGr); far;       {MENU INTERRUPT 3}
begin
  with P^,Glb^ do
  begin
    LockKernel;
    MyGrArea.ClearImage;
    mTextOutXY(90,0,'ERROR 3',b_OR,MyGrArea.Img,cF12x16WCR);
    mDrawLine(1,17,238,17,b_OR,MyGrArea.Img);

    mTextOutXY(3,117,'Enter Esc  F1',b_OR,MyGrArea.Img,cF6x8cr);
    mFillBox(1,115,238,126,b_XOR,MyGrArea.Img);
    UnLockKernel;

    if ChangeMenu then
    begin
      DispStr:='';
      BkBmp:=2;
      GraphStr:='';
      HlpStr :=zEsc+'F2,0,0;'+  '      NÁPOVĚDA      '+
                                '                    '+
                                ' Interrupt Menu 3   ';
      TerminateChar  :=[zCr,zEsc];
      TransTab[zCr]  :=iRet;
    end;
  end;
end;

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

procedure pErrorM2(P: pMenuGr); far;       {MENU INTERRUPT 2}
begin
  with P^,Glb^ do
  begin
    LockKernel;
    MyGrArea.ClearImage;
    mTextOutXY(90,0,'ERROR 3',b_OR,MyGrArea.Img,cF12x16WCR);
    mDrawLine(1,17,238,17,b_OR,MyGrArea.Img);

    mTextOutXY(3,117,'Enter Esc  F1',b_OR,MyGrArea.Img,cF6x8cr);
    mFillBox(1,115,238,126,b_XOR,MyGrArea.Img);
    UnLockKernel;

    if ChangeMenu then
    begin
      DispStr:='';
      BkBmp:=2;
      GraphStr:='';
      HlpStr :=zEsc+'F2,0,0;'+  '      NÁPOVĚDA      '+
                                '                    '+
                                ' Interrupt Menu 3   ';
      TerminateChar  :=[zCr,zEsc];
      TransTab[zCr]  :=iRet;
    end;
  end;
end;

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

procedure pErrorM1(P: pMenuGr); far;       {MENU INTERRUPT 1}
begin
  with P^,Glb^ do
  begin
    LockKernel;
    MyGrArea.ClearImage;
    mTextOutXY(90,0,'ERROR 1',b_OR,MyGrArea.Img,cF12x16WCR);
    mDrawLine(1,17,238,17,b_OR,MyGrArea.Img);

    mTextOutXY(3,117,'Enter Esc  F1',b_OR,MyGrArea.Img,cF6x8cr);
    mFillBox(1,115,238,126,b_XOR,MyGrArea.Img);
    UnLockKernel;

    if ChangeMenu then
    begin
      DispStr:='';
      BkBmp:=2;
      GraphStr:='';
      HlpStr :=zEsc+'F2,0,0;'+  '      NÁPOVĚDA      '+
                                '                    '+
                                ' Interrupt Menu 1   ';
      TerminateChar  :=[zCr,zEsc];
      TransTab[zCr]  :=iRet;
    end;
  end;
end;

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

procedure pErrorM0(P: pMenuGr); far;       {MENU INTERRUPT 0}
begin
  with P^,Glb^ do
  begin
    LockKernel;
    MyGrArea.ClearImage;
    mTextOutXY(90,0,'ERROR 0',b_OR,MyGrArea.Img,cF12x16WCR);
    mDrawLine(1,17,238,17,b_OR,MyGrArea.Img);

    mTextOutXY(3,117,'Enter Esc  F1',b_OR,MyGrArea.Img,cF6x8cr);
    mFillBox(1,115,238,126,b_XOR,MyGrArea.Img);
    UnLockKernel;

    if ChangeMenu then
    begin
      DispStr:='';
      BkBmp:=2;
      GraphStr:='';
      HlpStr :=zEsc+'F2,0,0;'+  '      NÁPOVĚDA      '+
                                '                    '+
                                ' Interrupt Menu 0   ';
      TerminateChar  :=[zCr,zEsc];
      TransTab[zCr]  :=iRet;
    end;
  end;
end;

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

const
ProcPtrArray  :array[tSelector]of tMMenuGr =
            (
             pUvod,
             pFirstMenu,
             pMServMenu,
             pMTimeDate,
               pNastTime,
               pNastDate,
             pNastavHeslo,
             pMSofconDoMas,
             pMSofconDoSl,
             pErrorM7,
             pErrorM6,
             pErrorM5,
             pErrorM4,
             pErrorM3,
             pErrorM2,
             pErrorM1,
             pErrorM0
            );


{----------------------------------------}
procedure UserMenu;
var pMyMenu  :pMenuGr;
    pMyTerm  :pTermT10;
begin
  DispStr:='';
  HlpStr :='';
{$ifdef SimPC}       { je zapnut simulator TERM10 }
  pMyTerm:=New(PTermT10,Init(New(PSimDispT10,Init(nil,20,12,AdrTerm,true{IniHW},
                                                 0,0,2,2,265,165,false{DobleSize})),
                             New(PSimKeybT10,Init(nil,20{Len},AdrTerm,FlEnd)),
                             AdrTerm,nil,nil));

{$else}
  {$ifdef Term10A}
  pMyTerm:=New(pTermT10,Init(New(PDispT10A,Init(nil,25,10,AdrTerm,True)),
                             New(PKeybT10,Init(nil,20{Len},AdrTerm)),
                             AdrTerm,nil,nil));
  {$else}
  pMyTerm:=New(pTermT10,Init(New(PDispT10,Init(nil,20,12,AdrTerm,True)),
                             New(PKeybT10,Init(nil,20{Len},AdrTerm)),
                             AdrTerm,nil,nil));
  {$endif}
{$endif}
  pMyTerm^.SetTDispParam(sParTerm);
  pMyMenu:=New(pMenuGr,Init(@ProcPtrArray,
                            ord(tErrorM0),
                            DispStr,
                            HlpStr,
                            GraphStr,
                            @BkBMP,
                            pMyTerm,
                            '',
                            2));   {wait pri cekani menuter2}


{$ifdef Term10A}
  InitSetUpT10(pMyTerm,@Glb^.gSetupTerm,4,4,15,7);   {Term10A}
{$else}
  InitSetUpT10(pMyTerm,@Glb^.gSetupTerm,4,4,6,1);{Term10}
{$endif}

  InitRunMenu(pMyMenu,
              MenuName,MenuStk,MenuSPrio,MenuDPrio,
              TermName,TermStk,TermSPrio,TermDPrio,
              8,4,     {4,1}  {wait ve volani menuterA.Run; Term01.Tick}
              edNop,
{$ifdef SimHW}
              SimHWKlav,
{$else}
              edNop,
{$endif}
              FlEnd);

  pMyMenu^.MenuIntEnable:=true;
{$ifdef SetupF10}
  pMyMenu^.SetupKeyChar:=zF10;
{$endif}
end;


procedure InitializeBMPs;
var Lng:word;
begin
  User_BkBMPs[1].AssignBMPAddr(GetBMPAddr_LOGO(Lng),Lng);
  MyGrArea.Init(240,128);Lng:=SizeOf(MyGrArea);
  User_BkBMPs[2].AssignBMPAddr(Addr(MyGrArea),Lng);
end;

procedure InitializeAppFonts;
var   PomLng  :word;
begin
  { inicializace pole zobrazovacich procedur}
  with User_FontArray[cF8x8c   ] do
  begin
    P:=pViewFont08x08;
    U:=GetFontAddr_F8x8c(PomLng);
  end;
  with User_FontArray[cF16x32c ] do
  begin
    P:=pViewFont16x32;
    U:=GetFontAddr_F16X32C(PomLng);
  end;
  with User_FontArray[cF12x16WCR] do
  begin
    P:=pViewFont12x16;
    U:=GetFontAddr_F1216WCR(PomLng);
  end;

  with User_FontArray[cF24x64n ] do
  begin
    P:=pViewFont24x64;
    U:=GetFontAddr_f24x64n(PomLng);
  end;

  with User_FontArray[cF6x8c] do
  begin
    P:=pViewFont08x08;
    U:=GetFontAddr_f6x8c(PomLng);
  end;
  with User_FontArray[cF6x8cr] do
  begin
{    P:=pViewFont08x08;                   {!Ka}
    U:=GetFontAddr_f6x8cr(PomLng);
  end;

end;



Begin
  InitializeAppFonts;
  InitializeBMPs;
End.

