Subversion Repositories Kolibri OS

Rev

Rev 763 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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