aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-10-09 11:41:50 -0400
committerJesse Luehrs <doy@tozt.net>2014-10-09 11:42:11 -0400
commite039f249a80f9068518579c06e8b4a8cef7b7339 (patch)
treece07d49f2dc3c08e6e6a6ec88c632e962c06a51a
parent88e83296cd6b401bfb794e3b3869063a309ef172 (diff)
downloadnes-snake-e039f249a80f9068518579c06e8b4a8cef7b7339.tar.gz
nes-snake-e039f249a80f9068518579c06e8b4a8cef7b7339.zip
add an apple in a random location
-rw-r--r--main.s29
-rw-r--r--sprites.chrbin8192 -> 8192 bytes
2 files changed, 27 insertions, 2 deletions
diff --git a/main.s b/main.s
index b840298..cce0ae4 100644
--- a/main.s
+++ b/main.s
@@ -41,6 +41,7 @@ direction DB ; 0: up, 1: down, 2: left, 3: right
frame_skip DB
frame_count DB
rand_state DB
+apple INSTANCEOF point
.ENDE
; }}}
; }}}
@@ -148,11 +149,11 @@ NMI:
LDA game_state
BEQ reset_sprites
CMP #$01
- BEQ draw_head
+ BEQ draw_game
CMP #$02
BEQ end_nmi
-draw_head:
+draw_game:
LDY #$01
LDA (head), y
STA $0200
@@ -163,12 +164,23 @@ draw_head:
LDY #$00
LDA (head), y
STA $0203
+
+ LDA apple.y
+ STA $0204
+ LDA #$07
+ STA $0205
+ LDA #$00
+ STA $0206
+ LDA apple.x
+ STA $0207
JMP do_dmi
reset_sprites:
LDA #$FE
STA $0200
STA $0203
+ STA $0204
+ STA $0207
do_dmi:
LDA #$00
@@ -321,6 +333,19 @@ start_game: ; {{{
LDY #$01
STA (head), y
+ JSR rand
+ LDA rand_state
+ AND #%01111000
+ CLC
+ ADC #$40
+ STA apple.x
+ JSR rand
+ LDA rand_state
+ AND #%01111000
+ CLC
+ ADC #$3D
+ STA apple.y
+
- BIT $2002
BPL -
diff --git a/sprites.chr b/sprites.chr
index 894b4b5..9f333de 100644
--- a/sprites.chr
+++ b/sprites.chr
Binary files differ