Subversion Repositories Kolibri OS

Rev

Rev 666 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 666 Rev 763
1
{cp866}
1
{cp866}
2
 
2
 
3
{ User interface }
3
{ User interface }
4
procedure kos_definewindow(x, y, w, h: Word; style, header, clframe: DWord); assembler; register;
4
procedure kos_definewindow(x, y, w, h: Word; style, header, clframe: DWord); assembler; register;
5
asm
5
asm
6
  pushl %ebx
6
  pushl %ebx
7
  pushl %ecx
7
  pushl %ecx
8
  pushl %edx
8
  pushl %edx
9
  pushl %esi
9
  pushl %esi
10
  pushl %edi
10
  pushl %edi
11
  movl  %eax, %ebx
11
  movl  %eax, %ebx
12
  xchgl %edx, %ecx
12
  xchgl %edx, %ecx
13
  movl  header, %esi
13
  movl  header, %esi
14
  shll  $16, %ebx
14
  shll  $16, %ebx
15
  shll  $16, %ecx
15
  shll  $16, %ecx
16
  movl  clframe, %edi
16
  movl  clframe, %edi
17
  movw  %dx, %bx
17
  movw  %dx, %bx
18
  movw  h, %cx
18
  movw  h, %cx
19
  xorl  %eax, %eax
19
  xorl  %eax, %eax
20
  movl  style, %edx
20
  movl  style, %edx
21
  decl  %ebx  {㬥­ìè¨âì è¨à¨­ã ­  1}
21
  decl  %ebx  {㬥­ìè¨âì è¨à¨­ã ­  1}
22
  decl  %ecx  {㬥­ìè¨âì ¢ëá®âã ­  1}
22
  decl  %ecx  {㬥­ìè¨âì ¢ëá®âã ­  1}
23
  andl  $0xEFFFFFFF, %edx
23
  andl  $0xEFFFFFFF, %edx
24
  int   $0x40
24
  int   $0x40
25
  popl %edi
25
  popl %edi
26
  popl %esi
26
  popl %esi
27
  popl %edx
27
  popl %edx
28
  popl %ecx
28
  popl %ecx
29
  popl %ebx
29
  popl %ebx
30
end;
30
end;
31
 
31
 
32
procedure kos_movewindow(x, y, w, h: DWord); assembler; register;
32
procedure kos_movewindow(x, y, w, h: DWord); assembler; register;
33
asm
33
asm
34
  pushl %eax
34
  pushl %eax
35
  pushl %ebx
35
  pushl %ebx
36
  pushl %ecx
36
  pushl %ecx
37
  pushl %edx
37
  pushl %edx
38
  pushl %esi
38
  pushl %esi
39
  movl  %eax, %ebx
39
  movl  %eax, %ebx
40
  xchgl %ecx, %edx
40
  xchgl %ecx, %edx
41
  movl  $67, %eax
41
  movl  $67, %eax
42
  movl  h, %esi
42
  movl  h, %esi
43
  decl  %edx  {㬥­ìè¨âì è¨à¨­ã ­  1}
43
  decl  %edx  {㬥­ìè¨âì è¨à¨­ã ­  1}
44
  decl  %esi  {㬥­ìè¨âì ¢ëá®âã ­  1}
44
  decl  %esi  {㬥­ìè¨âì ¢ëá®âã ­  1}
45
  int   $0x40
45
  int   $0x40
46
  popl  %esi
46
  popl  %esi
47
  popl  %edx
47
  popl  %edx
48
  popl  %ecx
48
  popl  %ecx
49
  popl  %ebx
49
  popl  %ebx
50
  popl  %eax
50
  popl  %eax
51
end;
51
end;
52
 
52
 
53
function kos_getkey(): DWord; assembler; register;
53
function kos_getkey(): DWord; assembler; register;
54
asm
54
asm
55
  movl $2, %eax
55
  movl $2, %eax
56
  int  $0x40
56
  int  $0x40
57
end;
57
end;
58
 
58
 
59
function kos_getevent(wait: Boolean = True): DWord; assembler; register;
59
function kos_getevent(wait: Boolean = True): DWord; assembler; register;
60
asm
60
asm
61
  andl $1, %eax
61
  andl $1, %eax
62
  xorb $1, %al
62
  xorb $1, %al
63
  addl $10, %eax
63
  addl $10, %eax
64
  int  $0x40
64
  int  $0x40
65
end;
65
end;
66
 
66
 
67
function kos_waitevent(timeout: DWord): DWord; assembler; register;
67
function kos_waitevent(timeout: DWord): DWord; assembler; register;
68
asm
68
asm
69
  pushl %ebx
69
  pushl %ebx
70
  movl  $23, %ebx
70
  movl  $23, %ebx
71
  xchgl %eax, %ebx
71
  xchgl %eax, %ebx
72
  int  $0x40
72
  int  $0x40
73
  popl  %ebx
73
  popl  %ebx
74
end;
74
end;
75
 
75
 
76
function kos_getbutton(): DWord; assembler; register;
76
function kos_getbutton(): DWord; assembler; register;
77
asm
77
asm
78
  movl  $17, %eax
78
  movl  $17, %eax
79
  int   $0x40
79
  int   $0x40
80
  shrl  $8, %eax
80
  shrl  $8, %eax
81
  andl  $0xFF, %eax
81
  andl  $0xFF, %eax
82
end;
82
end;
83
 
83
 
84
function kos_getmousepos(): TKosPoint; assembler; register;
84
function kos_getmousepos(): TKosPoint; assembler; register;
85
{@return: x*65536 + y}
85
{@return: x*65536 + y}
86
asm
86
asm
87
  pushl %eax
87
  pushl %eax
88
  pushl %ebx
88
  pushl %ebx
89
  pushl %ecx
89
  pushl %ecx
90
  pushl %eax
90
  pushl %eax
91
  movl  $37, %eax
91
  movl  $37, %eax
92
  xorl  %ebx, %ebx
92
  xorl  %ebx, %ebx
93
  int   $0x40
93
  int   $0x40
94
  movswl %ax, %ecx
94
  movswl %ax, %ecx
95
  popl  %ebx
95
  popl  %ebx
96
  shrl  $16, %eax
96
  shrl  $16, %eax
97
  movl  %ecx, TKosPoint.Y(%ebx)
97
  movl  %ecx, TKosPoint.Y(%ebx)
98
  movl  %eax, TKosPoint.X(%ebx)
98
  movl  %eax, TKosPoint.X(%ebx)
99
  popl  %ecx
99
  popl  %ecx
100
  popl  %ebx
100
  popl  %ebx
101
  popl  %eax
101
  popl  %eax
102
end;
102
end;
103
 
103
 
104
function kos_getmousewinpos(): TKosPoint; assembler; register;
104
function kos_getmousewinpos(): TKosPoint; assembler; register;
105
{@return: x*65536 + y}
105
{@return: x*65536 + y}
106
asm
106
asm
107
  pushl %eax
107
  pushl %eax
108
  pushl %ebx
108
  pushl %ebx
109
  pushl %ecx
109
  pushl %ecx
110
  pushl %eax
110
  pushl %eax
111
  movl  $37, %eax
111
  movl  $37, %eax
112
  movl  $1, %ebx
112
  movl  $1, %ebx
113
  int   $0x40
113
  int   $0x40
114
  movswl %ax, %ecx
114
  movswl %ax, %ecx
115
  popl  %ebx
115
  popl  %ebx
116
  shrl  $16, %eax
116
  shrl  $16, %eax
117
  movl  %ecx, TKosPoint.Y(%ebx)
117
  movl  %ecx, TKosPoint.Y(%ebx)
118
  movl  %eax, TKosPoint.X(%ebx)
118
  movl  %eax, TKosPoint.X(%ebx)
119
  popl  %ecx
119
  popl  %ecx
120
  popl  %ebx
120
  popl  %ebx
121
  popl  %eax
121
  popl  %eax
122
end;
122
end;
123
 
123
 
124
function kos_getmousebuttons(): DWord; assembler; register;
124
function kos_getmousebuttons(): DWord; assembler; register;
125
{@return:
125
{@return:
126
  ¡¨â 0 ãáâ ­®¢«¥­ = «¥¢ ï ª­®¯ª  ­ ¦ â 
126
  ¡¨â 0 ãáâ ­®¢«¥­ = «¥¢ ï ª­®¯ª  ­ ¦ â 
127
  ¡¨â 1 ãáâ ­®¢«¥­ = ¯à ¢ ï ª­®¯ª  ­ ¦ â 
127
  ¡¨â 1 ãáâ ­®¢«¥­ = ¯à ¢ ï ª­®¯ª  ­ ¦ â 
128
  ¡¨â 2 ãáâ ­®¢«¥­ = á।­ïï ª­®¯ª  ­ ¦ â 
128
  ¡¨â 2 ãáâ ­®¢«¥­ = á।­ïï ª­®¯ª  ­ ¦ â 
129
  ¡¨â 3 ãáâ ­®¢«¥­ = 4-ï ª­®¯ª  ­ ¦ â 
129
  ¡¨â 3 ãáâ ­®¢«¥­ = 4-ï ª­®¯ª  ­ ¦ â 
130
  ¡¨â 4 ãáâ ­®¢«¥­ = 5-ï ª­®¯ª  ­ ¦ â }
130
  ¡¨â 4 ãáâ ­®¢«¥­ = 5-ï ª­®¯ª  ­ ¦ â }
131
asm
131
asm
132
  pushl %ebx
132
  pushl %ebx
133
  movl  $37, %eax
133
  movl  $37, %eax
134
  movl  $2, %ebx
134
  movl  $2, %ebx
135
  int   $0x40
135
  int   $0x40
136
  popl  %ebx
136
  popl  %ebx
137
end;
137
end;
138
 
138
 
139
procedure kos_maskevents(mask: DWord); assembler; register;
139
procedure kos_maskevents(mask: DWord); assembler; register;
140
asm
140
asm
141
  pushl %ebx
141
  pushl %ebx
142
  xchgl %eax, %ebx
142
  xchgl %eax, %ebx
143
  movl  $40, %eax
143
  movl  $40, %eax
144
  int   $0x40
144
  int   $0x40
145
  xchgl %eax, %ebx
145
  xchgl %eax, %ebx
146
  popl  %ebx
146
  popl  %ebx
147
end;
147
end;
-
 
148
 
-
 
149
procedure kos_setkeyboardmode(mode: DWord); assembler; register;
-
 
150
asm
-
 
151
  pushl %eax
-
 
152
  pushl %ebx
-
 
153
  movl  $66, %ecx
-
 
154
  movl  $1,  %ebx
-
 
155
  xchgl %eax, %ecx
-
 
156
  int   $0x40
-
 
157
  xchgl %eax, %ecx
-
 
158
  popl  %ebx
-
 
159
  popl  %eax
-
 
160
end;
-
 
161
 
-
 
162
function kos_getkeyboardmode(): DWord; assembler; register;
-
 
163
asm
-
 
164
  pushl %ebx
-
 
165
  movl  $66, %eax
-
 
166
  movl  $2,  %ebx
-
 
167
  int   $0x40
-
 
168
  popl  %ebx
-
 
169
end;
148
 
170
 
149
procedure kos_setcaption(caption: PChar); assembler; register;
171
procedure kos_setcaption(caption: PChar); assembler; register;
150
asm
172
asm
151
  pushl %ecx
173
  pushl %ecx
152
  pushl %ebx
174
  pushl %ebx
153
  xchgl %eax, %ecx
175
  xchgl %eax, %ecx
154
  movl $1, %ebx
176
  movl $1, %ebx
155
  movl $71, %eax
177
  movl $71, %eax
156
  int  $0x40
178
  int  $0x40
157
  xchgl %eax, %ecx
179
  xchgl %eax, %ecx
158
  popl %ebx
180
  popl %ebx
159
  popl %ecx
181
  popl %ecx
160
end;
182
end;
161
 
183
 
162
 
184
 
163
{ Graphics }
185
{ Graphics }
164
 
186
 
165
function kos_screensize(): TKosPoint; assembler; register;
187
function kos_screensize(): TKosPoint; assembler; register;
166
asm
188
asm
167
  pushl %eax
189
  pushl %eax
168
  pushl %ecx
190
  pushl %ecx
169
  pushl %eax
191
  pushl %eax
170
  movl  $14, %eax
192
  movl  $14, %eax
171
  int   $0x40
193
  int   $0x40
172
  movswl %ax, %ecx
194
  movswl %ax, %ecx
173
  popl  %ebx
195
  popl  %ebx
174
  shrl  $16, %eax
196
  shrl  $16, %eax
175
  movl  %ecx, TKosPoint.Y(%ebx)
197
  movl  %ecx, TKosPoint.Y(%ebx)
176
  movl  %eax, TKosPoint.X(%ebx)
198
  movl  %eax, TKosPoint.X(%ebx)
177
  popl  %ecx
199
  popl  %ecx
178
  popl  %eax
200
  popl  %eax
179
end;
201
end;
180
 
202
 
181
procedure kos_begindraw(); assembler; register;
203
procedure kos_begindraw(); assembler; register;
182
asm
204
asm
183
  pushl %ebx
205
  pushl %ebx
184
  movl  $12, %eax
206
  movl  $12, %eax
185
  movl  $1, %ebx
207
  movl  $1, %ebx
186
  int   $0x40
208
  int   $0x40
187
  popl  %ebx
209
  popl  %ebx
188
end;
210
end;
189
 
211
 
190
procedure kos_enddraw(); assembler; register;
212
procedure kos_enddraw(); assembler; register;
191
asm
213
asm
192
  pushl %ebx
214
  pushl %ebx
193
  movl  $12, %eax
215
  movl  $12, %eax
194
  movl  $2, %ebx
216
  movl  $2, %ebx
195
  int   $0x40
217
  int   $0x40
196
  popl  %ebx
218
  popl  %ebx
197
end;
219
end;
198
 
220
 
199
procedure kos_putpixel(x, y: Word; color: DWord); assembler; register;
221
procedure kos_putpixel(x, y: Word; color: DWord); assembler; register;
200
asm
222
asm
201
  pushl %ebx
223
  pushl %ebx
202
  movl  %eax, %ebx
224
  movl  %eax, %ebx
203
  xchgl %edx, %ecx
225
  xchgl %edx, %ecx
204
  movl  $1, %eax
226
  movl  $1, %eax
205
  int   $0x40
227
  int   $0x40
206
  xchgl %edx, %ecx
228
  xchgl %edx, %ecx
207
  popl  %ebx
229
  popl  %ebx
208
end;
230
end;
209
 
231
 
210
procedure kos_drawtext(x, y: Word; text: String; flags, bgcolor: DWord); assembler; register;
232
procedure kos_drawtext(x, y: Word; text: String; flags, bgcolor: DWord); assembler; register;
211
label nobg;
233
label nobg;
212
asm
234
asm
213
  pusha
235
  pusha
214
  shll  $16, %eax
236
  shll  $16, %eax
215
  pushl %ecx
237
  pushl %ecx
216
  movl  flags, %ecx  {ä« £¨, 梥â}
238
  movl  flags, %ecx  {ä« £¨, 梥â}
217
  movl  bgcolor, %edi
239
  movl  bgcolor, %edi
218
  movw  %dx, %ax
240
  movw  %dx, %ax
219
  andl   $0x7FFFFFFF, %ecx
241
  andl   $0x7FFFFFFF, %ecx
220
  btl   $31, %edi
242
  btl   $31, %edi
221
  jnc   nobg
243
  jnc   nobg
222
  orl   $0x40000000, %ecx
244
  orl   $0x40000000, %ecx
223
nobg:
245
nobg:
224
  popl  %edx
246
  popl  %edx
225
  movl  %eax, %ebx    {ª®®à¤¨­ âë}
247
  movl  %eax, %ebx    {ª®®à¤¨­ âë}
226
  movzbl (%edx), %esi {¤«¨­  áâப¨}
248
  movzbl (%edx), %esi {¤«¨­  áâப¨}
227
  movl  $4, %eax      {­®¬¥à ä㭪樨}
249
  movl  $4, %eax      {­®¬¥à ä㭪樨}
228
  incl  %edx          {㪠§ â¥«ì ­  áâபã}
250
  incl  %edx          {㪠§ â¥«ì ­  áâபã}
229
  andl  $0xFFFFFF, %edi
251
  andl  $0xFFFFFF, %edi
230
  int   $0x40
252
  int   $0x40
231
  popa
253
  popa
232
end;
254
end;
233
 
255
 
234
procedure kos_drawrect(x, y, w, h: Word; color: DWord); assembler; register;
256
procedure kos_drawrect(x, y, w, h: Word; color: DWord); assembler; register;
235
asm
257
asm
236
  pushl %eax
258
  pushl %eax
237
  pushl %ebx
259
  pushl %ebx
238
  pushl %ecx
260
  pushl %ecx
239
  pushl %edx
261
  pushl %edx
240
  movl  %eax, %ebx
262
  movl  %eax, %ebx
241
  xchgl %edx, %ecx
263
  xchgl %edx, %ecx
242
  shll  $16, %ebx
264
  shll  $16, %ebx
243
  shll  $16, %ecx
265
  shll  $16, %ecx
244
  movl  $13, %eax
266
  movl  $13, %eax
245
  movw  %dx, %bx
267
  movw  %dx, %bx
246
  movw  h, %cx
268
  movw  h, %cx
247
  movl  color, %edx
269
  movl  color, %edx
248
  int   $0x40
270
  int   $0x40
249
  popl %edx
271
  popl %edx
250
  popl %ecx
272
  popl %ecx
251
  popl %ebx
273
  popl %ebx
252
  popl %eax
274
  popl %eax
253
end;
275
end;
254
 
276
 
255
procedure kos_drawline(x1, y1, x2, y2: Word; color: DWord = $000000); assembler; register;
277
procedure kos_drawline(x1, y1, x2, y2: Word; color: DWord = $000000); assembler; register;
256
asm
278
asm
257
  pushl %eax
279
  pushl %eax
258
  pushl %ebx
280
  pushl %ebx
259
  pushl %ecx
281
  pushl %ecx
260
  pushl %edx
282
  pushl %edx
261
 
283
 
262
  xchgl %eax, %ecx
284
  xchgl %eax, %ecx
263
  xchgl %ecx, %edx
285
  xchgl %ecx, %edx
264
  movl  color, %ebx
286
  movl  color, %ebx
265
  {eax - x2, ebx - color, ecx - y1, edx - x1}
287
  {eax - x2, ebx - color, ecx - y1, edx - x1}
266
  shll  $16, %ecx
288
  shll  $16, %ecx
267
  shll  $16, %edx
289
  shll  $16, %edx
268
  movw  %ax, %dx
290
  movw  %ax, %dx
269
  movw  y2, %cx
291
  movw  y2, %cx
270
  movl  $38, %eax
292
  movl  $38, %eax
271
  xchgl %ebx, %edx
293
  xchgl %ebx, %edx
272
  int   $0x40
294
  int   $0x40
273
 
295
 
274
  popl  %edx
296
  popl  %edx
275
  popl  %ecx
297
  popl  %ecx
276
  popl  %ebx
298
  popl  %ebx
277
  popl  %eax
299
  popl  %eax
278
end;
300
end;
279
 
301
 
280
procedure kos_drawimage(x, y, w, h, depth: DWord; image: Pointer; palette: Pointer; xoffset: DWord); assembler; register;
302
procedure kos_drawimage(x, y, w, h, depth: DWord; image: Pointer; palette: Pointer; xoffset: DWord); assembler; register;
281
asm
303
asm
282
  pusha
304
  pusha
283
  shll  $16, %eax
305
  shll  $16, %eax
284
  shll  $16, %ecx
306
  shll  $16, %ecx
285
  orl   %eax, %edx
307
  orl   %eax, %edx
286
  orl   h, %ecx
308
  orl   h, %ecx
287
  movl  depth, %esi
309
  movl  depth, %esi
288
  movl  image, %ebx
310
  movl  image, %ebx
289
  movl  palette, %edi
311
  movl  palette, %edi
290
  movl  xoffset, %ebp
312
  movl  xoffset, %ebp
291
  movl  $65, %eax
313
  movl  $65, %eax
292
  int   $0x40
314
  int   $0x40
293
  popa
315
  popa
294
end;
316
end;
295
 
317
 
296
procedure kos_drawimage24(x, y, w, h: DWord; image: Pointer); assembler; register;
318
procedure kos_drawimage24(x, y, w, h: DWord; image: Pointer); assembler; register;
297
asm
319
asm
298
  pushl %eax
320
  pushl %eax
299
  pushl %ebx
321
  pushl %ebx
300
  pushl %ecx
322
  pushl %ecx
301
  pushl %edx
323
  pushl %edx
302
  shll  $16, %eax
324
  shll  $16, %eax
303
  shll  $16, %ecx
325
  shll  $16, %ecx
304
  orl   %eax, %edx
326
  orl   %eax, %edx
305
  orl   h, %ecx
327
  orl   h, %ecx
306
  movl  image, %ebx
328
  movl  image, %ebx
307
  movl  $7, %eax
329
  movl  $7, %eax
308
  int   $0x40
330
  int   $0x40
309
  popl  %edx
331
  popl  %edx
310
  popl  %ecx
332
  popl  %ecx
311
  popl  %ebx
333
  popl  %ebx
312
  popl  %eax
334
  popl  %eax
313
end;
335
end;
314
 
336
 
315
 
337
 
316
{ Work with system }
338
{ Work with system }
317
 
339
 
318
{ Work with system - System services }
340
{ Work with system - System services }
319
 
341
 
320
function kos_killthread(tid: TThreadID): Boolean; assembler; register;
342
function kos_killthread(tid: TThreadID): Boolean; assembler; register;
321
asm
343
asm
322
  pushl %ecx
344
  pushl %ecx
323
  pushl %ebx
345
  pushl %ebx
324
  movl  $18, %ecx
346
  movl  $18, %ecx
325
  movl  $18, %ebx
347
  movl  $18, %ebx
326
  xchgl %eax, %ecx
348
  xchgl %eax, %ecx
327
  int   $0x40
349
  int   $0x40
328
  andl  $1, %eax
350
  andl  $1, %eax
329
  popl  %ebx
351
  popl  %ebx
330
  popl  %ecx
352
  popl  %ecx
331
  xorb  $1, %al
353
  xorb  $1, %al
332
end;
354
end;
333
 
355
 
334
procedure kos_setactivewindow(slot: TThreadSlot); assembler; register;
356
procedure kos_setactivewindow(slot: TThreadSlot); assembler; register;
335
asm
357
asm
336
  pushl %ecx
358
  pushl %ecx
337
  pushl %ebx
359
  pushl %ebx
338
  movl  $18, %ecx
360
  movl  $18, %ecx
339
  movl  $3, %ebx
361
  movl  $3, %ebx
340
  xchgl %eax, %ecx
362
  xchgl %eax, %ecx
341
  int   $0x40
363
  int   $0x40
342
  xchgl %eax, %ecx
364
  xchgl %eax, %ecx
343
  popl  %ebx
365
  popl  %ebx
344
  popl  %ecx
366
  popl  %ecx
345
end;
367
end;
346
 
368
 
347
{$ifdef EMULATOR}
369
{$ifdef EMULATOR}
348
function kos_getthreadslot(tid: TThreadID): TThreadSlot;
370
function kos_getthreadslot(tid: TThreadID): TThreadSlot;
349
var
371
var
350
  ThreadInfo: TKosThreadInfo;
372
  ThreadInfo: TKosThreadInfo;
351
  HighThreadSlot: TThreadSlot;
373
  HighThreadSlot: TThreadSlot;
352
begin
374
begin
353
  Result := 0;
375
  Result := 0;
354
  repeat
376
  repeat
355
    Inc(Result);
377
    Inc(Result);
356
    HighThreadSlot := kos_threadinfo(@ThreadInfo, Result);
378
    HighThreadSlot := kos_threadinfo(@ThreadInfo, Result);
357
  until (Result > HighThreadSlot) or (ThreadInfo.ThreadID = tid);
379
  until (Result > HighThreadSlot) or (ThreadInfo.ThreadID = tid);
358
end;
380
end;
359
 
381
 
360
{$else}
382
{$else}
361
 
383
 
362
function kos_getthreadslot(tid: TThreadID): TThreadSlot; assembler; register;
384
function kos_getthreadslot(tid: TThreadID): TThreadSlot; assembler; register;
363
asm
385
asm
364
  pushl %ecx
386
  pushl %ecx
365
  pushl %ebx
387
  pushl %ebx
366
  movl  $18, %ecx
388
  movl  $18, %ecx
367
  movl  $21, %ebx
389
  movl  $21, %ebx
368
  xchgl %eax, %ecx
390
  xchgl %eax, %ecx
369
  int   $0x40
391
  int   $0x40
370
  popl  %ebx
392
  popl  %ebx
371
  popl  %ecx
393
  popl  %ecx
372
end;
394
end;
373
{$endif}
395
{$endif}
374
 
396
 
375
{ Work with system - Set system parameters }
397
{ Work with system - Set system parameters }
376
 
398
 
377
procedure kos_enablepci(); assembler; register;
399
procedure kos_enablepci(); assembler; register;
378
asm
400
asm
379
  pushl %eax
401
  pushl %eax
380
  pushl %ebx
402
  pushl %ebx
381
  pushl %ecx
403
  pushl %ecx
382
  movl  $21, %eax
404
  movl  $21, %eax
383
  movl  $12, %ebx
405
  movl  $12, %ebx
384
  movl  $1, %ecx
406
  movl  $1, %ecx
385
  int   $0x40
407
  int   $0x40
386
  popl  %ecx
408
  popl  %ecx
387
  popl  %ebx
409
  popl  %ebx
388
  popl  %eax
410
  popl  %eax
389
end;
411
end;
390
 
412
 
391
{ Work with system - Get system parameters }
413
{ Work with system - Get system parameters }
392
 
414
 
393
function kos_timecounter(): DWord; assembler; register;
415
function kos_timecounter(): DWord; assembler; register;
394
asm
416
asm
395
  pushl %ebx
417
  pushl %ebx
396
  movl  $26, %eax
418
  movl  $26, %eax
397
  movl  $9, %ebx
419
  movl  $9, %ebx
398
  int   $0x40
420
  int   $0x40
399
  popl  %ebx
421
  popl  %ebx
400
end;
422
end;
401
 
423
 
402
{ Work with system - Internal system services }
424
{ Work with system - Internal system services }
403
 
425
 
404
procedure kos_switchthread(); assembler; register;
426
procedure kos_switchthread(); assembler; register;
405
asm
427
asm
406
  pushl %eax
428
  pushl %eax
407
  pushl %ebx
429
  pushl %ebx
408
  movl  $68, %eax
430
  movl  $68, %eax
409
  movl  $1, %ebx
431
  movl  $1, %ebx
410
  int   $0x40
432
  int   $0x40
411
  popl  %ebx
433
  popl  %ebx
412
  popl  %eax
434
  popl  %eax
413
end;
435
end;
414
 
436
 
415
function kos_initheap(): DWord; assembler; register;
437
function kos_initheap(): DWord; assembler; register;
416
asm
438
asm
417
  pushl %ebx
439
  pushl %ebx
418
  movl  $68, %eax
440
  movl  $68, %eax
419
  movl  $11, %ebx
441
  movl  $11, %ebx
420
  int   $0x40
442
  int   $0x40
421
  popl  %ebx
443
  popl  %ebx
422
end;
444
end;
423
 
445
 
424
function kos_alloc(size: DWord): Pointer; assembler; register;
446
function kos_alloc(size: DWord): Pointer; assembler; register;
425
asm
447
asm
426
  pushl %ebx
448
  pushl %ebx
427
  pushl %ecx
449
  pushl %ecx
428
  movl  %eax, %ecx
450
  movl  %eax, %ecx
429
  movl  $68, %eax
451
  movl  $68, %eax
430
  movl  $12, %ebx
452
  movl  $12, %ebx
431
  int   $0x40
453
  int   $0x40
432
  popl  %ecx
454
  popl  %ecx
433
  popl  %ebx
455
  popl  %ebx
434
end;
456
end;
435
 
457
 
436
function kos_free(ptr: Pointer): Boolean; assembler; register;
458
function kos_free(ptr: Pointer): Boolean; assembler; register;
437
asm
459
asm
438
  pushl %ebx
460
  pushl %ebx
439
  pushl %ecx
461
  pushl %ecx
440
  movl  %eax, %ecx
462
  movl  %eax, %ecx
441
  movl  $68, %eax
463
  movl  $68, %eax
442
  movl  $13, %ebx
464
  movl  $13, %ebx
443
  int   $0x40
465
  int   $0x40
444
  popl  %ecx
466
  popl  %ecx
445
  popl  %ebx
467
  popl  %ebx
446
end;
468
end;
447
 
469
 
448
function kos_loaddriver(name: PChar): THandle; assembler; register;
470
function kos_loaddriver(name: PChar): THandle; assembler; register;
449
asm
471
asm
450
  pushl %ebx
472
  pushl %ebx
451
  pushl %ecx
473
  pushl %ecx
452
  movl  %eax, %ecx
474
  movl  %eax, %ecx
453
  movl  $68, %eax
475
  movl  $68, %eax
454
  movl  $16, %ebx
476
  movl  $16, %ebx
455
  int   $0x40
477
  int   $0x40
456
  popl  %ecx
478
  popl  %ecx
457
  popl  %ebx
479
  popl  %ebx
458
end;
480
end;
459
 
481
 
460
 
482
 
461
{ Processes and threads }
483
{ Processes and threads }
462
 
484
 
463
function kos_threadinfo(info: PKosThreadInfo; slot: TThreadSlot): DWord; assembler; register;
485
function kos_threadinfo(info: PKosThreadInfo; slot: TThreadSlot): DWord; assembler; register;
464
asm
486
asm
465
  pushl %ebx
487
  pushl %ebx
466
  movl  %eax, %ebx
488
  movl  %eax, %ebx
467
  xchgl %edx, %ecx
489
  xchgl %edx, %ecx
468
  movl  $9, %eax
490
  movl  $9, %eax
469
  int   $0x40
491
  int   $0x40
470
  xchgl %edx, %ecx
492
  xchgl %edx, %ecx
471
  popl  %ebx
493
  popl  %ebx
472
end;
494
end;
473
 
495
 
474
function kos_newthread(entry, stack: Pointer): TThreadID; assembler; register;
496
function kos_newthread(entry, stack: Pointer): TThreadID; assembler; register;
475
asm
497
asm
476
  pushl %ebx
498
  pushl %ebx
477
  pushl %ecx
499
  pushl %ecx
478
  movl  $1, %ebx
500
  movl  $1, %ebx
479
  movl  %eax, %ecx
501
  movl  %eax, %ecx
480
  movl  $51, %eax
502
  movl  $51, %eax
481
  int   $0x40
503
  int   $0x40
482
  popl  %ecx
504
  popl  %ecx
483
  popl  %ebx
505
  popl  %ebx
484
end;
506
end;
485
 
507
 
486
procedure kos_initipc(ipc: PKosIPC; size: DWord); assembler; register;
508
procedure kos_initipc(ipc: PKosIPC; size: DWord); assembler; register;
487
asm
509
asm
488
  pushl %ebx
510
  pushl %ebx
489
  pushl %ecx
511
  pushl %ecx
490
  movl  $60, %ecx
512
  movl  $60, %ecx
491
  movl  $1, %ebx
513
  movl  $1, %ebx
492
  xchgl %eax, %ecx
514
  xchgl %eax, %ecx
493
  int   $0x40
515
  int   $0x40
494
  popl  %ecx
516
  popl  %ecx
495
  popl  %ebx
517
  popl  %ebx
496
end;
518
end;
497
 
519
 
498
function kos_sendmsg(tid: TThreadID; msg: Pointer; size: DWord): DWord; assembler; register;
520
function kos_sendmsg(tid: TThreadID; msg: Pointer; size: DWord): DWord; assembler; register;
499
{@return:
521
{@return:
500
  0 - ãᯥ譮
522
  0 - ãᯥ譮
501
  1 - ¯à¨ñ¬­¨ª ­¥ ®¯à¥¤¥«¨« ¡ãä¥à ¤«ï IPC-á®®¡é¥­¨©
523
  1 - ¯à¨ñ¬­¨ª ­¥ ®¯à¥¤¥«¨« ¡ãä¥à ¤«ï IPC-á®®¡é¥­¨©
502
      (¬®¦¥â ¡ëâì, ¥éñ ­¥ ãᯥ«,   ¬®¦¥â ¡ëâì, íâ® ­¥ â®â ¯®â®ª, ª®â®àë© ­ã¦¥­)
524
      (¬®¦¥â ¡ëâì, ¥éñ ­¥ ãᯥ«,   ¬®¦¥â ¡ëâì, íâ® ­¥ â®â ¯®â®ª, ª®â®àë© ­ã¦¥­)
503
  2 - ¯à¨ñ¬­¨ª § ¡«®ª¨à®¢ « IPC-¡ãä¥à; ¯®¯à®¡ã©â¥ ­¥¬­®£® ¯®¤®¦¤ âì
525
  2 - ¯à¨ñ¬­¨ª § ¡«®ª¨à®¢ « IPC-¡ãä¥à; ¯®¯à®¡ã©â¥ ­¥¬­®£® ¯®¤®¦¤ âì
504
  3 - ¯¥à¥¯®«­¥­¨¥ IPC-¡ãä¥à  ¯à¨ñ¬­¨ª 
526
  3 - ¯¥à¥¯®«­¥­¨¥ IPC-¡ãä¥à  ¯à¨ñ¬­¨ª 
505
  4 - ¯à®æ¥áá /¯®â®ª  á â ª¨¬ PID ­¥ áãé¥áâ¢ã¥â}
527
  4 - ¯à®æ¥áá /¯®â®ª  á â ª¨¬ PID ­¥ áãé¥áâ¢ã¥â}
506
asm
528
asm
507
  pushl %esi
529
  pushl %esi
508
  pushl %ebx
530
  pushl %ebx
509
  movl  $60, %esi
531
  movl  $60, %esi
510
  movl  $2, %ebx
532
  movl  $2, %ebx
511
  xchgl %ecx, %esi
533
  xchgl %ecx, %esi
512
  xchgl %eax, %ecx
534
  xchgl %eax, %ecx
513
  int   $0x40
535
  int   $0x40
514
  xchgl %ecx, %esi
536
  xchgl %ecx, %esi
515
  popl  %ebx
537
  popl  %ebx
516
  popl  %esi
538
  popl  %esi
517
end;
539
end;
518
 
540
 
519
function kos_resizemem(size: DWord): Boolean; assembler; register;
541
function kos_resizemem(size: DWord): Boolean; assembler; register;
520
asm
542
asm
521
  pushl %ebx
543
  pushl %ebx
522
  pushl %ecx
544
  pushl %ecx
523
  movl  %eax, %ecx
545
  movl  %eax, %ecx
524
  movl  $64, %eax
546
  movl  $64, %eax
525
  movl  $1, %ebx
547
  movl  $1, %ebx
526
  int   $0x40
548
  int   $0x40
527
  xorb  $1, %al
549
  xorb  $1, %al
528
  popl  %ecx
550
  popl  %ecx
529
  popl  %ebx
551
  popl  %ebx
530
end;
552
end;
531
 
553
 
532
 
554
 
533
{ File system }
555
{ File system }
534
{ File system - Work with the current folder }
556
{ File system - Work with the current folder }
535
 
557
 
536
procedure kos_setdir(path: PChar); assembler; register;
558
procedure kos_setdir(path: PChar); assembler; register;
537
asm
559
asm
538
  pushl %ecx
560
  pushl %ecx
539
  pushl %ebx
561
  pushl %ebx
540
  movl  $30, %ecx
562
  movl  $30, %ecx
541
  movl  $1, %ebx
563
  movl  $1, %ebx
542
  xchgl %eax, %ecx
564
  xchgl %eax, %ecx
543
  int   $0x40
565
  int   $0x40
544
  popl  %ebx
566
  popl  %ebx
545
  popl  %ecx
567
  popl  %ecx
546
end;
568
end;
547
 
569
 
548
function kos_getdir(path: PChar; size: DWord): DWord; assembler; register;
570
function kos_getdir(path: PChar; size: DWord): DWord; assembler; register;
549
asm
571
asm
550
  pushl %ecx
572
  pushl %ecx
551
  pushl %ebx
573
  pushl %ebx
552
  movl  $30, %ecx
574
  movl  $30, %ecx
553
  movl  $2, %ebx
575
  movl  $2, %ebx
554
  xchgl %eax, %ecx
576
  xchgl %eax, %ecx
555
  int   $0x40
577
  int   $0x40
556
  popl  %ebx
578
  popl  %ebx
557
  popl  %ecx
579
  popl  %ecx
558
end;
580
end;
559
 
581
 
560
{ File system - Work with file system with long names support }
582
{ File system - Work with file system with long names support }
561
 
583
 
562
function kos_readfile(kosfile: PKosFile; var readed: Longint): DWord; assembler; register;
584
function kos_readfile(kosfile: PKosFile; var readed: Longint): DWord; assembler; register;
563
asm
585
asm
564
  pushl %ebx
586
  pushl %ebx
565
  movl  $70, %ebx
587
  movl  $70, %ebx
566
  xchgl %eax, %ebx
588
  xchgl %eax, %ebx
567
  movl  $0, (%ebx)
589
  movl  $0, (%ebx)
568
  int   $0x40
590
  int   $0x40
569
  movl  %ebx, (%edx)
591
  movl  %ebx, (%edx)
570
  popl  %ebx
592
  popl  %ebx
571
end;
593
end;
572
 
594
 
573
function kos_rewritefile(kosfile: PKosFile; var writed: Longint): DWord; assembler; register;
595
function kos_rewritefile(kosfile: PKosFile; var writed: Longint): DWord; assembler; register;
574
asm
596
asm
575
  pushl %ebx
597
  pushl %ebx
576
  movl  $70, %ebx
598
  movl  $70, %ebx
577
  xchgl %eax, %ebx
599
  xchgl %eax, %ebx
578
  movl  $2, (%ebx)
600
  movl  $2, (%ebx)
579
  int   $0x40
601
  int   $0x40
580
  movl  %ebx, (%edx)
602
  movl  %ebx, (%edx)
581
  popl  %ebx
603
  popl  %ebx
582
end;
604
end;
583
 
605
 
584
function kos_writefile(kosfile: PKosFile; var writed: Longint): DWord; assembler; register;
606
function kos_writefile(kosfile: PKosFile; var writed: Longint): DWord; assembler; register;
585
asm
607
asm
586
  pushl %ebx
608
  pushl %ebx
587
  movl  $70, %ebx
609
  movl  $70, %ebx
588
  xchgl %eax, %ebx
610
  xchgl %eax, %ebx
589
  movl  $3, (%ebx)
611
  movl  $3, (%ebx)
590
  int   $0x40
612
  int   $0x40
591
  movl  %ebx, (%edx)
613
  movl  %ebx, (%edx)
592
  popl  %ebx
614
  popl  %ebx
593
end;
615
end;
594
 
616
 
595
function kos_fileinfo(kosfile: PKosFile): DWord; assembler; register;
617
function kos_fileinfo(kosfile: PKosFile): DWord; assembler; register;
596
asm
618
asm
597
  pushl %ebx
619
  pushl %ebx
598
  movl  $70, %ebx
620
  movl  $70, %ebx
599
  xchgl %eax, %ebx
621
  xchgl %eax, %ebx
600
  movl  $5, (%ebx)
622
  movl  $5, (%ebx)
601
  int   $0x40
623
  int   $0x40
602
  popl  %ebx
624
  popl  %ebx
603
end;
625
end;
604
 
626
 
605
 
627
 
606
{ Sound }
628
{ Sound }
607
 
629
 
608
function kos_speaker(notes: Pointer): Boolean; assembler; register;
630
function kos_speaker(notes: Pointer): Boolean; assembler; register;
609
asm
631
asm
610
  pushl %esi
632
  pushl %esi
611
  pushl %ebx
633
  pushl %ebx
612
  movl  $55, %esi
634
  movl  $55, %esi
613
  movl  %esi, %ebx
635
  movl  %esi, %ebx
614
  xchgl %eax, %esi
636
  xchgl %eax, %esi
615
  int   $0x40
637
  int   $0x40
616
  {eax = 55 - ®è¨¡ª }
638
  {eax = 55 - ®è¨¡ª }
617
  andl  $1, %eax
639
  andl  $1, %eax
618
  popl  %ebx
640
  popl  %ebx
619
  popl  %esi
641
  popl  %esi
620
  xorb  $1, %al
642
  xorb  $1, %al
621
end;
643
end;
622
 
644
 
623
 
645
 
624
{ Work with hardware }
646
{ Work with hardware }
625
 
647
 
626
function kos_readport(index: DWord): DWord; assembler; register;
648
function kos_readport(index: DWord): DWord; assembler; register;
627
label ok, exit;
649
label ok, exit;
628
asm
650
asm
629
  pushl %ecx
651
  pushl %ecx
630
  pushl %ebx
652
  pushl %ebx
631
  xchgl %eax, %ecx         {index}
653
  xchgl %eax, %ecx         {index}
632
  movl  $43, %eax
654
  movl  $43, %eax
633
  orl   $0x80000000, %ecx  {index}
655
  orl   $0x80000000, %ecx  {index}
634
  int   $0x40
656
  int   $0x40
635
  orl   %eax, %eax
657
  orl   %eax, %eax
636
  jzl   ok
658
  jzl   ok
637
  movl  $-1, %eax
659
  movl  $-1, %eax
638
  jmp   exit
660
  jmp   exit
639
ok:
661
ok:
640
  movl  %ebx, %eax
662
  movl  %ebx, %eax
641
exit:
663
exit:
642
  popl  %ebx
664
  popl  %ebx
643
  popl  %ecx
665
  popl  %ecx
644
end;
666
end;
645
 
667
 
646
procedure kos_writeport(index, value: DWord); assembler; register;
668
procedure kos_writeport(index, value: DWord); assembler; register;
647
asm
669
asm
648
  pushl %eax
670
  pushl %eax
649
  pushl %ebx
671
  pushl %ebx
650
  pushl %ecx
672
  pushl %ecx
651
  xchgl %edx, %ebx  {value}
673
  xchgl %edx, %ebx  {value}
652
  xchgl %eax, %ecx  {index}
674
  xchgl %eax, %ecx  {index}
653
  movl  $43, %eax
675
  movl  $43, %eax
654
  int   $0x40
676
  int   $0x40
655
  xchgl %edx, %ebx
677
  xchgl %edx, %ebx
656
  popl  %ecx
678
  popl  %ecx
657
  popl  %ebx
679
  popl  %ebx
658
  popl  %eax
680
  popl  %eax
659
end;
681
end;
660
 
682
 
661
function kos_reserveport(port: DWord): Boolean; assembler; register;
683
function kos_reserveport(port: DWord): Boolean; assembler; register;
662
asm
684
asm
663
  pushl %ebx
685
  pushl %ebx
664
  pushl %ecx
686
  pushl %ecx
665
  pushl %edx
687
  pushl %edx
666
  movl  %eax, %ecx  {port}
688
  movl  %eax, %ecx  {port}
667
  movl  $46, %eax
689
  movl  $46, %eax
668
  movl  %ecx, %edx  {port}
690
  movl  %ecx, %edx  {port}
669
  xorl  %ebx, %ebx
691
  xorl  %ebx, %ebx
670
  int   $0x40
692
  int   $0x40
671
  xorb  $1, %al
693
  xorb  $1, %al
672
  popl  %edx
694
  popl  %edx
673
  popl  %ecx
695
  popl  %ecx
674
  popl  %ebx
696
  popl  %ebx
675
end;
697
end;
676
 
698
 
677
{ Work with hardware - Low-level access to PCI}
699
{ Work with hardware - Low-level access to PCI}
678
 
700
 
679
function kos_lastpcibus(): Byte; assembler; register;
701
function kos_lastpcibus(): Byte; assembler; register;
680
asm
702
asm
681
  pushl %ebx
703
  pushl %ebx
682
  movl  $62, %eax
704
  movl  $62, %eax
683
  movl  $1, %ebx
705
  movl  $1, %ebx
684
  int   $0x40
706
  int   $0x40
685
  popl  %ebx
707
  popl  %ebx
686
end;
708
end;
687
 
709
 
688
function kos_readpcib(bus, dev, func, reg: Byte): Byte; assembler; register;
710
function kos_readpcib(bus, dev, func, reg: Byte): Byte; assembler; register;
689
asm
711
asm
690
  pushl %ebx
712
  pushl %ebx
691
  pushl %ecx
713
  pushl %ecx
692
  pushl %edx
714
  pushl %edx
693
  shlb  $3, %dl   {dev}
715
  shlb  $3, %dl   {dev}
694
  movb  %al, %bh  {bus}
716
  movb  %al, %bh  {bus}
695
  shlw  $8, %cx   {func}
717
  shlw  $8, %cx   {func}
696
  movb  $4, %bl
718
  movb  $4, %bl
697
  movb  reg, %cl  {func}
719
  movb  reg, %cl  {func}
698
  andb  $7, %ch   {func}
720
  andb  $7, %ch   {func}
699
  movl  $62, %eax
721
  movl  $62, %eax
700
  orb   %dl, %ch  {dev/func}
722
  orb   %dl, %ch  {dev/func}
701
  int   $0x40
723
  int   $0x40
702
  popl  %edx
724
  popl  %edx
703
  popl  %ecx
725
  popl  %ecx
704
  popl  %ebx
726
  popl  %ebx
705
end;
727
end;
706
 
728
 
707
function kos_readpciw(bus, dev, func, reg: Byte): Word; assembler; register;
729
function kos_readpciw(bus, dev, func, reg: Byte): Word; assembler; register;
708
asm
730
asm
709
  pushl %ebx
731
  pushl %ebx
710
  pushl %ecx
732
  pushl %ecx
711
  pushl %edx
733
  pushl %edx
712
  shlb  $3, %dl   {dev}
734
  shlb  $3, %dl   {dev}
713
  movb  %al, %bh  {bus}
735
  movb  %al, %bh  {bus}
714
  shlw  $8, %cx   {func}
736
  shlw  $8, %cx   {func}
715
  movb  $5, %bl
737
  movb  $5, %bl
716
  movb  reg, %cl  {reg}
738
  movb  reg, %cl  {reg}
717
  andb  $7, %ch   {func}
739
  andb  $7, %ch   {func}
718
  movl  $62, %eax
740
  movl  $62, %eax
719
  orb   %dl, %ch  {dev/func}
741
  orb   %dl, %ch  {dev/func}
720
  int   $0x40
742
  int   $0x40
721
  popl  %edx
743
  popl  %edx
722
  popl  %ecx
744
  popl  %ecx
723
  popl  %ebx
745
  popl  %ebx
724
end;
746
end;
725
 
747
 
726
function kos_readpcid(bus, dev, func, reg: Byte): DWord; assembler; register;
748
function kos_readpcid(bus, dev, func, reg: Byte): DWord; assembler; register;
727
asm
749
asm
728
  pushl %ebx
750
  pushl %ebx
729
  pushl %ecx
751
  pushl %ecx
730
  pushl %edx
752
  pushl %edx
731
  shlb  $3, %dl   {dev}
753
  shlb  $3, %dl   {dev}
732
  movb  %al, %bh  {bus}
754
  movb  %al, %bh  {bus}
733
  shlw  $8, %cx   {func}
755
  shlw  $8, %cx   {func}
734
  movb  $6, %bl
756
  movb  $6, %bl
735
  movb  reg, %cl  {reg}
757
  movb  reg, %cl  {reg}
736
  andb  $7, %ch   {func}
758
  andb  $7, %ch   {func}
737
  movl  $62, %eax
759
  movl  $62, %eax
738
  orb   %dl, %ch  {dev/func}
760
  orb   %dl, %ch  {dev/func}
739
  int   $0x40
761
  int   $0x40
740
  popl  %edx
762
  popl  %edx
741
  popl  %ecx
763
  popl  %ecx
742
  popl  %ebx
764
  popl  %ebx
743
end;
765
end;
744
 
766
 
745
 
767
 
746
{ Other }
768
{ Other }
747
procedure kos_delay(ms: DWord); assembler; register;
769
procedure kos_delay(ms: DWord); assembler; register;
748
asm
770
asm
749
  pushl %ebx
771
  pushl %ebx
750
  movl  %eax, %ebx
772
  movl  %eax, %ebx
751
  movl  $5, %eax
773
  movl  $5, %eax
752
  int   $0x40
774
  int   $0x40
753
  popl  %ebx
775
  popl  %ebx
754
end;
776
end;