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