HLS refers to two binary formats that both define a list of IDs, known as a hitlist. One format is a Pascal string with a 4-byte, little-endian length, representing a comma-seperated list of decimal values, or decimal ranges (e.g. "1025-1035"), succeeded by a single LF newline.
Ejemplo n.º 1
0
        public static Hitlist HitlistFromString(string str)
        {
            var result = new Hitlist();

            result.Populate(str);
            return(result);
        }
Ejemplo n.º 2
0
 public void LoadHitlist(uint id)
 {
     Hitlist = audContent.GetHitlist(id);
 }
Ejemplo n.º 3
0
        public void LoadFrom(byte[] FileData)
        {
            var Reader      = new StreamReader(new MemoryStream(FileData));
            var ActiveState = HotReadMode.None;

            while (!Reader.EndOfStream)
            {
                string CurrentLine = Reader.ReadLine().Trim().Replace("\r\n", "");

                switch (CurrentLine)
                {
                case "[EventMappingEquate]":
                    ActiveState = HotReadMode.EventMappingEquate;
                    break;

                case "[Options]":
                    ActiveState = HotReadMode.Options;
                    break;

                case "[TrackData]":
                    ActiveState = HotReadMode.TrackData;
                    break;

                case "[EventMapping]":
                    //equivalent to .evt file
                    //(name)=(eventMappingEquate as event type),(trackid),0,0,0,0
                    ActiveState = HotReadMode.EventMapping;
                    break;

                case "[Track]":
                    //equivalent to a lot of track files
                    //(trackid)=0,(subroutine),(volume),(arguments),(duckingPriority),(controlGroup),(soundPressureLevel),@(hitlistID),(patchID)
                    //patch id is usually 0, in favor of single item hitlists
                    ActiveState = HotReadMode.Track;
                    break;

                case "[Patch]":
                    //(patchid)=(name),(filenameInQuotes),(looped),(piano),0,0,0
                    ActiveState = HotReadMode.Patch;
                    break;

                case "[GlobalHitList]":
                    //(hitlistid)=(hitlistString)
                    //note: many hitlists contain just one patch
                    ActiveState = HotReadMode.GlobalHitList;
                    break;
                }

                if (!CurrentLine.Contains("["))
                {
                    if (!CurrentLine.Contains("]"))
                    {
                        if (CurrentLine != "")
                        {
                            string[] Params = CurrentLine.Split("=".ToCharArray());
                            //EventMappingEquate fields look like: kSndobPlay=1
                            switch (ActiveState)
                            {
                            case HotReadMode.EventMappingEquate:
                                var EMappingEquate = new EventMappingEquate();
                                EMappingEquate.Label = Params[0];
                                EMappingEquate.Value = int.Parse(Params[1]);
                                EventMappingEquate[EMappingEquate.Label] = EMappingEquate.Value;
                                break;

                            //Options fields look like: Version=1
                            case HotReadMode.Options:
                                switch (Params[0])
                                {
                                case "Version":
                                    m_Version = int.Parse(Params[1]);
                                    break;

                                case "LoadPriority":
                                    m_LoadPriority = int.Parse(Params[1]);
                                    break;
                                }
                                break;

                            //TrackData fields look like: 0xb0f4=0x10
                            case HotReadMode.TrackData:
                                TrackData.Add(Convert.ToUInt32(Params[0], 16), Convert.ToUInt32(Params[1], 16));
                                break;

                            case HotReadMode.EventMapping:
                                var commaSplit = Params[1].Split(',');
                                Events[Params[0].ToLowerInvariant()] = new EVTEntry
                                {
                                    Name      = Params[0].ToLowerInvariant(),
                                    EventType = (uint)ParseEME(commaSplit[0]),
                                    TrackID   = (commaSplit.Length > 1)?(uint)ParseEME(commaSplit[1]):0
                                };
                                break;

                            case HotReadMode.Track:
                                var tid     = uint.Parse(Params[0]);
                                var tcSplit = Params[1].Split(',');

                                var trk = new Track()
                                {
                                    SubroutineID    = 0, //(uint)HSMConst(tcSplit[1]),
                                    Volume          = (uint)ParseEME(tcSplit[2]),
                                    ArgType         = (HITArgs)ParseEME(tcSplit[3]),
                                    DuckingPriority = (HITDuckingPriorities)ParseEME(tcSplit[4]),
                                    ControlGroup    = (HITControlGroups)ParseEME(tcSplit[5]),
                                    HitlistID       = (uint)HSMConst(tcSplit[7].Substring(1)), //cut out @
                                    SoundID         = (uint)ParseEME(tcSplit[8])
                                };

                                if (trk.HitlistID != 0 && TrackData.ContainsKey(trk.HitlistID))
                                {
                                    trk.SubroutineID = TrackData[trk.HitlistID];
                                }
                                if (trk.SoundID != 0 && TrackData.ContainsKey(trk.SoundID))
                                {
                                    trk.SubroutineID = TrackData[trk.SoundID];
                                }

                                Tracks[tid] = trk;
                                break;

                            case HotReadMode.Patch:
                                var pid   = uint.Parse(Params[0]);
                                var patch = new Patch(Params[1]);
                                Patches[pid] = patch;
                                break;

                            case HotReadMode.GlobalHitList:
                                var hid = uint.Parse(Params[0]);
                                try
                                {
                                    var hitlist = Hitlist.HitlistFromString(Params[1]);
                                    Hitlists[hid] = hitlist;
                                } catch (Exception)
                                {
                                    /*
                                     * todo: saxophone seems to reference an hsm.
                                     * 20016=sulsaxj_way_aa
                                     * 20017=sulsaxk_way_solo
                                     * 20018=sulsaxl_way_fin
                                     * these labels are in the hsm but they have a different case...
                                     */
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }