Subversion Repositories Kolibri OS

Rev

Rev 2321 | Rev 2461 | 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: 2322 $
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
 
2322 art_zh 144
include 'fonts/sd_data.asm'
2318 art_zh 145
 
146
sdsh_code:
147
 
148
; eax	=	if (bit[31])
149
;				then lower 31 bits points to the user-selected font
150
;				else ax = number of preloaded system font
151
; ebx	=	x<<16 + y
152
; ecx	=	0x00RRGGBB
153
; edx	=	if (bits[31:8] == 0)
154
;				then dl = single char to write
155
;				else edx= pointer to asciiz-string
156
 
2322 art_zh 157
draw_char:
158
; font test
159
; bl=y; bh=x
160
; dl=ascii
161
        movzx   eax, bh
162
        movzx   ebx, bl
163
        movzx   ecx, dl
164
        xor     edi, edi
165
        mov     ebp, edi
166
 
2318 art_zh 167
sdsh_draw_char:
168
; eax = left side X
169
; ebx = bottom Y
170
; edi = color 0x0RRGGBB
171
; ebp = font@
172
; ecx = ascii, zero-extended to 32bits
2322 art_zh 173
        push    ecx
174
        push    edx
175
        push    ebp
2318 art_zh 176
        shl     ebp, 4
177
        add     ebp, sdsh_data.info
178
        call	ch_checkscreen
179
        jb		.exit
180
        call	ch_checkwin
181
        jc		.exit
182
        xor		ch, ch
183
        mov     edx, [ebp + 4]              ; chartable addr
184
        mov		cx, word[edx + ecx*2]       ; tick info
185
        mov		edx, ecx
2320 art_zh 186
        and     ecx, 7                      ; cl = number of ticks
2318 art_zh 187
        jz      .blank
188
        shr     edx, 4                      ; offset in the chartable
189
        add     edx, [sdsh_data.chars]      ; edx -> the char's ticklist
190
.next_tick:
191
        call    parse_tick
192
        add     edx, 4
193
        dec     cl
194
        jnz     .next_tick
195
.blank:
196
.exit:
2322 art_zh 197
        pop     ebp
198
        pop     edx
199
        pop     ecx
2318 art_zh 200
        ret
201
 
202
 
203
parse_tick:
204
; eax = left side X
205
; ebx = bottom Y
206
; edx ->tickinfo
207
; edi = color 0x0RRGGBB
208
; ebp = font's header
2320 art_zh 209
        pushad
2318 art_zh 210
        xor     ecx, ecx
211
        mov     dx, word[edx]
212
        mov     cl, dl
213
        test    dl, 0xE0            ; ticks #32..255
214
        jz      .lntick.short
215
        cmp     dl, 0xE0
216
        jae     .lntick.long
217
        cmp     dl, 0xC0
218
        jae     .cstick
219
.gptick:
2320 art_zh 220
        push    edx
221
        mov     cl, dh
222
        shr     cl, 3               ; orig.#
223
        mov     edx, [ebp+8]        ; orig. table
224
        mov     ch, byte[edx+ecx]   ; orig. coords
225
        pop     edx
226
        mov     cl, dh
2321 art_zh 227
        and     cl, 7                   ; three rotation bits
228
        and     edx, 0xFF               ; dl = gptick#
2320 art_zh 229
        sub     dl, 32
2321 art_zh 230
        cmp     dl, (sdsh_data.v5-sdsh_data.v1)
2320 art_zh 231
        jae     .gptick.2
232
.gptick.1:
233
        mov     esi, sdsh_data.tick_table
2321 art_zh 234
        add     esi, edx                ;  1-byte tickgroups .v1-v4:
2320 art_zh 235
        inc     dh
2321 art_zh 236
        sub     dl, 2                   ; .v1 : 2 ticks only (#32, 33)
237
        jae     @f
238
        mov     dl, dh
239
        jmp     .gptick.done
240
@@:     inc     dh
241
        shr     dl, 3                   ; tickgroups .v2-v4 : 8 ticks each
242
        add     dl, dh
243
        jmp     .gptick.done
2320 art_zh 244
.gptick.2:
245
        sub     dl, (sdsh_data.v5-sdsh_data.v1)
2321 art_zh 246
        cmp     dl, (sdsh_data.v9-sdsh_data.v5)
2320 art_zh 247
        jae     .gptick.3
248
        mov     esi, sdsh_data.v5
2321 art_zh 249
        lea     esi, [esi+edx*2]        ; 2-byte tickgroups .v5-v8: 8 ticks each
2320 art_zh 250
        mov     dh, 5
2321 art_zh 251
        shr     dl, 3
252
        add     dl, dh
253
        jmp     .gptick.done
2320 art_zh 254
.gptick.3:
255
        sub     dl, (sdsh_data.v9-sdsh_data.v5)
2321 art_zh 256
        cmp     dl, (sdsh_data.v13-sdsh_data.v9)
2320 art_zh 257
        jae     .gptick.4
258
        mov     esi, sdsh_data.v9
2322 art_zh 259
        lea     esi,[esi+edx*2]
260
        add     esi, edx                ; 3-byte tickgroups .v9-12: 4 ticks each
2320 art_zh 261
        mov     dh, 9
2321 art_zh 262
        shr     dl, 2
263
        add     dl, dh
264
        jmp     .gptick.done
2320 art_zh 265
.gptick.4:
266
        sub     dl, (sdsh_data.v13-sdsh_data.v9)
2321 art_zh 267
        cmp     dl, 16
268
        jae     .exit
2320 art_zh 269
        mov     esi, sdsh_data.v13
2321 art_zh 270
        lea     esi,[esi+edx*4]         ; 4-byte tickgroups .v13-16: 4 ticks each
2320 art_zh 271
        mov     dh, 13
2321 art_zh 272
        shr     dl, 2
273
        add     dl, dh
2320 art_zh 274
.gptick.done:
2321 art_zh 275
        mov     dh, ch                  ; dh = orig.XY;     dl = numvert
276
        jmp     .draw                   ; cl = rotation
2318 art_zh 277
 
278
.cstick:
279
        and     cl, 4
2321 art_zh 280
        shr     cl, 2                   ; only one rotational bit
2318 art_zh 281
        and     dl, 3
2321 art_zh 282
        inc     dl
2318 art_zh 283
        dec     dl
2321 art_zh 284
        jz      .cstick.0
2318 art_zh 285
        dec     dl
2321 art_zh 286
        jnz     @f
287
        mov     dl, 6
288
        jz      .cstick.1
289
@@:     dec     dl
290
        jz      .cstick.2
2318 art_zh 291
.cstick.3:
2321 art_zh 292
        mov     esi, sdsh_data.cs3      ; 12pix-ring
2318 art_zh 293
        mov     dl, 10
294
        jmp     .draw
295
.cstick.2:
296
        mov     dl, 7
297
.cstick.1:
2321 art_zh 298
        mov     esi, sdsh_data.cs2      ; the square
2318 art_zh 299
        jmp     .draw
2321 art_zh 300
.cstick.0:
301
        mov     esi, sdsh_data.cs0      ; 4pix-square
2318 art_zh 302
        mov     dl, 3
303
        jmp     .draw
304
 
305
.ritick:
306
        test    dl, 1
307
        jnz     .ritick.1
308
.ritick.0:
309
        mov     cl, dh              ; y
310
        and     cl, 0x0F
2320 art_zh 311
        sub     ebx, ecx
2318 art_zh 312
        mov     cl, dh
313
        shr     cl, 4               ; x
2320 art_zh 314
        add     eax, ecx
2318 art_zh 315
        call    ch_putpixel
316
        jmp     .exit
317
.ritick.1:
318
        mov     esi, sdsh_data.ri1  ; 8pix-ring
319
        mov     dl, 4
2320 art_zh 320
        xor     cl, cl
2318 art_zh 321
        jmp     .draw
322
 
323
.lntick.short:
324
        test    dl, 0x06            ; ticks #0, 1 are reserved for
325
        jz      .ritick             ;             rotational invariants
326
        and     dl, 0x07            ; dl = line length
327
        jmp     .lntick.both
328
.lntick.long:
329
        and     dl, 0x07
330
        add     dl, 8
331
.lntick.both:
332
        sub     dl, 2               ; num_vertice = num_points - 2
333
        and     cl, 0x18            ; two rotation bits
334
        shr     cl, 3
335
        mov     esi, sdsh_data.blank
336
.draw:
2320 art_zh 337
; cl = rot; dl = numvert; dh = orig.xy
2318 art_zh 338
        push    ecx
339
        mov     cl, dh              ; y
340
        and     cl, 0x0F
2320 art_zh 341
        sub     ebx, ecx
2318 art_zh 342
        mov     cl, dh
343
        shr     cl, 4               ; x
2320 art_zh 344
        add     eax, ecx
2318 art_zh 345
        pop     ecx
346
        call    draw_tick
2320 art_zh 347
.gptick.5:
2318 art_zh 348
.exit:
349
        popad
350
        ret
351
 
352
 
353
 
354
draw_tick:
355
; eax = x-origin
356
; ebx = y-origin
357
; edi = 0x0RRGGBB
358
;  cl = direction (0..7)
2320 art_zh 359
;  dl = number of vertices  (dl)
360
; esi -> tick bitfield
2318 art_zh 361
 
362
	pushad
2320 art_zh 363
    inc     dl                      ; -- that's to count down to 0
364
	call	ch_putpixel		        ; the point of origin
365
	and		ecx, 7
366
	call	[.moves + ecx*4]        ; basic vector
367
	call	ch_putpixel
368
    dec     dl
369
    jz      .done                   ; 2pix lines only
370
    mov     esi, dword [esi]        ; max 16 vertice bitfield limit
371
    xchg    esi, edx
2318 art_zh 372
.move_and_draw:
2320 art_zh 373
    mov     ch, dl
374
    and     ch, 3
375
    jz      .moved
2322 art_zh 376
    btc     ecx, 8
2320 art_zh 377
    jz      .2
378
.1:
379
    dec     cl                      ; right turns (1 and 3)
380
    and     cl, 7
2322 art_zh 381
@@: btc     ecx, 9                  ; straight angle (3) ?
2320 art_zh 382
    jc      .1
383
    jmp     .moved
384
.2:
385
    inc     cl                      ; left turn (2)
386
    and     cl, 7
2322 art_zh 387
    btc     ecx, 9                  ; just to zero ah
2320 art_zh 388
.moved:
389
	call	[.moves + ecx*4]        ; go new way
390
	call	ch_putpixel
391
    shr     edx, 2
392
    dec     esi
393
    jnz     .move_and_draw
2318 art_zh 394
.done:
395
	popad
396
	ret
397
 
398
.move000:
399
	inc		eax
400
	ret
401
.move001:
402
	inc		eax
2320 art_zh 403
	dec		ebx
2318 art_zh 404
	ret
405
.move010:
2320 art_zh 406
	dec		ebx
2318 art_zh 407
	ret
408
.move011:
409
	dec		eax
2320 art_zh 410
	dec		ebx
2318 art_zh 411
	ret
2320 art_zh 412
.move100:
2318 art_zh 413
	dec		eax
414
	ret
2320 art_zh 415
.move101:
2318 art_zh 416
	dec		eax
2320 art_zh 417
	inc		ebx
2318 art_zh 418
	ret
2320 art_zh 419
.move110:
420
	inc		ebx
2318 art_zh 421
	ret
2320 art_zh 422
.move111:
2318 art_zh 423
	inc		eax
2320 art_zh 424
	inc		ebx
2318 art_zh 425
	ret
426
 
427
align 4
428
.moves dd .move000, .move001, .move010, .move011, .move100, .move101, .move110, .move111
429
 
430
;)
431
 
432
align 4
433
ch_checkscreen:
434
     cmp	[Screen_Max_X], eax
435
     jb		.getout
436
     cmp	[Screen_Max_Y], ebx
437
.getout:
438
     ret
439
 
440
align 4
441
ch_checkwin:
442
; eax = x coordinate
443
; ebx = y coordinate
444
; ebp -> font info
445
;!destroys ch, edx!
2322 art_zh 446
        push    eax
447
        push    ebx
2318 art_zh 448
        mov     ch,  byte[CURRENT_TASK]
449
        mov     al,  byte [ebp]	            ; char X-width
450
        mov     edx, [_display.width]       ; screen X-size
451
        imul    edx, ebx
452
        add     edx, [_WinMapAddress]
453
        add     edx, eax
454
        cmp     ch,  byte [edx]
455
        jne     .fail
2322 art_zh 456
        movzx   eax, byte [ebp]
2318 art_zh 457
        cmp     ch,  byte [edx+eax]
458
        jne     .fail
2322 art_zh 459
        movzx   ebx, byte [ebp+1]
2318 art_zh 460
        imul    ebx, [_display.width]
461
        cmp     ch,  byte [edx+ebx]
462
        jne     .fail
463
        add     edx, eax
464
        cmp     ch,  byte [edx+ebx]
465
        clc
466
        je     .done
467
.fail:
468
        stc                                 ; CF means the charbox is invisible
469
.done:
2322 art_zh 470
        pop     ebx
471
        pop     eax
2318 art_zh 472
        ret
473
 
474
align 4
475
ch_putpixel:
476
; eax = x coordinate
477
; ebx = y coordinate
478
; edi = 0x0RRGGBB
479
     push   edx
480
	 mov	edx, ebx
481
     imul	edx, [BytesPerScanLine]
482
     lea	edx, [edx+eax*4]
483
     mov   [LFB_BASE+edx], edi
2322 art_zh 484
     pop    edx
2318 art_zh 485
     ret
486
;)
487
 
2322 art_zh 488
 
489
diff10 "new font  code size",sdsh_code,$