private static void AddString(int row, SpawnScript.Function func, string str, int maxLength)
        {
            if (str.Length < 2)
            {
                throw new SpawnScriptParserException(row, $"Expected a string but got '{str}'");
            }
            if (str[0] != '"' || str[str.Length - 1] != '"')
            {
                throw new SpawnScriptParserException(row, $"Expected a string but got '{str}' with probably wrong double-quotes.");
            }
            str = str.Substring(1, str.Length - 2);

            if (str.Length > maxLength)
            {
                throw new SpawnScriptStringTooLongException(row, str, maxLength);
            }
            for (var i = 0; i < maxLength; i += 4)
            {
                func.Parameters.Add(GetStringAsInt(str, i));
            }
        }
        public static string AsText(SpawnScript.Function function)
        {
            var p = function.Parameters;

            switch (function.Opcode)
            {
            case SpawnScript.Operation.Spawn:
                return($"Spawn \"{ReadString(p[0])}\"");

            case SpawnScript.Operation.MapOcclusion:
                return($"MapOcclusion 0x{p[0]:x08} 0x{p[1]:x08}");

            case SpawnScript.Operation.MultipleSpawn:
                var spawns = function.Parameters.Select(ReadString).Select(s => $"\"{s}\"");
                return($"MultipleSpawn {string.Join(" ", spawns)}");

            case (SpawnScript.Operation) 3:
                return($"Unk03 {p[0]} \"{ReadString(p[1])}\"");

            case (SpawnScript.Operation) 4:
                return($"Unk04 {p[0]}");

            case (SpawnScript.Operation) 5:
                return($"Unk05 {p[0]}");

            case (SpawnScript.Operation) 6:
                return($"Unk06 {p[0]}");

            case (SpawnScript.Operation) 7:
                return($"Unk07 {p[0]}");

            case (SpawnScript.Operation) 9:
                return($"Unk09 \"{ReadString(p[0])}\"");

            //case SpawnScript.Operation.Run: // One day...
            //    return RunAsText(function.Parameters);
            case SpawnScript.Operation.Party:
                return($"Party {PARTY[p[0]]}");

            case SpawnScript.Operation.Bgm:
                if (p[0] == 0)
                {
                    return("BgmDefault");
                }
                return($"Bgm {p[0] & 0xffff} {(p[0] >> 16) & 0xffff}");

            case (SpawnScript.Operation) 0x14:
                return($"Unk14");

            case SpawnScript.Operation.Mission:
                return($"Mission 0x{p[0]:x} \"" + string.Join(string.Empty,
                                                              ReadString(p[1]),
                                                              ReadString(p[2]),
                                                              ReadString(p[3]),
                                                              ReadString(p[4]),
                                                              ReadString(p[5]),
                                                              ReadString(p[6]),
                                                              ReadString(p[7]),
                                                              ReadString(p[8]) + "\""));

            case SpawnScript.Operation.Layout:
                return($"Layout \"" + string.Join(string.Empty,
                                                  ReadString(p[0]),
                                                  ReadString(p[1]),
                                                  ReadString(p[2]),
                                                  ReadString(p[3]),
                                                  ReadString(p[4]),
                                                  ReadString(p[5]),
                                                  ReadString(p[6]),
                                                  ReadString(p[7]) + "\""));

            case (SpawnScript.Operation) 0x17:
                return($"Unk17");

            case SpawnScript.Operation.BattleLevel:
                return($"BattleLevel {p[0]}");

            case (SpawnScript.Operation) 0x1f:
                return($"Unk1f \"{ReadString(p[0])}\"");

            default:
                return($"Unk{(int)(function.Opcode):x02} {string.Join(" ", p.Select(x => $"0x{x:x}"))}");
            }
        }