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 charY in range(0,numCharY):
for charX in range(0,numCharX): for charX in range(0,numCharX):
print ("\t.addr %s" % labelFromCharXY(prefix,CHAR_FIRST,charX,numCharX,charY)) 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 # Generate code for each glyph
for charY in range(0,numCharY): for charY in range(0,numCharY):
@ -60,7 +60,8 @@ def main(argv):
# Iterate through all the pixels # Iterate through all the pixels
charOriginX = charX*CHAR_WIDTH charOriginX = charX*CHAR_WIDTH
charOriginY = charY*CHAR_HEIGHT charOriginY = charY*CHAR_HEIGHT
pendingStackMove = 0
for charRow in reversed(range(0,CHAR_HEIGHT)): for charRow in reversed(range(0,CHAR_HEIGHT)):
# Print a comment to make generated source easier to understand # Print a comment to make generated source easier to understand
@ -95,9 +96,12 @@ def main(argv):
offsetNeeded = (CHAR_WIDTH/2-requiredStackIndex) - rowPushTotal - 2 offsetNeeded = (CHAR_WIDTH/2-requiredStackIndex) - rowPushTotal - 2
if (offsetNeeded>0): 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 nextRowDelta -= offsetNeeded
else: else:
stackAdvance(pendingStackMove) # First thing we did wasn't a stack move, so apply previous row pending first
pendingStackMove = 0
offsetNeeded=0 offsetNeeded=0
print ("\tpea $%04x" % word) print ("\tpea $%04x" % word)
nextRowDelta -= 2 nextRowDelta -= 2
@ -132,7 +136,8 @@ def main(argv):
if len(localStackList) > 0: if len(localStackList) > 0:
if (rowPushTotal < CHAR_WIDTH/2): # Get stack pointer to end of row if needed if (rowPushTotal < CHAR_WIDTH/2): # Get stack pointer to end of row if needed
cleanupPush = CHAR_WIDTH/2-rowPushTotal cleanupPush = CHAR_WIDTH/2-rowPushTotal
stackAdvance(cleanupPush) stackAdvance(cleanupPush + pendingStackMove)
pendingStackMove=0
rowPushTotal = CHAR_WIDTH/2 rowPushTotal = CHAR_WIDTH/2
nextRowDelta -= cleanupPush nextRowDelta -= cleanupPush
@ -144,8 +149,8 @@ def main(argv):
print ("\tsta %d,S" % (stackEntry[0] + extraReach)) print ("\tsta %d,S" % (stackEntry[0] + extraReach))
# Advance stack pointer to next row # 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 # Footer for each rendering operation
print ("\tjmp renderCharJumpReturn\n") 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 ldy #0
jsr copyBytes jsr copyBytes
EMULATION ; EMULATION
; Load rest of font data into bank 0 (needed if font size exceeds BUFFERSIZE) ; Load rest of font data into bank 0 (needed if font size exceeds BUFFERSIZE)
jsr PRODOS ; jsr PRODOS
.byte $ca ; .byte $ca
.addr fileRead ; .addr fileRead
bne ioErrorJmp ; bne ioErrorJmp
; Close the file ; Close the file
jsr PRODOS ; jsr PRODOS
.byte $cc ; .byte $cc
.addr fileClose ; .addr fileClose
NATIVE ; NATIVE
; Copy rest of font data into bank 5 (needed if font size exceeds BUFFERSIZE) ; Copy rest of font data into bank 5 (needed if font size exceeds BUFFERSIZE)
ldx fileReadLen ; ldx fileReadLen
txa ; txa
lda #5 ; lda #5
ldy #BUFFERSIZE ; ldy #BUFFERSIZE
jsr copyBytes ; jsr copyBytes
; Set up a long jump into bank 2, and ; Set up a long jump into bank 2, and
; a way for game code to get back here to exit ; a way for game code to get back here to exit