Advertisement
Guest User

Untitled

a guest
Mar 7th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. down = 0
  2. up = 1
  3. left = 2
  4. right = 3
  5. idle = 4
  6.  
  7. pCurrentFrame = $f0
  8. maxFrame = 3
  9.  
  10. pSprite = screen_ram + $3f8
  11.  
  12. pDirection = $f1
  13. pInputTrigger = $f6
  14. pVelocityX = $f2
  15. pVelocityY = $f3
  16. pX = $f4
  17. pY = $f5
  18. maxX = 255
  19. maxY = 200
  20.  
  21. update_player
  22.     ; Position = Position0 + velocity * time // Here, time = 1 by definition
  23.     ; First, we have to determine the direction
  24.     lda pInputTrigger
  25.     beq updateFrame
  26.  
  27.     lda pDirection
  28.  
  29.     cmp #idle
  30.     beq goIdle
  31.  
  32.     cmp #down
  33.     beq goDown
  34.  
  35.     cmp #up
  36.     beq goUp
  37.  
  38.     cmp #left
  39.     beq goLeft
  40.  
  41.     cmp #right
  42.     beq goRight
  43.  
  44.     rts
  45.  
  46. goIdle
  47.     lda #4
  48.     sta pDirection
  49.     lda #0
  50.     sta pCurrentFrame
  51.     sta pVelocityX
  52.     sta pVelocityY
  53.     lda #sprite_pointer
  54.     sta pSprite
  55.     jmp updateFrame
  56.  
  57. goDown
  58.     lda #0
  59.     sta pCurrentFrame
  60.     sta pVelocityX
  61.     sta pDirection
  62.     lda #1
  63.     sta pVelocityY
  64.     lda #sprite_pointer
  65.     sta pSprite
  66.     jmp updateFrame
  67.  
  68. goUp
  69.     lda #0
  70.     sta pCurrentFrame
  71.     sta pVelocityX
  72.     lda #1
  73.     sta pDirection
  74.     lda #-1
  75.     sta pVelocityY
  76.     lda #sprite_pointer
  77.     adc #3
  78.     sta pSprite
  79.     jmp updateFrame
  80.  
  81. goLeft
  82.     lda #0
  83.     sta pVelocityY
  84.     sta pCurrentFrame
  85.     lda #-1
  86.     sta pVelocityX
  87.     lda #2
  88.     sta pDirection
  89.     lda #sprite_pointer
  90.     adc #6
  91.     sta pSprite
  92.     jmp updateFrame
  93.  
  94. goRight
  95.     lda #0
  96.     sta pVelocityY
  97.     sta pCurrentFrame
  98.     lda #1
  99.     sta pVelocityX
  100.     lda #3
  101.     sta pDirection
  102.     lda #sprite_pointer
  103.     adc #9
  104.     sta pSprite
  105. ;   jmp updateFrame
  106.  
  107. updateFrame
  108.     ldx pCurrentFrame
  109.     inx
  110.     txa
  111.     cmp #maxFrame
  112.     bne updateFrame2
  113.     lda #0
  114.     sta pCurrentFrame
  115. updateFrame2
  116.     rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement