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