Subversion Repositories Kolibri OS

Rev

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