added box marking (but not painting yet)

This commit is contained in:
Rob McMullen 2017-07-21 11:53:23 -07:00
parent b9b5c7cf3b
commit 961310fd02
5 changed files with 154 additions and 37 deletions

View File

@ -87,6 +87,7 @@ GAME_OVER = 255
; ;
DOT_SCORE = 1 DOT_SCORE = 1
PAINT_SCORE_PER_LINE = 10 PAINT_SCORE_PER_LINE = 10
box_score .byte 0, $10, $20, $30, $40, $50, $60, $70, $80, $90
add_score nop add_score nop
sed sed

View File

@ -18,10 +18,6 @@ check_dots nop
sta c sta c
jsr has_dot jsr has_dot
beq ?1 beq ?1
lda r
sta dot_eaten_row,x
lda c
sta dot_eaten_col,x
ldy r ldy r
jsr mazerow jsr mazerow
@ -44,27 +40,6 @@ damage_maze nop
rts rts
;
; def update_background():
; zp.current_actor = 0
; while zp.current_actor < zp.num_players:
; if dot_eaten_col[zp.current_actor] < 128:
; # Here we update the screen; note the maze has already been updated
; # but we don't change the background until now so sprites can
; # restore their saved backgrounds first.
;
; r = dot_eaten_row[zp.current_actor]
; c = dot_eaten_col[zp.current_actor]
; addr = screenrow(r)
; addr[c] &= ~TILE_DOT
;
; # mark as completed
; dot_eaten_col[zp.current_actor] = 255
; update_score()
; zp.current_actor += 1
;
; paint_boxes()
;
; def paint_boxes(): ; def paint_boxes():
; x = 0 ; x = 0
; pad.addstr(28, 0, "Checking box:") ; pad.addstr(28, 0, "Checking box:")

142
maze.s
View File

@ -18,6 +18,10 @@ VPATH_NUM = 6
BOX_WIDTH = 5 BOX_WIDTH = 5
VPATH_COL_SPACING = BOX_WIDTH + 1 VPATH_COL_SPACING = BOX_WIDTH + 1
NUM_BOX_PAINTING_PARAMS = 4
MAX_BOX_PAINTING = NUM_BOX_PAINTING_PARAMS * 16
; storage ; storage
vpath_cols .byte 1, 7, 13, 19, 25, 31 vpath_cols .byte 1, 7, 13, 19, 25, 31
@ -425,15 +429,55 @@ finish_boxes nop
;def check_boxes(): ;def check_boxes():
check_boxes nop
; x = 0 ; x = 0
ldy #0
sty param_index
?loop ldy param_index
lda level_boxes,y
; pad.addstr(28, 0, str(level_boxes[0:21])) ; pad.addstr(28, 0, str(level_boxes[0:21]))
; while level_boxes[x] < 0xff: ; while level_boxes[x] < 0xff:
bpl ?1
rts
; c = level_boxes[x] ; c = level_boxes[x]
; if c > 0: ; if c > 0:
?1 bne ?check
iny ; box is filled; don't check again
iny
iny
sty param_index
bne ?loop
?check sta c1
sty param_save ; save index so we can mark the box as filled
; r1 = level_boxes[x + 1] ; r1 = level_boxes[x + 1]
iny
lda level_boxes,y
sta r1
iny
lda level_boxes,y
sta r2
iny
sty param_index
; addr = mazerow(r1) ; addr = mazerow(r1)
ldy r1
jsr mazerow
lda mazeaddr
sta scratch_addr
lda mazeaddr+1
sta scratch_addr+1 ; scratch_addr is top row
; r1 += 1 ; r1 += 1
iny
; r1_save = r1 ; r1_save = r1
sty r1
sty r
ldy r2
jsr mazerow ; mazeaddr is bot row
; ;
; # If there's a dot anywhere, then the box isn't painted. We don't ; # If there's a dot anywhere, then the box isn't painted. We don't
; # care where it is so we don't need to keep track of individual ; # care where it is so we don't need to keep track of individual
@ -443,34 +487,116 @@ finish_boxes nop
; r2 = level_boxes[x + 2] ; r2 = level_boxes[x + 2]
; addr = mazerow(r2) ; addr = mazerow(r2)
; dot |= addr[c]|addr[c + 1]|addr[c + 2]|addr[c + 3]|addr[c + 4]|addr[c + 5]|addr[c + BOX_WIDTH + 1] ; dot |= addr[c]|addr[c + 1]|addr[c + 2]|addr[c + 3]|addr[c + 4]|addr[c + 5]|addr[c + BOX_WIDTH + 1]
; lda #0
sta dot
; start checking top and bottom rows. 7 columns starting at c
ldy c1
ora (mazeaddr),y
ora (scratch_addr),y
iny
ora (mazeaddr),y
ora (scratch_addr),y
iny
ora (mazeaddr),y
ora (scratch_addr),y
iny
ora (mazeaddr),y
ora (scratch_addr),y
iny
ora (mazeaddr),y
ora (scratch_addr),y
iny
ora (mazeaddr),y
ora (scratch_addr),y
iny
ora (mazeaddr),y
ora (scratch_addr),y
and #TILE_DOT
bne ?loop ; a dot somewhere in there; skip this box!
sty c2
; while r1 < r2: ; while r1 < r2:
; addr = mazerow(r1) ; addr = mazerow(r1)
; dot |= addr[c]|addr[c + BOX_WIDTH + 1] ; dot |= addr[c]|addr[c + BOX_WIDTH + 1]
; r1 += 1 ; r1 += 1
; ?cols ldy r1
cpy r2
bcs ?paint
jsr mazerow
lda #0
ldy c1
ora (mazeaddr),y
ldy c2
ora (mazeaddr),y
and #TILE_DOT
bne ?loop ; a dot somewhere in there; skip this box!
inc r1
bne ?cols
; if (dot & TILE_DOT) == 0: ; if (dot & TILE_DOT) == 0:
; # No dots anywhere! Start painting ; # No dots anywhere! Start painting
; mark_box_for_painting(r1_save, r2, c + 1) ; mark_box_for_painting(r1_save, r2, c + 1)
?paint ldy r
sty r1
inc c1
jsr mark_box_for_painting
; level_boxes[x] = 0 # Set flag so we don't check this box again
ldy param_save
lda #0
sta level_boxes,y
; num_rows = r2 - r1_save ; num_rows = r2 - r1_save
; player_score[zp.current_actor] += num_rows * 100 ; player_score[zp.current_actor] += num_rows * 100
; level_boxes[x] = 0 # Set flag so we don't check this box again lda r2
; sec
; x += 3 sbc r
check_boxes nop tay
rts lda box_score,y
jsr add_score
;
;def mark_box_for_painting(r1, r2, c): ;def mark_box_for_painting(r1, r2, c):
mark_box_for_painting nop
; box_log.debug("Marking box, player $%d @ %d,%d -> %d,%d" % (zp.current_actor, r1, c, r2, c + BOX_WIDTH)) ; box_log.debug("Marking box, player $%d @ %d,%d -> %d,%d" % (zp.current_actor, r1, c, r2, c + BOX_WIDTH))
; x = 0 ; x = 0
; while x < NUM_BOX_PAINTING_PARAMS * 16: ; while x < NUM_BOX_PAINTING_PARAMS * 16:
ldy #0
?loop cpy #MAX_BOX_PAINTING
bcc ?1
rts
; if box_painting[x] == 0: ; if box_painting[x] == 0:
; box_painting[x] = c ; box_painting[x] = c
; box_painting[x + 1] = r1 ; box_painting[x + 1] = r1
; box_painting[x + 2] = r2 ; box_painting[x + 2] = r2
; box_painting[x + 3] = zp.current_actor ; box_painting[x + 3] = zp.current_actor
; break ; break
?1 lda box_painting,y
bne ?skip
lda c1
sta box_painting,y
iny
lda r1
sta box_painting,y
iny
lda r2
sta box_painting,y
iny
txa ; player number
sta box_painting,y
rts
; x += NUM_BOX_PAINTING_PARAMS ; x += NUM_BOX_PAINTING_PARAMS
; pad.addstr(27, 0, "starting box, player @ %d %d,%d -> %d,%d" % (zp.current_actor, r1, c, r2, c + BOX_WIDTH)) ; pad.addstr(27, 0, "starting box, player @ %d %d,%d -> %d,%d" % (zp.current_actor, r1, c, r2, c + BOX_WIDTH))
?skip iny
iny
iny
iny
bne ?loop ; always

4
vars.s
View File

@ -20,8 +20,6 @@ actor_active .ds MAX_ACTORS ; 1 = active, 0 = skip, $ff = end
actor_l .ds MAX_ACTORS actor_l .ds MAX_ACTORS
actor_h .ds MAX_ACTORS actor_h .ds MAX_ACTORS
dot_eaten_row .ds 4 ; # dot eaten by player
dot_eaten_col .ds 4
player_score .ds 4 player_score .ds 4
player_next_target_score .ds 4 player_next_target_score .ds 4
player_lives .ds 4 ; # lives remaining player_lives .ds 4 ; # lives remaining
@ -29,3 +27,5 @@ player_lives .ds 4 ; # lives remaining
amidar_start_col .ds VPATH_NUM amidar_start_col .ds VPATH_NUM
round_robin_up .ds VPATH_NUM round_robin_up .ds VPATH_NUM
round_robin_down .ds VPATH_NUM round_robin_down .ds VPATH_NUM
box_painting .ds MAX_BOX_PAINTING

View File

@ -25,6 +25,7 @@ param_col .ds 1
param_row .ds 1 param_row .ds 1
param_index .ds 1 param_index .ds 1
param_count .ds 1 param_count .ds 1
param_save .ds 1
*= $0010 *= $0010
; scratch areas: these may be modified by child subroutines ; scratch areas: these may be modified by child subroutines
@ -87,7 +88,12 @@ current .ds 1 ; current direction
allowed .ds 1 ; allowed directions allowed .ds 1 ; allowed directions
d .ds 1 ; actor input dir d .ds 1 ; actor input dir
r .ds 1 r .ds 1
r1 .ds 1
r2 .ds 1
c .ds 1 c .ds 1
c1 .ds 1
c2 .ds 1
dot .ds 1
round_robin_index .ds 2 round_robin_index .ds 2
level .ds 1 level .ds 1
last_enemy .ds 1 last_enemy .ds 1
@ -125,12 +131,21 @@ start nop
bit SETHIRES bit SETHIRES
jsr clrscr jsr clrscr
jsr init_screen_once jsr init_once
jsr init_actors_once
jsr title_screen jsr title_screen
jsr init_game jsr init_game
jsr game_loop jsr game_loop
init_once
jsr init_screen_once
jsr init_actors_once
ldx #MAX_BOX_PAINTING
lda #0
?1 sta box_painting - 1,x
dex
bne ?1
rts
forever forever
jmp forever jmp forever