From 526bc9e32031afd206a8ceba486205c16d64cf4d Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Sun, 31 May 2015 18:03:46 -0400 Subject: [PATCH] Spawn enemy shots from right edge of screen. --- pewpew.asm | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/pewpew.asm b/pewpew.asm index f8b1b25..a1354d6 100644 --- a/pewpew.asm +++ b/pewpew.asm @@ -467,6 +467,7 @@ MaybeShootDone: UpdateWorld: jsr UpdateShotCooldown + jsr SpawnEnemyShots jsr UpdateShotPositions jsr UpdateBackgroundScroll rts @@ -485,6 +486,38 @@ UpdateShotCooldown: +SpawnEnemyShots: + lda vBlankCounter + bit #%00111111 + beq + + rts ++ + lda #8 ; Sprite number. + sta enemyShotArray + + lda #254 + sta enemyShotArray + 1 ; x. + + lda #((224 - 32) / 2) + and #%01111111 + sta enemyShotArray + 2 ; y. + + lda #-6 + sta enemyShotArray + 3 ; x-velocity. + + GetRandomByte + and #%00000111 ; [0, 7] + clc + adc #-3 ; [-3, 4] + cmp #4 + bne + + lda #0 ; [-3, 3] with 2x chance of zero. ++ + sta enemyShotArray + 4 ; y-velocity. + rts + + + UpdateShotPositions: ldx #0 @@ -553,7 +586,7 @@ ShotDone: .rept shotSize inx .endr - cpx #(playerShotArrayLength * shotSize) + cpx #(playerShotArrayLength * enemyShotArrayLength * shotSize) bne UpdateShot rts @@ -653,7 +686,7 @@ UpdateSprites: .rept shotSize iny .endr - cpy #(playerShotArrayLength * shotSize) + cpy #((playerShotArrayLength + enemyShotArrayLength) * shotSize) bne - ; Now clear out the unused entries in the sprite table.