From 2bb1bc161d3cec45f5fd2ff71128d257dfbd3a6e Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Mon, 1 Jun 2015 00:18:03 -0400 Subject: [PATCH] Add multiple enemy shots. --- memory.asm | 4 ++-- pewpew.asm | 27 ++++++++++++++++++++------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/memory.asm b/memory.asm index a268167..ae3c391 100644 --- a/memory.asm +++ b/memory.asm @@ -13,7 +13,7 @@ ; 0030-003F: (x, y) velocities of each of the 8 possible shot states. ; 0040-009F: {sprite, x, y, x-velocity, y-velocity, unused} per player shot. ; If sprite is 0, the shot is disabled. -; 00A0-00FF: As above, for enemy shots. +; 00A0-015F: As above, for enemy shots. ; [gap] ; Sprite table buffers -- copied each frame to OAM during VBlank, using DMA. ; 1000-11FF: table 1 (4 bytes each: x/y coord, tile #, flip/priority/palette) @@ -34,7 +34,7 @@ .define playerShotArray $40 .define playerShotArrayLength 16 .define enemyShotArray $A0 -.define enemyShotArrayLength 16 +.define enemyShotArrayLength 32 .define shotSize 6 .define numSprites 128 diff --git a/pewpew.asm b/pewpew.asm index 5604b64..ddbb02d 100644 --- a/pewpew.asm +++ b/pewpew.asm @@ -488,22 +488,35 @@ UpdateShotCooldown: SpawnEnemyShots: lda vBlankCounter - bit #%00111111 + bit #%00001111 beq + rts ++ + ldy #0 +- + lda enemyShotArray, Y + cmp #0 + beq + + .rept 6 + iny + .endr + cpy #(enemyShotArrayLength * shotSize) + bne - + rts ; Too many shots; bail. + + lda #12 ; Sprite number. - sta enemyShotArray + sta enemyShotArray, Y lda #254 - sta enemyShotArray + 1 ; x. + sta enemyShotArray + 1, Y ; x. lda #((224 - 32) / 2) and #%01111111 - sta enemyShotArray + 2 ; y. + sta enemyShotArray + 2, Y ; y. - lda #-6 - sta enemyShotArray + 3 ; x-velocity. + lda #-4 + sta enemyShotArray + 3, Y ; x-velocity. GetRandomByte and #%00000111 ; [0, 7] @@ -513,7 +526,7 @@ SpawnEnemyShots: bne + lda #0 ; [-3, 3] with 2x chance of zero. + - sta enemyShotArray + 4 ; y-velocity. + sta enemyShotArray + 4, Y ; y-velocity. rts