Jump to content
IGNORED

The Southsider - Flashing Cockpits


RSS Bot

Recommended Posts

There is a discussion currently in the homebrew forum about adding a flashing cockpit to the Juno First ship. One approach would be to use the ball sprite overlaying the player sprite. The ball sprite is used for the laser and is already correctly positioned (horizontally), but I can't find the spare cycles to enable and disable it at the correct time. The main loop where the ship is drawn is a 1LK as follows (the actual code is in kernel1.h in the zip attached to the previous entry):

 

A_ShipLoop
; Calculate Pointer to Alien Sprite Data (aliens are 8 pixels high)
 tya					 ; [45] + 2
 sbc ALIENY			  ; [47] + 3
 bcs A_NoDraw			; [50] + 2/3
 adc #8				  ; [52] + 2
 bcc A_NewSprite		 ; [54] + 2/3
 adc TYPE				; [56] + 3
 tax					 ; [59] + 2
 
; Preload Ship Data
 lda (SPTR),Y			; [61] + 5
 sta GRP0				; [66] + 3	VDEL'ED
  
; Draw Alien & Ship
 lda A_Aliens,X		  ; [69] + 4
 sta GRP1				; [73] + 3	> 75
 lda A_AlienCols,X	; [0] + 4
 sta COLUP1			  ; [4] + 3	 > 75 < 23

; Set Ship Colour
 lda (CPTR),Y			; [7] + 5
 sta COLUP0			  ; [12] + 3	< 23
 
; Draw Bullets (using PHP stack trick)
 tya					 ; [15] + 2
 lsr					 ; [17] + 2
 cmp B2				  ; [19] + 3
 php					 ; [22] + 3
 cmp B1				  ; [25] + 3
 php					 ; [28] + 3 = 16

; Reset Stack Pointer
 ldx #ENAM1			  ; [31] + 2
 txs					 ; [33] + 2

; Check End of Kernel
 dey					 ; [35] + 2
 bmi A_EndShipKernel	 ; [37] + 2/3
 
; Check If Grid Line Should Be Drawn
 cpy LINE				; [39] + 3
 bcs A_ShipLoop		  ; [42] + 2/3
; ... Draw Grid Line, Alien & Ship and Return to Loop

 

The y register holds the line count, and there are variants of this loop for drawing background lines, calculating a pointer to the next alien, and repositioning the alien sprite. In these variants the bullets are not drawn, which frees up the necessary extra cycles.

 

To get a flashing cockpit, the ball sprite needs to be enabled and disabled at the correct time. One approach would be to use the lowest bit of the colour data, but would require 5 extra cycles as follows:

 

  lda (CPTR),Y
 sta COLUP0
 asl
 sta ENABL

 

Unfortunately I can't see any way to accomplish this. Unrolling the loop is not really possible as this would require 40 copies of this code (and all of the variants for repositioning etc.). I was wondering if any of the optimisation wizards around here could spot any way to fit this in. If not, it doesn't matter too much as this feature is not exactly essential to the game!

 

Chris

 

http://www.atariage.com/forums/index.php?a...;showentry=4939

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...