[Coco] Let's figure out the best method to compile sprites for the CoCo - Please add your input

Glen Hewlett glen.hewlett at sympatico.ca
Thu May 11 19:41:20 EDT 2017


Hi Mark,

Your comment about stack blasting made me think, why not combine both compiled sprites using LDD and STD etc. with PULU  D,X instructions and use U as a pointer instead of X.  That might work especially well for sprites that have repeating patterns or are all one colour like Pacman.

I’m just thinking off the top of my head here and the order of the bytes might be off, but I could do something like this (using my Pacman sprite data from the previous post):
Setup U with the location in Video RAM where the sprite will be
LEAS	8,S		[2]	[5]
LDD		#$4444	[3] 	[3]
LDX		#$4444 	[3] 	[3]
PSHU	D,X		[2] 	[9]
PSHU	D,X		[2]	[9]
LEAU	136,U	[4] 	[8]
LDD     	#$9944	[3] 	[3]
PSHU    	D,X		[2] 	[9]
LDD  	#$4999	[3] 	[3]
STD     	-2,U		[2] 	[6]
STD     	-4,U		[2] 	[6]
LEAU    	124,U	[4] 	[8]

This new method uses 32 bytes and 72 CPU cycles.  Where my previous version for the first two rows of the pacman sprite used 37 bytes and took 73 CPU cycles.  This is 5 bytes smaller and is 1.3% faster  You can also use the Y register for the stack blasting to get even more value out of each PULU instruction.

The down side of this is that you will also probably need to PSHS the U register before drawing the sprite and PULS U after unless you don’t need the U for your code.  

I’ll have to do more testing with this technique to see if other sprites will benefit from it, but it looks promising especially for sprites that have a lot of repeating data.


As for Pacman

I’ve done lots of testing with ways for doing the sprites for Pacman and it’s fastest to leave the black as black and not transparent for Pacman since everything pacman runs over gets erased anyways.  As for the mouth opening you can’t really notice it’s not going in it’s mouth because it goes so fast.  I might tweak it a little more so that the pills go in the mouth a little, we’ll see.

Yes I have worked out the order of the sprite drawing in normal chase mode vs. when a power pill is eaten.  Thanks for letting me know though.  :)

Cheers,
Glen


More information about the Coco mailing list