uint16 num = read16() uint16 seed = read16() uint32 offsets[num] uint32 sizes[num] uint16 binarystrings[num][$size] string texts[num] /* generate offsets and sizes */ for i from 1 to num $key = ((seed*i*0x2FD)&0xFFFF) | ((seed*i*0x2FD0000)&0xFFFF0000) offsets[i] = read32() ^ $key sizes[i] = read32() ^ $key for i from 1 to num /* temporary references */ $offset = offsets[i] $size = sizes[i] $string = binarystrings[i] $key = (0x91BD3*i)&0xFFFF $text = texts[i] seek($offset) /* decrypt strings */ for j from 1 to $size $string[j] = read16() ^ $key $key = ($key+0x493D)&0xFFFF if $string[1] is 0xF100 /* decompress string: characters are stored in 9 bits instead of 16 */ $newstring = [0] $string.pop() $container = 0 $bit = 0 while $string $container |= $string.pop() << $bit while $bit >= 9 $bit -= 9 $newstring.append($container&0x1FF) $container >>= 9 $string = $newstring $size = $newstring.size $text = "" while $string int16 $char = $string.pop() if $char is -1 break else if $char is -2 $count = $string.pop() $args = [0] for k from 1 $count $args.append($string.pop()) /* TEXT_VARIABLE is a function to come up with the value based on $args */ $text += TEXT_VARIABLE($args) else /* SYMBOLS is a list of symbols that each character corresponds to */ $text += SYMBOLS[$char]