diff --git a/HiSprite.py b/HiSprite.py index 7880bc4..ff7a539 100755 --- a/HiSprite.py +++ b/HiSprite.py @@ -167,7 +167,7 @@ class Listing(object): class Sprite(Listing): - def __init__(self, pngfile, assembler, screen, xdraw=False, processor="any"): + def __init__(self, pngfile, assembler, screen, xdraw=False, processor="any", name=""): Listing.__init__(self, assembler) self.screen = screen @@ -176,7 +176,9 @@ class Sprite(Listing): self.xdraw = xdraw self.processor = processor - self.niceName = slugify(os.path.splitext(pngfile)[0]) + if not name: + name = os.path.splitext(pngfile)[0] + self.niceName = slugify(name) self.width = pngdata[0] self.height = pngdata[1] self.pixelData = list(pngdata[2]) @@ -627,6 +629,7 @@ if __name__ == "__main__": parser.add_argument("-a", "--assembler", default="cc65", choices=["cc65","mac65"], help="Assembler syntax (default: %(default)s)") parser.add_argument("-p", "--processor", default="any", choices=["any","6502", "65C02"], help="Processor type (default: %(default)s)") parser.add_argument("-s", "--screen", default="hgrcolor", choices=["hgrcolor","hgrbw"], help="Screen format (default: %(default)s)") + parser.add_argument("-n", "--name", default="", help="Name for generated assembly function (default: based on image filename)") parser.add_argument("files", metavar="IMAGE", nargs="*", help="a PNG image [or a list of them]. PNG files must not have an alpha channel!") options, extra_args = parser.parse_known_args() @@ -652,7 +655,7 @@ if __name__ == "__main__": for pngfile in options.files: try: - listings.append(Sprite(pngfile, assembler, screen, options.xdraw, options.processor)) + listings.append(Sprite(pngfile, assembler, screen, options.xdraw, options.processor, options.name)) except RuntimeError, e: print "%s: %s" % (pngfile, e) sys.exit(1) diff --git a/Makefile.rob b/Makefile.rob index c82f243..bc240bf 100644 --- a/Makefile.rob +++ b/Makefile.rob @@ -1,12 +1,15 @@ +COLORSPRITE = apple.png +BWSPRITE = apple.png + all: bwtest.dsk colortest.dsk -bwtest.dsk: - python HiSprite.py -a mac65 -p 6502 -s hgrbw apple.png -t -c -r > apple.s +bwtest.dsk: HiSprite.py bwtest.s $(BWSPRITE) + python HiSprite.py -a mac65 -p 6502 -s hgrbw $(BWSPRITE) -n bwsprite -t -c -r > bwsprite.s atasm -obwtest.xex bwtest.s -Lbwtest.var -gbwtest.lst atrcopy bwtest.dsk boot -b bwtest.xex --brun 6000 -f -colortest.dsk: colortest.s boxw_mix.png - python HiSprite.py -a mac65 -p 6502 -s hgrcolor boxw_mix.png -t -c -r > boxw_mix.s +colortest.dsk: HiSprite.py colortest.s $(COLORSPRITE) + python HiSprite.py -a mac65 -p 6502 -s hgrcolor $(COLORSPRITE) -n colorsprite -t -c -r > colorsprite.s atasm -ocolortest.xex colortest.s -Lcolortest.var -gcolortest.lst atrcopy colortest.dsk boot -b colortest.xex --brun 6000 -f diff --git a/bwtest.s b/bwtest.s index a367f37..e9b097d 100644 --- a/bwtest.s +++ b/bwtest.s @@ -47,7 +47,7 @@ draw lda #100 sta PARAM0 ; x coord - jsr APPLE + jsr BWSPRITE wait jmp wait @@ -71,4 +71,4 @@ clr1 bcc clr1 rts - .include apple.s + .include bwsprite.s diff --git a/colortest.s b/colortest.s index e94eae7..8db1764 100644 --- a/colortest.s +++ b/colortest.s @@ -47,7 +47,7 @@ draw lda #100 sta PARAM0 ; x coord - jsr BOXW_MIX + jsr COLORSPRITE wait jmp wait @@ -71,4 +71,4 @@ clr1 bcc clr1 rts - .include boxw_mix.s + .include colorsprite.s