Subversion Repositories Kolibri OS

Rev

Rev 1998 | Rev 2743 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1998 Rev 2234
Line 21... Line 21...
21
include '../../../macros.inc'
21
include '../../../macros.inc'
22
include 'debug.inc'
22
include 'debug.inc'
23
purge newline
23
purge newline
24
MAXSTRINGS = 16
24
MAXSTRINGS = 16
25
TMP = 80*(MAXSTRINGS+1)
25
TMP = 80*(MAXSTRINGS+1)
26
 
-
 
-
 
26
;------------------------------------------------------------------------------
27
START:				; start of execution
27
START:				; start of execution
28
	mov	edi, filename
28
	mov	edi,filename
29
	cmp	byte [edi], 0
29
	cmp	[edi],byte 0
30
	jnz	param
30
	jnz	param
31
	mov	esi, default_filename
31
	mov	esi,default_filename
32
@@:
32
@@:
33
	lodsb
33
	lodsb
34
	stosb
34
	stosb
35
	test	al, al
35
	test	al,al
36
	jnz	@b
36
	jnz	@b
37
param:
37
param:
Line 38... Line 38...
38
 
38
 
39
; allow user to see messages written before start
39
; allow user to see messages written before start
40
;     mov  ecx,4096
40
;	mov	ecx,4096
41
;    flush:
-
 
42
;     mov  eax,63
-
 
43
;     mov  ebx,2
41
;flush:
44
;     mcall
42
;	mcall	63,2
45
;     loop flush
43
;	loop	flush
46
 
44
	
47
     mov  ecx, TMP
45
	mov	ecx,TMP
48
     xor  eax, eax
46
	xor	eax,eax
49
     mov  edi, [targ]
47
	mov	edi,[targ]
50
     rep  stosb
48
	rep	stosb
51
 
49
 
52
     mov  [tmp1],'x'
50
	mov	[tmp1],'x'
53
     mov  [tmp2],'x'
51
	mov	[tmp2],'x'
54
 
-
 
55
     mov  eax,14
52
	
56
     mcall
53
	mcall	14
57
     and  eax,0xffff0000
54
	and	eax,0xffff0000
58
     sub  eax,399 shl 16
55
	sub	eax,399 shl 16
59
     add  eax,399
56
	add	eax,399
60
     mov  [xstart],eax
-
 
61
 
-
 
62
     mov  eax,48
-
 
63
     mov  ebx,3
-
 
64
     mov  ecx,sc
57
	mov	[xstart],eax
65
     mov  edx,sizeof.system_colors
-
 
66
     mcall
58
	mcall	48,3,sc,sizeof.system_colors
67
  if WRITE_LOG
59
if WRITE_LOG
68
     mov  esi, filename
60
	mov	esi,filename
69
     call CreateFile
61
	call	CreateFile
-
 
62
end if
-
 
63
;------------------------------------------------------------------------------
-
 
64
red:
-
 
65
	call draw_window
-
 
66
;------------------------------------------------------------------------------
-
 
67
still:
-
 
68
	mcall	23,1		; wait here for event
-
 
69
	cmp	eax,1			; redraw request ?
Line -... Line 70...
-
 
70
	je	red
70
  end if
71
 
71
 
-
 
Line -... Line 72...
-
 
72
	cmp	eax,2			; key in buffer ?
72
  red:
73
	je	key
Line 73... Line -...
73
     call draw_window
-
 
74
 
-
 
75
still:
74
 
76
 
-
 
77
    mov  eax,23 		; wait here for event
-
 
78
    mov  ebx,1
-
 
79
    mcall
-
 
80
 
-
 
81
    cmp  eax,1			; redraw request ?
-
 
82
    je	 red
-
 
83
    cmp  eax,2			; key in buffer ?
-
 
84
    je	 key
-
 
85
    cmp  eax,3			; button in buffer ?
-
 
86
    je	 button
-
 
87
 
-
 
88
    mov  eax,63
75
	cmp	eax,3			; button in buffer ?
89
    mov  ebx,2
76
	je	button
90
    mcall
-
 
91
 
-
 
92
    cmp  ebx,1
-
 
93
    jne  still
-
 
94
 
-
 
95
  new_data:
-
 
96
  if WRITE_LOG
-
 
97
     pusha
-
 
98
     mov  [tmp], al
-
 
99
     mov  edx, tmp
-
 
100
     mov  ecx, 1
-
 
101
     mov  esi, filename
-
 
102
  .write_to_logfile:
-
 
103
     call WriteToFile
-
 
104
     cmp  eax, 5
-
 
105
     jne  @f
-
 
106
     mov  esi, filename
-
 
107
     mov  [filepos], 0
-
 
108
     call CreateFile
-
 
109
     jnc  .write_to_logfile
-
 
110
  @@:
-
 
111
     inc  [filepos]
-
 
112
     popa
-
 
113
  end if
-
 
114
 
-
 
115
    mov  ebp,[targ]
-
 
116
  .no4:
-
 
117
    cmp  al,13
-
 
118
    jne  no13
-
 
119
    and  dword[ebp-8],0
-
 
120
    jmp  new_check
-
 
121
   no13:
-
 
122
    cmp  al,10
-
 
123
    jne  no10
-
 
124
    and  dword[ebp-8],0
-
 
125
    inc  dword[ebp-4]
-
 
126
    cmp  dword[ebp-4],MAXSTRINGS
-
 
127
    jbe  .noypos
-
 
128
    mov  dword[ebp-4],MAXSTRINGS
-
 
129
    lea  esi,[ebp+80]
-
 
130
    mov  edi,ebp
-
 
131
    mov  ecx,80*(MAXSTRINGS)
-
 
132
    cld
-
 
133
    rep  movsb
-
 
134
 
-
 
135
    mov  esi,[ebp-4]
-
 
136
    imul esi,80
-
 
137
    add  esi,[ebp-8]
-
 
138
    add  esi,ebp
-
 
139
    mov  ecx,80
-
 
140
    xor  al,al
-
 
141
    rep  stosb
-
 
142
  .noypos:
-
 
143
    mov  [targ],text2
-
 
144
    and  [krnl_cnt],0
-
 
145
    jmp  new_check
-
 
146
  no10:
-
 
147
    cmp  ebp,text1
-
 
148
    je	 add2
-
 
149
		mov  ecx,[krnl_cnt]
-
 
150
		  cmp  al,[krnl_msg+ecx]
-
 
151
		jne  .noknl
-
 
152
		  inc  [krnl_cnt]
-
 
153
		cmp  [krnl_cnt],4
-
 
154
		jne  new_check
-
 
155
    mov  [targ],text1
-
 
156
	.noknl:
-
 
157
    mov  ebp,[targ]
-
 
158
	   jecxz .add
-
 
159
    push eax
-
 
160
    mov  esi,krnl_msg
-
 
161
   .l1:
-
 
162
    lodsb
-
 
163
    call add_char
-
 
164
    loop .l1
-
 
165
    pop  eax
-
 
166
   .add:
-
 
167
    and  [krnl_cnt],0
-
 
168
  add2:
-
 
169
    call add_char
-
 
170
 
-
 
171
  new_check:
-
 
172
 
-
 
173
    mov  eax,63
-
 
174
    mov  ebx,2
-
 
175
    mcall
-
 
176
 
-
 
177
    cmp  ebx,1
-
 
178
    je	 new_data
-
 
179
 
-
 
180
    call draw_window
-
 
181
 
-
 
182
    jmp  still
-
 
183
 
-
 
184
  key:				; key
-
 
185
    mov  al,2		       ; just read it and ignore
-
 
186
    mcall
-
 
187
    cmp  ah,' '
-
 
188
    je	 button.noclose
-
 
189
    jmp  still
-
 
190
 
-
 
191
  button:			; button
-
 
192
    mov  al,17		       ; get id
-
 
193
    mcall
-
 
194
 
-
 
195
    cmp  ah,1			; button id=1 ?
-
 
196
    jne  .noclose
-
 
197
 
-
 
198
    or	 eax,-1 		; close this program
-
 
Line -... Line 77...
-
 
77
 
-
 
78
	mcall	63,2
-
 
79
	cmp	ebx,1
-
 
80
	jne	still
-
 
81
 
-
 
82
new_data:
-
 
83
if WRITE_LOG
-
 
84
	pusha
-
 
85
	mov	[tmp],al
-
 
86
	mov	edx,tmp
-
 
87
	mov	ecx,1
-
 
88
	mov	esi,filename
-
 
89
.write_to_logfile:
-
 
90
	call	WriteToFile
-
 
91
	cmp	eax,5
-
 
92
	jne	@f
-
 
93
	mov	esi,filename
-
 
94
	mov	[filepos],0
-
 
95
	call	CreateFile
-
 
96
	jnc	.write_to_logfile
-
 
97
@@:
-
 
98
	inc	[filepos]
-
 
99
	popa
-
 
100
end if
-
 
101
	mov	ebp,[targ]
-
 
102
.no4:
-
 
103
	cmp	al,13
-
 
104
	jne	no13
-
 
105
	and	[ebp-8],dword 0
-
 
106
	jmp	new_check
-
 
107
;------------------------------------------
-
 
108
no13:
-
 
109
	cmp	al,10
-
 
110
	jne	no10
-
 
111
	and	[ebp-8],dword 0
-
 
112
	inc	dword [ebp-4]
-
 
113
	cmp	[ebp-4],dword MAXSTRINGS
-
 
114
	jbe	.noypos
-
 
115
	mov	[ebp-4],dword MAXSTRINGS
-
 
116
	lea	esi,[ebp+80]
-
 
117
	mov	edi,ebp
-
 
118
	mov	ecx,80*(MAXSTRINGS)
-
 
119
	cld
-
 
120
	rep	movsb
-
 
121
 
-
 
122
	mov	esi,[ebp-4]
-
 
123
	imul	esi,80
-
 
124
	add	esi,[ebp-8]
-
 
125
	add	esi,ebp
-
 
126
	mov	ecx,80
-
 
127
	xor	al,al
-
 
128
	rep	stosb
-
 
129
.noypos:
-
 
130
	mov	[targ],text2
-
 
131
	and	[krnl_cnt],0
-
 
132
	jmp	new_check
-
 
133
;------------------------------------------
-
 
134
no10:
-
 
135
	cmp	ebp,text1
-
 
136
	je	add2
-
 
137
	mov	ecx,[krnl_cnt]
-
 
138
	cmp	al,[krnl_msg+ecx]
-
 
139
	jne	.noknl
-
 
140
	inc	[krnl_cnt]
-
 
141
	cmp	[krnl_cnt],4
-
 
142
	jne	new_check
-
 
143
	mov	[targ],text1
-
 
144
.noknl:
-
 
145
	mov	ebp,[targ]
-
 
146
	jecxz	.add
-
 
147
	push	eax
-
 
148
	mov	esi,krnl_msg
-
 
149
.l1:
-
 
150
	lodsb
-
 
151
	call	add_char
-
 
152
	loop	.l1
-
 
153
	pop	eax
-
 
154
.add:
-
 
155
	and	[krnl_cnt],0
-
 
156
add2:
-
 
157
	call	add_char
-
 
158
 
-
 
159
new_check:
-
 
160
	mcall	63,2
-
 
161
	cmp	ebx,1
-
 
162
	je	new_data
-
 
163
	call	draw_text
-
 
164
	jmp	still
-
 
165
;------------------------------------------------------------------------------
-
 
166
key:
-
 
167
	mcall	2
-
 
168
	cmp	ah,' '
-
 
169
	je	button.noclose
-
 
170
	jmp	still
-
 
171
;------------------------------------------------------------------------------
-
 
172
button:
-
 
173
	mcall	17	; get id
-
 
174
	cmp	ah,1		; button id=1 ?
-
 
175
	jne	.noclose
-
 
176
	or	eax,-1 		; close this program
199
    mcall
177
	mcall
200
  .noclose:
178
.noclose:
201
    xor  [vmode],1
179
	xor	[vmode],1
202
    jmp  red
180
	jmp	red
203
 
181
;------------------------------------------------------------------------------
204
add_char:
182
add_char:
205
    push esi
183
	push	esi
206
    mov  esi,[ebp-4]
184
	mov	esi,[ebp-4]
207
    imul esi,80
185
	imul	esi,80
208
    add  esi,[ebp-8]
186
	add	esi,[ebp-8]
209
    mov  [ebp+esi],al
187
	mov	[ebp+esi],al
210
    inc  dword[ebp-8]
188
	inc	dword[ebp-8]
211
    cmp  dword[ebp-8],80
189
	cmp	dword[ebp-8],80
212
    jb	 .ok
-
 
-
 
190
	jb	.ok
213
    mov  dword[ebp-8],79
191
	mov	dword[ebp-8],79
214
  .ok:
192
.ok:
215
    pop  esi
193
	pop	esi
216
    ret
-
 
217
 
-
 
218
;   *********************************************
194
	ret
219
;   *******  WINDOW DEFINITIONS AND DRAW ********
-
 
220
;   *********************************************
-
 
221
 
195
;------------------------------------------------------------------------------
222
 
-
 
223
draw_window:
-
 
224
 
-
 
225
    mov  eax,12 		   ; function 12:tell os about windowdraw
196
;   *********************************************
226
    mov  ebx,1			   ; 1, start of draw
-
 
227
    mcall
-
 
228
 
197
;   *******  WINDOW DEFINITIONS AND DRAW ********
229
				   ; DRAW WINDOW
198
;   *********************************************
230
    xor  eax,eax		     ; function 0 : define and draw window
199
draw_window:
231
;   mov  ebx,50*65536+400          ; [x start] *65536 + [x size]
-
 
232
    mov  ebx,[xstart]
-
 
233
    mov  ecx,MAXSTRINGS*10+45	   ; [y start] *65536 + [y size]
-
 
234
    mov  edx,[sc.work]		   ; color of work area RRGGBB,8->color gl
200
	mcall	12,1	; 1, start of draw
235
    or	 edx,0x13000000
201
	xor	eax,eax		     ; function 0 : define and draw window
236
    mov  edi,title		  ; WINDOW LABEL
202
	mov	ecx,MAXSTRINGS*10+45	   ; [y start] *65536 + [y size]
237
    mcall
-
 
238
 
203
	mov	edx,[sc.work]		   ; color of work area RRGGBB,8->color gl
239
    mov  ecx,4
204
	or	edx,0x13000000
240
    mov  esi,[sc.work]
205
	xor	esi,esi
241
    mov  ebx,296 shl 16+5*6
206
	mcall	,[xstart],,,,title
-
 
207
	mov	ebx,296 shl 16+5*6
-
 
208
	mcall	8,,<5,12>,3,[sc.work]
242
    mov  edx,3;+1 shl 30
209
	mov	edx,[vmode]
-
 
210
	lea	edx,[edx*4+duk]
-
 
211
	mcall	4,<300,8>,,,4
243
    mcall 8,,<5,12>
212
	call	draw_text
244
    mov  edx,[vmode]
213
	mcall	12,2	; 2, end of draw
-
 
214
	ret
-
 
215
;------------------------------------------------------------------------------
245
    lea  edx,[edx*4+duk]
216
draw_text:
246
    mcall 4,<300,8>,,,4
217
	mov	ebx,15*65536+30	   ; draw info text with function 4
247
 
218
	mov	ecx,[sc.work_text]
248
    mov  ebx,15*65536+33	   ; draw info text with function 4
219
	or	ecx,0x40000000
249
    mov  ecx,[sc.work_text]
220
	mov	edi,[sc.work]
-
 
221
	mov	edx,text1
-
 
222
	cmp	[vmode],0
-
 
223
	je	.kern
-
 
224
	mov	edx,text2
-
 
225
.kern:
-
 
226
	push	ebx ecx edx
-
 
227
	mcall	9,procinfo,-1
250
    mov  edx,text1
228
	mov	eax,[ebx+42]
-
 
229
	xor	edx,edx
-
 
230
	mov	ebx,6
-
 
231
	div	ebx
-
 
232
	pop	edx ecx ebx
-
 
233
	mov	esi,80
-
 
234
	cmp	eax,esi
-
 
235
	ja	@f
-
 
236
	mov	esi,eax
-
 
237
@@:
251
    cmp  [vmode],0
238
	cmp	esi,5
252
    je	 .kern
239
	ja	@f
253
    mov  edx,text2
240
	mov	esi,5
254
  .kern:
241
@@:
255
    mov  esi,80
242
	sub	esi,4
256
    mov  eax,4
243
	mov	eax,4
257
  newline:
244
newline:
258
    mcall
-
 
259
    add  ebx,10
-
 
260
    add  edx,80
-
 
261
    cmp  [edx],byte 'x'
-
 
262
    jne  newline
245
	mcall
263
    mov  eax,12 		   ; function 12:tell os about windowdraw
-
 
264
    mov  ebx,2			   ; 2, end of draw
-
 
-
 
246
	add	ebx,10
265
    mcall
247
	add	edx,80
266
 
248
	cmp	[edx],byte 'x'
267
    ret
249
	jne	newline
268
 
250
	ret
Line 269... Line 251...
269
 
251
;------------------------------------------------------------------------------    
270
if WRITE_LOG
252
if WRITE_LOG
271
;********************************************
253
;********************************************
272
;*  input:  esi = pointer to the file name  *
254
;*  input:  esi = pointer to the file name  *
273
;********************************************
255
;********************************************
274
 
256
 
275
CreateFile:
257
CreateFile:
276
    pusha
258
	pusha
277
    mov      dword [InfoStructure],    2   ; create file
259
	mov	dword [InfoStructure],2		; create file
278
    mov      dword [InfoStructure+4],  0   ; reserved
260
	mov	dword [InfoStructure+4],0	; reserved
279
    mov      dword [InfoStructure+8],  0   ; reserved
261
	mov	dword [InfoStructure+8],0	; reserved
280
    mov      dword [InfoStructure+12], 0   ; 0 bytes to write (just create)
262
	mov	dword [InfoStructure+12],0	; 0 bytes to write (just create)
281
    mov      dword [InfoStructure+16], 0   ; NULL data pointer (no data)
263
	mov	dword [InfoStructure+16],0	; NULL data pointer (no data)
282
    mov      dword [InfoStructure+20], 0   ; reserved
264
	mov	dword [InfoStructure+20],0	; reserved
283
    mov      dword [InfoStructure+21], esi ; pointer to the file name
265
	mov	dword [InfoStructure+21],esi	; pointer to the file name
284
    mcall    70, InfoStructure
266
	mcall	70, InfoStructure
285
    test     eax, eax
-
 
-
 
267
	test	eax,eax
286
    jz	     .out
268
	jz	.out
287
    stc
269
	stc
288
  .out:
270
.out:
289
    popa
271
	popa
290
    ret
272
	ret
Line 291... Line 273...
291
 
273
;------------------------------------------------
292
;********************************************
274
;********************************************
293
;*  input:  esi = pointer to the file name  *
275
;*  input:  esi = pointer to the file name  *
294
;*          edx = pointer to data buffer    *
276
;*          edx = pointer to data buffer    *
295
;*          ecx = data length               *
277
;*          ecx = data length               *
296
;********************************************
278
;********************************************
297
 
279
 
298
WriteToFile:
280
WriteToFile:
299
    push     ebx
281
	push	ebx
300
    mov      dword [InfoStructure],    3   ; write to file
282
	mov	dword [InfoStructure],3		; write to file
301
    mov      eax,  [filepos]
283
	mov	eax,  [filepos]
302
    mov      dword [InfoStructure+4],  eax ; lower position addr
284
	mov	dword [InfoStructure+4],eax	; lower position addr
303
    mov      dword [InfoStructure+8],  0   ; upper position addr (0 for FAT)
285
	mov	dword [InfoStructure+8],0	; upper position addr (0 for FAT)
304
    mov      dword [InfoStructure+12], ecx ; number of bytes to write
286
	mov	dword [InfoStructure+12],ecx	; number of bytes to write
305
    mov      dword [InfoStructure+16], edx ; pointer to data buffer
287
	mov	dword [InfoStructure+16],edx	; pointer to data buffer
306
    mov      dword [InfoStructure+20], 0   ; reserved
288
	mov	dword [InfoStructure+20],0	; reserved
307
    mov      dword [InfoStructure+21], esi ; pointer to the file name
289
	mov	dword [InfoStructure+21],esi	; pointer to the file name
308
    mcall    70, InfoStructure
290
	mcall	70, InfoStructure
309
    clc
-
 
310
    test     eax, eax
-
 
-
 
291
	clc
311
    jz	     .out
292
	test	eax,eax
312
    stc
293
	jz	.out
313
  .out:
294
	stc
314
    pop      ebx
295
.out:
315
    ret
296
	pop      ebx
316
 
297
	ret
317
 
298
;--------------------------------------------------
318
InfoStructure:
299
InfoStructure:
Line 319... Line 300...
319
		     dd      0x0     ; subfunction number
300
	dd 0x0	; subfunction number
320
		     dd      0x0     ; position in the file in bytes
301
	dd 0x0	; position in the file in bytes
321
		     dd      0x0     ; upper part of the position address
302
	dd 0x0	; upper part of the position address
322
		     dd      0x0     ; number of     bytes to read
303
	dd 0x0	; number of bytes to read
323
		     dd      0x0     ; pointer to the buffer to write data
-
 
324
		     db      0
-
 
325
		     dd      0	     ; pointer to the filename
-
 
326
 
-
 
-
 
304
	dd 0x0	; pointer to the buffer to write data
327
filepos  dd 0
305
	db 0
328
default_filename db '/sys/boardlog.txt',0
306
	dd 0	; pointer to the filename
Line 329... Line 307...
329
tmp	 db 0
307
 
Line 330... Line 308...
330
end if
308
filepos	dd 0
331
 
309
default_filename db '/sys/boardlog.txt',0
332
 
310
tmp	db 0
333
 
311
end if
334
 
312
;------------------------------------------------------------------------------
335
krnl_msg db 'K : '
313
krnl_msg db 'K : '
336
duk db 'KernUser'
314
duk db 'KernUser'
337
 
315
 
338
; DATA AREA
316
; DATA AREA
339
 
317
 
340
; 11,11 > 0,-1
318
; 11,11 > 0,-1
341
; 5,11  > 0,-1
319
; 5,11  > 0,-1
-
 
320
if lang eq ru
342
if lang eq ru
321
 title	db '„®áª  ®â« ¤ª¨ ¨ á®®¡é¥­¨©',0
-
 
322
else if lang eq en
343
   title    db	 '„®áª  ®â« ¤ª¨ ¨ á®®¡é¥­¨©',0
323
 title	db 'General debug & message board',0
344
else if lang eq en
324
else
345
   title    db	 'General debug & message board',0
325
 title	db 'Allgemeines debug- & nachrichtenboard',0
346
else
326
end if
347
   title    db	 'Allgemeines debug- & nachrichtenboard',0
327
krnl_cnt	dd 0
348
end if
328
vmode		dd 1
349
   krnl_cnt dd 0
329
targ		dd text2
350
   vmode dd 1
330
;------------------------------------------------------------------------------
351
   targ  dd text2
331
I_END:
352
I_END:
332
;------------------------------------------------------------------------------
353
     offs dd ?
333
offs	dd ?
354
     flag rb 1
334
flag	rb 1
355
     rd 2
335
	rd 2
-
 
336
;x1pos	dd ?
356
;     x1pos  dd ?
337
;y1pos	dd ?
-
 
338
text1	rb 80*(MAXSTRINGS+1)
357
;     y1pos  dd ?
339
tmp1	db ?
Line 358... Line 340...
358
     text1 rb 80*(MAXSTRINGS+1)
340
	rd 2
-
 
341
;x2pos	dd ?
-
 
342
;y2pos	dd ?
-
 
343
text2	rb 80*(MAXSTRINGS+1)
-
 
344
tmp2	db ?
-
 
345
xstart	dd ?
359
     tmp1  db ?
346
 
360
     rd 2
347
sc system_colors
-
 
348
 
361
;     x2pos  dd ?
349
i_end: