Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- down = 0
- up = 1
- left = 2
- right = 3
- idle = 4
- pCurrentFrame = $f0
- maxFrame = 3
- pSprite = screen_ram + $3f8
- pDirection = $f1
- pInputTrigger = $f6
- pVelocityX = $f2
- pVelocityY = $f3
- pX = $f4
- pY = $f5
- maxX = 255
- maxY = 200
- update_player
- ; Position = Position0 + velocity * time // Here, time = 1 by definition
- ; First, we have to determine the direction
- lda pInputTrigger
- beq updateFrame
- lda pDirection
- cmp #idle
- beq goIdle
- cmp #down
- beq goDown
- cmp #up
- beq goUp
- cmp #left
- beq goLeft
- cmp #right
- beq goRight
- rts
- goIdle
- lda #4
- sta pDirection
- lda #0
- sta pCurrentFrame
- sta pVelocityX
- sta pVelocityY
- lda #sprite_pointer
- sta pSprite
- jmp updateFrame
- goDown
- lda #0
- sta pCurrentFrame
- sta pVelocityX
- sta pDirection
- lda #1
- sta pVelocityY
- lda #sprite_pointer
- sta pSprite
- jmp updateFrame
- goUp
- lda #0
- sta pCurrentFrame
- sta pVelocityX
- lda #1
- sta pDirection
- lda #-1
- sta pVelocityY
- lda #sprite_pointer
- adc #3
- sta pSprite
- jmp updateFrame
- goLeft
- lda #0
- sta pVelocityY
- sta pCurrentFrame
- lda #-1
- sta pVelocityX
- lda #2
- sta pDirection
- lda #sprite_pointer
- adc #6
- sta pSprite
- jmp updateFrame
- goRight
- lda #0
- sta pVelocityY
- sta pCurrentFrame
- lda #1
- sta pVelocityX
- lda #3
- sta pDirection
- lda #sprite_pointer
- adc #9
- sta pSprite
- ; jmp updateFrame
- updateFrame
- ldx pCurrentFrame
- inx
- txa
- cmp #maxFrame
- bne updateFrame2
- lda #0
- sta pCurrentFrame
- updateFrame2
- rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement