Subversion Repositories Kolibri OS

Rev

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