Subversion Repositories Kolibri OS

Rev

Rev 1998 | Rev 2743 | 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'
131 diamond 22
include 'debug.inc'
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
44
 
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'
52
 
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
59
if WRITE_LOG
60
	mov	esi,filename
61
	call	CreateFile
62
end if
63
;------------------------------------------------------------------------------
64
red:
65
	call draw_window
66
;------------------------------------------------------------------------------
31 halyavin 67
still:
2234 mario79 68
	mcall	23,1		; wait here for event
69
	cmp	eax,1			; redraw request ?
70
	je	red
31 halyavin 71
 
2234 mario79 72
	cmp	eax,2			; key in buffer ?
73
	je	key
31 halyavin 74
 
2234 mario79 75
	cmp	eax,3			; button in buffer ?
76
	je	button
447 heavyiron 77
 
2234 mario79 78
	mcall	63,2
79
	cmp	ebx,1
80
	jne	still
31 halyavin 81
 
2234 mario79 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
1571 Asper 121
 
2234 mario79 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
1571 Asper 158
 
2234 mario79 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
177
	mcall
178
.noclose:
179
	xor	[vmode],1
180
	jmp	red
181
;------------------------------------------------------------------------------
131 diamond 182
add_char:
2234 mario79 183
	push	esi
184
	mov	esi,[ebp-4]
185
	imul	esi,80
186
	add	esi,[ebp-8]
187
	mov	[ebp+esi],al
188
	inc	dword[ebp-8]
189
	cmp	dword[ebp-8],80
190
	jb	.ok
191
	mov	dword[ebp-8],79
192
.ok:
193
	pop	esi
194
	ret
195
;------------------------------------------------------------------------------
31 halyavin 196
;   *********************************************
197
;   *******  WINDOW DEFINITIONS AND DRAW ********
198
;   *********************************************
199
draw_window:
2234 mario79 200
	mcall	12,1	; 1, start of draw
201
	xor	eax,eax		     ; function 0 : define and draw window
202
	mov	ecx,MAXSTRINGS*10+45	   ; [y start] *65536 + [y size]
203
	mov	edx,[sc.work]		   ; color of work area RRGGBB,8->color gl
204
	or	edx,0x13000000
205
	xor	esi,esi
206
	mcall	,[xstart],,,,title
207
	mov	ebx,296 shl 16+5*6
208
	mcall	8,,<5,12>,3,[sc.work]
209
	mov	edx,[vmode]
210
	lea	edx,[edx*4+duk]
211
	mcall	4,<300,8>,,,4
212
	call	draw_text
213
	mcall	12,2	; 2, end of draw
214
	ret
215
;------------------------------------------------------------------------------
216
draw_text:
217
	mov	ebx,15*65536+30	   ; draw info text with function 4
218
	mov	ecx,[sc.work_text]
219
	or	ecx,0x40000000
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
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
@@:
238
	cmp	esi,5
239
	ja	@f
240
	mov	esi,5
241
@@:
242
	sub	esi,4
243
	mov	eax,4
244
newline:
245
	mcall
246
	add	ebx,10
247
	add	edx,80
248
	cmp	[edx],byte 'x'
249
	jne	newline
250
	ret
251
;------------------------------------------------------------------------------
1571 Asper 252
if WRITE_LOG
253
;********************************************
254
;*  input:  esi = pointer to the file name  *
255
;********************************************
256
 
257
CreateFile:
2234 mario79 258
	pusha
259
	mov	dword [InfoStructure],2		; create file
260
	mov	dword [InfoStructure+4],0	; reserved
261
	mov	dword [InfoStructure+8],0	; reserved
262
	mov	dword [InfoStructure+12],0	; 0 bytes to write (just create)
263
	mov	dword [InfoStructure+16],0	; NULL data pointer (no data)
264
	mov	dword [InfoStructure+20],0	; reserved
265
	mov	dword [InfoStructure+21],esi	; pointer to the file name
266
	mcall	70, InfoStructure
267
	test	eax,eax
268
	jz	.out
269
	stc
270
.out:
271
	popa
272
	ret
273
;------------------------------------------------
1571 Asper 274
;********************************************
275
;*  input:  esi = pointer to the file name  *
276
;*          edx = pointer to data buffer    *
277
;*          ecx = data length               *
278
;********************************************
279
 
280
WriteToFile:
2234 mario79 281
	push	ebx
282
	mov	dword [InfoStructure],3		; write to file
283
	mov	eax,  [filepos]
284
	mov	dword [InfoStructure+4],eax	; lower position addr
285
	mov	dword [InfoStructure+8],0	; upper position addr (0 for FAT)
286
	mov	dword [InfoStructure+12],ecx	; number of bytes to write
287
	mov	dword [InfoStructure+16],edx	; pointer to data buffer
288
	mov	dword [InfoStructure+20],0	; reserved
289
	mov	dword [InfoStructure+21],esi	; pointer to the file name
290
	mcall	70, InfoStructure
291
	clc
292
	test	eax,eax
293
	jz	.out
294
	stc
295
.out:
296
	pop      ebx
297
	ret
298
;--------------------------------------------------
1571 Asper 299
InfoStructure:
2234 mario79 300
	dd 0x0	; subfunction number
301
	dd 0x0	; position in the file in bytes
302
	dd 0x0	; upper part of the position address
303
	dd 0x0	; number of bytes to read
304
	dd 0x0	; pointer to the buffer to write data
305
	db 0
306
	dd 0	; pointer to the filename
1571 Asper 307
 
2234 mario79 308
filepos	dd 0
1996 clevermous 309
default_filename db '/sys/boardlog.txt',0
2234 mario79 310
tmp	db 0
1571 Asper 311
end if
2234 mario79 312
;------------------------------------------------------------------------------
131 diamond 313
krnl_msg db 'K : '
1997 clevermous 314
duk db 'KernUser'
131 diamond 315
 
31 halyavin 316
; DATA AREA
317
 
131 diamond 318
; 11,11 > 0,-1
319
; 5,11  > 0,-1
31 halyavin 320
if lang eq ru
2234 mario79 321
 title	db 'Доска отладки и сообщений',0
135 diamond 322
else if lang eq en
2234 mario79 323
 title	db 'General debug & message board',0
135 diamond 324
else
2234 mario79 325
 title	db 'Allgemeines debug- & nachrichtenboard',0
31 halyavin 326
end if
2234 mario79 327
krnl_cnt	dd 0
328
vmode		dd 1
329
targ		dd text2
330
;------------------------------------------------------------------------------
31 halyavin 331
I_END:
2234 mario79 332
;------------------------------------------------------------------------------
333
offs	dd ?
334
flag	rb 1
335
	rd 2
336
;x1pos	dd ?
337
;y1pos	dd ?
338
text1	rb 80*(MAXSTRINGS+1)
339
tmp1	db ?
340
	rd 2
341
;x2pos	dd ?
342
;y2pos	dd ?
343
text2	rb 80*(MAXSTRINGS+1)
344
tmp2	db ?
345
xstart	dd ?
346
 
347
sc system_colors
348
 
131 diamond 349
i_end:
1996 clevermous 350
 
2234 mario79 351
filename	rb 256
352
;------------------------------------------------------------------------------
1997 clevermous 353
align 4
2234 mario79 354
procinfo:
355
	rb 1024
356
;------------------------------------------------------------------------------
357
align 4
358
stackbuf	rb 2000h
359
;------------------------------------------------------------------------------
1997 clevermous 360
mem: