Combine cross-row stack moves in font compiler

Moar Speed
This commit is contained in:
blondie7575 2023-07-13 13:34:03 -07:00
parent ab12be85d3
commit 61efb73959
4 changed files with 1853 additions and 8144 deletions

View File

@ -45,7 +45,7 @@ def main(argv):
for charY in range(0,numCharY):
for charX in range(0,numCharX):
print ("\t.addr %s" % labelFromCharXY(prefix,CHAR_FIRST,charX,numCharX,charY))
print ("")
print ("\n; Chroma Key is $%x\n" % CHROMA)
# Generate code for each glyph
for charY in range(0,numCharY):
@ -60,7 +60,8 @@ def main(argv):
# Iterate through all the pixels
charOriginX = charX*CHAR_WIDTH
charOriginY = charY*CHAR_HEIGHT
pendingStackMove = 0
for charRow in reversed(range(0,CHAR_HEIGHT)):
# Print a comment to make generated source easier to understand
@ -95,9 +96,12 @@ def main(argv):
offsetNeeded = (CHAR_WIDTH/2-requiredStackIndex) - rowPushTotal - 2
if (offsetNeeded>0):
stackAdvance(offsetNeeded) # Advance stack to position needed for our two byte push
stackAdvance(offsetNeeded+pendingStackMove) # Advance stack to position needed for our two byte push
pendingStackMove = 0
nextRowDelta -= offsetNeeded
else:
stackAdvance(pendingStackMove) # First thing we did wasn't a stack move, so apply previous row pending first
pendingStackMove = 0
offsetNeeded=0
print ("\tpea $%04x" % word)
nextRowDelta -= 2
@ -132,7 +136,8 @@ def main(argv):
if len(localStackList) > 0:
if (rowPushTotal < CHAR_WIDTH/2): # Get stack pointer to end of row if needed
cleanupPush = CHAR_WIDTH/2-rowPushTotal
stackAdvance(cleanupPush)
stackAdvance(cleanupPush + pendingStackMove)
pendingStackMove=0
rowPushTotal = CHAR_WIDTH/2
nextRowDelta -= cleanupPush
@ -144,8 +149,8 @@ def main(argv):
print ("\tsta %d,S" % (stackEntry[0] + extraReach))
# Advance stack pointer to next row
stackAdvance(nextRowDelta)
pendingStackMove += nextRowDelta # Save this stack move for next row, because we can often combine them
# Footer for each rendering operation
print ("\tjmp renderCharJumpReturn\n")

File diff suppressed because it is too large Load Diff

3910
font8x8.s

File diff suppressed because it is too large Load Diff

View File

@ -209,27 +209,27 @@ loadData:
ldy #0
jsr copyBytes
EMULATION
; EMULATION
; Load rest of font data into bank 0 (needed if font size exceeds BUFFERSIZE)
jsr PRODOS
.byte $ca
.addr fileRead
bne ioErrorJmp
; jsr PRODOS
; .byte $ca
; .addr fileRead
; bne ioErrorJmp
; Close the file
jsr PRODOS
.byte $cc
.addr fileClose
; jsr PRODOS
; .byte $cc
; .addr fileClose
NATIVE
; NATIVE
; Copy rest of font data into bank 5 (needed if font size exceeds BUFFERSIZE)
ldx fileReadLen
txa
lda #5
ldy #BUFFERSIZE
jsr copyBytes
; ldx fileReadLen
; txa
; lda #5
; ldy #BUFFERSIZE
; jsr copyBytes
; Set up a long jump into bank 2, and
; a way for game code to get back here to exit