kolibrios/programs/develop/cedit/SRC/Timer.ob07
Anton Krotov 0d7861018a CEDIT: EOL conversion (CRLF/LF/CR)
git-svn-id: svn://kolibrios.org@9180 a494cfbc-eb01-0410-851d-a64ba20cac60
2021-09-06 21:06:31 +00:00

83 lines
1.6 KiB
Plaintext

(*
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;
ID*, time, cnt: INTEGER;
paused: BOOLEAN;
PROCEDURE reset*;
BEGIN
cnt := time;
paused := FALSE
END reset;
PROCEDURE stop*;
BEGIN
cnt := time;
paused := TRUE
END stop;
PROCEDURE kill*;
BEGIN
ID := 0;
K.ExitID(ID)
END kill;
PROCEDURE [stdcall] main (mainTID: INTEGER);
CONST
step = 5;
BEGIN
WHILE TRUE DO
K.Pause(step);
IF KOSAPI.sysfunc3(18, 21, mainTID) = 0 THEN
ID := 0;
K.Exit
END;
IF ~paused THEN
DEC(cnt, step);
IF cnt <= 0 THEN
K.SendIPC(mainTID, ID);
cnt := time
END
END
END
END main;
PROCEDURE create* (mainTID: INTEGER);
BEGIN
time := Ini.blink;
reset;
stack[LEN(stack) - 1] := mainTID;
ID := K.CreateThread(SYSTEM.ADR(main), stack)
END create;
BEGIN
ID := 0
END Timer.