Subversion Repositories Kolibri OS

Rev

Rev 5847 | Rev 5921 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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