Subversion Repositories Kolibri OS

Rev

Rev 7597 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7597 Rev 7693
Line 18... Line 18...
18
    maxint* = HOST.maxint;
18
    maxint* = HOST.maxint;
19
    minint* = HOST.minint;
19
    minint* = HOST.minint;
Line 20... Line 20...
20
    
20
 
Line -... Line 21...
-
 
21
    OS = HOST.OS;
-
 
22
 
-
 
23
    min32* = -2147483647-1;
Line 21... Line 24...
21
    OS = HOST.OS;
24
    max32* =  2147483647;
Line 22... Line 25...
22
 
25
 
Line 23... Line 26...
23
 
26
 
Line 24... Line 27...
24
VAR
27
VAR
Line -... Line 28...
-
 
28
 
-
 
29
    time*: INTEGER;
-
 
30
 
-
 
31
    eol*:  ARRAY 3 OF CHAR;
-
 
32
 
-
 
33
    maxreal*: REAL;
-
 
34
 
-
 
35
    target*:
-
 
36
 
-
 
37
      RECORD
-
 
38
 
-
 
39
          bit_depth*,
-
 
40
          maxInt*,
-
 
41
          minInt*,
-
 
42
          maxSet*,
-
 
43
          maxHex*:    INTEGER;
Line 25... Line 44...
25
 
44
 
26
    time*: INTEGER;
45
          maxReal*:   REAL
27
 
46
 
Line 110... Line 129...
110
 
129
 
111
    RETURN res
130
    RETURN res
Line -... Line 131...
-
 
131
END UnixTime;
-
 
132
 
-
 
133
 
-
 
134
PROCEDURE SetBitDepth* (BitDepth: INTEGER);
-
 
135
BEGIN
-
 
136
    ASSERT((BitDepth = 16) OR (BitDepth = 32) OR (BitDepth = 64));
-
 
137
    bit_diff := bit_depth - BitDepth;
-
 
138
    ASSERT(bit_diff >= 0);
-
 
139
 
-
 
140
    target.bit_depth := BitDepth;
-
 
141
    target.maxSet    := BitDepth - 1;
-
 
142
    target.maxHex    := BitDepth DIV 4;
-
 
143
    target.minInt    := ASR(minint, bit_diff);
-
 
144
    target.maxInt    := ASR(maxint, bit_diff);
-
 
145
    target.maxReal   := 1.9;
-
 
146
    PACK(target.maxReal, 1023);
-
 
147
END SetBitDepth;
-
 
148
 
-
 
149
 
-
 
150
PROCEDURE Byte* (n: INTEGER; idx: INTEGER): BYTE;
-
 
151
    RETURN ASR(n, 8 * idx) MOD 256
-
 
152
END Byte;
-
 
153
 
-
 
154
 
-
 
155
PROCEDURE Align* (VAR bytes: INTEGER; align: INTEGER): BOOLEAN;
-
 
156
VAR
-
 
157
    res: BOOLEAN;
-
 
158
 
-
 
159
BEGIN
-
 
160
    IF bytes MOD align # 0 THEN
-
 
161
        res := maxint - bytes >= align - (bytes MOD align);
-
 
162
        IF res THEN
-
 
163
            bytes := bytes + align - (bytes MOD align)
-
 
164
        END
-
 
165
    ELSE
-
 
166
        res := TRUE
-
 
167
    END
-
 
168
 
-
 
169
    RETURN res
-
 
170
END Align;
-
 
171
 
-
 
172
 
-
 
173
PROCEDURE Long* (value: INTEGER): INTEGER;
-
 
174
    RETURN ASR(LSL(value, bit_diff), bit_diff)
-
 
175
END Long;
-
 
176
 
-
 
177
 
-
 
178
PROCEDURE Short* (value: INTEGER): INTEGER;
-
 
179
    RETURN LSR(LSL(value, bit_diff), bit_diff)
-
 
180
END Short;
-
 
181
 
-
 
182
 
-
 
183
PROCEDURE Log2* (x: INTEGER): INTEGER;
-
 
184
VAR
-
 
185
    n: INTEGER;
-
 
186
 
-
 
187
BEGIN
-
 
188
    ASSERT(x > 0);
-
 
189
 
-
 
190
    n := 0;
-
 
191
    WHILE ~ODD(x) DO
-
 
192
        x := x DIV 2;
-
 
193
        INC(n)
-
 
194
    END;
-
 
195
 
-
 
196
    IF x # 1 THEN
-
 
197
        n := -1
-
 
198
    END
-
 
199
 
-
 
200
    RETURN n
112
END UnixTime;
201
END Log2;
113
 
202
 
114
 
203
 
115
BEGIN
204
BEGIN
116
    time := GetTickCount();
205
    time := GetTickCount();