Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
2322 art_zh 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
431 serge 2
;;                                                              ;;
2522 art_zh 3
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
4
;;   Distributed FOR KOLIBRIOS AND ITS DIRECT BRANCHES ONLY     ;;
5
;;     under conditions of the GNU General Public License       ;;
431 serge 6
;;                                                              ;;
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8
 
593 mikedld 9
$Revision: 2956 $
10
 
803 alver 11
align 4
2014 art_zh 12
dtext_asciiz_esi:			   ; for skins title out
803 alver 13
    push eax
14
    xor eax, eax
15
    inc eax
16
    jmp    dtext.1
593 mikedld 17
 
1 ha 18
align 4
2014 art_zh 19
dtext:	; Text String Output (rw by Johnny_B[john@kolibrios.org])
20
	; ebx x & y
21
	; ecx style ( 0xX0000000 ) & color ( 0x00RRGGBB )
22
	; X = ABnnb:
23
	; nn = font
24
	; A = 0 <=> output esi characters; otherwise output ASCIIZ string
25
	; B = 1 <=> fill background with color eax
26
	; edx start of text
27
	; edi 1 force
1 ha 28
 
2522 art_zh 29
	test	ecx, 0x20000000
30
	jnz	.font3
31
 
803 alver 32
       push eax
2014 art_zh 33
	xor	eax, eax
803 alver 34
.1:
2014 art_zh 35
	pushad
36
	call	[_display.disable_mouse]
1 ha 37
 
2014 art_zh 38
	movsx	eax, bx 	; eax=y
39
	sar	ebx, 16 	; ebx=x
40
	xchg	eax, ebx	; eax=x, ebx=y
41
	cmp	esi, 255
42
	jb	.loop
43
	mov	esi, 255
139 diamond 44
.loop:
2014 art_zh 45
	test	ecx, ecx
46
	js	.test_asciiz
47
	dec	esi
48
	js	.end
49
	jmp	@f
139 diamond 50
.test_asciiz:
2014 art_zh 51
	cmp	byte [edx], 0
52
	jz	.end
53
	cmp byte [esp+28], 1	;  was the entry point = dtext.1 ?
54
	jne   @f
55
	dec	esi
56
	js	  .end
139 diamond 57
@@:
2014 art_zh 58
	inc	edx
59
	pushad			; esp -= 64 !
60
	movzx	edx, byte [edx-1]
61
	test	ecx, 0x10000000
62
	jnz	.font2
63
	mov	esi, 9
64
	lea	ebp, [FONT_I+8*edx+edx]
139 diamond 65
.symloop1:
2014 art_zh 66
	mov	dl, byte [ebp]
67
	or	dl, 1 shl 6
139 diamond 68
.pixloop1:
2014 art_zh 69
	shr	dl, 1
70
	jz	.pixloop1end
71
	jnc	.nopix
72
	call	[putpixel]
73
	jmp	.pixloop1cont
12 halyavin 74
.nopix:
2014 art_zh 75
	test	ecx, 0x40000000
76
	jz	.pixloop1cont
77
	push	ecx
78
	mov	ecx, [esp+4+20h+20h]	; original eax?
79
	call	[putpixel]
80
	pop	ecx
139 diamond 81
.pixloop1cont:
2014 art_zh 82
	inc	eax
83
	jmp	.pixloop1
139 diamond 84
.pixloop1end:
2014 art_zh 85
	sub	eax, 6
86
	inc	ebx
87
	inc	ebp
88
	dec	esi
89
	jnz	.symloop1
90
	popad
91
	add	eax, 6
92
	jmp	.loop
2522 art_zh 93
 
139 diamond 94
.font2:
2014 art_zh 95
	add	edx, edx
96
	lea	ebp, [FONT_II+4*edx+edx+1]
97
	push	9
98
	movzx	esi, byte [ebp-1]
139 diamond 99
.symloop2:
2014 art_zh 100
	mov	dl, byte [ebp]
101
	push	esi
139 diamond 102
.pixloop2:
2014 art_zh 103
	shr	dl, 1
104
	jnc	.nopix2
105
	call	[putpixel]
106
	jmp	.pixloop2cont
139 diamond 107
.nopix2:
2014 art_zh 108
	test	ecx, 0x40000000
109
	jz	.pixloop2cont
110
	push	ecx
111
	mov	ecx, [esp+12+20h+20h]
112
	call	[putpixel]
113
	pop	ecx
139 diamond 114
.pixloop2cont:
2014 art_zh 115
	inc	eax
116
	dec	esi
117
	jnz	.pixloop2
118
	pop	esi
119
	sub	eax, esi
120
	inc	ebx
121
	inc	ebp
122
	dec	dword [esp]
123
	jnz	.symloop2
124
	pop	eax
125
	add	dword [esp+28], esi
126
	popad
127
	jmp	.loop
139 diamond 128
.end:
2014 art_zh 129
	popad
2522 art_zh 130
	pop  eax
2014 art_zh 131
	ret
2318 art_zh 132
 
2322 art_zh 133
diff10 "old font  code size",dtext,$
134
 
2318 art_zh 135
;=====================================================
136
; NEW FONTS
137
;_____________________________________________________
138
;
2522 art_zh 139
align 4
140
.font3:
141
	pushad
142
	call	[_display.disable_mouse]
143
	movsx	eax, bx 	; eax=y
144
	sar	ebx, 16 	; ebx=x
145
	xchg	eax, ebx	; eax=x, ebx=y
2318 art_zh 146
 
2522 art_zh 147
	xor	ebp, ebp	; font#
148
	mov	[font_check_routine], ebp
2956 art_zh 149
;        inc     ebp
2522 art_zh 150
 
151
	test	ecx, ecx
152
	js	.checked
153
	inc	[font_check_routine];  .check_esi
154
.checked:
155
	mov	edi, ecx	; colour
156
	and	edi, 0x0FFFFFF	; RGB
157
align 4
158
.draw_char:
159
	mov	cl,  byte[edx]	; char#
160
	movzx	ecx, cl
161
	call	nsvf_draw_char
162
	add	eax, 6
163
	test	[font_check_routine], 1
164
	jz	.check_asciz
165
 
166
.check_esi:
167
	inc	edx
168
	dec	esi
169
	jz	.exit
170
	jmp   .draw_char
171
 
172
align 4
173
.check_asciz:
174
	or	byte[edx], 0
175
	jz	.exit
176
	inc	edx
177
	jmp   .draw_char
178
 
179
align 4
180
.exit:
181
	popad
182
	ret
183
 
184
align 4
185
 
186
font_check_routine  dd ?
187
 
188
 
189
 
2318 art_zh 190
align 8
2956 art_zh 191
nsvf_data:
2318 art_zh 192
 
2461 art_zh 193
diff16 "sdsh_data      : ",0,$
194
 
2322 art_zh 195
include 'fonts/sd_data.asm'
2318 art_zh 196
 
2956 art_zh 197
nsvf_code:
2318 art_zh 198
 
2461 art_zh 199
; eax   =       if (bit[31])
200
;                               then lower 31 bits points to the user-selected font
201
;                               else ax = number of preloaded system font
202
; ebx   =       x<<16 + y
203
; ecx   =       0x00RRGGBB
204
; edx   =       if (bits[31:8] == 0)
205
;                               then dl = single char to write
206
;                               else edx= pointer to asciiz-string
2318 art_zh 207
 
2461 art_zh 208
diff16 "draw_char      : ",0,$
209
 
2322 art_zh 210
draw_char:
211
; font test
212
; bl=y; bh=x
213
; dl=ascii
2461 art_zh 214
	movzx	eax, bh
215
	movzx	ebx, bl
216
	movzx	ecx, dl
217
	xor	edi, edi
218
	mov	ebp, edi
219
 
220
 
2522 art_zh 221
nsvf_draw_char:
2318 art_zh 222
; eax = left side X
223
; ebx = bottom Y
2522 art_zh 224
; edi = colour 0x0RRGGBB
2956 art_zh 225
; ebp = font#
2318 art_zh 226
; ecx = ascii, zero-extended to 32bits
2461 art_zh 227
	push	ecx
228
	push	edx
229
	push	ebp
2956 art_zh 230
	shl	ebp, 5
231
	add	ebp, nsvf_info
2522 art_zh 232
	call   ch_checkscreen
233
	jb	       .exit
234
	call   ch_checkwin
235
	jc	       .exit
2461 art_zh 236
	mov	edx, [ebp + 4]		    ; chartable addr
237
	mov	cx, word[edx + ecx*2]	    ; tick info
2956 art_zh 238
	and   cx, 0xFFE7		  ; bits 3,4 used for width control
2461 art_zh 239
	mov	edx, ecx
240
	and	ecx, 7			    ; cl = number of ticks
241
	jz	.blank
242
	shr	edx, 4			    ; offset in the chartable
2956 art_zh 243
	add	edx, [ebp + 12] 	    ; edx -> the char's ticklist
2318 art_zh 244
.next_tick:
2461 art_zh 245
	call	parse_tick
246
	add	edx, 2
247
	dec	cl
248
	jnz	.next_tick
2318 art_zh 249
.blank:
250
.exit:
2461 art_zh 251
	pop	ebp
252
	pop	edx
253
	pop	ecx
254
	ret
2318 art_zh 255
 
256
 
257
parse_tick:
2461 art_zh 258
diff16 "parse_tick     : ",0,$
2318 art_zh 259
; eax = left side X
260
; ebx = bottom Y
261
; edx ->tickinfo
262
; edi = color 0x0RRGGBB
2461 art_zh 263
; ebp = font's header
264
	pushad
265
	mov	dx, word[edx]
2470 art_zh 266
	movzx	ecx, dl
2522 art_zh 267
	test	dl, 0xE0
268
	jz	.lntick.short	; ticks #0..31
2461 art_zh 269
	cmp	dl, 0xE0
2522 art_zh 270
	jae	.lntick.long	; ticks #224..255
2499 art_zh 271
	cmp	dl, 0xD8
2522 art_zh 272
	jae	.cstick 	; ticks #216..223
2318 art_zh 273
.gptick:
2461 art_zh 274
	push	edx
2499 art_zh 275
	cmp	dl, 38
2522 art_zh 276
	jb	.sptick 	    ; special ticks #32-37
277
				    ; general ticks #38..215
2461 art_zh 278
	mov	cl, dh
2499 art_zh 279
	shr	cl, 3		    ; number of origin
2461 art_zh 280
	mov	edx, [ebp+8]	    ; orig. table
281
	mov	ch, byte[edx+ecx]   ; orig. coords
282
	pop	edx
283
	mov	cl, dh
2470 art_zh 284
	and	cl, 7		    ; three rotation bits
2499 art_zh 285
	movzx	edx, dl 	    ; dl = gptick#
286
	cmp	dl, 80
2461 art_zh 287
	jae	.gptick.2
2499 art_zh 288
	sub	dl, 38
2470 art_zh 289
 
2320 art_zh 290
.gptick.1:
2470 art_zh 291
	;  1-byte tickgroups .v1-v4:
2956 art_zh 292
	lea	esi, [nsvf.v1+edx]
2522 art_zh 293
	inc	dh		  ; dh = 1 vertex
2499 art_zh 294
	sub	dl, 2			; .v1 : 2 ticks only (#38, 39)
2470 art_zh 295
	jae	.gptick.1v2v4
2461 art_zh 296
	mov	dl, dh
2470 art_zh 297
	mov	dh, ch
298
	jmp	.draw
299
 
300
.gptick.1v2v4:
2499 art_zh 301
	; 1-byte tickgroups .v2-v4 : 8, 16 and 16 ticks
2522 art_zh 302
	inc	dh		 ; dh = 2 vertice
303
	add	dl, 8
2499 art_zh 304
	shr	dl, 4
2461 art_zh 305
	jmp	.gptick.done
2470 art_zh 306
 
2320 art_zh 307
.gptick.2:
2470 art_zh 308
	; 2-byte tickgroups .v5-v8: 8 ticks each
2499 art_zh 309
	cmp	dl, 112
2461 art_zh 310
	jae	.gptick.3
2499 art_zh 311
	sub	dl, 80
2956 art_zh 312
	lea	esi, [nsvf.v5 + edx*2]
2461 art_zh 313
	mov	dh, 5
314
	shr	dl, 3
315
	jmp	.gptick.done
2470 art_zh 316
 
2320 art_zh 317
.gptick.3:
2470 art_zh 318
	; 3-byte tickgroups .v9-12: 4 ticks each
2499 art_zh 319
	cmp	dl, 128
2461 art_zh 320
	jae	.gptick.4
2499 art_zh 321
	sub	dl, 112
2956 art_zh 322
	lea	esi, [nsvf.v9 + edx*2 + edx]
2461 art_zh 323
	mov	dh, 9
324
	shr	dl, 2
325
	jmp	.gptick.done
2470 art_zh 326
 
2320 art_zh 327
.gptick.4:
2470 art_zh 328
	; 4-byte tickgroups .v13-16: 4 ticks each
2522 art_zh 329
	cmp	dl, 128 		; fix this when needed
330
	jae	.exit			; not implemented yet!
2499 art_zh 331
	sub	dl, 128
2956 art_zh 332
	lea	esi, [nsvf.v13 + edx*4]
2461 art_zh 333
	mov	dh, 13
334
	shr	dl, 2
2470 art_zh 335
 
336
.gptick.done:
2461 art_zh 337
	add	dl, dh
338
	mov	dh, ch			; dh = orig.XY;     dl = numvert
2470 art_zh 339
	jmp	.draw			; cl = rotation;   esi-> tickfield
2461 art_zh 340
 
2318 art_zh 341
.cstick:
2461 art_zh 342
	and	cl, 4
343
	shr	cl, 2			; only one rotational bit
344
	and	dl, 3
345
	jz	.cstick.0
346
	dec	dl
347
	jnz	@f
348
	mov	dl, 6
2470 art_zh 349
	jz	.cstick.1		; 8-pix square outline
2461 art_zh 350
@@:	dec	dl
351
	jz	.cstick.2
2318 art_zh 352
.cstick.3:
2956 art_zh 353
	mov	esi, nsvf_data.cs3	; 12pix-ring
2461 art_zh 354
	mov	dl, 10
355
	jmp	.draw
2318 art_zh 356
.cstick.2:
2470 art_zh 357
	mov	dl, 7			; 9-pix filled square
2318 art_zh 358
.cstick.1:
2956 art_zh 359
	mov	esi, nsvf_data.cs2	; the square tickfield
2461 art_zh 360
	jmp	.draw
2321 art_zh 361
.cstick.0:
2956 art_zh 362
	mov	esi, nsvf_data.cs0	; 4pix-square
2470 art_zh 363
	mov	dl, 2
2461 art_zh 364
	jmp	.draw
2318 art_zh 365
 
366
.ritick:
2461 art_zh 367
	test	dl, 1
368
	jnz	.ritick.1
2318 art_zh 369
.ritick.0:
2499 art_zh 370
	movzx	ecx, dh 	    ; y
2461 art_zh 371
	and	cl, 0x0F
372
	sub	ebx, ecx
373
	mov	cl, dh
374
	shr	cl, 4		    ; x
375
	add	eax, ecx
376
	call	ch_putpixel
377
	jmp	.exit
2318 art_zh 378
.ritick.1:
2956 art_zh 379
	mov	esi, nsvf_data.ri1  ; 8pix-ring
2470 art_zh 380
	mov	dl, 6
2461 art_zh 381
	jmp	.draw
382
 
2318 art_zh 383
.lntick.short:
2461 art_zh 384
	test	dl, 0x06	    ; ticks #0, 1 are reserved for
385
	jz	.ritick 	    ;             rotational invariants
386
	and	dl, 0x07	    ; dl = line length
387
	jmp	.lntick.both
2318 art_zh 388
.lntick.long:
2461 art_zh 389
	and	dl, 0x07
390
	add	dl, 8
2318 art_zh 391
.lntick.both:
2461 art_zh 392
	sub	dl, 2		    ; num_vertice = num_points - 2
393
	and	cl, 0x18	    ; two (lower) rotation bits
394
	shr	cl, 3
2956 art_zh 395
	mov	esi, nsvf_data.blank
2470 art_zh 396
 
2318 art_zh 397
.draw:
2461 art_zh 398
; cl = rot; dl = numvert; dh = orig.xy
399
	push	ecx
2499 art_zh 400
	movzx	ecx, dh 	    ; y
2461 art_zh 401
	and	cl, 0x0F
402
	sub	ebx, ecx
403
	mov	cl, dh
404
	shr	cl, 4		    ; x
405
	add	eax, ecx
406
	pop	ecx
407
	call	draw_tick
2320 art_zh 408
.gptick.5:
2499 art_zh 409
.sptick:
2318 art_zh 410
.exit:
2461 art_zh 411
	popad
412
	ret
2318 art_zh 413
 
2461 art_zh 414
 
415
diff16 "draw_tick      : ",0,$
416
 
2318 art_zh 417
draw_tick:
418
; eax = x-origin
419
; ebx = y-origin
2461 art_zh 420
; edi = 0x0RRGGBB
421
;  cl = direction (0..7)
422
;  dl = number of vertice  (dl)
423
; esi -> tick bitfield
2318 art_zh 424
 
425
	pushad
2461 art_zh 426
	call	ch_putpixel			; the point of origin
427
	and	ecx, 7
428
	lea	ebp, [.move000+ ecx*4]
429
	call	ebp		      ; basic vector
430
	call	ch_putpixel
2499 art_zh 431
	and	edx, 15
432
	jz	.done		       ; no vertex (2pix line)
433
	mov	esi, dword [esi]       ; 15 vertice will easily fit to 1dw
434
	xchg	esi, edx
2318 art_zh 435
.move_and_draw:
2499 art_zh 436
	mov	ch, dl
437
	and	ch, 3
438
	jz	.moved
439
	dec	ch
440
	jz	.1
441
	dec	ch
442
	jz	.2
443
.3:
444
	dec	cl
2320 art_zh 445
.1:
2499 art_zh 446
	dec	cl
447
	jmp	.wipe_it
2320 art_zh 448
.2:
2499 art_zh 449
	inc	cl
2461 art_zh 450
.wipe_it:
2499 art_zh 451
	and	ecx, 7
2320 art_zh 452
.moved:
2461 art_zh 453
diff16 "moved          : ",0,$
454
	lea	ebp, [.move000+ ecx*4]
455
	call	ebp		    ; go new way
456
	call	ch_putpixel
2499 art_zh 457
	shr	edx, 2
458
	dec	esi
459
	jnz	.move_and_draw
2461 art_zh 460
diff16 "done           : ",0,$
2318 art_zh 461
.done:
462
	popad
463
	ret
464
 
2461 art_zh 465
; WARNING! The order matters! ------
466
align 4
467
diff16 "move000        : ",0,$
2318 art_zh 468
.move000:
469
	inc		eax
470
	ret
2461 art_zh 471
align 4
2318 art_zh 472
.move001:
473
	inc		eax
2320 art_zh 474
	dec		ebx
2318 art_zh 475
	ret
2461 art_zh 476
align 4
2318 art_zh 477
.move010:
2320 art_zh 478
	dec		ebx
2318 art_zh 479
	ret
2461 art_zh 480
align 4
2318 art_zh 481
.move011:
482
	dec		eax
2320 art_zh 483
	dec		ebx
2318 art_zh 484
	ret
2461 art_zh 485
align 4
2320 art_zh 486
.move100:
2318 art_zh 487
	dec		eax
488
	ret
2461 art_zh 489
align 4
2320 art_zh 490
.move101:
2318 art_zh 491
	dec		eax
2320 art_zh 492
	inc		ebx
2318 art_zh 493
	ret
2461 art_zh 494
align 4
2320 art_zh 495
.move110:
496
	inc		ebx
2318 art_zh 497
	ret
2461 art_zh 498
 
499
align 4
500
diff10 "move111-move000 (must be 28!)  : ",.move000,$
2320 art_zh 501
.move111:
2318 art_zh 502
	inc		eax
2320 art_zh 503
	inc		ebx
2318 art_zh 504
	ret
505
 
2461 art_zh 506
;) ---------------
2318 art_zh 507
 
508
align 4
2461 art_zh 509
diff16 "checkscreen    : ",0,$
2318 art_zh 510
ch_checkscreen:
511
     cmp	[Screen_Max_X], eax
2461 art_zh 512
     jb 	.getout
2318 art_zh 513
     cmp	[Screen_Max_Y], ebx
514
.getout:
515
     ret
516
 
517
align 4
2461 art_zh 518
diff16 "checkwin       : ",0,$
2318 art_zh 519
ch_checkwin:
520
; eax = x coordinate
521
; ebx = y coordinate
522
; ebp -> font info
2522 art_zh 523
 
2461 art_zh 524
	push	eax
525
	push	ebx
2522 art_zh 526
	push	ecx
527
	push	edx
2461 art_zh 528
	mov	ch,  byte[CURRENT_TASK]
529
	mov	edx, [_display.width]	    ; screen X-size
530
	imul	edx, ebx
531
	add	edx, [_WinMapAddress]
532
	add	edx, eax
533
	cmp	ch,  byte [edx]
534
	jne	.fail
2522 art_zh 535
	movzx	eax, byte [ebp] 	    ; char X-width
2461 art_zh 536
	cmp	ch,  byte [edx+eax]
537
	jne	.fail
538
	movzx	ebx, byte [ebp+1]
539
	imul	ebx, [_display.width]
540
	cmp	ch,  byte [edx+ebx]
541
	jne	.fail
542
	add	edx, eax
543
	cmp	ch,  byte [edx+ebx]
544
	clc
545
	je     .done
546
.fail:
547
	stc				    ; CF means the charbox is invisible
2318 art_zh 548
.done:
2522 art_zh 549
	pop	edx
550
	pop	ecx
2461 art_zh 551
	pop	ebx
552
	pop	eax
553
	ret
2318 art_zh 554
 
555
align 4
2461 art_zh 556
diff16 "ch_putpix      : ",0,$
2522 art_zh 557
 ch_putpixel:
2318 art_zh 558
; eax = x coordinate
559
; ebx = y coordinate
2461 art_zh 560
; edi = 0x0RRGGBB
2318 art_zh 561
     push   edx
562
	 mov	edx, ebx
563
     imul	edx, [BytesPerScanLine]
564
     lea	edx, [edx+eax*4]
565
     mov   [LFB_BASE+edx], edi
2322 art_zh 566
     pop    edx
2318 art_zh 567
     ret
568
;)
2522 art_zh 569
;ch_putpixel2:
2499 art_zh 570
; test version!!! ===== to be removed!!
571
; eax = x coordinate
572
; ebx = y coordinate
573
; edi = 0x0RRGGBB
574
     push   edx
575
	 mov	edx, ebx
576
	shl	edx, 1
577
     imul	edx, [BytesPerScanLine]
578
     lea	edx, [edx+eax*8]
579
	add	edx, LFB_BASE
580
     mov   [edx], edi
581
	mov	[edx+4], edi
582
	sub	edx, [BytesPerScanLine]
583
	mov	[edx], edi
584
	mov	[edx+4], edi
585
     pop    edx
586
     ret
2318 art_zh 587
 
2322 art_zh 588
 
2956 art_zh 589
diff10 "new font  code size",nsvf_code,$