1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 04:30:10 +00:00

Worked on text scaling. This is an intermediate version which doesn't work.

git-svn-id: svn://svn.cc65.org/cc65/trunk@5089 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2011-07-17 18:27:01 +00:00
parent 928f675e4b
commit 83d67e930a
2 changed files with 65 additions and 61 deletions

View File

@ -27,16 +27,14 @@ _tgi_color: .res 1 ; Current drawing color
_tgi_font: .res 1 ; Which font to use
_tgi_textdir: .res 1 ; Current text direction
_tgi_vectorfont: .res 2 ; Pointer to vector font
; The following two store an 8.8 fixed point value in the first two bytes,
; and a rounded integer value in the third byte. The latter is passed to the
; driver to scale the bitmap font. The variables are expected to be in
; this order and adjacent.
_tgi_textscalew: .res 3 ; Text scale for the width
_tgi_textscaleh: .res 3 ; Text scale for the height
; The following two must also be in exactly this order
_tgi_charwidth: .res 1 ; Char width of system font
_tgi_charheight: .res 1 ; Char height of system font
; The following are character scale/size variables in 8.8 fixed point
; format. They are required to be in this order and adjacent.
_tgi_textscalew: .res 2 ; Vector font width scale
.res 2 ; Bitmap font width scale
_tgi_charwidth: .res 2 ; Full width of one bitmap char
_tgi_textscaleh: .res 2 ; Vector font height scale
.res 2 ; Bitmap font height scale
_tgi_charheight: .res 2 ; Full height of one bitmap char
; End of section that gets cleared when a new driver is loaded
csize = * - cstart
@ -45,7 +43,7 @@ csize = * - cstart
_tgi_xmax: .res 2
_tgi_ymax: .res 2
; The following variables are copied from the driver header for faster access
; The following variables are copied from the driver header for faster access.
; fontwidth and fontheight are expected to be in order and adjacent.
tgi_driver_vars:
_tgi_xres: .res 2 ; X resolution of the current mode

View File

@ -3,29 +3,13 @@
;
.include "zeropage.inc"
.include "tgi-kernel.inc"
.import umul8x16r24
.import popa, popax
;-----------------------------------------------------------------------------
; Calculate either the total height or the total width of a bitmapped
; character, depending on the value in Y. On entry, X contains the scaling
; factor. Since it is usually small, we multiplicate by doing repeated adds.
; The function returns zero in X and the calculated value in A.
.proc charsize_helper
lda _tgi_fontwidth,y
jmp @L2
@L1: clc
adc _tgi_fontwidth,y
@L2: dex
bne @L1
sta _tgi_charwidth,y
rts
.endproc
.macpack cpu
;-----------------------------------------------------------------------------
; void __fastcall__ tgi_textstyle (unsigned width, unsigned height,
@ -57,43 +41,65 @@
.proc _tgi_textscale
; The height value is in 8.8 fixed point. Store it and calculate a rounded
; value for scaling the bitmapped system font in the driver.
; Setup the height
sta _tgi_textscaleh+0
stx _tgi_textscaleh+1
asl a ; Check value behind comma
ldy _tgi_fontheight ; Get height of bitmap font in pixels
sty ptr1 ; Save for later
ldy #6 ; Address the height
jsr process_onedim ; Process height
; Setup the width
jsr popax ; Get width scale into a/x
ldy _tgi_fontwidth ; Get width of bitmap font in pixels
sty ptr1 ; Save for later
ldy #0 ; Address the width
; Process one character dimension. That means:
;
; - Store the vector font dimension in 8.8 format
; - If necessary, round up/down to next integer
; - Store the bitmap font dimension in 8.8 format
; - Multiply by size of bitmap char in pixels
; - Store the bitmap font size in 8.8 format
;
process_onedim:
jsr store ; Store vector font scale factor
bit _tgi_flags ; Fine grained scaling support avail?
bmi @L2 ; Jump if yes
asl a ; Round to nearest full integer
bcc @L1
inx ; Round
@L1: stx _tgi_textscaleh+2 ; Store rounded value
inx
@L1: lda #0
; Calculate the total height of the bitmapped font and remember it.
@L2: jsr store ; Store bitmap font scale factor
ldy #1
jsr charsize_helper
; The size of the font in pixels in the selected dimension is already in ptr1
; So if we call umul8x16r24 we get the size in pixels in 16.8 fixed point.
; Disallowing characters larger than 256 pixels, we just drop the high byte
; and remember the low 16 bit as size in 8.8 format.
; The width value is in 8.8 fixed point. Store it and calculate a rounded
; value for scaling the bitmapped system font in the driver.
.if (.cpu .bitand ::CPU_ISET_65SC02)
phy ; Save Y
jsr umul8x16r24
ply ; Restore Y
.else
sty tmp1 ; Save Y
jsr umul8x16r24
ldy tmp1 ; Restore Y
.endif
jsr popax ; height
sta _tgi_textscalew+0
stx _tgi_textscalew+1
asl a ; Check value behind comma
bcc @L2
inx ; Round
@L2: stx _tgi_textscalew+2 ; Store rounded value
; Calculate the total width of the bitmapped font and remember it.
ldy #0
jsr charsize_helper
; Load values and call the driver, parameters are passed in registers
ldx _tgi_textscalew+2
ldy _tgi_textscaleh+2
lda _tgi_textdir
jmp tgi_textstyle
store: sta _tgi_textscalew,y
iny
pha
txa
sta _tgi_textscalew,y
iny
pla
rts
.endproc