Inheritance: HITSound
Exemplo n.º 1
0
        //0x10
        /// <summary>
        /// Increment a "dest" variable by a "src" variable.
        /// </summary>
        public static HITResult Add(HITThread thread)
        {
            var dest = thread.ReadByte();
            var src = thread.ReadByte();

            var result = thread.ReadVar(dest) + thread.ReadVar(src);
            thread.WriteVar(dest, result);

            thread.SetFlags(result);

            return HITResult.CONTINUE;
        }
Exemplo n.º 2
0
        public static HITResult SetLT(HITThread thread)
        {
            //set local... to... t... yeah i don't know either
            //might be object vars

            var dest = thread.ReadByte();
            var src = thread.ReadByte();

            return HITResult.CONTINUE;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Copy the contents of one variable into another (equivalent to set and settt; 
 /// defaultsyms.txt says "ISN'T THIS THE SAME AS SET TOO?")
 /// </summary>
 public static HITResult SetLL(HITThread thread)
 {
     Set(thread);
     return HITResult.CONTINUE;
 }
Exemplo n.º 4
0
 public static HITResult Assert(HITThread thread)
 {
     return HITResult.CONTINUE; //unused in the sims
 }
Exemplo n.º 5
0
 public static HITResult WaitGreater(HITThread thread)
 {
     return HITResult.CONTINUE; //unused in the sims
 }
Exemplo n.º 6
0
 /// <summary>
 /// Unducks all audio back to the volume before Duck() was called.
 /// </summary>
 public static HITResult Unduck(HITThread thread)
 {
     thread.Unduck();
     return HITResult.CONTINUE; //quack
 }
Exemplo n.º 7
0
 /// <summary>
 /// Stop playing a track, whose ID resides in the specified variable.
 /// </summary>
 public static HITResult StopTrack(HITThread thread)
 {
     var src = thread.ReadByte();
     return HITResult.CONTINUE;
 }
Exemplo n.º 8
0
 public static HITResult SmartRemoveAll(HITThread thread)
 {
     return HITResult.CONTINUE; //unused in the sims
 }
Exemplo n.º 9
0
 public static HITResult Dec(HITThread thread) //0x30
 {
     return(HITResult.CONTINUE);               //unused in the sims
 }
Exemplo n.º 10
0
 public static HITResult SmartRemoveAll(HITThread thread)
 {
     return(HITResult.CONTINUE); //unused in the sims
 }
Exemplo n.º 11
0
 /// <summary>
 /// Set the loop point to the current position.
 /// </summary>
 public static HITResult SetLoop(HITThread thread)
 {
     thread.LoopPointer = (int)thread.PC;
     thread.HasSetLoop  = true;
     return(HITResult.CONTINUE);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Jump back to the loop point (start of track subroutine by default).
 /// </summary>
 public static HITResult Loop(HITThread thread) //0x20
 {
     thread.PC = (uint)thread.LoopPointer;
     return(HITResult.CONTINUE);
 }
Exemplo n.º 13
0
 public static HITResult GetVar(HITThread thread)
 {
     return(HITResult.CONTINUE); //unused in the sims
 }
Exemplo n.º 14
0
 public static HITResult RemoveFromGroup(HITThread thread)
 {
     return(HITResult.CONTINUE); //unused in the sims
 }
Exemplo n.º 15
0
 public static HITResult AddToGroup(HITThread thread)
 {
     return(HITResult.CONTINUE); //unused in the sims
 }
Exemplo n.º 16
0
        public static HITResult SetTL(HITThread thread)
        {
            var dest = thread.ReadByte();
            var src = thread.ReadByte();

            return HITResult.CONTINUE; //unused in the sims
        }
Exemplo n.º 17
0
        /// <summary>
        /// Play a track, whose ID resides in the specified variable.
        /// </summary>
        public static HITResult PlayTrack(HITThread thread)
        {
            var dest = thread.ReadByte();

            return(HITResult.CONTINUE); //Not used in TSO.
        }
Exemplo n.º 18
0
 public static HITResult CallPush(HITThread thread)
 {
     return(HITResult.CONTINUE); //unused in the sims
 }
Exemplo n.º 19
0
        /// <summary>
        /// Choose a global hitlist, or 0 for the one local to the track (source: defaultsyms.txt).
        /// </summary>
        public static HITResult SmartSetList(HITThread thread)
        {
            //sets the hitlist
            var src = thread.ReadByte();
            thread.LoadHitlist((uint)thread.ReadVar(src));

            return HITResult.CONTINUE;
        }
Exemplo n.º 20
0
 public static HITResult Test1(HITThread thread)
 {
     //no idea what these do. examples?
     return(HITResult.CONTINUE);
 }
Exemplo n.º 21
0
 public static HITResult Test1(HITThread thread)
 {
     //no idea what these do. examples?
     return HITResult.CONTINUE;
 }
Exemplo n.º 22
0
 public static HITResult Test4(HITThread thread)
 {
     return(HITResult.CONTINUE);
 }
Exemplo n.º 23
0
 /// <summary>
 /// Wait for a length of time in milliseconds, specified by a variable.
 /// </summary>
 public static HITResult Wait(HITThread thread)
 {
     var src = thread.ReadByte();
     if (thread.WaitRemain == -1) thread.WaitRemain = thread.ReadVar(src);
     thread.WaitRemain -= 16; //assuming tick rate is 60 times a second
     if (thread.WaitRemain > 0)
     {
         thread.PC -= 2;
         return HITResult.HALT;
     }
     else
     {
         thread.WaitRemain = -1;
         return HITResult.CONTINUE;
     }
 }
Exemplo n.º 24
0
 public static HITResult SeqGroupWait(HITThread thread) //unused in the sims
 {
     return(HITResult.CONTINUE);
 }
Exemplo n.º 25
0
 public static HITResult WaitNotEqual(HITThread thread)
 {
     return HITResult.CONTINUE; //unused in the sims
 }
Exemplo n.º 26
0
        /// <summary>
        /// Kill a sequence group with the return value specified by a constant.
        /// </summary>
        public static HITResult SeqGroupReturn(HITThread thread)
        {
            var src = thread.ReadByte();

            return(HITResult.CONTINUE);
        }
Exemplo n.º 27
0
 /// <summary>
 /// Kill this thread.
 /// </summary>
 public static HITResult Return(HITThread thread)
 {
     return(HITResult.KILL);
 }
Exemplo n.º 28
0
 /// <summary>
 /// Copy the contents of one variable into another (equivalent to set and settt;
 /// defaultsyms.txt says "ISN'T THIS THE SAME AS SET TOO?")
 /// </summary>
 public static HITResult SetLL(HITThread thread)
 {
     Set(thread);
     return(HITResult.CONTINUE);
 }
Exemplo n.º 29
0
 /// <summary>
 /// Set the loop point to the current position.
 /// </summary>
 public static HITResult SetLoop(HITThread thread)
 {
     thread.LoopPointer = (int)thread.PC;
     return HITResult.CONTINUE;
 }
Exemplo n.º 30
0
 public static HITResult WaitNotEqual(HITThread thread)
 {
     return(HITResult.CONTINUE); //unused in the sims
 }
Exemplo n.º 31
0
        public static HITResult SetSrcDataField(HITThread thread)
        {
            var value = thread.ReadByte();
            var src = thread.ReadByte();
            var field = thread.ReadByte();

            //TODO: System for keeping track of which objects correspond to ObjectID.

            return HITResult.CONTINUE; //you can set these??? what
        }
Exemplo n.º 32
0
 public static HITResult WaitLessOrEq(HITThread thread)
 {
     return(HITResult.CONTINUE); //unused in the sims
 }
Exemplo n.º 33
0
 /// <summary>
 /// Set the specified variable to a random entry from the selected hitlist.
 /// </summary>
 public static HITResult SmartChoose(HITThread thread)
 {
     var dest = thread.ReadByte();
     thread.WriteVar(dest, (int)thread.HitlistChoose());
     return HITResult.CONTINUE;
 }
Exemplo n.º 34
0
 /// <summary>
 /// Ducks all audio with priority lower than this.
 /// Imagine all the other sounds getting quieter when the fire music plays.
 /// </summary>
 public static HITResult Duck(HITThread thread)
 {
     thread.Duck();
     return(HITResult.CONTINUE);
 }
Exemplo n.º 35
0
        /// <summary>
        /// Load a track ("index" variable) from a hitlist ("table" variable).
        /// </summary>
        public static HITResult SmartIndex(HITThread thread)
        {
            var dest = thread.ReadVar(thread.ReadByte());
            var index = thread.ReadVar(thread.ReadByte());

            thread.LoadHitlist((byte)index);
            //Converting this to an int is a hack because WriteVar only takes an int... o_O
            int TrackID = (int)thread.LoadTrack(index);

            thread.WriteVar(dest, TrackID);

            return HITResult.CONTINUE; //Appears to be unused.
        }
Exemplo n.º 36
0
 /// <summary>
 /// Unducks all audio back to the volume before Duck() was called.
 /// </summary>
 public static HITResult Unduck(HITThread thread)
 {
     thread.Unduck();
     return(HITResult.CONTINUE); //quack
 }
Exemplo n.º 37
0
 public static HITResult SmartSetCrit(HITThread thread)
 {
     return HITResult.CONTINUE; //unused in the sims
 }
Exemplo n.º 38
0
        /// <summary>
        /// Stop playing a track, whose ID resides in the specified variable.
        /// </summary>
        public static HITResult StopTrack(HITThread thread)
        {
            var src = thread.ReadByte();

            return(HITResult.CONTINUE);
        }
Exemplo n.º 39
0
 public static HITResult StopNote(HITThread thread)
 {
     return HITResult.CONTINUE; //unused in the sims
 }
Exemplo n.º 40
0
 public static HITResult SetChanReg(HITThread thread)
 {
     return(HITResult.CONTINUE); //unused in the sims
 }
Exemplo n.º 41
0
        /// <summary>
        /// Examine a variable and set the flags.
        /// </summary>
        public static HITResult Test(HITThread thread)
        {
            var value = thread.ReadVar(thread.ReadByte());

            thread.SetFlags(value);

            return HITResult.CONTINUE;
        }
Exemplo n.º 42
0
 public static HITResult KillNote(HITThread thread)
 {
     return(HITResult.CONTINUE); //unused in the sims
 }
Exemplo n.º 43
0
 public static HITResult Test4(HITThread thread)
 {
     return HITResult.CONTINUE;
 }
Exemplo n.º 44
0
        public HITSound PlaySoundEvent(string evt)
        {
            if (DISABLE_SOUND)
            {
                return(null);
            }
            evt = evt.ToLowerInvariant();
            if (evt.StartsWith("nc_"))
            {
                NightclubMode = true;
            }
            HITThread InterruptBlocker = null; //the thread we have to wait for to finish before we begin.

            if (ActiveEvents.ContainsKey(evt))
            {
                var aevt = ActiveEvents[evt];
                if (aevt.Dead)
                {
                    ActiveEvents.Remove(evt);            //if the last event is dead, remove and make a new one
                }
                else
                {
                    if ((aevt as HITThread)?.InterruptBlocker != null)
                    {
                        //we can stop this thread - steal its waiter
                        (aevt as HITThread).Dead = true;
                        InterruptBlocker         = (aevt as HITThread).InterruptBlocker;
                    }
                    else if ((aevt as HITThread)?.Interruptable == true)
                    {
                        InterruptBlocker = (aevt as HITThread);
                    }
                    else
                    {
                        return(aevt); //an event of this type is already alive - here, take it.
                    }
                }
            }

            var content = FSO.Content.Content.Get();
            var evts    = content.Audio.Events;

            if (evts.ContainsKey(evt))
            {
                var evtent = evts[evt];

                //objects call the wrong event for piano playing
                //there is literally no file or evidence that this is not hard code mapped to PlayPiano in TSO, so it's hardcoded here.
                //the track and HSM associated with the piano_play event, however, are correct. it's just the subroutine that is renamed.
                if (evt.Equals("piano_play", StringComparison.InvariantCultureIgnoreCase))
                {
                    evt = "playpiano";
                    if (ActiveEvents.ContainsKey(evt))
                    {
                        if (ActiveEvents[evt].Dead)
                        {
                            ActiveEvents.Remove(evt);                         //if the last event is dead, remove and make a new one
                        }
                        else
                        {
                            return(ActiveEvents[evt]); //an event of this type is already alive - here, take it.
                        }
                    }
                }

                uint TrackID           = 0;
                uint SubroutinePointer = 0;

                if (content.TS1)
                {
                    TrackID = evtent.TrackID;
                    var track = content.Audio.GetTrack(TrackID, 0, evtent.ResGroup);
                    if (track != null && track.SubroutineID != 0)
                    {
                        SubroutinePointer = track.SubroutineID;
                    }
                }
                else
                {
                    if (evtent.ResGroup.hsm != null)
                    {
                        var c = evtent.ResGroup.hsm.Constants;
                        if (c.ContainsKey(evt))
                        {
                            SubroutinePointer = (uint)c[evt];
                        }
                        var trackIdName = "guid_tkd_" + evt;
                        if (c.ContainsKey(trackIdName))
                        {
                            TrackID = (uint)c[trackIdName];
                        }
                        else
                        {
                            TrackID = evtent.TrackID;
                        }
                    }
                    else
                    { //no hsm, fallback to eent and event track ids (tsov2)
                        var entPoints = evtent.ResGroup.hit.EntryPointByTrackID;
                        TrackID = evtent.TrackID;
                        if (entPoints != null && entPoints.ContainsKey(evtent.TrackID))
                        {
                            SubroutinePointer = entPoints[evtent.TrackID];
                        }
                    }
                }

                if (evtent.EventType == HITEvents.kTurnOnTV)
                {
                    var thread = new HITTVOn(evtent.TrackID, this);
                    thread.VolGroup = HITVolumeGroup.FX;
                    Sounds.Add(thread);
                    ActiveEvents.Add(evt, thread);
                    return(thread);
                }
                else if (evtent.EventType == HITEvents.kSetMusicMode)
                {
                    var thread = new HITTVOn(evtent.TrackID, this, true);
                    thread.VolGroup = HITVolumeGroup.MUSIC;
                    ActiveEvents.Add(evt, thread);
                    if (NextMusic != null)
                    {
                        NextMusic.Kill();
                    }
                    if (MusicEvent != null)
                    {
                        MusicEvent.Fade();
                    }
                    NextMusic = thread;
                    return(thread);
                }
                else if (SubroutinePointer != 0)
                {
                    var thread = new HITThread(evtent.ResGroup, this);
                    thread.PC          = SubroutinePointer;
                    thread.LoopPointer = (int)thread.PC;
                    if (TrackID != 0)
                    {
                        thread.SetTrack(TrackID, evtent.TrackID);
                    }
                    Sounds.Add(thread);
                    ActiveEvents[evt] = thread;
                    if (InterruptBlocker != null)
                    {
                        InterruptBlocker.Interrupt(thread);
                        if (!InterruptBlocker.Name.StartsWith("nc_"))
                        {
                            InterruptBlocker.KillVocals();
                        }
                    }
                    thread.Name = evt;
                    return(thread);
                }
                else if (TrackID != 0 && content.Audio.GetTrack(TrackID, 0, evtent.ResGroup) != null)
                {
                    var thread = new HITThread(TrackID, this, evtent.ResGroup);
                    Sounds.Add(thread);
                    ActiveEvents[evt] = thread;
                    if (InterruptBlocker != null)
                    {
                        InterruptBlocker.Interrupt(thread);
                        if (!InterruptBlocker.Name.StartsWith("nc_"))
                        {
                            InterruptBlocker.KillVocals();
                        }
                    }
                    thread.Name = evt;
                    return(thread);
                }
            }

            return(null);
        }
Exemplo n.º 45
0
 public static HITResult AddToGroup(HITThread thread)
 {
     return HITResult.CONTINUE; //unused in the sims
 }
Exemplo n.º 46
0
        /// <summary>
        /// Copy the contents of one variable into another.
        /// </summary>
        public static HITResult Set(HITThread thread)
        {
            var dest = thread.ReadByte();
            var src = thread.ReadVar(thread.ReadByte());

            thread.WriteVar(dest, src);

            thread.SetFlags(src);

            return HITResult.CONTINUE;
        }
Exemplo n.º 47
0
        /// <summary>
        /// Wait until two variables are equal.
        /// </summary>
        public static HITResult WaitEqual(HITThread thread)
        {
            var dest = thread.ReadByte();
            var src = thread.ReadByte();

            if (thread.ReadVar(dest) != thread.ReadVar(dest))
            {
                thread.PC -= 3;
                return HITResult.HALT;
            }
            else
                return HITResult.CONTINUE;
        }
Exemplo n.º 48
0
 public static HITResult SetChanReg(HITThread thread)
 {
     return HITResult.CONTINUE; //unused in the sims
 }
Exemplo n.º 49
0
 public static HITResult WaitLessOrEq(HITThread thread)
 {
     return HITResult.CONTINUE; //unused in the sims
 }
Exemplo n.º 50
0
        /// <summary>
        /// Read globally, set locally (source: defaultsyms.txt).
        /// </summary>
        public static HITResult SetGL(HITThread thread)
        {
            var dest = thread.ReadByte();
            var src = thread.ReadInt32();

            int Global = thread.VM.ReadGlobal(src);
            thread.WriteVar(dest, Global);

            return HITResult.CONTINUE;
        }
Exemplo n.º 51
0
 /// <summary>
 /// Wait for the previously selected note to finish playing.
 /// </summary>
 public static HITResult WaitSamp(HITThread thread)
 {
     if (thread.NoteActive(thread.LastNote))
     {
         thread.PC--;
         return HITResult.HALT;
     }
     else
         return HITResult.HALT;
 }
Exemplo n.º 52
0
        /// <summary>
        /// Set global = local (source: defaultsyms.txt).
        /// </summary>
        public static HITResult SetLG(HITThread thread)
        {
            var local = thread.ReadByte();
            var global = thread.ReadInt32();

            thread.VM.WriteGlobal(global, local);

            return HITResult.CONTINUE;
        }
Exemplo n.º 53
0
        public HITSound PlaySoundEvent(string evt)
        {
            evt = evt.ToLower();
            if (ActiveEvents.ContainsKey(evt))
            {
                if (ActiveEvents[evt].Dead) ActiveEvents.Remove(evt); //if the last event is dead, remove and make a new one
                else return ActiveEvents[evt]; //an event of this type is already alive - here, take it.
            }

            var content = FSO.Content.Content.Get();
            if (Events.ContainsKey(evt))
            {
                var evtent = Events[evt];

                if (evt.Equals("piano_play", StringComparison.InvariantCultureIgnoreCase))
                {
                    evt = "playpiano";
                    if (ActiveEvents.ContainsKey(evt))
                    {
                        if (ActiveEvents[evt].Dead) ActiveEvents.Remove(evt); //if the last event is dead, remove and make a new one
                        else return ActiveEvents[evt]; //an event of this type is already alive - here, take it.
                    }
                }

                uint TrackID = 0;
                uint SubroutinePointer = 0;
                if (evtent.ResGroup.hsm != null)
                {
                    var c = evtent.ResGroup.hsm.Constants;
                    if (c.ContainsKey(evt)) SubroutinePointer = (uint)c[evt];
                    var trackIdName = "guid_tkd_" + evt;
                    if (c.ContainsKey(trackIdName)) TrackID = (uint)c[trackIdName];
                    else TrackID = evtent.TrackID;
                }
                else
                { //no hsm, fallback to eent and event track ids (tsov2)
                    var entPoints = evtent.ResGroup.hit.EntryPointByTrackID;
                    TrackID = evtent.TrackID;
                    if (entPoints.ContainsKey(evtent.TrackID)) SubroutinePointer = entPoints[evtent.TrackID];
                }

                if (evtent.EventType == HITEvents.kTurnOnTV)
                {
                    var thread = new HITTVOn(evtent.TrackID);
                    Sounds.Add(thread);
                    ActiveEvents.Add(evt, thread);
                    return thread;
                }
                else if (SubroutinePointer != 0)
                {
                    var thread = new HITThread(evtent.ResGroup.hit, this);
                    thread.PC = SubroutinePointer;
                    if (TrackID != 0) thread.SetTrack(TrackID, evtent.TrackID);

                    Sounds.Add(thread);
                    ActiveEvents.Add(evt, thread);
                    return thread;
                }
                else if (TrackID != 0 && content.Audio.TracksById.ContainsKey(TrackID))
                {
                    var thread = new HITThread(TrackID);
                    Sounds.Add(thread);
                    ActiveEvents.Add(evt, thread);
                    return thread;
                }
            }

            return null;
        }
Exemplo n.º 54
0
 public void Unblock()
 {
     InterruptBlocker = null;
 }