Learning Assembly, #25

Today I figured out how to limit the sprite’s horizontal position!
Here’s the code snippet:

StartFrame:
	; ...
	inc P0XPos
	lda P0XPos
	and #%00111111  ; Limit player X to 63
	beq PlayerStart ; Branch on zero
	sta P0XPos

	jmp StartFrame

PlayerStart:
	lda #20         ; Reset player position
	sta P0XPos
	jmp StartFrame

There’s probably a much better way to do this, but it works!

Leave a comment

Your email address will not be published. Required fields are marked *

Your data is processed in accordance with my privacy policy. Comments are manually approved and may take a while to appear.