Font rendering is now left justified

This commit is contained in:
blondie7575 2023-07-17 15:53:17 -07:00
parent 1d3bfeba8f
commit 080ab768b8
4 changed files with 36 additions and 6 deletions

View File

@ -158,6 +158,12 @@ def main(argv):
print ("\tjmp renderCharJumpReturn_%s\n" % prefix)
return
def scaleForFontWidth(charWidth):
output = ""
for i in range(0,(int)(charWidth/4)):
output = output + "\tasl\n"
return output
def addWrapperCode(prefix, charWidth, firstChar):
code = """
@ -167,7 +173,7 @@ def addWrapperCode(prefix, charWidth, firstChar):
; Draws a Pascal string for font "{:s}"
;
; PARAML0 = Pointer to string
; Y = VRAM position of lower right corner of string at which to draw
; Y = VRAM position of lower left corner of string at which to draw
;
; Trashes SCRATCHL,X,Y,A
;
@ -181,6 +187,13 @@ renderString_{:s}:
BITS16
phb
; Advance VRAM pointer to end of string
{:s}
clc
adc SCRATCHL
dec
sta SCRATCHL
renderStringLoop_{:s}:
; Fetch and render next character in string
@ -234,7 +247,7 @@ renderCharJumpReturn_{:s}: ; Compiled glyphs jump back here. Can't rts because s
RESTORE_AXY
rts
""".format(prefix,prefix,prefix,prefix,prefix,prefix,charWidth,prefix,prefix,prefix,prefix,prefix,firstChar,prefix,prefix)
""".format(prefix,prefix,prefix,scaleForFontWidth(charWidth),prefix,prefix,prefix,charWidth,prefix,prefix,prefix,prefix,prefix,firstChar,prefix,prefix)
print (code)
return

17
fonts.s
View File

@ -20,6 +20,14 @@ renderString_tinyNum:
BITS16
phb
; Advance VRAM pointer to end of string
asl
clc
adc SCRATCHL
dec
sta SCRATCHL
renderStringLoop_tinyNum:
; Fetch and render next character in string
@ -647,6 +655,15 @@ renderString_font8:
BITS16
phb
; Advance VRAM pointer to end of string
asl
asl
clc
adc SCRATCHL
dec
sta SCRATCHL
renderStringLoop_font8:
; Fetch and render next character in string

View File

@ -131,7 +131,7 @@ renderInventoryItem_unselected:
; Render tiny numbers
pla
clc
adc #6*160+4
adc #6*160+2
tay
lda #intToStringPrefix
sta PARAML0

View File

@ -438,7 +438,7 @@ renderPlayerHeader:
adc #PD_NAME
sta PARAML0
phy
ldy #$25c0
ldy #$25a1
lda #1
jsl renderStringFar
ply
@ -456,12 +456,12 @@ renderPlayerHeader:
; jsr DrawString
lda playerData+PD_TREATS,y
ldx #$25f6
ldx #$25f0
jsr drawNumber
lda #treatsStr
sta PARAML0
ldy #$25f2
ldy #$25d0
lda #1
jsl renderStringFar