Rev 4384 | Rev 4600 | 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 |
||
3886 | hidnplayr | 791 | cmp al, '?' ; DEC private mode (DECSET/DECRST sequences) |
792 | je .questionmark |
||
836 | diamond | 793 | cmp al, ';' |
794 | jz .next_arg |
||
795 | cmp al, '0' |
||
796 | jb .not_digit |
||
797 | cmp al, '9' |
||
798 | ja .not_digit |
||
799 | push eax ecx edx |
||
800 | sub al, '0' |
||
801 | movzx eax, al |
||
802 | mov ecx, [con_esc_attr_n] |
||
803 | mov edx, [con_esc_attrs+(ecx-1)*4] |
||
804 | lea edx, [edx*5] |
||
805 | lea edx, [edx*2+eax] |
||
806 | mov [con_esc_attrs+(ecx-1)*4], edx |
||
807 | pop edx ecx eax |
||
808 | ret |
||
3886 | hidnplayr | 809 | .questionmark: |
810 | push ecx |
||
811 | mov ecx, [con_esc_attr_n] |
||
812 | mov dword[con_esc_attrs+(ecx-1)*4], 0xffffffff |
||
813 | pop ecx |
||
836 | diamond | 814 | .next_arg: |
815 | push eax |
||
816 | mov eax, [con_esc_attr_n] |
||
817 | inc eax |
||
818 | cmp al, 4 |
||
819 | jbe @f |
||
820 | dec eax |
||
821 | @@: |
||
822 | mov [con_esc_attr_n], eax |
||
823 | and [con_esc_attrs+(eax-1)*4], 0 |
||
824 | pop eax |
||
825 | ret |
||
826 | .not_digit: |
||
827 | mov [con_esc], 0 |
||
828 | mov [con_sci], 0 ; in any case, leave Esc mode |
||
853 | diamond | 829 | cmp al, 'J' |
3885 | hidnplayr | 830 | jz .clear |
853 | diamond | 831 | cmp al, 'H' |
832 | jz .setcursor |
||
833 | cmp al, 'f' |
||
834 | jz .setcursor |
||
836 | diamond | 835 | cmp al, 'm' |
836 | jz .set_attr |
||
853 | diamond | 837 | cmp al, 'A' |
838 | jz .cursor_up |
||
839 | cmp al, 'B' |
||
840 | jz .cursor_down |
||
841 | cmp al, 'C' |
||
842 | jz .cursor_right |
||
843 | cmp al, 'D' |
||
844 | jz .cursor_left |
||
3886 | hidnplayr | 845 | cmp al, 'l' |
846 | je .dec_rst |
||
847 | cmp al, 'h' |
||
848 | je .dec_set |
||
836 | diamond | 849 | ret ; simply skip unknown sequences |
3886 | hidnplayr | 850 | |
851 | .dec_rst: |
||
852 | mov eax, [con_esc_attrs] |
||
853 | cmp eax, 0xffffffff |
||
854 | jne .no_dec_rst |
||
855 | mov eax, [con_esc_attrs+4] |
||
856 | cmp eax, 25 |
||
857 | je .hide_cursor |
||
858 | .no_dec_rst: |
||
859 | ret |
||
860 | .hide_cursor: |
||
861 | mov [con.cursor_height], 0 |
||
862 | ret |
||
863 | |||
864 | .dec_set: |
||
865 | mov eax, [con_esc_attrs] |
||
866 | cmp eax, 0xffffffff |
||
867 | jne .no_dec_set |
||
868 | mov eax, [con_esc_attrs+4] |
||
869 | cmp eax, 25 |
||
870 | je .show_cursor |
||
871 | .no_dec_set: |
||
872 | ret |
||
873 | |||
874 | .show_cursor: |
||
875 | mov [con.cursor_height], (15*font_height+50)/100 ; default height |
||
876 | ret |
||
3885 | hidnplayr | 877 | .clear: |
878 | mov eax, [con_esc_attrs] |
||
879 | test eax, eax |
||
880 | jz .clear_till_end_of_screen ; |
||
881 | dec eax |
||
882 | jz .clear_till_start_of_screen ; |
||
883 | dec eax |
||
884 | je .cls ; |
||
885 | ret ; unknown sequence |
||
886 | |||
887 | .clear_till_end_of_screen: |
||
888 | push edi ecx |
||
889 | mov ecx, [con.scr_width] |
||
890 | imul ecx, [con.scr_height] |
||
891 | |||
892 | mov edi, [con.cur_y] |
||
893 | imul edi, [con.scr_width] |
||
894 | add edi, [con.cur_x] |
||
895 | |||
896 | sub ecx, edi |
||
897 | shl edi, 1 |
||
898 | add edi, [con.data] |
||
899 | mov ah, byte[con_flags] |
||
900 | mov al, ' ' |
||
901 | rep stosw |
||
902 | |||
903 | and [con.cur_x], 0 |
||
904 | and [con.cur_y], 0 |
||
905 | pop ecx edi |
||
906 | ret |
||
907 | |||
908 | .clear_till_start_of_screen: |
||
909 | push edi ecx |
||
910 | mov ecx, [con.cur_y] |
||
911 | imul ecx, [con.scr_width] |
||
912 | add ecx, [con.cur_x] |
||
913 | mov edi, [con.data] |
||
914 | mov ah, byte[con_flags] |
||
915 | mov al, ' ' |
||
916 | rep stosw |
||
917 | pop ecx edi |
||
918 | ret |
||
919 | |||
920 | .cls: ; clear screen completely |
||
853 | diamond | 921 | push ecx |
922 | and [con.cur_x], 0 |
||
923 | and [con.cur_y], 0 |
||
924 | mov edi, [con.data] |
||
925 | push edi |
||
926 | mov ecx, [con.scr_width] |
||
927 | imul ecx, [con.scr_height] |
||
928 | mov ax, 0720h |
||
929 | rep stosw |
||
930 | pop edi ecx |
||
931 | .nosetcursor: |
||
932 | ret |
||
933 | .setcursor: |
||
934 | cmp [con_esc_attr_n], 2 |
||
3686 | hidnplayr | 935 | je @f |
936 | xor eax, eax |
||
3688 | hidnplayr | 937 | mov [con.cur_x], eax |
938 | mov [con.cur_y], eax |
||
939 | jmp .j_get_data |
||
3686 | hidnplayr | 940 | @@: |
853 | diamond | 941 | mov eax, [con_esc_attrs] |
942 | cmp eax, [con.scr_width] |
||
943 | jae @f |
||
944 | mov [con.cur_x], eax |
||
945 | @@: |
||
946 | mov eax, [con_esc_attrs+4] |
||
947 | cmp eax, [con.scr_height+4] |
||
948 | jae @f |
||
949 | mov [con.cur_y], eax |
||
950 | .j_get_data: |
||
951 | jmp con.get_data_ptr |
||
952 | .cursor_up: |
||
953 | cmp [con_esc_attr_n], 1 |
||
954 | jnz .nosetcursor |
||
955 | mov eax, [con.cur_y] |
||
956 | sub eax, [con_esc_attrs] |
||
957 | jnc @f |
||
958 | xor eax, eax |
||
959 | @@: |
||
960 | mov [con.cur_y], eax |
||
961 | jmp .j_get_data |
||
962 | .cursor_down: |
||
963 | cmp [con_esc_attr_n], 1 |
||
964 | jnz .nosetcursor |
||
965 | mov eax, [con.cur_y] |
||
966 | add eax, [con_esc_attrs] |
||
967 | cmp eax, [con.scr_height] |
||
968 | jb @f |
||
969 | mov eax, [con.scr_height] |
||
970 | dec eax |
||
971 | @@: |
||
972 | mov [con.cur_y], eax |
||
973 | jmp .j_get_data |
||
974 | .cursor_right: |
||
975 | cmp [con_esc_attr_n], 1 |
||
976 | jnz .nosetcursor |
||
977 | mov eax, [con.cur_x] |
||
978 | add eax, [con_esc_attrs] |
||
979 | cmp eax, [con.scr_width] |
||
980 | jb @f |
||
981 | mov eax, [con.scr_width] |
||
982 | dec eax |
||
983 | @@: |
||
984 | mov [con.cur_x], eax |
||
985 | jmp .j_get_data |
||
986 | .cursor_left: |
||
987 | cmp [con_esc_attr_n], 1 |
||
988 | jnz .nosetcursor |
||
989 | mov eax, [con.cur_x] |
||
990 | sub eax, [con_esc_attrs] |
||
991 | jnc @f |
||
992 | xor eax, eax |
||
993 | @@: |
||
994 | mov [con.cur_x], eax |
||
995 | jmp .j_get_data |
||
836 | diamond | 996 | .set_attr: |
997 | push eax ecx edx |
||
998 | xor ecx, ecx |
||
999 | .set_one_attr: |
||
1000 | mov eax, [con_esc_attrs+ecx*4] |
||
1001 | cmp al, 0 |
||
1002 | jz .attr_normal |
||
1003 | cmp al, 1 |
||
1004 | jz .attr_bold |
||
1005 | cmp al, 5 |
||
1006 | jz .attr_bgr_bold |
||
1007 | cmp al, 7 |
||
1008 | jz .attr_reversed |
||
3690 | hidnplayr | 1009 | |
836 | diamond | 1010 | xor edx, edx |
1011 | cmp al, 30 |
||
1012 | jz .attr_color |
||
1013 | mov dl, 4 |
||
1014 | cmp al, 31 |
||
1015 | jz .attr_color |
||
1016 | mov dl, 2 |
||
1017 | cmp al, 32 |
||
1018 | jz .attr_color |
||
1019 | mov dl, 6 |
||
1020 | cmp al, 33 |
||
1021 | jz .attr_color |
||
1022 | mov dl, 1 |
||
1023 | cmp al, 34 |
||
1024 | jz .attr_color |
||
1025 | mov dl, 5 |
||
1026 | cmp al, 35 |
||
1027 | jz .attr_color |
||
1028 | mov dl, 3 |
||
1029 | cmp al, 36 |
||
1030 | jz .attr_color |
||
1031 | mov dl, 7 |
||
1032 | cmp al, 37 |
||
1033 | jz .attr_color |
||
3690 | hidnplayr | 1034 | |
836 | diamond | 1035 | xor edx, edx |
1036 | cmp al, 40 |
||
1037 | jz .attr_bgr_color |
||
1038 | mov dl, 0x40 |
||
1039 | cmp al, 41 |
||
1040 | jz .attr_bgr_color |
||
1041 | mov dl, 0x20 |
||
1042 | cmp al, 42 |
||
1043 | jz .attr_bgr_color |
||
1044 | mov dl, 0x60 |
||
1045 | cmp al, 43 |
||
1046 | jz .attr_bgr_color |
||
1047 | mov dl, 0x10 |
||
1048 | cmp al, 44 |
||
1049 | jz .attr_bgr_color |
||
1050 | mov dl, 0x50 |
||
1051 | cmp al, 45 |
||
1052 | jz .attr_bgr_color |
||
1053 | mov dl, 0x30 |
||
1054 | cmp al, 46 |
||
1055 | jz .attr_bgr_color |
||
1056 | mov dl, 0x70 |
||
1057 | cmp al, 47 |
||
3690 | hidnplayr | 1058 | jz .attr_bgr_color |
1059 | |||
1060 | mov dl, 0x08 |
||
3692 | hidnplayr | 1061 | cmp al, 90 |
3690 | hidnplayr | 1062 | jz .attr_color |
1063 | mov dl, 4 + 8 |
||
3692 | hidnplayr | 1064 | cmp al, 91 |
3690 | hidnplayr | 1065 | jz .attr_color |
1066 | mov dl, 2 + 8 |
||
3692 | hidnplayr | 1067 | cmp al, 92 |
3690 | hidnplayr | 1068 | jz .attr_color |
1069 | mov dl, 6 + 8 |
||
3692 | hidnplayr | 1070 | cmp al, 93 |
3690 | hidnplayr | 1071 | jz .attr_color |
1072 | mov dl, 1 + 8 |
||
3692 | hidnplayr | 1073 | cmp al, 94 |
3690 | hidnplayr | 1074 | jz .attr_color |
1075 | mov dl, 5 + 8 |
||
3692 | hidnplayr | 1076 | cmp al, 95 |
3690 | hidnplayr | 1077 | jz .attr_color |
1078 | mov dl, 3 + 8 |
||
3692 | hidnplayr | 1079 | cmp al, 96 |
3690 | hidnplayr | 1080 | jz .attr_color |
1081 | mov dl, 7 + 8 |
||
3692 | hidnplayr | 1082 | cmp al, 97 |
3690 | hidnplayr | 1083 | jz .attr_color |
1084 | |||
1085 | mov dl, 0x80 |
||
1086 | cmp al, 100 |
||
1087 | jz .attr_bgr_color |
||
1088 | mov dl, 0x80 + 0x40 |
||
1089 | cmp al, 101 |
||
1090 | jz .attr_bgr_color |
||
1091 | mov dl, 0x80 + 0x20 |
||
1092 | cmp al, 102 |
||
1093 | jz .attr_bgr_color |
||
1094 | mov dl, 0x80 + 0x60 |
||
1095 | cmp al, 103 |
||
1096 | jz .attr_bgr_color |
||
1097 | mov dl, 0x80 + 0x10 |
||
1098 | cmp al, 104 |
||
1099 | jz .attr_bgr_color |
||
1100 | mov dl, 0x80 + 0x50 |
||
1101 | cmp al, 105 |
||
1102 | jz .attr_bgr_color |
||
1103 | mov dl, 0x80 + 0x30 |
||
1104 | cmp al, 106 |
||
1105 | jz .attr_bgr_color |
||
1106 | mov dl, 0x80 + 0x70 |
||
1107 | cmp al, 107 |
||
836 | diamond | 1108 | jnz .attr_continue |
3690 | hidnplayr | 1109 | |
836 | diamond | 1110 | .attr_bgr_color: |
1111 | mov eax, [con_flags] |
||
3690 | hidnplayr | 1112 | and al, 0x0F |
836 | diamond | 1113 | or al, dl |
1114 | mov [con_flags], eax |
||
1115 | jmp .attr_continue |
||
1116 | .attr_color: |
||
1117 | mov eax, [con_flags] |
||
3690 | hidnplayr | 1118 | and al, 0xF0 |
836 | diamond | 1119 | or al, dl |
1120 | mov [con_flags], eax |
||
1121 | jmp .attr_continue |
||
1122 | .attr_normal: |
||
1123 | mov byte [con_flags], 7 |
||
1124 | jmp .attr_continue |
||
1125 | .attr_reversed: |
||
1126 | mov byte [con_flags], 0x70 |
||
1127 | jmp .attr_continue |
||
1128 | .attr_bold: |
||
1129 | or byte [con_flags], 8 |
||
1130 | jmp .attr_continue |
||
1131 | .attr_bgr_bold: |
||
1132 | or byte [con_flags], 0x80 |
||
1133 | .attr_continue: |
||
1134 | inc ecx |
||
1135 | cmp ecx, [con_esc_attr_n] |
||
1136 | jb .set_one_attr |
||
1137 | pop edx ecx eax |
||
1138 | ret |
||
1139 | |||
1140 | con.newline: |
||
1141 | mov eax, [con.cur_y] |
||
1142 | inc eax |
||
1143 | mov [con.cur_y], eax |
||
1144 | cmp eax, [con.scr_height] |
||
1145 | jb @f |
||
1146 | call con.scr_scroll_up |
||
1147 | @@: |
||
1148 | call con.get_data_ptr |
||
1149 | ret |
||
1150 | |||
1151 | con.scr_scroll_up: |
||
1152 | pushad |
||
1153 | mov edi, [con.data] |
||
1154 | mov esi, edi |
||
1155 | add esi, [con.scr_width] |
||
1156 | add esi, [con.scr_width] |
||
1157 | dec [con.cur_y] |
||
1158 | mov ecx, [con.scr_height] |
||
1159 | dec ecx |
||
1160 | imul ecx, [con.scr_width] |
||
1161 | shr ecx, 1 |
||
1162 | rep movsd |
||
1163 | adc ecx, ecx |
||
1164 | rep movsw |
||
1165 | mov ax, 0x0720 |
||
1166 | mov ecx, [con.scr_width] |
||
1167 | rep stosw |
||
1168 | popad |
||
1169 | ret |
||
1170 | |||
1171 | con.data2image: |
||
1172 | pushad |
||
1173 | mov edi, [con.image] |
||
1174 | mov esi, [con.data] |
||
1175 | mov eax, [con.wnd_ypos] |
||
1176 | mul [con.scr_width] |
||
1177 | add eax, [con.wnd_xpos] |
||
1178 | lea esi, [esi+eax*2] |
||
1179 | mov ecx, [con.wnd_height] |
||
1180 | .lh: |
||
1181 | push ecx |
||
1182 | mov ecx, [con.wnd_width] |
||
1183 | .lw: |
||
1184 | push ecx edi |
||
1185 | xor eax, eax |
||
1186 | mov al, [esi+1] |
||
1187 | push eax |
||
1188 | and al, 0xF |
||
1189 | mov ebx, eax ; цвет текста |
||
1190 | pop eax |
||
1191 | shr al, 4 |
||
1192 | mov ebp, eax ; цвет фона |
||
1193 | sub ebx, ebp |
||
1194 | lodsb |
||
1195 | inc esi |
||
1196 | if font_width > 8 |
||
1197 | lea edx, [eax+eax+font] |
||
1198 | else |
||
1199 | lea edx, [eax+font] |
||
1200 | end if |
||
1201 | .sh: |
||
1202 | mov ecx, [edx] |
||
1203 | repeat font_width |
||
1204 | shr ecx, 1 |
||
1205 | sbb eax, eax |
||
1206 | and eax, ebx |
||
1207 | add eax, ebp |
||
1208 | mov [edi+%-1], al |
||
1209 | end repeat |
||
1210 | mov eax, [con.wnd_width] |
||
1211 | ; imul eax, font_width |
||
1212 | ; add edi, eax |
||
1213 | if font_width = 6 |
||
1214 | lea eax, [eax*2+eax] |
||
1215 | lea edi, [edi+eax*2] |
||
1216 | else if font_width = 7 |
||
1217 | lea edi, [edi+eax*8] |
||
1218 | sub edi, eax |
||
1219 | else if font_width = 8 |
||
1220 | lea edi, [edi+eax*8] |
||
1221 | else if font_width = 9 |
||
1222 | lea edi, [edi+eax*8] |
||
1223 | add edi, eax |
||
1224 | else if font_width = 10 |
||
1225 | lea eax, [eax*4+eax] |
||
1226 | lea edi, [edi+eax*2] |
||
1227 | else |
||
1228 | Unknown font_width value! |
||
1229 | end if |
||
1230 | if font_width > 8 |
||
1231 | add edx, 256*2 |
||
1232 | cmp edx, font+256*2*font_height |
||
1233 | else |
||
1234 | add edx, 256 |
||
1235 | cmp edx, font+256*font_height |
||
1236 | end if |
||
1237 | jb .sh |
||
1238 | pop edi ecx |
||
1239 | add edi, font_width |
||
1240 | sub ecx, 1 |
||
1241 | jnz .lw |
||
1242 | mov eax, [con.wnd_width] |
||
1243 | imul eax, (font_height-1)*font_width |
||
1244 | add edi, eax |
||
1245 | pop ecx |
||
1246 | mov eax, [con.scr_width] |
||
1247 | sub eax, [con.wnd_width] |
||
1248 | lea esi, [esi+eax*2] |
||
1249 | dec ecx |
||
1250 | jnz .lh |
||
1251 | mov eax, [con.cur_y] |
||
1252 | sub eax, [con.wnd_ypos] |
||
1253 | jb .nocursor |
||
1254 | cmp eax, [con.wnd_height] |
||
1255 | jae .nocursor |
||
1256 | inc eax |
||
1257 | mul [con.wnd_width] |
||
1258 | imul eax, font_height*font_width |
||
1259 | mov edx, [con.cur_x] |
||
1260 | sub edx, [con.wnd_xpos] |
||
1261 | jb .nocursor |
||
1262 | cmp edx, [con.wnd_width] |
||
1263 | jae .nocursor |
||
1264 | inc edx |
||
1265 | imul edx, font_width |
||
1266 | add eax, edx |
||
1267 | add eax, [con.image] |
||
1268 | mov edx, [con.wnd_width] |
||
1269 | imul edx, font_width |
||
1270 | neg edx |
||
1271 | mov ecx, [con.cursor_height] |
||
1272 | jecxz .nocursor |
||
1273 | .cursor_loop: |
||
1274 | push ecx |
||
1275 | mov ecx, font_width |
||
1276 | add eax, edx |
||
1277 | push eax |
||
1278 | @@: |
||
1279 | xor byte [eax-1], 7 |
||
1280 | dec eax |
||
1281 | loop @b |
||
1282 | pop eax |
||
1283 | pop ecx |
||
1284 | loop .cursor_loop |
||
1285 | .nocursor: |
||
1286 | popad |
||
1287 | ret |
||
1288 | |||
1289 | con_exit: |
||
1290 | cmp byte [esp+4], 0 |
||
1291 | jz .noexit |
||
1292 | mov [con.thread_op], 1 |
||
1293 | call con.wake |
||
1294 | ret 4 |
||
1295 | .noexit: |
||
1296 | push esi |
||
1297 | mov esi, [con.title] |
||
1298 | mov edx, con.finished_title |
||
1299 | mov ecx, 255 |
||
1300 | call .strcpy |
||
1301 | mov esi, con.aFinished |
||
1302 | call .strcpy |
||
1303 | mov byte [edx], 0 |
||
1304 | pop esi |
||
1305 | and [con.cursor_height], 0 |
||
1306 | push con.finished_title |
||
1307 | call con_set_title |
||
1308 | ret 4 |
||
1309 | .strcpy: |
||
1310 | jecxz .ret |
||
1311 | @@: |
||
1312 | lodsb |
||
1313 | test al, al |
||
1314 | jz .ret |
||
1315 | mov [edx], al |
||
1316 | inc edx |
||
1317 | loop @b |
||
1318 | .ret: |
||
1319 | ret |
||
1320 | |||
1321 | con_set_title: |
||
1322 | mov eax, [esp+4] |
||
1323 | mov [con.title], eax |
||
1324 | mov [con.thread_op], 2 |
||
1325 | call con.wake |
||
1326 | ret 4 |
||
1327 | |||
1328 | ; int __stdcall con_kbhit(void); |
||
1329 | con_kbhit: |
||
1133 | diamond | 1330 | test byte [con_flags+1], 2 |
1331 | jnz @f |
||
836 | diamond | 1332 | mov eax, [con.input_start] |
1333 | cmp eax, [con.input_end] |
||
1133 | diamond | 1334 | @@: |
836 | diamond | 1335 | setnz al |
1336 | movzx eax, al |
||
1337 | ret |
||
1338 | |||
1339 | con.force_entered_char: |
||
1340 | cmp [con.entered_char], -1 |
||
1341 | jnz .ret |
||
1342 | mov [con.thread_op], 4 |
||
1343 | call con.wake |
||
1133 | diamond | 1344 | test byte [con_flags+1], 2 |
1345 | jnz .ret |
||
836 | diamond | 1346 | ; wait for response |
1347 | push ebx |
||
1348 | push 5 |
||
1349 | pop eax |
||
1350 | push 2 |
||
1351 | pop ebx |
||
1352 | @@: |
||
1353 | int 0x40 |
||
1354 | cmp [con.entered_char], -1 |
||
1355 | jz @b |
||
1356 | pop ebx |
||
1357 | .ret: |
||
1358 | ret |
||
1359 | |||
1360 | ; int __stdcall con_getch(void); |
||
1361 | con_getch: |
||
1362 | call con.force_entered_char |
||
1133 | diamond | 1363 | test byte [con_flags+1], 2 |
1364 | jnz con_getch_closed |
||
836 | diamond | 1365 | movzx eax, byte [con.entered_char] |
1366 | sar [con.entered_char], 8 |
||
1367 | mov byte [con.entered_char+1], 0xFF |
||
1368 | test al, al |
||
1369 | jz @f |
||
1370 | mov byte [con.entered_char], 0xFF |
||
1371 | @@: |
||
1372 | ret |
||
1373 | |||
1133 | diamond | 1374 | con_getch_closed: |
1145 | diamond | 1375 | xor eax, eax |
1133 | diamond | 1376 | ret |
1377 | |||
836 | diamond | 1378 | ; int __stdcall con_getch2(void); |
1379 | con_getch2: |
||
1380 | call con.force_entered_char |
||
1133 | diamond | 1381 | test byte [con_flags+1], 2 |
1382 | jnz con_getch_closed |
||
836 | diamond | 1383 | mov eax, 0xFFFF |
1384 | xchg ax, [con.entered_char] |
||
1385 | ret |
||
1386 | |||
1133 | diamond | 1387 | ; char* __stdcall con_gets(char* str, int n); |
836 | diamond | 1388 | con_gets: |
852 | diamond | 1389 | pop eax |
1390 | push 0 |
||
1391 | push eax |
||
1133 | diamond | 1392 | ; char* __stdcall con_gets2(con_gets2_callback callback, char* str, int n); |
852 | diamond | 1393 | con_gets2: |
1133 | diamond | 1394 | mov eax, [esp+8] ; str |
836 | diamond | 1395 | pushad |
1133 | diamond | 1396 | mov esi, eax ; str |
852 | diamond | 1397 | mov ebx, [esp+20h+12] ; n |
836 | diamond | 1398 | sub ebx, 1 |
1399 | jle .ret |
||
1400 | mov byte [esi], 0 |
||
1401 | xor ecx, ecx ; длина уже введённой строки |
||
1402 | call con.get_data_ptr |
||
1403 | .loop: |
||
852 | diamond | 1404 | call con_getch2 |
836 | diamond | 1405 | test al, al |
1406 | jz .extended |
||
1407 | cmp al, 8 |
||
1408 | jz .backspace |
||
1409 | cmp al, 27 |
||
1410 | jz .esc |
||
1411 | cmp al, 13 |
||
1412 | jz .enter |
||
852 | diamond | 1413 | cmp al, 9 |
1414 | jz .tab |
||
836 | diamond | 1415 | inc ecx |
1416 | mov dl, al |
||
1417 | call con.write_char_ex |
||
1418 | push [con.cur_x] |
||
1419 | push [con.cur_y] |
||
1420 | push edi |
||
1421 | push esi |
||
1422 | @@: |
||
1423 | lodsb |
||
1424 | mov [esi-1], dl |
||
1425 | mov dl, al |
||
1426 | test al, al |
||
1427 | jz @f |
||
1428 | call con.write_char_ex |
||
1429 | jmp @b |
||
1430 | @@: |
||
1431 | mov [esi], dl |
||
1432 | pop esi |
||
1433 | inc esi |
||
1434 | pop edi |
||
1435 | pop [con.cur_y] |
||
1436 | pop [con.cur_x] |
||
1437 | .update_screen_and_loop: |
||
1438 | call con.update_screen |
||
1439 | cmp ecx, ebx |
||
1440 | jb .loop |
||
852 | diamond | 1441 | .ret_us: |
836 | diamond | 1442 | mov edx, [con.cur_x] |
1443 | @@: |
||
1444 | lodsb |
||
1445 | test al, al |
||
1446 | jz @f |
||
1447 | inc edx |
||
1448 | cmp edx, [con.scr_width] |
||
1449 | jb @b |
||
1450 | xor edx, edx |
||
1451 | call con.newline |
||
1452 | jmp @b |
||
1453 | @@: |
||
1454 | mov [con.cur_x], edx |
||
1455 | call con.get_data_ptr |
||
1456 | call con.update_screen |
||
1457 | jmp .ret |
||
1458 | .esc: |
||
1459 | mov edx, [con.cur_x] |
||
1460 | @@: |
||
1461 | lodsb |
||
1462 | test al, al |
||
1463 | jz @f |
||
1464 | inc edx |
||
1465 | cmp edx, [con.scr_width] |
||
1466 | jb @b |
||
1467 | xor edx, edx |
||
1468 | call con.newline |
||
1469 | jmp @b |
||
1470 | @@: |
||
1471 | mov [con.cur_x], edx |
||
1472 | call con.get_data_ptr |
||
1473 | dec esi |
||
1474 | xor ecx, ecx |
||
1475 | @@: |
||
1476 | mov byte [esi], 0 |
||
852 | diamond | 1477 | cmp esi, [esp+20h+8] |
836 | diamond | 1478 | jbe .update_screen_and_loop |
1479 | mov al, 8 |
||
1480 | call con.write_special_char |
||
1481 | mov al, ' ' |
||
1482 | call con.write_char |
||
1483 | mov al, 8 |
||
1484 | call con.write_special_char |
||
1485 | dec esi |
||
1486 | jmp @b |
||
1487 | .delete: |
||
1488 | cmp byte [esi], 0 |
||
1489 | jz .loop |
||
1490 | lodsb |
||
1491 | call con.write_char_ex |
||
1492 | .backspace: |
||
852 | diamond | 1493 | cmp esi, [esp+20h+8] |
836 | diamond | 1494 | jbe .loop |
1495 | push esi |
||
1496 | mov edx, [con.cur_x] |
||
1497 | @@: |
||
1498 | lodsb |
||
1499 | test al, al |
||
1500 | jz @f |
||
1501 | inc edx |
||
1502 | cmp edx, [con.scr_width] |
||
1503 | jb @b |
||
1504 | xor edx, edx |
||
1505 | call con.newline |
||
1506 | jmp @b |
||
1507 | @@: |
||
1508 | mov [con.cur_x], edx |
||
1509 | call con.get_data_ptr |
||
1510 | dec esi |
||
1511 | mov al, 8 |
||
1512 | call con.write_special_char |
||
1513 | mov al, ' ' |
||
1514 | call con.write_char |
||
1515 | mov al, 8 |
||
1516 | call con.write_special_char |
||
1517 | mov dl, 0 |
||
1518 | @@: |
||
1519 | cmp esi, [esp] |
||
1520 | jbe @f |
||
1521 | mov al, 8 |
||
1522 | call con.write_special_char |
||
1523 | dec esi |
||
1524 | xchg dl, [esi] |
||
1525 | mov al, dl |
||
1526 | call con.write_char |
||
1527 | mov al, 8 |
||
1528 | call con.write_special_char |
||
1529 | jmp @b |
||
1530 | @@: |
||
1531 | pop esi |
||
1532 | dec esi |
||
1533 | mov [esi], dl |
||
1534 | dec ecx |
||
1535 | jmp .update_screen_and_loop |
||
1536 | .enter: |
||
1537 | mov edx, [con.cur_x] |
||
1538 | @@: |
||
1539 | lodsb |
||
1540 | test al, al |
||
1541 | jz @f |
||
1542 | inc edx |
||
1543 | cmp edx, [con.scr_width] |
||
1544 | jb @b |
||
1545 | xor edx, edx |
||
1546 | call con.newline |
||
1547 | jmp @b |
||
1548 | @@: |
||
1549 | mov [con.cur_x], edx |
||
1550 | call con.get_data_ptr |
||
1551 | mov al, 10 |
||
1552 | mov [esi-1], al |
||
1553 | mov byte [esi], 0 |
||
1554 | call con.write_special_char |
||
1555 | call con.update_screen |
||
1556 | jmp .ret |
||
852 | diamond | 1557 | .tab: |
1558 | mov al, 0 |
||
1559 | mov ah, 0xF |
||
836 | diamond | 1560 | .extended: |
1145 | diamond | 1561 | test ah, ah |
1562 | jz .closed |
||
852 | diamond | 1563 | xchg al, ah |
836 | diamond | 1564 | cmp al, 0x4B |
1565 | jz .left |
||
1566 | cmp al, 0x4D |
||
1567 | jz .right |
||
1568 | cmp al, 0x47 |
||
1569 | jz .home |
||
1570 | cmp al, 0x4F |
||
1571 | jz .end |
||
1572 | cmp al, 0x53 |
||
1573 | jz .delete |
||
852 | diamond | 1574 | ; give control to callback function |
1575 | cmp dword [esp+20h+4], 0 |
||
1576 | jz .loop |
||
1577 | ; remember length of text before and length of text after |
||
1578 | ; and advance cursor to the end of line |
||
1579 | push ecx |
||
1580 | push eax |
||
1581 | lea edx, [esi+1] |
||
1582 | @@: |
||
1583 | lodsb |
||
1584 | test al, al |
||
1585 | jz @f |
||
1586 | call con.write_char_ex |
||
1587 | jmp @b |
||
1588 | @@: |
||
1589 | sub esi, edx |
||
1590 | pop eax |
||
1591 | push esi |
||
1592 | dec edx |
||
1593 | sub edx, [esp+28h+8] |
||
1594 | push edx |
||
1595 | push esp ; ppos |
||
1596 | mov ecx, [esp+30h+4] |
||
1597 | lea edx, [esp+30h+12] |
||
1598 | push edx ; pn |
||
1599 | lea edx, [esp+34h+8] |
||
1600 | push edx ; pstr |
||
1601 | push eax ; keycode |
||
1602 | call ecx |
||
1603 | call con.get_data_ptr |
||
1604 | dec eax |
||
1605 | js .callback_nochange |
||
1606 | jz .callback_del |
||
1607 | dec eax |
||
1608 | jz .callback_output |
||
1609 | ; callback returned 2 - exit |
||
1610 | add esp, 12 |
||
1611 | jmp .ret |
||
1612 | .callback_nochange: |
||
1613 | ; callback returned 0 - string was not changed, only restore cursor position |
||
1614 | pop esi |
||
1615 | pop ecx |
||
1616 | test ecx, ecx |
||
1617 | jz .cncs |
||
1618 | @@: |
||
1619 | mov al, 8 |
||
1620 | call con.write_special_char |
||
1621 | loop @b |
||
1622 | .cncs: |
||
1623 | pop ecx |
||
1624 | add esi, [esp+20h+8] |
||
1625 | jmp .callback_done |
||
1626 | .callback_del: |
||
1627 | ; callback returned 1 - string was changed, delete old string and output new |
||
1628 | mov ecx, [esp+8] |
||
1629 | test ecx, ecx |
||
1630 | jz .cds |
||
1631 | @@: |
||
1632 | mov al, 8 |
||
1633 | call con.write_special_char |
||
1634 | mov al, ' ' |
||
1635 | call con.write_char_ex |
||
1636 | mov al, 8 |
||
1637 | call con.write_special_char |
||
1638 | loop @b |
||
1639 | .cds: |
||
1640 | .callback_output: |
||
1641 | ; callback returned 2 - string was changed, output new string |
||
1642 | pop edx |
||
1643 | pop esi |
||
1644 | pop ecx |
||
1645 | mov esi, [esp+20h+8] |
||
1646 | xor ecx, ecx |
||
1647 | @@: |
||
1648 | lodsb |
||
1649 | test al, al |
||
1650 | jz @f |
||
1651 | call con.write_char_ex |
||
1652 | inc ecx |
||
1653 | jmp @b |
||
1654 | @@: |
||
1655 | dec esi |
||
1656 | push ecx |
||
1657 | sub ecx, edx |
||
1658 | jz .cos |
||
1659 | @@: |
||
1660 | mov al, 8 |
||
1661 | call con.write_special_char |
||
1662 | dec esi |
||
1663 | loop @b |
||
1664 | .cos: |
||
1665 | pop ecx |
||
1666 | .callback_done: |
||
1667 | call con.update_screen |
||
1668 | mov ebx, [esp+20h+12] |
||
1669 | dec ebx |
||
1670 | cmp ecx, ebx |
||
1671 | jae .ret_us |
||
836 | diamond | 1672 | jmp .loop |
1673 | .left: |
||
852 | diamond | 1674 | cmp esi, [esp+20h+8] |
836 | diamond | 1675 | jbe .loop |
1676 | dec esi |
||
1677 | mov al, 8 |
||
1678 | call con.write_special_char |
||
1679 | jmp .update_screen_and_loop |
||
1680 | .right: |
||
1681 | cmp byte [esi], 0 |
||
1682 | jz .loop |
||
1683 | lodsb |
||
1684 | call con.write_char_ex |
||
1685 | jmp .update_screen_and_loop |
||
1686 | .home: |
||
852 | diamond | 1687 | cmp esi, [esp+20h+8] |
836 | diamond | 1688 | jz .update_screen_and_loop |
1689 | dec esi |
||
1690 | mov al, 8 |
||
1691 | call con.write_special_char |
||
1692 | jmp .home |
||
1693 | .end: |
||
1694 | lodsb |
||
1695 | test al, al |
||
1696 | jz @f |
||
1697 | call con.write_char_ex |
||
1698 | jmp .end |
||
1699 | @@: |
||
1700 | dec esi |
||
1701 | jmp .update_screen_and_loop |
||
1133 | diamond | 1702 | .closed: |
1703 | and dword [esp+1Ch], 0 |
||
836 | diamond | 1704 | .ret: |
1705 | popad |
||
852 | diamond | 1706 | ret 12 |
836 | diamond | 1707 | |
853 | diamond | 1708 | ; void __stdcall con_cls(); |
1709 | con_cls: |
||
1710 | push edi |
||
1711 | call con.write_special_char.cls |
||
1712 | pop edi |
||
1713 | call con.update_screen |
||
1714 | ret |
||
1715 | |||
1716 | ; void __stdcall con_get_cursor_pos(int* px, int* py); |
||
1717 | con_get_cursor_pos: |
||
1718 | push eax ecx |
||
1719 | mov eax, [esp+12] |
||
1720 | mov ecx, [con.cur_x] |
||
1721 | mov [eax], ecx |
||
1722 | mov eax, [esp+16] |
||
1723 | mov ecx, [con.cur_y] |
||
1724 | mov [eax], ecx |
||
1725 | pop ecx eax |
||
1726 | ret 8 |
||
1727 | |||
1728 | ; void __stdcall con_set_cursor_pos(int px, int py); |
||
1729 | con_set_cursor_pos: |
||
1730 | push eax |
||
1731 | mov eax, [esp+8] |
||
1732 | cmp eax, [con.scr_width] |
||
1733 | jae @f |
||
1734 | mov [con.cur_x], eax |
||
1735 | @@: |
||
1736 | mov eax, [esp+12] |
||
1737 | cmp eax, [con.scr_height] |
||
1738 | jae @f |
||
1739 | mov [con.cur_y], eax |
||
1740 | @@: |
||
1741 | pop eax |
||
1742 | call con.update_screen |
||
1743 | ret 8 |
||
1744 | |||
836 | diamond | 1745 | con.update_screen: |
1746 | push eax |
||
1747 | mov eax, [con.cur_y] |
||
1748 | sub eax, [con.wnd_ypos] |
||
1749 | jb .up |
||
1750 | cmp eax, [con.wnd_height] |
||
1751 | jb .done |
||
1752 | mov eax, [con.cur_y] |
||
1753 | sub eax, [con.wnd_height] |
||
1754 | inc eax |
||
1755 | jmp .set |
||
1756 | .up: |
||
1757 | mov eax, [con.cur_y] |
||
1758 | .set: |
||
1759 | mov [con.wnd_ypos], eax |
||
1760 | .done: |
||
1761 | pop eax |
||
1762 | mov [con.thread_op], 3 |
||
1763 | |||
1764 | con.wake: |
||
1765 | pushad |
||
1766 | mov al, [con.thread_op] |
||
1767 | cmp al, byte [con.ipc_buf+0x10] |
||
1768 | jz .ret |
||
1769 | @@: |
||
1770 | push 60 |
||
1771 | pop eax |
||
1772 | push 2 |
||
1773 | pop ebx |
||
1774 | mov ecx, [con.console_tid] |
||
1133 | diamond | 1775 | jecxz .ret |
836 | diamond | 1776 | mov edx, con.thread_op |
1777 | push 1 |
||
1778 | pop esi |
||
1779 | int 0x40 |
||
1780 | test eax, eax |
||
1781 | jz @f |
||
1782 | push 5 |
||
1783 | pop eax |
||
1784 | mov bl, 1 |
||
1785 | int 0x40 |
||
1786 | jmp @b |
||
1787 | @@: |
||
1788 | .ret: |
||
1789 | popad |
||
1790 | ret |
||
1791 | |||
1792 | ; Поток окна консоли. Обрабатывает ввод и вывод. |
||
1793 | con.thread: |
||
1794 | ; Поток реагирует на IPC, которое используется только для того, чтобы его можно было "разбудить" |
||
1795 | push 40 |
||
1796 | pop eax |
||
1797 | push 0x67 |
||
1798 | pop ebx |
||
1799 | int 0x40 |
||
1800 | mov al, 60 |
||
1801 | mov bl, 1 |
||
1802 | mov ecx, con.ipc_buf |
||
1803 | push 0x11 |
||
1804 | pop edx |
||
1805 | int 0x40 |
||
1806 | mov al, 66 |
||
1807 | mov bl, 1 |
||
1808 | mov ecx, ebx |
||
1809 | int 0x40 |
||
1810 | con.redraw: |
||
1811 | call con.draw_window |
||
1812 | con.msg_loop: |
||
1813 | cmp dword [con.bUpPressed], 0 |
||
1814 | jnz .wait_timeout |
||
1815 | push 10 |
||
1816 | pop eax |
||
1817 | jmp @f |
||
1818 | .wait_timeout: |
||
1819 | push 23 |
||
1820 | pop eax |
||
1821 | push 5 |
||
1822 | pop ebx |
||
1823 | @@: |
||
1824 | int 0x40 |
||
1825 | dec eax |
||
1826 | jz con.redraw |
||
1827 | dec eax |
||
1828 | jz con.key |
||
1829 | dec eax |
||
1830 | jz con.button |
||
1831 | cmp al, 4 |
||
1832 | jz con.ipc |
||
1833 | jmp con.mouse |
||
1834 | con.button: |
||
1835 | ; we have only one button, close |
||
1836 | con.thread_exit: |
||
1133 | diamond | 1837 | or byte [con_flags+1], 2 |
1838 | and [con.console_tid], 0 |
||
1134 | diamond | 1839 | and [con.entered_char], 0 |
836 | diamond | 1840 | or eax, -1 |
1841 | int 0x40 |
||
1842 | con.key: |
||
1843 | mov al, 2 |
||
1844 | int 0x40 |
||
1845 | ; ah = scancode |
||
1846 | cmp ah, 0xE0 |
||
1847 | jnz @f |
||
1848 | mov [con.bWasE0], 1 |
||
1849 | jmp con.msg_loop |
||
1850 | @@: |
||
1851 | shr eax, 8 |
||
1852 | xchg ah, [con.bWasE0] |
||
1853 | test al, al |
||
1854 | jle con.msg_loop |
||
1855 | cmp al, 0x1D |
||
1856 | jz con.msg_loop |
||
1857 | cmp al, 0x2A |
||
1858 | jz con.msg_loop |
||
1859 | cmp al, 0x36 |
||
1860 | jz con.msg_loop |
||
1861 | cmp al, 0x38 |
||
1862 | jz con.msg_loop |
||
1863 | cmp al, 0x3A |
||
1864 | jz con.msg_loop |
||
1865 | cmp al, 0x45 |
||
1866 | jz con.msg_loop |
||
1867 | cmp al, 0x46 |
||
1868 | jz con.msg_loop |
||
1869 | mov edx, eax |
||
4402 | hidnplayr | 1870 | cmp dl, 0x4e |
1871 | je .numpad |
||
1872 | cmp dl, 0x4a |
||
1873 | je .numpad |
||
836 | diamond | 1874 | push 66 |
1875 | pop eax |
||
1876 | push 3 |
||
1877 | pop ebx |
||
1878 | int 0x40 ; eax = control key state |
||
1879 | test dh, dh |
||
1880 | jnz .extended |
||
4306 | hidnplayr | 1881 | test al, 0x80 ; numlock |
1882 | jnz .numlock |
||
836 | diamond | 1883 | bt [scan_has_ascii], edx |
1884 | jnc .extended |
||
4306 | hidnplayr | 1885 | test al, 0x30 ; alt |
836 | diamond | 1886 | jnz .extended |
4306 | hidnplayr | 1887 | test al, 0x80 ; numlock |
1888 | jz .no_numlock |
||
1889 | .numlock: |
||
1890 | cmp dl, 71 |
||
1891 | jb .no_numlock |
||
1892 | cmp dl, 83 |
||
1893 | ja .no_numlock |
||
4402 | hidnplayr | 1894 | .numpad: |
4306 | hidnplayr | 1895 | mov dh, [con.extended_numlock+edx-71] |
1896 | xchg dl, dh |
||
1897 | jmp .gotcode |
||
1898 | .no_numlock: |
||
836 | diamond | 1899 | ; key has ASCII code |
1900 | push eax edx |
||
1901 | push 2 |
||
1902 | pop ecx |
||
1903 | test al, 3 |
||
1904 | jnz @f |
||
1905 | dec ecx |
||
1906 | @@: |
||
1907 | push 26 |
||
1908 | pop eax |
||
1909 | mov bl, 2 |
||
1910 | mov edx, con.kbd_layout |
||
1911 | int 0x40 |
||
1912 | pop edx eax |
||
1913 | mov dh, [con.kbd_layout+edx] |
||
1914 | test al, 0xC |
||
1915 | jz @f |
||
1916 | sub dh, 0x60 |
||
1917 | jmp @f |
||
1918 | .extended: |
||
1919 | mov dh, 0 ; no ASCII code |
||
1920 | @@: |
||
1921 | ; dh contains ASCII-code; now convert scancode to extended key code |
||
1922 | mov ecx, con.extended_alt |
||
1923 | test al, 0x30 |
||
1924 | jnz .xlat |
||
4384 | hidnplayr | 1925 | |
836 | diamond | 1926 | mov ecx, con.extended_shift |
1927 | test al, 3 |
||
1928 | jnz .xlat |
||
4384 | hidnplayr | 1929 | |
836 | diamond | 1930 | mov ecx, con.extended_ctrl |
1931 | test al, 0xC |
||
1932 | jnz .xlat |
||
4384 | hidnplayr | 1933 | |
1934 | cmp dl, 28 |
||
1935 | jne @f |
||
1936 | shl dx, 8 |
||
1937 | mov dl, 13 |
||
1938 | jmp .gotcode |
||
1939 | @@: |
||
1940 | cmp dl, 53 |
||
1941 | jne @f |
||
1942 | shl dx, 8 |
||
1943 | mov dl, '/' |
||
1944 | jmp .gotcode |
||
1945 | @@: |
||
1946 | cmp dl, 55 |
||
1947 | jne @f |
||
1948 | shl dx, 8 |
||
1949 | mov dl, '*' |
||
1950 | jmp .gotcode |
||
1951 | @@: |
||
836 | diamond | 1952 | xchg dl, dh |
1953 | cmp dh, 0x57 |
||
1954 | jz @f |
||
1955 | cmp dh, 0x58 |
||
1956 | jnz .gotcode |
||
1957 | @@: |
||
1958 | add dh, 0x85-0x57 |
||
1959 | jmp .gotcode |
||
1960 | .xlat: |
||
1961 | movzx eax, dl |
||
1962 | mov dl, dh |
||
1963 | mov dh, [eax+ecx] |
||
1964 | .gotcode: |
||
1965 | test dh, dh |
||
1966 | jz con.msg_loop |
||
1967 | cmp dh, 0x94 |
||
1968 | jnz @f |
||
1969 | mov dl, 0 |
||
1970 | @@: |
||
1971 | ; dx contains full keycode |
||
1972 | cmp [con.bGetchRequested], 0 |
||
1973 | jz @f |
||
1974 | mov [con.entered_char], dx |
||
1975 | jmp con.msg_loop |
||
1976 | @@: |
||
1977 | mov eax, [con.input_end] |
||
1978 | mov ecx, eax |
||
1979 | add eax, 2 |
||
1980 | cmp eax, con.input_buffer_end |
||
1981 | jnz @f |
||
1982 | mov eax, con.input_buffer |
||
1983 | @@: |
||
1984 | cmp eax, [con.input_start] |
||
1985 | jnz @f |
||
1986 | ; buffer overflow, make beep and continue |
||
1987 | push 55 |
||
1988 | pop eax |
||
1989 | mov ebx, eax |
||
1990 | mov esi, con.beep |
||
1991 | int 0x40 |
||
1992 | jmp con.msg_loop |
||
1993 | @@: |
||
1994 | mov [ecx], dx |
||
1995 | mov [con.input_end], eax |
||
1996 | jmp con.msg_loop |
||
1997 | con.ipc: |
||
1998 | movzx eax, byte [con.ipc_buf+0x10] |
||
1999 | mov byte [con.ipc_buf+4], 8 |
||
2000 | mov byte [con.ipc_buf+0x10], 0 |
||
2001 | dec eax |
||
2002 | jz con.thread_exit |
||
2003 | dec eax |
||
2004 | jz con.set_title |
||
2005 | dec eax |
||
2006 | jz con.redraw_image |
||
2007 | dec eax |
||
2008 | jz con.getch |
||
2009 | jmp con.msg_loop |
||
2010 | con.set_title: |
||
2011 | push 71 |
||
2012 | pop eax |
||
2013 | push 1 |
||
2014 | pop ebx |
||
2015 | mov ecx, [con.title] |
||
2016 | int 0x40 |
||
2017 | jmp con.msg_loop |
||
2018 | con.redraw_image: |
||
2019 | call con.data2image |
||
2020 | call con.draw_image |
||
2021 | jmp con.msg_loop |
||
2022 | con.getch: |
||
2023 | mov eax, [con.input_start] |
||
2024 | cmp eax, [con.input_end] |
||
2025 | jz .noinput |
||
2026 | mov ecx, [eax] |
||
2027 | mov [con.entered_char], cx |
||
2028 | inc eax |
||
2029 | inc eax |
||
2030 | cmp eax, con.input_buffer_end |
||
2031 | jnz @f |
||
2032 | mov eax, con.input_buffer |
||
2033 | @@: |
||
2034 | mov [con.input_start], eax |
||
2035 | jmp con.msg_loop |
||
2036 | .noinput: |
||
2037 | mov [con.bGetchRequested], 1 |
||
2038 | jmp con.msg_loop |
||
2039 | con.mouse: |
||
2040 | xor eax, eax |
||
2041 | xchg eax, dword [con.bUpPressed] |
||
2042 | mov dword [con.bUpPressed_saved], eax |
||
2043 | push 37 |
||
2044 | pop eax |
||
2045 | push 2 |
||
2046 | pop ebx |
||
2047 | int 0x40 |
||
2048 | test al, 1 |
||
2049 | jnz @f |
||
2050 | cmp [con.vscroll_pt], -1 |
||
2051 | jz .redraw_if_needed |
||
2052 | or [con.vscroll_pt], -1 |
||
2053 | .redraw_if_needed: |
||
2054 | cmp dword [con.bUpPressed_saved], 0 |
||
2055 | jnz con.redraw_image |
||
2056 | jmp con.msg_loop |
||
2057 | @@: |
||
2058 | mov al, 37 |
||
2059 | dec ebx |
||
2060 | int 0x40 |
||
2061 | movsx ebx, ax |
||
2062 | sar eax, 16 |
||
2063 | cmp [con.vscroll_pt], -1 |
||
2064 | jnz .vscrolling |
||
2065 | test ebx, ebx |
||
2066 | js .redraw_if_needed |
||
2067 | sub ax, [con.data_width] |
||
2068 | jb .redraw_if_needed |
||
2069 | cmp eax, con.vscroll_width |
||
2070 | jae .redraw_if_needed |
||
2071 | cmp ebx, con.vscroll_btn_height |
||
2072 | jb .up |
||
2073 | sub bx, [con.data_height] |
||
2074 | jae .redraw_if_needed |
||
2075 | cmp bx, -con.vscroll_btn_height |
||
2076 | jge .down |
||
2077 | add bx, [con.data_height] |
||
2078 | sub bx, word [con.vscrollbar_pos] |
||
2079 | jl .vscroll_up |
||
2080 | cmp bx, word [con.vscrollbar_size] |
||
2081 | jl .vscroll |
||
2082 | .vscroll_down: |
||
2083 | cmp [con.bScrollingDown_saved], 0 |
||
2084 | jz .vscroll_down_first |
||
2085 | cmp [con.bScrollingDown_saved], 1 |
||
2086 | jz .vscroll_down_wasfirst |
||
2087 | mov [con.bScrollingDown], 2 |
||
2088 | .vscroll_down_do: |
||
2089 | mov eax, [con.wnd_ypos] |
||
2090 | add eax, [con.wnd_height] |
||
2091 | dec eax |
||
2092 | mov ebx, [con.scr_height] |
||
2093 | sub ebx, [con.wnd_height] |
||
2094 | cmp eax, ebx |
||
2095 | jb @f |
||
2096 | mov eax, ebx |
||
2097 | @@: |
||
2098 | mov [con.wnd_ypos], eax |
||
2099 | jmp con.redraw_image |
||
2100 | .vscroll_down_first: |
||
2101 | push 26 |
||
2102 | pop eax |
||
2103 | push 9 |
||
2104 | pop ebx |
||
2105 | int 0x40 |
||
2106 | mov [con.scroll_down_first_time], eax |
||
2107 | mov [con.bScrollingDown], 1 |
||
2108 | jmp .vscroll_down_do |
||
2109 | .vscroll_down_wasfirst: |
||
2110 | push 26 |
||
2111 | pop eax |
||
2112 | push 9 |
||
2113 | pop ebx |
||
2114 | int 0x40 |
||
2115 | sub eax, [con.scroll_down_first_time] |
||
2116 | cmp eax, 25 |
||
2117 | jb @f |
||
2118 | mov [con.bScrollingDown], 2 |
||
2119 | jmp .vscroll_down_do |
||
2120 | @@: |
||
2121 | mov [con.bScrollingDown], 1 |
||
2122 | jmp con.msg_loop |
||
2123 | .vscroll_up: |
||
2124 | cmp [con.bScrollingUp_saved], 0 |
||
2125 | jz .vscroll_up_first |
||
2126 | cmp [con.bScrollingUp_saved], 1 |
||
2127 | jz .vscroll_up_wasfirst |
||
2128 | mov [con.bScrollingUp], 2 |
||
2129 | .vscroll_up_do: |
||
2130 | mov eax, [con.wnd_ypos] |
||
2131 | inc eax |
||
2132 | sub eax, [con.wnd_height] |
||
2133 | jns @f |
||
2134 | xor eax, eax |
||
2135 | @@: |
||
2136 | mov [con.wnd_ypos], eax |
||
2137 | jmp con.redraw_image |
||
2138 | .vscroll_up_first: |
||
2139 | push 26 |
||
2140 | pop eax |
||
2141 | push 9 |
||
2142 | pop ebx |
||
2143 | int 0x40 |
||
2144 | mov [con.scroll_up_first_time], eax |
||
2145 | mov [con.bScrollingUp], 1 |
||
2146 | jmp .vscroll_up_do |
||
2147 | .vscroll_up_wasfirst: |
||
2148 | push 26 |
||
2149 | pop eax |
||
2150 | push 9 |
||
2151 | pop ebx |
||
2152 | int 0x40 |
||
2153 | sub eax, [con.scroll_up_first_time] |
||
2154 | cmp eax, 25 |
||
2155 | jb @f |
||
2156 | mov [con.bScrollingUp], 2 |
||
2157 | jmp .vscroll_up_do |
||
2158 | @@: |
||
2159 | mov [con.bScrollingUp], 1 |
||
2160 | jmp con.msg_loop |
||
2161 | .up: |
||
2162 | cmp [con.bUpPressed_saved], 0 |
||
2163 | jz .up_first |
||
2164 | cmp [con.bUpPressed_saved], 1 |
||
2165 | jz .up_wasfirst |
||
2166 | mov [con.bUpPressed], 2 |
||
2167 | .up_do: |
||
2168 | mov eax, [con.wnd_ypos] |
||
2169 | dec eax |
||
2170 | js @f |
||
2171 | mov [con.wnd_ypos], eax |
||
2172 | @@: |
||
2173 | jmp con.redraw_image |
||
2174 | .up_first: |
||
2175 | push 26 |
||
2176 | pop eax |
||
2177 | push 9 |
||
2178 | pop ebx |
||
2179 | int 0x40 |
||
2180 | mov [con.up_first_time], eax |
||
2181 | mov [con.bUpPressed], 1 |
||
2182 | jmp .up_do |
||
2183 | .up_wasfirst: |
||
2184 | push 26 |
||
2185 | pop eax |
||
2186 | push 9 |
||
2187 | pop ebx |
||
2188 | int 0x40 |
||
2189 | sub eax, [con.up_first_time] |
||
2190 | cmp eax, 25 |
||
2191 | jb @f |
||
2192 | mov [con.bUpPressed], 2 |
||
2193 | jmp .up_do |
||
2194 | @@: |
||
2195 | mov [con.bUpPressed], 1 |
||
2196 | jmp con.msg_loop |
||
2197 | .down: |
||
2198 | cmp [con.bDownPressed_saved], 0 |
||
2199 | jz .down_first |
||
2200 | cmp [con.bDownPressed_saved], 1 |
||
2201 | jz .down_wasfirst |
||
2202 | mov [con.bDownPressed], 2 |
||
2203 | .down_do: |
||
2204 | mov eax, [con.scr_height] |
||
2205 | sub eax, [con.wnd_height] |
||
2206 | jbe con.redraw_image |
||
2207 | cmp [con.wnd_ypos], eax |
||
2208 | jae con.redraw_image |
||
2209 | inc [con.wnd_ypos] |
||
2210 | jmp con.redraw_image |
||
2211 | .down_first: |
||
2212 | push 26 |
||
2213 | pop eax |
||
2214 | push 9 |
||
2215 | pop ebx |
||
2216 | int 0x40 |
||
2217 | mov [con.down_first_time], eax |
||
2218 | mov [con.bDownPressed], 1 |
||
2219 | jmp .down_do |
||
2220 | .down_wasfirst: |
||
2221 | push 26 |
||
2222 | pop eax |
||
2223 | push 9 |
||
2224 | pop ebx |
||
2225 | int 0x40 |
||
2226 | sub eax, [con.down_first_time] |
||
2227 | cmp eax, 25 |
||
2228 | jb @f |
||
2229 | mov [con.bDownPressed], 2 |
||
2230 | jmp .down_do |
||
2231 | @@: |
||
2232 | mov [con.bDownPressed], 1 |
||
2233 | jmp con.msg_loop |
||
2234 | .vscroll: |
||
2235 | mov [con.vscroll_pt], ebx |
||
2236 | call con.draw_image |
||
2237 | jmp con.msg_loop |
||
2238 | .vscrolling: |
||
2239 | sub ebx, [con.vscroll_pt] |
||
2240 | sub ebx, con.vscroll_btn_height |
||
2241 | jge @f |
||
2242 | xor ebx, ebx |
||
2243 | @@: |
||
2244 | movzx eax, [con.data_height] |
||
2245 | sub eax, 2*con.vscroll_btn_height |
||
2246 | sub eax, [con.vscrollbar_size] |
||
2247 | cmp ebx, eax |
||
2248 | jb @f |
||
2249 | lea ebx, [eax-1] |
||
2250 | @@: |
||
2251 | xchg eax, ebx |
||
2252 | mov edx, [con.scr_height] |
||
2253 | sub edx, [con.wnd_height] |
||
2254 | inc edx |
||
2255 | mul edx |
||
2256 | div ebx |
||
2257 | cmp [con.wnd_ypos], eax |
||
2258 | jz con.msg_loop |
||
2259 | mov [con.wnd_ypos], eax |
||
2260 | jmp con.redraw_image |
||
2261 | |||
2262 | con.draw_window: |
||
2263 | push 12 |
||
2264 | pop eax |
||
2265 | xor ebx, ebx |
||
2266 | inc ebx |
||
2267 | int 0x40 |
||
2268 | mov al, 48 |
||
2269 | mov bl, 4 |
||
2270 | int 0x40 |
||
2271 | mov ebx, [con.def_wnd_x-2] |
||
2272 | mov bx, word [con.wnd_width] |
||
2273 | imul bx, font_width |
||
2274 | add bx, 5+5-1 |
||
2275 | mov ecx, [con.def_wnd_y-2] |
||
2276 | mov cx, word [con.wnd_height] |
||
2277 | imul cx, font_height |
||
2278 | lea ecx, [ecx+eax+5-1] |
||
2530 | leency | 2279 | mov edx, 0x74000000 |
836 | diamond | 2280 | mov edi, [con.title] |
2281 | ; place for scrollbar |
||
2282 | mov eax, [con.wnd_height] |
||
2283 | cmp eax, [con.scr_height] |
||
2284 | jae @f |
||
2285 | add ebx, con.vscroll_width |
||
2286 | @@: |
||
2287 | xor eax, eax |
||
2288 | int 0x40 |
||
3034 | leency | 2289 | ;Leency{ |
2290 | mov eax,9 |
||
2291 | mov ebx,process_info_buffer |
||
2292 | mov ecx,-1 |
||
2293 | int 0x40 |
||
2294 | mov eax,[ebx+70] |
||
2295 | mov [window_status],eax |
||
3686 | hidnplayr | 2296 | test [window_status],100b ; window is rolled up |
3034 | leency | 2297 | jnz .exit |
2298 | test [window_status],10b ; window is minimized to panel |
||
2299 | jnz .exit |
||
2300 | ;}Leency - I'm in diamond code... |
||
836 | diamond | 2301 | call con.draw_image |
3034 | leency | 2302 | |
2303 | .exit: |
||
836 | diamond | 2304 | push 12 |
2305 | pop eax |
||
2306 | push 2 |
||
2307 | pop ebx |
||
2308 | int 0x40 |
||
3686 | hidnplayr | 2309 | |
836 | diamond | 2310 | ret |
2311 | |||
2312 | con.draw_image: |
||
2313 | xor edx, edx |
||
2314 | mov ecx, [con.wnd_width] |
||
2315 | imul ecx, font_width |
||
2316 | mov [con.data_width], cx |
||
2317 | shl ecx, 16 |
||
2318 | mov cx, word [con.wnd_height] |
||
2319 | imul cx, font_height |
||
2320 | mov [con.data_height], cx |
||
2321 | mov ebx, [con.image] |
||
2322 | push 65 |
||
2323 | pop eax |
||
2324 | xor ebp, ebp |
||
2325 | mov edi, con.colors |
||
2326 | push 8 |
||
2327 | pop esi |
||
2328 | int 0x40 |
||
2329 | mov al, 7 |
||
2330 | mov edx, [con.wnd_height] |
||
2331 | cmp edx, [con.scr_height] |
||
2332 | jae .skip_vscroll |
||
2333 | push ecx |
||
2334 | mov edx, ecx |
||
2335 | xor dx, dx |
||
2336 | mov ebx, con.vscroll_btn3 |
||
2337 | cmp [con.bUpPressed], 0 |
||
2338 | jnz @f |
||
2339 | mov ebx, con.vscroll_btn1 |
||
2340 | @@: |
||
2341 | mov ecx, con.vscroll_width*65536 + con.vscroll_btn_height |
||
2342 | int 0x40 |
||
2343 | pop edx |
||
2344 | sub dx, con.vscroll_btn_height |
||
2345 | mov ebx, con.vscroll_btn4 |
||
2346 | cmp [con.bDownPressed], 0 |
||
2347 | jnz @f |
||
2348 | mov ebx, con.vscroll_btn2 |
||
2349 | @@: |
||
2350 | int 0x40 |
||
2351 | push edx |
||
2352 | ; Вычисляем высоту бегунка |
||
2353 | mov ax, dx |
||
2354 | sub eax, con.vscroll_btn_height |
||
2355 | mov ecx, eax |
||
2356 | mul [con.wnd_height] |
||
2357 | div [con.scr_height] |
||
2358 | cmp eax, 5 |
||
2359 | jae @f |
||
2360 | mov al, 5 |
||
2361 | @@: |
||
2362 | ; eax = высота бегунка. Вычисляем положение бегунка |
||
2363 | mov [con.vscrollbar_size], eax |
||
2364 | xchg eax, ecx |
||
2365 | sub eax, ecx |
||
2366 | mul [con.wnd_ypos] |
||
2367 | mov ebx, [con.scr_height] |
||
2368 | sub ebx, [con.wnd_height] |
||
2369 | div ebx |
||
2370 | pop edx |
||
2371 | push edx |
||
2372 | ; ecx = высота бегунка, eax = положение |
||
2373 | add eax, con.vscroll_btn_height |
||
2374 | mov [con.vscrollbar_pos], eax |
||
2375 | mov ebx, con.vscroll_bgr2 |
||
2376 | cmp [con.bScrollingUp], 0 |
||
2377 | jnz @f |
||
2378 | mov ebx, con.vscroll_bgr1 |
||
2379 | @@: |
||
2380 | mov ecx, con.vscroll_width*65536 + con.vscroll_bgr_height |
||
2381 | push eax |
||
2382 | push 7 |
||
2383 | pop eax |
||
2384 | mov dx, con.vscroll_btn_height |
||
2385 | call .vpattern |
||
2386 | mov dx, word [con.vscrollbar_pos] |
||
2387 | add dx, word [con.vscrollbar_size] |
||
2388 | mov cx, con.vscroll_bgr_height |
||
2389 | mov ebx, con.vscroll_bgr2 |
||
2390 | cmp [con.bScrollingDown], 0 |
||
2391 | jnz @f |
||
2392 | mov ebx, con.vscroll_bgr1 |
||
2393 | @@: |
||
2394 | call .vpattern |
||
2395 | mov ecx, [con.vscrollbar_pos] |
||
2396 | mov dx, cx |
||
2397 | add ecx, [con.vscrollbar_size] |
||
2398 | sub ecx, con.vscroll_bar_height3 |
||
2399 | push ecx |
||
2400 | mov ebx, con.vscroll_bar1 |
||
2401 | mov ecx, con.vscroll_width*65536 + con.vscroll_bar_height1 |
||
2402 | int 0x40 |
||
2403 | add dx, cx |
||
2404 | mov cx, con.vscroll_bar_height2 |
||
2405 | mov ebx, con.vscroll_bar2 |
||
2406 | call .vpattern |
||
2407 | mov ebx, con.vscroll_bar3 |
||
2408 | mov cx, con.vscroll_bar_height3 |
||
2409 | int 0x40 |
||
2410 | .skip_vscroll: |
||
2411 | ret |
||
2412 | |||
2413 | .vpattern: |
||
2414 | push edx |
||
2415 | add dx, cx |
||
2416 | cmp dx, [esp+8] |
||
2417 | pop edx |
||
2418 | jbe @f |
||
2419 | mov cx, [esp+4] |
||
2420 | sub cx, dx |
||
2421 | jz .ret |
||
2422 | @@: |
||
2423 | int 0x40 |
||
2424 | add dx, cx |
||
2425 | cmp dx, [esp+4] |
||
2426 | jb .vpattern |
||
2427 | .ret: |
||
2428 | ret 4 |
||
2429 | |||
2430 | align 4 |
||
2431 | con.colors dd 0x000000, 0x000080, 0x008000, 0x008080 |
||
2432 | dd 0x800000, 0x800080, 0x808000, 0xC0C0C0 |
||
2433 | dd 0x808080, 0x0000FF, 0x00FF00, 0x00FFFF |
||
2434 | dd 0xFF0000, 0xFF00FF, 0xFFFF00, 0xFFFFFF |
||
2435 | |||
2436 | scan_has_ascii: |
||
2437 | dd 11011111111111111111111111111110b |
||
2438 | dd 00000010001111111111101111111111b |
||
2439 | dd 00000000000000000000000000000000b |
||
2440 | dd 0 |
||
2441 | |||
2442 | con.extended_alt: |
||
2443 | db 00h,01h,78h,79h,7Ah,7Bh,7Ch,7Dh,7Eh,7Fh,80h,81h,82h,83h,0Eh,0A5h |
||
2444 | db 10h,11h,12h,13h,14h,15h,16h,17h,18h,19h,1Ah,1Bh,1Ch,00h,1Eh,1Fh |
||
2445 | db 20h,21h,22h,23h,24h,25h,26h,27h,28h,29h,00h,2Bh,2Ch,2Dh,2Eh,2Fh |
||
2446 | db 30h,31h,32h,33h,34h,35h,00h,37h,00h,39h,00h,68h,69h,6Ah,6Bh,6Ch |
||
2447 | db 6Dh,6Eh,6Fh,70h,71h,00h,00h,97h,98h,99h,4Ah,9Bh,9Ch,9Dh,4Eh,9Fh |
||
2448 | db 0A0h,0A1h,0A2h,0A3h,00h,00h,00h,8Bh,8Ch,00h,00h,00h,00h,00h,00h,00h |
||
2449 | times 20h db 0 |
||
2450 | con.extended_ctrl: |
||
2451 | times 0Fh db %-1 |
||
2452 | db 0x94 |
||
2453 | times 2Bh db %-1 |
||
2454 | db 5Eh,5Fh,60h,61h,62h,63h,64h,65h,66h,67h,00h,00h |
||
2455 | db 77h,8Dh,84h,8Eh,73h,8Fh,74h,90h,75h,91h,76h,92h,93h,00h,00h,00h,89h,8Ah |
||
2456 | times 0x80-0x59 db 0 |
||
2457 | con.extended_shift: |
||
2458 | times 3Bh db %-1 |
||
2459 | db 54h,55h,56h,57h,58h,59h,5Ah,5Bh,5Ch,5Dh,00h,00h |
||
2460 | db 47h,48h,49h,4Ah,4Bh,4Ch,4Dh,4Eh,4Fh,50h,51h,52h,53h,00h,00h,00h,87h,88h |
||
2461 | times 0x80-0x59 db 0 |
||
4306 | hidnplayr | 2462 | con.extended_numlock: |
2463 | db '7', '8', '9', '-' |
||
2464 | db '4', '5', '6', '+' |
||
2465 | db '1', '2', '3' |
||
2466 | db '0', '.' |
||
836 | diamond | 2467 | |
2468 | ; В текущей реализации значения по умолчанию таковы. |
||
2469 | ; В будущем они, возможно, будут считываться как параметры из ini-файла console.ini. |
||
2470 | con.def_wnd_width dd 80 |
||
2471 | con.def_wnd_height dd 25 |
||
2472 | con.def_scr_width dd 80 |
||
2473 | con.def_scr_height dd 300 |
||
2474 | con.def_wnd_x dd 200 |
||
2475 | con.def_wnd_y dd 50 |
||
2476 | |||
3034 | leency | 2477 | |
2478 | struc process_info |
||
2479 | { |
||
2480 | cpu_usage dd ? ; +0 |
||
2481 | window_stack_position dw ? ; +4 |
||
2482 | window_stack_value dw ? ; +6 |
||
2483 | dw ? ; +8 |
||
2484 | process_name rb 12 ; +10 |
||
2485 | memory_start dd ? ; +22 |
||
2486 | used_memory dd ? ; +26 |
||
2487 | PID dd ? ; +30 |
||
2488 | box.x dd ? ; +34 |
||
2489 | box.y dd ? ; +38 |
||
2490 | box.width dd ? ; +42 |
||
2491 | box.height dd ? ; +46 |
||
2492 | slot_state dw ? ; +50 |
||
2493 | dw ? ; +52 |
||
2494 | client_box.x dd ? ; +54 |
||
2495 | client_box.y dd ? ; +58 |
||
2496 | client_box.width dd ? ; +62 |
||
2497 | client_box.height dd ? ; +66 |
||
2498 | wnd_state db ? ; +70 |
||
2499 | rb (1024-71) |
||
2500 | } |
||
2501 | process_info_buffer process_info |
||
3686 | hidnplayr | 2502 | window_status rd 1 |
3034 | leency | 2503 | |
836 | diamond | 2504 | con.vscroll_pt dd -1 |
2505 | |||
2506 | align 16 |
||
2507 | EXPORTS: |
||
2508 | dd szStart, START |
||
1145 | diamond | 2509 | dd szVersion, 0x00020007 |
836 | diamond | 2510 | dd szcon_init, con_init |
2511 | dd szcon_write_asciiz, con_write_asciiz |
||
3686 | hidnplayr | 2512 | dd szcon_write_string, con_write_length |
836 | diamond | 2513 | dd szcon_printf, con_printf |
2514 | dd szcon_exit, con_exit |
||
2515 | dd szcon_get_flags, con_get_flags |
||
2516 | dd szcon_set_flags, con_set_flags |
||
2517 | dd szcon_kbhit, con_kbhit |
||
2518 | dd szcon_getch, con_getch |
||
2519 | dd szcon_getch2, con_getch2 |
||
2520 | dd szcon_gets, con_gets |
||
852 | diamond | 2521 | dd szcon_gets2, con_gets2 |
836 | diamond | 2522 | dd szcon_get_font_height, con_get_font_height |
2523 | dd szcon_get_cursor_height,con_get_cursor_height |
||
2524 | dd szcon_set_cursor_height,con_set_cursor_height |
||
853 | diamond | 2525 | dd szcon_cls, con_cls |
2526 | dd szcon_get_cursor_pos, con_get_cursor_pos |
||
2527 | dd szcon_set_cursor_pos, con_set_cursor_pos |
||
836 | diamond | 2528 | dd 0 |
2529 | |||
2530 | con_flags dd 7 |
||
2531 | con.cursor_height dd (15*font_height+50)/100 |
||
2532 | con.input_start dd con.input_buffer |
||
2533 | con.input_end dd con.input_buffer |
||
2534 | |||
2535 | con_esc_attr_n dd 0 |
||
2536 | con_esc_attrs dd 0,0,0,0 |
||
2537 | con_esc db 0 |
||
2538 | con_sci db 0 |
||
2539 | |||
2540 | con.entered_char dw -1 |
||
2541 | con.bGetchRequested db 0 |
||
2542 | con.bWasE0 db 0 |
||
2543 | |||
2544 | szStart db 'START',0 |
||
2545 | |||
2546 | szcon_init db 'con_init',0 |
||
2547 | szcon_write_asciiz db 'con_write_asciiz',0 |
||
3686 | hidnplayr | 2548 | szcon_write_string db 'con_write_string',0 |
836 | diamond | 2549 | szcon_printf db 'con_printf',0 |
2550 | szcon_exit db 'con_exit',0 |
||
2551 | szVersion db 'version',0 |
||
2552 | szcon_get_flags db 'con_get_flags',0 |
||
2553 | szcon_set_flags db 'con_set_flags',0 |
||
2554 | szcon_kbhit db 'con_kbhit',0 |
||
2555 | szcon_getch db 'con_getch',0 |
||
2556 | szcon_getch2 db 'con_getch2',0 |
||
2557 | szcon_gets db 'con_gets',0 |
||
852 | diamond | 2558 | szcon_gets2 db 'con_gets2',0 |
836 | diamond | 2559 | szcon_get_font_height db 'con_get_font_height',0 |
2560 | szcon_get_cursor_height db 'con_get_cursor_height',0 |
||
2561 | szcon_set_cursor_height db 'con_set_cursor_height',0 |
||
853 | diamond | 2562 | szcon_cls db 'con_cls',0 |
2563 | szcon_get_cursor_pos db 'con_get_cursor_pos',0 |
||
2564 | szcon_set_cursor_pos db 'con_set_cursor_pos',0 |
||
836 | diamond | 2565 | |
2566 | con.thread_err db 'Cannot create console thread!',13,10,0 |
||
2567 | con.nomem_err db 'Not enough memory!',13,10,0 |
||
2568 | con.aFinished db ' [Finished]',0 |
||
2569 | con.aNull db '(null)',0 |
||
2570 | con.beep db 0x90, 0x3C, 0x00 |
||
2571 | con.ipc_buf dd 0,8,0,0 |
||
2572 | db 0 |
||
2573 | |||
2574 | section '.data' data readable writable align 16 |
||
2575 | |||
2576 | con.finished_title rb 256 |
||
2577 | |||
2578 | con.cur_x rd 1 |
||
2579 | con.cur_y rd 1 |
||
2580 | con.wnd_xpos rd 1 |
||
2581 | con.wnd_ypos rd 1 |
||
2582 | |||
2583 | con.wnd_width rd 1 |
||
2584 | con.wnd_height rd 1 |
||
2585 | con.scr_width rd 1 |
||
2586 | con.scr_height rd 1 |
||
2587 | con.title rd 1 |
||
2588 | con.data rd 1 |
||
2589 | con.image rd 1 |
||
2590 | con.console_tid rd 1 |
||
2591 | con.data_width rw 1 |
||
2592 | con.data_height rw 1 |
||
2593 | con.vscrollbar_size rd 1 |
||
2594 | con.vscrollbar_pos rd 1 |
||
2595 | con.up_first_time rd 1 |
||
2596 | con.down_first_time rd 1 |
||
2597 | con.scroll_up_first_time rd 1 |
||
2598 | con.scroll_down_first_time rd 1 |
||
2599 | con.bUpPressed_saved rb 1 |
||
2600 | con.bDownPressed_saved rb 1 |
||
2601 | con.bScrollingUp_saved rb 1 |
||
2602 | con.bScrollingDown_saved rb 1 |
||
2603 | |||
2604 | con.input_buffer rw 128 |
||
2605 | con.input_buffer_end = $ |
||
2606 | |||
2607 | con.kbd_layout rb 128 |
||
2608 | |||
2609 | ; 1 = exit, 2 = set title, 3 = redraw, 4 = getch |
||
2610 | con.thread_op rb 1 |
||
2611 | con.bUpPressed rb 1 |
||
2612 | con.bDownPressed rb 1 |
||
2613 | con.bScrollingUp rb 1 |
||
2614 | con.bScrollingDown rb 1 |
||
2615 | |||
2616 | con.stack rb 1024 |
||
2617 | con.stack_top = $ |