Subversion Repositories Kolibri OS

Rev

Rev 2499 | Rev 2956 | 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: 2522 $
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
149
 
150
	test	ecx, ecx
151
	js	.checked
152
	inc	[font_check_routine];  .check_esi
153
.checked:
154
	mov	edi, ecx	; colour
155
	and	edi, 0x0FFFFFF	; RGB
156
align 4
157
.draw_char:
158
	mov	cl,  byte[edx]	; char#
159
	movzx	ecx, cl
160
	call	nsvf_draw_char
161
	add	eax, 6
162
	test	[font_check_routine], 1
163
	jz	.check_asciz
164
 
165
.check_esi:
166
	inc	edx
167
	dec	esi
168
	jz	.exit
169
	jmp   .draw_char
170
 
171
align 4
172
.check_asciz:
173
	or	byte[edx], 0
174
	jz	.exit
175
	inc	edx
176
	jmp   .draw_char
177
 
178
align 4
179
.exit:
180
	popad
181
	ret
182
 
183
align 4
184
 
185
font_check_routine  dd ?
186
 
187
 
188
 
2318 art_zh 189
align 8
190
sdsh_data:
191
 
2461 art_zh 192
diff16 "sdsh_data      : ",0,$
193
 
2322 art_zh 194
include 'fonts/sd_data.asm'
2318 art_zh 195
 
196
sdsh_code:
197
 
2461 art_zh 198
; eax   =       if (bit[31])
199
;                               then lower 31 bits points to the user-selected font
200
;                               else ax = number of preloaded system font
201
; ebx   =       x<<16 + y
202
; ecx   =       0x00RRGGBB
203
; edx   =       if (bits[31:8] == 0)
204
;                               then dl = single char to write
205
;                               else edx= pointer to asciiz-string
2318 art_zh 206
 
2461 art_zh 207
diff16 "draw_char      : ",0,$
208
 
2322 art_zh 209
draw_char:
210
; font test
211
; bl=y; bh=x
212
; dl=ascii
2461 art_zh 213
	movzx	eax, bh
214
	movzx	ebx, bl
215
	movzx	ecx, dl
216
	xor	edi, edi
217
	mov	ebp, edi
218
 
219
 
2522 art_zh 220
nsvf_draw_char:
2318 art_zh 221
; eax = left side X
222
; ebx = bottom Y
2522 art_zh 223
; edi = colour 0x0RRGGBB
2461 art_zh 224
; ebp = font@
2318 art_zh 225
; ecx = ascii, zero-extended to 32bits
2461 art_zh 226
	push	ecx
227
	push	edx
228
	push	ebp
229
	shl	ebp, 4
230
	add	ebp, sdsh_data.info
2522 art_zh 231
	call   ch_checkscreen
232
	jb	       .exit
233
	call   ch_checkwin
234
	jc	       .exit
2461 art_zh 235
	mov	edx, [ebp + 4]		    ; chartable addr
236
	mov	cx, word[edx + ecx*2]	    ; tick info
237
	mov	edx, ecx
238
	and	ecx, 7			    ; cl = number of ticks
239
	jz	.blank
240
	shr	edx, 4			    ; offset in the chartable
241
	add	edx, sdsh_data.chars	    ; edx -> the char's ticklist
2318 art_zh 242
.next_tick:
2461 art_zh 243
	call	parse_tick
244
	add	edx, 2
245
	dec	cl
246
	jnz	.next_tick
2318 art_zh 247
.blank:
248
.exit:
2461 art_zh 249
	pop	ebp
250
	pop	edx
251
	pop	ecx
252
	ret
2318 art_zh 253
 
254
 
255
parse_tick:
2461 art_zh 256
diff16 "parse_tick     : ",0,$
2318 art_zh 257
; eax = left side X
258
; ebx = bottom Y
259
; edx ->tickinfo
260
; edi = color 0x0RRGGBB
2461 art_zh 261
; ebp = font's header
262
	pushad
263
	mov	dx, word[edx]
2470 art_zh 264
	movzx	ecx, dl
2522 art_zh 265
	test	dl, 0xE0
266
	jz	.lntick.short	; ticks #0..31
2461 art_zh 267
	cmp	dl, 0xE0
2522 art_zh 268
	jae	.lntick.long	; ticks #224..255
2499 art_zh 269
	cmp	dl, 0xD8
2522 art_zh 270
	jae	.cstick 	; ticks #216..223
2318 art_zh 271
.gptick:
2461 art_zh 272
	push	edx
2499 art_zh 273
	cmp	dl, 38
2522 art_zh 274
	jb	.sptick 	    ; special ticks #32-37
275
				    ; general ticks #38..215
2461 art_zh 276
	mov	cl, dh
2499 art_zh 277
	shr	cl, 3		    ; number of origin
2461 art_zh 278
	mov	edx, [ebp+8]	    ; orig. table
279
	mov	ch, byte[edx+ecx]   ; orig. coords
280
	pop	edx
281
	mov	cl, dh
2470 art_zh 282
	and	cl, 7		    ; three rotation bits
2499 art_zh 283
	movzx	edx, dl 	    ; dl = gptick#
284
	cmp	dl, 80
2461 art_zh 285
	jae	.gptick.2
2499 art_zh 286
	sub	dl, 38
2470 art_zh 287
 
2320 art_zh 288
.gptick.1:
2470 art_zh 289
	;  1-byte tickgroups .v1-v4:
290
	lea	esi, [sdsh_data.v1+edx]
2522 art_zh 291
	inc	dh		  ; dh = 1 vertex
2499 art_zh 292
	sub	dl, 2			; .v1 : 2 ticks only (#38, 39)
2470 art_zh 293
	jae	.gptick.1v2v4
2461 art_zh 294
	mov	dl, dh
2470 art_zh 295
	mov	dh, ch
296
	jmp	.draw
297
 
298
.gptick.1v2v4:
2499 art_zh 299
	; 1-byte tickgroups .v2-v4 : 8, 16 and 16 ticks
2522 art_zh 300
	inc	dh		 ; dh = 2 vertice
301
	add	dl, 8
2499 art_zh 302
	shr	dl, 4
2461 art_zh 303
	jmp	.gptick.done
2470 art_zh 304
 
2320 art_zh 305
.gptick.2:
2470 art_zh 306
	; 2-byte tickgroups .v5-v8: 8 ticks each
2499 art_zh 307
	cmp	dl, 112
2461 art_zh 308
	jae	.gptick.3
2499 art_zh 309
	sub	dl, 80
2470 art_zh 310
	lea	esi, [sdsh_data.v5 + edx*2]
2461 art_zh 311
	mov	dh, 5
312
	shr	dl, 3
313
	jmp	.gptick.done
2470 art_zh 314
 
2320 art_zh 315
.gptick.3:
2470 art_zh 316
	; 3-byte tickgroups .v9-12: 4 ticks each
2499 art_zh 317
	cmp	dl, 128
2461 art_zh 318
	jae	.gptick.4
2499 art_zh 319
	sub	dl, 112
2470 art_zh 320
	lea	esi, [sdsh_data.v9 + edx*2 + edx]
2461 art_zh 321
	mov	dh, 9
322
	shr	dl, 2
323
	jmp	.gptick.done
2470 art_zh 324
 
2320 art_zh 325
.gptick.4:
2470 art_zh 326
	; 4-byte tickgroups .v13-16: 4 ticks each
2522 art_zh 327
	cmp	dl, 128 		; fix this when needed
328
	jae	.exit			; not implemented yet!
2499 art_zh 329
	sub	dl, 128
2470 art_zh 330
	lea	esi, [sdsh_data.v13 + edx*4]
2461 art_zh 331
	mov	dh, 13
332
	shr	dl, 2
2470 art_zh 333
 
334
.gptick.done:
2461 art_zh 335
	add	dl, dh
336
	mov	dh, ch			; dh = orig.XY;     dl = numvert
2470 art_zh 337
	jmp	.draw			; cl = rotation;   esi-> tickfield
2461 art_zh 338
 
2318 art_zh 339
.cstick:
2461 art_zh 340
	and	cl, 4
341
	shr	cl, 2			; only one rotational bit
342
	and	dl, 3
343
	jz	.cstick.0
344
	dec	dl
345
	jnz	@f
346
	mov	dl, 6
2470 art_zh 347
	jz	.cstick.1		; 8-pix square outline
2461 art_zh 348
@@:	dec	dl
349
	jz	.cstick.2
2318 art_zh 350
.cstick.3:
2461 art_zh 351
	mov	esi, sdsh_data.cs3	; 12pix-ring
352
	mov	dl, 10
353
	jmp	.draw
2318 art_zh 354
.cstick.2:
2470 art_zh 355
	mov	dl, 7			; 9-pix filled square
2318 art_zh 356
.cstick.1:
2470 art_zh 357
	mov	esi, sdsh_data.cs2	; the square tickfield
2461 art_zh 358
	jmp	.draw
2321 art_zh 359
.cstick.0:
2461 art_zh 360
	mov	esi, sdsh_data.cs0	; 4pix-square
2470 art_zh 361
	mov	dl, 2
2461 art_zh 362
	jmp	.draw
2318 art_zh 363
 
364
.ritick:
2461 art_zh 365
	test	dl, 1
366
	jnz	.ritick.1
2318 art_zh 367
.ritick.0:
2499 art_zh 368
	movzx	ecx, dh 	    ; y
2461 art_zh 369
	and	cl, 0x0F
370
	sub	ebx, ecx
371
	mov	cl, dh
372
	shr	cl, 4		    ; x
373
	add	eax, ecx
374
	call	ch_putpixel
375
	jmp	.exit
2318 art_zh 376
.ritick.1:
2461 art_zh 377
	mov	esi, sdsh_data.ri1  ; 8pix-ring
2470 art_zh 378
	mov	dl, 6
2461 art_zh 379
	jmp	.draw
380
 
2318 art_zh 381
.lntick.short:
2461 art_zh 382
	test	dl, 0x06	    ; ticks #0, 1 are reserved for
383
	jz	.ritick 	    ;             rotational invariants
384
	and	dl, 0x07	    ; dl = line length
385
	jmp	.lntick.both
2318 art_zh 386
.lntick.long:
2461 art_zh 387
	and	dl, 0x07
388
	add	dl, 8
2318 art_zh 389
.lntick.both:
2461 art_zh 390
	sub	dl, 2		    ; num_vertice = num_points - 2
391
	and	cl, 0x18	    ; two (lower) rotation bits
392
	shr	cl, 3
393
	mov	esi, sdsh_data.blank
2470 art_zh 394
 
2318 art_zh 395
.draw:
2461 art_zh 396
; cl = rot; dl = numvert; dh = orig.xy
397
	push	ecx
2499 art_zh 398
	movzx	ecx, dh 	    ; y
2461 art_zh 399
	and	cl, 0x0F
400
	sub	ebx, ecx
401
	mov	cl, dh
402
	shr	cl, 4		    ; x
403
	add	eax, ecx
404
	pop	ecx
405
	call	draw_tick
2320 art_zh 406
.gptick.5:
2499 art_zh 407
.sptick:
2318 art_zh 408
.exit:
2461 art_zh 409
	popad
410
	ret
2318 art_zh 411
 
2461 art_zh 412
 
413
diff16 "draw_tick      : ",0,$
414
 
2318 art_zh 415
draw_tick:
416
; eax = x-origin
417
; ebx = y-origin
2461 art_zh 418
; edi = 0x0RRGGBB
419
;  cl = direction (0..7)
420
;  dl = number of vertice  (dl)
421
; esi -> tick bitfield
2318 art_zh 422
 
423
	pushad
2461 art_zh 424
	call	ch_putpixel			; the point of origin
425
	and	ecx, 7
426
	lea	ebp, [.move000+ ecx*4]
427
	call	ebp		      ; basic vector
428
	call	ch_putpixel
2499 art_zh 429
	and	edx, 15
430
	jz	.done		       ; no vertex (2pix line)
431
	mov	esi, dword [esi]       ; 15 vertice will easily fit to 1dw
432
	xchg	esi, edx
2318 art_zh 433
.move_and_draw:
2499 art_zh 434
	mov	ch, dl
435
	and	ch, 3
436
	jz	.moved
437
	dec	ch
438
	jz	.1
439
	dec	ch
440
	jz	.2
441
.3:
442
	dec	cl
2320 art_zh 443
.1:
2499 art_zh 444
	dec	cl
445
	jmp	.wipe_it
2320 art_zh 446
.2:
2499 art_zh 447
	inc	cl
2461 art_zh 448
.wipe_it:
2499 art_zh 449
	and	ecx, 7
2320 art_zh 450
.moved:
2461 art_zh 451
diff16 "moved          : ",0,$
452
	lea	ebp, [.move000+ ecx*4]
453
	call	ebp		    ; go new way
454
	call	ch_putpixel
2499 art_zh 455
	shr	edx, 2
456
	dec	esi
457
	jnz	.move_and_draw
2461 art_zh 458
diff16 "done           : ",0,$
2318 art_zh 459
.done:
460
	popad
461
	ret
462
 
2461 art_zh 463
; WARNING! The order matters! ------
464
align 4
465
diff16 "move000        : ",0,$
2318 art_zh 466
.move000:
467
	inc		eax
468
	ret
2461 art_zh 469
align 4
2318 art_zh 470
.move001:
471
	inc		eax
2320 art_zh 472
	dec		ebx
2318 art_zh 473
	ret
2461 art_zh 474
align 4
2318 art_zh 475
.move010:
2320 art_zh 476
	dec		ebx
2318 art_zh 477
	ret
2461 art_zh 478
align 4
2318 art_zh 479
.move011:
480
	dec		eax
2320 art_zh 481
	dec		ebx
2318 art_zh 482
	ret
2461 art_zh 483
align 4
2320 art_zh 484
.move100:
2318 art_zh 485
	dec		eax
486
	ret
2461 art_zh 487
align 4
2320 art_zh 488
.move101:
2318 art_zh 489
	dec		eax
2320 art_zh 490
	inc		ebx
2318 art_zh 491
	ret
2461 art_zh 492
align 4
2320 art_zh 493
.move110:
494
	inc		ebx
2318 art_zh 495
	ret
2461 art_zh 496
 
497
align 4
498
diff10 "move111-move000 (must be 28!)  : ",.move000,$
2320 art_zh 499
.move111:
2318 art_zh 500
	inc		eax
2320 art_zh 501
	inc		ebx
2318 art_zh 502
	ret
503
 
2461 art_zh 504
;) ---------------
2318 art_zh 505
 
506
align 4
2461 art_zh 507
diff16 "checkscreen    : ",0,$
2318 art_zh 508
ch_checkscreen:
509
     cmp	[Screen_Max_X], eax
2461 art_zh 510
     jb 	.getout
2318 art_zh 511
     cmp	[Screen_Max_Y], ebx
512
.getout:
513
     ret
514
 
515
align 4
2461 art_zh 516
diff16 "checkwin       : ",0,$
2318 art_zh 517
ch_checkwin:
518
; eax = x coordinate
519
; ebx = y coordinate
520
; ebp -> font info
2522 art_zh 521
 
2461 art_zh 522
	push	eax
523
	push	ebx
2522 art_zh 524
	push	ecx
525
	push	edx
2461 art_zh 526
	mov	ch,  byte[CURRENT_TASK]
527
	mov	edx, [_display.width]	    ; screen X-size
528
	imul	edx, ebx
529
	add	edx, [_WinMapAddress]
530
	add	edx, eax
531
	cmp	ch,  byte [edx]
532
	jne	.fail
2522 art_zh 533
	movzx	eax, byte [ebp] 	    ; char X-width
2461 art_zh 534
	cmp	ch,  byte [edx+eax]
535
	jne	.fail
536
	movzx	ebx, byte [ebp+1]
537
	imul	ebx, [_display.width]
538
	cmp	ch,  byte [edx+ebx]
539
	jne	.fail
540
	add	edx, eax
541
	cmp	ch,  byte [edx+ebx]
542
	clc
543
	je     .done
544
.fail:
545
	stc				    ; CF means the charbox is invisible
2318 art_zh 546
.done:
2522 art_zh 547
	pop	edx
548
	pop	ecx
2461 art_zh 549
	pop	ebx
550
	pop	eax
551
	ret
2318 art_zh 552
 
553
align 4
2461 art_zh 554
diff16 "ch_putpix      : ",0,$
2522 art_zh 555
 ch_putpixel:
2318 art_zh 556
; eax = x coordinate
557
; ebx = y coordinate
2461 art_zh 558
; edi = 0x0RRGGBB
2318 art_zh 559
     push   edx
560
	 mov	edx, ebx
561
     imul	edx, [BytesPerScanLine]
562
     lea	edx, [edx+eax*4]
563
     mov   [LFB_BASE+edx], edi
2322 art_zh 564
     pop    edx
2318 art_zh 565
     ret
566
;)
2522 art_zh 567
;ch_putpixel2:
2499 art_zh 568
; test version!!! ===== to be removed!!
569
; eax = x coordinate
570
; ebx = y coordinate
571
; edi = 0x0RRGGBB
572
     push   edx
573
	 mov	edx, ebx
574
	shl	edx, 1
575
     imul	edx, [BytesPerScanLine]
576
     lea	edx, [edx+eax*8]
577
	add	edx, LFB_BASE
578
     mov   [edx], edi
579
	mov	[edx+4], edi
580
	sub	edx, [BytesPerScanLine]
581
	mov	[edx], edi
582
	mov	[edx+4], edi
583
     pop    edx
584
     ret
2318 art_zh 585
 
2322 art_zh 586
 
587
diff10 "new font  code size",sdsh_code,$