예제 #1
0
        public static void Init()
        {
            for (int i = 0; i < Entries; i++)
            {
                cc[i] = new CC();
            }

            cc[0].value       = 0xffff;
            cc[0].args        = 0;
            cc[0].description = "Ends the text block";
            cc[0].tag         = "end";

            cc[1].value       = 0xff01;
            cc[1].args        = 0;
            cc[1].description = "Line break";
            cc[1].tag         = "break";

            cc[2].value       = 0xff02;
            cc[2].args        = 0;
            cc[2].description = "End choice selection";
            cc[2].tag         = "endchoices";

            cc[3].value       = 0xff03;
            cc[3].args        = 1;
            cc[3].description = "Wait for player; XXXX is always 0xFF00";
            cc[3].tag         = "wait";

            cc[4].value       = 0xff04;
            cc[4].args        = 1;
            cc[4].description = "Pause for XXXX frames";
            cc[4].tag         = "pause";

            cc[5].value       = 0xff05;
            cc[5].args        = 1;
            cc[5].description = "Change text color; for XXXX, 0=normal, 3=blue";
            cc[5].tag         = "color";

            cc[6].value       = 0xff06;
            cc[6].args        = 1;
            cc[6].description = "Begin choice menu of XXXX choices";
            cc[6].tag         = "menu";

            cc[7].value       = 0xff07;
            cc[7].args        = 0;
            cc[7].description = "Event";
            cc[7].tag         = "event";

            cc[8].value       = 0xff08;
            cc[8].args        = 1;
            cc[8].description = "Play sound XX";
            cc[8].tag         = "sound";

            cc[9].value       = 0xff0b;
            cc[9].args        = 0;
            cc[9].description = "Alternate font between normal and Mr. Saturn";
            cc[9].tag         = "alternatefont";

            cc[10].value       = 0xff0c;
            cc[10].args        = 1;
            cc[10].description = "Unknown";

            cc[11].value       = 0xff21;
            cc[11].args        = 1;
            cc[11].description = "Display name of item XXXX";
            cc[11].tag         = "item";

            cc[12].value       = 0xff22;
            cc[12].args        = 1;
            cc[12].description = "Display character name XXXX";

            cc[13].value       = 0xff23;
            cc[13].args        = 1;
            cc[13].description = "Display character name XXXX";

            cc[14].value       = 0xff24;
            cc[14].args        = 1;
            cc[14].description = "Enemy name";
            cc[14].tag         = "enemyname";

            cc[15].value       = 0xff25;
            cc[15].args        = 1;
            cc[15].description = "Unknown";

            cc[16].value       = 0xff26;
            cc[16].args        = 2;
            cc[16].description = "Display character name XXXX with YYYY amount of succeeding dashes";
            cc[16].tag         = "ー";

            cc[17].value       = 0xff42;
            cc[17].args        = 1;
            cc[17].description = "Unknown";

            cc[18].value       = 0xff45;
            cc[18].args        = 0;
            cc[18].description = "Favorite Food";
            cc[18].tag         = "favfood";

            cc[19].value       = 0xff46;
            cc[19].args        = 0;
            cc[19].description = "Favorite Thing";
            cc[19].tag         = "favthing";

            cc[20].value       = 0xff47;
            cc[20].args        = 0;
            cc[20].description = "Player name";
            cc[20].tag         = "playername";

            cc[21].value       = 0xff48;
            cc[21].args        = 0;
            cc[21].description = "Factory name";
            cc[21].tag         = "factoryname";

            cc[22].value       = 0xff80;
            cc[22].args        = 1;
            cc[22].description = "Unknown";

            cc[23].value       = 0xff81;
            cc[23].args        = 0;// 1
            cc[23].description = "Unknown";

            cc[24].value       = 0xff0a;
            cc[24].args        = 0;
            cc[24].description = "Center (H)";
            cc[24].tag         = "center";

            cc[25].value       = 0xff09;
            cc[25].args        = 0;
            cc[25].description = "Center (H + V)";

            cc[26].value       = 0xff83;
            cc[26].args        = 0;
            cc[26].description = "Unknown";

            cc[27].value       = 0xff82;
            cc[27].args        = 0;
            cc[27].description = "Amount";

            cc[28].value       = 0xff84;
            cc[28].args        = 0;
            cc[28].description = "Unknown";

            cc[29].value       = 0xffe1;
            cc[29].args        = 1;
            cc[29].description = "Display XXXX status icon";
            cc[29].tag         = "icon";

            cc[30].value       = 0xffa0;
            cc[30].args        = 0;
            cc[30].description = "Unknown";

            cc[31].value       = 0xffa1;
            cc[31].args        = 0;
            cc[31].description = "Unknown";

            cc[32].value       = 0xffa2;
            cc[32].args        = 0;
            cc[32].description = "Unknown";

            cc[33].value       = 0xffa3;
            cc[33].args        = 0;
            cc[33].description = "Unknown";

            cc[34].value       = 0xff44;
            cc[34].args        = 0;
            cc[34].description = "Unknown";

            CCLookup.Clear();
            for (int i = 0; i < Entries; i++)
            {
                CCLookup.Add(cc[i].value, cc[i]);
            }
        }
예제 #2
0
        public static string GetText(int offset, int length, TextType texttype, bool ignorecc)
        {
            string ret = string.Empty;

            switch (texttype)
            {
            case TextType.Japanese:
                List <byte> stringBytes = new List <byte>();

                for (int i = 0; i < length; i++)
                {
                    ushort ch = Rom.ReadUShort(offset);

                    if (ch == 0xFFFF)
                    {
                        if (!ignorecc)
                        {
                            stringBytes.AppendString("[FFFF]");
                        }
                        break;
                    }

                    offset += 2;

                    if (ch >= 0xEF00)
                    {
                        if (!ignorecc)
                        {
                            stringBytes.AppendString("[" + ch.ToString("X4"));
                            if (ch == 0xff22)
                            {
                            }
                            if (M3CC.CCLookup.ContainsKey(ch))
                            {
                                CC c = M3CC.CCLookup[ch];
                                for (int j = 0; j < c.args; j++)
                                {
                                    stringBytes.AppendString(" " + Rom.ReadUShort(offset).ToString("X4"));
                                    offset += 2;
                                }
                            }
                            stringBytes.AppendString("]");
                        }

                        if ((ch == 0xFF01) || (ch == 0xFF32) || (ch == 0xFF03))
                        {
                            // Newline
                            stringBytes.AppendString(Environment.NewLine);
                        }

                        continue;
                    }

                    ch = (ushort)(ch % JapaneseMap.Length);
                    ushort code = JapaneseMap[ch];
                    stringBytes.Add((byte)((code >> 8) & 0xFF));
                    stringBytes.Add((byte)(code & 0xFF));
                }

                byte[] converted = Encoding.Convert(SJIS, Unicode, stringBytes.ToArray());
                ret = Unicode.GetString(converted);
                break;

            case TextType.EnglishWide:
                for (int i = 0; i < length; i++)
                {
                    ushort ch = Rom.ReadUShort(offset);

                    if (ch == 0xFFFF)
                    {
                        break;
                    }

                    offset += 2;

                    if (ch >= 0xEF00)
                    {
                        if (ignorecc)
                        {
                            if ((ch == 0xFF01) || (ch == 0xFF32) || (ch == 0xFF03))
                            {
                                // Newline
                                ret += Environment.NewLine;
                            }
                        }

                        else
                        {
                            ret += "[" + ch.ToString("X4") + "]";
                        }

                        continue;
                    }

                    ch  &= 0xFF;
                    ret += EnglishMap[ch];
                }
                break;

            case TextType.EnglishShort:
            case TextType.EnglishShortRaw:

                bool obfuscated = texttype == TextType.EnglishShort;

                for (int i = 0; i < length; i++)
                {
                    byte ch = Rom.DecodeByte(offset, obfuscated);

                    // Check for control codes
                    if (ch == 0xEF)
                    {
                        // EF is a custom control code
                        ret += "[EF";
                        ret += Rom.DecodeByte(offset + 1, obfuscated).ToString("X2") + "]";
                        offset++;
                    }

                    else if (ch >= 0xF0)
                    {
                        // Special case: 0xFF = end
                        if (ch == 0xFF)
                        {
                            ret += "[FFFF]";
                            break;
                        }

                        // Else: get the cc length
                        int cclen = ch & 0xF;

                        // Get the control byte
                        byte ccbyte    = Rom.DecodeByte(offset + 1, obfuscated);
                        bool doNewLine = ((ccbyte == 0x01) || (ccbyte == 0x32) || (ccbyte == 0x03));

                        // Print the result
                        ret += "[FF" + ccbyte.ToString("X2");

                        // Get the arguments
                        ushort[] args = new ushort[cclen];
                        for (int j = 0; j < cclen; j++)
                        {
                            ret += " " + Rom.DecodeUShort(offset + 2 + (j << 1), obfuscated).ToString("X4");
                        }

                        ret += "]";

                        if (doNewLine)
                        {
                            ret += Environment.NewLine;
                        }

                        offset += 1 + (cclen << 1);
                    }

                    else
                    {
                        ret += EnglishMap[ch];
                    }

                    offset++;
                }
                break;
            }

            return(ret);
        }