def getScript(self, japanese = False): data = self.data dataSize = len(data) script = [] i = 0 while i < dataSize: c = data[i] i += 1 if c == '\x11': # End of script break elif c == '\x00': # WAIT <arg> if i >= dataSize - 1: raise IndexError, "Spurious WAIT command in tutorial data" arg = struct.unpack_from("<H", data, i) i += 2 script.append(u"{WAIT %d}" % arg) elif c == '\x10': # Text string end = data.index('\xff', i) script.append(ff7text.decodeKernel(data[i:end], japanese)) i = end + 1 elif c == '\x12': # WINDOW <x> <y> if i >= dataSize - 3: raise IndexError, "Spurious WINDOW command in tutorial data" x, y = struct.unpack_from("<HH", data, i) i += 4 script.append(u"{WINDOW %d %d}" % (x, y)) else: # Other opcode if c in opcodes: script.append(opcodes[c]) else: raise IndexError, "Illegal opcode %02x in tutorial data" % ord(c) return script
def __init__(self, data = None, numStrings = 0, japanese = False): self.stringList = [] self.japanese = japanese # Parse the offset table offsets = [] for i in xrange(numStrings): offsets.append(struct.unpack_from("<H", data, i*2)[0]) # Extract the strings for offset in offsets: rawString, endOfString = self._extract(data, offset, len(data)) assert endOfString self.stringList.append(ff7text.decodeKernel(rawString, japanese))
def decodeKernelText(data, japanese=False): return ff7text.decodeKernel(data, japanese)
def decodeKernelText(data, japanese = False): return ff7text.decodeKernel(data, japanese)