Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. define horizontalMovementRight $1
  2. define verticalMovementDown $2
  3. updateBallNoClip:
  4. lda #horizontalMovementRight
  5. bit ballDirection ;check if direction to the right
  6. bne right
  7. left:
  8. dec ballX
  9. jmp verticalCheck
  10. right:
  11. inc ballX
  12. verticalCheck:
  13. lda #verticalMovementDown
  14. bit ballDirection ;check if going down
  15. bne down
  16. up:
  17. dec ballY
  18. jmp endUpdateBallNoClip
  19. down:
  20. inc ballY
  21. endUpdateBallNoClip:
  22. rts
  23.  
  24. ;check if the ball should bounce off walls
  25. checkBallWallCollision:
  26. leftWallCheck:
  27. lda ballX
  28. bpl rightWallCheck
  29. ;hit left wall
  30. jsr toggleHorizontalDirection
  31. ;move right two places
  32. inc ballX
  33. inc ballX
  34. rightWallCheck:
  35. cmp #$20 ;over the right wall
  36. bne topWallCheck
  37. ;hit right wall
  38. jsr toggleHorizontalDirection
  39. dec ballX
  40. dec ballX
  41. topWallCheck:
  42. lda ballY
  43. bpl bottomWallCheck
  44. ;hit top wall
  45. jsr toggleVerticalDirection
  46. inc ballY
  47. inc ballY
  48. bottomWallCheck:
  49. cmp #$20
  50. bne endCheckBallWallCollision
  51. jsr toggleVerticalDirection
  52. dec ballY
  53. dec ballY
  54. endCheckBallWallCollision:
  55. rts
  56.  
  57. toggleHorizontalDirection:
  58. lda ballDirection ; toggle horizontal bit
  59. eor #horizontalMovementRight
  60. sta ballDirection
  61. rts
  62.  
  63. toggleVerticalDirection:
  64. lda ballDirection ; toggle vertical bit
  65. eor #verticalMovementDown
  66. sta ballDirection
  67. rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement