Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import sys
- import os
- import zipfile
- BTN_A = 0x01
- BTN_B = 0x02
- BTN_SELECT = 0x04
- BTN_START = 0x08
- BTN_RIGHT = 0x10
- BTN_LEFT = 0x20
- BTN_UP = 0x40
- BTN_DOWN = 0x80
- BTN_POWER = 0xFF
- MAPPING = (
- BTN_UP,
- BTN_DOWN,
- BTN_LEFT,
- BTN_RIGHT,
- BTN_START,
- BTN_SELECT,
- BTN_B,
- BTN_A,
- BTN_POWER,
- )
- def decode_input(line):
- bits = 0
- for c, bit in zip(line, MAPPING):
- if c != ".":
- bits |= bit
- return bits
- bk2 = zipfile.ZipFile(os.path.abspath(sys.argv[1]))
- lines = [line.decode() for line in bk2.open('Input Log.txt')]
- data = [
- decode_input(line[1:-1])
- for line in lines
- if line.startswith("|")
- ]
- with open("bgb.dem", "wb") as f:
- f.write(bytes(data))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement