Subversion Repositories Kolibri OS

Rev

Rev 2743 | Rev 3586 | 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
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]
2484 mario79 203
;	mov	edx,[sc.work]		   ; color of work area RRGGBB,8->color gl
204
	mov	edx,0xffffff
2743 dunkaist 205
	or	edx,0x14000000
2234 mario79 206
	xor	esi,esi
207
	mcall	,[xstart],,,,title
208
	mov	ebx,296 shl 16+5*6
209
	mcall	8,,<5,12>,3,[sc.work]
210
	mov	edx,[vmode]
211
	lea	edx,[edx*4+duk]
212
	mcall	4,<300,8>,,,4
213
	call	draw_text
214
	mcall	12,2	; 2, end of draw
215
	ret
216
;------------------------------------------------------------------------------
217
draw_text:
218
	mov	ebx,15*65536+30	   ; draw info text with function 4
2484 mario79 219
;	mov	ecx,[sc.work_text]
220
	xor	ecx,ecx
2234 mario79 221
	or	ecx,0x40000000
2484 mario79 222
;	mov	edi,[sc.work]
223
	mov	edi,0xffffff
2234 mario79 224
	mov	edx,text1
225
	cmp	[vmode],0
226
	je	.kern
227
	mov	edx,text2
228
.kern:
229
	push	ebx ecx edx
230
	mcall	9,procinfo,-1
231
	mov	eax,[ebx+42]
232
	xor	edx,edx
233
	mov	ebx,6
234
	div	ebx
235
	pop	edx ecx ebx
236
	mov	esi,80
237
	cmp	eax,esi
238
	ja	@f
239
	mov	esi,eax
240
@@:
241
	cmp	esi,5
242
	ja	@f
243
	mov	esi,5
244
@@:
245
	sub	esi,4
246
	mov	eax,4
247
newline:
248
	mcall
249
	add	ebx,10
250
	add	edx,80
251
	cmp	[edx],byte 'x'
252
	jne	newline
253
	ret
254
;------------------------------------------------------------------------------
1571 Asper 255
if WRITE_LOG
256
;********************************************
257
;*  input:  esi = pointer to the file name  *
258
;********************************************
259
 
260
CreateFile:
2234 mario79 261
	pusha
262
	mov	dword [InfoStructure],2		; create file
263
	mov	dword [InfoStructure+4],0	; reserved
264
	mov	dword [InfoStructure+8],0	; reserved
265
	mov	dword [InfoStructure+12],0	; 0 bytes to write (just create)
266
	mov	dword [InfoStructure+16],0	; NULL data pointer (no data)
267
	mov	dword [InfoStructure+20],0	; reserved
268
	mov	dword [InfoStructure+21],esi	; pointer to the file name
269
	mcall	70, InfoStructure
270
	test	eax,eax
271
	jz	.out
272
	stc
273
.out:
274
	popa
275
	ret
276
;------------------------------------------------
1571 Asper 277
;********************************************
278
;*  input:  esi = pointer to the file name  *
279
;*          edx = pointer to data buffer    *
280
;*          ecx = data length               *
281
;********************************************
282
 
283
WriteToFile:
2234 mario79 284
	push	ebx
285
	mov	dword [InfoStructure],3		; write to file
286
	mov	eax,  [filepos]
287
	mov	dword [InfoStructure+4],eax	; lower position addr
288
	mov	dword [InfoStructure+8],0	; upper position addr (0 for FAT)
289
	mov	dword [InfoStructure+12],ecx	; number of bytes to write
290
	mov	dword [InfoStructure+16],edx	; pointer to data buffer
291
	mov	dword [InfoStructure+20],0	; reserved
292
	mov	dword [InfoStructure+21],esi	; pointer to the file name
293
	mcall	70, InfoStructure
294
	clc
295
	test	eax,eax
296
	jz	.out
297
	stc
298
.out:
299
	pop      ebx
300
	ret
301
;--------------------------------------------------
1571 Asper 302
InfoStructure:
2234 mario79 303
	dd 0x0	; subfunction number
304
	dd 0x0	; position in the file in bytes
305
	dd 0x0	; upper part of the position address
306
	dd 0x0	; number of bytes to read
307
	dd 0x0	; pointer to the buffer to write data
308
	db 0
309
	dd 0	; pointer to the filename
1571 Asper 310
 
2234 mario79 311
filepos	dd 0
1996 clevermous 312
default_filename db '/sys/boardlog.txt',0
2234 mario79 313
tmp	db 0
1571 Asper 314
end if
2234 mario79 315
;------------------------------------------------------------------------------
131 diamond 316
krnl_msg db 'K : '
1997 clevermous 317
duk db 'KernUser'
131 diamond 318
 
31 halyavin 319
; DATA AREA
320
 
131 diamond 321
; 11,11 > 0,-1
322
; 5,11  > 0,-1
31 halyavin 323
if lang eq ru
2234 mario79 324
 title	db 'Доска отладки и сообщений',0
135 diamond 325
else if lang eq en
2234 mario79 326
 title	db 'General debug & message board',0
135 diamond 327
else
2234 mario79 328
 title	db 'Allgemeines debug- & nachrichtenboard',0
31 halyavin 329
end if
2234 mario79 330
krnl_cnt	dd 0
331
vmode		dd 1
332
targ		dd text2
333
;------------------------------------------------------------------------------
31 halyavin 334
I_END:
2234 mario79 335
;------------------------------------------------------------------------------
336
offs	dd ?
337
flag	rb 1
338
	rd 2
339
;x1pos	dd ?
340
;y1pos	dd ?
341
text1	rb 80*(MAXSTRINGS+1)
342
tmp1	db ?
343
	rd 2
344
;x2pos	dd ?
345
;y2pos	dd ?
346
text2	rb 80*(MAXSTRINGS+1)
347
tmp2	db ?
348
xstart	dd ?
349
 
350
sc system_colors
351
 
131 diamond 352
i_end:
1996 clevermous 353
 
2234 mario79 354
filename	rb 256
355
;------------------------------------------------------------------------------
1997 clevermous 356
align 4
2234 mario79 357
procinfo:
358
	rb 1024
359
;------------------------------------------------------------------------------
360
align 4
361
stackbuf	rb 2000h
362
;------------------------------------------------------------------------------
1997 clevermous 363
mem: