Advertisement
wolfboyft

Help!

Jul 27th, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. WaitForInput::
  2.     call WaitForAllButtonsToBeReleased
  3. .loop
  4.     call GetJoypad
  5.     ld a, [PressedJoypad]
  6.     and $FF
  7.     jr z, .loop
  8.     ret
  9.  
  10. WaitForAllButtonsToBeReleased::
  11.     call GetJoypad
  12.     ld a, [DownJoypad]
  13.     and a
  14.     jr nz, WaitForAllButtonsToBeReleased
  15.     ret
  16.  
  17. ; also relevant
  18. LoopGameChoice_Inner::
  19.     call WaitForInput
  20.     and JOY_SELECT
  21.     jr nz, Change
  22.     and JOY_START
  23.     jr z, LoopGameChoice_Inner
  24.     ; do what you had selected
  25.  
  26. GetJoypad::
  27.     ld a, %00100000
  28.     ld [rP1], a
  29.     ld a, [rP1]
  30.     ld a, [rP1]
  31.     ld a, [rP1]
  32.     ld a, [rP1]
  33.     and $0F
  34.     swap a
  35.     ld b, a
  36.     ld a, %00010000
  37.     ld [rP1], a
  38.     ld a, [rP1]
  39.     ld a, [rP1]
  40.     ld a, [rP1]
  41.     ld a, [rP1]
  42.     and $0F
  43.     or b
  44.     cpl
  45.    
  46.     ld d, a
  47.    
  48.     ld b, a
  49.     ld a, [DownJoypad]
  50.     cpl
  51.     and b
  52.     ld [PressedJoypad], a
  53.    
  54.     ld hl, Flags
  55.     bit 0, [hl]
  56.     jr z, .skip
  57.    
  58.     ld a, [DownJoypad]
  59.     ld b, a
  60.     ld a, d
  61.     cpl
  62.     and b
  63.     ld a, b
  64.     ld [ReleasedJoypad], a
  65.     ld a, d
  66.     ld [DownJoypad], a
  67.     ret
  68.  
  69. .skip
  70.     set 0, [hl]
  71.     ld a, $FF
  72.     ld [ReleasedJoypad], a
  73.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement