-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmake-info.py
More file actions
95 lines (69 loc) · 1.94 KB
/
make-info.py
File metadata and controls
95 lines (69 loc) · 1.94 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import struct
def errmsg(ad, ad_max):
i = 0
while ad < ad_max:
c = ord(f.read(1))
mot = ''
while c < 0x80:
if c < 27:
mot = mot + commun[c]
else:
mot = mot + chr(c)
ad = ad + 1
c = ord(f.read(1))
c = c & 0x7f
if c < 27:
mot = mot + commun[c]
else:
mot = mot + chr(c)
ad = ad + 1
print i, mot
i = i + 1
return ad
ad = 0xdfb9
with open('original/hyperbas.rom', 'rb') as f:
debut = f.read(ad - 0xc000)
while True:
lfa = struct.unpack('<H', f.read(2))[0]
f.read(4)
nfa_len = ord(f.read(1)) - 7
nfa = f.read(nfa_len)
nfa = nfa.replace('"', '\\"')
if nfa == chr(0):
nfa = 'null'
print ''
print 'range { start $%04x; end $%04x; type addrtable; name "%s_lfa"; };' % (ad, ad + 1, nfa)
ad = ad + 2
print 'range { start $%04x; end $%04x; type bytetable; name "%s_pfa"; };' % (ad, ad + 4, nfa)
ad = ad + 5
print 'range { start $%04x; end $%04x; type texttable; name "%s"; };' % (ad, ad + nfa_len - 1, nfa)
ad = ad + nfa_len
print 'range { start $%04x; end $%04x; type bytetable; };' % (ad, ad + 1)
if lfa > ad:
ad = lfa
f.seek(ad - 0xc000, 0)
else:
break
ad = 0xd5e0
f.seek(ad - 0xc000, 0)
commun = []
i = 0
while ad < 0xd697:
c = ord(f.read(1))
mot = ''
while c < 0x80:
mot = mot + chr(c)
ad = ad + 1
c = ord(f.read(1))
mot = mot + chr(c & 0x7f)
ad = ad + 1
commun.append(mot)
print "\nTable 1:\n"
ad = errmsg(ad, 0xd771)
print "\nTable 2:\n"
ad = errmsg(ad, 0xd7d7)
print "\nTable 3:\n"
ad = errmsg(ad, 0xd831)
print "\nTable 4:\n"
ad = errmsg(ad, 0xd8a0)
f.close()