Subversion Repositories Kolibri OS

Rev

Rev 5665 | Rev 5839 | 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: 5681 $
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
5681 leency 133
@@:
5665 Pathoswith 134
        xor     ebx, ebx
135
        mov     bl, [esi]
136
        inc     esi
137
        test    bl, bl
138
        jz      .done
139
        jns     .valid
140
        shl     bx, 10
5681 leency 141
        jnc     @b
5665 Pathoswith 142
        shr     bh, 2
143
        mov     bl, [esi]
144
        shl     bl, 2
145
        shr     bx, 2
146
        inc     esi
147
        cmp     bx, 1419
148
        jc      .valid
149
        shl     bx, 4
150
@@:
151
        jns     @f
152
        inc     esi
153
        shl     bx, 1
154
        jmp     @b
155
@@:
156
        xor     ebx, ebx
157
.valid:
158
        pushd   esi edi 16
159
        shl     ebx, 4
160
        add     ebx, fontUni
161
        mov     esi, [esp+12+fontMultiplier]
162
        call    drawChar
163
        imul    esi, 8*4
164
        pop     edi
165
        pop     edi
166
        add     edi, esi
167
        pop     esi
168
        jmp     .drawUTF8
169
.draw866:
170
        dec     dword [esp]
171
        js      .done
172
        xor     ebx, ebx
173
        mov     bl, [esi]
174
        test    ebx, ebx
175
        jz      .done
176
        inc     esi
177
        pushd   esi edi 9
178
        lea     ebx, [ebx*8+ebx+font1]
179
        mov     esi, [esp+12+fontMultiplier]
180
        call    drawChar
181
        imul    esi, 6*4
182
        pop     edi
183
        pop     edi
184
        add     edi, esi
185
        pop     esi
186
        jmp     .draw866
187
.done:
188
        mov     ecx, edi
189
        pop     eax eax eax esi edx ebx ebp ebp ebp
190
        mov     edi, [esp]
191
        test    edi, edi
192
        jnz     @f
193
        pop     eax
194
        ret
195
@@:
196
        push    eax
197
        sub     ecx, edi
198
        shr     ecx, 2
199
        add     edx, ecx
200
        inc     ecx
201
        push    ecx
202
        push    edi
203
.drawPicture:
204
        mov     eax, -1
205
        repz scasd
206
        jcxz    @f
207
        mov     eax, edx
208
        sub     eax, ecx
209
        push    ecx
210
        mov     ecx, [edi-4]
211
        xchg    esi, edi
2453 mario79 212
        call    __sys_putpixel
5665 Pathoswith 213
        xchg    esi, edi
2536 mario79 214
        pop     ecx
5665 Pathoswith 215
        jmp     .drawPicture
2536 mario79 216
@@:
5665 Pathoswith 217
        pop     edi
218
        mov     ecx, [esp]
219
        add     edi, [esp+4]
2288 clevermous 220
        inc     ebx
5665 Pathoswith 221
        push    edi
222
        dec     ebp
223
        jnz     .drawPicture
224
        add     esp, 12
225
        call    kernel_free
226
        ret
227
.ret:
228
        add     esp, 28
229
        ret
230
 
231
drawChar:
232
        mov     dl, [ebx]
233
.raw:
234
        bsf     eax, edx
235
        jz      .nextRaw
236
        imul    eax, esi
237
        shl     eax, 2
238
        push    edi
239
        add     edi, eax
240
        mov     ecx, esi
2288 clevermous 241
        dec     esi
5665 Pathoswith 242
        jnz     .square
243
        mov     [edi], ebp
244
        inc     esi
245
        cmp     [fontSmoothing], 0
246
        jz      .nextPixel
247
.checkLeftSubP:
248
        bsf     eax, edx
249
        dec     eax
250
        js      .checkRightSubP
251
        bt      [ebx], eax
252
        jc      .checkRightSubP
253
        dec     eax
254
        js      .checkLeftDownSubP
255
        bt      [ebx], eax
256
        jc      .checkRightSubP
257
.checkLeftDownSubP:
258
        inc     eax
259
        bt      [ebx+1], eax
260
        jnc     .checkLeftUpSubP
261
        inc     eax
262
        bt      [ebx+1], eax
263
        jnc     @f
264
        bt      [ebx-1], eax
265
        jc      .checkRightSubP
266
        dec     eax
267
        dec     eax
268
        js      @f
269
        bt      [ebx+1], eax
270
        jnc     @f
271
        inc     eax
272
.checkLeftUpSubP:
273
        bt      [ebx-1], eax
274
        jnc     .checkRightSubP
275
        inc     eax
276
        bt      [ebx-1], eax
277
        jnc     @f
278
        bt      [ebx+1], eax
279
        jc      .checkRightSubP
280
        dec     eax
281
        dec     eax
282
        js      @f
283
        bt      [ebx-1], eax
284
        jc      .checkRightSubP
285
@@:
286
        mov     ecx, [esp+20+deltaToScreen]
287
        mov     eax, [edi-4]
288
        test    ecx, ecx
2536 mario79 289
        jz      @f
5665 Pathoswith 290
        pusha
291
        lea     ebx, [edi+ecx-4]
292
        shr     ebx, 2
293
        call    syscall_getpixel
294
        popa
2536 mario79 295
@@:
5665 Pathoswith 296
        mov     ecx, eax
297
        mov     eax, ebp
298
        shr     al, 1
299
        shr     cl, 1
300
        add     al, cl
301
        shr     ah, 2
302
        shr     ch, 2
303
        add     ah, ch
304
        add     ah, ch
305
        add     ah, ch
306
        ror     eax, 8
307
        ror     ecx, 8
308
        mov     ah, ch
309
        rol     eax, 8
310
        mov     [edi-4], eax
311
.checkRightSubP:
312
        bsf     eax, edx
313
        inc     eax
314
        bt      [ebx], eax
315
        jc      .nextPixel
316
        inc     eax
317
        bt      [ebx], eax
318
        jc      .nextPixel
319
        dec     eax
320
.checkRightDownSubP:
321
        bt      [ebx+1], eax
322
        jnc     .checkRightUpSubP
323
        dec     eax
324
        bt      [ebx+1], eax
325
        jnc     @f
326
        bt      [ebx-1], eax
327
        jc      .nextPixel
328
        inc     eax
329
        inc     eax
330
        bt      [ebx+1], eax
331
        jnc     @f
332
        dec     eax
333
.checkRightUpSubP:
334
        bt      [ebx-1], eax
335
        jnc     .nextPixel
336
        dec     eax
337
        bt      [ebx-1], eax
338
        jnc     @f
339
        bt      [ebx+1], eax
340
        jc      .nextPixel
341
        inc     eax
342
        inc     eax
343
        bt      [ebx-1], eax
344
        jc      .nextPixel
345
@@:
346
        mov     ecx, [esp+20+deltaToScreen]
347
        mov     eax, [edi+4]
348
        test    ecx, ecx
2536 mario79 349
        jz      @f
5665 Pathoswith 350
        pusha
351
        lea     ebx, [edi+ecx+4]
352
        shr     ebx, 2
353
        call    syscall_getpixel
354
        popa
2536 mario79 355
@@:
5665 Pathoswith 356
        mov     ecx, eax
357
        mov     eax, ebp
358
        shr     ah, 2
359
        shr     ch, 2
360
        add     ah, ch
361
        add     ah, ch
362
        add     ah, ch
363
        mov     al, cl
364
        ror     eax, 8
365
        ror     ecx, 8
366
        shr     ah, 1
367
        shr     ch, 1
368
        add     ah, ch
369
        rol     eax, 8
370
        mov     [edi+4], eax
371
        jmp     .nextPixel
372
.square:
373
        mov     eax, esi
374
@@:
375
        mov     [edi+eax*4], ebp
376
        dec     eax
377
        jns     @b
378
        add     edi, [esp+20+widthX]
379
        dec     ecx
380
        jnz     .square
381
        inc     esi
382
        mov     edi, [esp]
383
.checkLeft:
384
        bsf     eax, edx
385
        dec     eax
386
        js      .checkRight
387
        bt      [ebx], eax
388
        jc      .checkRight
389
.checkLeftDown:
390
        bt      [ebx+1], eax
391
        jnc     .checkLeftUp
392
        mov     ecx, eax
2288 clevermous 393
        inc     eax
5665 Pathoswith 394
        bt      [ebx+1], eax
395
        jc      @f
396
        bt      [ebx-1], eax
397
        jnc     .downRightLow
398
        bt      [ebx-2], eax
399
        jc      .downRightLow
400
        dec     eax
401
        bt      [ebx-1], eax
402
        jc      .downRightLow
403
        dec     eax
404
        js      .downRightHigh
405
        bt      [ebx-2], eax
406
        jc      .downRightLow
407
        jmp     .downRightHigh
408
@@:
409
        bt      [ebx-1], eax
410
        jc      .checkLeftUp
411
        dec     eax
412
        dec     eax
413
        js      .downRightLow
414
        bt      [ebx+1], eax
415
        jc      .checkLeftUp
416
.downRightLow:
417
        imul    ecx, esi
418
        shl     ecx, 2
419
        add     edi, ecx
2288 clevermous 420
        dec     esi
5665 Pathoswith 421
        mov     eax, [esp+20+widthX]
422
        imul    eax, esi
423
        add     edi, eax
424
        add     edi, 4
425
        mov     ecx, esi
426
        dec     ecx
427
.drawDownRight:
428
        mov     eax, ecx
429
@@:
430
        mov     [edi+eax*4], ebp
431
        dec     eax
432
        jns     @b
433
        sub     edi, [esp+20+widthX]
434
        add     edi, 4
435
        dec     ecx
436
        jns     .drawDownRight
437
        inc     esi
438
        mov     edi, [esp]
439
        jmp     .checkLeftUp
440
.downRightHigh:
441
        imul    ecx, esi
442
        shl     ecx, 2
443
        add     edi, ecx
444
        dec     esi
445
        mov     eax, [esp+20+widthX]
446
        imul    eax, esi
447
        add     edi, eax
448
        add     edi, 4
449
        mov     ecx, esi
450
        dec     ecx
451
.drawDownRightHigh:
452
        mov     eax, ecx
453
@@:
454
        mov     [edi+eax*4], ebp
455
        dec     eax
456
        jns     @b
457
        sub     edi, [esp+20+widthX]
458
        mov     eax, ecx
459
@@:
460
        mov     [edi+eax*4], ebp
461
        dec     eax
462
        jns     @b
463
        sub     edi, [esp+20+widthX]
464
        add     edi, 4
465
        dec     ecx
466
        jns     .drawDownRightHigh
467
        inc     esi
468
        mov     edi, [esp]
469
.checkLeftUp:
470
        bsf     eax, edx
471
        dec     eax
472
        bt      [ebx-1], eax
473
        jnc     .checkRight
474
        mov     ecx, eax
475
        inc     eax
476
        bt      [ebx-1], eax
477
        jc      @f
478
        bt      [ebx+1], eax
479
        jnc     .upRightLow
480
        bt      [ebx+2], eax
481
        jc      .upRightLow
482
        dec     eax
483
        bt      [ebx+1], eax
484
        jc      .upRightLow
485
        dec     eax
486
        js      .upRightHigh
487
        bt      [ebx+2], eax
488
        jc      .upRightLow
489
        jmp     .upRightHigh
490
@@:
491
        bt      [ebx+1], eax
492
        jc      .checkRight
493
        dec     eax
494
        dec     eax
495
        js      .upRightLow
496
        bt      [ebx-1], eax
497
        jc      .checkRight
498
.upRightLow:
499
        imul    ecx, esi
500
        shl     ecx, 2
501
        add     edi, ecx
502
        add     edi, 4
503
        mov     ecx, esi
504
        dec     ecx
505
        dec     ecx
506
.drawUpRight:
507
        mov     eax, ecx
508
@@:
509
        mov     [edi+eax*4], ebp
510
        dec     eax
511
        jns     @b
512
        add     edi, [esp+20+widthX]
513
        add     edi, 4
514
        dec     ecx
515
        jns     .drawUpRight
516
        mov     edi, [esp]
517
        jmp     .checkRight
518
.upRightHigh:
519
        imul    ecx, esi
520
        shl     ecx, 2
521
        add     edi, ecx
522
        add     edi, 4
523
        mov     ecx, esi
524
        dec     ecx
525
        dec     ecx
526
.drawUpRightHigh:
527
        mov     eax, ecx
528
@@:
529
        mov     [edi+eax*4], ebp
530
        dec     eax
531
        jns     @b
532
        add     edi, [esp+20+widthX]
533
        mov     eax, ecx
534
@@:
535
        mov     [edi+eax*4], ebp
536
        dec     eax
537
        jns     @b
538
        add     edi, [esp+20+widthX]
539
        add     edi, 4
540
        dec     ecx
541
        jns     .drawUpRightHigh
542
        mov     edi, [esp]
543
.checkRight:
544
        bsf     eax, edx
545
        inc     eax
546
        bt      [ebx], eax
547
        jc      .nextPixel
548
.checkRightDown:
549
        bt      [ebx+1], eax
550
        jnc     .checkRightUp
551
        mov     ecx, eax
552
        dec     eax
553
        bt      [ebx+1], eax
554
        jc      @f
555
        bt      [ebx-1], eax
556
        jnc     .downLeftLow
557
        bt      [ebx-2], eax
558
        jc      .downLeftLow
559
        inc     eax
560
        bt      [ebx-1], eax
561
        jc      .downLeftLow
562
        inc     eax
563
        bt      [ebx-2], eax
564
        jc      .downLeftLow
565
        jmp     .downLeftHigh
566
@@:
567
        bt      [ebx-1], eax
568
        jc      .checkRightUp
569
        inc     eax
570
        inc     eax
571
        bt      [ebx+1], eax
572
        jc      .checkRightUp
573
.downLeftLow:
574
        imul    ecx, esi
575
        shl     ecx, 2
576
        add     edi, ecx
577
        dec     esi
578
        mov     eax, [esp+20+widthX]
579
        imul    eax, esi
580
        add     edi, eax
581
        mov     ecx, esi
582
        dec     ecx
583
.drawDownLeft:
584
        mov     eax, ecx
585
@@:
586
        mov     [edi+eax*4], ebp
587
        dec     eax
588
        jns     @b
589
        sub     edi, [esp+20+widthX]
590
        dec     ecx
591
        jns     .drawDownLeft
592
        inc     esi
593
        mov     edi, [esp]
594
        jmp     .checkRightUp
595
.downLeftHigh:
596
        imul    ecx, esi
597
        shl     ecx, 2
598
        add     edi, ecx
599
        dec     esi
600
        mov     eax, [esp+20+widthX]
601
        imul    eax, esi
602
        add     edi, eax
603
        mov     ecx, esi
604
        dec     ecx
605
.drawDownLeftHigh:
606
        mov     eax, ecx
607
@@:
608
        mov     [edi+eax*4], ebp
609
        dec     eax
610
        jns     @b
611
        sub     edi, [esp+20+widthX]
612
        mov     eax, ecx
613
@@:
614
        mov     [edi+eax*4], ebp
615
        dec     eax
616
        jns     @b
617
        sub     edi, [esp+20+widthX]
618
        dec     ecx
619
        jns     .drawDownLeftHigh
620
        inc     esi
621
        mov     edi, [esp]
622
.checkRightUp:
623
        bsf     eax, edx
624
        inc     eax
625
        bt      [ebx-1], eax
626
        jnc     .nextPixel
627
        mov     ecx, eax
628
        dec     eax
629
        bt      [ebx-1], eax
630
        jc      @f
631
        bt      [ebx+1], eax
632
        jnc     .upLeftLow
633
        bt      [ebx+2], eax
634
        jc      .upLeftLow
635
        inc     eax
636
        bt      [ebx+1], eax
637
        jc      .upLeftLow
638
        inc     eax
639
        bt      [ebx+2], eax
640
        jc      .upLeftLow
641
        jmp     .upLeftHigh
642
@@:
643
        bt      [ebx+1], eax
644
        jc      .nextPixel
645
        inc     eax
646
        inc     eax
647
        bt      [ebx-1], eax
648
        jc      .nextPixel
649
.upLeftLow:
650
        imul    ecx, esi
651
        shl     ecx, 2
652
        add     edi, ecx
653
        mov     ecx, esi
654
        dec     ecx
655
        dec     ecx
656
.drawUpLeft:
657
        mov     eax, ecx
658
@@:
659
        mov     [edi+eax*4], ebp
660
        dec     eax
661
        jns     @b
662
        add     edi, [esp+20+widthX]
663
        dec     ecx
664
        jns     .drawUpLeft
665
        jmp     .nextPixel
666
.upLeftHigh:
667
        imul    ecx, esi
668
        shl     ecx, 2
669
        add     edi, ecx
670
        mov     ecx, esi
671
        dec     ecx
672
        dec     ecx
673
.drawUpLeftHigh:
674
        mov     eax, ecx
675
@@:
676
        mov     [edi+eax*4], ebp
677
        dec     eax
678
        jns     @b
679
        add     edi, [esp+20+widthX]
680
        mov     eax, ecx
681
@@:
682
        mov     [edi+eax*4], ebp
683
        dec     eax
684
        jns     @b
685
        add     edi, [esp+20+widthX]
686
        dec     ecx
687
        jns     .drawUpLeftHigh
688
.nextPixel:
689
        bsf     eax, edx
690
        btr     edx, eax
691
        pop     edi
692
        jmp     .raw
693
.nextRaw:
2288 clevermous 694
        inc     ebx
5665 Pathoswith 695
        mov     eax, [esp+16+widthX]
696
        imul    eax, esi
697
        add     edi, eax
698
        dec     dword [esp+4]
699
        jnz     drawChar
700
        ret
2536 mario79 701
 
5665 Pathoswith 702
fontSmoothing   db  1
703
font1:
3415 esevece 704
  if lang eq sp
705
  file 'char_sp.mt'
3927 kaitz 706
  else if lang eq et
707
  file 'char_et.mt'
3415 esevece 708
  else
2640 mario79 709
  file 'char.mt'
3415 esevece 710
  end if
5665 Pathoswith 711
fontUni:
712
file 'charUni.mt'