]> git.sur5r.net Git - cc65/blob - libsrc/tgi/tgi_textsize.s
added sleep() implementation
[cc65] / libsrc / tgi / tgi_textsize.s
1 ;
2 ; Ullrich von Bassewitz, 22.06.2002
3 ;
4
5
6         .include        "tgi-kernel.inc"
7
8         .import         _strlen, pushax, tosumulax
9
10 ;-----------------------------------------------------------------------------
11 ; unsigned __fastcall__ tgi_textwidth (const char* s);
12 ; /* Calculate the width of the text in pixels according to the current text
13 ;  * style.
14 ;  */
15
16
17 _tgi_textwidth:
18
19         ldy     _tgi_textdir            ; Get text direction
20         bne     height
21
22 ; Result is
23 ;
24 ;       strlen (s) * tgi_textmagx * tgi_fontsizex
25 ;
26 ; Since we don't expect textmagx to have large values, we do the multiplication
27 ; by looping.
28
29 width:  jsr     _strlen
30         jsr     pushax
31
32         lda     #0
33         tax
34         ldy     _tgi_textmagx
35 @L1:    clc
36         adc     _tgi_fontsizex
37         bcc     @L2
38         inx
39 @L2:    dey
40         bne     @L1
41
42         jmp     tosumulax               ; Result * strlen (s)
43
44 ;-----------------------------------------------------------------------------
45 ; unsigned __fastcall__ tgi_textheight (const char* s);
46 ; /* Calculate the height of the text in pixels according to the current text
47 ;  * style.
48 ;  */
49
50 _tgi_textheight:
51         ldy     _tgi_textdir            ; Get text direction
52         bne     width                   ; Jump if vertical
53
54 ; Result is
55 ;
56 ;       tgi_textmagy * tgi_fontsizey
57 ;
58 ; Since we don't expect textmagx to have large values, we do the multiplication
59 ; by looping.
60
61 height: lda     #0
62         tax
63         ldy     _tgi_textmagy
64 @L1:    clc
65         adc     _tgi_fontsizey
66         bcc     @L2
67         inx
68 @L2:    dey
69         bne     @L1
70         rts
71
72