Block Dodge is back on track. This game is for my Color Computer 3, and is my first all assembly project. All my backend graphics code, as well as some utility code had to be written first. But now that is mostly done. I now have a game that cycles between modes, and is able to somewhat play a game.
I say somewhat because the collision detection is way off. But the game does have an attract move, and you can use the space bar to jump to the top or bottom of the screen. That logic wasn't bad to figure out. But I did have to do some significant rework in the player_update
and process_input
code. For the latter, I had to check what direction I was already moving by looking at the negative flag, then branching to a move up or down routine. Pretty happy with this code.
;************************************************
; move player if they need moving, stop movement
; when they reach destination. Reset jump_pressed
; when destination reached. Ensure they are not past
; the dest, if so reset to dest.
;***
player_update lda jump_pressed ; are we processing a jump?
beq done@ ; no
lda playerxy+1 ; load posy
cmpa player_destxy+1 ; at destination?
beq at_dest@ ; yes
adda player_dirxy+1 ; no, move player y
sta playerxy+1 ; store
; check player has moved too far, and move back if so
lda player_dirxy+1 ; grab dir
bpl moving_down@
moving_up@ lda playerxy+1 ; load posy
cmpa #PLAYER_TOP ; check posy against TOP
bge done@ ; branch if >=,
lda #PLAYER_TOP ; posy < TOP so set player to top
sta playerxy+1
bra at_dest@ ; we are at our destination now
moving_down@ lda playerxy+1 ; load posy
cmpa #PLAYER_BOTTOM ; check posy against BOTTOM
bls done@ ; branch if <=
lda #PLAYER_BOTTOM ; posy > BOTTOM so set player to BOTTOM
sta playerxy+1
bra at_dest@ ; we are at our destination now
at_dest@ clr jump_pressed ; clear flag so we can jump again
ldd score_player ; load and update score
addd #10
std score_player
done@ rts
;************************************************
process_input
lda jump_pressed ; are we already jumping?
bne key_done@ ; yes, jump is already pressed
jsr inkey ; read keyboard
cmpa #32 ; did we detect space bar?
bne key_done@ ; nope, done
sta jump_pressed ; yup, set flag
; figure out what direction we need to send player
lda player_dirxy+1 ; get current direction
bpl move_up ; we were moving down, so move up
move_down
lda #PLAYER_BOTTOM
sta player_destxy+1
lda #PLAYER_SPEED_DN
sta player_dirxy+1
rts
move_up
lda #PLAYER_TOP
sta player_destxy+1
lda #PLAYER_SPEED_UP
sta player_dirxy+1
key_done@ rts
Copyright © 2025, Lee Patterson