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