]> git.sur5r.net Git - cc65/blob - libsrc/tgi/tgi_textstyle.s
Working on the TGI API, adding vector fonts. Only roughly tested!
[cc65] / libsrc / tgi / tgi_textstyle.s
1 ;
2 ; Ullrich von Bassewitz, 2009-10-30
3 ;
4
5
6         .include        "tgi-kernel.inc"
7
8         .import         popa, popax
9
10
11 ;-----------------------------------------------------------------------------
12 ; Calculate either the total height or the total width of a bitmapped
13 ; character, depending on the value in Y. On entry, X contains the scaling
14 ; factor. Since it is usually small, we multiplicate by doing repeated adds.
15 ; The function returns zero in X and the calculated value in A.
16
17 .proc   charsize_helper
18
19         lda     _tgi_fontwidth,y
20         jmp     @L2
21 @L1:    clc
22         adc     _tgi_fontwidth,y
23 @L2:    dex
24         bne     @L1
25         sta     _tgi_charwidth,y
26         rts
27
28 .endproc
29
30 ;-----------------------------------------------------------------------------
31 ; void __fastcall__ tgi_textstyle (unsigned width, unsigned height,
32 ;                                  unsigned char dir, unsigned char font);
33 ; /* Set the style for text output. The scaling factors for width and height
34 ;  * are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
35 ;  * dir is one of the TGI_TEXT_XXX constants. font is one of the TGI_FONT_XXX
36 ;  * constants.
37 ;  */
38 ;
39
40 .proc   _tgi_textstyle
41
42         sta     _tgi_font               ; Remember the font to use
43         jsr     popa
44         sta     _tgi_textdir            ; Remember the direction
45
46 ; Pop the height and run directly into tgi_textscale
47
48         jsr     popax
49
50 .endproc
51
52 ;-----------------------------------------------------------------------------
53 ; void __fastcall__ tgi_textscale (unsigned width, unsigned height);
54 ; /* Set the scaling for text output. The scaling factors for width and height
55 ;  * are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
56 ;  */
57
58 .proc   _tgi_textscale
59
60 ; The height value is in 8.8 fixed point. Store it and calculate a rounded
61 ; value for scaling the bitmapped system font in the driver.
62
63         sta     _tgi_textscaleh+0
64         stx     _tgi_textscaleh+1
65         asl     a                       ; Check value behind comma
66         bcc     @L1
67         inx                             ; Round
68 @L1:    stx     _tgi_textscaleh+2       ; Store rounded value
69
70 ; Calculate the total height of the bitmapped font and remember it.
71
72         ldy     #1
73         jsr     charsize_helper
74
75 ; The width value is in 8.8 fixed point. Store it and calculate a rounded
76 ; value for scaling the bitmapped system font in the driver.
77
78         jsr     popax                   ; height
79         sta     _tgi_textscalew+0
80         stx     _tgi_textscalew+1
81         asl     a                       ; Check value behind comma
82         bcc     @L2
83         inx                             ; Round
84 @L2:    stx     _tgi_textscalew+2       ; Store rounded value
85
86 ; Calculate the total width of the bitmapped font and remember it.
87
88         ldy     #0
89         jsr     charsize_helper
90
91 ; Load values and call the driver, parameters are passed in registers
92
93         ldx     _tgi_textscalew+2
94         ldy     _tgi_textscaleh+2
95         lda     _tgi_textdir
96         jmp     tgi_textstyle
97
98 .endproc
99
100