BullGFX1:
lda (Temp+10),y ; Get data from character we're
and #$0f ; about to overwrite, and mask it.
ora #$a0 ; now OR in the bullet graphic
sta (Temp+12),y ; and store into its new bitmap
iny ; and move on....
lda (Temp+10),y
and #$0f
ora #$d0
sta (Temp+12),y
iny
lda (Temp+10),y
and #$0f
ora #$b0
sta (Temp+12),y
iny
lda (Temp+10),y
and #$0f
ora #$a0
sta (Temp+12),y
iny
lda (Temp+10),y ; Since the bullet is only 4 high, we can
sta (Temp+12),y ; just copy the remaining lines.
iny
lda (Temp+10),y
sta (Temp+12),y
iny
lda (Temp+10),y
sta (Temp+12),y
iny
lda (Temp+10),y
sta (Temp+12),y
jmp RetMaskBull
Now this is pretty quick anyway. I have 4 routines like that to deal with the bullet in each of its positions (since a bullet takes up a quarter of a character, it can be in 4 places in a character). But the masking and copying still takes time. So heres what happens when I detect the bullet is over a space character.
BullGFX1_2:
lda #$a0 ; Get graphic data
sta (Temp+12),y ; Store in bitmap
iny ; move to next line
lda #$d0
sta (Temp+12),y
iny
lda #$b0
sta (Temp+12),y
iny
lda #$a0
sta (Temp+12),y
iny
lda #0 ; Since we know we are over a space, we can
sta (Temp+12),y ; just force in zero's all the time.
iny
sta (Temp+12),y
iny
sta (Temp+12),y
iny
sta (Temp+12),y
jmp RetMaskBull
This function should be the case most of the time, and help balance out the game and make it a bit more even. The faster routine's only added around 170 bytes to the code, so its well worth doing. Overall, the new bullet's take around 450 bytes extra of code - quite a lot, but worth it for the results it gives. There is always the chance that all the Aliens are over the background and so are all the bullets and this would cause the game to slow down. However, since we script the baddie movement, and can place the turrets where we like, we can simply design it all so that this worst case never happens, and you never experiance it. The only thing we can't design around is the player movement, and firing of his own weapons - we just have to leave as much CPU time as possible for that.
No comments:
Post a Comment