From 6e2bcdb352caa6616fa2a07c58550e532d348d90 Mon Sep 17 00:00:00 2001 From: Quinn Dunki Date: Wed, 20 Jul 2016 22:39:11 -0500 Subject: [PATCH] Rough first pass on python sprite compiler --- .gitignore | 1 + .../UserInterfaceState.xcuserstate | Bin 15943 -> 0 bytes HiSprite.py | 122 ++++++++++++++++++ box.png | Bin 0 -> 166 bytes spritedata.s | 6 + 5 files changed, 129 insertions(+) delete mode 100644 HGR.xcodeproj/project.xcworkspace/xcuserdata/qd.xcuserdatad/UserInterfaceState.xcuserstate create mode 100755 HiSprite.py create mode 100644 box.png diff --git a/.gitignore b/.gitignore index 505ede2..b4ec515 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ HGR.xcodeproj/xcuserdata hgrtest.lst +HGR.xcodeproj/project.xcworkspace/xcuserdata/qd.xcuserdatad/UserInterfaceState.xcuserstate diff --git a/HGR.xcodeproj/project.xcworkspace/xcuserdata/qd.xcuserdatad/UserInterfaceState.xcuserstate b/HGR.xcodeproj/project.xcworkspace/xcuserdata/qd.xcuserdatad/UserInterfaceState.xcuserstate deleted file mode 100644 index 2884c6e215499c5d57196c79c78d1f6637a57ddb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15943 zcmbVz2S8I-_xQce*XR{lDv2Cx#yj|-t>-Ex6hxSe*$5| zAc9!Lp)hVUw`IJ3j?3$Fd)mkAJ=3ptHTiuL^iFTnOgCJv*ZVykGK5!dzc(J=io#I@ zk|PCDqAZk+a*z?3P%bhf3#vp_s2UAHL(wpF6&j9e&z(Ja)8+E6?4 zpbj(}%||QH^=Jdyh_;}u=ytRd?M2JcooGLL03ASw&|&l>dKSHaUO{i5chPC|Fb2t*mVJTK&HBQGFScmmE8xO!&;DPu`JO~fQWw;zW z@JKug*W%H546eiVxB-vF0QTt)z{#6E9g#R*;os6&s$fE*$ZlgG#ra+Ewpj*;W! zMe-8)4|$EeN!}vwk@v}m>ccOb|<@wy_4O?KExhkA7&q6p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et;kbY6$J{rqF7O;s8CcXhA8S4 zO$wKyMd4P=QnV>NirEUPSgKgASgBa8SgTm4Sg+WixLvVZu~)HAv0rhI;*jDI#bLz} z#S@C7iWd}bDb6T zHOi67TICdFqtdBtQno5R%GpYva;@@K<#uJ4a;I{)a=TyI{epmge#%iMG)ZuESI$Ld34^R(L*QiITYt;?vaq0=`Notq6 zUA<7fSWVT-)GO4h)LYbh)px4*srRcNQ9q`BTzypiwE9`~yXueBXVqV*zfymr{$2f# z25X2WLKCHl*2HQwnskjtQ=qYHiZuf@gEVCtho)XLMRT>LP2$| z^+{us#wSfnTAFlQ((a@?lkQ5oC+WVV2a*maJ(cuK(y^rHl3qx9JL!X@Q%Pr%K218C z^hMHFNq;AYCo7T@k`t4YlQWX_$%f?YIhpcF%4aEGqW6gO{+^= zowhOU*0kHwwx+$7b}H>m+DB=hrfbu)(sR;H>6Y}S^p13Ix<7qx`u_As(hsK}Nq;i^ zrwk^8%?Qhg%ovn0JYz)0sEjcgt1@oRxHV&Q#_bu~GrBS!&p4j(LdMG(uV#Fb@rw@Y zSY4PdTox$xpi}Oi*+k>>vfxTcj)fYJ*azGcS84# zp6I3ec)d)o(5LG&^g4Z}-li|m7wU`j75Ykjm41l6Uf-Y}s~@j->1XI$^ltqe{apP# z{Q~_e{c8Oh{k8f{`Yrlx`W^b6`rY~i`h)sI`bYIY=>N_P&y329$&_ZwGm|n?Gcz(X zGqW>|nGKoCGY@3Gmw7hx%gnDczsvkF^L*xC2FAb{A`DRmwIRunYRE8T8H@(AArLBD z-KJfpJ*Iu8yG{3*4ww#_4w;UcUNU`Z`ZG5^*N{6XcU*2$?&{p@b2sGPk-IfccCi+M={1S<)E%w&j%NthL5E$~xKVwzgV5 zRrK{;)?2N&Ss%B4Y>TlK+sbT1ZKG}Vwkft|o7;AcZLw{Y zZLMvcZN2SQ+kV@0: + continue + + for row in range(height): + for col in range(width): + (pixelr,pixelg,pixelb,half) = pixelRemap(pixeldata,row,col,width,shift,phase) + + if pixelr==255 and pixelg==0 and pixelb==255: + bitmap[row][col] = Colors.magenta + else: + bitmap[row][col] = Colors.black + + spriteNum = max(0,shift*2-1+phase) + printBitmap(bitmap,os.path.splitext(pngfile)[0].upper(),spriteNum,half,0) + + + +def pixelRemap(pixeldata,row,col,width,shift,phase): + halfPixel = 0 + overHalf = 0 + + if shift>=width: + overHalf = 1 + shift = shift-width+1 + if phase==0: + halfPixel = 1 + + if phase==0: + col = col+shift + else: + col = col-(width-shift) + if not overHalf: + halfPixel = -1 + + + if col >= width or col<0: + return (0,0,0,halfPixel) + + r = pixeldata[row][col*3] + g = pixeldata[row][col*3+1] + b = pixeldata[row][col*3+2] + + return (r,g,b,halfPixel) + + +def colorString(color,currByteString): + if len(currByteString) > 6: + if color==Colors.magenta: + return '1' + else: + return '0' + else: + if color==Colors.magenta: + return '10' + + return '00' + + +def printBitmap(bitmap,label,shift,halfShift,highbit): + print "%s%d:" % (label,shift) + for row in range(len(bitmap)): + byteString = "%d" % highbit + + for col in range(len(bitmap[0])): + append = colorString(bitmap[row][col],byteString) + byteString += append + + if halfShift>0: + byteString = "0" + byteString[:-1] + else: + if halfShift<0: + byteString = byteString[1:] + "0" + + sys.stdout.write("\t.byte\t%%%s\n" % byteString); + + sys.stdout.write('\n\n') + sys.stdout.flush() + + + +def usage(): + print ''' +Usage: HiSprite + +PNG file must not have an alpha channel! +''' + sys.exit(2) + + + + +if __name__ == "__main__": + main(sys.argv[1:]) \ No newline at end of file diff --git a/box.png b/box.png new file mode 100644 index 0000000000000000000000000000000000000000..12a156e0d4f4473b50befabfb547cf81c7a33430 GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^EI`b`!2~1&15bhkI14-?iy0WWg+Z8+Vb&Z8pdfpR zr>`sf19nj+Cb=W090hS|xv6<2KrRD=b5UwyNotBhd1gt5g1e`0K#E=} zJ5XH4)5S4_<9hO+^B?9j@;#XIpXdKfi3tprGHxl08BNY}ux1Op=YS0GboFyt=akR{ E00xjL0RR91 literal 0 HcmV?d00001 diff --git a/spritedata.s b/spritedata.s index 1ef0910..86dd8e7 100644 --- a/spritedata.s +++ b/spritedata.s @@ -35,6 +35,7 @@ SPRITE2: .byte %00000010 .byte %00000010 + SPRITE3: .byte %01010000 ; Two pixel shift .byte %00010000 ; (reversed) @@ -55,6 +56,7 @@ SPRITE4: .byte %00001000 .byte %00001010 + SPRITE5: .byte %01000000 ; Three pixel shift .byte %01000000 ; (reversed) @@ -75,6 +77,7 @@ SPRITE6: .byte %00100000 .byte %00101010 + SPRITE7: .byte %00101010 ; Four pixel shift .byte %00000010 ; (reversed) @@ -95,6 +98,7 @@ SPRITE8: .byte %00000001 .byte %00000001 + SPRITE9: .byte %00101000 ; Five pixel shift .byte %00001000 ; (reversed) @@ -115,6 +119,7 @@ SPRITE10: .byte %00000100 .byte %00000101 + SPRITE11: .byte %00100000 ; Six pixel shift .byte %00100000 ; (2nd byte, reversed) @@ -135,6 +140,7 @@ SPRITE12: .byte %00010000 .byte %00010101 + BLACK: .byte %00000000 .byte %00000000