Subversion Repositories Kolibri OS

Rev

Rev 8560 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8560 Rev 8891
Line 1... Line 1...
1
;-------------------------------------------------------------------------------
1
;------------------------------------------------------------------------------
2
; DEBUG BOARD v1.0.1 for APPLICATIONS and KERNEL DEVELOPMENT
2
; DEBUG BOARD 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_END
12
        dd      mem
13
	dd	STACK_TOP
13
        dd      mem
14
	dd	PARAMS_STRING
14
        dd      filename
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
 
-
 
-
 
19
include '../../../debug.inc'
20
	purge	newline
20
purge   newline
-
 
21
;SMALL FONT
21
MAX_STRINGS = 45
22
MAXSTRINGS = 45
22
STRING_LENGTH = 80	;must be a multiple of 4
-
 
23
LINE_HEIGHT = 16
23
LINE_H = 10
24
WINDOW_W = 60*8+5*2
-
 
25
WINDOW_W_MIN = 330
24
WINDOW_W = 399
26
WORK_AREA_H_MIN = 60
-
 
27
WINDOW_W_PRCNT = 40
-
 
28
WINDOW_H_PRCNT = 75
-
 
29
TEXTFIELD_H = MAX_STRINGS*LINE_HEIGHT
25
WINDOW_H = MAXSTRINGS*LINE_H+45
30
FONT_TYPE = 0x50000000
26
FONT_TYPE = 0x40000000
31
;-------------------------------------------------------------------------------
-
 
32
START:
27
;BIG FONT
33
	mcall	68, 11	;init heap
28
; MAXSTRINGS = 30
34
	
-
 
35
	call	parse_params_string
29
; LINE_H = 15
36
	test	eax, eax
30
; WINDOW_W = 630
37
	jnz	.no_params
31
; WINDOW_H = MAXSTRINGS*LINE_H+50
38
	call	check_and_fix_params
32
; FONT_TYPE = 0x50000000
Line -... Line 33...
-
 
33
 
39
 
34
;------------------------------------------------------------------------------
40
.no_params:
35
START:
-
 
36
        call    CheckUnique
-
 
37
        mov     edi, filename
-
 
38
        cmp     [edi], byte 0
-
 
39
        jnz     param
41
	call	STATE_handler
40
        mov     esi, default_filename
-
 
41
@@:
-
 
42
        lodsb
-
 
43
        stosb
-
 
44
        test    al,al
-
 
45
        jnz     @b
42
 
46
param:
43
	mov	ecx, MAX_STRINGS*(STRING_LENGTH/4)
47
        mov     ecx, (MAXSTRINGS+1)*20
44
	mov	edi, text1
48
        mov     edi, text1
45
	mov	eax, "    "
-
 
46
	push	ecx
49
        mov     eax, '    '
Line 47... Line 50...
47
	rep	stosd
50
        rep     stosd
48
 
51
 
49
	pop	ecx
52
        mov     ecx, (MAXSTRINGS+1)*20
Line 50... Line -...
50
	mov	edi, text2
-
 
51
	rep	stosd
-
 
52
 
-
 
53
	cmp	[params.daemon_mode], 1
-
 
54
	je	.create_log_file
53
        mov     edi, text2
55
	
-
 
56
	call	calc_window_size
54
        rep     stosd
57
	mov	ax, word [xstart+2]
-
 
58
	mov	[prev_win_x], ax
-
 
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
	
-
 
Line 66... Line 55...
66
	cmp	[fullscreen_mode], 0
55
 
-
 
56
        mov     byte [tmp1], 'x'
-
 
57
        mov     byte [tmp2], 'x'
-
 
58
 
-
 
59
        mcall   14
67
	je	@f
60
        and     eax, 0xffff0000
Line 68... Line -...
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
-
 
85
	mov	[filepos], eax
61
        sub     eax, WINDOW_W shl 16
86
 
-
 
87
	cmp	[params.logging_mode], 0
-
 
88
	je	@f
-
 
89
	
-
 
90
	mov	esi, [log_filename]
62
        add     eax, WINDOW_W
91
	call	create_file
-
 
92
	jnc	@f
-
 
93
	mov	esi, default_log_filename
-
 
94
	mov	[log_filename], default_log_filename
-
 
95
	call	create_file
63
        mov     [xstart], eax
96
	
-
 
97
@@:
64
        mcall   48, 3, sc, sizeof.system_colors
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
-
 
120
	jae	@f
65
 
121
	mcall	67, -1, -1, -1 ;resize window
-
 
-
 
66
        mov     esi, filename
122
	mov	dword [procinfo+46], esi 
67
        call    CreateFile
123
 
68
;------------------------------------------------------------------------------
124
@@:	
-
 
125
	call	draw_window
-
 
126
 
69
red:
127
.still:
70
        call    draw_window
128
	cmp	byte [buffer_length], 0
-
 
129
	je	@f
-
 
130
	cmp	[params.logging_mode], 0
-
 
131
	je	@f
-
 
132
	call	write_buffer
-
 
133
	
-
 
134
@@:
71
;------------------------------------------------------------------------------
135
	cmp	[params.daemon_mode], 0
72
still:
136
	je	@f
73
        cmp     [buffer_length], 0
137
	mcall	5, 50				;pause for 0.5 sec
74
        je      @f
Line 138... Line 75...
138
	jmp	.read_byte
75
        call    write_buffer
139
@@:
76
@@:
Line 140... Line 77...
140
	mcall	23, 50				; wait here for event
77
        mcall   23, 50                    ; wait here for event
141
	dec	eax				; redraw request ?
78
        cmp     eax, 1                    ; redraw request ?
Line 142... Line 79...
142
	jz	.red
79
        je      red
143
	
-
 
144
	dec	eax				; key in buffer ?
80
 
145
	jz	.key
-
 
146
	
81
        cmp     eax, 2                    ; key in buffer ?
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 220... Line 82...
220
	mov	[vmode], 0
82
        je      key
221
	jmp	.red
83
 
222
@@:
84
        cmp     eax, 3                    ; button in buffer ?
223
	cmp	ah, 4
-
 
224
	jne	@f
-
 
225
	mov	[vmode], 1
85
        je      button
226
@@:
-
 
227
	jmp	.red
86
 
228
 
87
        mcall   63, 2
229
.new_data:
88
        cmp     ebx, 1
230
	cmp	byte [buffer_length], 255
89
        jne     still
231
	jne	@f
-
 
232
	cmp	[params.logging_mode], 0
-
 
233
	je	@f
90
 
234
	call	write_buffer
91
new_data:
235
	
92
        cmp     [buffer_length], 255
236
@@:
93
        jne     @f
237
	movzx	ebx, byte [buffer_length]
94
        call    write_buffer
238
	mov	[ebx+tmp], al
95
@@:
-
 
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]
239
	inc	byte [buffer_length]
110
        mov     esi, filename
-
 
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
240
	cmp	[params.daemon_mode], 1
118
        jnc     .write_to_logfile
241
	je	.read_byte
119
@@:
242
	mov	ebp, [targ]
120
        movzx   eax,byte[buffer_length]
243
	cmp	al, 10
121
        add     [filepos],eax
244
	jz	.new_line
122
        xor     eax,eax
245
	cmp	al, 13
123
        mov     [buffer_length],al
246
	jz	.new_check
124
        popa
247
	jmp	.char
125
        ret
248
 
126
;------------------------------------------
249
.new_line:
127
new_line:
250
	and	[ebp-8], dword 0
128
        and     [ebp-8], dword 0
Line 251... Line 129...
251
	inc	dword [ebp-4]
129
        inc     dword [ebp-4]
252
	cmp	[ebp-4], dword MAX_STRINGS
130
        cmp     [ebp-4], dword MAXSTRINGS
253
	jb	.noypos
131
        jbe     .noypos
254
	mov	[ebp-4], dword MAX_STRINGS-1
132
        mov     [ebp-4], dword MAXSTRINGS
255
	lea	esi, [ebp+STRING_LENGTH]
133
        lea     esi, [ebp+80]
256
	mov	edi, ebp
134
        mov     edi, ebp
257
	mov	ecx, (MAX_STRINGS-1)*(STRING_LENGTH/4)
135
        mov     ecx, 20*(MAXSTRINGS)
258
	cld
-
 
259
	rep	movsd
136
        cld
260
 
137
        rep     movsd
261
	mov	esi, [ebp-4]
138
 
262
	imul	esi, STRING_LENGTH
139
        mov     esi, [ebp-4]
263
	add	esi, [ebp-8]
-
 
-
 
140
        imul    esi, 80
264
	add	esi, ebp
141
        add     esi, [ebp-8]
265
	mov	ecx, STRING_LENGTH/4
142
        add     esi, ebp
266
	mov	eax, "    "
143
        mov     ecx, 20
267
	rep	stosd
144
        mov     eax, '    '
268
	
145
        rep     stosd
269
.noypos:
146
.noypos:
270
	mov	[targ], text1
147
        mov     [targ],text2
271
	and	[krnl_cnt], 0
148
        and     [krnl_cnt],0
272
	jmp	.new_check
149
        jmp     new_check
273
 
150
;------------------------------------------
274
.char:
151
char:
275
	cmp	ebp, text2
152
        cmp     ebp, text1
276
	je	.add2
153
        je      add2
277
	mov	ecx, [krnl_cnt]
154
        mov     ecx, [krnl_cnt]
278
	cmp	al, [krnl_msg+ecx]
155
        cmp     al, [krnl_msg+ecx]
279
	jne	.nokrnl
156
        jne     .noknl
Line 291... Line 168...
291
	call	add_char
168
        call    add_char
292
	loop	.l1
169
        loop    .l1
293
	pop	eax
170
        pop     eax
294
.add:
171
.add:
295
	and	[krnl_cnt], 0
172
        and     [krnl_cnt], 0
296
.add2:
173
add2:
297
	call	add_char
174
        call    add_char
Line 298... Line 175...
298
 
175
 
299
.new_check:
176
new_check:
300
	mcall	63, 2			;read a byte from the debug buffer
177
        mcall   63, 2
301
	cmp	ebx, 1
178
        cmp     ebx, 1
302
	je	.new_data
-
 
303
	
-
 
304
	cmp	[params.daemon_mode], 1
-
 
305
	je	.still
179
        je      new_data
-
 
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 306... Line -...
306
	call	draw_text
-
 
307
	
192
        jmp     red
308
	jmp	.still
193
		
-
 
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:
309
;-------------------------------------------------------------------------------
202
        xor     [vmode], 1
310
 
203
        jmp     red
311
;------------------------------------------------------------------------------
204
;------------------------------------------------------------------------------
312
add_char:
205
add_char:
313
	push	esi
206
        push    esi
314
	mov	esi, [ebp-4]
207
        mov     esi, [ebp-4]
315
	imul	esi, STRING_LENGTH
208
        imul    esi, 80
316
	add	esi, [ebp-8]
-
 
317
	mov	[ebp+esi], al
-
 
318
	cmp	dword [ebp-8], STRING_LENGTH-1
209
        add     esi, [ebp-8]
-
 
210
        mov     [ebp+esi], al
-
 
211
        inc     dword[ebp-8]
-
 
212
        cmp     dword[ebp-8], 80
319
	je	.ok
213
        jb      .ok
320
	inc	dword [ebp-8]
214
        mov     dword[ebp-8], 79
321
.ok:
215
.ok:
322
	pop	esi
-
 
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
-
 
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
-
 
Line 630... Line -...
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
216
        pop     esi
779
;-------------------------------------------------------------------------------
217
        ret
780
 
218
 
781
;-------------------------------------------------------------------------------
219
;------------------------------------------------------------------------------
782
;************************	WINDOW DEFINITIONS AND DRAW ************************
220
;************************  WINDOW DEFINITIONS AND DRAW ************************
783
;-------------------------------------------------------------------------------
-
 
784
draw_window:
-
 
785
	mcall	12, 1			; start of draw
-
 
786
	xor	edx, edx
-
 
787
	mov	dl, 0x13
-
 
788
	cmp	[fullscreen_mode], 0
-
 
789
	je	@f
-
 
790
	mov	dl, 1			;set fullscreen mode window
-
 
791
	
-
 
792
@@:
-
 
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
	
221
;------------------------------------------------------------------------------
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
@@:
-
 
807
	mcall	13, [xstart], [ystart], 0xFFFFFF	;draw a rectangle (fill the window)
222
draw_window:
808
	
223
        mcall   12, 1                     ; 1, start of draw
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
 
224
        mcall   48, 5                     ; GetClientTop
816
@@:
-
 
817
	add	ecx, 5
-
 
818
	shl	ecx, 16
-
 
819
	mov	cx, LINE_HEIGHT+5
-
 
820
	mov	eax, [sc.work_button]
225
        shr     ebx, 16
821
	cmp	[vmode], 0
-
 
822
	jne	@f
-
 
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
-
 
833
	add	bx, 3
226
        mov     ecx, ebx
834
	ror	ebx, 16
-
 
835
	add	bx, 4
227
        shl     ecx, 16
836
	mov	ecx, 0x90
-
 
837
	shl	ecx, 24
-
 
838
	add	ecx, [sc.work_button_text]
-
 
839
	mcall	4,,, u_button_text
228
        add     ecx, WINDOW_H     ; [y start] *65536 + [y size]
840
	cmp	[vmode], 0
229
        mov     edx, 0xffffff
841
	jne	@f
-
 
842
	add	ebx, 1 shl 16
-
 
843
	mcall			;make text bolder if the button is active
-
 
844
 
-
 
845
@@:
230
        or      edx, 0x14000000
846
	pop	ecx ebx
-
 
847
	
231
        xor     esi, esi
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
232
        mcall   0,[xstart],,,,title
853
	call	lighten_color	;make button lighter if it's active
233
        mov     ebx, 296 shl 16+31
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
234
        mcall   8,,<4,13>,3,[sc.work_button]
862
	ror	ebx, 16
235
        mov     edx, [vmode]
863
	add	bx, 4
236
        lea     edx, [edx*4+duk]
864
	mov	ecx, 0x90
237
        mov     ecx, 0x80
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
-
 
871
	mcall			;make text bolder if the button is active
238
        shr     ecx, 24
872
 
239
        add     ecx, [sc.work_button_text]
873
@@:
240
        mcall   4,<300,7>,,,4
874
	call	draw_text
241
        call    draw_text
875
	mcall	12, 2			; 2, end of draw
-
 
876
	ret
-
 
877
;-------------------------------------------------------------------------------
242
        mcall   12, 2                     ; 2, end of draw
878
 
243
        ret
879
;-------------------------------------------------------------------------------
244
;------------------------------------------------------------------------------
880
draw_text:
-
 
881
	mov	ebx, 15 shl 16 + 0
-
 
882
	xor	bx, bx
-
 
883
	cmp	[fullscreen_mode], 1
-
 
884
	je	@f
-
 
885
	mov	bx, word [window_header_height] 
-
 
886
 
245
draw_text:
887
@@:
246
        mov     ebx, 15*65536+30          ; draw info text with function 4
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
247
        xor     ecx, ecx
-
 
248
        or      ecx, FONT_TYPE
-
 
249
        mov     edi, 0xffffff
-
 
250
        mov     edx, text1
892
	cmp	[vmode], 1
251
        cmp     [vmode], 0
893
	je	.kern
252
        je      .kern
894
	mov	edx, text1
-
 
895
.kern:
-
 
896
	push	ebx edx
-
 
897
	
253
        mov     edx, text2
898
	
254
.kern:
899
	
255
        push    ebx ecx edx
900
	mov	eax, dword [procinfo+42]		;x-size of board window
256
        mcall   9, procinfo,-1
901
	sub	eax, 15*2
257
        mov     eax, [ebx+42]
902
	xor	edx, edx
-
 
903
	mov	ebx, 8
-
 
904
	div	ebx
258
        xor     edx, edx
905
	
-
 
906
@@:
-
 
907
	cmp	[vmode], 1
-
 
908
	jne	@f
-
 
909
	add	eax, 4
259
        mov     ebx, 6
910
 
260
        div     ebx
911
@@:
261
        pop     edx ecx ebx
912
	mov	esi, STRING_LENGTH
262
        mov     esi, 80
913
	cmp	eax, esi
-
 
914
	ja	@f
263
        cmp     eax, esi
915
	mov	esi, eax
-
 
916
 
264
        ja      @f
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
-
 
930
	
265
        mov     esi, eax
931
	mov	ebp, [edx-4]	;[edx-4] = count of strings
266
@@:
932
	cmp	eax, ebp
-
 
933
	ja	@f
267
        cmp     esi, 5
934
	mov	ebp, eax
-
 
935
 
-
 
936
@@:
-
 
937
	test	ebp, ebp
-
 
938
	jz	.ret
-
 
939
	mov	eax, 4
-
 
940
.newline:
-
 
941
	cmp	[edx], dword "K : "
-
 
942
	jne	.no_k_prefix
-
 
943
	
268
        ja      @f
944
	push	edx esi
-
 
945
	add	edx, 4
-
 
946
	sub	esi, 4
-
 
947
	
269
        mov     esi, 5
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
270
@@:
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
-
 
981
	pop	esi edx
271
        sub     esi, 4
982
	jmp	@f
-
 
983
.no_k_prefix:
272
        mov     eax, 4
984
	mcall
273
newline:
985
@@:
274
        mcall
986
	add	ebx, LINE_HEIGHT
275
        add     ebx, LINE_H
987
	add	edx, STRING_LENGTH
-
 
988
	dec	ebp
-
 
989
	jnz	.newline
-
 
990
.ret:
-
 
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
276
        add     edx, 80
1018
	rol	eax, 8
-
 
Line 1019... Line 277...
1019
	add	al, 20
277
        cmp     [edx], byte 'x'
1020
	ret
278
        jne     newline
1021
;-------------------------------------------------------------------------------
279
        ret
1022
	
280
 
1023
;-------------------------------------------------------------------------------
281
;------------------------------------------------------------------------------
1024
;*	input:	esi = pointer to the file name	*
-
 
1025
;-------------------------------------------------------------------------------
-
 
1026
create_file:
-
 
1027
	pusha
-
 
1028
	
-
 
1029
	cmp	[params.rewrite_log_flag], 1
-
 
1030
	je	.create
-
 
1031
	xor	eax, eax
-
 
1032
	mov	dword [f70_structure+0], 5		; get file info
-
 
1033
	mov	dword [f70_structure+4], eax		; reserved
-
 
1034
	mov	dword [f70_structure+8], eax		; reserved
-
 
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
-
 
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
282
;*  input:  esi = pointer to the file name  *
1051
	
283
;------------------------------------------------------------------------------
1052
.create:
284
CreateFile:
1053
	xor	eax, eax
285
        pusha
1054
	mov	dword [f70_structure+0], 2	; create file
286
        mov     dword [InfoStructure+00], 2   ; create file
1055
	mov	dword [f70_structure+4], eax	; reserved
287
        mov     dword [InfoStructure+04], 0   ; reserved
1056
	mov	dword [f70_structure+8], eax	; reserved
288
        mov     dword [InfoStructure+08], 0   ; reserved
1057
	mov	dword [f70_structure+12], eax	; 0 bytes to write (just create)
289
        mov     dword [InfoStructure+12], 0   ; 0 bytes to write (just create)
1058
	mov	dword [f70_structure+16], eax	; NULL data pointer (no data)
290
        mov     dword [InfoStructure+16], 0   ; NULL data pointer (no data)
1059
	mov	dword [f70_structure+20], eax	; reserved
291
        mov     dword [InfoStructure+20], 0   ; reserved
1060
	mov	dword [f70_structure+21], esi ; pointer to the file name
292
        mov     dword [InfoStructure+21], esi ; pointer to the file name
1061
	mcall	70, f70_structure
293
        mcall   70, InfoStructure
1062
	test	eax, eax
294
        test    eax, eax
1063
	jz	.ret
295
        jz      .out
1064
	stc
296
        stc
1065
.ret:
-
 
1066
	popa
-
 
1067
	ret
-
 
1068
;-------------------------------------------------------------------------------
-
 
1069
 
-
 
1070
 
-
 
1071
 
-
 
1072
 
297
.out:
1073
 
298
        popa
1074
 
299
        ret
1075
;-------------------------------------------------------------------------------
300
;------------------------------------------------------------------------------
1076
;*	input:	esi = pointer to the file name	*
301
;*  input:  esi = pointer to the file name  *
1077
;*		edx = pointer to data buffer	*
302
;*          edx = pointer to data buffer    *
1078
;*		ecx = data length		*
303
;*          ecx = data length               *
1079
;-------------------------------------------------------------------------------
304
;------------------------------------------------------------------------------
1080
write_to_file:
305
WriteToFile:
1081
	push	ebx
306
        push    ebx
1082
	mov	dword [f70_structure+0], 3	; write to file
307
        mov     dword [InfoStructure+00], 3   ; write to file
1083
	mov	eax,	[filepos]
308
        mov     eax,  [filepos]
1084
	mov	dword [f70_structure+4], eax ; lower position addr
309
        mov     dword [InfoStructure+04], eax ; lower position addr
1085
	mov	dword [f70_structure+8], 0	; upper position addr (0 for FAT)
310
        mov     dword [InfoStructure+08], 0   ; upper position addr (0 for FAT)
1086
	mov	dword [f70_structure+12], ecx ; number of bytes to write
311
        mov     dword [InfoStructure+12], ecx ; number of bytes to write
1087
	mov	dword [f70_structure+16], edx ; pointer to data buffer
312
        mov     dword [InfoStructure+16], edx ; pointer to data buffer
1088
	mov	dword [f70_structure+20], 0	; reserved
313
        mov     dword [InfoStructure+20], 0   ; reserved
1089
	mov	dword [f70_structure+21], esi ; pointer to the file name
314
        mov     dword [InfoStructure+21], esi ; pointer to the file name
1090
	mcall	70, f70_structure
315
        mcall   70, InfoStructure
1091
	clc
316
        clc
1092
	test	eax, eax
317
        test    eax, eax
1093
	jz	.out
318
        jz      .out
1094
	stc
-
 
Line 1095... Line 319...
1095
.out:
319
        stc
-
 
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
1096
	pop	ebx
331
        ja      .a_greater_b
1097
	ret
332
        jb      .a_less_b
-
 
333
.equal:
1098
;-------------------------------------------------------------------------------
334
        mov     eax, 0
1099
 
335
        jmp     .end
-
 
336
.a_less_b:
-
 
337
        mov     eax, 1
Line -... Line 338...
-
 
338
        jmp     .end
-
 
339
.a_greater_b:
-
 
340
        mov     eax, -1
-
 
341
.end:
1100
;-------------------------------------------------------------------------------
342
        ret
1101
STATE_handler:
343
 
1102
	mcall	68, 22, STATE_shm_block.name,, 0x00	;open "BOARDAPP:STATE" shared memory block (ro access)
344
;------------------------------------------------------------------------------
1103
	test	eax, eax
345
;*  input:  edi = pointer to string          *
-
 
346
;*          ecx = data length                *
1104
	jz	.create_STATE_shm_block
347
;------------------------------------------------------------------------------
1105
	
348
; 'a' - 'A' = 32 -> 'A'|32 = 'a'
1106
	mov	ecx, 20*10	;timeout = 20 sec
349
ToLower:
1107
.0:
350
        xor     eax, eax
Line 1108... Line -...
1108
	mov	ebx, [eax]
-
 
-
 
351
.cycle:
-
 
352
        or      byte[edi+eax], 32
-
 
353
        inc     eax
1109
	test	ebx, ebx
354
        loop    .cycle
-
 
355
.end:
-
 
356
        ret
1110
	jz	@f
357
 
1111
	mcall	5, 10		;wait for 0.1 sec
358
;------------------------------------------------------------------------------
1112
	loop	.0
359
;* get info on current thread, save pid/tid
1113
	jmp	terminate_board
360
;* look for another process with same name and different pid/tid
1114
	
361
;* if found, close self
-
 
362
;* else continue normally
-
 
363
;------------------------------------------------------------------------------
1115
@@:	
364
CheckUnique:
-
 
365
.get_thread_info:
1116
	mov	ebx, [eax+4]
366
        mov     ebx, procinfo
1117
	test	ebx, ebx
367
        mov     ecx, -1
-
 
368
        mcall   9
1118
	jnz	terminate_board
369
 
1119
	cmp	dword [eax+12], 0
370
.get_pid:                             ; check_buffer
-
 
371
        mov     [process_count], eax
1120
	jne	@f
372
        mov     eax, [ebx+process_information.PID]
-
 
373
        mov     [pid_tid], eax
Line 1121... Line -...
1121
	mov	ecx, [eax+16]
-
 
1122
	mcall	18, 21		;get slot number by PID
-
 
1123
	test	eax, eax
-
 
1124
	jz	terminate_board
-
 
1125
	mov	ecx, eax
374
        mov     ecx, 2
1126
	mcall	18, 3		;activate board window
-
 
1127
	jmp	terminate_board
375
 
1128
	
376
.check_threads:
1129
@@:
377
        cmp     ecx, [process_count]
1130
	cmp	[params.stop_daemon_flag], 1
378
        ja      .leave_check
-
 
379
        mov     eax, 9
1131
	jne	terminate_board
380
        mcall
1132
	cmp	dword [eax+12], 1
381
 
Line -... Line 382...
-
 
382
.check_slot_free:
1133
	jne	terminate_board
383
        cmp     dword [ebx+process_information.slot_state], 9
1134
	mov	ecx, [eax+16]
384
        je      .next_thread
1135
	mcall	18, 18		;terminate daemonized board
385
 
Line 1136... Line 386...
1136
	jmp	terminate_board
386
.check_pid:
1137
	
387
        mov     eax, [pid_tid]
1138
.create_STATE_shm_block:
388
        cmp     [ebx+process_information.PID], eax
1139
	cmp	[params.stop_daemon_flag], 1
389
        je      .next_thread
1140
	je	terminate_board
390
 
1141
 
391
.get_proc_name:
1142
	mcall	68,,,STATE_shm_block.size, 0x08		;create "BOARDAPP:STATE" shared memory block (ro access for other processes)
392
        lea     edi, [ebx+process_information.process_name]
1143
	test	eax, eax
393
        push    ecx
1144
	jz	terminate_board
-
 
1145
	
-
 
Line 1146... Line 394...
1146
	mov	edi, eax
394
        mov     ecx, my_name_size-1
-
 
395
 
-
 
396
.lower_case:
-
 
397
        call    ToLower
-
 
398
        lea     esi, [my_name]
-
 
399
        mov     ecx, my_name_size
-
 
400
        call    StrCmp
-
 
401
        pop     ecx
-
 
402
        cmp     eax, 0
-
 
403
        je      .close_program
-
 
404
 
1147
	mov	dword [edi], 1
405
.next_thread:
1148
	mov	dword [edi+4], STATE_shm_block.version
-
 
Line 1149... Line -...
1149
	mov	dword [edi+8], STATE_shm_block.size
-
 
1150
	movzx	eax, byte [params.daemon_mode]
-
 
1151
	mov	dword [edi+12], eax
406
        inc     ecx
1152
	mcall	9, procinfo, -1
407
        jmp     .check_threads
Line 1153... Line 408...
1153
	mov	eax, [ebx+30]				;PID of board
408
 
1154
	mov	dword [edi+16], eax
409
.close_program:
1155
	mov	dword [edi], 0
410
        ; restore and active window of previous thread
1156
	
411
        mcall   18, 3
1157
.ret:
412
        mov     eax, -1
1158
	ret
413
        mcall
1159
;-------------------------------------------------------------------------------
414
 
1160
 
415
.leave_check:
1161
terminate_board:
416
        ret
Line 1162... Line -...
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
-
 
1175
 
417
 
1176
STATE_shm_block:
418
;------------------------------------------------------------------------------
1177
;structure of BOARDAPP:STATE shared memory block:
419
; DATA
1178
;+0	dd	mutex (0 - unlocked, block was already written by board, 1 - locked, board is writing into block)
420
 
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
-
 
1208
	.log_filename_found	db	0
421
if lang eq ru
Line -... Line 422...
-
 
422
 title	db '„®áª  ®â« ¤ª¨ ¨ á®®¡é¥­¨©',0
1209
	.daemon_mode		db	0	;0 - normal mode, 1 - daemon mode
423
else if lang eq it
1210
	.stop_daemon_flag	db	0
424
 title	db 'Notifiche e informazioni generiche per il debug',0
1211
	.logging_mode		db	1	;0 - don't log, 1 - log
-
 
Line 1212... Line 425...
1212
	.rewrite_log_flag	db	0
425
else if lang eq ge
Line 1213... Line 426...
1213
	.options.d		db	"daemonize", 0
426
 title	db 'Allgemeines debug- & nachrichtenboard',0
-
 
427
else
-
 
428
 title	db 'General debug & message board',0
-
 
429
end if
-
 
430
 
-
 
431
default_filename db '/tmp0/1/boardlog.txt',0
-
 
432
krnl_msg        db  'K : '
-
 
433
duk             db  'KernUser'
Line 1214... Line 434...
1214
	.options.d.size = $-.options.d
434
my_name         db  'board',0
1215
	.options.s		db	"stop-daemon", 0
435
my_name_size = $-my_name
1216
	.options.s.size = $-.options.s
436
 
-
 
437
align 4
1217
	.options.n		db	"no-log", 0
438
vmode   dd  1
1218
	.options.n.size = $-.options.n
439
targ    dd  text2
1219
	.options.r		db	"rewrite-log", 0
-
 
1220
	.options.r.size = $-.options.r
440
 
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 1228... Line -...
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
-
 
1237
	dd	0
441
I_END:
1238
	db	"/sys/tinypad", 0
442
 
1239
 
443
InfoStructure:
-
 
444
        dd      ?       ; subfunction number
-
 
445
        dd      ?       ; position in the file in bytes
1240
I_END:
446
        dd      ?       ; upper part of the position address
1241
 
-
 
1242
	prev_win_x	dw	?
-
 
1243
prev_win_y	dw	?
-
 
1244
prev_win_w	dw	?
-
 
1245
prev_win_h	dw	?
447
        dd      ?       ; number of bytes to read
Line 1246... Line 448...
1246
 
448
        dd      ?       ; pointer to the buffer to write data
1247
f70_structure:
449
        db      ?
-
 
450
        dd      ?       ; pointer to the filename
Line 1248... Line 451...
1248
	dd	?	; subfunction number
451
 
1249
	dd	?	; 
452
open_log_in_tinypad:
-
 
453
        dd      7
Line 1250... Line 454...
1250
	dd	?	; 
454
        dd      0
1251
	dd	?	; 
455
        dd      filename
1252
	dd	?	; 
456
        dd      0
1253
	db	?
457
        dd      0
1254
	dd	?	; pointer to the filename
-
 
1255
 
-
 
1256
window_header_height	dd	?
-
 
1257
buffer_length		dd	?
-
 
1258
krnl_cnt		dd	?
-
 
1259
xstart			dd	?
458
        db      '/sys/tinypad',0