Advertisement
Guest User

Untitled

a guest
May 9th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. moveBall:
  2. horizontalCheck:
  3.     lda #horizontalMovementRight
  4.     bit ballDirection           ;check if direction to the right
  5.     bne right
  6. left:
  7.     lda ballX
  8.     cmp #AREA_MIN_X
  9.     beq switchHorizontalDirection
  10.     dec ballX                   ; no left wall, x-- and go to vertical
  11.     jmp verticalCheck
  12. right:
  13.     lda ballX
  14.     cmp #AREA_MAX_X             ;check for right wall
  15.     beq switchHorizontalDirection
  16.     inc ballX                   ; no right wall, x++ and go to vertical check
  17.     jmp verticalCheck           ;
  18. switchHorizontalDirection:
  19.     lda ballDirection           ; toggle horizontal bit
  20.     eor #horizontalMovementRight
  21.     sta ballDirection
  22.     jmp horizontalCheck         ; and check again for the new direction
  23. verticalCheck:
  24.     lda #verticalMovementDown
  25.     bit ballDirection           ;check if direction to the down
  26.     bne down
  27. up:
  28.     lda ballY
  29.     cmp #AREA_MIN_Y
  30.     beq switchVerticalDirection
  31.     dec ballY                   ; no top wall
  32.     jmp endMoveBall
  33. down:
  34.     lda ballY
  35.     cmp #AREA_MAX_Y
  36.     beq switchVerticalDirection
  37.     inc ballY                   ; no bottom wall
  38.     jmp endMoveBall
  39. switchVerticalDirection:
  40.     lda ballDirection           ; toggle horizontal bit
  41.     eor #verticalMovementDown
  42.     sta ballDirection
  43.     jmp verticalCheck         ; and check again for the new direction
  44. endMoveBall:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement