From ca8926f567de30854ba94373cd5e6a031a3db292 Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Mon, 1 Jun 2015 23:05:37 -0400 Subject: [PATCH] Add display of player health. --- pewpew.asm | 42 +++++++++++++++++++++++++++++++++++++----- sprites32.pcx | Bin 2268 -> 2306 bytes 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/pewpew.asm b/pewpew.asm index 75be138..ed6d2b7 100644 --- a/pewpew.asm +++ b/pewpew.asm @@ -219,7 +219,7 @@ InitWorld: sta playerX lda #((224 - 32) / 2) sta playerY - lda #10 + lda #20 sta playerHealth ; (x-velocity, y-velocity) of 4 different player shot patterns. @@ -510,7 +510,7 @@ SpawnEnemyShots: rts ; Too many shots; bail. + - lda #12 ; Sprite number. + lda #9 ; Sprite number. sta enemyShotArray, Y lda #254 @@ -732,7 +732,7 @@ UpdateSprites: lda #0 sta spriteTableStart + 2, X ; Set priority bits so that the sprite is drawn in front. - lda #%00110000 + lda #%00010000 sta spriteTableStart + 3, X lda #%11000000 ; Enable large sprite. sta spriteTableScratchStart, Y @@ -758,11 +758,11 @@ UpdateSprites: ; Update secondary sprite table. phy ; Save playerShotArray index. ldy $00 - lda #%01000000 + lda #%01000000 ; Enable small sprite. sta spriteTableScratchStart, Y iny sty $00 - ply ; Restore playerShotArrayIndex. + ply ; Restore playerShotArray index. .rept 4 inx @@ -773,6 +773,38 @@ UpdateSprites: .endr cpy #((playerShotArrayLength + enemyShotArrayLength) * shotSize) bne - + ldy $00 ; Restore Y to its rightful self. + + ; Now add sprites to show player health. + ; TODO(mcmillen): why aren't they in front? + stz $01 + lda #4 + sta $02 +- + lda $01 + cmp playerHealth + beq + ; All done? + lda #10 + sta spriteTableStart + 2, X ; sprite number + lda $02 + sta spriteTableStart, X ; x + clc + adc #7 + sta $02 + lda #212 + sta spriteTableStart + 1, X ; y + ; Set priority bits so that the sprite is drawn in front. + lda #%00110000 + sta spriteTableStart + 3, X + lda #%01000000 ; Enable small sprite. + sta spriteTableScratchStart, Y + .rept 4 + inx + .endr + iny + inc $01 + bra - ++ ; Now clear out the unused entries in the sprite table. - diff --git a/sprites32.pcx b/sprites32.pcx index 99f3f32eea6ff3dc0b7cbd8a51727509216d1baa..baf29501977e4e553c90ee0dcc272d9ba0007c24 100644 GIT binary patch delta 151 zcmca3*d#Qehw~`IVRj&9doyvOwE1BM_QPE4hZ)!o^Rc~VILW}s!F-5=g^88%Is+po z^C396?KT7ZVJ`OD6Zgt; zLYWLFChixV_>YYp%AYLAD9Z{qX0j!tBJ+QSGm{e;H7CcjvQ3`CCnCCW