def __init__(self, machine, offset, id): self.offset = offset self.machine = machine self.id = id if machine.header.version < 4: self.attr = (machine.readByte(offset) << 24) | ( machine.readByte(offset + 1) << 16) | ( machine.readByte(offset + 2) << 8) | ( machine.readByte(offset + 3)) #self.attr = [machine.readByte(offset),machine.readByte(offset+1),machine.readByte(offset+2),machine.readByte(offset+3)] self.parentId = machine.readByte(offset + 4) self.siblingId = machine.readByte(offset + 5) self.childId = machine.readByte(offset + 6) prop = machine.readWord(offset + 7) propHeaderLength = machine.readByte(prop + 0) l, self.propHeaderStr = zscii.decodeString(machine, prop + 1) ad = prop + 1 + l else: self.attr = (machine.readByte(offset) << 40) | ( machine.readByte(offset + 1) << 32) | ( machine.readByte(offset + 2) << 24) | ( machine.readByte(offset + 3) << 16) | ( machine.readByte(offset + 4) << 8) | ( machine.readByte(offset + 5)) #self.attr = [machine.readByte(offset),machine.readByte(offset+1),machine.readByte(offset+2),machine.readByte(offset+3),machine.readByte(offset+4),machine.readByte(offset+5)] self.parentId = machine.readWord(offset + 6) self.siblingId = machine.readWord(offset + 8) self.childId = machine.readWord(offset + 10) prop = machine.readWord(offset + 12) propHeaderLength = machine.readByte(prop + 0) l, self.propHeaderStr = zscii.decodeString(machine, prop + 1) ad = prop + 1 + l self.properties = {} self.propertyList = [] while True: prop = Property(machine, ad) if prop.end: break self.propertyList.append(prop.propId) self.properties[prop.propId] = prop ad += prop.totalLength continue pass
def call(self, machine): bytes, string = zscii.decodeString(machine, machine.pc) machine.printScreen(string) machine.pc += bytes machine.printDebug('Print', string) pass
def call(self, machine): bytes, string = zscii.decodeString(machine, machine.pc) machine.printScreen(string) machine.printScreen("\n") machine.pc += bytes machine.printDebug('PrintRet', string) machine.ret(ConstValue(1, 1)) pass
def call(self, machine): pAddress = self.argVals[0].load() address = machine.unpackAddressPrint(pAddress) bytes, string = zscii.decodeString(machine, address) machine.printDebug('PrintPaddr', self.argVals, address, string) machine.printScreen(string) pass
def init(machine): offset = machine.header.dict numSeparators = machine.readByte(offset) offset += 1 separators = [] for i in range(numSeparators): separators.append(machine.readByte(offset)) offset += 1 entryLength = machine.readByte(offset) offset += 1 numEntries = machine.readWord(offset) offset += 2 entries = [] for i in range(numEntries): len, str = zscii.decodeString(machine, offset) offset += entryLength entries.append(str) pass
def parse(machine, text): offset = machine.header.dict numSeparators = machine.readByte(offset) offset += 1 separators = [] for i in range(numSeparators): separators.append(machine.readByte(offset)) offset += 1 entryLength = machine.readByte(offset) offset += 1 numEntries = machine.readWord(offset) offset += 2 entries = [] for i in range(numEntries): length, str = zscii.decodeString(machine, offset) entries.append(DictionaryWord(offset, str)) offset += entryLength words = split(text, separators) parsedWords = [] for word in words: foundEntry = None for entry in entries: if entry.word == word.word: foundEntry = entry break if foundEntry is not None: parsedWords.append( DecodedWord(entry.address, len(word.word), word.offset)) else: parsedWords.append(DecodedWord(0, len(word.word), word.offset)) return parsedWords
def parse(machine, text): offset = machine.header.dict numSeparators = machine.readByte(offset) offset += 1 separators = [] for i in range(numSeparators): separators.append(machine.readByte(offset)) offset += 1 entryLength = machine.readByte(offset) offset += 1 numEntries = machine.readWord(offset) offset += 2 entries = [] for i in range(numEntries): length, str = zscii.decodeString(machine, offset) entries.append(DictionaryWord(offset, str)) offset += entryLength words = split(text, separators) parsedWords = [] for word in words: foundEntry = None for entry in entries: if entry.word == word.word: foundEntry = entry break if foundEntry is not None: parsedWords.append(DecodedWord(entry.address, len(word.word), word.offset)) else: parsedWords.append(DecodedWord(0, len(word.word), word.offset)) return parsedWords
def call(self, machine): address = self.argVals[0].load() length, string = zscii.decodeString(machine, address) machine.printDebug('PrintPaddr', self.argVals, address, string) machine.printScreen(string) pass