hacktools 0.34.0__tar.gz → 0.35.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hacktools-0.34.0/hacktools.egg-info → hacktools-0.35.0}/PKG-INFO +1 -1
- hacktools-0.35.0/hacktools/__init__.py +1 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools/c_ext/cmp_racjin.c +1 -1
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools/common.py +13 -3
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools/nds.py +10 -4
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools/psp.py +2 -2
- {hacktools-0.34.0 → hacktools-0.35.0/hacktools.egg-info}/PKG-INFO +1 -1
- hacktools-0.34.0/hacktools/__init__.py +0 -1
- {hacktools-0.34.0 → hacktools-0.35.0}/LICENSE +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/MANIFEST.in +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/README.md +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools/arch.py +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools/assets/icon.png +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools/c_ext/cmp_cri.c +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools/c_ext/cmp_lzss.c +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools/c_ext/cmp_misc.c +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools/c_ext/inc.h +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools/compression.py +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools/cpk.py +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools/gb.py +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools/gui.py +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools/nasm.py +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools/nitro.py +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools/psx.py +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools/wii.py +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools/ws.py +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools.egg-info/SOURCES.txt +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools.egg-info/dependency_links.txt +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools.egg-info/requires.txt +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/hacktools.egg-info/top_level.txt +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/setup.cfg +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/setup.py +0 -0
- {hacktools-0.34.0 → hacktools-0.35.0}/tests/test_cmp.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.35.0"
|
|
@@ -11,7 +11,7 @@ static PyObject* compressRACJIN(PyObject* module, PyObject* args, PyObject* kwar
|
|
|
11
11
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#", kwlist, &src, &srclen))
|
|
12
12
|
return NULL;
|
|
13
13
|
|
|
14
|
-
unsigned char* compressed_buffer = PyMem_Malloc(srclen);
|
|
14
|
+
unsigned char* compressed_buffer = PyMem_Malloc(srclen * 2);
|
|
15
15
|
MALLOC_CHECK(compressed_buffer);
|
|
16
16
|
unsigned int destlen = 0;
|
|
17
17
|
|
|
@@ -756,7 +756,7 @@ class TranslationFile:
|
|
|
756
756
|
note = ET.SubElement(unit, "note")
|
|
757
757
|
note.text = comment
|
|
758
758
|
|
|
759
|
-
def preloadLookup(self):
|
|
759
|
+
def preloadLookup(self, comments="#"):
|
|
760
760
|
self.lookup = {}
|
|
761
761
|
self.chartot = 0
|
|
762
762
|
self.transtot = 0
|
|
@@ -764,6 +764,8 @@ class TranslationFile:
|
|
|
764
764
|
for unit in self.files[file][0]:
|
|
765
765
|
self.chartot += len(unit[0].text)
|
|
766
766
|
if unit[1].text is not None and unit[1].text != "":
|
|
767
|
+
if comments in unit[1].text:
|
|
768
|
+
unit[1].text = unit[1].text.split(comments)[0]
|
|
767
769
|
self.lookup[unit[0].text] = unit[1].text
|
|
768
770
|
self.transtot += len(unit[0].text)
|
|
769
771
|
|
|
@@ -1030,7 +1032,7 @@ class BinaryPointer:
|
|
|
1030
1032
|
self.str = str
|
|
1031
1033
|
|
|
1032
1034
|
|
|
1033
|
-
def repackBinaryStrings(section, infile, outfile, binranges, freeranges=None, readfunc=detectEncodedString, writefunc=writeEncodedString, encoding="shift_jis", pointerstart=0, injectstart=0, fallbackf=None, injectfallback=0, sectionname="bin"):
|
|
1035
|
+
def repackBinaryStrings(section, infile, outfile, binranges, freeranges=None, readfunc=detectEncodedString, writefunc=writeEncodedString, encoding="shift_jis", pointerstart=0, injectstart=0, fallbackf=None, injectfallback=0, sectionname="bin", preformat=None, postformat=None):
|
|
1034
1036
|
insize = os.path.getsize(infile)
|
|
1035
1037
|
notfound = []
|
|
1036
1038
|
with Stream(infile, "rb") as fi:
|
|
@@ -1045,6 +1047,9 @@ def repackBinaryStrings(section, infile, outfile, binranges, freeranges=None, re
|
|
|
1045
1047
|
pos = fi.tell()
|
|
1046
1048
|
check = readfunc(fi, encoding)
|
|
1047
1049
|
if check != "":
|
|
1050
|
+
pre = post = ""
|
|
1051
|
+
if preformat != None:
|
|
1052
|
+
check, pre, post = preformat(check)
|
|
1048
1053
|
if isinstance(section, TranslationFile):
|
|
1049
1054
|
newsjis = section.getEntry(check, sectionname, pos)
|
|
1050
1055
|
else:
|
|
@@ -1055,6 +1060,8 @@ def repackBinaryStrings(section, infile, outfile, binranges, freeranges=None, re
|
|
|
1055
1060
|
if newsjis != "":
|
|
1056
1061
|
if newsjis == "!":
|
|
1057
1062
|
newsjis = ""
|
|
1063
|
+
if postformat != None:
|
|
1064
|
+
newsjis = postformat(newsjis, pre, post)
|
|
1058
1065
|
newsjislog = newsjis.encode("ascii", "ignore")
|
|
1059
1066
|
logDebug("Replacing string at", toHex(pos), "with", newsjislog)
|
|
1060
1067
|
fo.seek(pos)
|
|
@@ -1104,7 +1111,10 @@ def repackBinaryStrings(section, infile, outfile, binranges, freeranges=None, re
|
|
|
1104
1111
|
newpointer = range[0]
|
|
1105
1112
|
# For the injected range, add injectstart, otherwise add pointerstart
|
|
1106
1113
|
if (len(range) == 3):
|
|
1107
|
-
|
|
1114
|
+
if isinstance(range[2], bool):
|
|
1115
|
+
newpointer += injectstart
|
|
1116
|
+
else:
|
|
1117
|
+
newpointer += int(range[2])
|
|
1108
1118
|
else:
|
|
1109
1119
|
newpointer += pointerstart
|
|
1110
1120
|
range[0] = fo.tell()
|
|
@@ -134,7 +134,7 @@ def extractBIN(binrange, readfunc=common.detectEncodedString, encoding="shift_ji
|
|
|
134
134
|
|
|
135
135
|
|
|
136
136
|
def repackBIN(binrange, freeranges=[], readfunc=common.detectEncodedString, writefunc=common.writeEncodedString, encoding="shift_jis", comments="#",
|
|
137
|
-
binin="data/extract/arm9.bin", binout="data/repack/arm9.bin", binfile="data/bin_input.txt", fixchars=[], pointerstart=0x02000000, injectstart=0x02000000, fallbackf=None, injectfallback=0, nocopy=False, sectionname="bin"):
|
|
137
|
+
binin="data/extract/arm9.bin", binout="data/repack/arm9.bin", binfile="data/bin_input.txt", fixchars=[], pointerstart=0x02000000, injectstart=0x02000000, fallbackf=None, injectfallback=0, nocopy=False, sectionname="bin", preformat=None, postformat=None):
|
|
138
138
|
if not os.path.isfile(binfile):
|
|
139
139
|
common.logError("Input file", binfile, "not found")
|
|
140
140
|
return False
|
|
@@ -152,7 +152,7 @@ def repackBIN(binrange, freeranges=[], readfunc=common.detectEncodedString, writ
|
|
|
152
152
|
section.preloadLookup()
|
|
153
153
|
if type(binrange) == tuple:
|
|
154
154
|
binrange = [binrange]
|
|
155
|
-
notfound = common.repackBinaryStrings(section, binin, binout, binrange, freeranges, readfunc, writefunc, encoding, pointerstart, injectstart, fallbackf, injectfallback, sectionname)
|
|
155
|
+
notfound = common.repackBinaryStrings(section, binin, binout, binrange, freeranges, readfunc, writefunc, encoding, pointerstart, injectstart, fallbackf, injectfallback, sectionname, preformat, postformat)
|
|
156
156
|
for pointer in notfound:
|
|
157
157
|
common.logError("Pointer", common.toHex(pointer.old), "->", common.toHex(pointer.new), "not found for string", pointer.str)
|
|
158
158
|
if binfile.endswith(".txt"):
|
|
@@ -176,13 +176,17 @@ class BINSection:
|
|
|
176
176
|
self.data = bytearray(ramlen)
|
|
177
177
|
|
|
178
178
|
|
|
179
|
-
def expandBIN(binin, binout, headerin, headerout,
|
|
179
|
+
def expandBIN(binin, binout, headerin, headerout, newlengths, injectpos):
|
|
180
180
|
if not os.path.isfile(binin):
|
|
181
181
|
common.logError("Input file", binin, "not found")
|
|
182
182
|
return False
|
|
183
183
|
if not os.path.isfile(headerin):
|
|
184
184
|
common.logError("Header file", headerin, "not found")
|
|
185
185
|
return False
|
|
186
|
+
if not isinstance(newlengths, list):
|
|
187
|
+
newlengths = [newlengths]
|
|
188
|
+
if not isinstance(injectpos, list):
|
|
189
|
+
injectpos = [injectpos]
|
|
186
190
|
codesettings = -1
|
|
187
191
|
with common.Stream(headerin, "rb") as fin:
|
|
188
192
|
fin.seek(0x20)
|
|
@@ -225,13 +229,15 @@ def expandBIN(binin, binout, headerin, headerout, newlength, injectpos):
|
|
|
225
229
|
sections.append(BINSection(fin, start, size, datastart, bsssize))
|
|
226
230
|
datastart += size
|
|
227
231
|
# Write the new extended arm9.bin
|
|
228
|
-
|
|
232
|
+
for i in range(len(newlengths)):
|
|
233
|
+
sections.append(BINSection(None, injectpos[i], newlengths[i], 0, 0, True if i < len(newlengths) - 1 else False))
|
|
229
234
|
with common.Stream(binout, "wb") as f:
|
|
230
235
|
# Write the section data first
|
|
231
236
|
f.write(sections[0].data)
|
|
232
237
|
datastart = f.tell()
|
|
233
238
|
for i in range(1, len(sections)):
|
|
234
239
|
sections[i].offset = f.tell()
|
|
240
|
+
common.logDebug("Section", i, "offset:", common.toHex(f.tell()))
|
|
235
241
|
f.write(sections[i].data)
|
|
236
242
|
# Write the new copytable
|
|
237
243
|
copytablestart = f.tell()
|
|
@@ -31,7 +31,7 @@ def extractIso(isofile, extractfolder, workfolder="", fixfilename=False):
|
|
|
31
31
|
common.logMessage("Done!")
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
def repackIso(isofile, isopatch, workfolder, patchfile=""):
|
|
34
|
+
def repackIso(isofile, isopatch, workfolder, patchfile="", fixfilename=False):
|
|
35
35
|
try:
|
|
36
36
|
import pycdlib
|
|
37
37
|
except ImportError:
|
|
@@ -45,7 +45,7 @@ def repackIso(isofile, isopatch, workfolder, patchfile=""):
|
|
|
45
45
|
for file in common.showProgress(files):
|
|
46
46
|
filelen = os.path.getsize(workfolder + file)
|
|
47
47
|
with open(workfolder + file, "rb") as f:
|
|
48
|
-
iso.modify_file_in_place(f, filelen, "/" + file)
|
|
48
|
+
iso.modify_file_in_place(f, filelen, "/" + file + (";1" if fixfilename and not file.endswith(".") else ""))
|
|
49
49
|
iso.close()
|
|
50
50
|
common.logMessage("Done!")
|
|
51
51
|
# Create xdelta patch
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.34.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|