[stella] Revolutionary Horizontal positioning 2

Subject: [stella] Revolutionary Horizontal positioning 2
From: Manuel Polik <cybergoth@xxxxxxxx>
Date: Tue, 26 Nov 2002 13:23:42 +0100
Hi there!

Based on the repositioning technique of Battlezone, I 
discovered a technique that can reposition 2 objects at 
once(!) in a single(!) scannline - not table driven but 
by calculation!!!

Here's the snippet straight out of my recent Star Fire 
source (-> it works!)

This does a centered display of 16-Bit sprites with x 
coordinates ranging from 0-127:


        LDA xpos,X       ; A = desired X-position!

       STA WSYNC		;
       STA HMOVE        ; Begin repositioning scannline

       SBC #$0F      ; Battlezone calculate/wait
       BCS .wait     ; 2 in 1 magic !

       AND #$0F		 ; Manuels "forget about EOR/ASL
       TAY             ; nonsense" magic :-)
       LDA hmovetab,Y  ;
       STA HMP1       ;  Fine Position sprite 1
       SBC #$0F        ; Tada: carry is clear, so       
                       ;subtract $0F instead of $10
       STA HMP0        ; Fine Position 1 pixel 
				  ; corrected sprite 2
       STA RESP0       ;
       STA RESP1       ;
       JMP NextLine	  ; Immediate WSYNC/HMOVE follows!

    .byte $80,$70,$60,$50,$40,$30,$20,$10,$00
    .byte $F0,$E0,$D0,$C0,$B0,$A0,$90


So, I hope this gives you some more inspiration about 
ways of using the Battlezone magic :-)

For me it saved 2*160 bytes of tables, and even freed 
lots of kernel cycles, since both HMPX are set directly 
in the repositioning line now...


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

Current Thread