Subversion Repositories Kolibri OS

Rev

Rev 9174 | 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;
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
9180 akron1 64
				K.SendIPC(mainTID, ID);
65
				cnt := time
9174 akron1 66
			END
67
		END
68
	END
69
END main;
70
 
71
 
72
PROCEDURE create* (mainTID: INTEGER);
73
BEGIN
74
	time := Ini.blink;
75
	reset;
76
	stack[LEN(stack) - 1] := mainTID;
77
	ID := K.CreateThread(SYSTEM.ADR(main), stack)
78
END create;
79
 
80
 
81
BEGIN
82
	ID := 0
83
END Timer.