Subversion Repositories Kolibri OS

Rev

Rev 9180 | Blame | Last modification | View Log | Download | RSS feed

  1. (*
  2.     Copyright 2021 Anton Krotov
  3.  
  4.     This file is part of CEdit.
  5.  
  6.     CEdit is free software: you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation, either version 3 of the License, or
  9.     (at your option) any later version.
  10.  
  11.     CEdit is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with CEdit. If not, see <http://www.gnu.org/licenses/>.
  18. *)
  19.  
  20. MODULE Timer;
  21.  
  22. IMPORT SYSTEM, K := KolibriOS, KOSAPI, Ini;
  23.  
  24. VAR
  25.         stack: ARRAY 1024*64 OF INTEGER;
  26.         ID*, n*, time, cnt: INTEGER;
  27.         enabled: BOOLEAN;
  28.         msg: ARRAY 3 OF INTEGER;
  29.  
  30.  
  31. PROCEDURE kill*;
  32. BEGIN
  33.         enabled := FALSE;
  34.         INC(n)
  35. END kill;
  36.  
  37.  
  38. PROCEDURE [stdcall] main (mainTID: INTEGER);
  39. CONST
  40.         step = 5;
  41. BEGIN
  42.         msg[0] := ID;
  43.         msg[1] := 12;
  44.         WHILE TRUE DO
  45.                 K.Pause(step);
  46.                 IF KOSAPI.sysfunc3(18, 21, mainTID) = 0 THEN
  47.                         ID := 0;
  48.                         K.Exit
  49.                 END;
  50.                 IF enabled THEN
  51.                         DEC(cnt, step);
  52.                         IF cnt <= 0 THEN
  53.                                 KOSAPI.sysfunc5(60, 2, mainTID, SYSTEM.ADR(msg[0]), msg[1]);
  54.                                 cnt := time
  55.                         END
  56.                 END
  57.         END
  58. END main;
  59.  
  60.  
  61. PROCEDURE create* (mainTID: INTEGER);
  62. BEGIN
  63.         time := Ini.blink;
  64.         cnt := time;
  65.         enabled := TRUE;
  66.         IF ID = 0 THEN
  67.                 stack[LEN(stack) - 1] := mainTID;
  68.                 ID := K.CreateThread(SYSTEM.ADR(main), stack)
  69.         ELSE
  70.                 INC(n);
  71.                 msg[2] := n
  72.         END
  73. END create;
  74.  
  75.  
  76. BEGIN
  77.         ID := 0;
  78.         msg[2] := 0;
  79.         n := 0;
  80. END Timer.