Shots can now have negative y-velocity.

This commit is contained in:
Colin McMillen 2015-05-31 10:45:29 -04:00
parent 611b4d20f2
commit 5ace3844dc

View File

@ -77,9 +77,9 @@ rep #%00010000 ; 16-bit X/Y.
lda $028000, X ; $028000: beginning of ROM bank 2. lda $028000, X ; $028000: beginning of ROM bank 2.
inx inx
cpx #$8000 ; This is the size of the entire ROM bank. cpx #$8000 ; This is the size of the entire ROM bank.
bne + bne +++
ldx #0 ldx #0
+ +++
stx randomBytePtr stx randomBytePtr
.ENDM .ENDM
@ -466,7 +466,7 @@ MaybeShoot:
sta 2, X sta 2, X
lda #6 ; x-velocity. lda #6 ; x-velocity.
sta 3, X sta 3, X
lda #0 ; y-velocity. lda #-3 ; y-velocity.
sta 4, X sta 4, X
; Update nextShotPtr. ; Update nextShotPtr.
.rept shotSize .rept shotSize
@ -511,16 +511,32 @@ UpdateShot:
bcs DisableShot bcs DisableShot
sta shotArray + 1, X ; Store new x-coord. sta shotArray + 1, X ; Store new x-coord.
UpdateShotY:
; Add to the y-coordinate. ; Add to the y-coordinate.
lda shotArray + 4, X ; y-velocity. lda shotArray + 4, X ; y-velocity.
sta $00 sta $00
bit #%10000000 ; Check whether the velocity is negative.
bne UpdateShotWithNegativeYVelocity
lda shotArray + 2, X lda shotArray + 2, X
; no need for clc - if it was set above, we already jumped to DisableShot.
adc $00 adc $00
cmp #224 cmp #224
bcs DisableShot bcs DisableShot
sta shotArray + 2, X ; Store new y-coord. sta shotArray + 2, X ; Store new y-coord.
jmp ShotDone
UpdateShotWithNegativeYVelocity:
lda shotArray + 2, X ; Current Y.
cmp #224
bcs + ; If the shot was "off the top" before moving, maybe we'll reap it.
adc $00 ; Otherwise, just update it,
sta shotArray + 2, X ; save the result,
jmp ShotDone ; and we know it shouldn't be reaped.
+
adc $00
cmp #224
bcc DisableShot ; If it's now wrapped around, reap it.
sta shotArray + 2, X
jmp ShotDone jmp ShotDone
DisableShot: DisableShot: