-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
44 lines (32 loc) · 921 Bytes
/
main.py
File metadata and controls
44 lines (32 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import struct
from .commands import DLCmd
fb = []
def readFile(binfile):
global fb
with open(binfile, "rb") as f:
fb = f.read()
def readStruct(fmt, offset):
global fb
return struct.unpack_from(fmt, fb, offset)
class Command:
def __init__(self, type, arg1, arg2, vec):
self.type = type
self.arg1 = arg1
self.arg2 = arg2
self.vec = vec
def __str__(self):
return f"cmd {self.type}: ({self.arg1}, {self.arg2}) {self.vec}"
def readCMD(offset):
global fb
argvals = struct.unpack_from(">LLLfff", fb, offset)
return Command(
argvals[0], argvals[1], argvals[2], [argvals[3], argvals[4], argvals[5]]
)
def readDL(offset):
print("Reading DL...")
cmdList = [readCMD(offset)]
offset += 24
while cmdList[-1].type != DLCmd.EndList:
cmdList.append(readCMD(offset))
offset += 24
return cmdList