Re: [stella] Player Animation Basics Take 1

Subject: Re: [stella] Player Animation Basics Take 1
From: Ruffin Bailey <rufbo1@xxxxxxxxxxx>
Date: Mon, 15 Jul 2002 23:52:38 -0400
You begged for it. ;-)

Why yes, I guess I did... dang. :^)

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

I woke up this morning thinking I shoulda used CMP. Of course I didn't know how until I read this and pulled Mansfield back out... Thanks for the tip.

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).

Well, I get four frames of animation (in the source, I have 4 different player0 frames of animation -- I think I use "frame" to mean "different graphic for the player" and use "screen draw" to mean what you mean by "frame"), but you're quite right. I wanted there to be several screen draws between frames to "slow down" the animation. With what I had, I only had two draws between frames -- only 50% slower than the "palsy" animation I had originally before I posted. I changed the lines to...

adc #%00000100
and #%00111100
sta p0FrameCount

Now I've got four draws between frames of animation, which is just about right, and I'm only wasting four bits of the byte. :^) Thanks for pointing that out.

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

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

Okay, this would get me back to just one screen draw between animation frames (one frame per screen draw, each frame displayed only 1/60th of a second), correct? Sorry if I've missed something.

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.

Okay, except I don't know what #<player0data means. I assume that it means "add what's in the accum to the "high nibble" of player0data" but I'm afraid I'm clueless there. I did a quick skim of the Mansfield book and searched the archives for "#<" (too broad a search, it says) and didn't turn anything up. I'll look some more after I send this.

Thanks again for the help. It's always good to see how somebody who knows what's going on would do it.

Ruffin Bailey

Archives (includes files) at
Unsub & more at

Current Thread