Re: [stella] Player Animation Basics Take 1

Subject: Re: [stella] Player Animation Basics Take 1
From: Thomas Jentzsch <tjentzsch@xxxxxx>
Date: Mon, 15 Jul 2002 11:44:38 +0200
Ruffin Bailey wrote::
> I also used some fancy AND'ing to make sure the frames were
> increased every 8/60th (?? - every 8th frame written to the
> NTSC screen) of a second. 

That's correct.


>(though I'm only using 3 bits so Thomas will probably 
>shoot me for sacrilege):

Bang! :-)


>So anyhow I feel sufficiently happy with the 
>way that I did that that I'm betting there's a better way.  Go 
>ahead and bring me off of my high.  :^)  

You begged for it. ;-)

A minimal improvement would be (saves 2 bytes):
  lda SWCHA
  cmp #%11110000		; we don't care for the lower bits
  bcs dontIncreaseFrame ; CF=1, if all 4 upper bits are set


That code has a bug:
  lda p0FrameCount
  adc #%00001000	 		; ... increase the frame count 
"by one frame" (16 dec, $10)
  and #%00111000			; but don't let it get over 
"three frames" (48 dec, $30)
  sta p0FrameCount		; put back into p0FrameCount

Instead of 4 frames, you get 8 frames here 
(%00001000 = $08, %00111000 = $38). 


But you don't need to do that complicated stuff with 
p0FrameCount:
  dec	p0FrameCount
  bpl .skipReset
  lda	#NUM_FRAMES-1          ; = 3
  sta	p0FrameCount
.skipReset

This doesn't save space, but IMO is better readable.


And instead of using a magic number ($08) for the offset you 
better should write:
  clc				; not necessary, CF = 0 already
  adc	#<player0data	;
 
That makes the code more readable and maintainable.

Have fun!	
Thomas


----------------------------------------------------------------------------------------------
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/


Current Thread