Subversion Repositories Kolibri OS

Rev

Rev 2322 | Rev 2470 | 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: 2461 $
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
	xor	ecx, ecx
216
	mov	dx, word[edx]
217
	mov	cl, dl
218
	test	dl, 0xE0	    ; ticks #32..255
219
	jz	.lntick.short
220
	cmp	dl, 0xE0
221
	jae	.lntick.long
222
	cmp	dl, 0xC0
223
	jae	.cstick
2318 art_zh 224
.gptick:
2461 art_zh 225
	push	edx
226
	mov	cl, dh
227
	shr	cl, 3		    ; orig.#
228
	mov	edx, [ebp+8]	    ; orig. table
229
	mov	ch, byte[edx+ecx]   ; orig. coords
230
	pop	edx
231
	mov	cl, dh
232
	and	cl, 7			; three rotation bits
233
	and	edx, 0xFF		; dl = gptick#
234
	sub	dl, 32
235
	cmp	dl, (sdsh_data.v5-sdsh_data.v1)
236
	jae	.gptick.2
2320 art_zh 237
.gptick.1:
2461 art_zh 238
	mov	esi, sdsh_data.tick_table
239
	add	esi, edx		;  1-byte tickgroups .v1-v4:
240
	inc	dh
241
	sub	dl, 2			; .v1 : 2 ticks only (#32, 33)
242
	jae	@f
243
	mov	dl, dh
244
	jmp	.gptick.done
245
@@:	inc	dh
246
	shr	dl, 3			; tickgroups .v2-v4 : 8 ticks each
247
	add	dl, dh
248
	jmp	.gptick.done
2320 art_zh 249
.gptick.2:
2461 art_zh 250
	sub	dl, (sdsh_data.v5-sdsh_data.v1)
251
	cmp	dl, (sdsh_data.v9-sdsh_data.v5)
252
	jae	.gptick.3
253
	mov	esi, sdsh_data.v5
254
	lea	esi, [esi+edx*2]	; 2-byte tickgroups .v5-v8: 8 ticks each
255
	mov	dh, 5
256
	shr	dl, 3
257
	add	dl, dh
258
	jmp	.gptick.done
2320 art_zh 259
.gptick.3:
2461 art_zh 260
	sub	dl, (sdsh_data.v9-sdsh_data.v5)
261
	cmp	dl, (sdsh_data.v13-sdsh_data.v9)
262
	jae	.gptick.4
263
	mov	esi, sdsh_data.v9
264
	lea	esi,[esi+edx*2]
265
	add	esi, edx		; 3-byte tickgroups .v9-12: 4 ticks each
266
	mov	dh, 9
267
	shr	dl, 2
268
	add	dl, dh
269
	jmp	.gptick.done
2320 art_zh 270
.gptick.4:
2461 art_zh 271
	sub	dl, (sdsh_data.v13-sdsh_data.v9)
272
	cmp	dl, 16
273
	jae	.exit
274
	mov	esi, sdsh_data.v13
275
	lea	esi,[esi+edx*4] 	; 4-byte tickgroups .v13-16: 4 ticks each
276
	mov	dh, 13
277
	shr	dl, 2
278
	add	dl, dh
2320 art_zh 279
.gptick.done:
2461 art_zh 280
	mov	dh, ch			; dh = orig.XY;     dl = numvert
281
	jmp	.draw			; cl = rotation
282
 
2318 art_zh 283
.cstick:
2461 art_zh 284
	and	cl, 4
285
	shr	cl, 2			; only one rotational bit
286
	and	dl, 3
287
	inc	dl
288
	dec	dl
289
	jz	.cstick.0
290
	dec	dl
291
	jnz	@f
292
	mov	dl, 6
293
	jz	.cstick.1
294
@@:	dec	dl
295
	jz	.cstick.2
2318 art_zh 296
.cstick.3:
2461 art_zh 297
	mov	esi, sdsh_data.cs3	; 12pix-ring
298
	mov	dl, 10
299
	jmp	.draw
2318 art_zh 300
.cstick.2:
2461 art_zh 301
	mov	dl, 7
2318 art_zh 302
.cstick.1:
2461 art_zh 303
	mov	esi, sdsh_data.cs2	; the square
304
	jmp	.draw
2321 art_zh 305
.cstick.0:
2461 art_zh 306
	mov	esi, sdsh_data.cs0	; 4pix-square
307
	mov	dl, 3
308
	jmp	.draw
2318 art_zh 309
 
310
.ritick:
2461 art_zh 311
	test	dl, 1
312
	jnz	.ritick.1
2318 art_zh 313
.ritick.0:
2461 art_zh 314
	mov	cl, dh		    ; y
315
	and	cl, 0x0F
316
	sub	ebx, ecx
317
	mov	cl, dh
318
	shr	cl, 4		    ; x
319
	add	eax, ecx
320
	call	ch_putpixel
321
	jmp	.exit
2318 art_zh 322
.ritick.1:
2461 art_zh 323
	mov	esi, sdsh_data.ri1  ; 8pix-ring
324
	mov	dl, 4
325
	xor	cl, cl
326
	jmp	.draw
327
 
2318 art_zh 328
.lntick.short:
2461 art_zh 329
	test	dl, 0x06	    ; ticks #0, 1 are reserved for
330
	jz	.ritick 	    ;             rotational invariants
331
	and	dl, 0x07	    ; dl = line length
332
	jmp	.lntick.both
2318 art_zh 333
.lntick.long:
2461 art_zh 334
	and	dl, 0x07
335
	add	dl, 8
2318 art_zh 336
.lntick.both:
2461 art_zh 337
	sub	dl, 2		    ; num_vertice = num_points - 2
338
	and	cl, 0x18	    ; two (lower) rotation bits
339
	shr	cl, 3
340
	mov	esi, sdsh_data.blank
2318 art_zh 341
.draw:
2461 art_zh 342
; cl = rot; dl = numvert; dh = orig.xy
343
	push	ecx
344
	mov	cl, dh		    ; y
345
	and	cl, 0x0F
346
	sub	ebx, ecx
347
	mov	cl, dh
348
	shr	cl, 4		    ; x
349
	add	eax, ecx
350
	pop	ecx
351
	call	draw_tick
2320 art_zh 352
.gptick.5:
2318 art_zh 353
.exit:
2461 art_zh 354
	popad
355
	ret
2318 art_zh 356
 
2461 art_zh 357
 
358
diff16 "draw_tick      : ",0,$
359
 
2318 art_zh 360
draw_tick:
361
; eax = x-origin
362
; ebx = y-origin
2461 art_zh 363
; edi = 0x0RRGGBB
364
;  cl = direction (0..7)
365
;  dl = number of vertice  (dl)
366
; esi -> tick bitfield
2318 art_zh 367
 
368
	pushad
2461 art_zh 369
	call	ch_putpixel			; the point of origin
370
	and	ecx, 7
371
	lea	ebp, [.move000+ ecx*4]
372
	call	ebp		      ; basic vector
373
	call	ch_putpixel
374
        and     edx, 15
375
        jz	.done		       ; no vertex (2pix line)
376
        mov     esi, dword [esi]       ; 15 vertice will easily fit to 1dw
377
        xchg    esi, edx
2318 art_zh 378
.move_and_draw:
2461 art_zh 379
        mov     ch, dl
380
        and     ch, 3
381
        jz	.moved
382
        dec     ch
383
        jz      .1
384
        dec     ch
385
        jz      .2
386
.3:
387
        dec     cl
2320 art_zh 388
.1:
2461 art_zh 389
        dec     cl
390
        jmp     .wipe_it
2320 art_zh 391
.2:
2461 art_zh 392
        inc     cl
393
.wipe_it:
394
        and     ecx, 7
2320 art_zh 395
.moved:
2461 art_zh 396
diff16 "moved          : ",0,$
397
	lea	ebp, [.move000+ ecx*4]
398
	call	ebp		    ; go new way
399
	call	ch_putpixel
400
        shr     edx, 2
401
        dec     esi
402
        jnz     .move_and_draw
403
diff16 "done           : ",0,$
2318 art_zh 404
.done:
405
	popad
406
	ret
407
 
2461 art_zh 408
; WARNING! The order matters! ------
409
align 4
410
diff16 "move000        : ",0,$
2318 art_zh 411
.move000:
412
	inc		eax
413
	ret
2461 art_zh 414
align 4
2318 art_zh 415
.move001:
416
	inc		eax
2320 art_zh 417
	dec		ebx
2318 art_zh 418
	ret
2461 art_zh 419
align 4
2318 art_zh 420
.move010:
2320 art_zh 421
	dec		ebx
2318 art_zh 422
	ret
2461 art_zh 423
align 4
2318 art_zh 424
.move011:
425
	dec		eax
2320 art_zh 426
	dec		ebx
2318 art_zh 427
	ret
2461 art_zh 428
align 4
2320 art_zh 429
.move100:
2318 art_zh 430
	dec		eax
431
	ret
2461 art_zh 432
align 4
2320 art_zh 433
.move101:
2318 art_zh 434
	dec		eax
2320 art_zh 435
	inc		ebx
2318 art_zh 436
	ret
2461 art_zh 437
align 4
2320 art_zh 438
.move110:
439
	inc		ebx
2318 art_zh 440
	ret
2461 art_zh 441
 
442
align 4
443
diff10 "move111-move000 (must be 28!)  : ",.move000,$
2320 art_zh 444
.move111:
2318 art_zh 445
	inc		eax
2320 art_zh 446
	inc		ebx
2318 art_zh 447
	ret
448
 
2461 art_zh 449
;) ---------------
2318 art_zh 450
 
451
align 4
2461 art_zh 452
diff16 "checkscreen    : ",0,$
2318 art_zh 453
ch_checkscreen:
454
     cmp	[Screen_Max_X], eax
2461 art_zh 455
     jb 	.getout
2318 art_zh 456
     cmp	[Screen_Max_Y], ebx
457
.getout:
458
     ret
459
 
460
align 4
2461 art_zh 461
diff16 "checkwin       : ",0,$
2318 art_zh 462
ch_checkwin:
463
; eax = x coordinate
464
; ebx = y coordinate
465
; ebp -> font info
2461 art_zh 466
;!destroys ch, edx!
467
	push	eax
468
	push	ebx
469
	mov	ch,  byte[CURRENT_TASK]
470
	mov	al,  byte [ebp] 	    ; char X-width
471
	mov	edx, [_display.width]	    ; screen X-size
472
	imul	edx, ebx
473
	add	edx, [_WinMapAddress]
474
	add	edx, eax
475
	cmp	ch,  byte [edx]
476
	jne	.fail
477
	movzx	eax, byte [ebp]
478
	cmp	ch,  byte [edx+eax]
479
	jne	.fail
480
	movzx	ebx, byte [ebp+1]
481
	imul	ebx, [_display.width]
482
	cmp	ch,  byte [edx+ebx]
483
	jne	.fail
484
	add	edx, eax
485
	cmp	ch,  byte [edx+ebx]
486
	clc
487
	je     .done
488
.fail:
489
	stc				    ; CF means the charbox is invisible
2318 art_zh 490
.done:
2461 art_zh 491
	pop	ebx
492
	pop	eax
493
	ret
2318 art_zh 494
 
495
align 4
2461 art_zh 496
diff16 "ch_putpix      : ",0,$
2318 art_zh 497
ch_putpixel:
498
; eax = x coordinate
499
; ebx = y coordinate
2461 art_zh 500
; edi = 0x0RRGGBB
2318 art_zh 501
     push   edx
502
	 mov	edx, ebx
503
     imul	edx, [BytesPerScanLine]
504
     lea	edx, [edx+eax*4]
505
     mov   [LFB_BASE+edx], edi
2322 art_zh 506
     pop    edx
2318 art_zh 507
     ret
508
;)
509
 
2322 art_zh 510
 
511
diff10 "new font  code size",sdsh_code,$