Subversion Repositories Kolibri OS

Rev

Rev 3586 | Rev 4672 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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