Subject: Re: [stella] Asymmetrical Reflected Playfield From: Erik Mooney <erik@xxxxxxxxxx> Date: Sat, 22 Sep 2001 20:30:08 -0400 |
On Fri, 21 Sep 2001 22:34:51 -0700, you wrote: >As I outlined in an earlier email, I need to perform quite a bit of >conditional evaluation on the sprite scanlines: > >1) Do I display P0? If so, how far into the table do I index? Do I need >to turn VDELP0 on? >2) Do I display P1? If so, how far into the table do I index? Do I need >to turn VDELP1 on? >STA P1/VDELP1 Well, the VDELs can be done offscreen, but the rest of it is a bit of a challenge. The trick here is that you can combine your conditionals. What if, you maintain a counter for each of the objects, and decrement that on every scanline-pair all the time? Suppose player 0 is supposed to begin on linepair 34 (scanline 68) and end on pair 41. At the top of the frame, you initialize the counter to 41. Then each linepair would look like this: LDA P0Counter ;+3 3 AND #$F8 ;+2 5 'works if P0 height is a power of 2 BNE NoP0 ;+2 7 TAY ;+2 9 LDA (P0Gfx), Y ;+5 14 STA GRP0 ;+3 17 NoP0 DEC P0Counter ;+5 22 or 13 P0Gfx is a pointer in RAM to P0's current graphics frame in ROM, set up offscreen. (Note that it's a 16-bit pointer, so RAM location P0Gfx+1 must point to the correct page.) Also, the last line of player graphics read from the ROM must be zero, so that GRP0 will stay zero for the rest of the frame. That AND is the trick to the whole operation. It rests on the fact that P0Counter decrements to 255 after passing zero -- after that the AND will always result in nonzero for the rest of the frame so the BNE always jumps. That's 22 cycles to handle everything for P0, and the code can be cloned to handle P1. You can knock off one cycle if you copy the entire frame of animation to RAM offscreen, and then use zeropage indexed TAX / LDA P0RamGfx, X which is 4 cycles instead of 5. I think that doing this also lets you use the undocumented opcode LAX to load A and X at the same time, eliminating the TAX -- that's down to 19 to completely handle P0! The missiles are a bit trickier because you have to manipulate all of NUSIZx, HMMx, ENAMx, and HMOVE, but similar code should work. Can someone better at 6502 change that AND into a CMP to allow for any height of player? I'm not sure which branch instruction would make that work. Well, any improvements from the 6502 gurus are certainly welcome :) I vaguely recall seeing a routine like this used in somebody's source on the list.. Thrust maybe? This Planet Sucks? - Archives (includes files) at http://www.biglist.com/lists/stella/archives/ Unsub & more at http://www.biglist.com/lists/stella/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [stella] Asymmetrical Reflected, Glenn Saunders | Thread | [stella] DD Build 0002, Glenn Saunders |
RE: [stella] colours.bin (or is it , Nicolás Olhaberry | Date | [stella] DD_0003, Glenn Saunders |
Month |