Subject: Re: [stella] MultiSpriteDemo update (source+binary) From: emooney@xxxxxxxxxxxxxxxx (Erik Mooney) Date: Sat, 05 Apr 1997 21:35:08 GMT 
>; Straight from "Air sea battle", here's the routine >; to convert from standard X positions to FC positions. >; Could a good man explain me how it works? It's tricky, but I think I've figured it out. First, it makes the Xcoord zero if it's out of range (not between zero and 159.) Then, it takes the fine and coarse values in base16 of the number (which are simply the high and low nibbles). To convert base16 FC to base15 FC, you add the F and C values and put that in F; if that's >15, you subtract 15 from F and add one to C. (Trust me, this works mathematically, though it's difficult to explain.) The rest of the code cleans up and puts the F and C values together into one register. >CNV: STA TEMP+1 > BPL LF34B > CMP #$9E > BCC LF34B > LDA #$00 > STA TEMP+1 >LF34B: here, the Xcoordinate has been converted to zero if it was previously out of range, and it's in both A and Temp+1. >LSR > LSR > LSR > LSR > TAY Y=A/16 (Xcoord/16). Y = C in base16. > LDA TEMP+1 > AND #$0F A=A mod 16 (Xcoord mod 16). A = F in base16. > STY TEMP+1 > CLC > ADC TEMP+1 A = (Xcoord/16 + Xcoord mod 16) A now has the sum of the fine/coarse base16 coordinates. > CMP #$0F > BCC LF360 > SBC #$0F > INY >LF360: The key section. The coarse coordinate is now in Y, and A has the fine coordinate (zero to 14.) Y*15+A should equal the original Xcoord (try tracing through the code with a few different values.) >CMP #$08 > EOR #$0F > BCS LF369 > ADC #$01 > DEY >LF369: INY This converts the 0 to 14 setup of the fine coordinates to the +7 to 7 setup that HMxx and HMOVE want. I think we increment Y here because we want to use a DEY/BNE loop, so zero iterations of the loop means Y should equal 1 (?) > ASL > ASL > ASL > ASL > STA TEMP+1 > TYA > ORA TEMP+1 And this just puts the fine and coarse together into the same 8bit register. > RTS Obviously, the whole thing would be 12 cycles faster as a macro instead of as a subroutine if you can spare the space and only use it a few times.  Archives available at http://www.biglist.com/lists/stella/archives/ Email UNSUBSCRIBE in the body to stellarequest@xxxxxxxxxxx to be removed.
Current Thread 


< Previous  Index  Next > 

Re: [stella] MultiSpriteDemo update, Greg Troutman  Thread  Re: [stella] MultiSpriteDemo update, Erik Mooney 
Re: [stella] Re: Need programmer: A, Erik Mooney  Date  Re: [stella] MultiSpriteDemo update, Erik Mooney 
Month 