Advertisement
MrCheeze

Untitled

Aug 17th, 2014
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. f = open("Red.gb", "rb")
  2. f2 = open("Input Log", "w")
  3.  
  4. f2.write("LogKey:#Up|Down|Left|Right|Start|Select|B|A|Power|\n")
  5. byte = f.read(1)
  6. while byte:
  7.     byte = int.from_bytes(byte, byteorder="big")
  8.     s = "|"
  9.     if byte & 0x80:
  10.         s += "U"
  11.     else:
  12.         s += "."
  13.     if byte & 0x40:
  14.         s += "D"
  15.     else:
  16.         s += "."
  17.     if byte & 0x20:
  18.         s += "L"
  19.     else:
  20.         s += "."
  21.     if byte & 0x10:
  22.         s += "R"
  23.     else:
  24.         s += "."
  25.     if byte & 0x08:
  26.         s += "S"
  27.     else:
  28.         s += "."
  29.     if byte & 0x04:
  30.         s += "s"
  31.     else:
  32.         s += "."
  33.     if byte & 0x02:
  34.         s += "B"
  35.     else:
  36.         s += "."
  37.     if byte & 0x01:
  38.         s += "A"
  39.     else:
  40.         s += "."
  41.     s += ".|\n"
  42.  
  43.     f2.write(s) #repeat this multiple times to hold buttons for more than one frame
  44.  
  45.     byte = f.read(1)
  46. f2.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement