User:2 B/Debatably useful stuff: Difference between revisions

no edit summary
(I hadn't realized the wiki had an icon for the Drake. Added that.)
No edit summary
Line 45: Line 45:
     while i < len(text):
     while i < len(text):
         if text[i] == '\x0e':
         if text[i] == '\x0e':
             if text[i : i + 3] == '\x0e\x00\x00':
             i += 1
                assert(ord(text[i+3]) == ord(text[i+5]) + 4)
            tag = text[i:i+2]
                furigana_count = ord(text[i+3]) // 2 - 2
            extra_size = ord(text[i+2]) // 2
                kanji_count = ord(text[i+4]) // 2
            i += 3
                kanji = text[i + 6 + furigana_count : i + 6 + furigana_count + kanji_count]
            if tag == '\x00\x00':
                 if include_ruby:
                 if include_ruby:
                     furigana = text[i + 6 : i + 6 + furigana_count]
                    kanji_count = ord(text[i]) // 2
                    furigana_count = ord(text[i+1]) // 2
                     furigana = text[i+2 : i+2 + furigana_count]
                    kanji = text[i+2 + furigana_count : i+2 + furigana_count + kanji_count]
                     out += f"<ruby>{kanji}<rt>{furigana}</rt></ruby>"
                     out += f"<ruby>{kanji}<rt>{furigana}</rt></ruby>"
                else:
                     i += kanji_count
                     out += kanji
                 i += extra_size
                 i += 6 + furigana_count + kanji_count
                 continue
                 continue


             if text[i:i+4] == "\x0e\x00\x02\x02":
             if tag == '\x00\x02':
                 if include_textsize:
                 if include_textsize:
                     out += f"[text size: {hex(ord(text[i+4]))}]"
                     out += f"[text size: {hex(ord(text[i]))}]"
                 i += 5
                 i += extra_size
                 continue
                 continue


             if text[i:i+4] == "\x0e\x00\x03\x02":
             if tag == '\x00\x03':
                 if text[i+4] == '\uffff':
                 if text[i] == '\uffff':
                     # out += "[white]"
                     # out += "[white]"
                     if color:
                     if color:
                         out += f"}}}}"
                         out += f"}}}}"
                     color = False
                     color = False
                 elif ord(text[i+4]) in colors:
                 elif ord(text[i]) in colors:
                     # out += "[orange]"
                     # out += "[orange]"
                     if color:
                     if color:
                         out += f"}}}}"
                         out += f"}}}}"
                     out += f"{{{{color|2={colors[ord(text[i+4])]}|"
                     out += f"{{{{color|2={colors[ord(text[i])]}|"
                     color = True
                     color = True
                 else:
                 else:
                     out += f"[unknown color: {hex(ord(text[i+4]))}]"
                     out += f"[unknown color: {hex(ord(text[i]))}]"
                 i += 5
                 i += extra_size
                 continue
                 continue


             if text[i : i + 4] == '\x0e\x00\x04\x00':
             if tag == '\x00\x04':
                 out += textbox_separator
                 out += textbox_separator
                 i += 4
                 i += extra_size
                 continue
                 continue


             if text[i : i + 4] == '\x0e\x07\x01\x02':
             if tag[0] == '\x01':
                 detail = ord(text[i + 4])
                name_len = ord(text[i]) // 2
                var_name = text[i+1 : i+1 + name_len]
                assert(text[i+1 + name_len : i+1 + name_len + 2] == "\u0100\u0000")
                if include_variables:
                    out += f"[variable: {hex(ord(text[i-2]))} \"{var_name}\"]"
                else:
                    out += "_"
                i += extra_size
                continue
 
            if tag == '\x07\x01':
                 detail = ord(text[i])
                 assert(detail & 0x00FF == 0xcd)
                 assert(detail & 0x00FF == 0xcd)
                 button_id = (detail & 0xFF00) >> 8
                 button_id = (detail & 0xFF00) >> 8
                 out += f"[button: {buttons[button_id] if button_id < len(buttons) else hex(button_id)}]"
                 out += f"[button: {buttons[button_id] if button_id < len(buttons) else hex(button_id)}]"
                 i += 5
                 i += extra_size
                 continue
                 continue


             if text[i : i + 2] == "\x0e\x01":
             if tag == '\x15\x00':
                if include_variables:
                    out += f"[variable: {hex(ord(text[i+2]))}, {hex(ord(text[i+3]))}, {hex(ord(text[i+4]))}, \""
                i += 5
                while text[i] != "\u0100":
                    if include_variables:
                        out += text[i]
                    i += 1
                if include_variables:
                    out += f"\"]"
                else:
                    out += "_"
                i += 2
                continue
 
            if text[i : i + 4] == '\x0e\x15\x00\x02':
                 if include_sound:
                 if include_sound:
                     detail = ord(text[i + 4])
                     detail = ord(text[i])
                     high = (detail & 0xFF00) >> 8
                     high = detail >> 8
                     low = detail & 0x00FF
                     low = detail & 0x00FF
                     character = characters[high]
                     character = characters[high]
                     out += f"[{character} thinking sound]"
                     out += f"[{character} thinking sound]"
 
                 i += extra_size
                 i += 5
                 continue
                 continue


             if text[i : i + 4] == '\x0e\x15\x01\x02':
             if tag == '\x15\x01':
                 if include_lookat:
                 if include_lookat:
                     detail = ord(text[i + 4])
                     detail = ord(text[i])
                     high = (detail & 0xFF00) >> 8
                     character_name = characters[detail >> 8]
                    low = detail & 0x00FF
                     target = characters[detail & 0x00FF]
                    character_name = characters[high]
                     target = characters[low-1]
                     out += f"[look at: {character_name} -> {target}]"
                     out += f"[look at: {character_name} -> {target}]"
 
                 i += extra_size
                 i += 5
                continue
           
            if text[i : i + 4] == '\x0e\x17\x03\x00':
                if include_autoadvance:
                    out += f"[advance automatically]"
                i += 4
                 continue
                 continue


             if text[i : i + 4] == '\x0e\x17\x01\x02':
             if tag == '\x17\x01':
                 if include_pauses:
                 if include_pauses:
                    detail = ord(text[i + 4])
                     out += f"[pause: {ord(text[i])}]"
                     out += f"[pause: {detail}]"
                 i += extra_size
                 i += 5
                 continue
                 continue


             if text[i : i + 4] == '\x0e\x17\x02\x02':
             if tag == '\x17\x02':
                 icon = ord(text[i + 4])
                 detail = ord(text[i])
                 high = (icon & 0xFF00) >> 8
                 high = detail >> 8
                 low = icon & 0x00FF
                 low = detail & 0x00FF
 
                 if low == 0x19:
                 if low == 0x19:
                     character_name = characters[high]   
                     character_name = characters[high]   
Line 165: Line 151:
                         out += f"(speaker mismatch, should be {characters[high]}) "
                         out += f"(speaker mismatch, should be {characters[high]}) "


                 i += 5
                 i += extra_size
                continue
           
            if tag == '\x17\x03':
                if include_autoadvance:
                    out += f"[advance automatically]"
                i += extra_size
                 continue
                 continue


             if text[i : i + 3] == '\x0e\x17\x04':
             if tag == '\x17\x04':
                 assert(ord(text[i+3]) == ord(text[i+4]) + 4)
                 name_len = ord(text[i]) // 2
                 if include_sound:
                 sound_name = text[i+1 : i+1 + name_len]
                    out += f"[sound: {(ord(text[i+4]))}, \""
                i += 5
                while ord(text[i]) & 0x00FF != 0xcd:
                    if include_sound:
                        out += text[i]
                    i += 1
                 if include_sound:
                 if include_sound:
                     out += "\"]"
                     out += f"[sound: \"{sound_name}\", {ord(text[i+1 + name_len]) >> 8}]"
                 i += 1
                 i += extra_size
                 continue
                 continue
              
              
             out += f"[0xe{hex(ord(text[i+1]))}{hex(ord(text[i+2]))}{hex(ord(text[i+3]))}]"
             out += f"[unknown tag: {ord(tag[0])}, {ord(tag[1])}: \"{text[i:i+extra_size]}\"]"
             i += 4
             i += extra_size
             continue
             continue