Initial state machine for player status

This commit is contained in:
Rob McMullen 2017-07-22 12:47:55 -07:00
parent e38d57d144
commit 453641d8e2
4 changed files with 240 additions and 160 deletions

View File

@ -1,4 +1,4 @@
level_enemies .byte 55, 2, 5, 6, 7, 8 ;# level starts counting from 1, so dummy zeroth level info
level_enemies .byte 55, 4, 5, 6, 7, 8 ;# level starts counting from 1, so dummy zeroth level info
level_speed_l .byte 255, 200, 210, 220, 230, 240 ;# increment of fractional pixel per game frame
level_speed_h .byte 2, 2, 2, 2, 2, 2
;level_speed_h .byte 0, 0, 0, 0, 0, 0
@ -202,7 +202,7 @@ init_level nop
; actor_input_dir[zp.current_actor] = 0
; actor in X
init_actor nop
init_common nop
lda #MAZE_LEFT_COL
sta actor_col,x
lda #3
@ -216,17 +216,23 @@ init_actor nop
sta actor_yspeed_l,x
sta actor_yspeed_h,x
sta actor_input_dir,x
sta actor_frame_counter,x
sta actor_target_col,x
sta actor_input_dir,x
sta actor_turn_zone,x
lda #MAZE_BOT_ROW
sta actor_row,x
lda #TILE_UP
sta actor_updown,x
sta actor_dir,x
rts
init_actor nop
jsr init_common
lda #0
sta actor_frame_counter,x
sta actor_target_col,x
lda #NOT_VISIBLE
sta actor_status,x
lda #1
sta actor_active,x
rts
@ -295,8 +301,7 @@ init_amidar nop
; actor_col[zp.current_actor] = addr[zp.current_actor]
; actor_row[zp.current_actor] = MAZE_BOT_ROW
; actor_status[zp.current_actor] = PLAYER_ALIVE
init_player nop
jsr init_actor
init_player_common
lda config_num_players ; 4 players max,
asl a
asl a
@ -307,6 +312,11 @@ init_player nop
sta actor_col,x
lda #MAZE_BOT_ROW
sta actor_row,x
rts
init_player nop
jsr init_actor
jsr init_player_common
lda #PLAYER_ALIVE
sta actor_status,x
; player_lives[zp.current_actor] = STARTING_LIVES
@ -320,6 +330,9 @@ init_player nop
sta player_score_h
rts
next_life jsr init_common
jsr init_player_common
rts
;def init_actors():
init_actors nop

316
debug.s
View File

@ -54,52 +54,52 @@ debug_player nop
lda #22
sta scratch_row
ldx #34
ldy scratch_row
lda #'d'
jsr fastfont
ldx #0
lda actor_input_dir,x
ldx #35
ldy scratch_row
jsr debughex
ldx #0
lda actor_dir,x
ldx #38
ldy scratch_row
jsr debughex
dec scratch_row
ldx #34
ldy scratch_row
lda #'x'
jsr fastfont
ldx #0
lda actor_x,x
ldx #35
ldy scratch_row
jsr debughex
ldx #0
lda actor_y,x
ldx #38
ldy scratch_row
jsr debughex
dec scratch_row
ldx #34
ldy scratch_row
lda #'c'
jsr fastfont
ldx #0
lda actor_col,x
ldx #35
ldy scratch_row
jsr debughex
ldx #0
lda actor_row,x
ldx #38
ldy scratch_row
jsr debughex
; ldx #34
; ldy scratch_row
; lda #'d'
; jsr fastfont
; ldx #0
; lda actor_input_dir,x
; ldx #35
; ldy scratch_row
; jsr debughex
; ldx #0
; lda actor_dir,x
; ldx #38
; ldy scratch_row
; jsr debughex
;
; dec scratch_row
; ldx #34
; ldy scratch_row
; lda #'x'
; jsr fastfont
; ldx #0
; lda actor_x,x
; ldx #35
; ldy scratch_row
; jsr debughex
; ldx #0
; lda actor_y,x
; ldx #38
; ldy scratch_row
; jsr debughex
;
; dec scratch_row
; ldx #34
; ldy scratch_row
; lda #'c'
; jsr fastfont
; ldx #0
; lda actor_col,x
; ldx #35
; ldy scratch_row
; jsr debughex
; ldx #0
; lda actor_row,x
; ldx #38
; ldy scratch_row
; jsr debughex
dec scratch_row
ldx #34
@ -112,7 +112,23 @@ debug_player nop
ldy scratch_row
jsr debughex
ldx #0
lda actor_turn_zone,x
lda actor_active,x
ldx #38
ldy scratch_row
jsr debughex
dec scratch_row
ldx #34
ldy scratch_row
lda #'t'
jsr fastfont
ldx #0
lda actor_frame_counter,x
ldx #35
ldy scratch_row
jsr debughex
ldx #0
lda actor_active,x
ldx #38
ldy scratch_row
jsr debughex
@ -149,108 +165,108 @@ debug_player nop
; ldy scratch_row
; jsr debughex
; amidar 4
dec scratch_row
ldx #34
ldy scratch_row
lda #'4'
jsr fastfont
ldx #FIRST_AMIDAR+3
lda actor_col,x
ldx #35
ldy scratch_row
jsr debughex
ldx #FIRST_AMIDAR+3
lda actor_row,x
ldx #38
ldy scratch_row
jsr debughex
; amidar 3
dec scratch_row
ldx #34
ldy scratch_row
lda #'3'
jsr fastfont
ldx #FIRST_AMIDAR+2
lda actor_col,x
ldx #35
ldy scratch_row
jsr debughex
ldx #FIRST_AMIDAR+2
lda actor_row,x
ldx #38
ldy scratch_row
jsr debughex
; amidar 2
dec scratch_row
ldx #FIRST_AMIDAR+1
lda actor_xpixel,x
ldx #35
ldy scratch_row
jsr debughex
ldx #FIRST_AMIDAR+1
lda actor_ypixel,x
ldx #38
ldy scratch_row
jsr debughex
dec scratch_row
ldx #34
ldy scratch_row
lda #'2'
jsr fastfont
ldx #FIRST_AMIDAR+1
lda actor_col,x
ldx #35
ldy scratch_row
jsr debughex
ldx #FIRST_AMIDAR+1
lda actor_row,x
ldx #38
ldy scratch_row
jsr debughex
; amidar 1 (orbiter)
dec scratch_row
ldx #FIRST_AMIDAR
lda actor_xpixel,x
ldx #35
ldy scratch_row
jsr debughex
ldx #FIRST_AMIDAR
lda actor_ypixel,x
ldx #38
ldy scratch_row
jsr debughex
dec scratch_row
ldx #FIRST_AMIDAR
lda actor_xfrac,x
ldx #35
ldy scratch_row
jsr debughex
ldx #FIRST_AMIDAR
lda actor_yfrac,x
ldx #38
ldy scratch_row
jsr debughex
dec scratch_row
ldx #34
ldy scratch_row
lda #'1'
jsr fastfont
ldx #FIRST_AMIDAR
lda actor_col,x
ldx #35
ldy scratch_row
jsr debughex
ldx #FIRST_AMIDAR
lda actor_row,x
ldx #38
ldy scratch_row
jsr debughex
; ; amidar 4
; dec scratch_row
; ldx #34
; ldy scratch_row
; lda #'4'
; jsr fastfont
; ldx #FIRST_AMIDAR+3
; lda actor_col,x
; ldx #35
; ldy scratch_row
; jsr debughex
; ldx #FIRST_AMIDAR+3
; lda actor_row,x
; ldx #38
; ldy scratch_row
; jsr debughex
;
; ; amidar 3
; dec scratch_row
; ldx #34
; ldy scratch_row
; lda #'3'
; jsr fastfont
; ldx #FIRST_AMIDAR+2
; lda actor_col,x
; ldx #35
; ldy scratch_row
; jsr debughex
; ldx #FIRST_AMIDAR+2
; lda actor_row,x
; ldx #38
; ldy scratch_row
; jsr debughex
;
; ; amidar 2
; dec scratch_row
; ldx #FIRST_AMIDAR+1
; lda actor_xpixel,x
; ldx #35
; ldy scratch_row
; jsr debughex
; ldx #FIRST_AMIDAR+1
; lda actor_ypixel,x
; ldx #38
; ldy scratch_row
; jsr debughex
;
; dec scratch_row
; ldx #34
; ldy scratch_row
; lda #'2'
; jsr fastfont
; ldx #FIRST_AMIDAR+1
; lda actor_col,x
; ldx #35
; ldy scratch_row
; jsr debughex
; ldx #FIRST_AMIDAR+1
; lda actor_row,x
; ldx #38
; ldy scratch_row
; jsr debughex
;
; ; amidar 1 (orbiter)
; dec scratch_row
; ldx #FIRST_AMIDAR
; lda actor_xpixel,x
; ldx #35
; ldy scratch_row
; jsr debughex
; ldx #FIRST_AMIDAR
; lda actor_ypixel,x
; ldx #38
; ldy scratch_row
; jsr debughex
;
; dec scratch_row
; ldx #FIRST_AMIDAR
; lda actor_xfrac,x
; ldx #35
; ldy scratch_row
; jsr debughex
; ldx #FIRST_AMIDAR
; lda actor_yfrac,x
; ldx #38
; ldy scratch_row
; jsr debughex
;
; dec scratch_row
; ldx #34
; ldy scratch_row
; lda #'1'
; jsr fastfont
; ldx #FIRST_AMIDAR
; lda actor_col,x
; ldx #35
; ldy scratch_row
; jsr debughex
; ldx #FIRST_AMIDAR
; lda actor_row,x
; ldx #38
; ldy scratch_row
; jsr debughex
rts

56
logic.s
View File

@ -1,5 +1,5 @@
EXPLODING_TIME = 50
DEAD_TIME = 40
EXPLODING_TIME = 10
DEAD_TIME = 10
REGENERATING_TIME = 60
END_GAME_TIME = 100
TITLE_SCREEN_TIME = 100
@ -52,9 +52,57 @@ TITLE_SCREEN_TIME = 100
; c = None
; zp.sprite_addr = c
evaluate_status nop
; update pixel position
lda actor_status,x
cmp #PLAYER_EXPLODING
bne ?dead
lda #0
sta actor_active,x
dec actor_frame_counter,x
bne ?end
lda #PLAYER_DEAD
sta actor_status,x
lda #DEAD_TIME
sta actor_frame_counter,x
dec player_lives,x
jmp update_lives
?dead cmp #PLAYER_DEAD
bne ?regenerating
dec actor_frame_counter,x
bne ?end
lda player_lives,x
beq ?game_over
jsr next_life
lda #PLAYER_REGENERATING
sta actor_status,x
lda #REGENERATING_TIME
sta actor_frame_counter,x
rts
?regenerating cmp #PLAYER_REGENERATING
bne ?end
dec actor_frame_counter,x
beq ?alive
lda actor_frame_counter,x
and #1
sta actor_active,x
rts
?game_over nop
rts
?alive lda #1
sta actor_active,x
?end rts
get_sprite nop
; update pixel position
lda actor_row,x
tay
lda player_row_to_y,y
@ -71,6 +119,8 @@ get_sprite nop
?end
rts
?game_over
rts
;
;

View File

@ -318,6 +318,7 @@ renderstart
renderloop
ldx param_index
jsr evaluate_status
lda actor_active,x
beq renderskip ; skip if zero
bmi renderend ; end if negative