Rev 9125 | Rev 9163 | 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 | include 'font.inc' |
||
11 | include 'conscrl.inc' |
||
12 | |||
9105 | hidnplayr | 13 | struc process_info |
14 | { |
||
15 | .cpu_usage dd ? ; +0 |
||
16 | .window_stack_position dw ? ; +4 |
||
17 | .window_stack_value dw ? ; +6 |
||
18 | dw ? ; +8 |
||
19 | .process_name rb 12 ; +10 |
||
20 | .memory_start dd ? ; +22 |
||
21 | .used_memory dd ? ; +26 |
||
22 | .PID dd ? ; +30 |
||
23 | .box.x dd ? ; +34 |
||
24 | .box.y dd ? ; +38 |
||
25 | .box.width dd ? ; +42 |
||
26 | .box.height dd ? ; +46 |
||
27 | .slot_state dw ? ; +50 |
||
28 | dw ? ; +52 |
||
29 | .client_box.x dd ? ; +54 |
||
30 | .client_box.y dd ? ; +58 |
||
31 | .client_box.width dd ? ; +62 |
||
32 | .client_box.height dd ? ; +66 |
||
33 | .wnd_state db ? ; +70 |
||
34 | rb (1024-71) |
||
35 | } |
||
36 | |||
37 | OP_EXIT = 1 |
||
38 | OP_SET_TITLE = 2 |
||
39 | OP_REDRAW = 3 |
||
40 | OP_GETCH = 4 |
||
41 | OP_RESIZE = 5 |
||
42 | |||
836 | diamond | 43 | ;void __stdcall START(dword state); |
44 | START: |
||
45 | ; N.B. The current kernel implementation does not require |
||
46 | ; evident heap initialization, because if DLL is loaded, heap is already initialized |
||
47 | ; (if heap was not initialized, loader does this implicitly). |
||
48 | ; So this action does nothing useful, but nothing harmful. |
||
6067 | serge | 49 | push ebx |
836 | diamond | 50 | push 68 |
51 | pop eax |
||
52 | push 11 |
||
53 | pop ebx |
||
54 | int 0x40 |
||
6067 | serge | 55 | pop ebx |
836 | diamond | 56 | or eax, -1 |
57 | ret 4 |
||
58 | |||
59 | ; Инициализация консоли |
||
60 | ; void __stdcall con_init(dword wnd_width, dword wnd_height, |
||
61 | ; dword scr_width, dword scr_height, const char* title); |
||
62 | |||
63 | align 4 |
||
64 | con_init: |
||
6067 | serge | 65 | |
836 | diamond | 66 | pop eax |
67 | pop [con.wnd_width] |
||
68 | pop [con.wnd_height] |
||
9105 | hidnplayr | 69 | pop [con.main_scr_width] |
70 | pop [con.main_scr_height] |
||
836 | diamond | 71 | pop [con.title] |
72 | push eax |
||
2170 | serge | 73 | |
9105 | hidnplayr | 74 | push ebx |
2170 | serge | 75 | |
9105 | hidnplayr | 76 | mov [con.init_cmd],1 |
6067 | serge | 77 | |
836 | diamond | 78 | mov ecx, 4 |
79 | mov eax, con.wnd_width |
||
2170 | serge | 80 | mov edx, con.def_wnd_width |
9105 | hidnplayr | 81 | .1: |
836 | diamond | 82 | cmp dword [eax], -1 |
83 | jnz @f |
||
2170 | serge | 84 | mov ebx, [edx] |
836 | diamond | 85 | mov [eax], ebx |
9105 | hidnplayr | 86 | @@: |
836 | diamond | 87 | add eax, 4 |
2170 | serge | 88 | add edx, 4 |
836 | diamond | 89 | loop .1 |
9105 | hidnplayr | 90 | |
91 | ; Allocate memory for console data & bitmap data |
||
92 | ; First, calculate required amount of bytes |
||
93 | |||
94 | ; Main buffer |
||
95 | mov eax, [con.main_scr_width] |
||
96 | mul [con.main_scr_height] |
||
97 | ; 2 bytes per on-screen character (1 flags and 1 ascii) |
||
836 | diamond | 98 | lea ecx, [eax+eax] |
9105 | hidnplayr | 99 | |
100 | ; Alternate buffer |
||
101 | mov [con.altbuffer], ecx |
||
836 | diamond | 102 | mov eax, [con.wnd_width] |
103 | mul [con.wnd_height] |
||
9105 | hidnplayr | 104 | ; 2 bytes per on-screen character (1 flags and 1 ascii) |
105 | lea ecx, [ecx+2*eax] |
||
106 | |||
107 | ; Bitmap data |
||
108 | mov eax, [con.wnd_width] |
||
109 | mul [con.wnd_height] |
||
836 | diamond | 110 | imul eax, font_width*font_height |
111 | mov ebx, eax |
||
112 | push ebx ecx |
||
113 | add ecx, eax |
||
9105 | hidnplayr | 114 | |
115 | ; malloc |
||
836 | diamond | 116 | push 68 |
117 | pop eax |
||
118 | push 12 |
||
119 | pop ebx |
||
120 | int 0x40 |
||
121 | pop ecx ebx |
||
122 | mov edx, con.nomem_err |
||
123 | test eax, eax |
||
9105 | hidnplayr | 124 | jz .fatal |
125 | |||
126 | ; Set pointers to the buffers |
||
127 | mov [con.mainbuffer], eax |
||
128 | add [con.altbuffer], eax |
||
129 | |||
130 | ; Set active buffer pointer and dimensions |
||
836 | diamond | 131 | mov [con.data], eax |
9105 | hidnplayr | 132 | |
133 | push [con.main_scr_width] |
||
134 | pop [con.scr_width] |
||
135 | |||
136 | push [con.main_scr_height] |
||
137 | pop [con.scr_height] |
||
138 | |||
139 | ; Clear text buffers |
||
836 | diamond | 140 | push edi |
141 | mov edi, eax |
||
142 | shr ecx, 1 |
||
143 | mov ax, 0x0720 |
||
144 | rep stosw |
||
9105 | hidnplayr | 145 | |
146 | ; Clear bitmap buffer |
||
836 | diamond | 147 | mov ecx, ebx |
148 | mov [con.image], edi |
||
149 | xor eax, eax |
||
150 | rep stosb |
||
151 | pop edi |
||
1133 | diamond | 152 | and byte [con_flags+1], not 2 |
9105 | hidnplayr | 153 | |
836 | diamond | 154 | ; create console thread |
155 | push 51 |
||
156 | pop eax |
||
157 | xor ebx, ebx |
||
158 | inc ebx |
||
159 | mov ecx, con.thread |
||
160 | mov edx, con.stack_top |
||
161 | int 0x40 |
||
162 | mov edx, con.thread_err |
||
163 | test eax, eax |
||
9105 | hidnplayr | 164 | js .fatal |
836 | diamond | 165 | mov [con.console_tid], eax |
166 | pop ebx |
||
167 | ret |
||
9105 | hidnplayr | 168 | |
169 | .fatal: |
||
836 | diamond | 170 | ; output string to debug board and die |
171 | mov cl, [edx] |
||
172 | test cl, cl |
||
173 | jz @f |
||
174 | push 63 |
||
175 | pop eax |
||
176 | xor ebx, ebx |
||
177 | inc ebx |
||
178 | int 0x40 |
||
179 | inc edx |
||
9105 | hidnplayr | 180 | jmp .fatal |
181 | @@: |
||
836 | diamond | 182 | or eax, -1 |
183 | int 0x40 |
||
184 | |||
185 | ; dword __stdcall con_get_flags(void); |
||
186 | con_get_flags: |
||
187 | mov eax, [con_flags] |
||
188 | ret |
||
189 | |||
190 | ; dword __stdcall con_set_flags(dword flags); |
||
191 | con_set_flags: |
||
192 | mov eax, [esp+4] |
||
1133 | diamond | 193 | and ah, not 2 |
836 | diamond | 194 | xchg eax, [con_flags] |
195 | ret 4 |
||
196 | |||
197 | ; dword __stdcall con_get_font_height(void); |
||
198 | con_get_font_height: |
||
199 | mov eax, font_height |
||
200 | ret |
||
201 | |||
202 | ; int __stdcall con_get_cursor_height(void); |
||
203 | con_get_cursor_height: |
||
204 | mov eax, [con.cursor_height] |
||
205 | ret |
||
206 | |||
207 | ; int __stdcall con_set_cursor_height(int new_height); |
||
208 | con_set_cursor_height: |
||
209 | mov eax, [esp+4] |
||
210 | cmp eax, font_height |
||
211 | jae @f |
||
212 | xchg eax, [con.cursor_height] |
||
213 | ret 4 |
||
9105 | hidnplayr | 214 | @@: |
836 | diamond | 215 | mov eax, [con.cursor_height] |
216 | ret 4 |
||
217 | |||
5835 | pavelyakov | 218 | con_init_check: |
9105 | hidnplayr | 219 | mov ah, [con.init_cmd] |
220 | test ah, ah |
||
221 | jne .yes |
||
6067 | serge | 222 | |
9105 | hidnplayr | 223 | push con.title_init_console |
224 | push -1 |
||
225 | push -1 |
||
226 | push -1 |
||
227 | push -1 |
||
6067 | serge | 228 | |
9105 | hidnplayr | 229 | call con_init |
230 | .yes: |
||
231 | ret |
||
6067 | serge | 232 | |
836 | diamond | 233 | ; void __stdcall con_write_asciiz(const char* string); |
234 | con_write_asciiz: |
||
9105 | hidnplayr | 235 | |
236 | call con_init_check |
||
237 | |||
836 | diamond | 238 | push ebx esi |
239 | or ebx, -1 |
||
240 | mov esi, [esp+12] |
||
241 | call con.write |
||
242 | pop esi ebx |
||
243 | ret 4 |
||
244 | |||
245 | ; void __stdcall con_write_string(const char* string, dword length); |
||
246 | con_write_length: |
||
9105 | hidnplayr | 247 | |
836 | diamond | 248 | push ebx esi |
249 | mov esi, [esp+12] |
||
250 | mov ebx, [esp+16] |
||
251 | call con.write |
||
252 | pop esi ebx |
||
253 | ret 8 |
||
254 | |||
255 | ; Каждый символ классифицируется как один из |
||
256 | con.printfc.normal = 0 ; нормальный символ |
||
257 | con.printfc.percent = 1 ; '%' |
||
258 | con.printfc.dot = 2 ; '.' |
||
259 | con.printfc.asterisk = 3 ; '*' |
||
260 | con.printfc.zero = 4 ; '0' |
||
261 | con.printfc.digit = 5 ; ненулевая цифра |
||
262 | con.printfc.plus = 6 ; '+' |
||
263 | con.printfc.minus = 7 ; '-' |
||
264 | con.printfc.sharp = 8 ; '#' |
||
265 | con.printfc.space = 9 ; ' ' |
||
266 | con.printfc.long = 10 ; 'l' for 'long' |
||
267 | con.printfc.short = 11 ; 'h' for 'short' |
||
268 | con.printfc.dec = 12 ; 'd' = print decimal |
||
269 | con.printfc.oct = 13 ; 'o' = print octal |
||
270 | con.printfc.unsigned = 14 ; 'u' = print unsigned decimal |
||
271 | con.printfc.hex = 15 ; 'x' = print hexadecimal |
||
272 | con.printfc.pointer = 16 ; 'p' = print pointer |
||
273 | con.printfc.char = 17 ; 'c' = print char |
||
274 | con.printfc.string = 18 ; 's' = print string |
||
275 | |||
276 | macro set char,type |
||
277 | {store byte con.printfc.#type at con.charcodes + char - ' '} |
||
278 | |||
279 | con.charcodes: |
||
280 | times 'x'-' '+1 db con.printfc.normal |
||
281 | set '%', percent |
||
282 | set '.', dot |
||
283 | set '*', asterisk |
||
284 | set '0', zero |
||
285 | set '1', digit |
||
286 | set '2', digit |
||
287 | set '3', digit |
||
288 | set '4', digit |
||
289 | set '5', digit |
||
290 | set '6', digit |
||
291 | set '7', digit |
||
292 | set '8', digit |
||
293 | set '9', digit |
||
294 | set ' ', space |
||
295 | set '#', sharp |
||
296 | set '+', plus |
||
297 | set '-', minus |
||
298 | set 'X', hex |
||
299 | set 'x', hex |
||
300 | set 'c', char |
||
301 | set 'd', dec |
||
302 | set 'h', short |
||
303 | set 'i', dec |
||
304 | set 'l', long |
||
305 | set 'o', oct |
||
306 | set 'p', pointer |
||
307 | set 's', string |
||
308 | set 'u', unsigned |
||
309 | purge set |
||
310 | align 4 |
||
3690 | hidnplayr | 311 | con.charjump: |
312 | dd con_printf.normal |
||
836 | diamond | 313 | dd con_printf.percent |
314 | dd con_printf.dot |
||
315 | dd con_printf.asterisk |
||
316 | dd con_printf.zero |
||
317 | dd con_printf.digit |
||
318 | dd con_printf.plus |
||
319 | dd con_printf.minus |
||
320 | dd con_printf.sharp |
||
321 | dd con_printf.space |
||
322 | dd con_printf.long |
||
323 | dd con_printf.short |
||
324 | dd con_printf.dec |
||
325 | dd con_printf.oct |
||
326 | dd con_printf.unsigned |
||
327 | dd con_printf.hex |
||
328 | dd con_printf.pointer |
||
329 | dd con_printf.char |
||
330 | dd con_printf.string |
||
331 | |||
332 | ; int __cdecl con_printf(const char* format, ...) |
||
333 | con_printf: |
||
9105 | hidnplayr | 334 | |
335 | call con_init_check |
||
336 | |||
836 | diamond | 337 | xor eax, eax |
338 | pushad |
||
339 | call con.get_data_ptr |
||
340 | lea ebp, [esp+20h+8] |
||
341 | mov esi, [ebp-4] |
||
342 | sub esp, 64 ; reserve space for buffer |
||
9105 | hidnplayr | 343 | .loop: |
836 | diamond | 344 | xor eax, eax |
345 | lodsb |
||
346 | test al, al |
||
347 | jz .done |
||
348 | cmp al, '%' |
||
349 | jz .spec_begin |
||
9105 | hidnplayr | 350 | .normal: |
836 | diamond | 351 | call con.write_char_ex |
352 | inc dword [esp+64+28] |
||
353 | jmp .loop |
||
9105 | hidnplayr | 354 | .errspec: |
355 | .percent: |
||
836 | diamond | 356 | add esp, 12 |
357 | jmp .normal |
||
9105 | hidnplayr | 358 | .spec_begin: |
836 | diamond | 359 | xor ebx, ebx |
360 | ; bl = тип позиции: |
||
361 | ; 0 = начало |
||
362 | ; 1 = прочитан ведущий 0 в спецификации формата |
||
363 | ; 2 = читаем поле ширины |
||
364 | ; 3 = читаем поле точности |
||
365 | ; 4 = прочитано поле размера аргумента |
||
366 | ; 5 = читаем поле типа |
||
367 | ; bh = флаги: |
||
368 | ; 1 = флаг '#', выводить 0/0x/0X |
||
369 | ; 2 = флаг '-', выравнивание влево |
||
370 | ; 4 = флаг '0', дополнение нулями |
||
371 | ; 8 = флаг 'h', короткий аргумент |
||
372 | push -1 |
||
373 | ; dword [esp+8] = precision |
||
374 | push -1 |
||
375 | ; dword [esp+4] = width |
||
376 | push 0 |
||
377 | ; byte [esp] = флаг 0/'+'/' ' |
||
9105 | hidnplayr | 378 | .spec: |
836 | diamond | 379 | xor eax, eax |
380 | lodsb |
||
381 | test al, al |
||
382 | jz .done |
||
383 | cmp al, ' ' |
||
384 | jb .normal |
||
385 | cmp al, 'x' |
||
386 | ja .normal |
||
387 | movzx ecx, byte [con.charcodes + eax - ' '] |
||
3690 | hidnplayr | 388 | jmp dword[con.charjump + ecx*4] |
836 | diamond | 389 | |
9105 | hidnplayr | 390 | .sharp: |
836 | diamond | 391 | test bl, bl |
392 | jnz .errspec |
||
393 | or bh, 1 |
||
394 | jmp .spec |
||
9105 | hidnplayr | 395 | .minus: |
836 | diamond | 396 | test bl, bl |
397 | jnz .errspec |
||
398 | or bh, 2 |
||
399 | jmp .spec |
||
9105 | hidnplayr | 400 | .plus: |
401 | .space: |
||
836 | diamond | 402 | test bl, bl |
403 | jnz .errspec |
||
404 | cmp byte [esp], '+' |
||
405 | jz .spec |
||
406 | mov byte [esp], al |
||
407 | jmp .spec |
||
9105 | hidnplayr | 408 | .zero: |
836 | diamond | 409 | test bl, bl |
410 | jnz .digit |
||
411 | test bh, 2 |
||
412 | jnz .spec |
||
413 | or bh, 4 |
||
414 | inc ebx |
||
415 | jmp .spec |
||
9105 | hidnplayr | 416 | .digit: |
836 | diamond | 417 | sub al, '0' |
418 | cmp bl, 2 |
||
419 | ja .precision |
||
420 | mov bl, 2 |
||
421 | xchg eax, [esp+4] |
||
422 | test eax, eax |
||
423 | js .spec |
||
424 | lea eax, [eax*5] |
||
425 | add eax, eax |
||
426 | add [esp+4], eax |
||
427 | jmp .spec |
||
9105 | hidnplayr | 428 | .precision: |
836 | diamond | 429 | cmp bl, 3 |
430 | jnz .errspec |
||
431 | xchg eax, [esp+8] |
||
432 | lea eax, [eax*5] |
||
433 | add eax, eax |
||
434 | add [esp+8], eax |
||
435 | jmp .spec |
||
9105 | hidnplayr | 436 | .asterisk: |
836 | diamond | 437 | mov eax, [ebp] |
438 | add ebp, 4 |
||
439 | cmp bl, 2 |
||
440 | ja .asterisk_precision |
||
441 | test eax, eax |
||
442 | jns @f |
||
443 | neg eax |
||
444 | or bh, 2 |
||
9105 | hidnplayr | 445 | @@: |
836 | diamond | 446 | mov [esp+4], eax |
447 | mov bl, 3 |
||
448 | jmp .spec |
||
9105 | hidnplayr | 449 | .asterisk_precision: |
836 | diamond | 450 | cmp bl, 3 |
451 | jnz .errspec |
||
452 | mov [esp+8], eax |
||
453 | inc ebx |
||
454 | jmp .spec |
||
9105 | hidnplayr | 455 | .dot: |
836 | diamond | 456 | cmp bl, 2 |
457 | ja .errspec |
||
458 | mov bl, 3 |
||
459 | and dword [esp+8], 0 |
||
460 | jmp .spec |
||
9105 | hidnplayr | 461 | .long: |
836 | diamond | 462 | cmp bl, 3 |
463 | ja .errspec |
||
464 | mov bl, 4 |
||
465 | jmp .spec |
||
9105 | hidnplayr | 466 | .short: |
836 | diamond | 467 | cmp bl, 3 |
468 | ja .errspec |
||
469 | mov bl, 4 |
||
470 | or bh, 8 |
||
471 | jmp .spec |
||
9105 | hidnplayr | 472 | .unsigned: |
473 | .dec: |
||
836 | diamond | 474 | push 10 |
475 | jmp .write_number |
||
9105 | hidnplayr | 476 | .pointer: |
836 | diamond | 477 | mov dword [esp+12], 8 |
478 | or bh, 4 |
||
479 | and bh, not 8 |
||
9105 | hidnplayr | 480 | .hex: |
836 | diamond | 481 | push 16 |
482 | jmp @f |
||
9105 | hidnplayr | 483 | .oct: |
836 | diamond | 484 | push 8 |
9105 | hidnplayr | 485 | @@: |
836 | diamond | 486 | mov byte [esp+4], 0 |
9105 | hidnplayr | 487 | .write_number: |
836 | diamond | 488 | pop ecx |
489 | push edi |
||
490 | lea edi, [esp+16+64-1] ; edi -> end of buffer |
||
491 | mov byte [edi], 0 |
||
492 | push edx |
||
493 | push eax |
||
494 | mov eax, [ebp] |
||
495 | add ebp, 4 |
||
496 | test bh, 8 |
||
497 | jz @f |
||
498 | movzx eax, ax |
||
499 | cmp byte [esp], 'd' |
||
500 | jnz @f |
||
501 | movsx eax, ax |
||
9105 | hidnplayr | 502 | @@: |
836 | diamond | 503 | xor edx, edx |
504 | test eax, eax |
||
505 | jns @f |
||
506 | cmp byte [esp], 'd' |
||
507 | jnz @f |
||
508 | inc edx |
||
509 | neg eax |
||
9105 | hidnplayr | 510 | @@: |
836 | diamond | 511 | push edx |
512 | xor edx, edx |
||
513 | ; число в eax, основание системы счисления в ecx |
||
9105 | hidnplayr | 514 | @@: |
836 | diamond | 515 | cmp dword [esp+16+8], 0 |
516 | jnz .print_num |
||
517 | test eax, eax |
||
518 | jz .zeronum |
||
9105 | hidnplayr | 519 | .print_num: |
836 | diamond | 520 | div ecx |
521 | xchg eax, edx |
||
522 | cmp al, 10 |
||
523 | sbb al, 69h |
||
524 | das |
||
525 | cmp byte [esp+4], 'x' |
||
526 | jnz @f |
||
527 | or al, 20h |
||
9105 | hidnplayr | 528 | @@: |
836 | diamond | 529 | dec edi |
530 | mov [edi], al |
||
531 | xor eax, eax |
||
532 | xchg eax, edx |
||
533 | test eax, eax |
||
534 | jnz .print_num |
||
9105 | hidnplayr | 535 | .zeronum: |
836 | diamond | 536 | push 0 |
537 | mov edx, [esp+12] |
||
538 | lea eax, [esp+32+64-1] |
||
539 | sub eax, edi |
||
540 | cmp dword [esp+20+8], -1 |
||
541 | jz .noprec1 |
||
542 | cmp eax, [esp+20+8] |
||
543 | jae .len_found1 |
||
544 | mov eax, [esp+20+8] |
||
545 | jmp .len_found1 |
||
9105 | hidnplayr | 546 | .noprec1: |
836 | diamond | 547 | test bh, 4 |
548 | jnz .do_print_num |
||
9105 | hidnplayr | 549 | .len_found1: |
836 | diamond | 550 | test bh, 2 |
551 | jnz .do_print_num |
||
552 | cmp byte [esp+20], 0 |
||
553 | jz @f |
||
554 | inc eax |
||
9105 | hidnplayr | 555 | @@: |
836 | diamond | 556 | cmp byte [esp+20], 0 |
557 | jnz @f |
||
558 | cmp byte [esp+4], 0 |
||
559 | jz @f |
||
560 | inc eax |
||
9105 | hidnplayr | 561 | @@: |
836 | diamond | 562 | test bh, 1 |
563 | jz .nosharp1 |
||
564 | cmp cl, 8 |
||
565 | jnz @f |
||
566 | inc eax |
||
567 | jmp .nosharp1 |
||
9105 | hidnplayr | 568 | @@: |
836 | diamond | 569 | cmp cl, 16 |
570 | jnz .nosharp1 |
||
571 | inc eax |
||
572 | inc eax |
||
9105 | hidnplayr | 573 | .nosharp1: |
836 | diamond | 574 | cmp dword [esp+20+4], -1 |
575 | jz .do_print_num |
||
576 | sub eax, [esp+20+4] |
||
577 | jae .do_print_num |
||
578 | push ecx |
||
579 | mov ecx, eax |
||
580 | mov al, ' ' |
||
9105 | hidnplayr | 581 | @@: |
836 | diamond | 582 | xchg edi, [esp+20] |
583 | call con.write_char_ex |
||
584 | inc dword [esp+24+12+64+28] |
||
585 | xchg edi, [esp+20] |
||
586 | inc dword [esp+4] |
||
587 | inc ecx |
||
588 | jnz @b |
||
589 | pop ecx |
||
9105 | hidnplayr | 590 | .do_print_num: |
836 | diamond | 591 | mov al, '-' |
592 | cmp byte [esp+4], 0 |
||
593 | jnz .write_sign |
||
594 | mov al, [esp+20] |
||
595 | test al, al |
||
596 | jz .sign_written |
||
9105 | hidnplayr | 597 | .write_sign: |
836 | diamond | 598 | call .num_write_char |
9105 | hidnplayr | 599 | .sign_written: |
836 | diamond | 600 | test bh, 1 |
601 | jz .nosharp2 |
||
602 | mov al, '0' |
||
603 | cmp cl, 8 |
||
604 | jz @f |
||
605 | cmp cl, 16 |
||
606 | jnz .nosharp2 |
||
607 | call .num_write_char |
||
608 | mov al, [esp+8] |
||
9105 | hidnplayr | 609 | @@: |
836 | diamond | 610 | call .num_write_char |
9105 | hidnplayr | 611 | .nosharp2: |
836 | diamond | 612 | lea ecx, [esp+32+64-1] |
613 | sub ecx, edi |
||
614 | cmp dword [esp+20+8], -1 |
||
615 | jz .noprec2 |
||
616 | sub ecx, [esp+20+8] |
||
617 | jmp .lead_zeroes |
||
9105 | hidnplayr | 618 | .noprec2: |
836 | diamond | 619 | test bh, 4 |
620 | jz .do_print_num2 |
||
621 | add ecx, [esp] |
||
622 | sub ecx, [esp+20+4] |
||
9105 | hidnplayr | 623 | .lead_zeroes: |
836 | diamond | 624 | jae .do_print_num2 |
9105 | hidnplayr | 625 | @@: |
836 | diamond | 626 | mov al, '0' |
627 | call .num_write_char |
||
628 | inc ecx |
||
629 | jnz @b |
||
9105 | hidnplayr | 630 | .do_print_num2: |
836 | diamond | 631 | mov al, [edi] |
632 | test al, al |
||
633 | jz .num_written |
||
634 | call .num_write_char |
||
635 | inc edi |
||
636 | jmp .do_print_num2 |
||
9105 | hidnplayr | 637 | .num_written: |
836 | diamond | 638 | pop ecx |
639 | mov edi, [esp+12] |
||
640 | cmp dword [esp+16+4], -1 |
||
641 | jz .num_written2 |
||
9105 | hidnplayr | 642 | @@: |
836 | diamond | 643 | cmp ecx, [esp+16+4] |
644 | jae .num_written2 |
||
645 | mov al, ' ' |
||
646 | call con.write_char |
||
647 | inc ecx |
||
648 | jmp @b |
||
9105 | hidnplayr | 649 | .num_written2: |
836 | diamond | 650 | add esp, 16 |
9105 | hidnplayr | 651 | .spec_done: |
836 | diamond | 652 | add esp, 12 |
653 | jmp .loop |
||
9105 | hidnplayr | 654 | .char: |
836 | diamond | 655 | mov ecx, [esp+4] |
656 | cmp ecx, -1 |
||
657 | jnz @f |
||
658 | inc ecx |
||
9105 | hidnplayr | 659 | @@: |
836 | diamond | 660 | test ecx, ecx |
661 | jnz @f |
||
662 | inc ecx |
||
9105 | hidnplayr | 663 | @@: |
836 | diamond | 664 | test bh, 2 |
665 | jnz .char_left_pad |
||
666 | mov al, ' ' |
||
667 | dec ecx |
||
668 | jz .nowidth |
||
669 | add [esp+12+64+28], ecx |
||
9105 | hidnplayr | 670 | @@: |
836 | diamond | 671 | call con.write_char |
672 | loop @b |
||
9105 | hidnplayr | 673 | .nowidth: |
836 | diamond | 674 | mov al, [ebp] |
675 | add ebp, 4 |
||
676 | jmp .percent |
||
9105 | hidnplayr | 677 | .char_left_pad: |
836 | diamond | 678 | mov al, [ebp] |
679 | add ebp, 4 |
||
680 | call con.write_char_ex |
||
681 | add [esp+12+64+28], ecx |
||
682 | dec ecx |
||
683 | jz .nowidth2 |
||
684 | mov al, ' ' |
||
9105 | hidnplayr | 685 | @@: |
836 | diamond | 686 | call con.write_char |
687 | loop @b |
||
9105 | hidnplayr | 688 | .nowidth2: |
836 | diamond | 689 | jmp .spec_done |
9105 | hidnplayr | 690 | .string: |
836 | diamond | 691 | push esi |
692 | mov esi, [ebp] |
||
693 | test esi, esi |
||
694 | jnz @f |
||
695 | mov esi, con.aNull |
||
9105 | hidnplayr | 696 | @@: |
836 | diamond | 697 | add ebp, 4 |
698 | or ecx, -1 |
||
9105 | hidnplayr | 699 | @@: |
836 | diamond | 700 | inc ecx |
701 | cmp byte [esi+ecx], 0 |
||
702 | jnz @b |
||
703 | cmp ecx, [esp+12] |
||
704 | jb @f |
||
705 | mov ecx, [esp+12] |
||
9105 | hidnplayr | 706 | @@: |
836 | diamond | 707 | test bh, 2 |
708 | jnz .write_string |
||
709 | cmp dword [esp+8], -1 |
||
710 | jz .write_string |
||
711 | push ecx |
||
712 | sub ecx, [esp+12] |
||
713 | jae .nospace |
||
714 | mov al, ' ' |
||
9105 | hidnplayr | 715 | @@: |
836 | diamond | 716 | call con.write_char |
717 | inc dword [esp+20+64+28] |
||
718 | inc ecx |
||
719 | jnz @b |
||
9105 | hidnplayr | 720 | .nospace: |
836 | diamond | 721 | pop ecx |
9105 | hidnplayr | 722 | .write_string: |
836 | diamond | 723 | jecxz .string_written |
724 | add dword [esp+16+64+28], ecx |
||
725 | push ecx |
||
9105 | hidnplayr | 726 | @@: |
836 | diamond | 727 | lodsb |
728 | call con.write_char_ex |
||
729 | loop @b |
||
730 | pop ecx |
||
9105 | hidnplayr | 731 | .string_written: |
836 | diamond | 732 | pop esi |
733 | test bh, 2 |
||
734 | jz .spec_done |
||
735 | cmp dword [esp+4], -1 |
||
736 | jz .spec_done |
||
737 | sub ecx, [esp+4] |
||
738 | jae .spec_done |
||
739 | mov al, ' ' |
||
9105 | hidnplayr | 740 | @@: |
836 | diamond | 741 | call con.write_char |
742 | inc dword [esp+12+64+28] |
||
743 | inc ecx |
||
744 | jnz @b |
||
745 | jmp .spec_done |
||
9105 | hidnplayr | 746 | .done: |
836 | diamond | 747 | add esp, 64 |
748 | popad |
||
749 | jmp con.update_screen |
||
9105 | hidnplayr | 750 | .num_write_char: |
836 | diamond | 751 | xchg edi, [esp+20] |
752 | call con.write_char_ex |
||
753 | inc dword [esp+24+12+64+28] |
||
754 | xchg edi, [esp+20] |
||
755 | inc dword [esp+4] |
||
756 | ret |
||
757 | |||
758 | con.write: |
||
759 | ; esi = string, ebx = length (ebx=-1 for ASCIIZ strings) |
||
760 | push edi |
||
761 | call con.get_data_ptr |
||
762 | test ebx, ebx |
||
763 | jz .done |
||
9105 | hidnplayr | 764 | .loop: |
836 | diamond | 765 | lodsb |
766 | cmp ebx, -1 |
||
767 | jnz @f |
||
768 | test al, al |
||
769 | jz .done |
||
9105 | hidnplayr | 770 | @@: |
836 | diamond | 771 | call con.write_char_ex |
9105 | hidnplayr | 772 | .next: |
836 | diamond | 773 | cmp ebx, -1 |
774 | jz .loop |
||
775 | dec ebx |
||
776 | jnz .loop |
||
9105 | hidnplayr | 777 | .done: |
836 | diamond | 778 | pop edi |
779 | jmp con.update_screen |
||
780 | |||
781 | con.get_data_ptr: |
||
782 | mov edi, [con.cur_y] |
||
783 | imul edi, [con.scr_width] |
||
784 | add edi, [con.cur_x] |
||
785 | add edi, edi |
||
786 | add edi, [con.data] |
||
787 | ret |
||
788 | |||
789 | con.write_char_ex: |
||
790 | test byte [con_flags+1], 1 |
||
791 | jz con.write_special_char |
||
792 | |||
793 | con.write_char: |
||
794 | push eax |
||
3690 | hidnplayr | 795 | |
796 | mov eax, [con.cur_x] |
||
797 | cmp eax, [con.scr_width] |
||
798 | jb @f |
||
799 | and [con.cur_x], 0 |
||
800 | call con.newline |
||
9105 | hidnplayr | 801 | @@: |
3690 | hidnplayr | 802 | mov eax, [esp] |
836 | diamond | 803 | stosb |
804 | mov al, byte [con_flags] |
||
805 | stosb |
||
3690 | hidnplayr | 806 | |
836 | diamond | 807 | mov eax, [con.cur_x] |
808 | inc eax |
||
809 | mov [con.cur_x], eax |
||
3690 | hidnplayr | 810 | |
836 | diamond | 811 | pop eax |
812 | ret |
||
813 | |||
814 | con.write_special_char: |
||
815 | cmp [con_esc], 0 |
||
816 | jnz .esc_mode |
||
9105 | hidnplayr | 817 | .normal_mode: |
836 | diamond | 818 | cmp al, 10 |
819 | jz .write_lf |
||
820 | cmp al, 13 |
||
821 | jz .write_cr |
||
822 | cmp al, 27 |
||
823 | jz .write_esc |
||
824 | cmp al, 8 |
||
825 | jz .write_bs |
||
9096 | hidnplayr | 826 | cmp al, 7 |
827 | jz .bell |
||
836 | diamond | 828 | cmp al, 9 |
829 | jnz con.write_char |
||
9105 | hidnplayr | 830 | .write_tab: |
836 | diamond | 831 | mov al, ' ' |
832 | call con.write_char |
||
833 | test [con.cur_x], 7 |
||
834 | jnz .write_tab |
||
835 | ret |
||
9105 | hidnplayr | 836 | .write_cr: |
836 | diamond | 837 | and [con.cur_x], 0 |
838 | jmp con.get_data_ptr |
||
9105 | hidnplayr | 839 | .write_lf: |
836 | diamond | 840 | and [con.cur_x], 0 |
841 | jmp con.newline |
||
9105 | hidnplayr | 842 | .write_bs: |
836 | diamond | 843 | cmp [con.cur_x], 0 |
844 | jz @f |
||
845 | dec [con.cur_x] |
||
846 | dec edi |
||
847 | dec edi |
||
848 | ret |
||
9105 | hidnplayr | 849 | @@: |
836 | diamond | 850 | push eax |
851 | mov eax, [con.cur_y] |
||
852 | dec eax |
||
853 | js @f |
||
854 | mov [con.cur_y], eax |
||
855 | mov eax, [con.scr_width] |
||
856 | dec eax |
||
857 | mov [con.cur_x], eax |
||
858 | dec edi |
||
859 | dec edi |
||
9105 | hidnplayr | 860 | @@: |
836 | diamond | 861 | pop eax |
862 | ret |
||
9105 | hidnplayr | 863 | .bell: |
9096 | hidnplayr | 864 | pusha |
865 | push 55 |
||
866 | pop eax |
||
867 | mov ebx, eax |
||
9105 | hidnplayr | 868 | mov esi, con.bell |
9096 | hidnplayr | 869 | int 0x40 |
870 | popa |
||
871 | ret |
||
9105 | hidnplayr | 872 | .write_esc: |
836 | diamond | 873 | mov [con_esc], 1 |
874 | mov [con_esc_attr_n], 1 |
||
875 | and [con_esc_attrs], 0 |
||
876 | ret |
||
9105 | hidnplayr | 877 | |
878 | .esc_mode: |
||
836 | diamond | 879 | cmp [con_sci], 0 |
880 | jnz .esc_sci |
||
9125 | hidnplayr | 881 | cmp al, '[' ; CSI - Control Sequence Introducer |
9105 | hidnplayr | 882 | je .esc_sqro |
9125 | hidnplayr | 883 | cmp al, ']' ; OSC - Operating System Command |
9105 | hidnplayr | 884 | je .esc_sqrc |
9125 | hidnplayr | 885 | cmp al, '(' ; Designate G0 Character Set, VT100, ISO 2022. |
9105 | hidnplayr | 886 | je .esc_rndo |
9125 | hidnplayr | 887 | cmp al, '>' ; Normal Keypad (DECKPNM), VT100. |
9105 | hidnplayr | 888 | je .keypm_norm |
9125 | hidnplayr | 889 | cmp al, '=' ; Application Keypad (DECKPAM). |
9105 | hidnplayr | 890 | je .keypm_alt |
9125 | hidnplayr | 891 | ; Control characters |
892 | cmp al, 'G' |
||
893 | je .bell |
||
894 | cmp al, 'H' |
||
895 | je .write_bs |
||
896 | cmp al, 'I' |
||
897 | je .write_tab |
||
898 | cmp al, 'J' |
||
899 | je .write_lf |
||
900 | cmp al, 'M' |
||
901 | je .write_cr |
||
9105 | hidnplayr | 902 | ; Unrecognized escape sequence, print it to screen |
836 | diamond | 903 | push eax |
904 | mov al, 27 |
||
905 | call con.write_char |
||
906 | pop eax |
||
907 | jmp con.write_char |
||
9105 | hidnplayr | 908 | |
909 | .esc_sqro: |
||
910 | mov [con_sci], 1 |
||
911 | ret |
||
912 | .esc_sqrc: |
||
913 | mov [con_sci], 2 |
||
914 | ret |
||
915 | .esc_rndo: |
||
916 | mov [con_sci], 4 |
||
917 | ret |
||
918 | |||
919 | .keypm_norm: |
||
920 | ; TODO: turn numlock on |
||
921 | mov [con_esc], 0 |
||
922 | ret |
||
923 | |||
924 | .keypm_alt: |
||
925 | ; TODO: turn numlock off |
||
926 | mov [con_esc], 0 |
||
927 | ret |
||
928 | |||
836 | diamond | 929 | .esc_sci: |
9105 | hidnplayr | 930 | cmp [con_sci], 3 |
931 | je .string |
||
932 | cmp [con_sci], 4 |
||
933 | je .g0charset |
||
836 | diamond | 934 | ; this is real Esc sequence |
3886 | hidnplayr | 935 | cmp al, '?' ; DEC private mode (DECSET/DECRST sequences) |
936 | je .questionmark |
||
836 | diamond | 937 | cmp al, ';' |
938 | jz .next_arg |
||
939 | cmp al, '0' |
||
940 | jb .not_digit |
||
941 | cmp al, '9' |
||
942 | ja .not_digit |
||
943 | push eax ecx edx |
||
944 | sub al, '0' |
||
945 | movzx eax, al |
||
946 | mov ecx, [con_esc_attr_n] |
||
947 | mov edx, [con_esc_attrs+(ecx-1)*4] |
||
948 | lea edx, [edx*5] |
||
949 | lea edx, [edx*2+eax] |
||
950 | mov [con_esc_attrs+(ecx-1)*4], edx |
||
951 | pop edx ecx eax |
||
952 | ret |
||
9105 | hidnplayr | 953 | .g0charset: |
954 | ; Designate G0 Character Set |
||
955 | ; Unimplemented: read and ignore. |
||
956 | mov [con_sci], 0 |
||
957 | mov [con_esc], 0 |
||
958 | ret |
||
959 | .string: |
||
960 | cmp al, 0x07 ; bell |
||
961 | je .string_end |
||
962 | cmp al, 0x9C ; string terminator |
||
963 | je .string_end |
||
964 | push ecx |
||
965 | mov ecx, [con_osc_strlen] |
||
966 | cmp ecx, 255 |
||
967 | jae @f |
||
968 | mov [con_osc_str+ecx], al |
||
969 | inc [con_osc_strlen] |
||
970 | @@: |
||
971 | pop ecx |
||
972 | ret |
||
973 | .string_end: |
||
974 | mov [con_sci], 0 |
||
975 | mov [con_esc], 0 |
||
976 | pusha |
||
977 | mov ecx, [con_osc_strlen] |
||
978 | mov byte[con_osc_str+ecx], 0 |
||
979 | cmp [con_esc_attrs+0], 0 ; Set Icon and Window Title |
||
980 | je .set_title |
||
981 | cmp [con_esc_attrs+0], 2 ; Set Window Title |
||
982 | je .set_title |
||
983 | ret |
||
984 | .set_title: |
||
985 | push con_osc_str |
||
986 | call con_set_title |
||
987 | popa |
||
988 | ret |
||
3886 | hidnplayr | 989 | .questionmark: |
990 | push ecx |
||
991 | mov ecx, [con_esc_attr_n] |
||
992 | mov dword[con_esc_attrs+(ecx-1)*4], 0xffffffff |
||
993 | pop ecx |
||
836 | diamond | 994 | .next_arg: |
995 | push eax |
||
996 | mov eax, [con_esc_attr_n] |
||
997 | inc eax |
||
998 | cmp al, 4 |
||
999 | jbe @f |
||
1000 | dec eax |
||
1001 | @@: |
||
1002 | mov [con_esc_attr_n], eax |
||
1003 | and [con_esc_attrs+(eax-1)*4], 0 |
||
9105 | hidnplayr | 1004 | ; Check for operating system command |
1005 | cmp [con_sci], 2 |
||
1006 | jne @f |
||
1007 | cmp [con_esc_attr_n], 2 |
||
1008 | jne @f |
||
1009 | ; Next argument is string |
||
1010 | mov [con_sci], 3 |
||
1011 | mov [con_osc_strlen], 0 |
||
1012 | @@: |
||
836 | diamond | 1013 | pop eax |
1014 | ret |
||
1015 | .not_digit: |
||
1016 | mov [con_esc], 0 |
||
1017 | mov [con_sci], 0 ; in any case, leave Esc mode |
||
9105 | hidnplayr | 1018 | |
1019 | ; cmp al, '@' |
||
1020 | ; je .insert_chars |
||
853 | diamond | 1021 | cmp al, 'A' |
9105 | hidnplayr | 1022 | je .cursor_up |
853 | diamond | 1023 | cmp al, 'B' |
9105 | hidnplayr | 1024 | je .cursor_down |
853 | diamond | 1025 | cmp al, 'C' |
9105 | hidnplayr | 1026 | je .cursor_right |
853 | diamond | 1027 | cmp al, 'D' |
9105 | hidnplayr | 1028 | je .cursor_left |
1029 | ; cmp al, 'E' |
||
1030 | ; je .cursor_next_line |
||
1031 | ; cmp al, 'F' |
||
1032 | ; je .cursor_prev_line |
||
1033 | ; cmp al, 'G' |
||
1034 | ; je .cursor_next_line |
||
1035 | ; cmp al, 'S' |
||
1036 | ; je .scroll_page_up |
||
1037 | ; cmp al, 'T' |
||
1038 | ; je .scroll_page_down |
||
1039 | cmp al, 'H' |
||
1040 | je .cursor_position |
||
1041 | cmp al, 'J' |
||
1042 | je .erase_in_display |
||
9096 | hidnplayr | 1043 | cmp al, 'K' |
1044 | je .erase_in_line |
||
9105 | hidnplayr | 1045 | cmp al, 'L' |
1046 | je .insert_lines |
||
1047 | cmp al, 'M' |
||
1048 | je .delete_lines |
||
1049 | cmp al, 'P' |
||
1050 | je .delete_chars |
||
1051 | cmp al, 'X' |
||
1052 | je .erase_chars |
||
1053 | |||
1054 | cmp al, 'd' |
||
1055 | je .line_position_abs |
||
1056 | ; cmp al, 'e' |
||
1057 | ; je .line_position_rel |
||
1058 | cmp al, 'f' |
||
1059 | je .cursor_position |
||
1060 | cmp al, 'h' |
||
1061 | je .set_mode |
||
1062 | cmp al, 'l' |
||
1063 | je .reset_mode |
||
1064 | cmp al, 'm' |
||
1065 | je .set_attr |
||
1066 | cmp al, 'r' |
||
1067 | je .scroll_region |
||
1068 | ; cmp al, 's' |
||
1069 | ; je .save_cursor_pos |
||
1070 | ; cmp al, 't' |
||
1071 | ; je .window_manip |
||
1072 | ; cmp al, 'u' |
||
1073 | ; je .restore_cursor_pos |
||
1074 | |||
836 | diamond | 1075 | ret ; simply skip unknown sequences |
3886 | hidnplayr | 1076 | |
9105 | hidnplayr | 1077 | .insert_lines: |
1078 | |||
1079 | push eax ebx ecx esi |
||
1080 | mov eax, [con_esc_attrs+0] ; amount of lines to scroll down |
||
1081 | test eax, eax |
||
1082 | jnz @f ; default is 1 |
||
1083 | inc eax |
||
1084 | @@: |
||
1085 | ; Check that we are inside the scroll region |
||
1086 | mov ebx, [con.cur_y] |
||
1087 | cmp ebx, [con.scroll_top] |
||
1088 | jb .no_insert_lines |
||
1089 | add ebx, eax |
||
1090 | cmp ebx, [con.scroll_bot] |
||
1091 | ja .no_insert_lines |
||
1092 | ; Move cursor to the left |
||
1093 | mov [con.cur_x], 0 |
||
1094 | call con.get_data_ptr |
||
1095 | ; Calc amount of chars in requested numer of lines |
||
1096 | mov ebx, [con.scr_width] |
||
1097 | imul ebx, eax |
||
1098 | ; Move the lines down (in backwards order) |
||
1099 | push edi |
||
1100 | mov ecx, [con.scroll_bot] |
||
1101 | sub ecx, [con.cur_y] |
||
1102 | sub ecx, eax |
||
1103 | imul ecx, [con.scr_width] |
||
1104 | lea esi, [edi + 2*ecx - 2] |
||
1105 | lea edi, [esi + 2*ebx] |
||
1106 | std |
||
1107 | rep movsw |
||
1108 | cld |
||
1109 | pop edi |
||
1110 | ; Insert empty lines |
||
1111 | push edi |
||
1112 | mov ecx, ebx |
||
1113 | mov ah, byte[con_flags] |
||
1114 | mov al, ' ' |
||
1115 | rep stosw |
||
1116 | pop edi |
||
1117 | .no_insert_lines: |
||
1118 | pop esi ecx ebx eax |
||
1119 | ret |
||
1120 | |||
1121 | .delete_lines: |
||
1122 | |||
1123 | push eax ebx ecx esi |
||
1124 | mov eax, [con_esc_attrs+0] ; amount of lines to scroll up |
||
1125 | test eax, eax |
||
1126 | jnz @f ; default is 1 |
||
1127 | inc eax |
||
1128 | @@: |
||
1129 | ; Check that we are inside the scroll region |
||
1130 | mov ebx, [con.cur_y] |
||
1131 | cmp ebx, [con.scroll_top] |
||
1132 | jb .no_delete_lines |
||
1133 | add ebx, eax |
||
1134 | cmp ebx, [con.scroll_bot] |
||
1135 | ja .no_delete_lines |
||
1136 | ; Move cursor to the left |
||
1137 | mov [con.cur_x], 0 |
||
1138 | call con.get_data_ptr |
||
1139 | ; Calc amount of chars in requested numer of lines |
||
1140 | mov ebx, [con.scr_width] |
||
1141 | imul ebx, eax |
||
1142 | ; Move the lines up |
||
1143 | mov ecx, [con.scroll_bot] |
||
1144 | sub ecx, [con.cur_y] |
||
1145 | imul ecx, [con.scr_width] |
||
1146 | lea esi, [edi + 2*ebx] |
||
1147 | rep movsw |
||
1148 | ; Set new cursor row position |
||
1149 | add [con.cur_y], eax |
||
1150 | ; Add empty lines till end of scroll region |
||
1151 | push edi |
||
1152 | mov ecx, ebx |
||
1153 | mov ah, byte[con_flags] |
||
1154 | mov al, ' ' |
||
1155 | rep stosw |
||
1156 | pop edi |
||
1157 | .no_delete_lines: |
||
1158 | pop esi ecx ebx eax |
||
1159 | ret |
||
1160 | |||
1161 | .scroll_region: |
||
1162 | push eax ebx |
||
1163 | cmp [con_esc_attr_n], 2 |
||
1164 | jb .no_scroll_region |
||
1165 | mov eax, [con_esc_attrs+0] ; top |
||
1166 | dec eax |
||
1167 | js .no_scroll_region |
||
1168 | cmp eax, [con.wnd_height] |
||
1169 | ja .no_scroll_region |
||
1170 | |||
1171 | mov ebx, [con_esc_attrs+4] ; bottom |
||
1172 | dec ebx |
||
1173 | js .no_scroll_region |
||
1174 | cmp ebx, [con.wnd_height] |
||
1175 | ja .no_scroll_region |
||
1176 | |||
1177 | cmp eax, ebx |
||
1178 | ja .no_scroll_region |
||
1179 | |||
1180 | mov [con.scroll_top], eax |
||
1181 | mov [con.scroll_bot], ebx |
||
1182 | |||
1183 | .no_scroll_region: |
||
1184 | pop ebx eax |
||
1185 | ret |
||
1186 | |||
1187 | .reset_mode: |
||
3886 | hidnplayr | 1188 | mov eax, [con_esc_attrs] |
1189 | cmp eax, 0xffffffff |
||
1190 | jne .no_dec_rst |
||
1191 | mov eax, [con_esc_attrs+4] |
||
9105 | hidnplayr | 1192 | cmp eax, 1 |
1193 | je .dec_rst_app_cursor_keys |
||
1194 | ; cmp eax, 7 |
||
1195 | ; je .dec_rst_wraparound |
||
1196 | ; cmp eax, 12 |
||
1197 | ; je .dec_rst_cursor_blink |
||
3886 | hidnplayr | 1198 | cmp eax, 25 |
9105 | hidnplayr | 1199 | je .dec_rst_cursor |
1200 | ; cmp eax, 1000 |
||
1201 | ; je .dec_rst_mouse |
||
1202 | ; cmp eax, 1002 |
||
1203 | ; je .dec_rst_buttons |
||
1204 | ; cmp eax, 1006 |
||
1205 | ; je .dec_rst_mouse_sgr |
||
1206 | cmp eax, 1049 |
||
1207 | je .dec_rst_altbuff |
||
1208 | ; cmp eax, 2004 |
||
1209 | ; je .dec_rst_brck_paste |
||
3886 | hidnplayr | 1210 | .no_dec_rst: |
9105 | hidnplayr | 1211 | ; cmp eax, 2 |
1212 | ; je .rst_keyb_action_mode |
||
1213 | ; cmp eax, 4 |
||
1214 | ; je .set_replace_mode |
||
3886 | hidnplayr | 1215 | ret |
1216 | |||
9105 | hidnplayr | 1217 | .set_mode: |
3886 | hidnplayr | 1218 | mov eax, [con_esc_attrs] |
1219 | cmp eax, 0xffffffff |
||
1220 | jne .no_dec_set |
||
1221 | mov eax, [con_esc_attrs+4] |
||
9105 | hidnplayr | 1222 | cmp eax, 1 |
1223 | je .dec_set_app_cursor_keys |
||
1224 | ; cmp eax, 7 |
||
1225 | ; je .dec_set_wraparound |
||
1226 | ; cmp eax, 12 |
||
1227 | ; je .dec_set_cursor_blink |
||
3886 | hidnplayr | 1228 | cmp eax, 25 |
9105 | hidnplayr | 1229 | je .dec_set_cursor |
1230 | ; cmp eax, 1000 |
||
1231 | ; je .dec_set_mouse |
||
1232 | ; cmp eax, 1002 |
||
1233 | ; je .set_buttons |
||
1234 | ; cmp eax, 1006 |
||
1235 | ; je .dec_rst_mouse_sgr |
||
1236 | cmp eax, 1049 |
||
1237 | je .dec_set_altbuff |
||
1238 | ; cmp eax, 2004 |
||
1239 | ; je .dec_set_brck_paste |
||
3886 | hidnplayr | 1240 | .no_dec_set: |
9105 | hidnplayr | 1241 | ; cmp eax, 2 |
1242 | ; je .set_keyb_action_mode |
||
1243 | ; cmp eax, 4 |
||
1244 | ; je .set_insert_mode |
||
3886 | hidnplayr | 1245 | ret |
1246 | |||
9105 | hidnplayr | 1247 | .dec_set_app_cursor_keys: |
1248 | mov [cursor_esc], 27 + ('O' shl 8) |
||
1249 | ret |
||
1250 | |||
1251 | .dec_rst_app_cursor_keys: |
||
1252 | mov [cursor_esc], 27 + ('[' shl 8) |
||
1253 | ret |
||
1254 | |||
1255 | .dec_set_cursor: |
||
3886 | hidnplayr | 1256 | mov [con.cursor_height], (15*font_height+50)/100 ; default height |
1257 | ret |
||
9096 | hidnplayr | 1258 | |
9105 | hidnplayr | 1259 | .dec_rst_cursor: |
1260 | mov [con.cursor_height], 0 |
||
1261 | ret |
||
1262 | |||
1263 | .dec_set_altbuff: |
||
1264 | ; Switch buffer |
||
1265 | push [con.altbuffer] |
||
1266 | pop [con.data] |
||
1267 | ; Set new buffer size |
||
1268 | push [con.wnd_width] |
||
1269 | pop [con.scr_width] |
||
1270 | push [con.wnd_height] |
||
1271 | pop [con.scr_height] |
||
1272 | ; Save cursor |
||
1273 | push [con.cur_x] |
||
1274 | pop [con.main_cur_x] |
||
1275 | push [con.cur_y] |
||
1276 | pop [con.main_cur_y] |
||
1277 | ; Save window position |
||
1278 | push [con.wnd_xpos] |
||
1279 | pop [con.main_wnd_xpos] |
||
1280 | push [con.wnd_ypos] |
||
1281 | pop [con.main_wnd_ypos] |
||
1282 | ; Clear screen |
||
1283 | mov edi, [con.altbuffer] |
||
1284 | mov eax, [con.wnd_width] |
||
1285 | mul [con.wnd_height] |
||
1286 | mov ecx, eax |
||
1287 | mov ah, byte[con_flags] |
||
1288 | mov al, ' ' |
||
1289 | rep stosw |
||
1290 | ; Reset cursor position |
||
1291 | mov [con.cur_x], 0 |
||
1292 | mov [con.cur_y], 0 |
||
1293 | ; Reset window position |
||
1294 | mov [con.wnd_xpos], 0 |
||
1295 | mov [con.wnd_ypos], 0 |
||
1296 | ; Get new data ptr so we can sart writing to new buffer |
||
1297 | call con.get_data_ptr |
||
1298 | ; Finally, tell the GUI the window has been resized |
||
1299 | ; (Redraw scrollbar and image) |
||
1300 | mov [con.thread_op], OP_RESIZE |
||
1301 | jmp con.wake |
||
1302 | |||
1303 | .dec_rst_altbuff: |
||
1304 | ; Switch buffer |
||
1305 | push [con.mainbuffer] |
||
1306 | pop [con.data] |
||
1307 | ; Set new buffer size |
||
1308 | push [con.main_scr_width] |
||
1309 | pop [con.scr_width] |
||
1310 | push [con.main_scr_height] |
||
1311 | pop [con.scr_height] |
||
1312 | ; Restore cursor |
||
1313 | push [con.main_cur_x] |
||
1314 | pop [con.cur_x] |
||
1315 | push [con.main_cur_y] |
||
1316 | pop [con.cur_y] |
||
1317 | ; Restore window position |
||
1318 | push [con.main_wnd_xpos] |
||
1319 | pop [con.wnd_xpos] |
||
1320 | push [con.main_wnd_ypos] |
||
1321 | pop [con.wnd_ypos] |
||
1322 | ; Get new data ptr so we can sart writing to new buffer |
||
1323 | call con.get_data_ptr |
||
1324 | ; Finally, tell the GUI the window has been resized |
||
1325 | ; (Redraw scrollbar and image) |
||
1326 | mov [con.thread_op], OP_RESIZE |
||
1327 | jmp con.wake |
||
1328 | |||
1329 | .erase_chars: |
||
1330 | push edi ecx |
||
1331 | mov ecx, [con_esc_attrs] |
||
1332 | test ecx, ecx |
||
1333 | jnz @f |
||
1334 | inc ecx |
||
1335 | @@: |
||
1336 | mov ah, byte[con_flags] |
||
1337 | mov al, ' ' |
||
1338 | rep stosw |
||
1339 | pop ecx edi |
||
1340 | ; Unclear where cursor should point to now.. |
||
1341 | ret |
||
1342 | |||
1343 | .delete_chars: |
||
1344 | push edi ecx |
||
1345 | mov ecx, [con_esc_attrs] |
||
1346 | test ecx, ecx |
||
1347 | jnz @f |
||
1348 | inc ecx |
||
1349 | @@: |
||
1350 | sub edi, 2 |
||
1351 | mov ah, byte[con_flags] |
||
1352 | mov al, ' ' |
||
1353 | std |
||
1354 | rep stosw |
||
1355 | cld |
||
1356 | pop ecx edi |
||
1357 | ret |
||
1358 | |||
9096 | hidnplayr | 1359 | .erase_in_line: |
1360 | mov eax, [con_esc_attrs] |
||
1361 | test eax, eax |
||
9105 | hidnplayr | 1362 | jz .erase_after ; |
9096 | hidnplayr | 1363 | dec eax |
9105 | hidnplayr | 1364 | jz .erase_before ; |
9096 | hidnplayr | 1365 | dec eax |
1366 | je .erase_current_line ; |
||
1367 | ret ; unknown sequence |
||
1368 | |||
9105 | hidnplayr | 1369 | .erase_after: |
9096 | hidnplayr | 1370 | push edi ecx |
1371 | mov ecx, [con.scr_width] |
||
1372 | sub ecx, [con.cur_x] |
||
1373 | mov ah, byte[con_flags] |
||
1374 | mov al, ' ' |
||
1375 | rep stosw |
||
1376 | pop ecx edi |
||
1377 | ret |
||
1378 | |||
9105 | hidnplayr | 1379 | .erase_before: |
9096 | hidnplayr | 1380 | push edi ecx |
1381 | mov edi, [con.cur_y] |
||
1382 | imul edi, [con.scr_width] |
||
1383 | shl edi, 1 |
||
1384 | add edi, [con.data] |
||
1385 | mov ecx, [con.cur_y] |
||
1386 | mov ah, byte[con_flags] |
||
1387 | mov al, ' ' |
||
1388 | rep stosw |
||
1389 | pop ecx edi |
||
1390 | ret |
||
1391 | |||
1392 | .erase_current_line: |
||
1393 | push edi ecx |
||
1394 | mov edi, [con.cur_y] |
||
1395 | imul edi, [con.scr_width] |
||
1396 | shl edi, 1 |
||
1397 | add edi, [con.data] |
||
1398 | mov ecx, [con.scr_width] |
||
1399 | mov ah, byte[con_flags] |
||
1400 | mov al, ' ' |
||
1401 | rep stosw |
||
1402 | pop ecx edi |
||
1403 | ret |
||
1404 | |||
9105 | hidnplayr | 1405 | .erase_in_display: |
3885 | hidnplayr | 1406 | mov eax, [con_esc_attrs] |
1407 | test eax, eax |
||
9105 | hidnplayr | 1408 | jz .erase_below ; |
3885 | hidnplayr | 1409 | dec eax |
9105 | hidnplayr | 1410 | jz .erase_above ; |
3885 | hidnplayr | 1411 | dec eax |
9105 | hidnplayr | 1412 | je .erase_all ; |
3885 | hidnplayr | 1413 | ret ; unknown sequence |
1414 | |||
9105 | hidnplayr | 1415 | .erase_below: |
3885 | hidnplayr | 1416 | push edi ecx |
1417 | mov ecx, [con.scr_width] |
||
1418 | imul ecx, [con.scr_height] |
||
1419 | |||
1420 | mov edi, [con.cur_y] |
||
1421 | imul edi, [con.scr_width] |
||
1422 | add edi, [con.cur_x] |
||
1423 | |||
1424 | sub ecx, edi |
||
1425 | shl edi, 1 |
||
1426 | add edi, [con.data] |
||
1427 | mov ah, byte[con_flags] |
||
1428 | mov al, ' ' |
||
1429 | rep stosw |
||
1430 | |||
1431 | and [con.cur_x], 0 |
||
1432 | and [con.cur_y], 0 |
||
1433 | pop ecx edi |
||
1434 | ret |
||
1435 | |||
9105 | hidnplayr | 1436 | .erase_above: |
3885 | hidnplayr | 1437 | push edi ecx |
1438 | mov ecx, [con.cur_y] |
||
1439 | imul ecx, [con.scr_width] |
||
1440 | add ecx, [con.cur_x] |
||
1441 | mov edi, [con.data] |
||
1442 | mov ah, byte[con_flags] |
||
1443 | mov al, ' ' |
||
1444 | rep stosw |
||
1445 | pop ecx edi |
||
1446 | ret |
||
1447 | |||
9105 | hidnplayr | 1448 | .erase_all: ; clear screen completely |
853 | diamond | 1449 | push ecx |
1450 | and [con.cur_x], 0 |
||
1451 | and [con.cur_y], 0 |
||
1452 | mov edi, [con.data] |
||
1453 | push edi |
||
1454 | mov ecx, [con.scr_width] |
||
1455 | imul ecx, [con.scr_height] |
||
1456 | mov ax, 0720h |
||
1457 | rep stosw |
||
1458 | pop edi ecx |
||
1459 | .nosetcursor: |
||
1460 | ret |
||
9105 | hidnplayr | 1461 | .line_position_abs: |
1462 | mov eax, [con_esc_attrs] |
||
1463 | dec eax |
||
1464 | jns @f |
||
1465 | inc eax |
||
1466 | @@: |
||
1467 | cmp eax, [con.scr_height] |
||
1468 | jae .nolinepos |
||
3688 | hidnplayr | 1469 | mov [con.cur_y], eax |
9105 | hidnplayr | 1470 | jmp con.get_data_ptr |
1471 | .nolinepos: |
||
1472 | ret |
||
1473 | .cursor_position: |
||
1474 | ; We always have at least one con_esc_attr, defaulting to 0 |
||
1475 | ; Coordinates however are 1-based |
||
1476 | ; First comes Y (row) and then X (column) |
||
1477 | mov eax, [con_esc_attrs] |
||
1478 | dec eax |
||
1479 | jns @f |
||
1480 | inc eax |
||
3686 | hidnplayr | 1481 | @@: |
9105 | hidnplayr | 1482 | cmp eax, [con.scr_height] |
1483 | jae .no_y |
||
1484 | mov [con.cur_y], eax |
||
1485 | .no_y: |
||
1486 | cmp [con_esc_attr_n], 2 |
||
1487 | jb .no_x |
||
1488 | mov eax, [con_esc_attrs+4] |
||
1489 | dec eax |
||
1490 | jns @f |
||
1491 | inc eax |
||
1492 | @@: |
||
853 | diamond | 1493 | cmp eax, [con.scr_width] |
9105 | hidnplayr | 1494 | jae .no_x |
853 | diamond | 1495 | mov [con.cur_x], eax |
9105 | hidnplayr | 1496 | .no_x: |
853 | diamond | 1497 | .j_get_data: |
1498 | jmp con.get_data_ptr |
||
1499 | .cursor_up: |
||
9105 | hidnplayr | 1500 | mov eax, [con_esc_attrs] |
1501 | test eax, eax |
||
1502 | jnz @f |
||
1503 | inc eax ; default = 1 |
||
853 | diamond | 1504 | @@: |
9105 | hidnplayr | 1505 | sub [con.cur_y], eax |
1506 | jns .j_get_data |
||
1507 | mov [con.cur_y], 0 |
||
853 | diamond | 1508 | jmp .j_get_data |
1509 | .cursor_down: |
||
9105 | hidnplayr | 1510 | mov eax, [con_esc_attrs] |
1511 | test eax, eax |
||
1512 | jnz @f |
||
1513 | inc eax ; default = 1 |
||
1514 | @@: |
||
1515 | add eax, [con.cur_y] |
||
853 | diamond | 1516 | cmp eax, [con.scr_height] |
9105 | hidnplayr | 1517 | ja @f |
1518 | mov [con.cur_y], eax |
||
1519 | jmp .j_get_data |
||
1520 | @@: |
||
853 | diamond | 1521 | mov eax, [con.scr_height] |
1522 | mov [con.cur_y], eax |
||
1523 | jmp .j_get_data |
||
1524 | .cursor_right: |
||
9105 | hidnplayr | 1525 | mov eax, [con_esc_attrs] |
1526 | test eax, eax |
||
1527 | jnz @f |
||
1528 | inc eax ; default = 1 |
||
1529 | @@: |
||
1530 | add eax, [con.cur_x] |
||
853 | diamond | 1531 | cmp eax, [con.scr_width] |
9105 | hidnplayr | 1532 | ja @f |
1533 | mov [con.cur_x], eax |
||
1534 | jmp .j_get_data |
||
1535 | @@: |
||
853 | diamond | 1536 | mov eax, [con.scr_width] |
1537 | mov [con.cur_x], eax |
||
1538 | jmp .j_get_data |
||
1539 | .cursor_left: |
||
9105 | hidnplayr | 1540 | test eax, eax |
1541 | jnz @f |
||
1542 | inc eax ; default = 1 |
||
853 | diamond | 1543 | @@: |
9105 | hidnplayr | 1544 | sub [con.cur_x], eax |
1545 | jns .j_get_data |
||
1546 | mov [con.cur_x], 0 |
||
853 | diamond | 1547 | jmp .j_get_data |
836 | diamond | 1548 | .set_attr: |
1549 | push eax ecx edx |
||
1550 | xor ecx, ecx |
||
1551 | .set_one_attr: |
||
1552 | mov eax, [con_esc_attrs+ecx*4] |
||
1553 | cmp al, 0 |
||
1554 | jz .attr_normal |
||
1555 | cmp al, 1 |
||
1556 | jz .attr_bold |
||
1557 | cmp al, 5 |
||
1558 | jz .attr_bgr_bold |
||
1559 | cmp al, 7 |
||
1560 | jz .attr_reversed |
||
9105 | hidnplayr | 1561 | ; cmp al, 8 |
1562 | ; jz .attr_invisible |
||
1563 | cmp al, 27 |
||
1564 | jz .attr_normal ; FIXME: not inverse |
||
1565 | ; cmp al, 28 |
||
1566 | ; jz .attr_visible |
||
3690 | hidnplayr | 1567 | |
9105 | hidnplayr | 1568 | ; Forground colors |
836 | diamond | 1569 | xor edx, edx |
9105 | hidnplayr | 1570 | cmp al, 30 ; Black |
836 | diamond | 1571 | jz .attr_color |
1572 | mov dl, 4 |
||
9105 | hidnplayr | 1573 | cmp al, 31 ; Red |
836 | diamond | 1574 | jz .attr_color |
1575 | mov dl, 2 |
||
9105 | hidnplayr | 1576 | cmp al, 32 ; Green |
836 | diamond | 1577 | jz .attr_color |
1578 | mov dl, 6 |
||
9105 | hidnplayr | 1579 | cmp al, 33 ; Yellow |
836 | diamond | 1580 | jz .attr_color |
1581 | mov dl, 1 |
||
9105 | hidnplayr | 1582 | cmp al, 34 ; Blue |
836 | diamond | 1583 | jz .attr_color |
1584 | mov dl, 5 |
||
9105 | hidnplayr | 1585 | cmp al, 35 ; Purple |
836 | diamond | 1586 | jz .attr_color |
1587 | mov dl, 3 |
||
9105 | hidnplayr | 1588 | cmp al, 36 ; Cyan |
836 | diamond | 1589 | jz .attr_color |
1590 | mov dl, 7 |
||
9105 | hidnplayr | 1591 | cmp al, 37 ; White |
836 | diamond | 1592 | jz .attr_color |
9105 | hidnplayr | 1593 | mov dl, 7 |
1594 | cmp al, 39 ; Default - White |
||
1595 | jz .attr_color |
||
3690 | hidnplayr | 1596 | |
9105 | hidnplayr | 1597 | ; Background colors |
836 | diamond | 1598 | xor edx, edx |
9105 | hidnplayr | 1599 | cmp al, 40 ; Black |
836 | diamond | 1600 | jz .attr_bgr_color |
1601 | mov dl, 0x40 |
||
9105 | hidnplayr | 1602 | cmp al, 41 ; Red |
836 | diamond | 1603 | jz .attr_bgr_color |
1604 | mov dl, 0x20 |
||
9105 | hidnplayr | 1605 | cmp al, 42 ; Green |
836 | diamond | 1606 | jz .attr_bgr_color |
1607 | mov dl, 0x60 |
||
9105 | hidnplayr | 1608 | cmp al, 43 ; Yellow |
836 | diamond | 1609 | jz .attr_bgr_color |
1610 | mov dl, 0x10 |
||
9105 | hidnplayr | 1611 | cmp al, 44 ; Blue |
836 | diamond | 1612 | jz .attr_bgr_color |
1613 | mov dl, 0x50 |
||
9105 | hidnplayr | 1614 | cmp al, 45 ; Magenta |
836 | diamond | 1615 | jz .attr_bgr_color |
1616 | mov dl, 0x30 |
||
9105 | hidnplayr | 1617 | cmp al, 46 ; Cyan |
836 | diamond | 1618 | jz .attr_bgr_color |
1619 | mov dl, 0x70 |
||
9105 | hidnplayr | 1620 | cmp al, 47 ; White |
3690 | hidnplayr | 1621 | jz .attr_bgr_color |
9105 | hidnplayr | 1622 | mov dl, 0 |
1623 | cmp al, 49 ; Default - Black |
||
1624 | jz .attr_bgr_color |
||
3690 | hidnplayr | 1625 | |
9105 | hidnplayr | 1626 | ; 16-color support, bright colors follow |
1627 | ; Foreground colors |
||
3690 | hidnplayr | 1628 | mov dl, 0x08 |
9105 | hidnplayr | 1629 | cmp al, 90 ; Black |
3690 | hidnplayr | 1630 | jz .attr_color |
1631 | mov dl, 4 + 8 |
||
9105 | hidnplayr | 1632 | cmp al, 91 ; Red |
3690 | hidnplayr | 1633 | jz .attr_color |
1634 | mov dl, 2 + 8 |
||
9105 | hidnplayr | 1635 | cmp al, 92 ; Green |
3690 | hidnplayr | 1636 | jz .attr_color |
1637 | mov dl, 6 + 8 |
||
9105 | hidnplayr | 1638 | cmp al, 93 ; Yellow |
3690 | hidnplayr | 1639 | jz .attr_color |
1640 | mov dl, 1 + 8 |
||
9105 | hidnplayr | 1641 | cmp al, 94 ; Blue |
3690 | hidnplayr | 1642 | jz .attr_color |
1643 | mov dl, 5 + 8 |
||
9105 | hidnplayr | 1644 | cmp al, 95 ; Magenta |
3690 | hidnplayr | 1645 | jz .attr_color |
1646 | mov dl, 3 + 8 |
||
9105 | hidnplayr | 1647 | cmp al, 96 ; Cyan |
3690 | hidnplayr | 1648 | jz .attr_color |
1649 | mov dl, 7 + 8 |
||
9105 | hidnplayr | 1650 | cmp al, 97 ; White |
3690 | hidnplayr | 1651 | jz .attr_color |
1652 | |||
9105 | hidnplayr | 1653 | ; Background colors |
3690 | hidnplayr | 1654 | mov dl, 0x80 |
9105 | hidnplayr | 1655 | cmp al, 100 ; Black |
3690 | hidnplayr | 1656 | jz .attr_bgr_color |
1657 | mov dl, 0x80 + 0x40 |
||
9105 | hidnplayr | 1658 | cmp al, 101 ; Red |
3690 | hidnplayr | 1659 | jz .attr_bgr_color |
1660 | mov dl, 0x80 + 0x20 |
||
9105 | hidnplayr | 1661 | cmp al, 102 ; Green |
3690 | hidnplayr | 1662 | jz .attr_bgr_color |
1663 | mov dl, 0x80 + 0x60 |
||
9105 | hidnplayr | 1664 | cmp al, 103 ; Yellow |
3690 | hidnplayr | 1665 | jz .attr_bgr_color |
1666 | mov dl, 0x80 + 0x10 |
||
9105 | hidnplayr | 1667 | cmp al, 104 ; Blue |
3690 | hidnplayr | 1668 | jz .attr_bgr_color |
1669 | mov dl, 0x80 + 0x50 |
||
9105 | hidnplayr | 1670 | cmp al, 105 ; Magenta |
3690 | hidnplayr | 1671 | jz .attr_bgr_color |
1672 | mov dl, 0x80 + 0x30 |
||
9105 | hidnplayr | 1673 | cmp al, 106 ; Cyan |
3690 | hidnplayr | 1674 | jz .attr_bgr_color |
1675 | mov dl, 0x80 + 0x70 |
||
9105 | hidnplayr | 1676 | cmp al, 107 ; White |
836 | diamond | 1677 | jnz .attr_continue |
3690 | hidnplayr | 1678 | |
836 | diamond | 1679 | .attr_bgr_color: |
1680 | mov eax, [con_flags] |
||
3690 | hidnplayr | 1681 | and al, 0x0F |
9105 | hidnplayr | 1682 | or al, byte [con_flags_attr] |
836 | diamond | 1683 | or al, dl |
1684 | mov [con_flags], eax |
||
1685 | jmp .attr_continue |
||
1686 | .attr_color: |
||
1687 | mov eax, [con_flags] |
||
3690 | hidnplayr | 1688 | and al, 0xF0 |
9105 | hidnplayr | 1689 | or al, byte [con_flags_attr] |
836 | diamond | 1690 | or al, dl |
1691 | mov [con_flags], eax |
||
1692 | jmp .attr_continue |
||
1693 | .attr_normal: |
||
9105 | hidnplayr | 1694 | mov byte [con_flags_attr], 0 |
1695 | mov byte [con_flags], 0x07 |
||
836 | diamond | 1696 | jmp .attr_continue |
1697 | .attr_reversed: |
||
1698 | mov byte [con_flags], 0x70 |
||
1699 | jmp .attr_continue |
||
1700 | .attr_bold: |
||
9105 | hidnplayr | 1701 | or byte [con_flags_attr], 0x08 |
836 | diamond | 1702 | jmp .attr_continue |
1703 | .attr_bgr_bold: |
||
9105 | hidnplayr | 1704 | or byte [con_flags_attr], 0x80 |
836 | diamond | 1705 | .attr_continue: |
1706 | inc ecx |
||
1707 | cmp ecx, [con_esc_attr_n] |
||
1708 | jb .set_one_attr |
||
1709 | pop edx ecx eax |
||
1710 | ret |
||
1711 | |||
1712 | con.newline: |
||
1713 | mov eax, [con.cur_y] |
||
1714 | inc eax |
||
1715 | mov [con.cur_y], eax |
||
1716 | cmp eax, [con.scr_height] |
||
1717 | jb @f |
||
1718 | call con.scr_scroll_up |
||
1719 | @@: |
||
1720 | call con.get_data_ptr |
||
1721 | ret |
||
1722 | |||
1723 | con.scr_scroll_up: |
||
1724 | pushad |
||
1725 | mov edi, [con.data] |
||
1726 | mov esi, edi |
||
1727 | add esi, [con.scr_width] |
||
1728 | add esi, [con.scr_width] |
||
1729 | dec [con.cur_y] |
||
1730 | mov ecx, [con.scr_height] |
||
1731 | dec ecx |
||
1732 | imul ecx, [con.scr_width] |
||
1733 | shr ecx, 1 |
||
1734 | rep movsd |
||
1735 | adc ecx, ecx |
||
1736 | rep movsw |
||
1737 | mov ax, 0x0720 |
||
1738 | mov ecx, [con.scr_width] |
||
1739 | rep stosw |
||
1740 | popad |
||
1741 | ret |
||
1742 | |||
1743 | con.data2image: |
||
1744 | pushad |
||
1745 | mov edi, [con.image] |
||
1746 | mov esi, [con.data] |
||
1747 | mov eax, [con.wnd_ypos] |
||
1748 | mul [con.scr_width] |
||
1749 | add eax, [con.wnd_xpos] |
||
1750 | lea esi, [esi+eax*2] |
||
1751 | mov ecx, [con.wnd_height] |
||
1752 | .lh: |
||
1753 | push ecx |
||
1754 | mov ecx, [con.wnd_width] |
||
1755 | .lw: |
||
1756 | push ecx edi |
||
1757 | xor eax, eax |
||
1758 | mov al, [esi+1] |
||
1759 | push eax |
||
1760 | and al, 0xF |
||
1761 | mov ebx, eax ; цвет текста |
||
1762 | pop eax |
||
1763 | shr al, 4 |
||
1764 | mov ebp, eax ; цвет фона |
||
1765 | sub ebx, ebp |
||
1766 | lodsb |
||
1767 | inc esi |
||
1768 | if font_width > 8 |
||
1769 | lea edx, [eax+eax+font] |
||
1770 | else |
||
1771 | lea edx, [eax+font] |
||
1772 | end if |
||
1773 | .sh: |
||
1774 | mov ecx, [edx] |
||
1775 | repeat font_width |
||
1776 | shr ecx, 1 |
||
1777 | sbb eax, eax |
||
1778 | and eax, ebx |
||
1779 | add eax, ebp |
||
1780 | mov [edi+%-1], al |
||
1781 | end repeat |
||
1782 | mov eax, [con.wnd_width] |
||
1783 | ; imul eax, font_width |
||
1784 | ; add edi, eax |
||
1785 | if font_width = 6 |
||
1786 | lea eax, [eax*2+eax] |
||
1787 | lea edi, [edi+eax*2] |
||
1788 | else if font_width = 7 |
||
1789 | lea edi, [edi+eax*8] |
||
1790 | sub edi, eax |
||
1791 | else if font_width = 8 |
||
1792 | lea edi, [edi+eax*8] |
||
1793 | else if font_width = 9 |
||
1794 | lea edi, [edi+eax*8] |
||
1795 | add edi, eax |
||
1796 | else if font_width = 10 |
||
1797 | lea eax, [eax*4+eax] |
||
1798 | lea edi, [edi+eax*2] |
||
1799 | else |
||
1800 | Unknown font_width value! |
||
1801 | end if |
||
1802 | if font_width > 8 |
||
1803 | add edx, 256*2 |
||
1804 | cmp edx, font+256*2*font_height |
||
1805 | else |
||
1806 | add edx, 256 |
||
1807 | cmp edx, font+256*font_height |
||
1808 | end if |
||
1809 | jb .sh |
||
1810 | pop edi ecx |
||
1811 | add edi, font_width |
||
1812 | sub ecx, 1 |
||
1813 | jnz .lw |
||
1814 | mov eax, [con.wnd_width] |
||
1815 | imul eax, (font_height-1)*font_width |
||
1816 | add edi, eax |
||
1817 | pop ecx |
||
1818 | mov eax, [con.scr_width] |
||
1819 | sub eax, [con.wnd_width] |
||
1820 | lea esi, [esi+eax*2] |
||
1821 | dec ecx |
||
1822 | jnz .lh |
||
1823 | mov eax, [con.cur_y] |
||
1824 | sub eax, [con.wnd_ypos] |
||
1825 | jb .nocursor |
||
1826 | cmp eax, [con.wnd_height] |
||
1827 | jae .nocursor |
||
1828 | inc eax |
||
1829 | mul [con.wnd_width] |
||
1830 | imul eax, font_height*font_width |
||
1831 | mov edx, [con.cur_x] |
||
1832 | sub edx, [con.wnd_xpos] |
||
1833 | jb .nocursor |
||
1834 | cmp edx, [con.wnd_width] |
||
1835 | jae .nocursor |
||
1836 | inc edx |
||
1837 | imul edx, font_width |
||
1838 | add eax, edx |
||
1839 | add eax, [con.image] |
||
1840 | mov edx, [con.wnd_width] |
||
1841 | imul edx, font_width |
||
1842 | neg edx |
||
1843 | mov ecx, [con.cursor_height] |
||
1844 | jecxz .nocursor |
||
1845 | .cursor_loop: |
||
1846 | push ecx |
||
1847 | mov ecx, font_width |
||
1848 | add eax, edx |
||
1849 | push eax |
||
1850 | @@: |
||
1851 | xor byte [eax-1], 7 |
||
1852 | dec eax |
||
1853 | loop @b |
||
1854 | pop eax |
||
1855 | pop ecx |
||
1856 | loop .cursor_loop |
||
1857 | .nocursor: |
||
1858 | popad |
||
1859 | ret |
||
1860 | |||
1861 | con_exit: |
||
9096 | hidnplayr | 1862 | |
9105 | hidnplayr | 1863 | mov ah, [con.init_cmd] |
1864 | test ah, ah |
||
1865 | je .ret |
||
5835 | pavelyakov | 1866 | |
836 | diamond | 1867 | cmp byte [esp+4], 0 |
1868 | jz .noexit |
||
9105 | hidnplayr | 1869 | mov [con.thread_op], OP_EXIT |
836 | diamond | 1870 | call con.wake |
9096 | hidnplayr | 1871 | |
836 | diamond | 1872 | ret 4 |
1873 | .noexit: |
||
1874 | push esi |
||
1875 | mov esi, [con.title] |
||
1876 | mov edx, con.finished_title |
||
1877 | mov ecx, 255 |
||
1878 | call .strcpy |
||
1879 | mov esi, con.aFinished |
||
1880 | call .strcpy |
||
1881 | mov byte [edx], 0 |
||
1882 | pop esi |
||
1883 | and [con.cursor_height], 0 |
||
1884 | push con.finished_title |
||
1885 | call con_set_title |
||
1886 | ret 4 |
||
1887 | .strcpy: |
||
1888 | jecxz .ret |
||
1889 | @@: |
||
1890 | lodsb |
||
1891 | test al, al |
||
1892 | jz .ret |
||
1893 | mov [edx], al |
||
1894 | inc edx |
||
1895 | loop @b |
||
1896 | .ret: |
||
1897 | ret |
||
1898 | |||
1899 | con_set_title: |
||
1900 | mov eax, [esp+4] |
||
1901 | mov [con.title], eax |
||
9105 | hidnplayr | 1902 | mov [con.thread_op], OP_SET_TITLE |
836 | diamond | 1903 | call con.wake |
1904 | ret 4 |
||
1905 | |||
1906 | ; int __stdcall con_kbhit(void); |
||
1907 | con_kbhit: |
||
1133 | diamond | 1908 | test byte [con_flags+1], 2 |
1909 | jnz @f |
||
836 | diamond | 1910 | mov eax, [con.input_start] |
1911 | cmp eax, [con.input_end] |
||
9127 | hidnplayr | 1912 | jnz @f |
1913 | cmp [con.entered_char], 0xffff |
||
1133 | diamond | 1914 | @@: |
836 | diamond | 1915 | setnz al |
1916 | movzx eax, al |
||
1917 | ret |
||
1918 | |||
1919 | con.force_entered_char: |
||
1920 | cmp [con.entered_char], -1 |
||
1921 | jnz .ret |
||
9105 | hidnplayr | 1922 | mov [con.thread_op], OP_GETCH |
836 | diamond | 1923 | call con.wake |
1133 | diamond | 1924 | test byte [con_flags+1], 2 |
1925 | jnz .ret |
||
836 | diamond | 1926 | ; wait for response |
1927 | push ebx |
||
1928 | push 5 |
||
1929 | pop eax |
||
1930 | push 2 |
||
1931 | pop ebx |
||
1932 | @@: |
||
1933 | int 0x40 |
||
1934 | cmp [con.entered_char], -1 |
||
1935 | jz @b |
||
1936 | pop ebx |
||
1937 | .ret: |
||
1938 | ret |
||
1939 | |||
1940 | ; int __stdcall con_getch(void); |
||
1941 | con_getch: |
||
9105 | hidnplayr | 1942 | call con_init_check |
836 | diamond | 1943 | call con.force_entered_char |
1133 | diamond | 1944 | test byte [con_flags+1], 2 |
1945 | jnz con_getch_closed |
||
836 | diamond | 1946 | movzx eax, byte [con.entered_char] |
1947 | sar [con.entered_char], 8 |
||
1948 | mov byte [con.entered_char+1], 0xFF |
||
1949 | test al, al |
||
1950 | jz @f |
||
1951 | mov byte [con.entered_char], 0xFF |
||
1952 | @@: |
||
1953 | ret |
||
1954 | |||
1133 | diamond | 1955 | con_getch_closed: |
1145 | diamond | 1956 | xor eax, eax |
1133 | diamond | 1957 | ret |
1958 | |||
836 | diamond | 1959 | ; int __stdcall con_getch2(void); |
1960 | con_getch2: |
||
9105 | hidnplayr | 1961 | call con_init_check |
836 | diamond | 1962 | call con.force_entered_char |
1133 | diamond | 1963 | test byte [con_flags+1], 2 |
1964 | jnz con_getch_closed |
||
836 | diamond | 1965 | mov eax, 0xFFFF |
1966 | xchg ax, [con.entered_char] |
||
1967 | ret |
||
1968 | |||
9105 | hidnplayr | 1969 | ; int __stdcall con_get_input(int *bufptr, int buflen); |
1970 | con_get_input: |
||
1971 | call con_init_check |
||
1972 | ; Wait for input available |
||
1973 | call con.force_entered_char |
||
1974 | test byte [con_flags+1], 2 |
||
1975 | jnz .none |
||
1976 | |||
1977 | push ebx |
||
9125 | hidnplayr | 1978 | mov ebx, [esp+8] |
9105 | hidnplayr | 1979 | .check_more: |
1980 | ; Avoid buffer overflow |
||
9125 | hidnplayr | 1981 | cmp dword[esp+12], 16 |
9105 | hidnplayr | 1982 | jl .no_more |
1983 | ; Check element available |
||
1984 | cmp [con.entered_char], 0xFFFF |
||
1985 | je .no_more |
||
1986 | ; Get an element from the input queue |
||
1987 | mov eax, 0xFFFF |
||
1988 | xchg ax, [con.entered_char] |
||
1989 | ; Function keys F1-F4 |
||
1990 | cmp ah, 0x3B |
||
1991 | jb @f |
||
1992 | cmp ah, 0x3E |
||
1993 | jbe .f1_4 |
||
1994 | @@: |
||
1995 | ; Function keys F5-F8 |
||
1996 | cmp ah, 0x3F |
||
1997 | jb @f |
||
1998 | je .f5 |
||
1999 | cmp ah, 0x42 |
||
2000 | jbe .f6_8 |
||
2001 | @@: |
||
2002 | ; Function keys F9-F12 |
||
2003 | cmp ah, 0x43 |
||
2004 | je .f9 |
||
2005 | cmp ah, 0x44 |
||
2006 | je .f10 |
||
2007 | cmp ah, 0x57 |
||
2008 | je .f11 |
||
2009 | cmp ah, 0x58 |
||
2010 | je .f12 |
||
2011 | ; Cursor keys |
||
2012 | cmp ah, 0x47 |
||
2013 | je .home |
||
2014 | cmp ah, 0x48 |
||
2015 | je .up |
||
2016 | cmp ah, 0x49 |
||
2017 | je .pgup |
||
2018 | ; cmp ah, 0x4a |
||
2019 | ; je .minus |
||
2020 | cmp ah, 0x4b |
||
2021 | je .left |
||
2022 | cmp ah, 0x4c |
||
2023 | je .begin |
||
2024 | cmp ah, 0x4d |
||
2025 | je .right |
||
2026 | ; cmp ah, 0x4e |
||
2027 | ; je .plus |
||
2028 | cmp ah, 0x4f |
||
2029 | je .end |
||
2030 | cmp ah, 0x50 |
||
2031 | je .down |
||
2032 | cmp ah, 0x51 |
||
2033 | je .pgdown |
||
2034 | cmp ah, 0x52 |
||
2035 | je .insert |
||
2036 | cmp ah, 0x53 |
||
2037 | je .delete |
||
2038 | ; regular ASCII |
||
2039 | mov byte[ebx], al |
||
2040 | mov eax, 1 |
||
2041 | .got_input: |
||
2042 | and eax, 0xff |
||
9125 | hidnplayr | 2043 | sub [esp+12], eax |
9105 | hidnplayr | 2044 | add ebx, eax |
2045 | jmp .check_more |
||
2046 | .no_more: |
||
2047 | mov eax, ebx |
||
9125 | hidnplayr | 2048 | sub eax, [esp+8] |
9105 | hidnplayr | 2049 | pop ebx |
2050 | ret 8 |
||
2051 | |||
2052 | .none: |
||
2053 | xor eax, eax |
||
2054 | ret 8 |
||
2055 | |||
2056 | .f1_4: |
||
2057 | ; F1 = SSR P, F2 = SS3 Q .. |
||
2058 | ; SS3 = 0x8f (8bit) or 0x1b + 'O' (7-bit) |
||
2059 | mov word[ebx], 27 + ('O' shl 8) |
||
2060 | add ah, 'P' - 59 |
||
2061 | mov byte[ebx+2], ah |
||
2062 | mov al, 3 |
||
2063 | jmp .got_input |
||
2064 | .f5: |
||
2065 | ; CSI = 0x9b (8bit) or 0x1b + '[' (7-bit) |
||
2066 | mov byte[ebx], 27 |
||
2067 | mov dword[ebx+1], '[15~' |
||
2068 | mov al, 5 |
||
2069 | jmp .got_input |
||
2070 | .f6_8: |
||
2071 | mov byte[ebx], 27 |
||
2072 | xor al, al |
||
2073 | shl eax, 8 |
||
2074 | add eax, '[17~' - (0x40 shl 16) |
||
2075 | mov dword[ebx+1], eax |
||
2076 | mov al, 5 |
||
2077 | jmp .got_input |
||
2078 | .f9: |
||
2079 | mov byte[ebx], 27 |
||
2080 | mov dword[ebx+1], '[20~' |
||
2081 | mov al, 5 |
||
2082 | jmp .got_input |
||
2083 | .f10: |
||
2084 | mov byte[ebx], 27 |
||
2085 | mov dword[ebx+1], '[21~' |
||
2086 | mov al, 5 |
||
2087 | jmp .got_input |
||
2088 | .f11: |
||
2089 | mov byte[ebx], 27 |
||
2090 | mov dword[ebx+1], '[23~' |
||
2091 | mov al, 5 |
||
2092 | jmp .got_input |
||
2093 | .f12: |
||
2094 | mov byte[ebx], 27 |
||
2095 | mov dword[ebx+1], '[24~' |
||
2096 | mov al, 5 |
||
2097 | jmp .got_input |
||
2098 | .up: |
||
2099 | mov eax, 'A' shl 16 |
||
2100 | add eax, [cursor_esc] |
||
2101 | mov dword[ebx], eax |
||
2102 | mov al, 3 |
||
2103 | jmp .got_input |
||
2104 | .down: |
||
2105 | mov eax, 'B' shl 16 |
||
2106 | add eax, [cursor_esc] |
||
2107 | mov dword[ebx], eax |
||
2108 | mov al, 3 |
||
2109 | jmp .got_input |
||
2110 | .right: |
||
2111 | mov eax, 'C' shl 16 |
||
2112 | add eax, [cursor_esc] |
||
2113 | mov dword[ebx], eax |
||
2114 | mov al, 3 |
||
2115 | jmp .got_input |
||
2116 | .left: |
||
2117 | mov eax, 'D' shl 16 |
||
2118 | add eax, [cursor_esc] |
||
2119 | mov dword[ebx], eax |
||
2120 | mov al, 3 |
||
2121 | jmp .got_input |
||
2122 | .home: |
||
2123 | mov eax, 'H' shl 16 |
||
2124 | add eax, [cursor_esc] |
||
2125 | mov dword[ebx], eax |
||
2126 | mov al, 3 |
||
2127 | jmp .got_input |
||
2128 | .end: |
||
2129 | mov eax, 'F' shl 16 |
||
2130 | add eax, [cursor_esc] |
||
2131 | mov dword[ebx], eax |
||
2132 | mov al, 3 |
||
2133 | jmp .got_input |
||
2134 | .insert: |
||
2135 | mov dword[ebx], 27 + ('[2~' shl 8) |
||
2136 | mov al, 4 |
||
2137 | jmp .got_input |
||
2138 | .delete: |
||
2139 | mov dword[ebx], 27 + ('[3~' shl 8) |
||
2140 | mov al, 4 |
||
2141 | jmp .got_input |
||
2142 | .pgup: |
||
2143 | mov dword[ebx], 27 + ('[5~' shl 8) |
||
2144 | mov al, 4 |
||
2145 | jmp .got_input |
||
2146 | .pgdown: |
||
2147 | mov dword[ebx], 27 + ('[6~' shl 8) |
||
2148 | mov al, 4 |
||
2149 | jmp .got_input |
||
2150 | .begin: |
||
2151 | mov dword[ebx], 27 + ('[E' shl 8) |
||
2152 | mov al, 3 |
||
2153 | jmp .got_input |
||
2154 | |||
2155 | |||
2156 | |||
1133 | diamond | 2157 | ; char* __stdcall con_gets(char* str, int n); |
836 | diamond | 2158 | con_gets: |
852 | diamond | 2159 | pop eax |
2160 | push 0 |
||
2161 | push eax |
||
1133 | diamond | 2162 | ; char* __stdcall con_gets2(con_gets2_callback callback, char* str, int n); |
852 | diamond | 2163 | con_gets2: |
9105 | hidnplayr | 2164 | call con_init_check |
1133 | diamond | 2165 | mov eax, [esp+8] ; str |
836 | diamond | 2166 | pushad |
1133 | diamond | 2167 | mov esi, eax ; str |
852 | diamond | 2168 | mov ebx, [esp+20h+12] ; n |
836 | diamond | 2169 | sub ebx, 1 |
2170 | jle .ret |
||
2171 | mov byte [esi], 0 |
||
2172 | xor ecx, ecx ; длина уже введённой строки |
||
2173 | call con.get_data_ptr |
||
2174 | .loop: |
||
852 | diamond | 2175 | call con_getch2 |
836 | diamond | 2176 | test al, al |
2177 | jz .extended |
||
2178 | cmp al, 8 |
||
2179 | jz .backspace |
||
2180 | cmp al, 27 |
||
2181 | jz .esc |
||
2182 | cmp al, 13 |
||
2183 | jz .enter |
||
852 | diamond | 2184 | cmp al, 9 |
2185 | jz .tab |
||
836 | diamond | 2186 | inc ecx |
2187 | mov dl, al |
||
2188 | call con.write_char_ex |
||
2189 | push [con.cur_x] |
||
2190 | push [con.cur_y] |
||
2191 | push edi |
||
2192 | push esi |
||
2193 | @@: |
||
2194 | lodsb |
||
2195 | mov [esi-1], dl |
||
2196 | mov dl, al |
||
2197 | test al, al |
||
2198 | jz @f |
||
2199 | call con.write_char_ex |
||
2200 | jmp @b |
||
2201 | @@: |
||
2202 | mov [esi], dl |
||
2203 | pop esi |
||
2204 | inc esi |
||
2205 | pop edi |
||
2206 | pop [con.cur_y] |
||
2207 | pop [con.cur_x] |
||
2208 | .update_screen_and_loop: |
||
2209 | call con.update_screen |
||
2210 | cmp ecx, ebx |
||
2211 | jb .loop |
||
852 | diamond | 2212 | .ret_us: |
836 | diamond | 2213 | mov edx, [con.cur_x] |
2214 | @@: |
||
2215 | lodsb |
||
2216 | test al, al |
||
2217 | jz @f |
||
2218 | inc edx |
||
2219 | cmp edx, [con.scr_width] |
||
2220 | jb @b |
||
2221 | xor edx, edx |
||
2222 | call con.newline |
||
2223 | jmp @b |
||
2224 | @@: |
||
2225 | mov [con.cur_x], edx |
||
2226 | call con.get_data_ptr |
||
2227 | call con.update_screen |
||
2228 | jmp .ret |
||
2229 | .esc: |
||
2230 | mov edx, [con.cur_x] |
||
2231 | @@: |
||
2232 | lodsb |
||
2233 | test al, al |
||
2234 | jz @f |
||
2235 | inc edx |
||
2236 | cmp edx, [con.scr_width] |
||
2237 | jb @b |
||
2238 | xor edx, edx |
||
2239 | call con.newline |
||
2240 | jmp @b |
||
2241 | @@: |
||
2242 | mov [con.cur_x], edx |
||
2243 | call con.get_data_ptr |
||
2244 | dec esi |
||
2245 | xor ecx, ecx |
||
2246 | @@: |
||
2247 | mov byte [esi], 0 |
||
852 | diamond | 2248 | cmp esi, [esp+20h+8] |
836 | diamond | 2249 | jbe .update_screen_and_loop |
2250 | mov al, 8 |
||
2251 | call con.write_special_char |
||
2252 | mov al, ' ' |
||
2253 | call con.write_char |
||
2254 | mov al, 8 |
||
2255 | call con.write_special_char |
||
2256 | dec esi |
||
2257 | jmp @b |
||
2258 | .delete: |
||
2259 | cmp byte [esi], 0 |
||
2260 | jz .loop |
||
2261 | lodsb |
||
2262 | call con.write_char_ex |
||
2263 | .backspace: |
||
852 | diamond | 2264 | cmp esi, [esp+20h+8] |
836 | diamond | 2265 | jbe .loop |
2266 | push esi |
||
2267 | mov edx, [con.cur_x] |
||
2268 | @@: |
||
2269 | lodsb |
||
2270 | test al, al |
||
2271 | jz @f |
||
2272 | inc edx |
||
2273 | cmp edx, [con.scr_width] |
||
2274 | jb @b |
||
2275 | xor edx, edx |
||
2276 | call con.newline |
||
2277 | jmp @b |
||
2278 | @@: |
||
2279 | mov [con.cur_x], edx |
||
2280 | call con.get_data_ptr |
||
2281 | dec esi |
||
2282 | mov al, 8 |
||
2283 | call con.write_special_char |
||
2284 | mov al, ' ' |
||
2285 | call con.write_char |
||
2286 | mov al, 8 |
||
2287 | call con.write_special_char |
||
2288 | mov dl, 0 |
||
2289 | @@: |
||
2290 | cmp esi, [esp] |
||
2291 | jbe @f |
||
2292 | mov al, 8 |
||
2293 | call con.write_special_char |
||
2294 | dec esi |
||
2295 | xchg dl, [esi] |
||
2296 | mov al, dl |
||
2297 | call con.write_char |
||
2298 | mov al, 8 |
||
2299 | call con.write_special_char |
||
2300 | jmp @b |
||
2301 | @@: |
||
2302 | pop esi |
||
2303 | dec esi |
||
2304 | mov [esi], dl |
||
2305 | dec ecx |
||
2306 | jmp .update_screen_and_loop |
||
2307 | .enter: |
||
2308 | mov edx, [con.cur_x] |
||
2309 | @@: |
||
2310 | lodsb |
||
2311 | test al, al |
||
2312 | jz @f |
||
2313 | inc edx |
||
2314 | cmp edx, [con.scr_width] |
||
2315 | jb @b |
||
2316 | xor edx, edx |
||
2317 | call con.newline |
||
2318 | jmp @b |
||
2319 | @@: |
||
2320 | mov [con.cur_x], edx |
||
2321 | call con.get_data_ptr |
||
2322 | mov al, 10 |
||
2323 | mov [esi-1], al |
||
2324 | mov byte [esi], 0 |
||
2325 | call con.write_special_char |
||
2326 | call con.update_screen |
||
2327 | jmp .ret |
||
852 | diamond | 2328 | .tab: |
2329 | mov al, 0 |
||
2330 | mov ah, 0xF |
||
836 | diamond | 2331 | .extended: |
1145 | diamond | 2332 | test ah, ah |
2333 | jz .closed |
||
852 | diamond | 2334 | xchg al, ah |
836 | diamond | 2335 | cmp al, 0x4B |
2336 | jz .left |
||
2337 | cmp al, 0x4D |
||
2338 | jz .right |
||
2339 | cmp al, 0x47 |
||
2340 | jz .home |
||
2341 | cmp al, 0x4F |
||
2342 | jz .end |
||
2343 | cmp al, 0x53 |
||
2344 | jz .delete |
||
852 | diamond | 2345 | ; give control to callback function |
2346 | cmp dword [esp+20h+4], 0 |
||
2347 | jz .loop |
||
2348 | ; remember length of text before and length of text after |
||
2349 | ; and advance cursor to the end of line |
||
2350 | push ecx |
||
2351 | push eax |
||
2352 | lea edx, [esi+1] |
||
2353 | @@: |
||
2354 | lodsb |
||
2355 | test al, al |
||
2356 | jz @f |
||
2357 | call con.write_char_ex |
||
2358 | jmp @b |
||
2359 | @@: |
||
2360 | sub esi, edx |
||
2361 | pop eax |
||
2362 | push esi |
||
2363 | dec edx |
||
2364 | sub edx, [esp+28h+8] |
||
2365 | push edx |
||
2366 | push esp ; ppos |
||
2367 | mov ecx, [esp+30h+4] |
||
2368 | lea edx, [esp+30h+12] |
||
2369 | push edx ; pn |
||
2370 | lea edx, [esp+34h+8] |
||
2371 | push edx ; pstr |
||
2372 | push eax ; keycode |
||
2373 | call ecx |
||
2374 | call con.get_data_ptr |
||
2375 | dec eax |
||
2376 | js .callback_nochange |
||
2377 | jz .callback_del |
||
2378 | dec eax |
||
2379 | jz .callback_output |
||
2380 | ; callback returned 2 - exit |
||
2381 | add esp, 12 |
||
2382 | jmp .ret |
||
2383 | .callback_nochange: |
||
2384 | ; callback returned 0 - string was not changed, only restore cursor position |
||
2385 | pop esi |
||
2386 | pop ecx |
||
2387 | test ecx, ecx |
||
2388 | jz .cncs |
||
2389 | @@: |
||
2390 | mov al, 8 |
||
2391 | call con.write_special_char |
||
2392 | loop @b |
||
2393 | .cncs: |
||
2394 | pop ecx |
||
2395 | add esi, [esp+20h+8] |
||
2396 | jmp .callback_done |
||
2397 | .callback_del: |
||
2398 | ; callback returned 1 - string was changed, delete old string and output new |
||
2399 | mov ecx, [esp+8] |
||
2400 | test ecx, ecx |
||
2401 | jz .cds |
||
2402 | @@: |
||
2403 | mov al, 8 |
||
2404 | call con.write_special_char |
||
2405 | mov al, ' ' |
||
2406 | call con.write_char_ex |
||
2407 | mov al, 8 |
||
2408 | call con.write_special_char |
||
2409 | loop @b |
||
2410 | .cds: |
||
2411 | .callback_output: |
||
2412 | ; callback returned 2 - string was changed, output new string |
||
2413 | pop edx |
||
2414 | pop esi |
||
2415 | pop ecx |
||
2416 | mov esi, [esp+20h+8] |
||
2417 | xor ecx, ecx |
||
2418 | @@: |
||
2419 | lodsb |
||
2420 | test al, al |
||
2421 | jz @f |
||
2422 | call con.write_char_ex |
||
2423 | inc ecx |
||
2424 | jmp @b |
||
2425 | @@: |
||
2426 | dec esi |
||
2427 | push ecx |
||
2428 | sub ecx, edx |
||
2429 | jz .cos |
||
2430 | @@: |
||
2431 | mov al, 8 |
||
2432 | call con.write_special_char |
||
2433 | dec esi |
||
2434 | loop @b |
||
2435 | .cos: |
||
2436 | pop ecx |
||
2437 | .callback_done: |
||
2438 | call con.update_screen |
||
2439 | mov ebx, [esp+20h+12] |
||
2440 | dec ebx |
||
2441 | cmp ecx, ebx |
||
2442 | jae .ret_us |
||
836 | diamond | 2443 | jmp .loop |
2444 | .left: |
||
852 | diamond | 2445 | cmp esi, [esp+20h+8] |
836 | diamond | 2446 | jbe .loop |
2447 | dec esi |
||
2448 | mov al, 8 |
||
2449 | call con.write_special_char |
||
2450 | jmp .update_screen_and_loop |
||
2451 | .right: |
||
2452 | cmp byte [esi], 0 |
||
2453 | jz .loop |
||
2454 | lodsb |
||
2455 | call con.write_char_ex |
||
2456 | jmp .update_screen_and_loop |
||
2457 | .home: |
||
852 | diamond | 2458 | cmp esi, [esp+20h+8] |
836 | diamond | 2459 | jz .update_screen_and_loop |
2460 | dec esi |
||
2461 | mov al, 8 |
||
2462 | call con.write_special_char |
||
2463 | jmp .home |
||
2464 | .end: |
||
2465 | lodsb |
||
2466 | test al, al |
||
2467 | jz @f |
||
2468 | call con.write_char_ex |
||
2469 | jmp .end |
||
2470 | @@: |
||
2471 | dec esi |
||
2472 | jmp .update_screen_and_loop |
||
1133 | diamond | 2473 | .closed: |
2474 | and dword [esp+1Ch], 0 |
||
836 | diamond | 2475 | .ret: |
2476 | popad |
||
852 | diamond | 2477 | ret 12 |
836 | diamond | 2478 | |
853 | diamond | 2479 | ; void __stdcall con_cls(); |
2480 | con_cls: |
||
9105 | hidnplayr | 2481 | mov ah, [con.init_cmd] |
2482 | test ah, ah |
||
2483 | je cmd_init_no |
||
9096 | hidnplayr | 2484 | |
853 | diamond | 2485 | push edi |
9105 | hidnplayr | 2486 | call con.write_special_char.erase_all |
853 | diamond | 2487 | pop edi |
2488 | call con.update_screen |
||
9096 | hidnplayr | 2489 | |
9105 | hidnplayr | 2490 | ret |
9096 | hidnplayr | 2491 | |
9105 | hidnplayr | 2492 | cmd_init_no: |
9096 | hidnplayr | 2493 | |
9105 | hidnplayr | 2494 | push con.title_init_console |
2495 | push -1 |
||
2496 | push -1 |
||
2497 | push -1 |
||
2498 | push -1 |
||
9096 | hidnplayr | 2499 | |
9105 | hidnplayr | 2500 | call con_init |
9096 | hidnplayr | 2501 | |
853 | diamond | 2502 | ret |
2503 | |||
2504 | ; void __stdcall con_get_cursor_pos(int* px, int* py); |
||
2505 | con_get_cursor_pos: |
||
2506 | push eax ecx |
||
2507 | mov eax, [esp+12] |
||
2508 | mov ecx, [con.cur_x] |
||
2509 | mov [eax], ecx |
||
2510 | mov eax, [esp+16] |
||
2511 | mov ecx, [con.cur_y] |
||
2512 | mov [eax], ecx |
||
2513 | pop ecx eax |
||
2514 | ret 8 |
||
2515 | |||
2516 | ; void __stdcall con_set_cursor_pos(int px, int py); |
||
2517 | con_set_cursor_pos: |
||
2518 | push eax |
||
2519 | mov eax, [esp+8] |
||
2520 | cmp eax, [con.scr_width] |
||
2521 | jae @f |
||
2522 | mov [con.cur_x], eax |
||
2523 | @@: |
||
2524 | mov eax, [esp+12] |
||
2525 | cmp eax, [con.scr_height] |
||
2526 | jae @f |
||
2527 | mov [con.cur_y], eax |
||
2528 | @@: |
||
2529 | pop eax |
||
2530 | call con.update_screen |
||
2531 | ret 8 |
||
2532 | |||
836 | diamond | 2533 | con.update_screen: |
2534 | push eax |
||
2535 | mov eax, [con.cur_y] |
||
2536 | sub eax, [con.wnd_ypos] |
||
2537 | jb .up |
||
2538 | cmp eax, [con.wnd_height] |
||
2539 | jb .done |
||
2540 | mov eax, [con.cur_y] |
||
2541 | sub eax, [con.wnd_height] |
||
2542 | inc eax |
||
2543 | jmp .set |
||
2544 | .up: |
||
2545 | mov eax, [con.cur_y] |
||
2546 | .set: |
||
2547 | mov [con.wnd_ypos], eax |
||
2548 | .done: |
||
2549 | pop eax |
||
9105 | hidnplayr | 2550 | mov [con.thread_op], OP_REDRAW |
836 | diamond | 2551 | |
2552 | con.wake: |
||
2553 | pushad |
||
2554 | mov al, [con.thread_op] |
||
2555 | cmp al, byte [con.ipc_buf+0x10] |
||
2556 | jz .ret |
||
2557 | @@: |
||
2558 | push 60 |
||
2559 | pop eax |
||
2560 | push 2 |
||
2561 | pop ebx |
||
2562 | mov ecx, [con.console_tid] |
||
1133 | diamond | 2563 | jecxz .ret |
836 | diamond | 2564 | mov edx, con.thread_op |
2565 | push 1 |
||
2566 | pop esi |
||
2567 | int 0x40 |
||
2568 | test eax, eax |
||
2569 | jz @f |
||
2570 | push 5 |
||
2571 | pop eax |
||
2572 | mov bl, 1 |
||
2573 | int 0x40 |
||
2574 | jmp @b |
||
2575 | @@: |
||
2576 | .ret: |
||
2577 | popad |
||
2578 | ret |
||
2579 | |||
2580 | ; Поток окна консоли. Обрабатывает ввод и вывод. |
||
2581 | con.thread: |
||
2582 | ; Поток реагирует на IPC, которое используется только для того, чтобы его можно было "разбудить" |
||
2583 | push 40 |
||
2584 | pop eax |
||
2585 | push 0x67 |
||
2586 | pop ebx |
||
2587 | int 0x40 |
||
2588 | mov al, 60 |
||
2589 | mov bl, 1 |
||
2590 | mov ecx, con.ipc_buf |
||
2591 | push 0x11 |
||
2592 | pop edx |
||
2593 | int 0x40 |
||
2594 | mov al, 66 |
||
2595 | mov bl, 1 |
||
2596 | mov ecx, ebx |
||
2597 | int 0x40 |
||
2598 | con.redraw: |
||
2599 | call con.draw_window |
||
2600 | con.msg_loop: |
||
2601 | cmp dword [con.bUpPressed], 0 |
||
2602 | jnz .wait_timeout |
||
2603 | push 10 |
||
2604 | pop eax |
||
2605 | jmp @f |
||
2606 | .wait_timeout: |
||
2607 | push 23 |
||
2608 | pop eax |
||
2609 | push 5 |
||
2610 | pop ebx |
||
2611 | @@: |
||
2612 | int 0x40 |
||
2613 | dec eax |
||
2614 | jz con.redraw |
||
2615 | dec eax |
||
2616 | jz con.key |
||
2617 | dec eax |
||
2618 | jz con.button |
||
2619 | cmp al, 4 |
||
2620 | jz con.ipc |
||
2621 | jmp con.mouse |
||
2622 | con.button: |
||
2623 | ; we have only one button, close |
||
8328 | superturbo | 2624 | mov eax, 18 |
2625 | mov ebx, 18 |
||
2626 | mov ecx,[process_info_buffer+30] |
||
2627 | dec ecx |
||
2628 | int 0x40 ; kill parent process |
||
2629 | |||
836 | diamond | 2630 | con.thread_exit: |
1133 | diamond | 2631 | or byte [con_flags+1], 2 |
2632 | and [con.console_tid], 0 |
||
1134 | diamond | 2633 | and [con.entered_char], 0 |
836 | diamond | 2634 | or eax, -1 |
2635 | int 0x40 |
||
2636 | con.key: |
||
2637 | mov al, 2 |
||
2638 | int 0x40 |
||
5618 | hidnplayr | 2639 | and eax, 0xffff ; supress scancodes |
836 | diamond | 2640 | ; ah = scancode |
2641 | cmp ah, 0xE0 |
||
2642 | jnz @f |
||
2643 | mov [con.bWasE0], 1 |
||
2644 | jmp con.msg_loop |
||
2645 | @@: |
||
2646 | shr eax, 8 |
||
2647 | xchg ah, [con.bWasE0] |
||
2648 | test al, al |
||
2649 | jle con.msg_loop |
||
2650 | cmp al, 0x1D |
||
2651 | jz con.msg_loop |
||
2652 | cmp al, 0x2A |
||
2653 | jz con.msg_loop |
||
2654 | cmp al, 0x36 |
||
2655 | jz con.msg_loop |
||
2656 | cmp al, 0x38 |
||
2657 | jz con.msg_loop |
||
2658 | cmp al, 0x3A |
||
2659 | jz con.msg_loop |
||
2660 | cmp al, 0x45 |
||
2661 | jz con.msg_loop |
||
2662 | cmp al, 0x46 |
||
2663 | jz con.msg_loop |
||
2664 | mov edx, eax |
||
4402 | hidnplayr | 2665 | cmp dl, 0x4e |
2666 | je .numpad |
||
2667 | cmp dl, 0x4a |
||
2668 | je .numpad |
||
836 | diamond | 2669 | push 66 |
2670 | pop eax |
||
2671 | push 3 |
||
2672 | pop ebx |
||
2673 | int 0x40 ; eax = control key state |
||
2674 | test dh, dh |
||
2675 | jnz .extended |
||
4306 | hidnplayr | 2676 | test al, 0x80 ; numlock |
2677 | jnz .numlock |
||
836 | diamond | 2678 | bt [scan_has_ascii], edx |
2679 | jnc .extended |
||
4306 | hidnplayr | 2680 | test al, 0x30 ; alt |
836 | diamond | 2681 | jnz .extended |
4306 | hidnplayr | 2682 | test al, 0x80 ; numlock |
2683 | jz .no_numlock |
||
2684 | .numlock: |
||
2685 | cmp dl, 71 |
||
2686 | jb .no_numlock |
||
2687 | cmp dl, 83 |
||
2688 | ja .no_numlock |
||
4402 | hidnplayr | 2689 | .numpad: |
4306 | hidnplayr | 2690 | mov dh, [con.extended_numlock+edx-71] |
2691 | xchg dl, dh |
||
2692 | jmp .gotcode |
||
2693 | .no_numlock: |
||
836 | diamond | 2694 | ; key has ASCII code |
2695 | push eax edx |
||
2696 | push 2 |
||
2697 | pop ecx |
||
2698 | test al, 3 |
||
2699 | jnz @f |
||
2700 | dec ecx |
||
2701 | @@: |
||
2702 | push 26 |
||
2703 | pop eax |
||
2704 | mov bl, 2 |
||
2705 | mov edx, con.kbd_layout |
||
2706 | int 0x40 |
||
2707 | pop edx eax |
||
2708 | mov dh, [con.kbd_layout+edx] |
||
2709 | test al, 0xC |
||
2710 | jz @f |
||
2711 | sub dh, 0x60 |
||
2712 | jmp @f |
||
2713 | .extended: |
||
2714 | mov dh, 0 ; no ASCII code |
||
2715 | @@: |
||
2716 | ; dh contains ASCII-code; now convert scancode to extended key code |
||
2717 | mov ecx, con.extended_alt |
||
2718 | test al, 0x30 |
||
2719 | jnz .xlat |
||
4384 | hidnplayr | 2720 | |
836 | diamond | 2721 | mov ecx, con.extended_shift |
2722 | test al, 3 |
||
2723 | jnz .xlat |
||
4384 | hidnplayr | 2724 | |
836 | diamond | 2725 | mov ecx, con.extended_ctrl |
2726 | test al, 0xC |
||
2727 | jnz .xlat |
||
4384 | hidnplayr | 2728 | |
2729 | cmp dl, 28 |
||
2730 | jne @f |
||
2731 | shl dx, 8 |
||
2732 | mov dl, 13 |
||
2733 | jmp .gotcode |
||
2734 | @@: |
||
2735 | cmp dl, 53 |
||
2736 | jne @f |
||
2737 | shl dx, 8 |
||
2738 | mov dl, '/' |
||
2739 | jmp .gotcode |
||
2740 | @@: |
||
2741 | cmp dl, 55 |
||
2742 | jne @f |
||
2743 | shl dx, 8 |
||
2744 | mov dl, '*' |
||
2745 | jmp .gotcode |
||
2746 | @@: |
||
836 | diamond | 2747 | xchg dl, dh |
2748 | cmp dh, 0x57 |
||
2749 | jz @f |
||
2750 | cmp dh, 0x58 |
||
2751 | jnz .gotcode |
||
2752 | @@: |
||
2753 | add dh, 0x85-0x57 |
||
2754 | jmp .gotcode |
||
2755 | .xlat: |
||
2756 | movzx eax, dl |
||
2757 | mov dl, dh |
||
2758 | mov dh, [eax+ecx] |
||
2759 | .gotcode: |
||
2760 | test dh, dh |
||
2761 | jz con.msg_loop |
||
2762 | cmp dh, 0x94 |
||
2763 | jnz @f |
||
2764 | mov dl, 0 |
||
2765 | @@: |
||
2766 | ; dx contains full keycode |
||
2767 | cmp [con.bGetchRequested], 0 |
||
2768 | jz @f |
||
2769 | mov [con.entered_char], dx |
||
2770 | jmp con.msg_loop |
||
2771 | @@: |
||
2772 | mov eax, [con.input_end] |
||
2773 | mov ecx, eax |
||
2774 | add eax, 2 |
||
2775 | cmp eax, con.input_buffer_end |
||
2776 | jnz @f |
||
2777 | mov eax, con.input_buffer |
||
2778 | @@: |
||
2779 | cmp eax, [con.input_start] |
||
2780 | jnz @f |
||
2781 | ; buffer overflow, make beep and continue |
||
2782 | push 55 |
||
2783 | pop eax |
||
2784 | mov ebx, eax |
||
2785 | mov esi, con.beep |
||
2786 | int 0x40 |
||
2787 | jmp con.msg_loop |
||
2788 | @@: |
||
2789 | mov [ecx], dx |
||
2790 | mov [con.input_end], eax |
||
2791 | jmp con.msg_loop |
||
2792 | con.ipc: |
||
2793 | movzx eax, byte [con.ipc_buf+0x10] |
||
2794 | mov byte [con.ipc_buf+4], 8 |
||
2795 | mov byte [con.ipc_buf+0x10], 0 |
||
2796 | dec eax |
||
2797 | jz con.thread_exit |
||
2798 | dec eax |
||
2799 | jz con.set_title |
||
2800 | dec eax |
||
2801 | jz con.redraw_image |
||
2802 | dec eax |
||
2803 | jz con.getch |
||
9105 | hidnplayr | 2804 | dec eax |
2805 | jz con.resize |
||
836 | diamond | 2806 | jmp con.msg_loop |
9105 | hidnplayr | 2807 | con.resize: |
2808 | push 48 |
||
2809 | pop eax |
||
2810 | push 4 |
||
2811 | pop ebx |
||
2812 | int 0x40 |
||
2813 | |||
2814 | mov edx, [con.def_wnd_x-2] |
||
2815 | mov edx, [con.wnd_width] |
||
2816 | imul edx, font_width |
||
2817 | add edx, 5+5-1 |
||
2818 | |||
2819 | mov esi, [con.def_wnd_y-2] |
||
2820 | mov esi, [con.wnd_height] |
||
2821 | imul esi, font_height |
||
2822 | lea esi, [eax + esi + 5-1] |
||
2823 | ; place for scrollbar |
||
2824 | mov eax, [con.wnd_height] |
||
2825 | cmp eax, [con.scr_height] |
||
2826 | jae @f |
||
2827 | add edx, con.vscroll_width |
||
2828 | @@: |
||
2829 | push 67 |
||
2830 | pop eax |
||
2831 | mov ebx, -1 |
||
2832 | mov ecx, ebx |
||
2833 | int 0x40 |
||
2834 | call con.draw_window |
||
2835 | jmp con.msg_loop |
||
836 | diamond | 2836 | con.set_title: |
2837 | push 71 |
||
2838 | pop eax |
||
2839 | push 1 |
||
2840 | pop ebx |
||
2841 | mov ecx, [con.title] |
||
2842 | int 0x40 |
||
2843 | jmp con.msg_loop |
||
2844 | con.redraw_image: |
||
2845 | call con.data2image |
||
2846 | call con.draw_image |
||
2847 | jmp con.msg_loop |
||
2848 | con.getch: |
||
2849 | mov eax, [con.input_start] |
||
2850 | cmp eax, [con.input_end] |
||
2851 | jz .noinput |
||
2852 | mov ecx, [eax] |
||
2853 | mov [con.entered_char], cx |
||
2854 | inc eax |
||
2855 | inc eax |
||
2856 | cmp eax, con.input_buffer_end |
||
2857 | jnz @f |
||
2858 | mov eax, con.input_buffer |
||
2859 | @@: |
||
2860 | mov [con.input_start], eax |
||
2861 | jmp con.msg_loop |
||
2862 | .noinput: |
||
2863 | mov [con.bGetchRequested], 1 |
||
2864 | jmp con.msg_loop |
||
2865 | con.mouse: |
||
5618 | hidnplayr | 2866 | push 37 |
2867 | pop eax |
||
2868 | push 7 |
||
2869 | pop ebx |
||
2870 | int 0x40 |
||
2871 | test eax, eax |
||
2872 | jz .no_scrollmouse |
||
2873 | cwde |
||
2874 | add eax, [con.wnd_ypos] |
||
2875 | jg @f |
||
836 | diamond | 2876 | xor eax, eax |
5618 | hidnplayr | 2877 | @@: |
2878 | mov ebx, [con.scr_height] |
||
2879 | sub ebx, [con.wnd_height] |
||
2880 | cmp eax, ebx |
||
2881 | jb @f |
||
2882 | mov eax, ebx |
||
2883 | @@: |
||
2884 | mov [con.wnd_ypos], eax |
||
2885 | jmp con.redraw_image |
||
2886 | .no_scrollmouse: |
||
2887 | xor eax, eax |
||
836 | diamond | 2888 | xchg eax, dword [con.bUpPressed] |
2889 | mov dword [con.bUpPressed_saved], eax |
||
2890 | push 37 |
||
2891 | pop eax |
||
2892 | push 2 |
||
2893 | pop ebx |
||
2894 | int 0x40 |
||
2895 | test al, 1 |
||
2896 | jnz @f |
||
2897 | cmp [con.vscroll_pt], -1 |
||
2898 | jz .redraw_if_needed |
||
2899 | or [con.vscroll_pt], -1 |
||
2900 | .redraw_if_needed: |
||
2901 | cmp dword [con.bUpPressed_saved], 0 |
||
2902 | jnz con.redraw_image |
||
2903 | jmp con.msg_loop |
||
2904 | @@: |
||
2905 | mov al, 37 |
||
2906 | dec ebx |
||
2907 | int 0x40 |
||
2908 | movsx ebx, ax |
||
2909 | sar eax, 16 |
||
2910 | cmp [con.vscroll_pt], -1 |
||
2911 | jnz .vscrolling |
||
2912 | test ebx, ebx |
||
2913 | js .redraw_if_needed |
||
2914 | sub ax, [con.data_width] |
||
2915 | jb .redraw_if_needed |
||
2916 | cmp eax, con.vscroll_width |
||
2917 | jae .redraw_if_needed |
||
2918 | cmp ebx, con.vscroll_btn_height |
||
2919 | jb .up |
||
2920 | sub bx, [con.data_height] |
||
2921 | jae .redraw_if_needed |
||
2922 | cmp bx, -con.vscroll_btn_height |
||
2923 | jge .down |
||
2924 | add bx, [con.data_height] |
||
2925 | sub bx, word [con.vscrollbar_pos] |
||
2926 | jl .vscroll_up |
||
2927 | cmp bx, word [con.vscrollbar_size] |
||
2928 | jl .vscroll |
||
2929 | .vscroll_down: |
||
2930 | cmp [con.bScrollingDown_saved], 0 |
||
2931 | jz .vscroll_down_first |
||
2932 | cmp [con.bScrollingDown_saved], 1 |
||
2933 | jz .vscroll_down_wasfirst |
||
2934 | mov [con.bScrollingDown], 2 |
||
2935 | .vscroll_down_do: |
||
2936 | mov eax, [con.wnd_ypos] |
||
2937 | add eax, [con.wnd_height] |
||
2938 | dec eax |
||
2939 | mov ebx, [con.scr_height] |
||
2940 | sub ebx, [con.wnd_height] |
||
2941 | cmp eax, ebx |
||
2942 | jb @f |
||
2943 | mov eax, ebx |
||
2944 | @@: |
||
2945 | mov [con.wnd_ypos], eax |
||
2946 | jmp con.redraw_image |
||
2947 | .vscroll_down_first: |
||
2948 | push 26 |
||
2949 | pop eax |
||
2950 | push 9 |
||
2951 | pop ebx |
||
2952 | int 0x40 |
||
2953 | mov [con.scroll_down_first_time], eax |
||
2954 | mov [con.bScrollingDown], 1 |
||
2955 | jmp .vscroll_down_do |
||
2956 | .vscroll_down_wasfirst: |
||
2957 | push 26 |
||
2958 | pop eax |
||
2959 | push 9 |
||
2960 | pop ebx |
||
2961 | int 0x40 |
||
2962 | sub eax, [con.scroll_down_first_time] |
||
2963 | cmp eax, 25 |
||
2964 | jb @f |
||
2965 | mov [con.bScrollingDown], 2 |
||
2966 | jmp .vscroll_down_do |
||
2967 | @@: |
||
2968 | mov [con.bScrollingDown], 1 |
||
2969 | jmp con.msg_loop |
||
2970 | .vscroll_up: |
||
2971 | cmp [con.bScrollingUp_saved], 0 |
||
2972 | jz .vscroll_up_first |
||
2973 | cmp [con.bScrollingUp_saved], 1 |
||
2974 | jz .vscroll_up_wasfirst |
||
2975 | mov [con.bScrollingUp], 2 |
||
2976 | .vscroll_up_do: |
||
2977 | mov eax, [con.wnd_ypos] |
||
2978 | inc eax |
||
2979 | sub eax, [con.wnd_height] |
||
2980 | jns @f |
||
2981 | xor eax, eax |
||
2982 | @@: |
||
2983 | mov [con.wnd_ypos], eax |
||
2984 | jmp con.redraw_image |
||
2985 | .vscroll_up_first: |
||
2986 | push 26 |
||
2987 | pop eax |
||
2988 | push 9 |
||
2989 | pop ebx |
||
2990 | int 0x40 |
||
2991 | mov [con.scroll_up_first_time], eax |
||
2992 | mov [con.bScrollingUp], 1 |
||
2993 | jmp .vscroll_up_do |
||
2994 | .vscroll_up_wasfirst: |
||
2995 | push 26 |
||
2996 | pop eax |
||
2997 | push 9 |
||
2998 | pop ebx |
||
2999 | int 0x40 |
||
3000 | sub eax, [con.scroll_up_first_time] |
||
3001 | cmp eax, 25 |
||
3002 | jb @f |
||
3003 | mov [con.bScrollingUp], 2 |
||
3004 | jmp .vscroll_up_do |
||
3005 | @@: |
||
3006 | mov [con.bScrollingUp], 1 |
||
3007 | jmp con.msg_loop |
||
3008 | .up: |
||
3009 | cmp [con.bUpPressed_saved], 0 |
||
3010 | jz .up_first |
||
3011 | cmp [con.bUpPressed_saved], 1 |
||
3012 | jz .up_wasfirst |
||
3013 | mov [con.bUpPressed], 2 |
||
3014 | .up_do: |
||
3015 | mov eax, [con.wnd_ypos] |
||
3016 | dec eax |
||
3017 | js @f |
||
3018 | mov [con.wnd_ypos], eax |
||
3019 | @@: |
||
3020 | jmp con.redraw_image |
||
3021 | .up_first: |
||
3022 | push 26 |
||
3023 | pop eax |
||
3024 | push 9 |
||
3025 | pop ebx |
||
3026 | int 0x40 |
||
3027 | mov [con.up_first_time], eax |
||
3028 | mov [con.bUpPressed], 1 |
||
3029 | jmp .up_do |
||
3030 | .up_wasfirst: |
||
3031 | push 26 |
||
3032 | pop eax |
||
3033 | push 9 |
||
3034 | pop ebx |
||
3035 | int 0x40 |
||
3036 | sub eax, [con.up_first_time] |
||
3037 | cmp eax, 25 |
||
3038 | jb @f |
||
3039 | mov [con.bUpPressed], 2 |
||
3040 | jmp .up_do |
||
3041 | @@: |
||
3042 | mov [con.bUpPressed], 1 |
||
3043 | jmp con.msg_loop |
||
3044 | .down: |
||
3045 | cmp [con.bDownPressed_saved], 0 |
||
3046 | jz .down_first |
||
3047 | cmp [con.bDownPressed_saved], 1 |
||
3048 | jz .down_wasfirst |
||
3049 | mov [con.bDownPressed], 2 |
||
3050 | .down_do: |
||
3051 | mov eax, [con.scr_height] |
||
3052 | sub eax, [con.wnd_height] |
||
3053 | jbe con.redraw_image |
||
3054 | cmp [con.wnd_ypos], eax |
||
3055 | jae con.redraw_image |
||
3056 | inc [con.wnd_ypos] |
||
3057 | jmp con.redraw_image |
||
3058 | .down_first: |
||
3059 | push 26 |
||
3060 | pop eax |
||
3061 | push 9 |
||
3062 | pop ebx |
||
3063 | int 0x40 |
||
3064 | mov [con.down_first_time], eax |
||
3065 | mov [con.bDownPressed], 1 |
||
3066 | jmp .down_do |
||
3067 | .down_wasfirst: |
||
3068 | push 26 |
||
3069 | pop eax |
||
3070 | push 9 |
||
3071 | pop ebx |
||
3072 | int 0x40 |
||
3073 | sub eax, [con.down_first_time] |
||
3074 | cmp eax, 25 |
||
3075 | jb @f |
||
3076 | mov [con.bDownPressed], 2 |
||
3077 | jmp .down_do |
||
3078 | @@: |
||
3079 | mov [con.bDownPressed], 1 |
||
3080 | jmp con.msg_loop |
||
3081 | .vscroll: |
||
3082 | mov [con.vscroll_pt], ebx |
||
3083 | call con.draw_image |
||
3084 | jmp con.msg_loop |
||
3085 | .vscrolling: |
||
3086 | sub ebx, [con.vscroll_pt] |
||
3087 | sub ebx, con.vscroll_btn_height |
||
3088 | jge @f |
||
3089 | xor ebx, ebx |
||
3090 | @@: |
||
3091 | movzx eax, [con.data_height] |
||
3092 | sub eax, 2*con.vscroll_btn_height |
||
3093 | sub eax, [con.vscrollbar_size] |
||
3094 | cmp ebx, eax |
||
3095 | jb @f |
||
3096 | lea ebx, [eax-1] |
||
3097 | @@: |
||
3098 | xchg eax, ebx |
||
3099 | mov edx, [con.scr_height] |
||
3100 | sub edx, [con.wnd_height] |
||
3101 | inc edx |
||
3102 | mul edx |
||
3103 | div ebx |
||
3104 | cmp [con.wnd_ypos], eax |
||
3105 | jz con.msg_loop |
||
3106 | mov [con.wnd_ypos], eax |
||
3107 | jmp con.redraw_image |
||
3108 | |||
3109 | con.draw_window: |
||
3110 | push 12 |
||
3111 | pop eax |
||
3112 | xor ebx, ebx |
||
3113 | inc ebx |
||
3114 | int 0x40 |
||
9105 | hidnplayr | 3115 | |
836 | diamond | 3116 | mov al, 48 |
3117 | mov bl, 4 |
||
3118 | int 0x40 |
||
3119 | mov ebx, [con.def_wnd_x-2] |
||
3120 | mov bx, word [con.wnd_width] |
||
3121 | imul bx, font_width |
||
3122 | add bx, 5+5-1 |
||
3123 | mov ecx, [con.def_wnd_y-2] |
||
3124 | mov cx, word [con.wnd_height] |
||
3125 | imul cx, font_height |
||
3126 | lea ecx, [ecx+eax+5-1] |
||
2530 | leency | 3127 | mov edx, 0x74000000 |
836 | diamond | 3128 | mov edi, [con.title] |
3129 | ; place for scrollbar |
||
3130 | mov eax, [con.wnd_height] |
||
3131 | cmp eax, [con.scr_height] |
||
3132 | jae @f |
||
3133 | add ebx, con.vscroll_width |
||
3134 | @@: |
||
3135 | xor eax, eax |
||
3136 | int 0x40 |
||
9105 | hidnplayr | 3137 | |
3138 | mov eax, 9 |
||
3139 | mov ebx, process_info_buffer |
||
3140 | mov ecx, -1 |
||
3034 | leency | 3141 | int 0x40 |
9105 | hidnplayr | 3142 | test [process_info_buffer.wnd_state], 110b ; window is rolled up or minimized to panel |
3034 | leency | 3143 | jnz .exit |
9105 | hidnplayr | 3144 | |
836 | diamond | 3145 | call con.draw_image |
3034 | leency | 3146 | |
3147 | .exit: |
||
836 | diamond | 3148 | push 12 |
3149 | pop eax |
||
3150 | push 2 |
||
3151 | pop ebx |
||
3152 | int 0x40 |
||
3686 | hidnplayr | 3153 | |
836 | diamond | 3154 | ret |
3155 | |||
3156 | con.draw_image: |
||
3157 | xor edx, edx |
||
3158 | mov ecx, [con.wnd_width] |
||
3159 | imul ecx, font_width |
||
3160 | mov [con.data_width], cx |
||
3161 | shl ecx, 16 |
||
3162 | mov cx, word [con.wnd_height] |
||
3163 | imul cx, font_height |
||
3164 | mov [con.data_height], cx |
||
3165 | mov ebx, [con.image] |
||
3166 | push 65 |
||
3167 | pop eax |
||
3168 | xor ebp, ebp |
||
3169 | mov edi, con.colors |
||
3170 | push 8 |
||
3171 | pop esi |
||
3172 | int 0x40 |
||
3173 | mov al, 7 |
||
3174 | mov edx, [con.wnd_height] |
||
3175 | cmp edx, [con.scr_height] |
||
3176 | jae .skip_vscroll |
||
3177 | push ecx |
||
3178 | mov edx, ecx |
||
3179 | xor dx, dx |
||
3180 | mov ebx, con.vscroll_btn3 |
||
3181 | cmp [con.bUpPressed], 0 |
||
3182 | jnz @f |
||
3183 | mov ebx, con.vscroll_btn1 |
||
3184 | @@: |
||
3185 | mov ecx, con.vscroll_width*65536 + con.vscroll_btn_height |
||
3186 | int 0x40 |
||
3187 | pop edx |
||
3188 | sub dx, con.vscroll_btn_height |
||
3189 | mov ebx, con.vscroll_btn4 |
||
3190 | cmp [con.bDownPressed], 0 |
||
3191 | jnz @f |
||
3192 | mov ebx, con.vscroll_btn2 |
||
3193 | @@: |
||
3194 | int 0x40 |
||
3195 | push edx |
||
3196 | ; Вычисляем высоту бегунка |
||
3197 | mov ax, dx |
||
3198 | sub eax, con.vscroll_btn_height |
||
3199 | mov ecx, eax |
||
3200 | mul [con.wnd_height] |
||
3201 | div [con.scr_height] |
||
3202 | cmp eax, 5 |
||
3203 | jae @f |
||
3204 | mov al, 5 |
||
3205 | @@: |
||
3206 | ; eax = высота бегунка. Вычисляем положение бегунка |
||
3207 | mov [con.vscrollbar_size], eax |
||
3208 | xchg eax, ecx |
||
3209 | sub eax, ecx |
||
3210 | mul [con.wnd_ypos] |
||
3211 | mov ebx, [con.scr_height] |
||
3212 | sub ebx, [con.wnd_height] |
||
3213 | div ebx |
||
3214 | pop edx |
||
3215 | push edx |
||
3216 | ; ecx = высота бегунка, eax = положение |
||
3217 | add eax, con.vscroll_btn_height |
||
3218 | mov [con.vscrollbar_pos], eax |
||
3219 | mov ebx, con.vscroll_bgr2 |
||
3220 | cmp [con.bScrollingUp], 0 |
||
3221 | jnz @f |
||
3222 | mov ebx, con.vscroll_bgr1 |
||
3223 | @@: |
||
3224 | mov ecx, con.vscroll_width*65536 + con.vscroll_bgr_height |
||
3225 | push eax |
||
3226 | push 7 |
||
3227 | pop eax |
||
3228 | mov dx, con.vscroll_btn_height |
||
3229 | call .vpattern |
||
3230 | mov dx, word [con.vscrollbar_pos] |
||
3231 | add dx, word [con.vscrollbar_size] |
||
3232 | mov cx, con.vscroll_bgr_height |
||
3233 | mov ebx, con.vscroll_bgr2 |
||
3234 | cmp [con.bScrollingDown], 0 |
||
3235 | jnz @f |
||
3236 | mov ebx, con.vscroll_bgr1 |
||
3237 | @@: |
||
3238 | call .vpattern |
||
3239 | mov ecx, [con.vscrollbar_pos] |
||
3240 | mov dx, cx |
||
3241 | add ecx, [con.vscrollbar_size] |
||
3242 | sub ecx, con.vscroll_bar_height3 |
||
3243 | push ecx |
||
3244 | mov ebx, con.vscroll_bar1 |
||
3245 | mov ecx, con.vscroll_width*65536 + con.vscroll_bar_height1 |
||
3246 | int 0x40 |
||
3247 | add dx, cx |
||
3248 | mov cx, con.vscroll_bar_height2 |
||
3249 | mov ebx, con.vscroll_bar2 |
||
3250 | call .vpattern |
||
3251 | mov ebx, con.vscroll_bar3 |
||
3252 | mov cx, con.vscroll_bar_height3 |
||
3253 | int 0x40 |
||
3254 | .skip_vscroll: |
||
3255 | ret |
||
3256 | |||
3257 | .vpattern: |
||
3258 | push edx |
||
3259 | add dx, cx |
||
3260 | cmp dx, [esp+8] |
||
3261 | pop edx |
||
3262 | jbe @f |
||
3263 | mov cx, [esp+4] |
||
3264 | sub cx, dx |
||
3265 | jz .ret |
||
3266 | @@: |
||
3267 | int 0x40 |
||
3268 | add dx, cx |
||
3269 | cmp dx, [esp+4] |
||
3270 | jb .vpattern |
||
3271 | .ret: |
||
3272 | ret 4 |
||
3273 | |||
3274 | align 4 |
||
3275 | con.colors dd 0x000000, 0x000080, 0x008000, 0x008080 |
||
3276 | dd 0x800000, 0x800080, 0x808000, 0xC0C0C0 |
||
3277 | dd 0x808080, 0x0000FF, 0x00FF00, 0x00FFFF |
||
3278 | dd 0xFF0000, 0xFF00FF, 0xFFFF00, 0xFFFFFF |
||
3279 | |||
3280 | scan_has_ascii: |
||
3281 | dd 11011111111111111111111111111110b |
||
3282 | dd 00000010001111111111101111111111b |
||
3283 | dd 00000000000000000000000000000000b |
||
3284 | dd 0 |
||
3285 | |||
3286 | con.extended_alt: |
||
3287 | db 00h,01h,78h,79h,7Ah,7Bh,7Ch,7Dh,7Eh,7Fh,80h,81h,82h,83h,0Eh,0A5h |
||
3288 | db 10h,11h,12h,13h,14h,15h,16h,17h,18h,19h,1Ah,1Bh,1Ch,00h,1Eh,1Fh |
||
3289 | db 20h,21h,22h,23h,24h,25h,26h,27h,28h,29h,00h,2Bh,2Ch,2Dh,2Eh,2Fh |
||
3290 | db 30h,31h,32h,33h,34h,35h,00h,37h,00h,39h,00h,68h,69h,6Ah,6Bh,6Ch |
||
3291 | db 6Dh,6Eh,6Fh,70h,71h,00h,00h,97h,98h,99h,4Ah,9Bh,9Ch,9Dh,4Eh,9Fh |
||
3292 | db 0A0h,0A1h,0A2h,0A3h,00h,00h,00h,8Bh,8Ch,00h,00h,00h,00h,00h,00h,00h |
||
3293 | times 20h db 0 |
||
3294 | con.extended_ctrl: |
||
3295 | times 0Fh db %-1 |
||
3296 | db 0x94 |
||
3297 | times 2Bh db %-1 |
||
3298 | db 5Eh,5Fh,60h,61h,62h,63h,64h,65h,66h,67h,00h,00h |
||
3299 | db 77h,8Dh,84h,8Eh,73h,8Fh,74h,90h,75h,91h,76h,92h,93h,00h,00h,00h,89h,8Ah |
||
3300 | times 0x80-0x59 db 0 |
||
3301 | con.extended_shift: |
||
3302 | times 3Bh db %-1 |
||
3303 | db 54h,55h,56h,57h,58h,59h,5Ah,5Bh,5Ch,5Dh,00h,00h |
||
3304 | db 47h,48h,49h,4Ah,4Bh,4Ch,4Dh,4Eh,4Fh,50h,51h,52h,53h,00h,00h,00h,87h,88h |
||
3305 | times 0x80-0x59 db 0 |
||
4306 | hidnplayr | 3306 | con.extended_numlock: |
3307 | db '7', '8', '9', '-' |
||
3308 | db '4', '5', '6', '+' |
||
3309 | db '1', '2', '3' |
||
3310 | db '0', '.' |
||
836 | diamond | 3311 | |
9105 | hidnplayr | 3312 | |
3313 | cursor_esc dd 27 + ('[' shl 8) |
||
3314 | |||
836 | diamond | 3315 | ; В текущей реализации значения по умолчанию таковы. |
3316 | ; В будущем они, возможно, будут считываться как параметры из ini-файла console.ini. |
||
3317 | con.def_wnd_width dd 80 |
||
3318 | con.def_wnd_height dd 25 |
||
3319 | con.def_scr_width dd 80 |
||
3320 | con.def_scr_height dd 300 |
||
3321 | con.def_wnd_x dd 200 |
||
3322 | con.def_wnd_y dd 50 |
||
3323 | |||
5835 | pavelyakov | 3324 | con.init_cmd db 0 |
3325 | con.title_init_console db "Console",0 |
||
836 | diamond | 3326 | con.vscroll_pt dd -1 |
3327 | |||
3328 | align 16 |
||
3329 | EXPORTS: |
||
3330 | dd szStart, START |
||
9105 | hidnplayr | 3331 | dd szVersion, 0x00020009 |
836 | diamond | 3332 | dd szcon_init, con_init |
3333 | dd szcon_write_asciiz, con_write_asciiz |
||
3686 | hidnplayr | 3334 | dd szcon_write_string, con_write_length |
836 | diamond | 3335 | dd szcon_printf, con_printf |
3336 | dd szcon_exit, con_exit |
||
3337 | dd szcon_get_flags, con_get_flags |
||
3338 | dd szcon_set_flags, con_set_flags |
||
3339 | dd szcon_kbhit, con_kbhit |
||
3340 | dd szcon_getch, con_getch |
||
3341 | dd szcon_getch2, con_getch2 |
||
3342 | dd szcon_gets, con_gets |
||
852 | diamond | 3343 | dd szcon_gets2, con_gets2 |
836 | diamond | 3344 | dd szcon_get_font_height, con_get_font_height |
3345 | dd szcon_get_cursor_height,con_get_cursor_height |
||
3346 | dd szcon_set_cursor_height,con_set_cursor_height |
||
853 | diamond | 3347 | dd szcon_cls, con_cls |
3348 | dd szcon_get_cursor_pos, con_get_cursor_pos |
||
3349 | dd szcon_set_cursor_pos, con_set_cursor_pos |
||
6603 | 0CodErr | 3350 | dd szcon_set_title, con_set_title |
9105 | hidnplayr | 3351 | dd szcon_get_input, con_get_input |
836 | diamond | 3352 | dd 0 |
3353 | |||
9105 | hidnplayr | 3354 | con_flags dd 0x07 ; black on white |
3355 | con_flags_attr dd 0 ; Modifiers (for example, high intensity colors) |
||
836 | diamond | 3356 | con.cursor_height dd (15*font_height+50)/100 |
3357 | con.input_start dd con.input_buffer |
||
3358 | con.input_end dd con.input_buffer |
||
3359 | |||
3360 | con_esc_attr_n dd 0 |
||
3361 | con_esc_attrs dd 0,0,0,0 |
||
3362 | con_esc db 0 |
||
3363 | con_sci db 0 |
||
9105 | hidnplayr | 3364 | con_osc_str rb 256 |
3365 | con_osc_strlen dd 0 |
||
836 | diamond | 3366 | |
3367 | con.entered_char dw -1 |
||
3368 | con.bGetchRequested db 0 |
||
3369 | con.bWasE0 db 0 |
||
3370 | |||
3371 | szStart db 'START',0 |
||
3372 | |||
3373 | szcon_init db 'con_init',0 |
||
3374 | szcon_write_asciiz db 'con_write_asciiz',0 |
||
3686 | hidnplayr | 3375 | szcon_write_string db 'con_write_string',0 |
836 | diamond | 3376 | szcon_printf db 'con_printf',0 |
3377 | szcon_exit db 'con_exit',0 |
||
3378 | szVersion db 'version',0 |
||
3379 | szcon_get_flags db 'con_get_flags',0 |
||
3380 | szcon_set_flags db 'con_set_flags',0 |
||
3381 | szcon_kbhit db 'con_kbhit',0 |
||
3382 | szcon_getch db 'con_getch',0 |
||
3383 | szcon_getch2 db 'con_getch2',0 |
||
3384 | szcon_gets db 'con_gets',0 |
||
852 | diamond | 3385 | szcon_gets2 db 'con_gets2',0 |
836 | diamond | 3386 | szcon_get_font_height db 'con_get_font_height',0 |
3387 | szcon_get_cursor_height db 'con_get_cursor_height',0 |
||
3388 | szcon_set_cursor_height db 'con_set_cursor_height',0 |
||
853 | diamond | 3389 | szcon_cls db 'con_cls',0 |
3390 | szcon_get_cursor_pos db 'con_get_cursor_pos',0 |
||
3391 | szcon_set_cursor_pos db 'con_set_cursor_pos',0 |
||
6603 | 0CodErr | 3392 | szcon_set_title db 'con_set_title',0 |
9105 | hidnplayr | 3393 | szcon_get_input db 'con_get_input',0 |
836 | diamond | 3394 | |
3395 | con.thread_err db 'Cannot create console thread!',13,10,0 |
||
3396 | con.nomem_err db 'Not enough memory!',13,10,0 |
||
3397 | con.aFinished db ' [Finished]',0 |
||
3398 | con.aNull db '(null)',0 |
||
9096 | hidnplayr | 3399 | con.beep db 0x90, 0x3C, 0x00 |
9105 | hidnplayr | 3400 | con.bell db 0x85, 0x25, 0x85, 0x40, 0x00 |
836 | diamond | 3401 | con.ipc_buf dd 0,8,0,0 |
3402 | db 0 |
||
3403 | |||
3404 | section '.data' data readable writable align 16 |
||
3405 | |||
9105 | hidnplayr | 3406 | process_info_buffer process_info |
3407 | |||
836 | diamond | 3408 | con.finished_title rb 256 |
3409 | |||
9105 | hidnplayr | 3410 | con.cur_x dd ? ; Active cursor column (0 based) |
3411 | con.cur_y dd ? ; Active cursor row (0 based) |
||
3412 | con.main_cur_x dd ? ; Saved cursor position for main buffer |
||
3413 | con.main_cur_y dd ? ; Saved cursor position for main buffer |
||
3414 | con.wnd_xpos dd ? ; Active window position in active buffer |
||
3415 | con.wnd_ypos dd ? ; Active window position in active buffer |
||
3416 | con.main_wnd_xpos dd ? ; Saved window position for main buffer |
||
3417 | con.main_wnd_ypos dd ? ; Saved window position for main buffer |
||
3418 | con.scroll_top dd ? ; VT100 scroll region |
||
3419 | con.scroll_bot dd ? ; VT100 scroll region |
||
836 | diamond | 3420 | |
9105 | hidnplayr | 3421 | con.wnd_width dd ? ; window width (= alt buffer width) |
3422 | con.wnd_height dd ? ; window height (= alt buffer height) |
||
3423 | con.main_scr_width dd ? ; main buffer width |
||
3424 | con.main_scr_height dd ? ; main buffer height |
||
3425 | con.scr_width dd ? ; active buffer width |
||
3426 | con.scr_height dd ? ; active buffer height |
||
3427 | con.title dd ? |
||
3428 | con.data dd ? ; active buffer ptr |
||
3429 | con.mainbuffer dd ? |
||
3430 | con.altbuffer dd ? |
||
3431 | con.image dd ? |
||
3432 | con.console_tid dd ? |
||
3433 | con.data_width dw ? ; width in pixels |
||
3434 | con.data_height dw ? ; height in pixels |
||
3435 | con.vscrollbar_size dd ? |
||
3436 | con.vscrollbar_pos dd ? |
||
3437 | con.up_first_time dd ? |
||
3438 | con.down_first_time dd ? |
||
3439 | con.scroll_up_first_time dd ? |
||
3440 | con.scroll_down_first_time dd ? |
||
3441 | con.bUpPressed_saved db ? |
||
3442 | con.bDownPressed_saved db ? |
||
3443 | con.bScrollingUp_saved db ? |
||
3444 | con.bScrollingDown_saved db ? |
||
836 | diamond | 3445 | |
9105 | hidnplayr | 3446 | con.input_buffer rw 128 |
836 | diamond | 3447 | con.input_buffer_end = $ |
3448 | |||
9105 | hidnplayr | 3449 | con.kbd_layout rb 128 |
836 | diamond | 3450 | |
9105 | hidnplayr | 3451 | con.thread_op db ? |
3452 | con.bUpPressed db ? |
||
3453 | con.bDownPressed db ? |
||
3454 | con.bScrollingUp db ? |
||
3455 | con.bScrollingDown db ? |
||
836 | diamond | 3456 | |
3457 | con.stack rb 1024 |
||
3458 | con.stack_top = $ |