From 485da7fcc6623bbdbd5cb44302eee900cb843354 Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Sun, 7 Jun 2015 15:14:41 -0400 Subject: [PATCH] Track & display high score. --- memory.asm | 2 ++ pewpew.asm | 44 +++++++++++++++++++++++++++++++++++++++++++- sprites32.pcx | Bin 3135 -> 3185 bytes 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/memory.asm b/memory.asm index 81e0d0e..25d9a01 100644 --- a/memory.asm +++ b/memory.asm @@ -5,6 +5,7 @@ ; 0014-0016: 24-bit counter of vblanks. ; 0017-0019: RGB color values to use for background color, from [0-31]. ; 001A-001B: 16-bit pointer to next random byte. +; 001C-001D: 16-bit high-score. ; [gap] ; 0020-0021: (x, y) coordinates of player. ; 0022: player health. @@ -31,6 +32,7 @@ .define backgroundGreen $18 .define backgroundBlue $19 .define randomBytePtr $1A +.define highScore $1C .define playerX $20 .define playerY $21 .define playerHealth $22 diff --git a/pewpew.asm b/pewpew.asm index 76915a2..26bf8e0 100644 --- a/pewpew.asm +++ b/pewpew.asm @@ -504,6 +504,7 @@ UpdateWorld: jsr CheckCollisionsWithEnemies jsr UpdateBackgroundScroll + jsr UpdateHighScore rts @@ -959,6 +960,18 @@ UpdateBackgroundScroll: +UpdateHighScore: + SetA16Bit + lda playerScore + cmp highScore + bcc + + sta highScore ++ + SetA8Bit + rts + + + UpdateSprites: ; TODO: refactor into smaller pieces. ; This page is a good reference on SNES sprite formats: ; http://wiki.superfamicom.org/snes/show/SNES+Sprites @@ -1094,7 +1107,7 @@ UpdateSprites: ; TODO: refactor into smaller pieces. + ; Sprites to show player score. - lda #(252 - 7 * 6) + lda #76 sta $00 ; x-position lda #212 sta $01 ; y-position @@ -1108,6 +1121,35 @@ UpdateSprites: ; TODO: refactor into smaller pieces. lda #0 jsr RenderTwoDigits + ; Sprites to show high score. + lda #(252 - 7 * 6) + sta $00 + lda #212 + sta $01 + stz $02 + stz $03 + lda highScore + 1 + jsr RenderTwoDigits + lda highScore + jsr RenderTwoDigits + inc $03 ; Render rightmost zero always. + lda #0 + jsr RenderTwoDigits + + ; The little "HI" sprite next to high-score. + lda #(252 - 7 * 7 - 2) + sta spriteTableStart, X + lda #212 + sta spriteTableStart + 1, X + lda #74 + sta spriteTableStart + 2, X + ; 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 + AdvanceSpritePointers + ; Now clear out the unused entries in the sprite table. - cpx #spriteTable1Size diff --git a/sprites32.pcx b/sprites32.pcx index b6a61da9469d2ba983d68886ee533cbac7c956a4..c61e09d94c7433f5e5341f24b63625f0213cbfd6 100644 GIT binary patch delta 107 zcmdll@lj$!5ev&%2ClD@C7A3sZ)V|T;$k=iMK2~FWYa