Advertisement
Guest User

debounce2.bas

a guest
Jun 11th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. dim rand16 = z
  2.  
  3. dim sw = d
  4. dim debounce = e
  5. dim jf = f
  6. dim cntr = g
  7. dim edge = h
  8. dim prev = i
  9.  
  10. gosub clear
  11.  
  12. COLUPF = $4A
  13. COLUBK = $42
  14.  
  15. debounce = $00
  16.  
  17. main
  18.  
  19. if cntr <> 32 then skip_fire
  20.  
  21. temp1 = ((jf ^ $80) | INPT4) & $80 : jf = INPT4
  22. if temp1 then goto draw
  23. gosub clear
  24. cntr = 0
  25.  
  26. skip_fire
  27. sw = 0
  28. if cntr & $08 then sw = sw - 1
  29. temp1 = (cntr ^ $04) & $04
  30. if temp1 then sw = rand
  31.  
  32. gosub debounce
  33.  
  34. rem edge detection
  35. edge = (prev ^ $FF) & debounce : prev = debounce
  36.  
  37. if cntr & $08 then pfpixel cntr 0 on
  38. if sw & 1 then pfpixel cntr 1 on
  39. if debounce & 1 then pfpixel cntr 2 on
  40. if edge & 1 then pfpixel cntr 3 on
  41.  
  42. if b & 1 then pfpixel cntr 5 on
  43. if a & 1 then pfpixel cntr 6 on
  44.  
  45. cntr = cntr + 1
  46.  
  47. draw
  48. drawscreen
  49. goto main
  50.  
  51.  
  52.  
  53.  
  54. debounce
  55. temp1 = sw ^ debounce
  56.  
  57. rem increment counter or reset to 11
  58. b = (b ^ a) | temp1
  59. a = (a ^ $FF) | temp1
  60.  
  61. rem if the counter has counted to 11
  62. rem and 11 is not due to reset toggle debounce
  63. debounce = (((temp1 ^ $FF) & b) & a) ^ debounce
  64. return
  65.  
  66.  
  67. clear
  68. playfield:
  69. ................................
  70. ................................
  71. ................................
  72. ................................
  73. ................................
  74. ................................
  75. ................................
  76. ................................
  77. ................................
  78. ................................
  79. ................................
  80. ................................
  81. end
  82. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement