Advertisement
NovaYoshi

NES collision

Jul 12th, 2013
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .proc ChkTouchGeneric
  2.   jsr :+
  3.   swapa TouchLeftA,   TouchLeftB
  4.   swapa TouchTopA,    TouchTopB
  5.   swapa TouchWidthA,  TouchWidthB
  6.   swapa TouchHeightA, TouchHeightB
  7.   jsr :+
  8.   clc ; no collision
  9.   rts
  10. : lda TouchLeftB
  11.   add TouchWidthB
  12.   sta TouchRight
  13.   lda TouchTopB
  14.   add TouchHeightB
  15.   sta TouchBottom
  16.  
  17.   lda TouchLeftA
  18.   cmp TouchLeftB
  19.   bcc :+
  20.  
  21.   lda TouchLeftA
  22.   cmp TouchRight
  23.   bcs :+
  24.  
  25.   lda TouchTopA
  26.   cmp TouchTopB
  27.   bcc :+
  28.  
  29.   lda TouchTopA
  30.   cmp TouchBottom
  31.   bcs :+
  32.   pla
  33.   pla
  34.   sec ; collision detected
  35. : rts
  36. .endproc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement