unit ProcMenu;

      {=================================================================}
      {                                                                 }
      {  Obrazovky TERM10                                               }
      {                                                                 }
      {                                                                 }
      {=================================================================}

{$I Sets.inc}

interface

uses
  GO240128,
  uTermGr,
  uTermT10,
  uAMenu,
  uMenuChr,
  uMenuGr;


const
  MyMenu  :pMenuGr  = nil; {ukazatel na objekt menu}
  MyTerm  :pTermT10 = nil; {ukazatel na objekt terminalu}
var
  MyGrArea:tGraphicArea;

procedure UserMenu;


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

  F8x8c,       { font 8x8                      }
  F6x8cr,      { font 6x8   proporcionalni     }
  F1216WCR,    { font 12x16 bold proporcionalni}
  F16x32c,     { font 16x32                    }
  F6x8c,       { font 6x8                      }

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


const
 { identifikatory typu pouzivanych bitmap }
  cBmp_Clear  =-1;
  cBMP_Logo   =1;
  cBMP_GrArea =2;

 { identifikatory typu pouzitych fontu - implem. viz tCFontArrayIndx }
  cF6x8c    = 0;
  cF6x8cr   = 1;
  cF8x8c    = 2;
  cF12x16WCR= 3;
  cF16x32c  = 4;
 { identifikatory typu pouzitych fontu pro DispStr }
  sF6x8c    = 'F0';
  sF6x8cr   = 'F1';
  sF8x8c    = 'F2';
  sF12x16wcr= 'F3';
  sF16x32c  = 'F4';

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


const
  DispStr  : String  = ''; {string pro vypis textu na display}
  HelpStr  : String  = ''; {string pro help}
  GraphStr : String  = ''; {string pro graficke tvary}
  BkBMP    : integer = cBmp_Clear;{cislo podkladove bitmapy}

  ViewRst  : Byte = 0;   {cislo vybraneho restartu}
  ArrowsX  : word = 0;


{----------------------------------------}
type
  {vycet menuobrazovek}
  tSelector=(tUvod,
             tFirstMenu,
             tMServMenu,
             tMTimeDate,
               tNastTime,
               tNastDate,
             tNastavHeslo,
             tMAppInfo,
             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:='';

      HelpStr:=zESC+sF12x16wcr+',60,2;'+'NÁPOVĚDA'+
               zESC+sF6x8cr+',20,55;'+'K pohybu mezi obrazovkami'+
               zESC+sF6x8cr+',20,65;'+'používejte klávesy šipek.'+
               zESC+sF6x8cr+',8,80;'+ 'Klávesou F1 je možné vyvolat'+
               zESC+sF6x8cr+',84,90;'+'nápovědu.'+
               zESC+sF6x8cr+',100,110;'+'[ESC]';
      BkBMP  :=cBMP_Logo;

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

{----------------------------------------}
procedure pFirstMenu(P: pMenuGr); far;   {PRVNI MENU}
begin
  with P^,MyGrArea do
  begin
    if ChangeMenu then
    begin
      DispStr:=zEsc+sF12x16wcr+',10,10;'+'První obrazovka';
      BkBmp:=cBMP_GrArea;
      GraphStr:='';
      HelpStr:=zEsc+sF8x8c+',90,2;NÁPOVĚDA'+
               zEsc+sF6x8c+',10,20;První obrazovka';
      SetCtrlTab([iUp,iDn],word(tMServMenu));     {Up}
    end;
   LockKernel;
    ClearImage;
    mDrawBox(1,1,238,126,b_OR,MyGrArea.Img);{oramovani obrazovky}
    {spodni cerna linka}
    mFillBox(1,115,238,126,b_OR,Img);
    mTextOutXY(3,117,'Používané klávesy: <F1>=help;',b_XOR,Img,cF6x8cr);
    ArrowsX:=165; {sipky}
    mDrawLine(ArrowsX+ 2,117,ArrowsX+ 0,119,b_XOR,MyGrArea.Img);{/}
    mDrawLine(ArrowsX+ 2,117,ArrowsX+ 4,119,b_XOR,MyGrArea.Img);{\}
    mDrawLine(ArrowsX+ 2,117,ArrowsX+ 2,125,b_XOR,MyGrArea.Img);{|}
    mDrawLine(ArrowsX+11,123,ArrowsX+13,125,b_XOR,MyGrArea.Img);{\}
    mDrawLine(ArrowsX+15,123,ArrowsX+13,125,b_XOR,MyGrArea.Img);{/}
    mDrawLine(ArrowsX+13,117,ArrowsX+13,125,b_XOR,MyGrArea.Img);{|}
   UnLockKernel;
  end;
end;

{----------------------------------------}
procedure pMServMenuThirth(P: pMenuGr); far;
begin
   with P^,Glb^ do
   begin
     if ActChar=zCr then
     begin
       if (PomStr<>gServHeslo)and
          (PomStr<>'SOFCON') then
       begin
         PomStr:='';
         SetActMenu(Word(tMServMenu));
       end;
     end;
   end;
end;
{-------------}
procedure pMServMenu(P: pMenuGr); far;   { VSTUP DO SERVISNIHO MENU }
begin
  with P^ do
  begin
    DispStr:='          '+zESC+sF16x32c+',40,60;';
    if ChangeMenu then
    begin
     LockKernel;
      MyGrArea.ClearImage;
      {nadpis}
      mTextOutXY(70,2 ,'Servisní menu',b_OR,MyGrArea.Img,cF12x16wcr);
      mDrawLine(1,18,238,18,b_OR,MyGrArea.Img);{podtrzeni nadpisu}
      mDrawBox(1,1,238,126,b_OR,MyGrArea.Img);{oramovani obrazovky}
      {dolni cerna linka}
      mFillBox(1,115,238,126,b_OR,MyGrArea.Img);
      mTextOutXY(3,117,'po <Enter> zadej heslo, <F1>=help',b_XOR,MyGrArea.Img,cF6x8cr);
      {ramecek pro zadani hesla}
      mDrawBox(35,55,205,93,b_OR,MyGrArea.Img);
     UnLockKernel;
      PomStr:='';
      BkBmp:=cBMP_GrArea;
      GraphStr:='';
      HelpStr:=zEsc+sF8x8c +',90,2;NÁPOVĚDA'+
               zEsc+sF6x8cr+',10,30;Pro vstup do servisního menu'+
               zEsc+sF6x8cr+',10,40;stiskni <ENTER>, zadej'+
               zEsc+sF6x8cr+',10,50;správné heslo a stiskni opět'+
               zEsc+sF6x8cr+',10,60;<ENTER>';
      SetEditWin(1,1,10,1);
      EditEnter:=True;
      EditPassWord(PomStr);
      SetUserThird(Addr(pMServMenuThirth));  { instalace procedury pro test hesla }
      SetCtrlTab([iDn,iUp],word(tFirstMenu));
      SetTransCtrlTab([zCr],iJmp1,word(tMTimeDate));
    end;
  end;
end;

{------------------------------------------}
procedure pMTimeDate(P: pMenuGr); far; {MENU NASTAVENI DATA A CASU}
var Time:DateTime;
    X:Word;
begin
  with P^ do
  begin
    with Time do GetTime( Hour, Min, Sec, X);
    with Time do GetDate( Year, Month, Day, X);
   LockKernel;
    MyGrArea.ClearImage;
    {nadpis}
    mTextOutXY(50,2,'Nastavení času a data',b_OR,MyGrArea.Img,cF12x16wcr);
    mDrawLine(1,18,238,18,b_OR,MyGrArea.Img); {podtrzeni nadpisu}
    mDrawBox(1,1,238,126,b_OR,MyGrArea.Img);{oramovani obrazovky}

    mTextOutXY(60,25,TimeToStr(Time,'HH:MM:SS'),b_OR,MyGrArea.Img,cF16x32c);
    mTextOutXY(45,65,DateToStr(Time,'DD.MM.YYYY'),b_OR,MyGrArea.Img,cF16x32c);
    {dolni cerna linka}
    mFillBox(1,115,238,126,b_OR,MyGrArea.Img);
    mTextOutXY(3,117,'<C>=čas; <D>=datum; <F1>=help;',b_XOR,MyGrArea.Img,cF6x8cr);
    ArrowsX:=170; {sipky}
    mDrawLine(ArrowsX+ 2,117,ArrowsX+ 0,119,b_XOR,MyGrArea.Img);{/}
    mDrawLine(ArrowsX+ 2,117,ArrowsX+ 4,119,b_XOR,MyGrArea.Img);{\}
    mDrawLine(ArrowsX+ 2,117,ArrowsX+ 2,125,b_XOR,MyGrArea.Img);{|}
    mDrawLine(ArrowsX+11,123,ArrowsX+13,125,b_XOR,MyGrArea.Img);{\}
    mDrawLine(ArrowsX+15,123,ArrowsX+13,125,b_XOR,MyGrArea.Img);{/}
    mDrawLine(ArrowsX+13,117,ArrowsX+13,125,b_XOR,MyGrArea.Img);{|}
   UnlockKernel;
    if ChangeMenu then
    begin
      DispStr:='';
      BkBmp:=cBMP_GrArea;
      GraphStr:='';
      HelpStr:=zEsc+sF8x8c+',90,2;NÁPOVĚDA'+
               zEsc+sF6x8c+',10,20;[C] nastavení času'+
               zEsc+sF6x8c+',10,30;[D] nastavení data';
      AddTerminateChar(['C','D']);
      SetTransCtrlTab(['C'],iCall1,word(tNastTime));
      SetTransCtrlTab(['D'],iCall2,word(tNastDate));
      SetCtrlTab([iUp],word(tMAppInfo));
      SetCtrlTab([iDn],word(tNastavHeslo));
    end;
  end;
end;

{--------------------------------------}
procedure pNastTimeThirth(P: pMenuGr); far;
var Time:DateTime;
begin
   with P^, Time do
   if ActChar=zCR then
   begin
     if StrToTime(TimeStr,Time) then
     begin
      LockKernel;
       SetTime(Hour, Min, Sec, 0);
       pTermT10(P^.Term)^.TimeLastKeyPressed:=Min*60+Sec;
      UnLockKernel;
     end;
   end;
end;
{--------------}
procedure pNastTime(P: pMenuGr); far;  { NASTAVENI CASU}
var Time:DateTime;
    X:Word;
begin
  with P^ do
  begin
    with Time do GetTime( Hour, Min, Sec, X);
    with Time do GetDate( Year, Month, Day, X);
    TimeStr:=TimeToStr(Time,'HH:MM:SS');
   LockKernel;
    MyGrArea.ClearImage;
    {nadpis}
    mTextOutXY(75,2,'Nastavení času',b_OR,MyGrArea.Img,cF12x16wcr);
    mDrawLine(1,18,238,18,b_OR,MyGrArea.Img); {podtrzeni nadpisu}
    mDrawBox(1,1,238,126,b_OR,MyGrArea.Img);{oramovani obrazovky}

    mTextOutXY(45,65,DateToStr(Time,'DD.MM.YYYY'),b_OR,MyGrArea.Img,cF16x32c);
    {dolni cerna linka}
    mFillBox(1,115,238,126,b_OR,MyGrArea.Img);
    mTextOutXY(3,117,'<Enter>=nastav; <Esc>=zpět; <F1>=help',b_XOR,MyGrArea.Img,cF6x8cr);
   UnLockKernel;
    DispStr:='HH:MM:SS'+zESC+sF16x32c+',60,25;';
    BkBmp:=cBMP_GrArea;
    HelpStr:=zEsc+sF8x8c+',90,2;NÁPOVĚDA'+
             zEsc+sF6x8c+',10,20;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;
begin
   with P^,Time do
   if ActChar=zCR then
   begin
     if StrToDate(DateStr,Time) then
     begin
      LockKernel;
       SetDate(Year, Month, Day);
      UnLockKernel;
     end;
   end;
end;
{-------------}
procedure pNastDate(P: pMenuGr); far;    { NASTAVENI DATA}
var Time:DateTime;
    X:Word;
begin
  with P^ do
  begin
    with Time do GetTime( Hour, Min, Sec, X);
    with Time do GetDate( Year, Month, Day, X);
    DateStr:=DateToStr(Time,'DD.MM.YYYY');
   LockKernel;
    MyGrArea.ClearImage;
    {nadpis}
    mTextOutXY(75,2,'Nastavení data',b_OR,MyGrArea.Img,cF12x16wcr);
    mDrawLine(1,18,238,18,b_OR,MyGrArea.Img); {podtrzeni nadpisu}
    mDrawBox(1,1,238,126,b_OR,MyGrArea.Img);{oramovani obrazovky}

    mTextOutXY(60,25,TimeToStr(Time,'HH:MM:SS'),b_OR,MyGrArea.Img,cF16x32c);
    {dolni cerna linka}
    mFillBox(1,115,238,126,b_OR,MyGrArea.Img);
    mTextOutXY(3,117,'<Enter>=nastav; <Esc>=zpět; <F1>=help',b_XOR,MyGrArea.Img,cF6x8cr);
   UnLockKernel;
    DispStr:='DD.MM.YYYY'+zESC+sF16x32c+',45,65;';
    BkBmp:=cBMP_GrArea;
    HelpStr:=zEsc+sF8x8c+',90,2;NÁPOVĚDA'+
             zEsc+sF6x8c+',10,20;Zadej datum ve tvaru: "DD.MM.RRRR"';
    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;
begin
  with P^, Glb^ do
  begin
    if ActChar=zCr then
    begin
      gServHeslo:=UpCaseStr(gServHeslo);
      SetActMenu(Word(tNastavHeslo));
    end;
  end;
end;
{---------}
procedure pNastavHeslo(P: pMenuGr); far;      {EDITACE HESLA}
begin
  with P^ do
  begin
    if ChangeMenu then
    begin
     LockKernel;
      MyGrArea.ClearImage;
      {nadpis}
      mTextOutXY(60,2,'Nastavení hesla:',b_OR,MyGrArea.Img,cF12x16wcr);
      mDrawLine(1,18,238,18,b_OR,MyGrArea.Img);{podtrzeni nadpisu}
      mDrawBox(1,1,238,126,b_OR,MyGrArea.Img);{oramovani obrazovky}
      {texty}
      mDrawBox(35,55,205,93,b_OR,MyGrArea.Img);
      {dolni cerna linka}
      mFillBox(1,115,238,126,b_OR,MyGrArea.Img);
      mTextOutXY(3,117,'<Enter>=editace, <F1>=help',b_XOR,MyGrArea.Img,cF6x8cr);
     UnLockKernel;
      DispStr:='1234567890 '+zESC+sF12x16wcr+',40,65;';
      BkBmp:=cBMP_GrArea;
      GraphStr:='';
      HelpStr:=zEsc+sF8x8c+',90,2;NÁPOVĚDA'+
               zEsc+sF6x8c+',10,20;<ENTER> - editace hesla pro vstup'+
               zEsc+sF6x8c+',10,30;          do servisního menu';
      EditEnter:=True;
      SetEditWin(1,1,10,1);
      EditString(Glb^.gServHeslo);
      SetTerminateChar([zUp,zDn,zESC,zCR]);
      SetUserThird(Addr(pNastavHesloThirth));
      SetTransCtrlTab([zESC,zCR],iJmp2,Word(tNastavHeslo));
      SetCtrlTab([iUp],word(tMTimeDate));
      SetCtrlTab([iDn],word(tMAppInfo));
    end;
  end;
end;

{----------------------------------------}
procedure pMAppInfoThirth(P: pMenuGr); far;
{$ifdef VerMC}
var
  ManDev ,
  LenSect: word;
  Vysledek : boolean;
{$endif}
begin
  with P^ do
  if ActChar<>#0 then
  begin
    Move(BufNula[2],BufNula[1],4);
    BufNula[5]:=UpCase(ActChar);
    with Glb^.gRStruct do
    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
            CommonRstStruct.RstCt:=0;
            gPFICt:=0;
          end;
    end;
    if BufNula='RESET' then
    begin     { Znovunastaveni Glb }
      Glb^.gRStruct.CommonRstStruct.Verse:=0;
{$ifdef VerMc}
      asm cli end;
      repeat until false;   {WatchDog provede reset}
{$endif}
      Halt(0);
    end;
    if BufNula='DESTR' then
    begin
{$ifdef VerMc}
      if ATMIdent(cFlashBase,ManDev,LenSect) then
      begin
        Vysledek:=ATMDestruct(cFlashBase,cAppBegin);
        asm cli end;
        repeat until false; {WatchDog provede reset}
      end;
{$endif}
      Halt(0);
    end;
  end;
end;
{-----------}
procedure pMAppInfo(P: pMenuGr); far;
begin
  with P^ do
  begin
    if ChangeMenu then ViewRst:=Glb^.gRStruct.CommonRstStruct.ARst;

    with Glb^,gRStruct,CommonRstStruct.Rst[ViewRst] do
    begin
     LockKernel;
      MyGrArea.ClearImage;
      {nadpis}
      mTextOutXY(80,2,'Aplication Info',b_OR,MyGrArea.Img,cF12x16wcr);
      mDrawLine(1,18,238,18,b_OR,MyGrArea.Img); {podtrzeni nadpisu}
      mDrawBox(1,1,238,126,b_OR,MyGrArea.Img);{oramovani obrazovky}
      {texty}
      mTextOutXY(15,25,'App Version'     ,b_OR,MyGrArea.Img,cF8x8c);
      mTextOutXY(117,25,AppVer           ,b_OR,MyGrArea.Img,cF6x8c);
      mTextOutXY(15,35,'Lib Version      '+uTermT10.cVer,b_OR,MyGrArea.Img,cF6x8c);
      mTextOutXY(15,45,'Restart counter  '+WordStrDec(CommonRstStruct.RstCt,0),b_OR,MyGrArea.Img,cF6x8c);
      mTextOutXY(15,55,'PFI     counter  '+WordStrDec(gPFICt,0),b_OR,MyGrArea.Img,cF6x8c);
      mTextOutXY(15,65,'Aktual restart   '+ByteStrDec(CommonRstStruct.ARst,0),b_OR,MyGrArea.Img,cF6x8c);
      mTextOutXY(25,75,'View Restart no. '+ByteStrDec(ViewRst,0)+' Proc. '+Copy(rStr,1,10),b_OR,MyGrArea.Img,cF6x8c);
      if rPckTime=0 then
      mTextOutXY(25,85,'Time 00.00.0000   00:00:00',b_OR,MyGrArea.Img,cF6x8c)
      else
      mTextOutXY(25,85,'Time '+DateToStrPT(rPckTime,'DD.MM.YYYY')+'   '+
                       TimeToStrPT(rPckTime,'HH:MM:SS'),b_OR,MyGrArea.Img,cF6x8c);
      mTextOutXY(25,95,'Error '+ByteStrDec(rErr,0)+' on addr '+
                        +PtrToStr(rAddr),b_OR,MyGrArea.Img,cF6x8c);
      {spodni cerna linka}
      mFillBox(1,104,238,126,b_OR,MyGrArea.Img);
      mTextOutXY(15,107,'"RESET" = Reset & Init Glb',b_XOR,MyGrArea.Img,cF6x8c);
      mTextOutXY(15,117,'"DESTR" = Destruct App',b_XOR,MyGrArea.Img,cF6x8c);
     UnLockKernel;
    end;
    if ChangeMenu then
    begin
      DispStr:='';
      BkBmp:=cBMP_GrArea;
      HelpStr:=zEsc+sF8x8c+',90,2;NÁPOVĚDA'+
               zEsc+sF6x8c+',10,20;<-,-> změna zobrazeného restartu'+
               zEsc+sF6x8c+',10,32;  0   nulování Restart a PFI čítačů'+
               zEsc+sF6x8c+',10,44;RESET Init Glb + reset'+
               zEsc+sF6x8c+',10,56;DESTR spuštění Bios Monitoru pro'+
               zEsc+sF6x8c+',10,66;      nahrání nové aplikace';
      SetCtrlTab([iDn],word(tMTimeDate));
      SetTransCtrlTab([zESC],iJmp2,word(tMTimeDate));
      SetUserThird(Addr(pMAppInfoThirth));
    end;
  end;
end;

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

procedure pErrorM7(P: pMenuGr); far;       {MENU INTERRUPT 7}
begin
  with P^ 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:=cBMP_GrArea;
      GraphStr:='';
      HelpStr:=zEsc+sF8x8c+',90,2;NÁPOVĚDA'+
               zEsc+sF6x8c+',10,20;Interrupt Menu 7';
      TerminateChar  :=[zCr,zEsc];
      TransTab[zCr]  :=iRet;
    end;
  end;
end;

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

procedure pErrorM6(P: pMenuGr); far;       {MENU INTERRUPT 6}
begin
  with P^ 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:=cBMP_GrArea;
      GraphStr:='';
      HelpStr:=zEsc+sF8x8c+',90,2;NÁPOVĚDA'+
               zEsc+sF6x8c+',10,20;Interrupt Menu 6';
      TerminateChar  :=[zCr,zEsc];
      TransTab[zCr]  :=iRet;
    end;
  end;
end;

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

procedure pErrorM5(P: pMenuGr); far;       {MENU INTERRUPT 5}
begin
  with P^ 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:=cBMP_GrArea;
      GraphStr:='';
      HelpStr:=zEsc+sF8x8c+',90,2;NÁPOVĚDA'+
               zEsc+sF6x8c+',10,20;Interrupt Menu 5';
      TerminateChar  :=[zCr,zEsc];
      TransTab[zCr]  :=iRet;
    end;
  end;
end;

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

procedure pErrorM4(P: pMenuGr); far;       {MENU INTERRUPT 4}
begin
  with P^ 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:=cBMP_GrArea;
      GraphStr:='';
      HelpStr:=zEsc+sF8x8c+',90,2;NÁPOVĚDA'+
               zEsc+sF6x8c+',10,20;Interrupt Menu 4';
      TerminateChar  :=[zCr,zEsc];
      TransTab[zCr]  :=iRet;
    end;
  end;
end;

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

procedure pErrorM3(P: pMenuGr); far;       {MENU INTERRUPT 3}
begin
  with P^ 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:=cBMP_GrArea;
      GraphStr:='';
      HelpStr:=zEsc+sF8x8c+',90,2;NÁPOVĚDA'+
               zEsc+sF6x8c+',10,20;Interrupt Menu 3';
      TerminateChar  :=[zCr,zEsc];
      TransTab[zCr]  :=iRet;
    end;
  end;
end;

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

procedure pErrorM2(P: pMenuGr); far;       {MENU INTERRUPT 2}
begin
  with P^ do
  begin
   LockKernel;
    MyGrArea.ClearImage;
    mTextOutXY(90,0,'ERROR 2',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:=cBMP_GrArea;
      GraphStr:='';
      HelpStr:=zEsc+sF8x8c+',90,2;NÁPOVĚDA'+
               zEsc+sF6x8c+',10,20;Interrupt Menu 2';
      TerminateChar  :=[zCr,zEsc];
      TransTab[zCr]  :=iRet;
    end;
  end;
end;

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

procedure pErrorM1(P: pMenuGr); far;       {MENU INTERRUPT 1}
begin
  with P^ 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:=cBMP_GrArea;
      GraphStr:='';
      HelpStr:=zEsc+sF8x8c+',90,2;NÁPOVĚDA'+
               zEsc+sF6x8c+',10,20;Interrupt Menu 1';
      TerminateChar  :=[zCr,zEsc];
      TransTab[zCr]  :=iRet;
    end;
  end;
end;

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

procedure pErrorM0(P: pMenuGr); far;       {MENU INTERRUPT 0}
begin
  with P^ 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:=cBMP_GrArea;
      GraphStr:='';
      HelpStr:=zEsc+sF8x8c+',90,2;NÁPOVĚDA'+
               zEsc+sF6x8c+',10,20;Interrupt Menu 0';
      TerminateChar  :=[zCr,zEsc];
      TransTab[zCr]  :=iRet;
    end;
  end;
end;

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

const
  ProcPtrArray  :array[tSelector]of tMMenuGr =
            {poradi procedur musi byt shodne s typem tSelector}
            (pUvod,
             pFirstMenu,
             pMServMenu,
             pMTimeDate,
               pNastTime,
               pNastDate,
             pNastavHeslo,
             pMAppInfo,
             pErrorM7,
             pErrorM6,
             pErrorM5,
             pErrorM4,
             pErrorM3,
             pErrorM2,
             pErrorM1,
             pErrorM0
            );


{----------------------------------------}
procedure UserMenu;
begin
{$ifdef SimPC}       { je zapnut simulator TERM10 }
  MyTerm:=New(PTermT10,Init(New(PSimDispT10,Init(nil,31{CharCols},8{CharRows},AdrTerm,True,
                                                0,0,2,2,265,165,false{DoubleSize})),
                            New(PSimKeybT10,Init(nil,20{Len},AdrTerm,FlEnd)),
                            AdrTerm,nil,nil));

{$else}

  MyTerm:=New(pTermT10,Init(New({$ifdef Term10A}PDispT10A{$else}PDispT10{$endif},
                                         Init(nil,31{CharCols},8{CharRows},AdrTerm,True)),
                            New(PKeybT10,Init(nil,20{Len},AdrTerm)),
                            AdrTerm,nil,nil));
{$endif}
  MyTerm^.SetTDispParam(sParTerm);
  MyTerm^.LedSign(Term10LED,$00);
  MyMenu:=New(pMenuGr,Init(@ProcPtrArray,
                           ord(tErrorM0),
                           DispStr,
                           HelpStr,
                           GraphStr,
                           @BkBMP,
                           MyTerm,
                           '',
                           2));   {wait pri cekani menuter2}

  with MyMenu^ do
  begin
    MenuIntEnable:=true;
   {$ifdef SetupF10}
    SetupKeyChar:=zF10;
   {$endif}
  end;

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

  InitRunMenu(MyMenu,
              MenuName,MenuStk,MenuSPrio,MenuDPrio,
              TermName,TermStk,TermSPrio,TermDPrio,
              4,2, {wait ve volani menuterA.Run; Term10.Tick}
              edNop,
{$ifdef SimHW}
              SimHWKlav,
{$else}
              edNop,
{$endif}
              FlEnd);
end;


procedure InitializeBMPs;
var Lng:word;
begin
  User_BkBMPs[cBMP_Logo].AssignBMPAddr(GetBMPAddr_LOGO(Lng),Lng);
  MyGrArea.Init(240,128);
  Lng:=SizeOf(MyGrArea);
  User_BkBMPs[cBMP_GrArea].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[cF6x8c] do
  begin
    P:=pViewFont08x08;
    U:=GetFontAddr_f6x8c(PomLng);
  end;
  with User_FontArray[cF6x8cr] do
  begin
    P:=pViewFont08x08;
    U:=GetFontAddr_f6x8cr(PomLng);
  end;

end;



Begin
  InitializeAppFonts;
  InitializeBMPs;
End.
