2021-09-03 01:15:33 +02:00
|
|
|
(*
|
|
|
|
Copyright 2021 Anton Krotov
|
|
|
|
|
|
|
|
This file is part of CEdit.
|
|
|
|
|
|
|
|
CEdit is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
CEdit is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with CEdit. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*)
|
|
|
|
|
|
|
|
MODULE Timer;
|
|
|
|
|
|
|
|
IMPORT SYSTEM, K := KolibriOS, KOSAPI, Ini;
|
|
|
|
|
|
|
|
VAR
|
|
|
|
stack: ARRAY 1024*64 OF INTEGER;
|
2021-09-07 22:18:42 +02:00
|
|
|
ID*, n*, time, cnt: INTEGER;
|
|
|
|
enabled: BOOLEAN;
|
|
|
|
msg: ARRAY 3 OF INTEGER;
|
2021-09-03 01:15:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE kill*;
|
|
|
|
BEGIN
|
2021-09-07 22:18:42 +02:00
|
|
|
enabled := FALSE;
|
|
|
|
INC(n)
|
2021-09-03 01:15:33 +02:00
|
|
|
END kill;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE [stdcall] main (mainTID: INTEGER);
|
|
|
|
CONST
|
|
|
|
step = 5;
|
|
|
|
BEGIN
|
2021-09-07 22:18:42 +02:00
|
|
|
msg[0] := ID;
|
|
|
|
msg[1] := 12;
|
2021-09-03 01:15:33 +02:00
|
|
|
WHILE TRUE DO
|
|
|
|
K.Pause(step);
|
|
|
|
IF KOSAPI.sysfunc3(18, 21, mainTID) = 0 THEN
|
|
|
|
ID := 0;
|
|
|
|
K.Exit
|
|
|
|
END;
|
2021-09-07 22:18:42 +02:00
|
|
|
IF enabled THEN
|
2021-09-03 01:15:33 +02:00
|
|
|
DEC(cnt, step);
|
|
|
|
IF cnt <= 0 THEN
|
2021-10-03 19:44:42 +02:00
|
|
|
K.SendIPC(mainTID, msg);
|
2021-09-06 23:06:31 +02:00
|
|
|
cnt := time
|
2021-09-03 01:15:33 +02:00
|
|
|
END
|
|
|
|
END
|
|
|
|
END
|
|
|
|
END main;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE create* (mainTID: INTEGER);
|
|
|
|
BEGIN
|
|
|
|
time := Ini.blink;
|
2021-09-07 22:18:42 +02:00
|
|
|
cnt := time;
|
|
|
|
enabled := TRUE;
|
|
|
|
IF ID = 0 THEN
|
|
|
|
stack[LEN(stack) - 1] := mainTID;
|
|
|
|
ID := K.CreateThread(SYSTEM.ADR(main), stack)
|
|
|
|
ELSE
|
|
|
|
INC(n);
|
|
|
|
msg[2] := n
|
|
|
|
END
|
2021-09-03 01:15:33 +02:00
|
|
|
END create;
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN
|
2021-09-07 22:18:42 +02:00
|
|
|
ID := 0;
|
|
|
|
msg[2] := 0;
|
|
|
|
n := 0;
|
2021-09-03 01:15:33 +02:00
|
|
|
END Timer.
|