Subversion Repositories Kolibri OS

Rev

Go to most recent revision | 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*, time, cnt: INTEGER;
  27.         paused: BOOLEAN;
  28.  
  29.  
  30. PROCEDURE reset*;
  31. BEGIN
  32.         cnt := time;
  33.         paused := FALSE
  34. END reset;
  35.  
  36.  
  37. PROCEDURE stop*;
  38. BEGIN
  39.         cnt := time;
  40.         paused := TRUE
  41. END stop;
  42.  
  43.  
  44. PROCEDURE kill*;
  45. BEGIN
  46.         ID := 0;
  47.         K.ExitID(ID)
  48. END kill;
  49.  
  50.  
  51. PROCEDURE [stdcall] main (mainTID: INTEGER);
  52. CONST
  53.         step = 5;
  54. BEGIN
  55.         WHILE TRUE DO
  56.                 K.Pause(step);
  57.                 IF KOSAPI.sysfunc3(18, 21, mainTID) = 0 THEN
  58.                         ID := 0;
  59.                         K.Exit
  60.                 END;
  61.                 IF ~paused THEN
  62.                         DEC(cnt, step);
  63.                         IF cnt <= 0 THEN
  64.                                 cnt := time;
  65.                                 IF time > 0 THEN
  66.                                         K.SendIPC(mainTID, ID)
  67.                                 END
  68.                         END
  69.                 END
  70.         END
  71. END main;
  72.  
  73.  
  74. PROCEDURE create* (mainTID: INTEGER);
  75. BEGIN
  76.         time := Ini.blink;
  77.         reset;
  78.         stack[LEN(stack) - 1] := mainTID;
  79.         ID := K.CreateThread(SYSTEM.ADR(main), stack)
  80. END create;
  81.  
  82.  
  83. BEGIN
  84.         ID := 0
  85. END Timer.