Subversion Repositories Kolibri OS

Rev

Rev 5363 | Rev 5681 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2288 clevermous 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
5363 yogev_ezra 3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
2288 clevermous 4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
8
$Revision: 5665 $
9
 
5665 Pathoswith 10
dtext_asciiz_esi:
11
        btr     ecx, 31
2536 mario79 12
dtext:
5665 Pathoswith 13
; edx -> string
14
; esi = number of characters
15
; ebx = output coordinates XXXXYYYY h
16
; ecx = char color and flags flRRGGBB h
17
; fl = ZBFFRSSS b
18
; Z=1: edx -> zero terminated string, esi = ?
19
; B=1: fill background with color eax
20
; R=1: edi -> user area for redirect
21
; FF=3: UTF-8 8x16, FF=2: UTF-16LE 8x16, FF=0: 866 6x9
22
; SSS = (font multiplier)-1
23
; edi=1: force output
24
        and     eax, 0xFFFFFF
25
        bt      ecx, 30
26
        jc      @f
2288 clevermous 27
        xor     eax, eax
5665 Pathoswith 28
        dec     eax
29
@@:
30
        pushd   0 0 0 eax
31
        movsx   eax, bx
32
        sar     ebx, 16
33
        push    eax ebx edi
34
        bt      ecx, 27
35
        jc      .redirect
36
        mov     ebp, [_display.width]
37
        xor     edi, edi
2288 clevermous 38
        jmp     @f
5665 Pathoswith 39
.redirect:
40
        mov     ebp, [edi]
41
        add     edi, 8
2288 clevermous 42
@@:
5665 Pathoswith 43
        shl     ebp, 2
44
        imul    eax, ebp
45
        shl     ebx, 2
46
        add     eax, ebx
47
        js      .ret
48
        add     edi, eax    ; linear address (32bit)
49
        mov     eax, ecx
50
        mov     ebx, ecx
51
        test    ecx, ecx
52
        jns     @f
53
        mov     esi, 256
54
@@:
55
        shr     ecx, 24
56
        and     cl, 7
57
        inc     ecx
58
        push    ebp ecx esi
59
        mov     esi, edx    ; -> string
60
        or      eax, 0xFF000000
61
        bt      ebx, 27
62
        jc      .bufferReady
63
        mov     eax, 9
64
        bt      ebx, 29
65
        jnc     @f
66
        add     eax, 7
67
@@:
68
        imul    eax, ecx
69
        mov     [esp+32], eax
70
        imul    ebp, eax
71
        stdcall kernel_alloc, ebp
72
        mov     ecx, ebp
73
        shr     ecx, 2
74
        mov     [esp+36], eax
75
        sub     edi, eax
76
        mov     edx, eax
77
        mov     eax, [esp+24]
78
        cmp     eax, -1
79
        jnz     .background
80
        mov     [esp+28], edi
81
.background:
82
        mov     edi, edx
83
        rep stosd
84
        mov     edi, edx
85
        mov     eax, ebx
86
        and     eax, 0xFFFFFF
87
.bufferReady:
88
        mov     ebp, eax
89
        xor     edx, edx
90
        bt      ebx, 29
91
        jnc     .draw866
92
        bt      ebx, 28
93
        jc      .drawUTF8
2536 mario79 94
 
5665 Pathoswith 95
; char counter +0
96
fontMultiplier = 4
97
widthX = 8
98
; edi +12
99
; X +16
100
; Y +20
101
; background +24
102
deltaToScreen = 28
103
; temp buffer height +32
104
; temp buffer +36
2536 mario79 105
 
5665 Pathoswith 106
.drawUTF16:
107
        dec     dword [esp]
108
        js      .done
109
        xor     ebx, ebx
110
        mov     bx, [esi]
111
        test    ebx, ebx
112
        jz      .done
113
        inc     esi
114
        inc     esi
115
        cmp     bx, 1419
116
        jc      @f
117
        xor     ebx, ebx
2536 mario79 118
@@:
5665 Pathoswith 119
        pushd   esi edi 16
120
        shl     ebx, 4
121
        add     ebx, fontUni
122
        mov     esi, [esp+12+fontMultiplier]
123
        call    drawChar
124
        imul    esi, 8*4
125
        pop     edi
126
        pop     edi
127
        add     edi, esi
128
        pop     esi
129
        jmp     .drawUTF16
130
.drawUTF8:
131
        dec     dword [esp]
132
        js      .done
133
        xor     ebx, ebx
134
        mov     bl, [esi]
135
        inc     esi
136
        test    bl, bl
137
        jz      .done
138
        jns     .valid
139
        shl     bx, 10
140
        shr     bh, 2
141
        mov     bl, [esi]
142
        shl     bl, 2
143
        shr     bx, 2
144
        inc     esi
145
        cmp     bx, 1419
146
        jc      .valid
147
        shl     bx, 4
148
@@:
149
        jns     @f
150
        inc     esi
151
        shl     bx, 1
152
        jmp     @b
153
@@:
154
        xor     ebx, ebx
155
.valid:
156
        pushd   esi edi 16
157
        shl     ebx, 4
158
        add     ebx, fontUni
159
        mov     esi, [esp+12+fontMultiplier]
160
        call    drawChar
161
        imul    esi, 8*4
162
        pop     edi
163
        pop     edi
164
        add     edi, esi
165
        pop     esi
166
        jmp     .drawUTF8
167
.draw866:
168
        dec     dword [esp]
169
        js      .done
170
        xor     ebx, ebx
171
        mov     bl, [esi]
172
        test    ebx, ebx
173
        jz      .done
174
        inc     esi
175
        pushd   esi edi 9
176
        lea     ebx, [ebx*8+ebx+font1]
177
        mov     esi, [esp+12+fontMultiplier]
178
        call    drawChar
179
        imul    esi, 6*4
180
        pop     edi
181
        pop     edi
182
        add     edi, esi
183
        pop     esi
184
        jmp     .draw866
185
.done:
186
        mov     ecx, edi
187
        pop     eax eax eax esi edx ebx ebp ebp ebp
188
        mov     edi, [esp]
189
        test    edi, edi
190
        jnz     @f
191
        pop     eax
192
        ret
193
@@:
194
        push    eax
195
        sub     ecx, edi
196
        shr     ecx, 2
197
        add     edx, ecx
198
        inc     ecx
199
        push    ecx
200
        push    edi
201
.drawPicture:
202
        mov     eax, -1
203
        repz scasd
204
        jcxz    @f
205
        mov     eax, edx
206
        sub     eax, ecx
207
        push    ecx
208
        mov     ecx, [edi-4]
209
        xchg    esi, edi
2453 mario79 210
        call    __sys_putpixel
5665 Pathoswith 211
        xchg    esi, edi
2536 mario79 212
        pop     ecx
5665 Pathoswith 213
        jmp     .drawPicture
2536 mario79 214
@@:
5665 Pathoswith 215
        pop     edi
216
        mov     ecx, [esp]
217
        add     edi, [esp+4]
2288 clevermous 218
        inc     ebx
5665 Pathoswith 219
        push    edi
220
        dec     ebp
221
        jnz     .drawPicture
222
        add     esp, 12
223
        call    kernel_free
224
        ret
225
.ret:
226
        add     esp, 28
227
        ret
228
 
229
drawChar:
230
        mov     dl, [ebx]
231
.raw:
232
        bsf     eax, edx
233
        jz      .nextRaw
234
        imul    eax, esi
235
        shl     eax, 2
236
        push    edi
237
        add     edi, eax
238
        mov     ecx, esi
2288 clevermous 239
        dec     esi
5665 Pathoswith 240
        jnz     .square
241
        mov     [edi], ebp
242
        inc     esi
243
        cmp     [fontSmoothing], 0
244
        jz      .nextPixel
245
.checkLeftSubP:
246
        bsf     eax, edx
247
        dec     eax
248
        js      .checkRightSubP
249
        bt      [ebx], eax
250
        jc      .checkRightSubP
251
        dec     eax
252
        js      .checkLeftDownSubP
253
        bt      [ebx], eax
254
        jc      .checkRightSubP
255
.checkLeftDownSubP:
256
        inc     eax
257
        bt      [ebx+1], eax
258
        jnc     .checkLeftUpSubP
259
        inc     eax
260
        bt      [ebx+1], eax
261
        jnc     @f
262
        bt      [ebx-1], eax
263
        jc      .checkRightSubP
264
        dec     eax
265
        dec     eax
266
        js      @f
267
        bt      [ebx+1], eax
268
        jnc     @f
269
        inc     eax
270
.checkLeftUpSubP:
271
        bt      [ebx-1], eax
272
        jnc     .checkRightSubP
273
        inc     eax
274
        bt      [ebx-1], eax
275
        jnc     @f
276
        bt      [ebx+1], eax
277
        jc      .checkRightSubP
278
        dec     eax
279
        dec     eax
280
        js      @f
281
        bt      [ebx-1], eax
282
        jc      .checkRightSubP
283
@@:
284
        mov     ecx, [esp+20+deltaToScreen]
285
        mov     eax, [edi-4]
286
        test    ecx, ecx
2536 mario79 287
        jz      @f
5665 Pathoswith 288
        pusha
289
        lea     ebx, [edi+ecx-4]
290
        shr     ebx, 2
291
        call    syscall_getpixel
292
        popa
2536 mario79 293
@@:
5665 Pathoswith 294
        mov     ecx, eax
295
        mov     eax, ebp
296
        shr     al, 1
297
        shr     cl, 1
298
        add     al, cl
299
        shr     ah, 2
300
        shr     ch, 2
301
        add     ah, ch
302
        add     ah, ch
303
        add     ah, ch
304
        ror     eax, 8
305
        ror     ecx, 8
306
        mov     ah, ch
307
        rol     eax, 8
308
        mov     [edi-4], eax
309
.checkRightSubP:
310
        bsf     eax, edx
311
        inc     eax
312
        bt      [ebx], eax
313
        jc      .nextPixel
314
        inc     eax
315
        bt      [ebx], eax
316
        jc      .nextPixel
317
        dec     eax
318
.checkRightDownSubP:
319
        bt      [ebx+1], eax
320
        jnc     .checkRightUpSubP
321
        dec     eax
322
        bt      [ebx+1], eax
323
        jnc     @f
324
        bt      [ebx-1], eax
325
        jc      .nextPixel
326
        inc     eax
327
        inc     eax
328
        bt      [ebx+1], eax
329
        jnc     @f
330
        dec     eax
331
.checkRightUpSubP:
332
        bt      [ebx-1], eax
333
        jnc     .nextPixel
334
        dec     eax
335
        bt      [ebx-1], eax
336
        jnc     @f
337
        bt      [ebx+1], eax
338
        jc      .nextPixel
339
        inc     eax
340
        inc     eax
341
        bt      [ebx-1], eax
342
        jc      .nextPixel
343
@@:
344
        mov     ecx, [esp+20+deltaToScreen]
345
        mov     eax, [edi+4]
346
        test    ecx, ecx
2536 mario79 347
        jz      @f
5665 Pathoswith 348
        pusha
349
        lea     ebx, [edi+ecx+4]
350
        shr     ebx, 2
351
        call    syscall_getpixel
352
        popa
2536 mario79 353
@@:
5665 Pathoswith 354
        mov     ecx, eax
355
        mov     eax, ebp
356
        shr     ah, 2
357
        shr     ch, 2
358
        add     ah, ch
359
        add     ah, ch
360
        add     ah, ch
361
        mov     al, cl
362
        ror     eax, 8
363
        ror     ecx, 8
364
        shr     ah, 1
365
        shr     ch, 1
366
        add     ah, ch
367
        rol     eax, 8
368
        mov     [edi+4], eax
369
        jmp     .nextPixel
370
.square:
371
        mov     eax, esi
372
@@:
373
        mov     [edi+eax*4], ebp
374
        dec     eax
375
        jns     @b
376
        add     edi, [esp+20+widthX]
377
        dec     ecx
378
        jnz     .square
379
        inc     esi
380
        mov     edi, [esp]
381
.checkLeft:
382
        bsf     eax, edx
383
        dec     eax
384
        js      .checkRight
385
        bt      [ebx], eax
386
        jc      .checkRight
387
.checkLeftDown:
388
        bt      [ebx+1], eax
389
        jnc     .checkLeftUp
390
        mov     ecx, eax
2288 clevermous 391
        inc     eax
5665 Pathoswith 392
        bt      [ebx+1], eax
393
        jc      @f
394
        bt      [ebx-1], eax
395
        jnc     .downRightLow
396
        bt      [ebx-2], eax
397
        jc      .downRightLow
398
        dec     eax
399
        bt      [ebx-1], eax
400
        jc      .downRightLow
401
        dec     eax
402
        js      .downRightHigh
403
        bt      [ebx-2], eax
404
        jc      .downRightLow
405
        jmp     .downRightHigh
406
@@:
407
        bt      [ebx-1], eax
408
        jc      .checkLeftUp
409
        dec     eax
410
        dec     eax
411
        js      .downRightLow
412
        bt      [ebx+1], eax
413
        jc      .checkLeftUp
414
.downRightLow:
415
        imul    ecx, esi
416
        shl     ecx, 2
417
        add     edi, ecx
2288 clevermous 418
        dec     esi
5665 Pathoswith 419
        mov     eax, [esp+20+widthX]
420
        imul    eax, esi
421
        add     edi, eax
422
        add     edi, 4
423
        mov     ecx, esi
424
        dec     ecx
425
.drawDownRight:
426
        mov     eax, ecx
427
@@:
428
        mov     [edi+eax*4], ebp
429
        dec     eax
430
        jns     @b
431
        sub     edi, [esp+20+widthX]
432
        add     edi, 4
433
        dec     ecx
434
        jns     .drawDownRight
435
        inc     esi
436
        mov     edi, [esp]
437
        jmp     .checkLeftUp
438
.downRightHigh:
439
        imul    ecx, esi
440
        shl     ecx, 2
441
        add     edi, ecx
442
        dec     esi
443
        mov     eax, [esp+20+widthX]
444
        imul    eax, esi
445
        add     edi, eax
446
        add     edi, 4
447
        mov     ecx, esi
448
        dec     ecx
449
.drawDownRightHigh:
450
        mov     eax, ecx
451
@@:
452
        mov     [edi+eax*4], ebp
453
        dec     eax
454
        jns     @b
455
        sub     edi, [esp+20+widthX]
456
        mov     eax, ecx
457
@@:
458
        mov     [edi+eax*4], ebp
459
        dec     eax
460
        jns     @b
461
        sub     edi, [esp+20+widthX]
462
        add     edi, 4
463
        dec     ecx
464
        jns     .drawDownRightHigh
465
        inc     esi
466
        mov     edi, [esp]
467
.checkLeftUp:
468
        bsf     eax, edx
469
        dec     eax
470
        bt      [ebx-1], eax
471
        jnc     .checkRight
472
        mov     ecx, eax
473
        inc     eax
474
        bt      [ebx-1], eax
475
        jc      @f
476
        bt      [ebx+1], eax
477
        jnc     .upRightLow
478
        bt      [ebx+2], eax
479
        jc      .upRightLow
480
        dec     eax
481
        bt      [ebx+1], eax
482
        jc      .upRightLow
483
        dec     eax
484
        js      .upRightHigh
485
        bt      [ebx+2], eax
486
        jc      .upRightLow
487
        jmp     .upRightHigh
488
@@:
489
        bt      [ebx+1], eax
490
        jc      .checkRight
491
        dec     eax
492
        dec     eax
493
        js      .upRightLow
494
        bt      [ebx-1], eax
495
        jc      .checkRight
496
.upRightLow:
497
        imul    ecx, esi
498
        shl     ecx, 2
499
        add     edi, ecx
500
        add     edi, 4
501
        mov     ecx, esi
502
        dec     ecx
503
        dec     ecx
504
.drawUpRight:
505
        mov     eax, ecx
506
@@:
507
        mov     [edi+eax*4], ebp
508
        dec     eax
509
        jns     @b
510
        add     edi, [esp+20+widthX]
511
        add     edi, 4
512
        dec     ecx
513
        jns     .drawUpRight
514
        mov     edi, [esp]
515
        jmp     .checkRight
516
.upRightHigh:
517
        imul    ecx, esi
518
        shl     ecx, 2
519
        add     edi, ecx
520
        add     edi, 4
521
        mov     ecx, esi
522
        dec     ecx
523
        dec     ecx
524
.drawUpRightHigh:
525
        mov     eax, ecx
526
@@:
527
        mov     [edi+eax*4], ebp
528
        dec     eax
529
        jns     @b
530
        add     edi, [esp+20+widthX]
531
        mov     eax, ecx
532
@@:
533
        mov     [edi+eax*4], ebp
534
        dec     eax
535
        jns     @b
536
        add     edi, [esp+20+widthX]
537
        add     edi, 4
538
        dec     ecx
539
        jns     .drawUpRightHigh
540
        mov     edi, [esp]
541
.checkRight:
542
        bsf     eax, edx
543
        inc     eax
544
        bt      [ebx], eax
545
        jc      .nextPixel
546
.checkRightDown:
547
        bt      [ebx+1], eax
548
        jnc     .checkRightUp
549
        mov     ecx, eax
550
        dec     eax
551
        bt      [ebx+1], eax
552
        jc      @f
553
        bt      [ebx-1], eax
554
        jnc     .downLeftLow
555
        bt      [ebx-2], eax
556
        jc      .downLeftLow
557
        inc     eax
558
        bt      [ebx-1], eax
559
        jc      .downLeftLow
560
        inc     eax
561
        bt      [ebx-2], eax
562
        jc      .downLeftLow
563
        jmp     .downLeftHigh
564
@@:
565
        bt      [ebx-1], eax
566
        jc      .checkRightUp
567
        inc     eax
568
        inc     eax
569
        bt      [ebx+1], eax
570
        jc      .checkRightUp
571
.downLeftLow:
572
        imul    ecx, esi
573
        shl     ecx, 2
574
        add     edi, ecx
575
        dec     esi
576
        mov     eax, [esp+20+widthX]
577
        imul    eax, esi
578
        add     edi, eax
579
        mov     ecx, esi
580
        dec     ecx
581
.drawDownLeft:
582
        mov     eax, ecx
583
@@:
584
        mov     [edi+eax*4], ebp
585
        dec     eax
586
        jns     @b
587
        sub     edi, [esp+20+widthX]
588
        dec     ecx
589
        jns     .drawDownLeft
590
        inc     esi
591
        mov     edi, [esp]
592
        jmp     .checkRightUp
593
.downLeftHigh:
594
        imul    ecx, esi
595
        shl     ecx, 2
596
        add     edi, ecx
597
        dec     esi
598
        mov     eax, [esp+20+widthX]
599
        imul    eax, esi
600
        add     edi, eax
601
        mov     ecx, esi
602
        dec     ecx
603
.drawDownLeftHigh:
604
        mov     eax, ecx
605
@@:
606
        mov     [edi+eax*4], ebp
607
        dec     eax
608
        jns     @b
609
        sub     edi, [esp+20+widthX]
610
        mov     eax, ecx
611
@@:
612
        mov     [edi+eax*4], ebp
613
        dec     eax
614
        jns     @b
615
        sub     edi, [esp+20+widthX]
616
        dec     ecx
617
        jns     .drawDownLeftHigh
618
        inc     esi
619
        mov     edi, [esp]
620
.checkRightUp:
621
        bsf     eax, edx
622
        inc     eax
623
        bt      [ebx-1], eax
624
        jnc     .nextPixel
625
        mov     ecx, eax
626
        dec     eax
627
        bt      [ebx-1], eax
628
        jc      @f
629
        bt      [ebx+1], eax
630
        jnc     .upLeftLow
631
        bt      [ebx+2], eax
632
        jc      .upLeftLow
633
        inc     eax
634
        bt      [ebx+1], eax
635
        jc      .upLeftLow
636
        inc     eax
637
        bt      [ebx+2], eax
638
        jc      .upLeftLow
639
        jmp     .upLeftHigh
640
@@:
641
        bt      [ebx+1], eax
642
        jc      .nextPixel
643
        inc     eax
644
        inc     eax
645
        bt      [ebx-1], eax
646
        jc      .nextPixel
647
.upLeftLow:
648
        imul    ecx, esi
649
        shl     ecx, 2
650
        add     edi, ecx
651
        mov     ecx, esi
652
        dec     ecx
653
        dec     ecx
654
.drawUpLeft:
655
        mov     eax, ecx
656
@@:
657
        mov     [edi+eax*4], ebp
658
        dec     eax
659
        jns     @b
660
        add     edi, [esp+20+widthX]
661
        dec     ecx
662
        jns     .drawUpLeft
663
        jmp     .nextPixel
664
.upLeftHigh:
665
        imul    ecx, esi
666
        shl     ecx, 2
667
        add     edi, ecx
668
        mov     ecx, esi
669
        dec     ecx
670
        dec     ecx
671
.drawUpLeftHigh:
672
        mov     eax, ecx
673
@@:
674
        mov     [edi+eax*4], ebp
675
        dec     eax
676
        jns     @b
677
        add     edi, [esp+20+widthX]
678
        mov     eax, ecx
679
@@:
680
        mov     [edi+eax*4], ebp
681
        dec     eax
682
        jns     @b
683
        add     edi, [esp+20+widthX]
684
        dec     ecx
685
        jns     .drawUpLeftHigh
686
.nextPixel:
687
        bsf     eax, edx
688
        btr     edx, eax
689
        pop     edi
690
        jmp     .raw
691
.nextRaw:
2288 clevermous 692
        inc     ebx
5665 Pathoswith 693
        mov     eax, [esp+16+widthX]
694
        imul    eax, esi
695
        add     edi, eax
696
        dec     dword [esp+4]
697
        jnz     drawChar
698
        ret
2536 mario79 699
 
5665 Pathoswith 700
fontSmoothing   db  1
701
font1:
3415 esevece 702
  if lang eq sp
703
  file 'char_sp.mt'
3927 kaitz 704
  else if lang eq et
705
  file 'char_et.mt'
3415 esevece 706
  else
2640 mario79 707
  file 'char.mt'
3415 esevece 708
  end if
5665 Pathoswith 709
fontUni:
710
file 'charUni.mt'