Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. HandleUSBEvents:
  2.     ld a, (ModelID)
  3.     cp 2
  4.     jp nc, ResumeInterrupt ; Leave if we don't have the hardware
  5.     in a, (55h) ; Read USB status
  6.     bit 0, a
  7.     jr z, UnknownUSBEvent
  8.     bit 2, a
  9.     jr z, USBLineInterrupt
  10.     bit 4, a
  11.     jp z, USBProtocolInterrupt
  12.     jp ResumeInterrupt
  13.  
  14. UnknownUSBEvent:
  15.     halt
  16.     xor a
  17.     out (5Bh), a ; Unknown event, WikiTI claims you should zero port 5B to acknowledge
  18.     jp ResumeInterrupt
  19.  
  20. USBLineInterrupt:
  21.     in a, (56h)
  22.     ld c, a
  23.     xor 0FFh
  24.     ld b, a
  25.     in a, (57h)
  26.     ld c, a
  27.     and b
  28.     out (57h), a
  29.     ld a, c
  30.     out (57h), a    ; Ack the interrupt without doing anything special
  31.     jp ResumeInterrupt
  32.  
  33. USBProtocolInterrupt:
  34.     in a, (86h)
  35.     ld c, a
  36.     in a, (84h)
  37.     ld b, a
  38.     in a, (82h) ; Just ack and leave, and hope that it doesn't get angry
  39.     jp ResumeInterrupt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement