Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.apple2.programmer > #1859

Re: "Best practices" for animating sprites in Apple II Assembly? (HGR/HGR2)

Newsgroups comp.sys.apple2.programmer
Date 2015-10-16 08:49 -0700
References <3dfeb2b4-f124-40fe-afe1-cfde8912151d@googlegroups.com> <mmphosis-1444979010@macgui.com>
Message-ID <08117548-7665-4aca-a7e5-d6ac52ac7686@googlegroups.com> (permalink)
Subject Re: "Best practices" for animating sprites in Apple II Assembly? (HGR/HGR2)
From jamesiwalker77@gmail.com

Show all headers | View raw


On Friday, October 16, 2015 at 3:03:33 AM UTC-4, mmphosis wrote:
> Lots of hoops and unrolled loops.
> 
> You only need an offset of 40 bytes to span the screen horizontally so this
> can be accomplished using an 8-bit index register.  You can use a look up
> table, like you created with C#, to span the screen vertically 192 lines.
> 
> > So, is there an assembly language instruction that I am not aware of that
> > allows 2 byte variability?
> 
> You can usually only modify one byte at a time with the 8-bit 6502, although
> the JSR instruction pushes two bytes at a time onto the stack.  The 16-bit
> 65816 allows 2 byte variability. If you want to modify two bytes using the
> 8-bit 6502, use two store instructions.  Indirect addressing might also be
> helpful, although absolute addressing is faster.
> 
> 	LDY horizontal
> 	LDX vertical
> 	LDA lo,X ; lo is the lo order address of the lookup table
> 	STA zp
> 	LDA hi,X ; hi is the hi order address of the lookup table
> 	STA zp+1
> 	LDA (zp),Y
> 	AND mask
> 	ORA shape
> 	STA (zp),Y
> 
> Only redraw the parts of the background that need to be "undrawn."  Redraw
> each animated sprite at it's new location.  Flip the page during the
> Vertical Blanking Interval.
> 
> There are many techniques depending on what type of animation is being done:
> sprite animation, tiling, scrolling, color animation, rotoscoping, etc... 
> Some of Bill Budge's work was mentioned recently.  The source code for
> Prince of Persia is available.

I already understood the concept of lookup tables, but what I was thinking was, without indirect addressing with 16-bit pointers, you couldn't just store raw memory addresses in the lookup table and then plot bytes to those addresses that you get from the lookup table with a few simple instructions, because even the addresses you would "look up" would be 16-bit, and thus the address locations to plot to would vary by more than 256 bytes in the location value, so plotting to those locations that you look up would require more than 8 bit variability.  According to my understanding, without indirect addressing with 16-bit pointers (which I did not know about when I posted my original question yesterday), you would not only have to hard-code the addresses of each row, but you would also have to hard code many more instructions to plot to those rows than you would have to with the 16-bit pointers.  

Back to comp.sys.apple2.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

"Best practices" for animating sprites in Apple II Assembly? (HGR/HGR2) jamesiwalker77@gmail.com - 2015-10-15 19:15 -0700
  Re: "Best practices" for animating sprites in Apple II Assembly? (HGR/HGR2) Michael J. Mahon <mjmahon@aol.com> - 2015-10-16 01:58 -0500
    Re: "Best practices" for animating sprites in Apple II Assembly? (HGR/HGR2) jamesiwalker77@gmail.com - 2015-10-16 08:38 -0700
  Re: "Best practices" for animating sprites in Apple II Assembly? (HGR/HGR2) mmphosis <mmphosis@macgui.com> - 2015-10-16 07:01 +0000
    Re: "Best practices" for animating sprites in Apple II Assembly? (HGR/HGR2) jamesiwalker77@gmail.com - 2015-10-16 08:49 -0700
  Re: "Best practices" for animating sprites in Apple II Assembly? (HGR/HGR2) "Anton Treuenfels" <teamtempest@yahoo.com> - 2015-10-16 08:32 -0500
  Re: "Best practices" for animating sprites in Apple II Assembly? (HGR/HGR2) John Brooks <jbrooks@blueshiftinc.com> - 2015-10-16 08:08 -0700
  Re: "Best practices" for animating sprites in Apple II Assembly? (HGR/HGR2) jamesiwalker77@gmail.com - 2015-10-16 08:34 -0700

csiph-web