]> git.sur5r.net Git - cc65/blob - libsrc/tgi/tgi_settextstyle.s
Restore src/cc65/locals.c:278 to its orignal state
[cc65] / libsrc / tgi / tgi_settextstyle.s
1 ;
2 ; Ullrich von Bassewitz, 2009-10-30
3 ;
4
5
6         .include        "zeropage.inc"
7         .include        "tgi-kernel.inc"
8
9         .import         umul8x16r24
10         .import         popa, popax
11
12         .macpack        cpu
13
14 ;-----------------------------------------------------------------------------
15 ; void __fastcall__ tgi_settextstyle (unsigned width, unsigned height,
16 ;                                     unsigned char dir, unsigned char font);
17 ; /* Set the style for text output. The scaling factors for width and height
18 ; ** are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
19 ; ** dir is one of the TGI_TEXT_XXX constants. font is one of the TGI_FONT_XXX
20 ; ** constants.
21 ; */
22 ;
23
24 .proc   _tgi_settextstyle
25
26         sta     _tgi_font               ; Remember the font to use
27         jsr     popa
28         sta     _tgi_textdir            ; Remember the direction
29
30 ; Pop the height and run directly into tgi_textscale
31
32         jsr     popax
33
34 .endproc
35
36 ;-----------------------------------------------------------------------------
37 ; void __fastcall__ tgi_settextscale (unsigned width, unsigned height);
38 ; /* Set the scaling for text output. The scaling factors for width and height
39 ; ** are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
40 ; */
41
42 .proc   _tgi_settextscale
43
44 ; Setup the height
45
46         ldy     _tgi_fontheight         ; Get height of bitmap font in pixels
47         sty     ptr1                    ; Save for later
48         ldy     #6                      ; Address the height
49         jsr     process_onedim          ; Process height
50
51 ; Setup the width
52
53         jsr     popax                   ; Get width scale into a/x
54         ldy     _tgi_fontwidth          ; Get width of bitmap font in pixels
55         sty     ptr1                    ; Save for later
56         ldy     #0                      ; Address the width
57
58 ; Process one character dimension. That means:
59 ;
60 ;   - Store the vector font dimension in 8.8 format
61 ;   - If necessary, round up/down to next integer
62 ;   - Store the bitmap font dimension in 8.8 format
63 ;   - Multiply by size of bitmap char in pixels
64 ;   - Store the bitmap font size in 8.8 format
65 ;
66
67 process_onedim:
68
69         jsr     store                   ; Store vector font scale factor
70         bit     _tgi_flags              ; Fine grained scaling support avail?
71         bmi     @L2                     ; Jump if yes
72
73         asl     a                       ; Round to nearest full integer
74         bcc     @L1
75         inx
76 @L1:    lda     #0
77
78 @L2:    jsr     store                   ; Store bitmap font scale factor
79
80 ; The size of the font in pixels in the selected dimension is already in ptr1
81 ; So if we call umul8x16r24 we get the size in pixels in 16.8 fixed point.
82 ; Disallowing characters larger than 256 pixels, we just drop the high byte
83 ; and remember the low 16 bit as size in 8.8 format.
84
85 .if (.cpu .bitand ::CPU_ISET_65SC02)
86         phy                             ; Save Y
87         jsr     umul8x16r24
88         ply                             ; Restore Y
89 .else
90         sty     tmp1                    ; Save Y
91         jsr     umul8x16r24
92         ldy     tmp1                    ; Restore Y
93 .endif
94
95 store:  sta     _tgi_textscalew,y
96         iny
97         pha
98         txa
99         sta     _tgi_textscalew,y
100         iny
101         pla
102         rts
103
104 .endproc
105
106