Subversion Repositories Kolibri OS

Rev

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