Permalink
Browse files

adding pattern seems to work - but pattern is flipped horizontally.

watch out for stack/heap collisions with big patterns!
  • Loading branch information...
1 parent e201cd5 commit 1fec9b8505b3252c9072f388da14aec5c92b0243 @ladyada ladyada committed Oct 18, 2010
Showing with 24 additions and 1 deletion.
  1. +24 −1 addpattern.py
View
@@ -198,7 +198,30 @@ def bytesForMemo(rows):
for i in range(7):
outfile.write(chr(progentry[i]))
-for i in range(patternbankptr+7, 2048):
+# now we have to figure out the -end- of the last pattern is
+endaddr = 0x6df
+
+for p in pats:
+ endaddr = min(p['pattend'], endaddr)
+print "top address = ", hex(endaddr)
+beginaddr = endaddr - bytesForMemo(height) - len(pattmem) + 1
+print "end will be at ", hex(beginaddr)
+if beginaddr < 0x2B8:
+ print "sorry, this will colllide with the pattern entry data!"
+ exit
+
+for i in range(patternbankptr+7, beginaddr):
+ outfile.write(chr(bf.getIndexedByte(i)))
+
+# dump the pattern data here
+for i in range(len(pattmem)):
+ outfile.write(chr(pattmem[len(pattmem)-i-1]))
+
+for i in range(bytesForMemo(height)):
+ outfile.write(chr(0))
+
+for i in range (endaddr, 2048):
outfile.write(chr(bf.getIndexedByte(i)))
+
outfile.close()

0 comments on commit 1fec9b8

Please sign in to comment.