Rev 3692 | Rev 3886 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
836 | diamond | 1 | ; Функции работы с консолью для программ КолибриОС |
852 | diamond | 2 | ; diamond, 2006-2008 |
836 | diamond | 3 | |
4 | |||
5 | format MS COFF |
||
6 | |||
7 | public EXPORTS |
||
8 | |||
9 | section '.flat' code readable align 16 |
||
10 | |||
11 | include 'font.inc' |
||
12 | include 'conscrl.inc' |
||
13 | |||
14 | ;void __stdcall START(dword state); |
||
15 | START: |
||
16 | ; N.B. The current kernel implementation does not require |
||
17 | ; evident heap initialization, because if DLL is loaded, heap is already initialized |
||
18 | ; (if heap was not initialized, loader does this implicitly). |
||
19 | ; So this action does nothing useful, but nothing harmful. |
||
20 | push 68 |
||
21 | pop eax |
||
22 | push 11 |
||
23 | pop ebx |
||
24 | int 0x40 |
||
25 | or eax, -1 |
||
26 | ret 4 |
||
27 | |||
28 | ; Инициализация консоли |
||
29 | ; void __stdcall con_init(dword wnd_width, dword wnd_height, |
||
30 | ; dword scr_width, dword scr_height, const char* title); |
||
31 | |||
32 | align 4 |
||
33 | con_init: |
||
34 | pop eax |
||
35 | pop [con.wnd_width] |
||
36 | pop [con.wnd_height] |
||
37 | pop [con.scr_width] |
||
38 | pop [con.scr_height] |
||
39 | pop [con.title] |
||
40 | push eax |
||
2170 | serge | 41 | |
42 | push ebx |
||
43 | |||
836 | diamond | 44 | mov ecx, 4 |
45 | mov eax, con.wnd_width |
||
2170 | serge | 46 | mov edx, con.def_wnd_width |
836 | diamond | 47 | .1: |
48 | cmp dword [eax], -1 |
||
49 | jnz @f |
||
2170 | serge | 50 | mov ebx, [edx] |
836 | diamond | 51 | mov [eax], ebx |
52 | @@: |
||
53 | add eax, 4 |
||
2170 | serge | 54 | add edx, 4 |
836 | diamond | 55 | loop .1 |
56 | ; allocate memory for console data & bitmap data |
||
57 | mov eax, [con.scr_width] |
||
58 | mul [con.scr_height] |
||
59 | lea ecx, [eax+eax] |
||
60 | mov eax, [con.wnd_width] |
||
61 | mul [con.wnd_height] |
||
62 | imul eax, font_width*font_height |
||
63 | mov ebx, eax |
||
64 | push ebx ecx |
||
65 | add ecx, eax |
||
66 | push 68 |
||
67 | pop eax |
||
68 | push 12 |
||
69 | pop ebx |
||
70 | int 0x40 |
||
71 | pop ecx ebx |
||
72 | mov edx, con.nomem_err |
||
73 | test eax, eax |
||
74 | jz con.fatal |
||
75 | mov [con.data], eax |
||
76 | push edi |
||
77 | mov edi, eax |
||
78 | shr ecx, 1 |
||
79 | mov ax, 0x0720 |
||
80 | rep stosw |
||
81 | mov ecx, ebx |
||
82 | mov [con.image], edi |
||
83 | xor eax, eax |
||
84 | rep stosb |
||
85 | pop edi |
||
1133 | diamond | 86 | and byte [con_flags+1], not 2 |
836 | diamond | 87 | ; create console thread |
88 | push 51 |
||
89 | pop eax |
||
90 | xor ebx, ebx |
||
91 | inc ebx |
||
92 | mov ecx, con.thread |
||
93 | mov edx, con.stack_top |
||
94 | int 0x40 |
||
95 | mov edx, con.thread_err |
||
96 | test eax, eax |
||
97 | js con.fatal |
||
98 | mov [con.console_tid], eax |
||
99 | pop ebx |
||
100 | ret |
||
101 | con.fatal: |
||
102 | ; output string to debug board and die |
||
103 | mov cl, [edx] |
||
104 | test cl, cl |
||
105 | jz @f |
||
106 | push 63 |
||
107 | pop eax |
||
108 | xor ebx, ebx |
||
109 | inc ebx |
||
110 | int 0x40 |
||
111 | inc edx |
||
112 | jmp con.fatal |
||
113 | @@: |
||
114 | or eax, -1 |
||
115 | int 0x40 |
||
116 | |||
117 | ; dword __stdcall con_get_flags(void); |
||
118 | con_get_flags: |
||
119 | mov eax, [con_flags] |
||
120 | ret |
||
121 | |||
122 | ; dword __stdcall con_set_flags(dword flags); |
||
123 | con_set_flags: |
||
124 | mov eax, [esp+4] |
||
1133 | diamond | 125 | and ah, not 2 |
836 | diamond | 126 | xchg eax, [con_flags] |
127 | ret 4 |
||
128 | |||
129 | ; dword __stdcall con_get_font_height(void); |
||
130 | con_get_font_height: |
||
131 | mov eax, font_height |
||
132 | ret |
||
133 | |||
134 | ; int __stdcall con_get_cursor_height(void); |
||
135 | con_get_cursor_height: |
||
136 | mov eax, [con.cursor_height] |
||
137 | ret |
||
138 | |||
139 | ; int __stdcall con_set_cursor_height(int new_height); |
||
140 | con_set_cursor_height: |
||
141 | mov eax, [esp+4] |
||
142 | cmp eax, font_height |
||
143 | jae @f |
||
144 | xchg eax, [con.cursor_height] |
||
145 | ret 4 |
||
146 | @@: |
||
147 | mov eax, [con.cursor_height] |
||
148 | ret 4 |
||
149 | |||
150 | ; void __stdcall con_write_asciiz(const char* string); |
||
151 | con_write_asciiz: |
||
152 | push ebx esi |
||
153 | or ebx, -1 |
||
154 | mov esi, [esp+12] |
||
155 | call con.write |
||
156 | pop esi ebx |
||
157 | ret 4 |
||
158 | |||
159 | ; void __stdcall con_write_string(const char* string, dword length); |
||
160 | con_write_length: |
||
161 | push ebx esi |
||
162 | mov esi, [esp+12] |
||
163 | mov ebx, [esp+16] |
||
164 | call con.write |
||
165 | pop esi ebx |
||
166 | ret 8 |
||
167 | |||
168 | ; Каждый символ классифицируется как один из |
||
169 | con.printfc.normal = 0 ; нормальный символ |
||
170 | con.printfc.percent = 1 ; '%' |
||
171 | con.printfc.dot = 2 ; '.' |
||
172 | con.printfc.asterisk = 3 ; '*' |
||
173 | con.printfc.zero = 4 ; '0' |
||
174 | con.printfc.digit = 5 ; ненулевая цифра |
||
175 | con.printfc.plus = 6 ; '+' |
||
176 | con.printfc.minus = 7 ; '-' |
||
177 | con.printfc.sharp = 8 ; '#' |
||
178 | con.printfc.space = 9 ; ' ' |
||
179 | con.printfc.long = 10 ; 'l' for 'long' |
||
180 | con.printfc.short = 11 ; 'h' for 'short' |
||
181 | con.printfc.dec = 12 ; 'd' = print decimal |
||
182 | con.printfc.oct = 13 ; 'o' = print octal |
||
183 | con.printfc.unsigned = 14 ; 'u' = print unsigned decimal |
||
184 | con.printfc.hex = 15 ; 'x' = print hexadecimal |
||
185 | con.printfc.pointer = 16 ; 'p' = print pointer |
||
186 | con.printfc.char = 17 ; 'c' = print char |
||
187 | con.printfc.string = 18 ; 's' = print string |
||
188 | |||
189 | macro set char,type |
||
190 | {store byte con.printfc.#type at con.charcodes + char - ' '} |
||
191 | |||
192 | con.charcodes: |
||
193 | times 'x'-' '+1 db con.printfc.normal |
||
194 | set '%', percent |
||
195 | set '.', dot |
||
196 | set '*', asterisk |
||
197 | set '0', zero |
||
198 | set '1', digit |
||
199 | set '2', digit |
||
200 | set '3', digit |
||
201 | set '4', digit |
||
202 | set '5', digit |
||
203 | set '6', digit |
||
204 | set '7', digit |
||
205 | set '8', digit |
||
206 | set '9', digit |
||
207 | set ' ', space |
||
208 | set '#', sharp |
||
209 | set '+', plus |
||
210 | set '-', minus |
||
211 | set 'X', hex |
||
212 | set 'x', hex |
||
213 | set 'c', char |
||
214 | set 'd', dec |
||
215 | set 'h', short |
||
216 | set 'i', dec |
||
217 | set 'l', long |
||
218 | set 'o', oct |
||
219 | set 'p', pointer |
||
220 | set 's', string |
||
221 | set 'u', unsigned |
||
222 | purge set |
||
223 | align 4 |
||
3690 | hidnplayr | 224 | con.charjump: |
225 | dd con_printf.normal |
||
836 | diamond | 226 | dd con_printf.percent |
227 | dd con_printf.dot |
||
228 | dd con_printf.asterisk |
||
229 | dd con_printf.zero |
||
230 | dd con_printf.digit |
||
231 | dd con_printf.plus |
||
232 | dd con_printf.minus |
||
233 | dd con_printf.sharp |
||
234 | dd con_printf.space |
||
235 | dd con_printf.long |
||
236 | dd con_printf.short |
||
237 | dd con_printf.dec |
||
238 | dd con_printf.oct |
||
239 | dd con_printf.unsigned |
||
240 | dd con_printf.hex |
||
241 | dd con_printf.pointer |
||
242 | dd con_printf.char |
||
243 | dd con_printf.string |
||
244 | |||
245 | ; int __cdecl con_printf(const char* format, ...) |
||
246 | con_printf: |
||
247 | xor eax, eax |
||
248 | pushad |
||
249 | call con.get_data_ptr |
||
250 | lea ebp, [esp+20h+8] |
||
251 | mov esi, [ebp-4] |
||
252 | sub esp, 64 ; reserve space for buffer |
||
253 | .loop: |
||
254 | xor eax, eax |
||
255 | lodsb |
||
256 | test al, al |
||
257 | jz .done |
||
258 | cmp al, '%' |
||
259 | jz .spec_begin |
||
260 | .normal: |
||
261 | call con.write_char_ex |
||
262 | inc dword [esp+64+28] |
||
263 | jmp .loop |
||
264 | .errspec: |
||
265 | .percent: |
||
266 | add esp, 12 |
||
267 | jmp .normal |
||
268 | .spec_begin: |
||
269 | xor ebx, ebx |
||
270 | ; bl = тип позиции: |
||
271 | ; 0 = начало |
||
272 | ; 1 = прочитан ведущий 0 в спецификации формата |
||
273 | ; 2 = читаем поле ширины |
||
274 | ; 3 = читаем поле точности |
||
275 | ; 4 = прочитано поле размера аргумента |
||
276 | ; 5 = читаем поле типа |
||
277 | ; bh = флаги: |
||
278 | ; 1 = флаг '#', выводить 0/0x/0X |
||
279 | ; 2 = флаг '-', выравнивание влево |
||
280 | ; 4 = флаг '0', дополнение нулями |
||
281 | ; 8 = флаг 'h', короткий аргумент |
||
282 | push -1 |
||
283 | ; dword [esp+8] = precision |
||
284 | push -1 |
||
285 | ; dword [esp+4] = width |
||
286 | push 0 |
||
287 | ; byte [esp] = флаг 0/'+'/' ' |
||
288 | .spec: |
||
289 | xor eax, eax |
||
290 | lodsb |
||
291 | test al, al |
||
292 | jz .done |
||
293 | cmp al, ' ' |
||
294 | jb .normal |
||
295 | cmp al, 'x' |
||
296 | ja .normal |
||
297 | movzx ecx, byte [con.charcodes + eax - ' '] |
||
3690 | hidnplayr | 298 | jmp dword[con.charjump + ecx*4] |
836 | diamond | 299 | |
300 | .sharp: |
||
301 | test bl, bl |
||
302 | jnz .errspec |
||
303 | or bh, 1 |
||
304 | jmp .spec |
||
305 | .minus: |
||
306 | test bl, bl |
||
307 | jnz .errspec |
||
308 | or bh, 2 |
||
309 | jmp .spec |
||
310 | .plus: |
||
311 | .space: |
||
312 | test bl, bl |
||
313 | jnz .errspec |
||
314 | cmp byte [esp], '+' |
||
315 | jz .spec |
||
316 | mov byte [esp], al |
||
317 | jmp .spec |
||
318 | .zero: |
||
319 | test bl, bl |
||
320 | jnz .digit |
||
321 | test bh, 2 |
||
322 | jnz .spec |
||
323 | or bh, 4 |
||
324 | inc ebx |
||
325 | jmp .spec |
||
326 | .digit: |
||
327 | sub al, '0' |
||
328 | cmp bl, 2 |
||
329 | ja .precision |
||
330 | mov bl, 2 |
||
331 | xchg eax, [esp+4] |
||
332 | test eax, eax |
||
333 | js .spec |
||
334 | lea eax, [eax*5] |
||
335 | add eax, eax |
||
336 | add [esp+4], eax |
||
337 | jmp .spec |
||
338 | .precision: |
||
339 | cmp bl, 3 |
||
340 | jnz .errspec |
||
341 | xchg eax, [esp+8] |
||
342 | lea eax, [eax*5] |
||
343 | add eax, eax |
||
344 | add [esp+8], eax |
||
345 | jmp .spec |
||
346 | .asterisk: |
||
347 | mov eax, [ebp] |
||
348 | add ebp, 4 |
||
349 | cmp bl, 2 |
||
350 | ja .asterisk_precision |
||
351 | test eax, eax |
||
352 | jns @f |
||
353 | neg eax |
||
354 | or bh, 2 |
||
355 | @@: |
||
356 | mov [esp+4], eax |
||
357 | mov bl, 3 |
||
358 | jmp .spec |
||
359 | .asterisk_precision: |
||
360 | cmp bl, 3 |
||
361 | jnz .errspec |
||
362 | mov [esp+8], eax |
||
363 | inc ebx |
||
364 | jmp .spec |
||
365 | .dot: |
||
366 | cmp bl, 2 |
||
367 | ja .errspec |
||
368 | mov bl, 3 |
||
369 | and dword [esp+8], 0 |
||
370 | jmp .spec |
||
371 | .long: |
||
372 | cmp bl, 3 |
||
373 | ja .errspec |
||
374 | mov bl, 4 |
||
375 | jmp .spec |
||
376 | .short: |
||
377 | cmp bl, 3 |
||
378 | ja .errspec |
||
379 | mov bl, 4 |
||
380 | or bh, 8 |
||
381 | jmp .spec |
||
382 | .unsigned: |
||
383 | .dec: |
||
384 | push 10 |
||
385 | jmp .write_number |
||
386 | .pointer: |
||
387 | mov dword [esp+12], 8 |
||
388 | or bh, 4 |
||
389 | and bh, not 8 |
||
390 | .hex: |
||
391 | push 16 |
||
392 | jmp @f |
||
393 | .oct: |
||
394 | push 8 |
||
395 | @@: |
||
396 | mov byte [esp+4], 0 |
||
397 | .write_number: |
||
398 | pop ecx |
||
399 | push edi |
||
400 | lea edi, [esp+16+64-1] ; edi -> end of buffer |
||
401 | mov byte [edi], 0 |
||
402 | push edx |
||
403 | push eax |
||
404 | mov eax, [ebp] |
||
405 | add ebp, 4 |
||
406 | test bh, 8 |
||
407 | jz @f |
||
408 | movzx eax, ax |
||
409 | cmp byte [esp], 'd' |
||
410 | jnz @f |
||
411 | movsx eax, ax |
||
412 | @@: |
||
413 | xor edx, edx |
||
414 | test eax, eax |
||
415 | jns @f |
||
416 | cmp byte [esp], 'd' |
||
417 | jnz @f |
||
418 | inc edx |
||
419 | neg eax |
||
420 | @@: |
||
421 | push edx |
||
422 | xor edx, edx |
||
423 | ; число в eax, основание системы счисления в ecx |
||
424 | @@: |
||
425 | cmp dword [esp+16+8], 0 |
||
426 | jnz .print_num |
||
427 | test eax, eax |
||
428 | jz .zeronum |
||
429 | .print_num: |
||
430 | div ecx |
||
431 | xchg eax, edx |
||
432 | cmp al, 10 |
||
433 | sbb al, 69h |
||
434 | das |
||
435 | cmp byte [esp+4], 'x' |
||
436 | jnz @f |
||
437 | or al, 20h |
||
438 | @@: |
||
439 | dec edi |
||
440 | mov [edi], al |
||
441 | xor eax, eax |
||
442 | xchg eax, edx |
||
443 | test eax, eax |
||
444 | jnz .print_num |
||
445 | .zeronum: |
||
446 | push 0 |
||
447 | mov edx, [esp+12] |
||
448 | lea eax, [esp+32+64-1] |
||
449 | sub eax, edi |
||
450 | cmp dword [esp+20+8], -1 |
||
451 | jz .noprec1 |
||
452 | cmp eax, [esp+20+8] |
||
453 | jae .len_found1 |
||
454 | mov eax, [esp+20+8] |
||
455 | jmp .len_found1 |
||
456 | .noprec1: |
||
457 | test bh, 4 |
||
458 | jnz .do_print_num |
||
459 | .len_found1: |
||
460 | test bh, 2 |
||
461 | jnz .do_print_num |
||
462 | cmp byte [esp+20], 0 |
||
463 | jz @f |
||
464 | inc eax |
||
465 | @@: |
||
466 | cmp byte [esp+20], 0 |
||
467 | jnz @f |
||
468 | cmp byte [esp+4], 0 |
||
469 | jz @f |
||
470 | inc eax |
||
471 | @@: |
||
472 | test bh, 1 |
||
473 | jz .nosharp1 |
||
474 | cmp cl, 8 |
||
475 | jnz @f |
||
476 | inc eax |
||
477 | jmp .nosharp1 |
||
478 | @@: |
||
479 | cmp cl, 16 |
||
480 | jnz .nosharp1 |
||
481 | inc eax |
||
482 | inc eax |
||
483 | .nosharp1: |
||
484 | cmp dword [esp+20+4], -1 |
||
485 | jz .do_print_num |
||
486 | sub eax, [esp+20+4] |
||
487 | jae .do_print_num |
||
488 | push ecx |
||
489 | mov ecx, eax |
||
490 | mov al, ' ' |
||
491 | @@: |
||
492 | xchg edi, [esp+20] |
||
493 | call con.write_char_ex |
||
494 | inc dword [esp+24+12+64+28] |
||
495 | xchg edi, [esp+20] |
||
496 | inc dword [esp+4] |
||
497 | inc ecx |
||
498 | jnz @b |
||
499 | pop ecx |
||
500 | .do_print_num: |
||
501 | mov al, '-' |
||
502 | cmp byte [esp+4], 0 |
||
503 | jnz .write_sign |
||
504 | mov al, [esp+20] |
||
505 | test al, al |
||
506 | jz .sign_written |
||
507 | .write_sign: |
||
508 | call .num_write_char |
||
509 | .sign_written: |
||
510 | test bh, 1 |
||
511 | jz .nosharp2 |
||
512 | mov al, '0' |
||
513 | cmp cl, 8 |
||
514 | jz @f |
||
515 | cmp cl, 16 |
||
516 | jnz .nosharp2 |
||
517 | call .num_write_char |
||
518 | mov al, [esp+8] |
||
519 | @@: |
||
520 | call .num_write_char |
||
521 | .nosharp2: |
||
522 | lea ecx, [esp+32+64-1] |
||
523 | sub ecx, edi |
||
524 | cmp dword [esp+20+8], -1 |
||
525 | jz .noprec2 |
||
526 | sub ecx, [esp+20+8] |
||
527 | jmp .lead_zeroes |
||
528 | .noprec2: |
||
529 | test bh, 4 |
||
530 | jz .do_print_num2 |
||
531 | add ecx, [esp] |
||
532 | sub ecx, [esp+20+4] |
||
533 | .lead_zeroes: |
||
534 | jae .do_print_num2 |
||
535 | @@: |
||
536 | mov al, '0' |
||
537 | call .num_write_char |
||
538 | inc ecx |
||
539 | jnz @b |
||
540 | .do_print_num2: |
||
541 | mov al, [edi] |
||
542 | test al, al |
||
543 | jz .num_written |
||
544 | call .num_write_char |
||
545 | inc edi |
||
546 | jmp .do_print_num2 |
||
547 | .num_written: |
||
548 | pop ecx |
||
549 | mov edi, [esp+12] |
||
550 | cmp dword [esp+16+4], -1 |
||
551 | jz .num_written2 |
||
552 | @@: |
||
553 | cmp ecx, [esp+16+4] |
||
554 | jae .num_written2 |
||
555 | mov al, ' ' |
||
556 | call con.write_char |
||
557 | inc ecx |
||
558 | jmp @b |
||
559 | .num_written2: |
||
560 | add esp, 16 |
||
561 | .spec_done: |
||
562 | add esp, 12 |
||
563 | jmp .loop |
||
564 | .char: |
||
565 | mov ecx, [esp+4] |
||
566 | cmp ecx, -1 |
||
567 | jnz @f |
||
568 | inc ecx |
||
569 | @@: |
||
570 | test ecx, ecx |
||
571 | jnz @f |
||
572 | inc ecx |
||
573 | @@: |
||
574 | test bh, 2 |
||
575 | jnz .char_left_pad |
||
576 | mov al, ' ' |
||
577 | dec ecx |
||
578 | jz .nowidth |
||
579 | add [esp+12+64+28], ecx |
||
580 | @@: |
||
581 | call con.write_char |
||
582 | loop @b |
||
583 | .nowidth: |
||
584 | mov al, [ebp] |
||
585 | add ebp, 4 |
||
586 | jmp .percent |
||
587 | .char_left_pad: |
||
588 | mov al, [ebp] |
||
589 | add ebp, 4 |
||
590 | call con.write_char_ex |
||
591 | add [esp+12+64+28], ecx |
||
592 | dec ecx |
||
593 | jz .nowidth2 |
||
594 | mov al, ' ' |
||
595 | @@: |
||
596 | call con.write_char |
||
597 | loop @b |
||
598 | .nowidth2: |
||
599 | jmp .spec_done |
||
600 | .string: |
||
601 | push esi |
||
602 | mov esi, [ebp] |
||
603 | test esi, esi |
||
604 | jnz @f |
||
605 | mov esi, con.aNull |
||
606 | @@: |
||
607 | add ebp, 4 |
||
608 | or ecx, -1 |
||
609 | @@: |
||
610 | inc ecx |
||
611 | cmp byte [esi+ecx], 0 |
||
612 | jnz @b |
||
613 | cmp ecx, [esp+12] |
||
614 | jb @f |
||
615 | mov ecx, [esp+12] |
||
616 | @@: |
||
617 | test bh, 2 |
||
618 | jnz .write_string |
||
619 | cmp dword [esp+8], -1 |
||
620 | jz .write_string |
||
621 | push ecx |
||
622 | sub ecx, [esp+12] |
||
623 | jae .nospace |
||
624 | mov al, ' ' |
||
625 | @@: |
||
626 | call con.write_char |
||
627 | inc dword [esp+20+64+28] |
||
628 | inc ecx |
||
629 | jnz @b |
||
630 | .nospace: |
||
631 | pop ecx |
||
632 | .write_string: |
||
633 | jecxz .string_written |
||
634 | add dword [esp+16+64+28], ecx |
||
635 | push ecx |
||
636 | @@: |
||
637 | lodsb |
||
638 | call con.write_char_ex |
||
639 | loop @b |
||
640 | pop ecx |
||
641 | .string_written: |
||
642 | pop esi |
||
643 | test bh, 2 |
||
644 | jz .spec_done |
||
645 | cmp dword [esp+4], -1 |
||
646 | jz .spec_done |
||
647 | sub ecx, [esp+4] |
||
648 | jae .spec_done |
||
649 | mov al, ' ' |
||
650 | @@: |
||
651 | call con.write_char |
||
652 | inc dword [esp+12+64+28] |
||
653 | inc ecx |
||
654 | jnz @b |
||
655 | jmp .spec_done |
||
656 | .done: |
||
657 | add esp, 64 |
||
658 | popad |
||
659 | jmp con.update_screen |
||
660 | .num_write_char: |
||
661 | xchg edi, [esp+20] |
||
662 | call con.write_char_ex |
||
663 | inc dword [esp+24+12+64+28] |
||
664 | xchg edi, [esp+20] |
||
665 | inc dword [esp+4] |
||
666 | ret |
||
667 | |||
668 | con.write: |
||
669 | ; esi = string, ebx = length (ebx=-1 for ASCIIZ strings) |
||
670 | push edi |
||
671 | call con.get_data_ptr |
||
672 | test ebx, ebx |
||
673 | jz .done |
||
674 | .loop: |
||
675 | lodsb |
||
676 | cmp ebx, -1 |
||
677 | jnz @f |
||
678 | test al, al |
||
679 | jz .done |
||
680 | @@: |
||
681 | call con.write_char_ex |
||
682 | .next: |
||
683 | cmp ebx, -1 |
||
684 | jz .loop |
||
685 | dec ebx |
||
686 | jnz .loop |
||
687 | .done: |
||
688 | pop edi |
||
689 | jmp con.update_screen |
||
690 | |||
691 | con.get_data_ptr: |
||
692 | mov edi, [con.cur_y] |
||
693 | imul edi, [con.scr_width] |
||
694 | add edi, [con.cur_x] |
||
695 | add edi, edi |
||
696 | add edi, [con.data] |
||
697 | ret |
||
698 | |||
699 | con.write_char_ex: |
||
700 | test byte [con_flags+1], 1 |
||
701 | jz con.write_special_char |
||
702 | |||
703 | con.write_char: |
||
704 | push eax |
||
3690 | hidnplayr | 705 | |
706 | mov eax, [con.cur_x] |
||
707 | cmp eax, [con.scr_width] |
||
708 | jb @f |
||
709 | and [con.cur_x], 0 |
||
710 | call con.newline |
||
711 | @@: |
||
712 | mov eax, [esp] |
||
836 | diamond | 713 | stosb |
714 | mov al, byte [con_flags] |
||
715 | stosb |
||
3690 | hidnplayr | 716 | |
836 | diamond | 717 | mov eax, [con.cur_x] |
718 | inc eax |
||
719 | mov [con.cur_x], eax |
||
3690 | hidnplayr | 720 | |
836 | diamond | 721 | pop eax |
722 | ret |
||
723 | |||
724 | con.write_special_char: |
||
725 | cmp [con_esc], 0 |
||
726 | jnz .esc_mode |
||
727 | .normal_mode: |
||
728 | cmp al, 10 |
||
729 | jz .write_lf |
||
730 | cmp al, 13 |
||
731 | jz .write_cr |
||
732 | cmp al, 27 |
||
733 | jz .write_esc |
||
734 | cmp al, 8 |
||
735 | jz .write_bs |
||
736 | cmp al, 9 |
||
737 | jnz con.write_char |
||
738 | .write_tab: |
||
739 | mov al, ' ' |
||
740 | call con.write_char |
||
741 | test [con.cur_x], 7 |
||
742 | jnz .write_tab |
||
743 | ret |
||
744 | .write_cr: |
||
745 | and [con.cur_x], 0 |
||
746 | jmp con.get_data_ptr |
||
747 | .write_lf: |
||
748 | and [con.cur_x], 0 |
||
749 | jmp con.newline |
||
750 | .write_bs: |
||
751 | cmp [con.cur_x], 0 |
||
752 | jz @f |
||
753 | dec [con.cur_x] |
||
754 | dec edi |
||
755 | dec edi |
||
756 | ret |
||
757 | @@: |
||
758 | push eax |
||
759 | mov eax, [con.cur_y] |
||
760 | dec eax |
||
761 | js @f |
||
762 | mov [con.cur_y], eax |
||
763 | mov eax, [con.scr_width] |
||
764 | dec eax |
||
765 | mov [con.cur_x], eax |
||
766 | dec edi |
||
767 | dec edi |
||
768 | @@: |
||
769 | pop eax |
||
770 | ret |
||
771 | .write_esc: |
||
772 | mov [con_esc], 1 |
||
773 | mov [con_esc_attr_n], 1 |
||
774 | and [con_esc_attrs], 0 |
||
775 | ret |
||
776 | .esc_mode: |
||
777 | cmp [con_sci], 0 |
||
778 | jnz .esc_sci |
||
779 | cmp al, '[' |
||
780 | jnz @f |
||
781 | mov [con_sci], 1 |
||
782 | ret |
||
783 | @@: |
||
784 | push eax |
||
785 | mov al, 27 |
||
786 | call con.write_char |
||
787 | pop eax |
||
788 | jmp con.write_char |
||
789 | .esc_sci: |
||
790 | ; this is real Esc sequence |
||
791 | cmp al, ';' |
||
792 | jz .next_arg |
||
793 | cmp al, '0' |
||
794 | jb .not_digit |
||
795 | cmp al, '9' |
||
796 | ja .not_digit |
||
797 | push eax ecx edx |
||
798 | sub al, '0' |
||
799 | movzx eax, al |
||
800 | mov ecx, [con_esc_attr_n] |
||
801 | mov edx, [con_esc_attrs+(ecx-1)*4] |
||
802 | lea edx, [edx*5] |
||
803 | lea edx, [edx*2+eax] |
||
804 | mov [con_esc_attrs+(ecx-1)*4], edx |
||
805 | pop edx ecx eax |
||
806 | ret |
||
807 | .next_arg: |
||
808 | push eax |
||
809 | mov eax, [con_esc_attr_n] |
||
810 | inc eax |
||
811 | cmp al, 4 |
||
812 | jbe @f |
||
813 | dec eax |
||
814 | @@: |
||
815 | mov [con_esc_attr_n], eax |
||
816 | and [con_esc_attrs+(eax-1)*4], 0 |
||
817 | pop eax |
||
818 | ret |
||
819 | .not_digit: |
||
820 | mov [con_esc], 0 |
||
821 | mov [con_sci], 0 ; in any case, leave Esc mode |
||
853 | diamond | 822 | cmp al, 'J' |
3885 | hidnplayr | 823 | jz .clear |
853 | diamond | 824 | cmp al, 'H' |
825 | jz .setcursor |
||
826 | cmp al, 'f' |
||
827 | jz .setcursor |
||
836 | diamond | 828 | cmp al, 'm' |
829 | jz .set_attr |
||
853 | diamond | 830 | cmp al, 'A' |
831 | jz .cursor_up |
||
832 | cmp al, 'B' |
||
833 | jz .cursor_down |
||
834 | cmp al, 'C' |
||
835 | jz .cursor_right |
||
836 | cmp al, 'D' |
||
837 | jz .cursor_left |
||
836 | diamond | 838 | ret ; simply skip unknown sequences |
3885 | hidnplayr | 839 | .clear: |
840 | mov eax, [con_esc_attrs] |
||
841 | test eax, eax |
||
842 | jz .clear_till_end_of_screen ; |
||
843 | dec eax |
||
844 | jz .clear_till_start_of_screen ; |
||
845 | dec eax |
||
846 | je .cls ; |
||
847 | ret ; unknown sequence |
||
848 | |||
849 | .clear_till_end_of_screen: |
||
850 | push edi ecx |
||
851 | mov ecx, [con.scr_width] |
||
852 | imul ecx, [con.scr_height] |
||
853 | |||
854 | mov edi, [con.cur_y] |
||
855 | imul edi, [con.scr_width] |
||
856 | add edi, [con.cur_x] |
||
857 | |||
858 | sub ecx, edi |
||
859 | shl edi, 1 |
||
860 | add edi, [con.data] |
||
861 | mov ah, byte[con_flags] |
||
862 | mov al, ' ' |
||
863 | rep stosw |
||
864 | |||
865 | and [con.cur_x], 0 |
||
866 | and [con.cur_y], 0 |
||
867 | pop ecx edi |
||
868 | ret |
||
869 | |||
870 | .clear_till_start_of_screen: |
||
871 | push edi ecx |
||
872 | mov ecx, [con.cur_y] |
||
873 | imul ecx, [con.scr_width] |
||
874 | add ecx, [con.cur_x] |
||
875 | mov edi, [con.data] |
||
876 | mov ah, byte[con_flags] |
||
877 | mov al, ' ' |
||
878 | rep stosw |
||
879 | pop ecx edi |
||
880 | ret |
||
881 | |||
882 | .cls: ; clear screen completely |
||
853 | diamond | 883 | push ecx |
884 | and [con.cur_x], 0 |
||
885 | and [con.cur_y], 0 |
||
886 | mov edi, [con.data] |
||
887 | push edi |
||
888 | mov ecx, [con.scr_width] |
||
889 | imul ecx, [con.scr_height] |
||
890 | mov ax, 0720h |
||
891 | rep stosw |
||
892 | pop edi ecx |
||
893 | .nosetcursor: |
||
894 | ret |
||
895 | .setcursor: |
||
896 | cmp [con_esc_attr_n], 2 |
||
3686 | hidnplayr | 897 | je @f |
898 | xor eax, eax |
||
3688 | hidnplayr | 899 | mov [con.cur_x], eax |
900 | mov [con.cur_y], eax |
||
901 | jmp .j_get_data |
||
3686 | hidnplayr | 902 | @@: |
853 | diamond | 903 | mov eax, [con_esc_attrs] |
904 | cmp eax, [con.scr_width] |
||
905 | jae @f |
||
906 | mov [con.cur_x], eax |
||
907 | @@: |
||
908 | mov eax, [con_esc_attrs+4] |
||
909 | cmp eax, [con.scr_height+4] |
||
910 | jae @f |
||
911 | mov [con.cur_y], eax |
||
912 | .j_get_data: |
||
913 | jmp con.get_data_ptr |
||
914 | .cursor_up: |
||
915 | cmp [con_esc_attr_n], 1 |
||
916 | jnz .nosetcursor |
||
917 | mov eax, [con.cur_y] |
||
918 | sub eax, [con_esc_attrs] |
||
919 | jnc @f |
||
920 | xor eax, eax |
||
921 | @@: |
||
922 | mov [con.cur_y], eax |
||
923 | jmp .j_get_data |
||
924 | .cursor_down: |
||
925 | cmp [con_esc_attr_n], 1 |
||
926 | jnz .nosetcursor |
||
927 | mov eax, [con.cur_y] |
||
928 | add eax, [con_esc_attrs] |
||
929 | cmp eax, [con.scr_height] |
||
930 | jb @f |
||
931 | mov eax, [con.scr_height] |
||
932 | dec eax |
||
933 | @@: |
||
934 | mov [con.cur_y], eax |
||
935 | jmp .j_get_data |
||
936 | .cursor_right: |
||
937 | cmp [con_esc_attr_n], 1 |
||
938 | jnz .nosetcursor |
||
939 | mov eax, [con.cur_x] |
||
940 | add eax, [con_esc_attrs] |
||
941 | cmp eax, [con.scr_width] |
||
942 | jb @f |
||
943 | mov eax, [con.scr_width] |
||
944 | dec eax |
||
945 | @@: |
||
946 | mov [con.cur_x], eax |
||
947 | jmp .j_get_data |
||
948 | .cursor_left: |
||
949 | cmp [con_esc_attr_n], 1 |
||
950 | jnz .nosetcursor |
||
951 | mov eax, [con.cur_x] |
||
952 | sub eax, [con_esc_attrs] |
||
953 | jnc @f |
||
954 | xor eax, eax |
||
955 | @@: |
||
956 | mov [con.cur_x], eax |
||
957 | jmp .j_get_data |
||
836 | diamond | 958 | .set_attr: |
959 | push eax ecx edx |
||
960 | xor ecx, ecx |
||
961 | .set_one_attr: |
||
962 | mov eax, [con_esc_attrs+ecx*4] |
||
963 | cmp al, 0 |
||
964 | jz .attr_normal |
||
965 | cmp al, 1 |
||
966 | jz .attr_bold |
||
967 | cmp al, 5 |
||
968 | jz .attr_bgr_bold |
||
969 | cmp al, 7 |
||
970 | jz .attr_reversed |
||
3690 | hidnplayr | 971 | |
836 | diamond | 972 | xor edx, edx |
973 | cmp al, 30 |
||
974 | jz .attr_color |
||
975 | mov dl, 4 |
||
976 | cmp al, 31 |
||
977 | jz .attr_color |
||
978 | mov dl, 2 |
||
979 | cmp al, 32 |
||
980 | jz .attr_color |
||
981 | mov dl, 6 |
||
982 | cmp al, 33 |
||
983 | jz .attr_color |
||
984 | mov dl, 1 |
||
985 | cmp al, 34 |
||
986 | jz .attr_color |
||
987 | mov dl, 5 |
||
988 | cmp al, 35 |
||
989 | jz .attr_color |
||
990 | mov dl, 3 |
||
991 | cmp al, 36 |
||
992 | jz .attr_color |
||
993 | mov dl, 7 |
||
994 | cmp al, 37 |
||
995 | jz .attr_color |
||
3690 | hidnplayr | 996 | |
836 | diamond | 997 | xor edx, edx |
998 | cmp al, 40 |
||
999 | jz .attr_bgr_color |
||
1000 | mov dl, 0x40 |
||
1001 | cmp al, 41 |
||
1002 | jz .attr_bgr_color |
||
1003 | mov dl, 0x20 |
||
1004 | cmp al, 42 |
||
1005 | jz .attr_bgr_color |
||
1006 | mov dl, 0x60 |
||
1007 | cmp al, 43 |
||
1008 | jz .attr_bgr_color |
||
1009 | mov dl, 0x10 |
||
1010 | cmp al, 44 |
||
1011 | jz .attr_bgr_color |
||
1012 | mov dl, 0x50 |
||
1013 | cmp al, 45 |
||
1014 | jz .attr_bgr_color |
||
1015 | mov dl, 0x30 |
||
1016 | cmp al, 46 |
||
1017 | jz .attr_bgr_color |
||
1018 | mov dl, 0x70 |
||
1019 | cmp al, 47 |
||
3690 | hidnplayr | 1020 | jz .attr_bgr_color |
1021 | |||
1022 | mov dl, 0x08 |
||
3692 | hidnplayr | 1023 | cmp al, 90 |
3690 | hidnplayr | 1024 | jz .attr_color |
1025 | mov dl, 4 + 8 |
||
3692 | hidnplayr | 1026 | cmp al, 91 |
3690 | hidnplayr | 1027 | jz .attr_color |
1028 | mov dl, 2 + 8 |
||
3692 | hidnplayr | 1029 | cmp al, 92 |
3690 | hidnplayr | 1030 | jz .attr_color |
1031 | mov dl, 6 + 8 |
||
3692 | hidnplayr | 1032 | cmp al, 93 |
3690 | hidnplayr | 1033 | jz .attr_color |
1034 | mov dl, 1 + 8 |
||
3692 | hidnplayr | 1035 | cmp al, 94 |
3690 | hidnplayr | 1036 | jz .attr_color |
1037 | mov dl, 5 + 8 |
||
3692 | hidnplayr | 1038 | cmp al, 95 |
3690 | hidnplayr | 1039 | jz .attr_color |
1040 | mov dl, 3 + 8 |
||
3692 | hidnplayr | 1041 | cmp al, 96 |
3690 | hidnplayr | 1042 | jz .attr_color |
1043 | mov dl, 7 + 8 |
||
3692 | hidnplayr | 1044 | cmp al, 97 |
3690 | hidnplayr | 1045 | jz .attr_color |
1046 | |||
1047 | mov dl, 0x80 |
||
1048 | cmp al, 100 |
||
1049 | jz .attr_bgr_color |
||
1050 | mov dl, 0x80 + 0x40 |
||
1051 | cmp al, 101 |
||
1052 | jz .attr_bgr_color |
||
1053 | mov dl, 0x80 + 0x20 |
||
1054 | cmp al, 102 |
||
1055 | jz .attr_bgr_color |
||
1056 | mov dl, 0x80 + 0x60 |
||
1057 | cmp al, 103 |
||
1058 | jz .attr_bgr_color |
||
1059 | mov dl, 0x80 + 0x10 |
||
1060 | cmp al, 104 |
||
1061 | jz .attr_bgr_color |
||
1062 | mov dl, 0x80 + 0x50 |
||
1063 | cmp al, 105 |
||
1064 | jz .attr_bgr_color |
||
1065 | mov dl, 0x80 + 0x30 |
||
1066 | cmp al, 106 |
||
1067 | jz .attr_bgr_color |
||
1068 | mov dl, 0x80 + 0x70 |
||
1069 | cmp al, 107 |
||
836 | diamond | 1070 | jnz .attr_continue |
3690 | hidnplayr | 1071 | |
836 | diamond | 1072 | .attr_bgr_color: |
1073 | mov eax, [con_flags] |
||
3690 | hidnplayr | 1074 | and al, 0x0F |
836 | diamond | 1075 | or al, dl |
1076 | mov [con_flags], eax |
||
1077 | jmp .attr_continue |
||
1078 | .attr_color: |
||
1079 | mov eax, [con_flags] |
||
3690 | hidnplayr | 1080 | and al, 0xF0 |
836 | diamond | 1081 | or al, dl |
1082 | mov [con_flags], eax |
||
1083 | jmp .attr_continue |
||
1084 | .attr_normal: |
||
1085 | mov byte [con_flags], 7 |
||
1086 | jmp .attr_continue |
||
1087 | .attr_reversed: |
||
1088 | mov byte [con_flags], 0x70 |
||
1089 | jmp .attr_continue |
||
1090 | .attr_bold: |
||
1091 | or byte [con_flags], 8 |
||
1092 | jmp .attr_continue |
||
1093 | .attr_bgr_bold: |
||
1094 | or byte [con_flags], 0x80 |
||
1095 | .attr_continue: |
||
1096 | inc ecx |
||
1097 | cmp ecx, [con_esc_attr_n] |
||
1098 | jb .set_one_attr |
||
1099 | pop edx ecx eax |
||
1100 | ret |
||
1101 | |||
1102 | con.newline: |
||
1103 | mov eax, [con.cur_y] |
||
1104 | inc eax |
||
1105 | mov [con.cur_y], eax |
||
1106 | cmp eax, [con.scr_height] |
||
1107 | jb @f |
||
1108 | call con.scr_scroll_up |
||
1109 | @@: |
||
1110 | call con.get_data_ptr |
||
1111 | ret |
||
1112 | |||
1113 | con.scr_scroll_up: |
||
1114 | pushad |
||
1115 | mov edi, [con.data] |
||
1116 | mov esi, edi |
||
1117 | add esi, [con.scr_width] |
||
1118 | add esi, [con.scr_width] |
||
1119 | dec [con.cur_y] |
||
1120 | mov ecx, [con.scr_height] |
||
1121 | dec ecx |
||
1122 | imul ecx, [con.scr_width] |
||
1123 | shr ecx, 1 |
||
1124 | rep movsd |
||
1125 | adc ecx, ecx |
||
1126 | rep movsw |
||
1127 | mov ax, 0x0720 |
||
1128 | mov ecx, [con.scr_width] |
||
1129 | rep stosw |
||
1130 | popad |
||
1131 | ret |
||
1132 | |||
1133 | con.data2image: |
||
1134 | pushad |
||
1135 | mov edi, [con.image] |
||
1136 | mov esi, [con.data] |
||
1137 | mov eax, [con.wnd_ypos] |
||
1138 | mul [con.scr_width] |
||
1139 | add eax, [con.wnd_xpos] |
||
1140 | lea esi, [esi+eax*2] |
||
1141 | mov ecx, [con.wnd_height] |
||
1142 | .lh: |
||
1143 | push ecx |
||
1144 | mov ecx, [con.wnd_width] |
||
1145 | .lw: |
||
1146 | push ecx edi |
||
1147 | xor eax, eax |
||
1148 | mov al, [esi+1] |
||
1149 | push eax |
||
1150 | and al, 0xF |
||
1151 | mov ebx, eax ; цвет текста |
||
1152 | pop eax |
||
1153 | shr al, 4 |
||
1154 | mov ebp, eax ; цвет фона |
||
1155 | sub ebx, ebp |
||
1156 | lodsb |
||
1157 | inc esi |
||
1158 | if font_width > 8 |
||
1159 | lea edx, [eax+eax+font] |
||
1160 | else |
||
1161 | lea edx, [eax+font] |
||
1162 | end if |
||
1163 | .sh: |
||
1164 | mov ecx, [edx] |
||
1165 | repeat font_width |
||
1166 | shr ecx, 1 |
||
1167 | sbb eax, eax |
||
1168 | and eax, ebx |
||
1169 | add eax, ebp |
||
1170 | mov [edi+%-1], al |
||
1171 | end repeat |
||
1172 | mov eax, [con.wnd_width] |
||
1173 | ; imul eax, font_width |
||
1174 | ; add edi, eax |
||
1175 | if font_width = 6 |
||
1176 | lea eax, [eax*2+eax] |
||
1177 | lea edi, [edi+eax*2] |
||
1178 | else if font_width = 7 |
||
1179 | lea edi, [edi+eax*8] |
||
1180 | sub edi, eax |
||
1181 | else if font_width = 8 |
||
1182 | lea edi, [edi+eax*8] |
||
1183 | else if font_width = 9 |
||
1184 | lea edi, [edi+eax*8] |
||
1185 | add edi, eax |
||
1186 | else if font_width = 10 |
||
1187 | lea eax, [eax*4+eax] |
||
1188 | lea edi, [edi+eax*2] |
||
1189 | else |
||
1190 | Unknown font_width value! |
||
1191 | end if |
||
1192 | if font_width > 8 |
||
1193 | add edx, 256*2 |
||
1194 | cmp edx, font+256*2*font_height |
||
1195 | else |
||
1196 | add edx, 256 |
||
1197 | cmp edx, font+256*font_height |
||
1198 | end if |
||
1199 | jb .sh |
||
1200 | pop edi ecx |
||
1201 | add edi, font_width |
||
1202 | sub ecx, 1 |
||
1203 | jnz .lw |
||
1204 | mov eax, [con.wnd_width] |
||
1205 | imul eax, (font_height-1)*font_width |
||
1206 | add edi, eax |
||
1207 | pop ecx |
||
1208 | mov eax, [con.scr_width] |
||
1209 | sub eax, [con.wnd_width] |
||
1210 | lea esi, [esi+eax*2] |
||
1211 | dec ecx |
||
1212 | jnz .lh |
||
1213 | mov eax, [con.cur_y] |
||
1214 | sub eax, [con.wnd_ypos] |
||
1215 | jb .nocursor |
||
1216 | cmp eax, [con.wnd_height] |
||
1217 | jae .nocursor |
||
1218 | inc eax |
||
1219 | mul [con.wnd_width] |
||
1220 | imul eax, font_height*font_width |
||
1221 | mov edx, [con.cur_x] |
||
1222 | sub edx, [con.wnd_xpos] |
||
1223 | jb .nocursor |
||
1224 | cmp edx, [con.wnd_width] |
||
1225 | jae .nocursor |
||
1226 | inc edx |
||
1227 | imul edx, font_width |
||
1228 | add eax, edx |
||
1229 | add eax, [con.image] |
||
1230 | mov edx, [con.wnd_width] |
||
1231 | imul edx, font_width |
||
1232 | neg edx |
||
1233 | mov ecx, [con.cursor_height] |
||
1234 | jecxz .nocursor |
||
1235 | .cursor_loop: |
||
1236 | push ecx |
||
1237 | mov ecx, font_width |
||
1238 | add eax, edx |
||
1239 | push eax |
||
1240 | @@: |
||
1241 | xor byte [eax-1], 7 |
||
1242 | dec eax |
||
1243 | loop @b |
||
1244 | pop eax |
||
1245 | pop ecx |
||
1246 | loop .cursor_loop |
||
1247 | .nocursor: |
||
1248 | popad |
||
1249 | ret |
||
1250 | |||
1251 | con_exit: |
||
1252 | cmp byte [esp+4], 0 |
||
1253 | jz .noexit |
||
1254 | mov [con.thread_op], 1 |
||
1255 | call con.wake |
||
1256 | ret 4 |
||
1257 | .noexit: |
||
1258 | push esi |
||
1259 | mov esi, [con.title] |
||
1260 | mov edx, con.finished_title |
||
1261 | mov ecx, 255 |
||
1262 | call .strcpy |
||
1263 | mov esi, con.aFinished |
||
1264 | call .strcpy |
||
1265 | mov byte [edx], 0 |
||
1266 | pop esi |
||
1267 | and [con.cursor_height], 0 |
||
1268 | push con.finished_title |
||
1269 | call con_set_title |
||
1270 | ret 4 |
||
1271 | .strcpy: |
||
1272 | jecxz .ret |
||
1273 | @@: |
||
1274 | lodsb |
||
1275 | test al, al |
||
1276 | jz .ret |
||
1277 | mov [edx], al |
||
1278 | inc edx |
||
1279 | loop @b |
||
1280 | .ret: |
||
1281 | ret |
||
1282 | |||
1283 | con_set_title: |
||
1284 | mov eax, [esp+4] |
||
1285 | mov [con.title], eax |
||
1286 | mov [con.thread_op], 2 |
||
1287 | call con.wake |
||
1288 | ret 4 |
||
1289 | |||
1290 | ; int __stdcall con_kbhit(void); |
||
1291 | con_kbhit: |
||
1133 | diamond | 1292 | test byte [con_flags+1], 2 |
1293 | jnz @f |
||
836 | diamond | 1294 | mov eax, [con.input_start] |
1295 | cmp eax, [con.input_end] |
||
1133 | diamond | 1296 | @@: |
836 | diamond | 1297 | setnz al |
1298 | movzx eax, al |
||
1299 | ret |
||
1300 | |||
1301 | con.force_entered_char: |
||
1302 | cmp [con.entered_char], -1 |
||
1303 | jnz .ret |
||
1304 | mov [con.thread_op], 4 |
||
1305 | call con.wake |
||
1133 | diamond | 1306 | test byte [con_flags+1], 2 |
1307 | jnz .ret |
||
836 | diamond | 1308 | ; wait for response |
1309 | push ebx |
||
1310 | push 5 |
||
1311 | pop eax |
||
1312 | push 2 |
||
1313 | pop ebx |
||
1314 | @@: |
||
1315 | int 0x40 |
||
1316 | cmp [con.entered_char], -1 |
||
1317 | jz @b |
||
1318 | pop ebx |
||
1319 | .ret: |
||
1320 | ret |
||
1321 | |||
1322 | ; int __stdcall con_getch(void); |
||
1323 | con_getch: |
||
1324 | call con.force_entered_char |
||
1133 | diamond | 1325 | test byte [con_flags+1], 2 |
1326 | jnz con_getch_closed |
||
836 | diamond | 1327 | movzx eax, byte [con.entered_char] |
1328 | sar [con.entered_char], 8 |
||
1329 | mov byte [con.entered_char+1], 0xFF |
||
1330 | test al, al |
||
1331 | jz @f |
||
1332 | mov byte [con.entered_char], 0xFF |
||
1333 | @@: |
||
1334 | ret |
||
1335 | |||
1133 | diamond | 1336 | con_getch_closed: |
1145 | diamond | 1337 | xor eax, eax |
1133 | diamond | 1338 | ret |
1339 | |||
836 | diamond | 1340 | ; int __stdcall con_getch2(void); |
1341 | con_getch2: |
||
1342 | call con.force_entered_char |
||
1133 | diamond | 1343 | test byte [con_flags+1], 2 |
1344 | jnz con_getch_closed |
||
836 | diamond | 1345 | mov eax, 0xFFFF |
1346 | xchg ax, [con.entered_char] |
||
1347 | ret |
||
1348 | |||
1133 | diamond | 1349 | ; char* __stdcall con_gets(char* str, int n); |
836 | diamond | 1350 | con_gets: |
852 | diamond | 1351 | pop eax |
1352 | push 0 |
||
1353 | push eax |
||
1133 | diamond | 1354 | ; char* __stdcall con_gets2(con_gets2_callback callback, char* str, int n); |
852 | diamond | 1355 | con_gets2: |
1133 | diamond | 1356 | mov eax, [esp+8] ; str |
836 | diamond | 1357 | pushad |
1133 | diamond | 1358 | mov esi, eax ; str |
852 | diamond | 1359 | mov ebx, [esp+20h+12] ; n |
836 | diamond | 1360 | sub ebx, 1 |
1361 | jle .ret |
||
1362 | mov byte [esi], 0 |
||
1363 | xor ecx, ecx ; длина уже введённой строки |
||
1364 | call con.get_data_ptr |
||
1365 | .loop: |
||
852 | diamond | 1366 | call con_getch2 |
836 | diamond | 1367 | test al, al |
1368 | jz .extended |
||
1369 | cmp al, 8 |
||
1370 | jz .backspace |
||
1371 | cmp al, 27 |
||
1372 | jz .esc |
||
1373 | cmp al, 13 |
||
1374 | jz .enter |
||
852 | diamond | 1375 | cmp al, 9 |
1376 | jz .tab |
||
836 | diamond | 1377 | inc ecx |
1378 | mov dl, al |
||
1379 | call con.write_char_ex |
||
1380 | push [con.cur_x] |
||
1381 | push [con.cur_y] |
||
1382 | push edi |
||
1383 | push esi |
||
1384 | @@: |
||
1385 | lodsb |
||
1386 | mov [esi-1], dl |
||
1387 | mov dl, al |
||
1388 | test al, al |
||
1389 | jz @f |
||
1390 | call con.write_char_ex |
||
1391 | jmp @b |
||
1392 | @@: |
||
1393 | mov [esi], dl |
||
1394 | pop esi |
||
1395 | inc esi |
||
1396 | pop edi |
||
1397 | pop [con.cur_y] |
||
1398 | pop [con.cur_x] |
||
1399 | .update_screen_and_loop: |
||
1400 | call con.update_screen |
||
1401 | cmp ecx, ebx |
||
1402 | jb .loop |
||
852 | diamond | 1403 | .ret_us: |
836 | diamond | 1404 | mov edx, [con.cur_x] |
1405 | @@: |
||
1406 | lodsb |
||
1407 | test al, al |
||
1408 | jz @f |
||
1409 | inc edx |
||
1410 | cmp edx, [con.scr_width] |
||
1411 | jb @b |
||
1412 | xor edx, edx |
||
1413 | call con.newline |
||
1414 | jmp @b |
||
1415 | @@: |
||
1416 | mov [con.cur_x], edx |
||
1417 | call con.get_data_ptr |
||
1418 | call con.update_screen |
||
1419 | jmp .ret |
||
1420 | .esc: |
||
1421 | mov edx, [con.cur_x] |
||
1422 | @@: |
||
1423 | lodsb |
||
1424 | test al, al |
||
1425 | jz @f |
||
1426 | inc edx |
||
1427 | cmp edx, [con.scr_width] |
||
1428 | jb @b |
||
1429 | xor edx, edx |
||
1430 | call con.newline |
||
1431 | jmp @b |
||
1432 | @@: |
||
1433 | mov [con.cur_x], edx |
||
1434 | call con.get_data_ptr |
||
1435 | dec esi |
||
1436 | xor ecx, ecx |
||
1437 | @@: |
||
1438 | mov byte [esi], 0 |
||
852 | diamond | 1439 | cmp esi, [esp+20h+8] |
836 | diamond | 1440 | jbe .update_screen_and_loop |
1441 | mov al, 8 |
||
1442 | call con.write_special_char |
||
1443 | mov al, ' ' |
||
1444 | call con.write_char |
||
1445 | mov al, 8 |
||
1446 | call con.write_special_char |
||
1447 | dec esi |
||
1448 | jmp @b |
||
1449 | .delete: |
||
1450 | cmp byte [esi], 0 |
||
1451 | jz .loop |
||
1452 | lodsb |
||
1453 | call con.write_char_ex |
||
1454 | .backspace: |
||
852 | diamond | 1455 | cmp esi, [esp+20h+8] |
836 | diamond | 1456 | jbe .loop |
1457 | push esi |
||
1458 | mov edx, [con.cur_x] |
||
1459 | @@: |
||
1460 | lodsb |
||
1461 | test al, al |
||
1462 | jz @f |
||
1463 | inc edx |
||
1464 | cmp edx, [con.scr_width] |
||
1465 | jb @b |
||
1466 | xor edx, edx |
||
1467 | call con.newline |
||
1468 | jmp @b |
||
1469 | @@: |
||
1470 | mov [con.cur_x], edx |
||
1471 | call con.get_data_ptr |
||
1472 | dec esi |
||
1473 | mov al, 8 |
||
1474 | call con.write_special_char |
||
1475 | mov al, ' ' |
||
1476 | call con.write_char |
||
1477 | mov al, 8 |
||
1478 | call con.write_special_char |
||
1479 | mov dl, 0 |
||
1480 | @@: |
||
1481 | cmp esi, [esp] |
||
1482 | jbe @f |
||
1483 | mov al, 8 |
||
1484 | call con.write_special_char |
||
1485 | dec esi |
||
1486 | xchg dl, [esi] |
||
1487 | mov al, dl |
||
1488 | call con.write_char |
||
1489 | mov al, 8 |
||
1490 | call con.write_special_char |
||
1491 | jmp @b |
||
1492 | @@: |
||
1493 | pop esi |
||
1494 | dec esi |
||
1495 | mov [esi], dl |
||
1496 | dec ecx |
||
1497 | jmp .update_screen_and_loop |
||
1498 | .enter: |
||
1499 | mov edx, [con.cur_x] |
||
1500 | @@: |
||
1501 | lodsb |
||
1502 | test al, al |
||
1503 | jz @f |
||
1504 | inc edx |
||
1505 | cmp edx, [con.scr_width] |
||
1506 | jb @b |
||
1507 | xor edx, edx |
||
1508 | call con.newline |
||
1509 | jmp @b |
||
1510 | @@: |
||
1511 | mov [con.cur_x], edx |
||
1512 | call con.get_data_ptr |
||
1513 | mov al, 10 |
||
1514 | mov [esi-1], al |
||
1515 | mov byte [esi], 0 |
||
1516 | call con.write_special_char |
||
1517 | call con.update_screen |
||
1518 | jmp .ret |
||
852 | diamond | 1519 | .tab: |
1520 | mov al, 0 |
||
1521 | mov ah, 0xF |
||
836 | diamond | 1522 | .extended: |
1145 | diamond | 1523 | test ah, ah |
1524 | jz .closed |
||
852 | diamond | 1525 | xchg al, ah |
836 | diamond | 1526 | cmp al, 0x4B |
1527 | jz .left |
||
1528 | cmp al, 0x4D |
||
1529 | jz .right |
||
1530 | cmp al, 0x47 |
||
1531 | jz .home |
||
1532 | cmp al, 0x4F |
||
1533 | jz .end |
||
1534 | cmp al, 0x53 |
||
1535 | jz .delete |
||
852 | diamond | 1536 | ; give control to callback function |
1537 | cmp dword [esp+20h+4], 0 |
||
1538 | jz .loop |
||
1539 | ; remember length of text before and length of text after |
||
1540 | ; and advance cursor to the end of line |
||
1541 | push ecx |
||
1542 | push eax |
||
1543 | lea edx, [esi+1] |
||
1544 | @@: |
||
1545 | lodsb |
||
1546 | test al, al |
||
1547 | jz @f |
||
1548 | call con.write_char_ex |
||
1549 | jmp @b |
||
1550 | @@: |
||
1551 | sub esi, edx |
||
1552 | pop eax |
||
1553 | push esi |
||
1554 | dec edx |
||
1555 | sub edx, [esp+28h+8] |
||
1556 | push edx |
||
1557 | push esp ; ppos |
||
1558 | mov ecx, [esp+30h+4] |
||
1559 | lea edx, [esp+30h+12] |
||
1560 | push edx ; pn |
||
1561 | lea edx, [esp+34h+8] |
||
1562 | push edx ; pstr |
||
1563 | push eax ; keycode |
||
1564 | call ecx |
||
1565 | call con.get_data_ptr |
||
1566 | dec eax |
||
1567 | js .callback_nochange |
||
1568 | jz .callback_del |
||
1569 | dec eax |
||
1570 | jz .callback_output |
||
1571 | ; callback returned 2 - exit |
||
1572 | add esp, 12 |
||
1573 | jmp .ret |
||
1574 | .callback_nochange: |
||
1575 | ; callback returned 0 - string was not changed, only restore cursor position |
||
1576 | pop esi |
||
1577 | pop ecx |
||
1578 | test ecx, ecx |
||
1579 | jz .cncs |
||
1580 | @@: |
||
1581 | mov al, 8 |
||
1582 | call con.write_special_char |
||
1583 | loop @b |
||
1584 | .cncs: |
||
1585 | pop ecx |
||
1586 | add esi, [esp+20h+8] |
||
1587 | jmp .callback_done |
||
1588 | .callback_del: |
||
1589 | ; callback returned 1 - string was changed, delete old string and output new |
||
1590 | mov ecx, [esp+8] |
||
1591 | test ecx, ecx |
||
1592 | jz .cds |
||
1593 | @@: |
||
1594 | mov al, 8 |
||
1595 | call con.write_special_char |
||
1596 | mov al, ' ' |
||
1597 | call con.write_char_ex |
||
1598 | mov al, 8 |
||
1599 | call con.write_special_char |
||
1600 | loop @b |
||
1601 | .cds: |
||
1602 | .callback_output: |
||
1603 | ; callback returned 2 - string was changed, output new string |
||
1604 | pop edx |
||
1605 | pop esi |
||
1606 | pop ecx |
||
1607 | mov esi, [esp+20h+8] |
||
1608 | xor ecx, ecx |
||
1609 | @@: |
||
1610 | lodsb |
||
1611 | test al, al |
||
1612 | jz @f |
||
1613 | call con.write_char_ex |
||
1614 | inc ecx |
||
1615 | jmp @b |
||
1616 | @@: |
||
1617 | dec esi |
||
1618 | push ecx |
||
1619 | sub ecx, edx |
||
1620 | jz .cos |
||
1621 | @@: |
||
1622 | mov al, 8 |
||
1623 | call con.write_special_char |
||
1624 | dec esi |
||
1625 | loop @b |
||
1626 | .cos: |
||
1627 | pop ecx |
||
1628 | .callback_done: |
||
1629 | call con.update_screen |
||
1630 | mov ebx, [esp+20h+12] |
||
1631 | dec ebx |
||
1632 | cmp ecx, ebx |
||
1633 | jae .ret_us |
||
836 | diamond | 1634 | jmp .loop |
1635 | .left: |
||
852 | diamond | 1636 | cmp esi, [esp+20h+8] |
836 | diamond | 1637 | jbe .loop |
1638 | dec esi |
||
1639 | mov al, 8 |
||
1640 | call con.write_special_char |
||
1641 | jmp .update_screen_and_loop |
||
1642 | .right: |
||
1643 | cmp byte [esi], 0 |
||
1644 | jz .loop |
||
1645 | lodsb |
||
1646 | call con.write_char_ex |
||
1647 | jmp .update_screen_and_loop |
||
1648 | .home: |
||
852 | diamond | 1649 | cmp esi, [esp+20h+8] |
836 | diamond | 1650 | jz .update_screen_and_loop |
1651 | dec esi |
||
1652 | mov al, 8 |
||
1653 | call con.write_special_char |
||
1654 | jmp .home |
||
1655 | .end: |
||
1656 | lodsb |
||
1657 | test al, al |
||
1658 | jz @f |
||
1659 | call con.write_char_ex |
||
1660 | jmp .end |
||
1661 | @@: |
||
1662 | dec esi |
||
1663 | jmp .update_screen_and_loop |
||
1133 | diamond | 1664 | .closed: |
1665 | and dword [esp+1Ch], 0 |
||
836 | diamond | 1666 | .ret: |
1667 | popad |
||
852 | diamond | 1668 | ret 12 |
836 | diamond | 1669 | |
853 | diamond | 1670 | ; void __stdcall con_cls(); |
1671 | con_cls: |
||
1672 | push edi |
||
1673 | call con.write_special_char.cls |
||
1674 | pop edi |
||
1675 | call con.update_screen |
||
1676 | ret |
||
1677 | |||
1678 | ; void __stdcall con_get_cursor_pos(int* px, int* py); |
||
1679 | con_get_cursor_pos: |
||
1680 | push eax ecx |
||
1681 | mov eax, [esp+12] |
||
1682 | mov ecx, [con.cur_x] |
||
1683 | mov [eax], ecx |
||
1684 | mov eax, [esp+16] |
||
1685 | mov ecx, [con.cur_y] |
||
1686 | mov [eax], ecx |
||
1687 | pop ecx eax |
||
1688 | ret 8 |
||
1689 | |||
1690 | ; void __stdcall con_set_cursor_pos(int px, int py); |
||
1691 | con_set_cursor_pos: |
||
1692 | push eax |
||
1693 | mov eax, [esp+8] |
||
1694 | cmp eax, [con.scr_width] |
||
1695 | jae @f |
||
1696 | mov [con.cur_x], eax |
||
1697 | @@: |
||
1698 | mov eax, [esp+12] |
||
1699 | cmp eax, [con.scr_height] |
||
1700 | jae @f |
||
1701 | mov [con.cur_y], eax |
||
1702 | @@: |
||
1703 | pop eax |
||
1704 | call con.update_screen |
||
1705 | ret 8 |
||
1706 | |||
836 | diamond | 1707 | con.update_screen: |
1708 | push eax |
||
1709 | mov eax, [con.cur_y] |
||
1710 | sub eax, [con.wnd_ypos] |
||
1711 | jb .up |
||
1712 | cmp eax, [con.wnd_height] |
||
1713 | jb .done |
||
1714 | mov eax, [con.cur_y] |
||
1715 | sub eax, [con.wnd_height] |
||
1716 | inc eax |
||
1717 | jmp .set |
||
1718 | .up: |
||
1719 | mov eax, [con.cur_y] |
||
1720 | .set: |
||
1721 | mov [con.wnd_ypos], eax |
||
1722 | .done: |
||
1723 | pop eax |
||
1724 | mov [con.thread_op], 3 |
||
1725 | |||
1726 | con.wake: |
||
1727 | pushad |
||
1728 | mov al, [con.thread_op] |
||
1729 | cmp al, byte [con.ipc_buf+0x10] |
||
1730 | jz .ret |
||
1731 | @@: |
||
1732 | push 60 |
||
1733 | pop eax |
||
1734 | push 2 |
||
1735 | pop ebx |
||
1736 | mov ecx, [con.console_tid] |
||
1133 | diamond | 1737 | jecxz .ret |
836 | diamond | 1738 | mov edx, con.thread_op |
1739 | push 1 |
||
1740 | pop esi |
||
1741 | int 0x40 |
||
1742 | test eax, eax |
||
1743 | jz @f |
||
1744 | push 5 |
||
1745 | pop eax |
||
1746 | mov bl, 1 |
||
1747 | int 0x40 |
||
1748 | jmp @b |
||
1749 | @@: |
||
1750 | .ret: |
||
1751 | popad |
||
1752 | ret |
||
1753 | |||
1754 | ; Поток окна консоли. Обрабатывает ввод и вывод. |
||
1755 | con.thread: |
||
1756 | ; Поток реагирует на IPC, которое используется только для того, чтобы его можно было "разбудить" |
||
1757 | push 40 |
||
1758 | pop eax |
||
1759 | push 0x67 |
||
1760 | pop ebx |
||
1761 | int 0x40 |
||
1762 | mov al, 60 |
||
1763 | mov bl, 1 |
||
1764 | mov ecx, con.ipc_buf |
||
1765 | push 0x11 |
||
1766 | pop edx |
||
1767 | int 0x40 |
||
1768 | mov al, 66 |
||
1769 | mov bl, 1 |
||
1770 | mov ecx, ebx |
||
1771 | int 0x40 |
||
1772 | con.redraw: |
||
1773 | call con.draw_window |
||
1774 | con.msg_loop: |
||
1775 | cmp dword [con.bUpPressed], 0 |
||
1776 | jnz .wait_timeout |
||
1777 | push 10 |
||
1778 | pop eax |
||
1779 | jmp @f |
||
1780 | .wait_timeout: |
||
1781 | push 23 |
||
1782 | pop eax |
||
1783 | push 5 |
||
1784 | pop ebx |
||
1785 | @@: |
||
1786 | int 0x40 |
||
1787 | dec eax |
||
1788 | jz con.redraw |
||
1789 | dec eax |
||
1790 | jz con.key |
||
1791 | dec eax |
||
1792 | jz con.button |
||
1793 | cmp al, 4 |
||
1794 | jz con.ipc |
||
1795 | jmp con.mouse |
||
1796 | con.button: |
||
1797 | ; we have only one button, close |
||
1798 | con.thread_exit: |
||
1133 | diamond | 1799 | or byte [con_flags+1], 2 |
1800 | and [con.console_tid], 0 |
||
1134 | diamond | 1801 | and [con.entered_char], 0 |
836 | diamond | 1802 | or eax, -1 |
1803 | int 0x40 |
||
1804 | con.key: |
||
1805 | mov al, 2 |
||
1806 | int 0x40 |
||
1807 | ; ah = scancode |
||
1808 | cmp ah, 0xE0 |
||
1809 | jnz @f |
||
1810 | mov [con.bWasE0], 1 |
||
1811 | jmp con.msg_loop |
||
1812 | @@: |
||
1813 | shr eax, 8 |
||
1814 | xchg ah, [con.bWasE0] |
||
1815 | test al, al |
||
1816 | jle con.msg_loop |
||
1817 | cmp al, 0x1D |
||
1818 | jz con.msg_loop |
||
1819 | cmp al, 0x2A |
||
1820 | jz con.msg_loop |
||
1821 | cmp al, 0x36 |
||
1822 | jz con.msg_loop |
||
1823 | cmp al, 0x38 |
||
1824 | jz con.msg_loop |
||
1825 | cmp al, 0x3A |
||
1826 | jz con.msg_loop |
||
1827 | cmp al, 0x45 |
||
1828 | jz con.msg_loop |
||
1829 | cmp al, 0x46 |
||
1830 | jz con.msg_loop |
||
1831 | mov edx, eax |
||
1832 | push 66 |
||
1833 | pop eax |
||
1834 | push 3 |
||
1835 | pop ebx |
||
1836 | int 0x40 ; eax = control key state |
||
1837 | test dh, dh |
||
1838 | jnz .extended |
||
1839 | bt [scan_has_ascii], edx |
||
1840 | jnc .extended |
||
1841 | test al, 0x30 |
||
1842 | jnz .extended |
||
1843 | ; key has ASCII code |
||
1844 | push eax edx |
||
1845 | push 2 |
||
1846 | pop ecx |
||
1847 | test al, 3 |
||
1848 | jnz @f |
||
1849 | dec ecx |
||
1850 | @@: |
||
1851 | push 26 |
||
1852 | pop eax |
||
1853 | mov bl, 2 |
||
1854 | mov edx, con.kbd_layout |
||
1855 | int 0x40 |
||
1856 | pop edx eax |
||
1857 | mov dh, [con.kbd_layout+edx] |
||
1858 | test al, 0xC |
||
1859 | jz @f |
||
1860 | sub dh, 0x60 |
||
1861 | jmp @f |
||
1862 | .extended: |
||
1863 | mov dh, 0 ; no ASCII code |
||
1864 | @@: |
||
1865 | ; dh contains ASCII-code; now convert scancode to extended key code |
||
1866 | mov ecx, con.extended_alt |
||
1867 | test al, 0x30 |
||
1868 | jnz .xlat |
||
1869 | mov ecx, con.extended_shift |
||
1870 | test al, 3 |
||
1871 | jnz .xlat |
||
1872 | mov ecx, con.extended_ctrl |
||
1873 | test al, 0xC |
||
1874 | jnz .xlat |
||
1875 | xchg dl, dh |
||
1876 | cmp dh, 0x57 |
||
1877 | jz @f |
||
1878 | cmp dh, 0x58 |
||
1879 | jnz .gotcode |
||
1880 | @@: |
||
1881 | add dh, 0x85-0x57 |
||
1882 | jmp .gotcode |
||
1883 | .xlat: |
||
1884 | movzx eax, dl |
||
1885 | mov dl, dh |
||
1886 | mov dh, [eax+ecx] |
||
1887 | .gotcode: |
||
1888 | test dh, dh |
||
1889 | jz con.msg_loop |
||
1890 | cmp dh, 0x94 |
||
1891 | jnz @f |
||
1892 | mov dl, 0 |
||
1893 | @@: |
||
1894 | ; dx contains full keycode |
||
1895 | cmp [con.bGetchRequested], 0 |
||
1896 | jz @f |
||
1897 | mov [con.entered_char], dx |
||
1898 | jmp con.msg_loop |
||
1899 | @@: |
||
1900 | mov eax, [con.input_end] |
||
1901 | mov ecx, eax |
||
1902 | add eax, 2 |
||
1903 | cmp eax, con.input_buffer_end |
||
1904 | jnz @f |
||
1905 | mov eax, con.input_buffer |
||
1906 | @@: |
||
1907 | cmp eax, [con.input_start] |
||
1908 | jnz @f |
||
1909 | ; buffer overflow, make beep and continue |
||
1910 | push 55 |
||
1911 | pop eax |
||
1912 | mov ebx, eax |
||
1913 | mov esi, con.beep |
||
1914 | int 0x40 |
||
1915 | jmp con.msg_loop |
||
1916 | @@: |
||
1917 | mov [ecx], dx |
||
1918 | mov [con.input_end], eax |
||
1919 | jmp con.msg_loop |
||
1920 | con.ipc: |
||
1921 | movzx eax, byte [con.ipc_buf+0x10] |
||
1922 | mov byte [con.ipc_buf+4], 8 |
||
1923 | mov byte [con.ipc_buf+0x10], 0 |
||
1924 | dec eax |
||
1925 | jz con.thread_exit |
||
1926 | dec eax |
||
1927 | jz con.set_title |
||
1928 | dec eax |
||
1929 | jz con.redraw_image |
||
1930 | dec eax |
||
1931 | jz con.getch |
||
1932 | jmp con.msg_loop |
||
1933 | con.set_title: |
||
1934 | push 71 |
||
1935 | pop eax |
||
1936 | push 1 |
||
1937 | pop ebx |
||
1938 | mov ecx, [con.title] |
||
1939 | int 0x40 |
||
1940 | jmp con.msg_loop |
||
1941 | con.redraw_image: |
||
1942 | call con.data2image |
||
1943 | call con.draw_image |
||
1944 | jmp con.msg_loop |
||
1945 | con.getch: |
||
1946 | mov eax, [con.input_start] |
||
1947 | cmp eax, [con.input_end] |
||
1948 | jz .noinput |
||
1949 | mov ecx, [eax] |
||
1950 | mov [con.entered_char], cx |
||
1951 | inc eax |
||
1952 | inc eax |
||
1953 | cmp eax, con.input_buffer_end |
||
1954 | jnz @f |
||
1955 | mov eax, con.input_buffer |
||
1956 | @@: |
||
1957 | mov [con.input_start], eax |
||
1958 | jmp con.msg_loop |
||
1959 | .noinput: |
||
1960 | mov [con.bGetchRequested], 1 |
||
1961 | jmp con.msg_loop |
||
1962 | con.mouse: |
||
1963 | xor eax, eax |
||
1964 | xchg eax, dword [con.bUpPressed] |
||
1965 | mov dword [con.bUpPressed_saved], eax |
||
1966 | push 37 |
||
1967 | pop eax |
||
1968 | push 2 |
||
1969 | pop ebx |
||
1970 | int 0x40 |
||
1971 | test al, 1 |
||
1972 | jnz @f |
||
1973 | cmp [con.vscroll_pt], -1 |
||
1974 | jz .redraw_if_needed |
||
1975 | or [con.vscroll_pt], -1 |
||
1976 | .redraw_if_needed: |
||
1977 | cmp dword [con.bUpPressed_saved], 0 |
||
1978 | jnz con.redraw_image |
||
1979 | jmp con.msg_loop |
||
1980 | @@: |
||
1981 | mov al, 37 |
||
1982 | dec ebx |
||
1983 | int 0x40 |
||
1984 | movsx ebx, ax |
||
1985 | sar eax, 16 |
||
1986 | cmp [con.vscroll_pt], -1 |
||
1987 | jnz .vscrolling |
||
1988 | test ebx, ebx |
||
1989 | js .redraw_if_needed |
||
1990 | sub ax, [con.data_width] |
||
1991 | jb .redraw_if_needed |
||
1992 | cmp eax, con.vscroll_width |
||
1993 | jae .redraw_if_needed |
||
1994 | cmp ebx, con.vscroll_btn_height |
||
1995 | jb .up |
||
1996 | sub bx, [con.data_height] |
||
1997 | jae .redraw_if_needed |
||
1998 | cmp bx, -con.vscroll_btn_height |
||
1999 | jge .down |
||
2000 | add bx, [con.data_height] |
||
2001 | sub bx, word [con.vscrollbar_pos] |
||
2002 | jl .vscroll_up |
||
2003 | cmp bx, word [con.vscrollbar_size] |
||
2004 | jl .vscroll |
||
2005 | .vscroll_down: |
||
2006 | cmp [con.bScrollingDown_saved], 0 |
||
2007 | jz .vscroll_down_first |
||
2008 | cmp [con.bScrollingDown_saved], 1 |
||
2009 | jz .vscroll_down_wasfirst |
||
2010 | mov [con.bScrollingDown], 2 |
||
2011 | .vscroll_down_do: |
||
2012 | mov eax, [con.wnd_ypos] |
||
2013 | add eax, [con.wnd_height] |
||
2014 | dec eax |
||
2015 | mov ebx, [con.scr_height] |
||
2016 | sub ebx, [con.wnd_height] |
||
2017 | cmp eax, ebx |
||
2018 | jb @f |
||
2019 | mov eax, ebx |
||
2020 | @@: |
||
2021 | mov [con.wnd_ypos], eax |
||
2022 | jmp con.redraw_image |
||
2023 | .vscroll_down_first: |
||
2024 | push 26 |
||
2025 | pop eax |
||
2026 | push 9 |
||
2027 | pop ebx |
||
2028 | int 0x40 |
||
2029 | mov [con.scroll_down_first_time], eax |
||
2030 | mov [con.bScrollingDown], 1 |
||
2031 | jmp .vscroll_down_do |
||
2032 | .vscroll_down_wasfirst: |
||
2033 | push 26 |
||
2034 | pop eax |
||
2035 | push 9 |
||
2036 | pop ebx |
||
2037 | int 0x40 |
||
2038 | sub eax, [con.scroll_down_first_time] |
||
2039 | cmp eax, 25 |
||
2040 | jb @f |
||
2041 | mov [con.bScrollingDown], 2 |
||
2042 | jmp .vscroll_down_do |
||
2043 | @@: |
||
2044 | mov [con.bScrollingDown], 1 |
||
2045 | jmp con.msg_loop |
||
2046 | .vscroll_up: |
||
2047 | cmp [con.bScrollingUp_saved], 0 |
||
2048 | jz .vscroll_up_first |
||
2049 | cmp [con.bScrollingUp_saved], 1 |
||
2050 | jz .vscroll_up_wasfirst |
||
2051 | mov [con.bScrollingUp], 2 |
||
2052 | .vscroll_up_do: |
||
2053 | mov eax, [con.wnd_ypos] |
||
2054 | inc eax |
||
2055 | sub eax, [con.wnd_height] |
||
2056 | jns @f |
||
2057 | xor eax, eax |
||
2058 | @@: |
||
2059 | mov [con.wnd_ypos], eax |
||
2060 | jmp con.redraw_image |
||
2061 | .vscroll_up_first: |
||
2062 | push 26 |
||
2063 | pop eax |
||
2064 | push 9 |
||
2065 | pop ebx |
||
2066 | int 0x40 |
||
2067 | mov [con.scroll_up_first_time], eax |
||
2068 | mov [con.bScrollingUp], 1 |
||
2069 | jmp .vscroll_up_do |
||
2070 | .vscroll_up_wasfirst: |
||
2071 | push 26 |
||
2072 | pop eax |
||
2073 | push 9 |
||
2074 | pop ebx |
||
2075 | int 0x40 |
||
2076 | sub eax, [con.scroll_up_first_time] |
||
2077 | cmp eax, 25 |
||
2078 | jb @f |
||
2079 | mov [con.bScrollingUp], 2 |
||
2080 | jmp .vscroll_up_do |
||
2081 | @@: |
||
2082 | mov [con.bScrollingUp], 1 |
||
2083 | jmp con.msg_loop |
||
2084 | .up: |
||
2085 | cmp [con.bUpPressed_saved], 0 |
||
2086 | jz .up_first |
||
2087 | cmp [con.bUpPressed_saved], 1 |
||
2088 | jz .up_wasfirst |
||
2089 | mov [con.bUpPressed], 2 |
||
2090 | .up_do: |
||
2091 | mov eax, [con.wnd_ypos] |
||
2092 | dec eax |
||
2093 | js @f |
||
2094 | mov [con.wnd_ypos], eax |
||
2095 | @@: |
||
2096 | jmp con.redraw_image |
||
2097 | .up_first: |
||
2098 | push 26 |
||
2099 | pop eax |
||
2100 | push 9 |
||
2101 | pop ebx |
||
2102 | int 0x40 |
||
2103 | mov [con.up_first_time], eax |
||
2104 | mov [con.bUpPressed], 1 |
||
2105 | jmp .up_do |
||
2106 | .up_wasfirst: |
||
2107 | push 26 |
||
2108 | pop eax |
||
2109 | push 9 |
||
2110 | pop ebx |
||
2111 | int 0x40 |
||
2112 | sub eax, [con.up_first_time] |
||
2113 | cmp eax, 25 |
||
2114 | jb @f |
||
2115 | mov [con.bUpPressed], 2 |
||
2116 | jmp .up_do |
||
2117 | @@: |
||
2118 | mov [con.bUpPressed], 1 |
||
2119 | jmp con.msg_loop |
||
2120 | .down: |
||
2121 | cmp [con.bDownPressed_saved], 0 |
||
2122 | jz .down_first |
||
2123 | cmp [con.bDownPressed_saved], 1 |
||
2124 | jz .down_wasfirst |
||
2125 | mov [con.bDownPressed], 2 |
||
2126 | .down_do: |
||
2127 | mov eax, [con.scr_height] |
||
2128 | sub eax, [con.wnd_height] |
||
2129 | jbe con.redraw_image |
||
2130 | cmp [con.wnd_ypos], eax |
||
2131 | jae con.redraw_image |
||
2132 | inc [con.wnd_ypos] |
||
2133 | jmp con.redraw_image |
||
2134 | .down_first: |
||
2135 | push 26 |
||
2136 | pop eax |
||
2137 | push 9 |
||
2138 | pop ebx |
||
2139 | int 0x40 |
||
2140 | mov [con.down_first_time], eax |
||
2141 | mov [con.bDownPressed], 1 |
||
2142 | jmp .down_do |
||
2143 | .down_wasfirst: |
||
2144 | push 26 |
||
2145 | pop eax |
||
2146 | push 9 |
||
2147 | pop ebx |
||
2148 | int 0x40 |
||
2149 | sub eax, [con.down_first_time] |
||
2150 | cmp eax, 25 |
||
2151 | jb @f |
||
2152 | mov [con.bDownPressed], 2 |
||
2153 | jmp .down_do |
||
2154 | @@: |
||
2155 | mov [con.bDownPressed], 1 |
||
2156 | jmp con.msg_loop |
||
2157 | .vscroll: |
||
2158 | mov [con.vscroll_pt], ebx |
||
2159 | call con.draw_image |
||
2160 | jmp con.msg_loop |
||
2161 | .vscrolling: |
||
2162 | sub ebx, [con.vscroll_pt] |
||
2163 | sub ebx, con.vscroll_btn_height |
||
2164 | jge @f |
||
2165 | xor ebx, ebx |
||
2166 | @@: |
||
2167 | movzx eax, [con.data_height] |
||
2168 | sub eax, 2*con.vscroll_btn_height |
||
2169 | sub eax, [con.vscrollbar_size] |
||
2170 | cmp ebx, eax |
||
2171 | jb @f |
||
2172 | lea ebx, [eax-1] |
||
2173 | @@: |
||
2174 | xchg eax, ebx |
||
2175 | mov edx, [con.scr_height] |
||
2176 | sub edx, [con.wnd_height] |
||
2177 | inc edx |
||
2178 | mul edx |
||
2179 | div ebx |
||
2180 | cmp [con.wnd_ypos], eax |
||
2181 | jz con.msg_loop |
||
2182 | mov [con.wnd_ypos], eax |
||
2183 | jmp con.redraw_image |
||
2184 | |||
2185 | con.draw_window: |
||
2186 | push 12 |
||
2187 | pop eax |
||
2188 | xor ebx, ebx |
||
2189 | inc ebx |
||
2190 | int 0x40 |
||
2191 | mov al, 48 |
||
2192 | mov bl, 4 |
||
2193 | int 0x40 |
||
2194 | mov ebx, [con.def_wnd_x-2] |
||
2195 | mov bx, word [con.wnd_width] |
||
2196 | imul bx, font_width |
||
2197 | add bx, 5+5-1 |
||
2198 | mov ecx, [con.def_wnd_y-2] |
||
2199 | mov cx, word [con.wnd_height] |
||
2200 | imul cx, font_height |
||
2201 | lea ecx, [ecx+eax+5-1] |
||
2530 | leency | 2202 | mov edx, 0x74000000 |
836 | diamond | 2203 | mov edi, [con.title] |
2204 | ; place for scrollbar |
||
2205 | mov eax, [con.wnd_height] |
||
2206 | cmp eax, [con.scr_height] |
||
2207 | jae @f |
||
2208 | add ebx, con.vscroll_width |
||
2209 | @@: |
||
2210 | xor eax, eax |
||
2211 | int 0x40 |
||
3034 | leency | 2212 | ;Leency{ |
2213 | mov eax,9 |
||
2214 | mov ebx,process_info_buffer |
||
2215 | mov ecx,-1 |
||
2216 | int 0x40 |
||
2217 | mov eax,[ebx+70] |
||
2218 | mov [window_status],eax |
||
3686 | hidnplayr | 2219 | test [window_status],100b ; window is rolled up |
3034 | leency | 2220 | jnz .exit |
2221 | test [window_status],10b ; window is minimized to panel |
||
2222 | jnz .exit |
||
2223 | ;}Leency - I'm in diamond code... |
||
836 | diamond | 2224 | call con.draw_image |
3034 | leency | 2225 | |
2226 | .exit: |
||
836 | diamond | 2227 | push 12 |
2228 | pop eax |
||
2229 | push 2 |
||
2230 | pop ebx |
||
2231 | int 0x40 |
||
3686 | hidnplayr | 2232 | |
836 | diamond | 2233 | ret |
2234 | |||
2235 | con.draw_image: |
||
2236 | xor edx, edx |
||
2237 | mov ecx, [con.wnd_width] |
||
2238 | imul ecx, font_width |
||
2239 | mov [con.data_width], cx |
||
2240 | shl ecx, 16 |
||
2241 | mov cx, word [con.wnd_height] |
||
2242 | imul cx, font_height |
||
2243 | mov [con.data_height], cx |
||
2244 | mov ebx, [con.image] |
||
2245 | push 65 |
||
2246 | pop eax |
||
2247 | xor ebp, ebp |
||
2248 | mov edi, con.colors |
||
2249 | push 8 |
||
2250 | pop esi |
||
2251 | int 0x40 |
||
2252 | mov al, 7 |
||
2253 | mov edx, [con.wnd_height] |
||
2254 | cmp edx, [con.scr_height] |
||
2255 | jae .skip_vscroll |
||
2256 | push ecx |
||
2257 | mov edx, ecx |
||
2258 | xor dx, dx |
||
2259 | mov ebx, con.vscroll_btn3 |
||
2260 | cmp [con.bUpPressed], 0 |
||
2261 | jnz @f |
||
2262 | mov ebx, con.vscroll_btn1 |
||
2263 | @@: |
||
2264 | mov ecx, con.vscroll_width*65536 + con.vscroll_btn_height |
||
2265 | int 0x40 |
||
2266 | pop edx |
||
2267 | sub dx, con.vscroll_btn_height |
||
2268 | mov ebx, con.vscroll_btn4 |
||
2269 | cmp [con.bDownPressed], 0 |
||
2270 | jnz @f |
||
2271 | mov ebx, con.vscroll_btn2 |
||
2272 | @@: |
||
2273 | int 0x40 |
||
2274 | push edx |
||
2275 | ; Вычисляем высоту бегунка |
||
2276 | mov ax, dx |
||
2277 | sub eax, con.vscroll_btn_height |
||
2278 | mov ecx, eax |
||
2279 | mul [con.wnd_height] |
||
2280 | div [con.scr_height] |
||
2281 | cmp eax, 5 |
||
2282 | jae @f |
||
2283 | mov al, 5 |
||
2284 | @@: |
||
2285 | ; eax = высота бегунка. Вычисляем положение бегунка |
||
2286 | mov [con.vscrollbar_size], eax |
||
2287 | xchg eax, ecx |
||
2288 | sub eax, ecx |
||
2289 | mul [con.wnd_ypos] |
||
2290 | mov ebx, [con.scr_height] |
||
2291 | sub ebx, [con.wnd_height] |
||
2292 | div ebx |
||
2293 | pop edx |
||
2294 | push edx |
||
2295 | ; ecx = высота бегунка, eax = положение |
||
2296 | add eax, con.vscroll_btn_height |
||
2297 | mov [con.vscrollbar_pos], eax |
||
2298 | mov ebx, con.vscroll_bgr2 |
||
2299 | cmp [con.bScrollingUp], 0 |
||
2300 | jnz @f |
||
2301 | mov ebx, con.vscroll_bgr1 |
||
2302 | @@: |
||
2303 | mov ecx, con.vscroll_width*65536 + con.vscroll_bgr_height |
||
2304 | push eax |
||
2305 | push 7 |
||
2306 | pop eax |
||
2307 | mov dx, con.vscroll_btn_height |
||
2308 | call .vpattern |
||
2309 | mov dx, word [con.vscrollbar_pos] |
||
2310 | add dx, word [con.vscrollbar_size] |
||
2311 | mov cx, con.vscroll_bgr_height |
||
2312 | mov ebx, con.vscroll_bgr2 |
||
2313 | cmp [con.bScrollingDown], 0 |
||
2314 | jnz @f |
||
2315 | mov ebx, con.vscroll_bgr1 |
||
2316 | @@: |
||
2317 | call .vpattern |
||
2318 | mov ecx, [con.vscrollbar_pos] |
||
2319 | mov dx, cx |
||
2320 | add ecx, [con.vscrollbar_size] |
||
2321 | sub ecx, con.vscroll_bar_height3 |
||
2322 | push ecx |
||
2323 | mov ebx, con.vscroll_bar1 |
||
2324 | mov ecx, con.vscroll_width*65536 + con.vscroll_bar_height1 |
||
2325 | int 0x40 |
||
2326 | add dx, cx |
||
2327 | mov cx, con.vscroll_bar_height2 |
||
2328 | mov ebx, con.vscroll_bar2 |
||
2329 | call .vpattern |
||
2330 | mov ebx, con.vscroll_bar3 |
||
2331 | mov cx, con.vscroll_bar_height3 |
||
2332 | int 0x40 |
||
2333 | .skip_vscroll: |
||
2334 | ret |
||
2335 | |||
2336 | .vpattern: |
||
2337 | push edx |
||
2338 | add dx, cx |
||
2339 | cmp dx, [esp+8] |
||
2340 | pop edx |
||
2341 | jbe @f |
||
2342 | mov cx, [esp+4] |
||
2343 | sub cx, dx |
||
2344 | jz .ret |
||
2345 | @@: |
||
2346 | int 0x40 |
||
2347 | add dx, cx |
||
2348 | cmp dx, [esp+4] |
||
2349 | jb .vpattern |
||
2350 | .ret: |
||
2351 | ret 4 |
||
2352 | |||
2353 | align 4 |
||
2354 | con.colors dd 0x000000, 0x000080, 0x008000, 0x008080 |
||
2355 | dd 0x800000, 0x800080, 0x808000, 0xC0C0C0 |
||
2356 | dd 0x808080, 0x0000FF, 0x00FF00, 0x00FFFF |
||
2357 | dd 0xFF0000, 0xFF00FF, 0xFFFF00, 0xFFFFFF |
||
2358 | |||
2359 | scan_has_ascii: |
||
2360 | dd 11011111111111111111111111111110b |
||
2361 | dd 00000010001111111111101111111111b |
||
2362 | dd 00000000000000000000000000000000b |
||
2363 | dd 0 |
||
2364 | |||
2365 | con.extended_alt: |
||
2366 | db 00h,01h,78h,79h,7Ah,7Bh,7Ch,7Dh,7Eh,7Fh,80h,81h,82h,83h,0Eh,0A5h |
||
2367 | db 10h,11h,12h,13h,14h,15h,16h,17h,18h,19h,1Ah,1Bh,1Ch,00h,1Eh,1Fh |
||
2368 | db 20h,21h,22h,23h,24h,25h,26h,27h,28h,29h,00h,2Bh,2Ch,2Dh,2Eh,2Fh |
||
2369 | db 30h,31h,32h,33h,34h,35h,00h,37h,00h,39h,00h,68h,69h,6Ah,6Bh,6Ch |
||
2370 | db 6Dh,6Eh,6Fh,70h,71h,00h,00h,97h,98h,99h,4Ah,9Bh,9Ch,9Dh,4Eh,9Fh |
||
2371 | db 0A0h,0A1h,0A2h,0A3h,00h,00h,00h,8Bh,8Ch,00h,00h,00h,00h,00h,00h,00h |
||
2372 | times 20h db 0 |
||
2373 | con.extended_ctrl: |
||
2374 | times 0Fh db %-1 |
||
2375 | db 0x94 |
||
2376 | times 2Bh db %-1 |
||
2377 | db 5Eh,5Fh,60h,61h,62h,63h,64h,65h,66h,67h,00h,00h |
||
2378 | db 77h,8Dh,84h,8Eh,73h,8Fh,74h,90h,75h,91h,76h,92h,93h,00h,00h,00h,89h,8Ah |
||
2379 | times 0x80-0x59 db 0 |
||
2380 | con.extended_shift: |
||
2381 | times 3Bh db %-1 |
||
2382 | db 54h,55h,56h,57h,58h,59h,5Ah,5Bh,5Ch,5Dh,00h,00h |
||
2383 | db 47h,48h,49h,4Ah,4Bh,4Ch,4Dh,4Eh,4Fh,50h,51h,52h,53h,00h,00h,00h,87h,88h |
||
2384 | times 0x80-0x59 db 0 |
||
2385 | |||
2386 | ; В текущей реализации значения по умолчанию таковы. |
||
2387 | ; В будущем они, возможно, будут считываться как параметры из ini-файла console.ini. |
||
2388 | con.def_wnd_width dd 80 |
||
2389 | con.def_wnd_height dd 25 |
||
2390 | con.def_scr_width dd 80 |
||
2391 | con.def_scr_height dd 300 |
||
2392 | con.def_wnd_x dd 200 |
||
2393 | con.def_wnd_y dd 50 |
||
2394 | |||
3034 | leency | 2395 | |
2396 | struc process_info |
||
2397 | { |
||
2398 | cpu_usage dd ? ; +0 |
||
2399 | window_stack_position dw ? ; +4 |
||
2400 | window_stack_value dw ? ; +6 |
||
2401 | dw ? ; +8 |
||
2402 | process_name rb 12 ; +10 |
||
2403 | memory_start dd ? ; +22 |
||
2404 | used_memory dd ? ; +26 |
||
2405 | PID dd ? ; +30 |
||
2406 | box.x dd ? ; +34 |
||
2407 | box.y dd ? ; +38 |
||
2408 | box.width dd ? ; +42 |
||
2409 | box.height dd ? ; +46 |
||
2410 | slot_state dw ? ; +50 |
||
2411 | dw ? ; +52 |
||
2412 | client_box.x dd ? ; +54 |
||
2413 | client_box.y dd ? ; +58 |
||
2414 | client_box.width dd ? ; +62 |
||
2415 | client_box.height dd ? ; +66 |
||
2416 | wnd_state db ? ; +70 |
||
2417 | rb (1024-71) |
||
2418 | } |
||
2419 | process_info_buffer process_info |
||
3686 | hidnplayr | 2420 | window_status rd 1 |
3034 | leency | 2421 | |
836 | diamond | 2422 | con.vscroll_pt dd -1 |
2423 | |||
2424 | align 16 |
||
2425 | EXPORTS: |
||
2426 | dd szStart, START |
||
1145 | diamond | 2427 | dd szVersion, 0x00020007 |
836 | diamond | 2428 | dd szcon_init, con_init |
2429 | dd szcon_write_asciiz, con_write_asciiz |
||
3686 | hidnplayr | 2430 | dd szcon_write_string, con_write_length |
836 | diamond | 2431 | dd szcon_printf, con_printf |
2432 | dd szcon_exit, con_exit |
||
2433 | dd szcon_get_flags, con_get_flags |
||
2434 | dd szcon_set_flags, con_set_flags |
||
2435 | dd szcon_kbhit, con_kbhit |
||
2436 | dd szcon_getch, con_getch |
||
2437 | dd szcon_getch2, con_getch2 |
||
2438 | dd szcon_gets, con_gets |
||
852 | diamond | 2439 | dd szcon_gets2, con_gets2 |
836 | diamond | 2440 | dd szcon_get_font_height, con_get_font_height |
2441 | dd szcon_get_cursor_height,con_get_cursor_height |
||
2442 | dd szcon_set_cursor_height,con_set_cursor_height |
||
853 | diamond | 2443 | dd szcon_cls, con_cls |
2444 | dd szcon_get_cursor_pos, con_get_cursor_pos |
||
2445 | dd szcon_set_cursor_pos, con_set_cursor_pos |
||
836 | diamond | 2446 | dd 0 |
2447 | |||
2448 | con_flags dd 7 |
||
2449 | con.cursor_height dd (15*font_height+50)/100 |
||
2450 | con.input_start dd con.input_buffer |
||
2451 | con.input_end dd con.input_buffer |
||
2452 | |||
2453 | con_esc_attr_n dd 0 |
||
2454 | con_esc_attrs dd 0,0,0,0 |
||
2455 | con_esc db 0 |
||
2456 | con_sci db 0 |
||
2457 | |||
2458 | con.entered_char dw -1 |
||
2459 | con.bGetchRequested db 0 |
||
2460 | con.bWasE0 db 0 |
||
2461 | |||
2462 | szStart db 'START',0 |
||
2463 | |||
2464 | szcon_init db 'con_init',0 |
||
2465 | szcon_write_asciiz db 'con_write_asciiz',0 |
||
3686 | hidnplayr | 2466 | szcon_write_string db 'con_write_string',0 |
836 | diamond | 2467 | szcon_printf db 'con_printf',0 |
2468 | szcon_exit db 'con_exit',0 |
||
2469 | szVersion db 'version',0 |
||
2470 | szcon_get_flags db 'con_get_flags',0 |
||
2471 | szcon_set_flags db 'con_set_flags',0 |
||
2472 | szcon_kbhit db 'con_kbhit',0 |
||
2473 | szcon_getch db 'con_getch',0 |
||
2474 | szcon_getch2 db 'con_getch2',0 |
||
2475 | szcon_gets db 'con_gets',0 |
||
852 | diamond | 2476 | szcon_gets2 db 'con_gets2',0 |
836 | diamond | 2477 | szcon_get_font_height db 'con_get_font_height',0 |
2478 | szcon_get_cursor_height db 'con_get_cursor_height',0 |
||
2479 | szcon_set_cursor_height db 'con_set_cursor_height',0 |
||
853 | diamond | 2480 | szcon_cls db 'con_cls',0 |
2481 | szcon_get_cursor_pos db 'con_get_cursor_pos',0 |
||
2482 | szcon_set_cursor_pos db 'con_set_cursor_pos',0 |
||
836 | diamond | 2483 | |
2484 | con.thread_err db 'Cannot create console thread!',13,10,0 |
||
2485 | con.nomem_err db 'Not enough memory!',13,10,0 |
||
2486 | con.aFinished db ' [Finished]',0 |
||
2487 | con.aNull db '(null)',0 |
||
2488 | con.beep db 0x90, 0x3C, 0x00 |
||
2489 | con.ipc_buf dd 0,8,0,0 |
||
2490 | db 0 |
||
2491 | |||
2492 | section '.data' data readable writable align 16 |
||
2493 | |||
2494 | con.finished_title rb 256 |
||
2495 | |||
2496 | con.cur_x rd 1 |
||
2497 | con.cur_y rd 1 |
||
2498 | con.wnd_xpos rd 1 |
||
2499 | con.wnd_ypos rd 1 |
||
2500 | |||
2501 | con.wnd_width rd 1 |
||
2502 | con.wnd_height rd 1 |
||
2503 | con.scr_width rd 1 |
||
2504 | con.scr_height rd 1 |
||
2505 | con.title rd 1 |
||
2506 | con.data rd 1 |
||
2507 | con.image rd 1 |
||
2508 | con.console_tid rd 1 |
||
2509 | con.data_width rw 1 |
||
2510 | con.data_height rw 1 |
||
2511 | con.vscrollbar_size rd 1 |
||
2512 | con.vscrollbar_pos rd 1 |
||
2513 | con.up_first_time rd 1 |
||
2514 | con.down_first_time rd 1 |
||
2515 | con.scroll_up_first_time rd 1 |
||
2516 | con.scroll_down_first_time rd 1 |
||
2517 | con.bUpPressed_saved rb 1 |
||
2518 | con.bDownPressed_saved rb 1 |
||
2519 | con.bScrollingUp_saved rb 1 |
||
2520 | con.bScrollingDown_saved rb 1 |
||
2521 | |||
2522 | con.input_buffer rw 128 |
||
2523 | con.input_buffer_end = $ |
||
2524 | |||
2525 | con.kbd_layout rb 128 |
||
2526 | |||
2527 | ; 1 = exit, 2 = set title, 3 = redraw, 4 = getch |
||
2528 | con.thread_op rb 1 |
||
2529 | con.bUpPressed rb 1 |
||
2530 | con.bDownPressed rb 1 |
||
2531 | con.bScrollingUp rb 1 |
||
2532 | con.bScrollingDown rb 1 |
||
2533 | |||
2534 | con.stack rb 1024 |
||
2535 | con.stack_top = $ |