Subversion Repositories Kolibri OS

Rev

Rev 9181 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
9174 akron1 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 .
18
*)
19
 
20
MODULE Timer;
21
 
22
IMPORT SYSTEM, K := KolibriOS, KOSAPI, Ini;
23
 
24
VAR
25
	stack: ARRAY 1024*64 OF INTEGER;
9181 akron1 26
	ID*, n*, time, cnt: INTEGER;
27
	enabled: BOOLEAN;
28
	msg: ARRAY 3 OF INTEGER;
9174 akron1 29
 
30
 
31
PROCEDURE kill*;
32
BEGIN
9181 akron1 33
	enabled := FALSE;
34
	INC(n)
9174 akron1 35
END kill;
36
 
37
 
38
PROCEDURE [stdcall] main (mainTID: INTEGER);
39
CONST
40
	step = 5;
41
BEGIN
9181 akron1 42
	msg[0] := ID;
43
	msg[1] := 12;
9174 akron1 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;
9181 akron1 50
		IF enabled THEN
9174 akron1 51
			DEC(cnt, step);
52
			IF cnt <= 0 THEN
9210 akron1 53
				K.SendIPC(mainTID, msg);
9180 akron1 54
				cnt := time
9174 akron1 55
			END
56
		END
57
	END
58
END main;
59
 
60
 
61
PROCEDURE create* (mainTID: INTEGER);
62
BEGIN
63
	time := Ini.blink;
9181 akron1 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
9174 akron1 73
END create;
74
 
75
 
76
BEGIN
9181 akron1 77
	ID := 0;
78
	msg[2] := 0;
79
	n := 0;
9174 akron1 80
END Timer.