mirror of
https://github.com/blondie7575/GSCats.git
synced 2024-11-22 06:31:48 +00:00
Optimizations to font compiler
This commit is contained in:
parent
5fb8aa3327
commit
cbd4b9beeb
@ -43,7 +43,7 @@ def main(argv):
|
||||
charOriginY = charY*CHAR_HEIGHT
|
||||
|
||||
for charRow in reversed(range(0,CHAR_HEIGHT)):
|
||||
print ("\t; Line %d, Pixel values: %x,%x,%x,%x,%x,%x,%x,%x" % (charRow,
|
||||
print ("\t; Line %d, Pixel values: %x%x%x%x %x%x%x%x" % (charRow,
|
||||
pixels[charOriginY+charRow][charOriginX+0],
|
||||
pixels[charOriginY+charRow][charOriginX+1],
|
||||
pixels[charOriginY+charRow][charOriginX+2],
|
||||
@ -52,7 +52,11 @@ def main(argv):
|
||||
pixels[charOriginY+charRow][charOriginX+5],
|
||||
pixels[charOriginY+charRow][charOriginX+6],
|
||||
pixels[charOriginY+charRow][charOriginX+7]))
|
||||
|
||||
nextRowDelta = 160
|
||||
localStackList = []
|
||||
rowPushTotal = 0 # Row-right relative
|
||||
|
||||
for charCol in reversed(range(0,CHAR_WIDTH,4)):
|
||||
nibbles = [pixels[charOriginY+charRow][charOriginX+charCol],
|
||||
pixels[charOriginY+charRow][charOriginX+charCol+1],
|
||||
@ -60,6 +64,7 @@ def main(argv):
|
||||
pixels[charOriginY+charRow][charOriginX+charCol+3]]
|
||||
|
||||
word = nibbles[2]<<12 | nibbles[3]<<8 | nibbles[0]<<4 | nibbles[1]
|
||||
requiredStackIndex = charCol/2
|
||||
|
||||
if (nibbles[0]==CHROMA and nibbles[1]==CHROMA and nibbles[2]==CHROMA and nibbles[3]==CHROMA):
|
||||
print ("\ttsc") # Case 1 : All chroma, so let stack advance with no work
|
||||
@ -67,14 +72,19 @@ def main(argv):
|
||||
print ("\tdec")
|
||||
print ("\ttcs")
|
||||
nextRowDelta-=2
|
||||
rowPushTotal +=2
|
||||
elif (nibbles[0]!=CHROMA and nibbles[1]!=CHROMA and nibbles[2]!=CHROMA and nibbles[3]!=CHROMA):
|
||||
print ("\ttsc") # Advance stack 1 for two byte push
|
||||
print ("\tdec")
|
||||
print ("\ttcs")
|
||||
offsetNeeded = (CHAR_WIDTH/2-requiredStackIndex) - rowPushTotal - 2
|
||||
if (offsetNeeded>0):
|
||||
print ("\ttsc") # Advance stack to position needed for our two byte push
|
||||
print ("\tsec") # Note that PEA needs a little +1 to put bytes in the place we expect
|
||||
print ("\tsbc #%d" % (offsetNeeded+1))
|
||||
print ("\ttcs")
|
||||
print ("\tpea $%04x" % word) # Case 2 : No chroma, so fast push
|
||||
nextRowDelta -= 3
|
||||
rowPushTotal += (3+offsetNeeded)
|
||||
else:
|
||||
mask = 0xFFFF # Case 3 : Mixed chroma, so mask and or
|
||||
mask = 0xFFFF # Case 3 : Mixed chroma, so mask and or
|
||||
if (nibbles[0]!=CHROMA):
|
||||
mask = mask & 0xFF0F
|
||||
if (nibbles[1]!=CHROMA):
|
||||
@ -94,16 +104,26 @@ def main(argv):
|
||||
if (nibbles[3]==CHROMA):
|
||||
sprite = sprite & 0xF0FF
|
||||
|
||||
print ("\ttsc") # Keep stack moving, even though we didn't use it
|
||||
print ("\tdec")
|
||||
print ("\tdec")
|
||||
print ("\ttcs")
|
||||
print ("\tlda 0,S") # Blend mask, sprite, and background
|
||||
print ("\tand #$%04x" % mask)
|
||||
print ("\tora #$%04x" % sprite)
|
||||
print ("\tsta 0,S")
|
||||
localStackEntry = [requiredStackIndex,mask,sprite]
|
||||
localStackList.append(localStackEntry)
|
||||
nextRowDelta -= 2
|
||||
|
||||
|
||||
# Process any local stack work we accumulated
|
||||
if len(localStackList) > 0:
|
||||
if (rowPushTotal < CHAR_WIDTH/2): # Get stack pointer to end of row if needed
|
||||
print ("\ttsc")
|
||||
print ("\tsec")
|
||||
print ("\tsbc #%d" % (CHAR_WIDTH/2-rowPushTotal))
|
||||
print ("\ttcs")
|
||||
rowPushTotal = CHAR_WIDTH/2
|
||||
|
||||
extraReach = rowPushTotal - CHAR_WIDTH/2
|
||||
for stackEntry in localStackList:
|
||||
print ("\tlda %d,S" % (stackEntry[0] + extraReach)) # Blend mask, sprite, and background
|
||||
print ("\tand #$%04x" % stackEntry[1])
|
||||
print ("\tora #$%04x" % stackEntry[2])
|
||||
print ("\tsta %d,S" % (stackEntry[0] + extraReach))
|
||||
|
||||
# Advance stack pointer to next row
|
||||
print ("\ttsc")
|
||||
print ("\tsec")
|
||||
|
Loading…
Reference in New Issue
Block a user