diff options
author | Jesse Luehrs <doy@tozt.net> | 2014-10-06 17:24:58 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2014-10-06 17:24:58 -0400 |
commit | a13dde134922a3ec5b16be1bb65a689f552b5418 (patch) | |
tree | 49957c87b3ae675779ea339d538c10fb3093aca5 | |
parent | 4e30e6509eea40f44d1d38316433c684257b4f8a (diff) | |
download | nes-snake-a13dde134922a3ec5b16be1bb65a689f552b5418.tar.gz nes-snake-a13dde134922a3ec5b16be1bb65a689f552b5418.zip |
add a (blank) start screen
-rw-r--r-- | main.s | 32 |
1 files changed, 29 insertions, 3 deletions
@@ -18,6 +18,7 @@ BANKS 1 .ENUM $0000 buttons_pressed DB sleeping DB +game_state DB ; 0: menu, 1: playing head_x DB head_y DB direction DB ; 0: up, 1: down, 2: left, 3: right @@ -73,6 +74,7 @@ clrmem: LDA #$00 STA buttons_pressed STA sleeping + STA game_state STA direction STA frame_count LDA #$80 @@ -113,6 +115,26 @@ loop: JSR read_controller1 + LDA game_state + BNE + + JSR start_screen_loop + JMP loop ++ JSR game_loop + JMP loop + +start_screen_loop: +handle_start: + LDA buttons_pressed + AND #%00010000 + CMP #$00 + BEQ end_start_screen_loop + LDA #$01 + STA game_state + +end_start_screen_loop: + RTS + +game_loop: handle_up: LDA buttons_pressed AND #%00001000 @@ -150,7 +172,7 @@ handle_frame: INX STX frame_count CPX frame_skip - BMI next_frame + BMI end_game_loop LDA #$00 STA frame_count @@ -175,8 +197,8 @@ apply_direction: ADC head_x, y ; head_x offset by 1 is head_y STA head_x, y -next_frame: - JMP loop +end_game_loop: + RTS NMI: @@ -186,6 +208,9 @@ NMI: TYA PHA + LDA game_state + BEQ end_nmi + LDA head_y STA $0200 LDA #$00 @@ -200,6 +225,7 @@ NMI: LDA #$02 STA $4014 +end_nmi: LDA #$00 STA sleeping |