Rev 7431 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7431 | Rev 8560 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;------------------------------------------------------------------------------ |
1 | ;------------------------------------------------------------------------------- |
2 | ; DEBUG BOARD for APPLICATIONS and KERNEL DEVELOPMENT |
2 | ; DEBUG BOARD v1.0.1 for APPLICATIONS and KERNEL DEVELOPMENT |
3 | ; See f63 |
3 | ; See f63 |
4 | ; Compile with FASM for KolibriOS |
4 | ; Compile with FASM for KolibriOS |
5 | ;------------------------------------------------------------------------------ |
5 | ;------------------------------------------------------------------------------- |
6 | use32 |
6 | use32 |
7 | org 0 |
7 | org 0 |
8 | db 'MENUET01' |
8 | db "MENUET01" |
9 | dd 1 |
9 | dd 1 |
10 | dd START |
10 | dd START |
11 | dd I_END |
11 | dd I_END |
12 | dd mem |
12 | dd MEM_END |
13 | dd mem |
13 | dd STACK_TOP |
14 | dd filename |
14 | dd PARAMS_STRING |
15 | dd 0 |
15 | dd 0 |
16 | ;------------------------------------------------------------------------------ |
16 | ;------------------------------------------------------------------------------- |
17 | include 'lang.inc' |
17 | include "lang.inc" |
18 | include '../../../macros.inc' |
18 | include "../../../macros.inc" |
19 | include '../../../debug.inc' |
- | |
20 | purge newline |
- | |
21 | ;SMALL FONT |
- | |
22 | MAXSTRINGS = 45 |
- | |
23 | LINE_H = 10 |
- | |
24 | WINDOW_W = 399 |
- | |
25 | WINDOW_H = MAXSTRINGS*LINE_H+45 |
- | |
26 | FONT_TYPE = 0x40000000 |
- | |
27 | ;BIG FONT |
- | |
28 | ; MAXSTRINGS = 30 |
- | |
29 | ; LINE_H = 15 |
- | |
30 | ; WINDOW_W = 630 |
- | |
31 | ; WINDOW_H = MAXSTRINGS*LINE_H+50 |
- | |
32 | ; FONT_TYPE = 0x50000000 |
- | |
Line -... | Line 19... | ||
- | 19 | ||
- | 20 | purge newline |
|
- | 21 | MAX_STRINGS = 45 |
|
- | 22 | STRING_LENGTH = 80 ;must be a multiple of 4 |
|
- | 23 | LINE_HEIGHT = 16 |
|
- | 24 | WINDOW_W = 60*8+5*2 |
|
- | 25 | WINDOW_W_MIN = 330 |
|
- | 26 | WORK_AREA_H_MIN = 60 |
|
- | 27 | WINDOW_W_PRCNT = 40 |
|
- | 28 | WINDOW_H_PRCNT = 75 |
|
- | 29 | TEXTFIELD_H = MAX_STRINGS*LINE_HEIGHT |
|
33 | 30 | FONT_TYPE = 0x50000000 |
|
34 | ;------------------------------------------------------------------------------ |
31 | ;------------------------------------------------------------------------------- |
35 | START: |
32 | START: |
- | 33 | mcall 68, 11 ;init heap |
|
36 | call CheckUnique |
34 | |
37 | mov edi, filename |
35 | call parse_params_string |
38 | cmp [edi], byte 0 |
36 | test eax, eax |
39 | jnz param |
37 | jnz .no_params |
40 | mov esi, default_filename |
38 | call check_and_fix_params |
41 | @@: |
- | |
42 | lodsb |
39 | |
43 | stosb |
40 | .no_params: |
44 | test al,al |
- | |
45 | jnz @b |
41 | call STATE_handler |
46 | param: |
42 | |
47 | mov ecx, (MAXSTRINGS+1)*20 |
43 | mov ecx, MAX_STRINGS*(STRING_LENGTH/4) |
48 | mov edi, text1 |
44 | mov edi, text1 |
- | 45 | mov eax, " " |
|
49 | mov eax, ' ' |
46 | push ecx |
Line 50... | Line 47... | ||
50 | rep stosd |
47 | rep stosd |
51 | 48 | ||
52 | mov ecx, (MAXSTRINGS+1)*20 |
49 | pop ecx |
Line 53... | Line 50... | ||
53 | mov edi, text2 |
50 | mov edi, text2 |
54 | rep stosd |
51 | rep stosd |
Line 55... | Line 52... | ||
55 | 52 | ||
56 | mov byte [tmp1], 'x' |
53 | cmp [params.daemon_mode], 1 |
- | 54 | je .create_log_file |
|
57 | mov byte [tmp2], 'x' |
55 | |
- | 56 | call calc_window_size |
|
58 | 57 | mov ax, word [xstart+2] |
|
- | 58 | mov [prev_win_x], ax |
|
59 | mcall 14 |
59 | mov ax, word [ystart+2] |
- | 60 | mov [prev_win_y], ax |
|
- | 61 | mov ax, word [xstart] |
|
- | 62 | mov [prev_win_w], ax |
|
- | 63 | mov ax, word [ystart] |
|
- | 64 | mov [prev_win_h], ax |
|
- | 65 | ||
- | 66 | cmp [fullscreen_mode], 0 |
|
60 | and eax, 0xffff0000 |
67 | je @f |
Line -... | Line 68... | ||
- | 68 | call calc_fullscreen_window_size |
|
- | 69 | ||
- | 70 | @@: |
|
- | 71 | mcall 48, 3, sc, sizeof.system_colors |
|
- | 72 | ||
- | 73 | xor eax, eax |
|
- | 74 | mov [vmode], eax |
|
- | 75 | mov dword [text1-4], eax |
|
- | 76 | mov dword [text1-8], eax |
|
- | 77 | mov dword [text2-4], eax |
|
- | 78 | mov dword [text2-8], eax |
|
- | 79 | mov [krnl_cnt], eax |
|
- | 80 | mov [hl_line_count], eax |
|
- | 81 | ||
- | 82 | .create_log_file: |
|
- | 83 | xor eax, eax |
|
- | 84 | mov byte [buffer_length], al |
|
61 | sub eax, WINDOW_W shl 16 |
85 | mov [filepos], eax |
- | 86 | ||
- | 87 | cmp [params.logging_mode], 0 |
|
- | 88 | je @f |
|
- | 89 | ||
62 | add eax, WINDOW_W |
90 | mov esi, [log_filename] |
- | 91 | call create_file |
|
- | 92 | jnc @f |
|
- | 93 | mov esi, default_log_filename |
|
- | 94 | mov [log_filename], default_log_filename |
|
63 | mov [xstart], eax |
95 | call create_file |
- | 96 | ||
64 | mcall 48, 3, sc, sizeof.system_colors |
97 | @@: |
- | 98 | cmp [params.daemon_mode], 0 |
|
- | 99 | je .red |
|
- | 100 | mcall 40, 0 ;set event mask (do not receive any event codes) |
|
- | 101 | ||
- | 102 | .red: |
|
- | 103 | cmp [params.daemon_mode], 1 |
|
- | 104 | je .still |
|
- | 105 | mcall 9, procinfo, -1 ;get info about board process |
|
- | 106 | mov eax, dword [procinfo+42] ;width of board window |
|
- | 107 | mov edx, WINDOW_W_MIN |
|
- | 108 | cmp eax, edx |
|
- | 109 | jae @f |
|
- | 110 | mcall 67, -1, -1, WINDOW_W_MIN, -1 ;resize window |
|
- | 111 | mov dword [procinfo+42], edx |
|
- | 112 | ||
- | 113 | @@: |
|
- | 114 | mcall 48, 4 ; get window header height |
|
- | 115 | mov [window_header_height], eax |
|
- | 116 | mov esi, WORK_AREA_H_MIN |
|
- | 117 | add esi, eax |
|
- | 118 | mov eax, dword [procinfo+46] ;height of board window |
|
- | 119 | cmp eax, esi |
|
65 | 120 | jae @f |
|
66 | mov esi, filename |
- | |
- | 121 | mcall 67, -1, -1, -1 ;resize window |
|
67 | call CreateFile |
122 | mov dword [procinfo+46], esi |
68 | ;------------------------------------------------------------------------------ |
123 | |
- | 124 | @@: |
|
- | 125 | call draw_window |
|
69 | red: |
126 | |
70 | call draw_window |
127 | .still: |
- | 128 | cmp byte [buffer_length], 0 |
|
- | 129 | je @f |
|
- | 130 | cmp [params.logging_mode], 0 |
|
- | 131 | je @f |
|
- | 132 | call write_buffer |
|
- | 133 | ||
71 | ;------------------------------------------------------------------------------ |
134 | @@: |
72 | still: |
135 | cmp [params.daemon_mode], 0 |
73 | cmp [buffer_length], 0 |
136 | je @f |
74 | je @f |
137 | mcall 5, 50 ;pause for 0.5 sec |
Line 75... | Line 138... | ||
75 | call write_buffer |
138 | jmp .read_byte |
76 | @@: |
139 | @@: |
Line 77... | Line 140... | ||
77 | mcall 23, 50 ; wait here for event |
140 | mcall 23, 50 ; wait here for event |
78 | cmp eax, 1 ; redraw request ? |
141 | dec eax ; redraw request ? |
Line 79... | Line 142... | ||
79 | je red |
142 | jz .red |
- | 143 | ||
80 | 144 | dec eax ; key in buffer ? |
|
- | 145 | jz .key |
|
81 | cmp eax, 2 ; key in buffer ? |
146 | |
- | 147 | dec eax ; button in buffer ? |
|
- | 148 | jz .button |
|
- | 149 | ||
- | 150 | .read_byte: |
|
- | 151 | mcall 63, 2 ;read a byte from the debug buffer |
|
- | 152 | cmp ebx, 1 |
|
- | 153 | je .new_data |
|
- | 154 | jne .still |
|
- | 155 | ||
- | 156 | .key: |
|
- | 157 | mcall 2 |
|
- | 158 | cmp ah, " " |
|
- | 159 | jne @f |
|
- | 160 | not [vmode] |
|
- | 161 | and [vmode], 1 |
|
- | 162 | jmp .red |
|
- | 163 | @@: |
|
- | 164 | cmp ah, 51 ; F2 |
|
- | 165 | je .open_boardlog |
|
- | 166 | cmp ah, 0x1B ;[Esc]? |
|
- | 167 | je terminate_board |
|
- | 168 | cmp ah, 0x44 ;[F11]? |
|
- | 169 | jne .still |
|
- | 170 | cmp [fullscreen_mode], 0 |
|
- | 171 | jne @f |
|
- | 172 | mov [fullscreen_mode], 1 |
|
- | 173 | mcall 9, procinfo, -1 ;get info about process |
|
- | 174 | mov ax, word [ebx+34] |
|
- | 175 | mov [prev_win_x], ax |
|
- | 176 | mov ax, word [ebx+38] |
|
- | 177 | mov [prev_win_y], ax |
|
- | 178 | mov ax, word [ebx+42] |
|
- | 179 | mov [prev_win_w], ax |
|
- | 180 | mov ax, word [ebx+46] |
|
- | 181 | mov [prev_win_h], ax |
|
- | 182 | call calc_fullscreen_window_size |
|
- | 183 | movzx ebx, word [xstart+2] |
|
- | 184 | movzx ecx, word [ystart+2] |
|
- | 185 | movzx edx, word [xstart] |
|
- | 186 | movzx esi, word [ystart] |
|
- | 187 | mcall 67 ;change window size & position |
|
- | 188 | jmp .still |
|
- | 189 | ||
- | 190 | @@: |
|
- | 191 | mov [fullscreen_mode], 0 |
|
- | 192 | mcall 71, 2, title, 1 ;set window caption |
|
- | 193 | mcall 18, 25, 2, -1, 0 ;set window position (usual) |
|
- | 194 | mov [already_on_top], 0 |
|
- | 195 | movzx ebx, word [prev_win_x] |
|
- | 196 | movzx ecx, word [prev_win_y] |
|
- | 197 | movzx edx, word [prev_win_w] |
|
- | 198 | movzx esi, word [prev_win_h] |
|
- | 199 | mcall 67 ;change window size & position |
|
- | 200 | ||
- | 201 | @@: |
|
- | 202 | jmp .still |
|
- | 203 | ||
- | 204 | .open_boardlog: |
|
- | 205 | mov eax, [log_filename] |
|
- | 206 | mov [open_log_in_tinypad+8], eax |
|
- | 207 | mcall 70, open_log_in_tinypad |
|
- | 208 | jmp .red |
|
- | 209 | ||
- | 210 | .button: |
|
- | 211 | mcall 17 ; get id |
|
- | 212 | cmp ah, 1 ; button id=1 ? |
|
- | 213 | jne .button.noclose |
|
- | 214 | ||
- | 215 | .exit: |
|
- | 216 | jmp terminate_board |
|
- | 217 | .button.noclose: |
|
- | 218 | cmp ah, 3 |
|
- | 219 | jne @f |
|
Line 82... | Line 220... | ||
82 | je key |
220 | mov [vmode], 0 |
83 | 221 | jmp .red |
|
84 | cmp eax, 3 ; button in buffer ? |
222 | @@: |
- | 223 | cmp ah, 4 |
|
- | 224 | jne @f |
|
85 | je button |
225 | mov [vmode], 1 |
- | 226 | @@: |
|
86 | 227 | jmp .red |
|
87 | mcall 63, 2 |
228 | |
88 | cmp ebx, 1 |
229 | .new_data: |
89 | jne still |
230 | cmp byte [buffer_length], 255 |
- | 231 | jne @f |
|
- | 232 | cmp [params.logging_mode], 0 |
|
90 | 233 | je @f |
|
91 | new_data: |
234 | call write_buffer |
92 | cmp [buffer_length], 255 |
235 | |
93 | jne @f |
236 | @@: |
94 | call write_buffer |
237 | movzx ebx, byte [buffer_length] |
95 | @@: |
238 | mov [ebx+tmp], al |
96 | movzx ebx, byte[buffer_length] |
- | |
97 | mov [ebx+tmp], al |
- | |
98 | inc [buffer_length] |
- | |
99 | mov ebp, [targ] |
- | |
100 | cmp al, 10 |
- | |
101 | jz new_line |
- | |
102 | cmp al, 13 |
- | |
103 | jz new_check |
- | |
104 | jmp char |
- | |
105 | ;------------------------------------------ |
- | |
106 | write_buffer: |
- | |
107 | pusha |
- | |
108 | mov edx, tmp |
- | |
109 | movzx ecx, byte[buffer_length] |
- | |
110 | mov esi, filename |
239 | inc byte [buffer_length] |
111 | .write_to_logfile: |
- | |
112 | call WriteToFile |
- | |
113 | cmp eax, 5 |
- | |
114 | jne @f |
- | |
115 | mov esi, filename |
- | |
116 | mov [filepos], 0 |
- | |
117 | call CreateFile |
- | |
118 | jnc .write_to_logfile |
240 | cmp [params.daemon_mode], 1 |
119 | @@: |
241 | je .read_byte |
120 | movzx eax,byte[buffer_length] |
242 | mov ebp, [targ] |
121 | add [filepos],eax |
243 | cmp al, 10 |
122 | xor eax,eax |
244 | jz .new_line |
123 | mov [buffer_length],al |
245 | cmp al, 13 |
124 | popa |
246 | jz .new_check |
125 | ret |
247 | jmp .char |
126 | ;------------------------------------------ |
248 | |
127 | new_line: |
249 | .new_line: |
128 | and [ebp-8], dword 0 |
250 | and [ebp-8], dword 0 |
Line 129... | Line 251... | ||
129 | inc dword [ebp-4] |
251 | inc dword [ebp-4] |
130 | cmp [ebp-4], dword MAXSTRINGS |
252 | cmp [ebp-4], dword MAX_STRINGS |
131 | jbe .noypos |
253 | jb .noypos |
132 | mov [ebp-4], dword MAXSTRINGS |
254 | mov [ebp-4], dword MAX_STRINGS-1 |
133 | lea esi, [ebp+80] |
255 | lea esi, [ebp+STRING_LENGTH] |
134 | mov edi, ebp |
256 | mov edi, ebp |
135 | mov ecx, 20*(MAXSTRINGS) |
257 | mov ecx, (MAX_STRINGS-1)*(STRING_LENGTH/4) |
- | 258 | cld |
|
136 | cld |
259 | rep movsd |
137 | rep movsd |
260 | |
138 | 261 | mov esi, [ebp-4] |
|
139 | mov esi, [ebp-4] |
262 | imul esi, STRING_LENGTH |
140 | imul esi, 80 |
- | |
- | 263 | add esi, [ebp-8] |
|
141 | add esi, [ebp-8] |
264 | add esi, ebp |
142 | add esi, ebp |
265 | mov ecx, STRING_LENGTH/4 |
143 | mov ecx, 20 |
266 | mov eax, " " |
144 | mov eax, ' ' |
267 | rep stosd |
145 | rep stosd |
268 | |
146 | .noypos: |
269 | .noypos: |
147 | mov [targ],text2 |
270 | mov [targ], text1 |
148 | and [krnl_cnt],0 |
271 | and [krnl_cnt], 0 |
149 | jmp new_check |
272 | jmp .new_check |
150 | ;------------------------------------------ |
273 | |
151 | char: |
274 | .char: |
152 | cmp ebp, text1 |
275 | cmp ebp, text2 |
153 | je add2 |
276 | je .add2 |
154 | mov ecx, [krnl_cnt] |
277 | mov ecx, [krnl_cnt] |
155 | cmp al, [krnl_msg+ecx] |
278 | cmp al, [krnl_msg+ecx] |
156 | jne .noknl |
279 | jne .nokrnl |
Line 168... | Line 291... | ||
168 | call add_char |
291 | call add_char |
169 | loop .l1 |
292 | loop .l1 |
170 | pop eax |
293 | pop eax |
171 | .add: |
294 | .add: |
172 | and [krnl_cnt], 0 |
295 | and [krnl_cnt], 0 |
173 | add2: |
296 | .add2: |
174 | call add_char |
297 | call add_char |
Line 175... | Line 298... | ||
175 | 298 | ||
176 | new_check: |
299 | .new_check: |
177 | mcall 63, 2 |
300 | mcall 63, 2 ;read a byte from the debug buffer |
178 | cmp ebx, 1 |
301 | cmp ebx, 1 |
- | 302 | je .new_data |
|
- | 303 | ||
- | 304 | cmp [params.daemon_mode], 1 |
|
179 | je new_data |
305 | je .still |
180 | call draw_text |
- | |
181 | jmp still |
- | |
182 | ;------------------------------------------------------------------------------ |
- | |
183 | key: |
- | |
184 | mcall 2 |
- | |
185 | cmp ah, ' ' |
- | |
186 | je button.noclose |
- | |
187 | cmp ah, 51 ; F2 |
- | |
188 | je open_boardlog |
- | |
189 | jmp still |
- | |
190 | open_boardlog: |
- | |
191 | mcall 70, open_log_in_tinypad |
- | |
Line -... | Line 306... | ||
- | 306 | call draw_text |
|
192 | jmp red |
307 | |
193 | 308 | jmp .still |
|
194 | ;------------------------------------------------------------------------------ |
- | |
195 | button: |
- | |
196 | mcall 17 ; get id |
- | |
197 | cmp ah, 1 ; button id=1 ? |
- | |
198 | jne .noclose |
- | |
199 | or eax, -1 ; close this program |
- | |
200 | mcall |
- | |
201 | .noclose: |
- | |
202 | xor [vmode], 1 |
309 | ;------------------------------------------------------------------------------- |
203 | jmp red |
310 | |
204 | ;------------------------------------------------------------------------------ |
311 | ;------------------------------------------------------------------------------ |
205 | add_char: |
312 | add_char: |
206 | push esi |
313 | push esi |
207 | mov esi, [ebp-4] |
314 | mov esi, [ebp-4] |
208 | imul esi, 80 |
315 | imul esi, STRING_LENGTH |
- | 316 | add esi, [ebp-8] |
|
- | 317 | mov [ebp+esi], al |
|
209 | add esi, [ebp-8] |
318 | cmp dword [ebp-8], STRING_LENGTH-1 |
210 | mov [ebp+esi], al |
- | |
211 | inc dword[ebp-8] |
- | |
212 | cmp dword[ebp-8], 80 |
- | |
213 | jb .ok |
319 | je .ok |
214 | mov dword[ebp-8], 79 |
320 | inc dword [ebp-8] |
215 | .ok: |
321 | .ok: |
- | 322 | pop esi |
|
Line -... | Line 323... | ||
- | 323 | ret |
|
- | 324 | ;------------------------------------------------------------------------------- |
|
- | 325 | ||
- | 326 | calc_fullscreen_window_size: |
|
- | 327 | ;------------------------------------------------------------------------------- |
|
- | 328 | push eax |
|
- | 329 | ||
- | 330 | mcall 14 ;get screen size |
|
- | 331 | ; inc ax |
|
- | 332 | mov word [ystart], ax |
|
- | 333 | shr eax, 16 |
|
- | 334 | ; inc ax |
|
- | 335 | mov word [xstart], ax |
|
- | 336 | xor eax, eax |
|
- | 337 | mov word [xstart+2], ax |
|
- | 338 | mov word [ystart+2], ax |
|
- | 339 | ||
- | 340 | pop eax |
|
- | 341 | ret |
|
- | 342 | ;------------------------------------------------------------------------------- |
|
- | 343 | ||
- | 344 | calc_window_size: |
|
- | 345 | ;------------------------------------------------------------------------------- |
|
- | 346 | pusha |
|
- | 347 | ||
- | 348 | mcall 48, 5 ;get screen working area size |
|
- | 349 | mov [ystart], ebx |
|
- | 350 | ror eax, 16 |
|
- | 351 | ror ebx, 16 |
|
- | 352 | mov [xstart], eax |
|
- | 353 | movzx ecx, ax |
|
- | 354 | movzx edx, bx |
|
- | 355 | shr eax, 16 |
|
- | 356 | shr ebx, 16 |
|
- | 357 | sub eax, ecx |
|
- | 358 | sub ebx, edx |
|
- | 359 | inc eax |
|
- | 360 | inc ebx |
|
- | 361 | ||
- | 362 | mov ecx, 100 |
|
- | 363 | mov edx, WINDOW_W_PRCNT |
|
- | 364 | mul edx |
|
- | 365 | xor edx, edx |
|
- | 366 | div ecx |
|
- | 367 | cmp ax, WINDOW_W_MIN |
|
- | 368 | jae @f |
|
- | 369 | mov ax, WINDOW_W_MIN |
|
- | 370 | @@: |
|
- | 371 | mov word [xstart], ax |
|
- | 372 | sub word [xstart+2], ax |
|
- | 373 | mov eax, ebx |
|
- | 374 | mov edx, WINDOW_H_PRCNT |
|
- | 375 | mul edx |
|
- | 376 | xor edx, edx |
|
- | 377 | div ecx |
|
- | 378 | mov dx, ax |
|
- | 379 | mov cx, WORK_AREA_H_MIN |
|
- | 380 | mcall 48, 4 ; get window header height |
|
- | 381 | add ax, cx |
|
- | 382 | cmp dx, ax |
|
- | 383 | jae @f |
|
- | 384 | mov dx, ax |
|
- | 385 | @@: |
|
- | 386 | mov word [ystart], dx |
|
- | 387 | ||
- | 388 | popa |
|
- | 389 | ret |
|
- | 390 | ;------------------------------------------------------------------------------- |
|
- | 391 | ||
- | 392 | ;------------------------------------------------------------------------------- |
|
- | 393 | write_buffer: |
|
- | 394 | pusha |
|
- | 395 | ||
- | 396 | mov edx, tmp |
|
- | 397 | movzx ecx, byte [buffer_length] |
|
- | 398 | mov esi, [log_filename] |
|
- | 399 | mov ebx, ecx |
|
- | 400 | ||
- | 401 | .write_to_logfile: |
|
- | 402 | call write_to_file |
|
- | 403 | cmp eax, 5 |
|
- | 404 | jne @f |
|
- | 405 | mov esi, [log_filename] |
|
- | 406 | mov [filepos], 0 |
|
- | 407 | call create_file |
|
- | 408 | jnc .write_to_logfile |
|
- | 409 | ; mov [params.logging_mode], 0 |
|
- | 410 | jmp .ret |
|
- | 411 | @@: |
|
- | 412 | add [filepos], ebx |
|
- | 413 | xor eax, eax |
|
- | 414 | mov byte [buffer_length], al |
|
- | 415 | ||
- | 416 | .ret: |
|
- | 417 | popa |
|
- | 418 | ret |
|
- | 419 | ;------------------------------------------------------------------------------- |
|
- | 420 | ||
- | 421 | ;------------------------------------------------------------------------------- |
|
- | 422 | parse_params_string: |
|
- | 423 | ;result: eax = 0 (OK), eax = -1 (no params string), -2 (wrong params string) |
|
- | 424 | xor eax, eax |
|
- | 425 | pusha |
|
- | 426 | ||
- | 427 | mov esi, PARAMS_STRING |
|
- | 428 | mov ecx, 256 |
|
- | 429 | ||
- | 430 | cmp byte [esi], 0 |
|
- | 431 | je .no_params_string |
|
- | 432 | ||
- | 433 | @@: |
|
- | 434 | call skip_spaces |
|
- | 435 | call check_param |
|
- | 436 | inc eax |
|
- | 437 | jz .no_params_string |
|
- | 438 | inc eax |
|
- | 439 | jz .wrong_params_string |
|
- | 440 | cmp byte [esi], 0 |
|
- | 441 | je .ok |
|
- | 442 | loop @b |
|
- | 443 | ||
- | 444 | .ok: |
|
- | 445 | popa |
|
- | 446 | ||
- | 447 | ret |
|
- | 448 | ||
- | 449 | .no_params_string: |
|
- | 450 | popa |
|
- | 451 | ||
- | 452 | dec eax |
|
- | 453 | ||
- | 454 | ret |
|
- | 455 | ||
- | 456 | .wrong_params_string: |
|
- | 457 | popa |
|
- | 458 | ||
- | 459 | dec eax |
|
- | 460 | dec eax |
|
- | 461 | ||
- | 462 | ret |
|
216 | pop esi |
463 | |
- | 464 | ;------------------------------------------------------------------------------- |
|
- | 465 | ||
- | 466 | ;------------------------------------------------------------------------------- |
|
- | 467 | skip_spaces: |
|
- | 468 | push eax |
|
- | 469 | cld |
|
- | 470 | .0: |
|
- | 471 | lodsb |
|
- | 472 | cmp al, " " |
|
- | 473 | je @f |
|
- | 474 | cmp al, 9 ;skip tabs too |
|
- | 475 | jne .ret |
|
- | 476 | @@: |
|
- | 477 | loop .0 |
|
- | 478 | ||
- | 479 | .ret: |
|
- | 480 | dec esi |
|
- | 481 | ||
- | 482 | pop eax |
|
- | 483 | ret |
|
- | 484 | ;------------------------------------------------------------------------------- |
|
- | 485 | ||
- | 486 | ;------------------------------------------------------------------------------- |
|
- | 487 | check_param: |
|
- | 488 | push ebx |
|
- | 489 | ||
- | 490 | test ecx, ecx |
|
- | 491 | jz .empty |
|
- | 492 | ||
- | 493 | cld |
|
- | 494 | lodsb |
|
- | 495 | test al, al |
|
- | 496 | jnz @f |
|
- | 497 | dec esi |
|
- | 498 | jmp .empty |
|
- | 499 | ||
- | 500 | @@: |
|
- | 501 | cmp al, "-" |
|
- | 502 | jne .not_option |
|
- | 503 | dec ecx |
|
- | 504 | lodsb |
|
- | 505 | test al, al |
|
- | 506 | jz .wrong_option |
|
- | 507 | cmp al, " " |
|
- | 508 | je .wrong_option |
|
- | 509 | cmp al, 9 |
|
- | 510 | je .wrong_option |
|
- | 511 | ||
- | 512 | dec esi |
|
- | 513 | call check_option |
|
- | 514 | inc eax |
|
- | 515 | jnz .ok |
|
- | 516 | ||
- | 517 | .wrong_option: |
|
- | 518 | lea esi, [esi-2] |
|
- | 519 | jmp .wrong |
|
- | 520 | ||
- | 521 | .not_option: |
|
- | 522 | cmp [params.log_filename_found], 1 |
|
- | 523 | je .wrong |
|
- | 524 | mov [params.log_filename], esi |
|
- | 525 | cmp al, '"' |
|
- | 526 | je .quoted |
|
- | 527 | dec [params.log_filename] |
|
- | 528 | xor ebx, ebx |
|
- | 529 | inc ebx |
|
- | 530 | dec ecx |
|
- | 531 | ||
- | 532 | @@: |
|
- | 533 | lodsb |
|
- | 534 | test al, al |
|
- | 535 | jz @f |
|
- | 536 | cmp al, " " |
|
- | 537 | je @f |
|
- | 538 | cmp al, 9 |
|
- | 539 | je @f |
|
- | 540 | inc ebx |
|
- | 541 | loop @b |
|
- | 542 | dec ebx |
|
- | 543 | ||
- | 544 | @@: |
|
- | 545 | dec esi |
|
- | 546 | mov [params.log_filename_found], 1 |
|
- | 547 | mov [params.log_filename.size], ebx |
|
- | 548 | jmp .ok |
|
- | 549 | ||
- | 550 | .quoted: |
|
- | 551 | xor ebx, ebx |
|
- | 552 | dec ecx |
|
- | 553 | .quoted.0: |
|
- | 554 | lodsb |
|
- | 555 | test al, al |
|
- | 556 | jnz @f |
|
- | 557 | lea ecx, [ecx+ebx+1] |
|
- | 558 | lea esi, [esi-2] |
|
- | 559 | sub esi, ebx |
|
- | 560 | jmp .wrong |
|
- | 561 | @@: |
|
- | 562 | cmp al, '"' |
|
- | 563 | je @f |
|
- | 564 | inc ebx |
|
- | 565 | loop .quoted.0 |
|
- | 566 | lea ecx, [ecx+ebx+1] |
|
- | 567 | lea esi, [esi-2] |
|
- | 568 | sub esi, ebx |
|
- | 569 | jmp .wrong |
|
- | 570 | ||
- | 571 | @@: |
|
- | 572 | mov al, byte [esi] |
|
- | 573 | test al, al |
|
- | 574 | jz @f |
|
- | 575 | cmp al, " " |
|
- | 576 | je @f |
|
- | 577 | cmp al, 9 |
|
- | 578 | jne .wrong ;there must be spaces or null after closing (final) quote mark |
|
- | 579 | @@: |
|
- | 580 | mov [params.log_filename_found], 1 |
|
- | 581 | mov [params.log_filename.size], ebx |
|
- | 582 | ||
- | 583 | ||
- | 584 | .ok: |
|
- | 585 | xor eax, eax |
|
- | 586 | ||
- | 587 | pop ebx |
|
- | 588 | ret |
|
- | 589 | ||
- | 590 | .empty: |
|
- | 591 | xor eax, eax |
|
- | 592 | dec eax |
|
- | 593 | ||
- | 594 | pop ebx |
|
- | 595 | ret |
|
- | 596 | ||
- | 597 | .wrong: |
|
- | 598 | xor eax, eax |
|
- | 599 | dec eax |
|
- | 600 | dec eax |
|
- | 601 | ||
- | 602 | pop ebx |
|
- | 603 | ret |
|
- | 604 | ;------------------------------------------------------------------------------- |
|
- | 605 | ||
- | 606 | ;------------------------------------------------------------------------------- |
|
- | 607 | check_option: |
|
- | 608 | push ebx edi |
|
- | 609 | lea ebx, [esi-1] |
|
- | 610 | cmp byte [esi], "-" |
|
- | 611 | je .long_option |
|
- | 612 | ||
- | 613 | cld |
|
- | 614 | @@: |
|
- | 615 | lodsb |
|
- | 616 | test al, al |
|
- | 617 | jz .ok |
|
- | 618 | cmp al, " " |
|
- | 619 | je .ok |
|
- | 620 | cmp al, 9 |
|
- | 621 | je .ok |
|
- | 622 | call .subcheck |
|
- | 623 | test eax, eax |
|
- | 624 | jz .wrong |
|
- | 625 | loop @b |
|
- | 626 | ||
- | 627 | .subcheck: |
|
- | 628 | cmp al, "d" |
|
- | 629 | jne @f |
|
- | 630 | mov [params.daemon_mode], 1 |
|
- | 631 | ret |
|
- | 632 | ||
- | 633 | @@: |
|
- | 634 | cmp al, "s" |
|
- | 635 | jne @f |
|
- | 636 | mov [params.stop_daemon_flag], 1 |
|
- | 637 | ret |
|
- | 638 | ||
- | 639 | @@: |
|
- | 640 | cmp al, "n" |
|
- | 641 | jne @f |
|
- | 642 | mov [params.logging_mode], 0 |
|
- | 643 | ret |
|
- | 644 | ||
- | 645 | @@: |
|
- | 646 | cmp al, "r" |
|
- | 647 | jne @f |
|
- | 648 | mov [params.rewrite_log_flag], 1 |
|
- | 649 | ret |
|
- | 650 | ||
- | 651 | @@: |
|
- | 652 | cmp al, "f" |
|
- | 653 | jne @f |
|
- | 654 | mov [fullscreen_mode], 1 |
|
- | 655 | ret |
|
- | 656 | ||
- | 657 | ||
- | 658 | ||
- | 659 | ||
- | 660 | @@: |
|
- | 661 | xor eax, eax |
|
- | 662 | ret |
|
- | 663 | ||
- | 664 | ||
- | 665 | .long_option: |
|
- | 666 | lodsb |
|
- | 667 | dec ecx |
|
- | 668 | jz .wrong |
|
- | 669 | mov edi, esi |
|
- | 670 | push esi |
|
- | 671 | cmp ecx, params.options.d.size-1 |
|
- | 672 | jl @f |
|
- | 673 | mov esi, params.options.d |
|
- | 674 | call cmp_str |
|
- | 675 | jnz @f |
|
- | 676 | pop esi |
|
- | 677 | lea ecx, [ecx-params.options.d.size-1] |
|
- | 678 | lea esi, [esi+params.options.d.size-1] |
|
- | 679 | mov [params.daemon_mode], 1 |
|
- | 680 | jmp .long_option.0 |
|
- | 681 | ||
- | 682 | @@: |
|
- | 683 | cmp ecx, params.options.s.size-1 |
|
- | 684 | jl @f |
|
- | 685 | mov esi, params.options.s |
|
- | 686 | call cmp_str |
|
- | 687 | jnz @f |
|
- | 688 | pop esi |
|
- | 689 | lea ecx, [ecx-params.options.s.size-1] |
|
- | 690 | lea esi, [esi+params.options.s.size-1] |
|
- | 691 | mov [params.stop_daemon_flag], 1 |
|
- | 692 | jmp .long_option.0 |
|
- | 693 | ||
- | 694 | @@: |
|
- | 695 | cmp ecx, params.options.n.size-1 |
|
- | 696 | jl @f |
|
- | 697 | mov esi, params.options.n |
|
- | 698 | call cmp_str |
|
- | 699 | jnz @f |
|
- | 700 | pop esi |
|
- | 701 | lea ecx, [ecx-params.options.n.size-1] |
|
- | 702 | lea esi, [esi+params.options.n.size-1] |
|
- | 703 | mov [params.logging_mode], 0 |
|
- | 704 | jmp .long_option.0 |
|
- | 705 | ||
- | 706 | @@: |
|
- | 707 | cmp ecx, params.options.r.size-1 |
|
- | 708 | jl @f |
|
- | 709 | mov esi, params.options.r |
|
- | 710 | call cmp_str |
|
- | 711 | jnz @f |
|
- | 712 | pop esi |
|
- | 713 | lea ecx, [ecx-params.options.r.size-1] |
|
- | 714 | lea esi, [esi+params.options.r.size-1] |
|
- | 715 | mov [params.rewrite_log_flag], 1 |
|
- | 716 | jmp .long_option.0 |
|
- | 717 | ||
- | 718 | @@: |
|
- | 719 | cmp ecx, params.options.f.size-1 |
|
- | 720 | jl @f |
|
- | 721 | mov esi, params.options.f |
|
- | 722 | call cmp_str |
|
- | 723 | jnz @f |
|
- | 724 | pop esi |
|
- | 725 | lea ecx, [ecx-params.options.f.size-1] |
|
- | 726 | lea esi, [esi+params.options.f.size-1] |
|
- | 727 | mov [fullscreen_mode], 1 |
|
- | 728 | jmp .long_option.0 |
|
- | 729 | ||
- | 730 | @@: |
|
- | 731 | pop esi |
|
- | 732 | jmp .wrong |
|
- | 733 | ||
- | 734 | .long_option.0: |
|
- | 735 | mov al, byte [esi] |
|
- | 736 | test al, al |
|
- | 737 | jz @f |
|
- | 738 | cmp al, " " |
|
- | 739 | je @f |
|
- | 740 | cmp al, 9 |
|
- | 741 | jne .wrong ;there must be spaces or null after long option |
|
- | 742 | @@: |
|
- | 743 | inc esi |
|
- | 744 | ||
- | 745 | .ok: |
|
- | 746 | dec esi |
|
- | 747 | xor eax, eax |
|
- | 748 | ||
- | 749 | pop edi ebx |
|
- | 750 | ret |
|
- | 751 | ||
- | 752 | .wrong: |
|
- | 753 | xor eax, eax |
|
- | 754 | dec eax |
|
- | 755 | pop edi esi |
|
- | 756 | ret |
|
- | 757 | ;------------------------------------------------------------------------------- |
|
- | 758 | ||
- | 759 | check_and_fix_params: |
|
- | 760 | ;------------------------------------------------------------------------------- |
|
- | 761 | push eax |
|
- | 762 | ||
- | 763 | cmp [params.daemon_mode], 1 |
|
- | 764 | jne @f |
|
- | 765 | mov [params.stop_daemon_flag], 0 |
|
- | 766 | mov [params.logging_mode], 1 |
|
- | 767 | ||
- | 768 | @@: |
|
- | 769 | mov eax, [params.log_filename] |
|
- | 770 | test eax, eax |
|
- | 771 | jz @f |
|
- | 772 | mov [log_filename], eax |
|
- | 773 | add ebx, [params.log_filename.size] |
|
- | 774 | mov byte [eax+ebx], 0 |
|
- | 775 | ||
- | 776 | @@: |
|
- | 777 | pop eax |
|
- | 778 | ret |
|
217 | ret |
779 | ;------------------------------------------------------------------------------- |
218 | 780 | ||
219 | ;------------------------------------------------------------------------------ |
781 | ;------------------------------------------------------------------------------- |
220 | ;************************ WINDOW DEFINITIONS AND DRAW ************************ |
782 | ;************************ WINDOW DEFINITIONS AND DRAW ************************ |
221 | ;------------------------------------------------------------------------------ |
- | |
222 | draw_window: |
783 | ;------------------------------------------------------------------------------- |
223 | mcall 12, 1 ; 1, start of draw |
784 | draw_window: |
224 | mcall 48, 5 ; GetClientTop |
785 | mcall 12, 1 ; start of draw |
- | 786 | xor edx, edx |
|
225 | shr ebx, 16 |
787 | mov dl, 0x13 |
- | 788 | cmp [fullscreen_mode], 0 |
|
- | 789 | je @f |
|
226 | mov ecx, ebx |
790 | mov dl, 1 ;set fullscreen mode window |
227 | shl ecx, 16 |
791 | |
228 | add ecx, WINDOW_H ; [y start] *65536 + [y size] |
792 | @@: |
229 | mov edx, 0xffffff |
793 | shl edx, 24 |
- | 794 | or edx, 0xFFFFFF |
|
- | 795 | xor esi, esi |
|
- | 796 | mcall 0,[xstart],[ystart],,,title |
|
- | 797 | ||
- | 798 | cmp [fullscreen_mode], 0 |
|
- | 799 | je .l0 |
|
- | 800 | ||
- | 801 | cmp [already_on_top], 1 |
|
- | 802 | je @f |
|
- | 803 | mcall 18, 25, 2, -1, 1 ;set window position (always on top) |
|
- | 804 | mov [already_on_top], 1 |
|
- | 805 | ||
- | 806 | @@: |
|
230 | or edx, 0x14000000 |
807 | mcall 13, [xstart], [ystart], 0xFFFFFF ;draw a rectangle (fill the window) |
- | 808 | ||
- | 809 | .l0: |
|
- | 810 | mov ebx, 15 shl 16+(8*4+5) |
|
- | 811 | xor ecx, ecx |
|
- | 812 | cmp [fullscreen_mode], 1 |
|
- | 813 | je @f |
|
- | 814 | mov ecx, [window_header_height] |
|
- | 815 | ||
- | 816 | @@: |
|
231 | xor esi, esi |
817 | add ecx, 5 |
- | 818 | shl ecx, 16 |
|
- | 819 | mov cx, LINE_HEIGHT+5 |
|
- | 820 | mov eax, [sc.work_button] |
|
- | 821 | cmp [vmode], 0 |
|
232 | mcall 0,[xstart],,,,title |
822 | jne @f |
233 | mov ebx, 296 shl 16+31 |
823 | call lighten_color ;make button lighter if it's active |
- | 824 | @@: |
|
- | 825 | mov esi, eax |
|
- | 826 | mcall 8,,,3 ;'User' button |
|
- | 827 | ||
- | 828 | push ebx ecx |
|
- | 829 | ||
- | 830 | shr ecx, 16 |
|
- | 831 | mov bx, cx |
|
- | 832 | rol ebx, 16 |
|
234 | mcall 8,,<4,13>,3,[sc.work_button] |
833 | add bx, 3 |
235 | mov edx, [vmode] |
834 | ror ebx, 16 |
236 | lea edx, [edx*4+duk] |
835 | add bx, 4 |
237 | mov ecx, 0x80 |
836 | mov ecx, 0x90 |
- | 837 | shl ecx, 24 |
|
- | 838 | add ecx, [sc.work_button_text] |
|
- | 839 | mcall 4,,, u_button_text |
|
- | 840 | cmp [vmode], 0 |
|
- | 841 | jne @f |
|
- | 842 | add ebx, 1 shl 16 |
|
- | 843 | mcall ;make text bolder if the button is active |
|
- | 844 | ||
- | 845 | @@: |
|
- | 846 | pop ecx ebx |
|
- | 847 | ||
- | 848 | add ebx, (8*4+10) shl 16 |
|
- | 849 | mov bx, (8*6+5+5) |
|
- | 850 | mov eax, [sc.work_button] |
|
- | 851 | cmp [vmode], 1 |
|
- | 852 | jne @f |
|
- | 853 | call lighten_color ;make button lighter if it's active |
|
- | 854 | @@: |
|
- | 855 | mov esi, eax |
|
- | 856 | mcall 8,,,4 ;'Kernel' button |
|
- | 857 | ||
- | 858 | shr ecx, 16 |
|
- | 859 | mov bx, cx |
|
- | 860 | rol ebx, 16 |
|
- | 861 | add bx, 3 |
|
- | 862 | ror ebx, 16 |
|
- | 863 | add bx, 4 |
|
- | 864 | mov ecx, 0x90 |
|
- | 865 | shl ecx, 24 |
|
- | 866 | add ecx, [sc.work_button_text] |
|
- | 867 | mcall 4,,, k_button_text |
|
- | 868 | cmp [vmode], 1 |
|
- | 869 | jne @f |
|
- | 870 | add ebx, 1 shl 16 |
|
238 | shr ecx, 24 |
871 | mcall ;make text bolder if the button is active |
239 | add ecx, [sc.work_button_text] |
872 | |
240 | mcall 4,<300,7>,,,4 |
873 | @@: |
241 | call draw_text |
874 | call draw_text |
- | 875 | mcall 12, 2 ; 2, end of draw |
|
- | 876 | ret |
|
242 | mcall 12, 2 ; 2, end of draw |
877 | ;------------------------------------------------------------------------------- |
243 | ret |
878 | |
244 | ;------------------------------------------------------------------------------ |
879 | ;------------------------------------------------------------------------------- |
245 | draw_text: |
880 | draw_text: |
- | 881 | mov ebx, 15 shl 16 + 0 |
|
246 | mov ebx, 15*65536+30 ; draw info text with function 4 |
882 | xor bx, bx |
- | 883 | cmp [fullscreen_mode], 1 |
|
- | 884 | je @f |
|
247 | xor ecx, ecx |
885 | mov bx, word [window_header_height] |
248 | or ecx, FONT_TYPE |
886 | |
249 | mov edi, 0xffffff |
887 | @@: |
250 | mov edx, text1 |
888 | add bx, 5+(LINE_HEIGHT+5)+5 ;space between window header and textfield |
- | 889 | mov ecx, FONT_TYPE |
|
- | 890 | mov edi, 0xFFFFFF |
|
- | 891 | mov edx, text2 |
|
251 | cmp [vmode], 0 |
892 | cmp [vmode], 1 |
252 | je .kern |
893 | je .kern |
- | 894 | mov edx, text1 |
|
- | 895 | .kern: |
|
- | 896 | push ebx edx |
|
253 | mov edx, text2 |
897 | |
254 | .kern: |
898 | |
255 | push ebx ecx edx |
899 | |
256 | mcall 9, procinfo,-1 |
900 | mov eax, dword [procinfo+42] ;x-size of board window |
257 | mov eax, [ebx+42] |
901 | sub eax, 15*2 |
- | 902 | xor edx, edx |
|
- | 903 | mov ebx, 8 |
|
258 | xor edx, edx |
904 | div ebx |
- | 905 | ||
- | 906 | @@: |
|
- | 907 | cmp [vmode], 1 |
|
- | 908 | jne @f |
|
259 | mov ebx, 6 |
909 | add eax, 4 |
260 | div ebx |
910 | |
261 | pop edx ecx ebx |
911 | @@: |
262 | mov esi, 80 |
912 | mov esi, STRING_LENGTH |
- | 913 | cmp eax, esi |
|
263 | cmp eax, esi |
914 | ja @f |
- | 915 | mov esi, eax |
|
264 | ja @f |
916 | |
- | 917 | @@: |
|
- | 918 | mov eax, dword [procinfo+46] ;y-size of board window |
|
- | 919 | cmp [fullscreen_mode], 1 |
|
- | 920 | je @f |
|
- | 921 | sub eax, [window_header_height] |
|
- | 922 | ||
- | 923 | @@: |
|
- | 924 | sub eax, 5+(LINE_HEIGHT+5)+5+5 |
|
- | 925 | xor edx, edx |
|
- | 926 | mov ebx, 16 |
|
- | 927 | div ebx |
|
- | 928 | ||
- | 929 | pop edx ebx |
|
265 | mov esi, eax |
930 | |
266 | @@: |
931 | mov ebp, [edx-4] ;[edx-4] = count of strings |
- | 932 | cmp eax, ebp |
|
267 | cmp esi, 5 |
933 | ja @f |
268 | ja @f |
934 | mov ebp, eax |
- | 935 | ||
269 | mov esi, 5 |
936 | @@: |
270 | @@: |
937 | test ebp, ebp |
- | 938 | jz .ret |
|
- | 939 | mov eax, 4 |
|
- | 940 | .newline: |
|
- | 941 | cmp [edx], dword "K : " |
|
- | 942 | jne .no_k_prefix |
|
- | 943 | ||
- | 944 | push edx esi |
|
- | 945 | add edx, 4 |
|
- | 946 | sub esi, 4 |
|
- | 947 | ||
- | 948 | push ecx esi edi |
|
- | 949 | mov ecx, STRING_LENGTH-4 |
|
- | 950 | mov edi, edx |
|
- | 951 | ||
- | 952 | mov esi, proc_fors_term |
|
- | 953 | call cmp_str |
|
- | 954 | jz .highlight |
|
- | 955 | ||
- | 956 | mov esi, proc_fors_term_sp |
|
- | 957 | call cmp_str |
|
- | 958 | jnz .no_fors_term |
|
- | 959 | ||
- | 960 | .highlight: |
|
- | 961 | lea edi, [edx+STRING_LENGTH*7] |
|
- | 962 | mov esi, unexp_end_of_stack |
|
- | 963 | call cmp_str |
|
- | 964 | jnz @f |
|
- | 965 | mov [hl_line_count], 8 |
|
- | 966 | jmp .no_fors_term |
|
- | 967 | @@: |
|
- | 968 | mov [hl_line_count], 10 |
|
- | 969 | ||
- | 970 | .no_fors_term: |
|
- | 971 | pop edi esi ecx |
|
- | 972 | push ecx |
|
- | 973 | cmp [hl_line_count], 0 |
|
- | 974 | je @f |
|
- | 975 | and ecx, 0xFF000000 |
|
- | 976 | or ecx, 0xCC0000 ;red |
|
- | 977 | dec [hl_line_count] |
|
- | 978 | @@: |
|
- | 979 | mcall ; draw info text with function 4 |
|
- | 980 | pop ecx |
|
271 | sub esi, 4 |
981 | pop esi edx |
- | 982 | jmp @f |
|
272 | mov eax, 4 |
983 | .no_k_prefix: |
273 | newline: |
984 | mcall |
274 | mcall |
985 | @@: |
275 | add ebx, LINE_H |
986 | add ebx, LINE_HEIGHT |
- | 987 | add edx, STRING_LENGTH |
|
276 | add edx, 80 |
988 | dec ebp |
- | 989 | jnz .newline |
|
Line -... | Line 990... | ||
- | 990 | .ret: |
|
277 | cmp [edx], byte 'x' |
991 | ret |
- | 992 | ;------------------------------------------------------------------------------- |
|
- | 993 | ||
- | 994 | cmp_str: |
|
- | 995 | ;------------------------------------------------------------------------------- |
|
- | 996 | pusha |
|
- | 997 | ||
- | 998 | @@: |
|
- | 999 | lodsb |
|
- | 1000 | test al, al |
|
- | 1001 | jz .ret |
|
- | 1002 | scasb |
|
- | 1003 | loope @b |
|
- | 1004 | xor eax, eax |
|
- | 1005 | inc eax |
|
- | 1006 | ||
- | 1007 | .ret: |
|
- | 1008 | popa |
|
- | 1009 | ret |
|
- | 1010 | ;------------------------------------------------------------------------------- |
|
- | 1011 | ||
- | 1012 | ;------------------------------------------------------------------------------- |
|
- | 1013 | lighten_color: |
|
- | 1014 | ror eax, 16 |
|
- | 1015 | add al, 20 |
|
- | 1016 | rol eax, 8 |
|
- | 1017 | add al, 20 |
|
- | 1018 | rol eax, 8 |
|
- | 1019 | add al, 20 |
|
278 | jne newline |
1020 | ret |
279 | ret |
1021 | ;------------------------------------------------------------------------------- |
280 | 1022 | ||
281 | ;------------------------------------------------------------------------------ |
1023 | ;------------------------------------------------------------------------------- |
- | 1024 | ;* input: esi = pointer to the file name * |
|
- | 1025 | ;------------------------------------------------------------------------------- |
|
- | 1026 | create_file: |
|
- | 1027 | pusha |
|
282 | ;* input: esi = pointer to the file name * |
1028 | |
283 | ;------------------------------------------------------------------------------ |
1029 | cmp [params.rewrite_log_flag], 1 |
284 | CreateFile: |
1030 | je .create |
285 | pusha |
1031 | xor eax, eax |
286 | mov dword [InfoStructure+00], 2 ; create file |
1032 | mov dword [f70_structure+0], 5 ; get file info |
287 | mov dword [InfoStructure+04], 0 ; reserved |
1033 | mov dword [f70_structure+4], eax ; reserved |
288 | mov dword [InfoStructure+08], 0 ; reserved |
1034 | mov dword [f70_structure+8], eax ; reserved |
289 | mov dword [InfoStructure+12], 0 ; 0 bytes to write (just create) |
1035 | mov dword [f70_structure+12], eax ; reserved |
- | 1036 | mov dword [f70_structure+16], file_info ; file info buf pointer |
|
- | 1037 | mov dword [f70_structure+20], eax ; reserved |
|
290 | mov dword [InfoStructure+16], 0 ; NULL data pointer (no data) |
1038 | mov dword [f70_structure+21], esi ; pointer to the file name |
- | 1039 | mcall 70, f70_structure |
|
- | 1040 | cmp eax, 5 |
|
- | 1041 | je .create ;create file if it doesn't exist |
|
- | 1042 | test eax, eax |
|
- | 1043 | jnz .create |
|
- | 1044 | ||
- | 1045 | cmp dword [file_info+36], 0 |
|
- | 1046 | jne .create |
|
- | 1047 | mov eax, dword [file_info+32] |
|
- | 1048 | mov [filepos], eax |
|
- | 1049 | ||
- | 1050 | jmp .ret |
|
- | 1051 | ||
- | 1052 | .create: |
|
- | 1053 | xor eax, eax |
|
- | 1054 | mov dword [f70_structure+0], 2 ; create file |
|
- | 1055 | mov dword [f70_structure+4], eax ; reserved |
|
- | 1056 | mov dword [f70_structure+8], eax ; reserved |
|
291 | mov dword [InfoStructure+20], 0 ; reserved |
1057 | mov dword [f70_structure+12], eax ; 0 bytes to write (just create) |
- | 1058 | mov dword [f70_structure+16], eax ; NULL data pointer (no data) |
|
- | 1059 | mov dword [f70_structure+20], eax ; reserved |
|
292 | mov dword [InfoStructure+21], esi ; pointer to the file name |
1060 | mov dword [f70_structure+21], esi ; pointer to the file name |
293 | mcall 70, InfoStructure |
1061 | mcall 70, f70_structure |
294 | test eax, eax |
1062 | test eax, eax |
295 | jz .out |
1063 | jz .ret |
296 | stc |
1064 | stc |
- | 1065 | .ret: |
|
- | 1066 | popa |
|
- | 1067 | ret |
|
- | 1068 | ;------------------------------------------------------------------------------- |
|
- | 1069 | ||
- | 1070 | ||
- | 1071 | ||
297 | .out: |
1072 | |
298 | popa |
1073 | |
299 | ret |
1074 | |
300 | ;------------------------------------------------------------------------------ |
1075 | ;------------------------------------------------------------------------------- |
301 | ;* input: esi = pointer to the file name * |
1076 | ;* input: esi = pointer to the file name * |
302 | ;* edx = pointer to data buffer * |
1077 | ;* edx = pointer to data buffer * |
303 | ;* ecx = data length * |
1078 | ;* ecx = data length * |
304 | ;------------------------------------------------------------------------------ |
1079 | ;------------------------------------------------------------------------------- |
305 | WriteToFile: |
1080 | write_to_file: |
306 | push ebx |
1081 | push ebx |
307 | mov dword [InfoStructure+00], 3 ; write to file |
1082 | mov dword [f70_structure+0], 3 ; write to file |
308 | mov eax, [filepos] |
1083 | mov eax, [filepos] |
309 | mov dword [InfoStructure+04], eax ; lower position addr |
1084 | mov dword [f70_structure+4], eax ; lower position addr |
310 | mov dword [InfoStructure+08], 0 ; upper position addr (0 for FAT) |
1085 | mov dword [f70_structure+8], 0 ; upper position addr (0 for FAT) |
311 | mov dword [InfoStructure+12], ecx ; number of bytes to write |
1086 | mov dword [f70_structure+12], ecx ; number of bytes to write |
312 | mov dword [InfoStructure+16], edx ; pointer to data buffer |
1087 | mov dword [f70_structure+16], edx ; pointer to data buffer |
313 | mov dword [InfoStructure+20], 0 ; reserved |
1088 | mov dword [f70_structure+20], 0 ; reserved |
314 | mov dword [InfoStructure+21], esi ; pointer to the file name |
1089 | mov dword [f70_structure+21], esi ; pointer to the file name |
315 | mcall 70, InfoStructure |
1090 | mcall 70, f70_structure |
316 | clc |
1091 | clc |
317 | test eax, eax |
1092 | test eax, eax |
318 | jz .out |
1093 | jz .out |
- | 1094 | stc |
|
Line 319... | Line 1095... | ||
319 | stc |
1095 | .out: |
320 | .out: |
- | |
321 | pop ebx |
- | |
322 | ret |
- | |
323 | - | ||
324 | ;------------------------------------------------------------------------------ |
- | |
325 | ;* input: esi = pointer to string * |
- | |
326 | ;* edi = pointer to string * |
- | |
327 | ;* ecx = data length * |
- | |
328 | ;------------------------------------------------------------------------------ |
- | |
329 | StrCmp: |
- | |
330 | repe cmpsb |
- | |
331 | ja .a_greater_b |
- | |
332 | jb .a_less_b |
- | |
333 | .equal: |
- | |
334 | mov eax, 0 |
1096 | pop ebx |
335 | jmp .end |
- | |
336 | .a_less_b: |
- | |
337 | mov eax, 1 |
- | |
338 | jmp .end |
- | |
339 | .a_greater_b: |
- | |
340 | mov eax, -1 |
- | |
341 | .end: |
- | |
342 | ret |
1097 | ret |
343 | - | ||
344 | ;------------------------------------------------------------------------------ |
- | |
345 | ;* input: edi = pointer to string * |
1098 | ;------------------------------------------------------------------------------- |
346 | ;* ecx = data length * |
- | |
347 | ;------------------------------------------------------------------------------ |
- | |
348 | ; 'a' - 'A' = 32 -> 'A'|32 = 'a' |
- | |
349 | ToLower: |
1099 | |
350 | xor eax, eax |
- | |
351 | .cycle: |
- | |
Line 352... | Line -... | ||
352 | or byte[edi+eax], 32 |
- | |
353 | inc eax |
- | |
354 | loop .cycle |
- | |
355 | .end: |
- | |
356 | ret |
1100 | ;------------------------------------------------------------------------------- |
357 | - | ||
358 | ;------------------------------------------------------------------------------ |
1101 | STATE_handler: |
359 | ;* get info on current thread, save pid/tid |
- | |
360 | ;* look for another process with same name and different pid/tid |
1102 | mcall 68, 22, STATE_shm_block.name,, 0x00 ;open "BOARDAPP:STATE" shared memory block (ro access) |
361 | ;* if found, close self |
- | |
362 | ;* else continue normally |
1103 | test eax, eax |
363 | ;------------------------------------------------------------------------------ |
1104 | jz .create_STATE_shm_block |
364 | CheckUnique: |
- | |
365 | .get_thread_info: |
- | |
366 | mov ebx, procinfo |
- | |
367 | mov ecx, -1 |
1105 | |
368 | mcall 9 |
- | |
369 | - | ||
370 | .get_pid: ; check_buffer |
1106 | mov ecx, 20*10 ;timeout = 20 sec |
371 | mov [process_count], eax |
- | |
372 | mov eax, [ebx+process_information.PID] |
- | |
373 | mov [pid_tid], eax |
1107 | .0: |
374 | mov ecx, 2 |
- | |
Line -... | Line 1108... | ||
- | 1108 | mov ebx, [eax] |
|
- | 1109 | test ebx, ebx |
|
375 | 1110 | jz @f |
|
376 | .check_threads: |
1111 | mcall 5, 10 ;wait for 0.1 sec |
377 | cmp ecx, [process_count] |
1112 | loop .0 |
378 | ja .leave_check |
1113 | jmp terminate_board |
- | 1114 | ||
- | 1115 | @@: |
|
379 | mov eax, 9 |
1116 | mov ebx, [eax+4] |
- | 1117 | test ebx, ebx |
|
380 | mcall |
1118 | jnz terminate_board |
381 | 1119 | cmp dword [eax+12], 0 |
|
382 | .check_slot_free: |
1120 | jne @f |
Line -... | Line 1121... | ||
- | 1121 | mov ecx, [eax+16] |
|
- | 1122 | mcall 18, 21 ;get slot number by PID |
|
- | 1123 | test eax, eax |
|
- | 1124 | jz terminate_board |
|
383 | cmp dword [ebx+process_information.slot_state], 9 |
1125 | mov ecx, eax |
- | 1126 | mcall 18, 3 ;activate board window |
|
384 | je .next_thread |
1127 | jmp terminate_board |
- | 1128 | ||
- | 1129 | @@: |
|
385 | 1130 | cmp [params.stop_daemon_flag], 1 |
|
386 | .check_pid: |
1131 | jne terminate_board |
- | 1132 | cmp dword [eax+12], 1 |
|
Line 387... | Line -... | ||
387 | mov eax, [pid_tid] |
- | |
388 | cmp [ebx+process_information.PID], eax |
- | |
389 | je .next_thread |
- | |
390 | 1133 | jne terminate_board |
|
391 | .get_proc_name: |
- | |
392 | lea edi, [ebx+process_information.process_name] |
1134 | mov ecx, [eax+16] |
393 | push ecx |
1135 | mcall 18, 18 ;terminate daemonized board |
394 | mov ecx, my_name_size-1 |
- | |
Line 395... | Line 1136... | ||
395 | 1136 | jmp terminate_board |
|
396 | .lower_case: |
1137 | |
397 | call ToLower |
1138 | .create_STATE_shm_block: |
398 | lea esi, [my_name] |
- | |
399 | mov ecx, my_name_size |
1139 | cmp [params.stop_daemon_flag], 1 |
400 | call StrCmp |
1140 | je terminate_board |
401 | pop ecx |
1141 | |
402 | cmp eax, 0 |
1142 | mcall 68,,,STATE_shm_block.size, 0x08 ;create "BOARDAPP:STATE" shared memory block (ro access for other processes) |
- | 1143 | test eax, eax |
|
- | 1144 | jz terminate_board |
|
403 | je .close_program |
1145 | |
Line 404... | Line 1146... | ||
404 | 1146 | mov edi, eax |
|
405 | .next_thread: |
1147 | mov dword [edi], 1 |
- | 1148 | mov dword [edi+4], STATE_shm_block.version |
|
Line -... | Line 1149... | ||
- | 1149 | mov dword [edi+8], STATE_shm_block.size |
|
- | 1150 | movzx eax, byte [params.daemon_mode] |
|
406 | inc ecx |
1151 | mov dword [edi+12], eax |
407 | jmp .check_threads |
1152 | mcall 9, procinfo, -1 |
Line 408... | Line 1153... | ||
408 | 1153 | mov eax, [ebx+30] ;PID of board |
|
409 | .close_program: |
1154 | mov dword [edi+16], eax |
410 | ; restore and active window of previous thread |
1155 | mov dword [edi], 0 |
411 | mcall 18, 3 |
1156 | |
412 | mov eax, -1 |
1157 | .ret: |
413 | mcall |
1158 | ret |
414 | 1159 | ;------------------------------------------------------------------------------- |
|
415 | .leave_check: |
1160 | |
416 | ret |
1161 | terminate_board: |
Line -... | Line 1162... | ||
- | 1162 | mcall -1 |
|
- | 1163 | ;------------------------------------------------------------------------------- |
|
- | 1164 | ; DATA |
|
- | 1165 | ||
- | 1166 | if lang eq ru |
|
- | 1167 | title db "®áª ®â« ¤ª¨ ¨ á®®¡é¥¨© v1.0.1", 0 |
|
- | 1168 | else if lang eq it |
|
- | 1169 | title db "Notifiche e informazioni generiche per il debug v1.0.1", 0 |
|
- | 1170 | else if lang eq ge |
|
- | 1171 | title db "Allgemeines debug- & nachrichtenboard v1.0.1", 0 |
|
- | 1172 | else |
|
- | 1173 | title db "General debug & message board v1.0.1", 0 |
|
- | 1174 | end if |
|
417 | 1175 | ||
418 | ;------------------------------------------------------------------------------ |
1176 | STATE_shm_block: |
419 | ; DATA |
1177 | ;structure of BOARDAPP:STATE shared memory block: |
420 | 1178 | ;+0 dd mutex (0 - unlocked, block was already written by board, 1 - locked, board is writing into block) |
|
- | 1179 | ;+4 dd version of block structure (current is 0) |
|
- | 1180 | ;+8 dd size of block (min. 4096 byte for version 0) |
|
- | 1181 | ;+12 dd board's state (0 - usual windowed app, 1 - daemonized) |
|
- | 1182 | ;+16 dd board's PID |
|
- | 1183 | ;next bytes are reserved |
|
- | 1184 | ||
- | 1185 | .name db "BOARDAPP:STATE", 0 |
|
- | 1186 | .size = 4*1024 |
|
- | 1187 | .version = 0 |
|
- | 1188 | ||
- | 1189 | default_log_filename db "/tmp0/1/boardlog.txt", 0 |
|
- | 1190 | krnl_msg db "K : " |
|
- | 1191 | k_button_text db "Kernel", 0 |
|
- | 1192 | u_button_text db "User", 0 |
|
- | 1193 | ||
- | 1194 | proc_fors_term db "Process - forced terminate PID: ", 0 |
|
- | 1195 | proc_fors_term_sp db "Proceso - terminado forzado PID: ", 0 |
|
- | 1196 | unexp_end_of_stack db "Unexpected end of the stack", 0 |
|
- | 1197 | ||
- | 1198 | log_filename dd default_log_filename |
|
- | 1199 | ||
- | 1200 | filepos dd 0 |
|
- | 1201 | ||
- | 1202 | already_on_top db 0 |
|
- | 1203 | ||
- | 1204 | ||
- | 1205 | params: |
|
- | 1206 | .log_filename dd 0 |
|
- | 1207 | .log_filename.size dd 0 |
|
421 | if lang eq ru |
1208 | .log_filename_found db 0 |
Line 422... | Line -... | ||
422 | title db '®áª ®â« ¤ª¨ ¨ á®®¡é¥¨©',0 |
- | |
423 | else if lang eq it |
1209 | .daemon_mode db 0 ;0 - normal mode, 1 - daemon mode |
424 | title db 'Notifiche e informazioni generiche per il debug',0 |
1210 | .stop_daemon_flag db 0 |
Line 425... | Line -... | ||
425 | else if lang eq ge |
- | |
Line 426... | Line 1211... | ||
426 | title db 'Allgemeines debug- & nachrichtenboard',0 |
1211 | .logging_mode db 1 ;0 - don't log, 1 - log |
427 | else |
- | |
428 | title db 'General debug & message board',0 |
- | |
429 | end if |
- | |
430 | - | ||
431 | default_filename db '/tmp0/1/boardlog.txt',0 |
- | |
- | 1212 | .rewrite_log_flag db 0 |
|
432 | krnl_msg db 'K : ' |
1213 | .options.d db "daemonize", 0 |
433 | duk db 'KernUser' |
- | |
Line 434... | Line 1214... | ||
434 | my_name db 'board',0 |
1214 | .options.d.size = $-.options.d |
435 | my_name_size = $-my_name |
1215 | .options.s db "stop-daemon", 0 |
436 | 1216 | .options.s.size = $-.options.s |
|
437 | align 4 |
- | |
438 | vmode dd 1 |
1217 | .options.n db "no-log", 0 |
439 | targ dd text2 |
1218 | .options.n.size = $-.options.n |
- | 1219 | .options.r db "rewrite-log", 0 |
|
440 | 1220 | .options.r.size = $-.options.r |
|
- | 1221 | .options.f db "fullscreen", 0 |
|
- | 1222 | .options.f.size = $-.options.f |
|
- | 1223 | ||
- | 1224 | vmode dd 1 |
|
- | 1225 | fullscreen_mode db 0 |
|
- | 1226 | ||
- | 1227 | ||
Line -... | Line 1228... | ||
- | 1228 | align 4 |
|
- | 1229 | ||
- | 1230 | targ dd text1 |
|
- | 1231 | ||
- | 1232 | open_log_in_tinypad: |
|
- | 1233 | dd 7 |
|
- | 1234 | dd 0 |
|
- | 1235 | dd 0 |
|
- | 1236 | dd 0 |
|
441 | I_END: |
1237 | dd 0 |
442 | 1238 | db "/sys/tinypad", 0 |
|
443 | InfoStructure: |
1239 | |
444 | dd ? ; subfunction number |
- | |
445 | dd ? ; position in the file in bytes |
- | |
446 | dd ? ; upper part of the position address |
1240 | I_END: |
- | 1241 | ||
- | 1242 | prev_win_x dw ? |
|
- | 1243 | prev_win_y dw ? |
|
- | 1244 | prev_win_w dw ? |
|
447 | dd ? ; number of bytes to read |
1245 | prev_win_h dw ? |
Line 448... | Line 1246... | ||
448 | dd ? ; pointer to the buffer to write data |
1246 | |
449 | db ? |
1247 | f70_structure: |
450 | dd ? ; pointer to the filename |
- | |
Line 451... | Line 1248... | ||
451 | 1248 | dd ? ; subfunction number |
|
452 | open_log_in_tinypad: |
1249 | dd ? ; |
453 | dd 7 |
- | |
Line 454... | Line 1250... | ||
454 | dd 0 |
1250 | dd ? ; |
455 | dd filename |
1251 | dd ? ; |
456 | dd 0 |
1252 | dd ? ; |
457 | dd 0 |
1253 | db ? |
- | 1254 | dd ? ; pointer to the filename |
|
- | 1255 | ||
- | 1256 | window_header_height dd ? |
|
- | 1257 | buffer_length dd ? |
|
- | 1258 | krnl_cnt dd ? |
|
458 | db '/sys/tinypad',0 |
1259 | xstart dd ? |