]> git.sur5r.net Git - cc65/blob - libsrc/tgi/tgi_gettextheight.s
Merge pull request #740 from laubzega/master
[cc65] / libsrc / tgi / tgi_gettextheight.s
1 ;
2 ; Ullrich von Bassewitz, 2009-10-30
3 ;
4
5
6         .include        "tgi-kernel.inc"
7         .include        "tgi-vectorfont.inc"
8         .include        "zeropage.inc"
9
10
11 ;-----------------------------------------------------------------------------
12 ; unsigned __fastcall__ tgi_gettextheight (const char* s);
13 ; /* Calculate the height of the text in pixels according to the current text
14 ; ** style.
15 ; */
16 ;
17
18 .proc   _tgi_gettextheight        
19
20         ldy     _tgi_font
21         bne     @L2                     ; Jump if vector font
22
23 ; Return the height for the bitmap font
24
25         lda     _tgi_charheight
26         ldx     #0
27 @L1:    rts
28
29 ; Return the height for the vector font
30
31 @L2:    lda     _tgi_vectorfont
32         tax
33         ora     _tgi_vectorfont+1
34         beq     @L1                     ; Return zero if no font
35
36         stx     ptr1
37         lda     _tgi_vectorfont+1
38         sta     ptr1+1
39         ldy     #TGI_VECTORFONT::HEIGHT
40         lda     (ptr1),y                ; Get height of font
41
42         sta     ptr1
43         lda     #0
44         sta     ptr1+1                  ; Save base height in ptr1
45
46         lda     _tgi_textscaleh
47         ldx     _tgi_textscaleh+1       ; Get scale factor ...
48         jmp     tgi_imulround           ; ... and return scaled result
49
50 .endproc
51
52