Пример #1
0
        }/* end_of_sound */

        /*
         * z_sound_effect, load / play / stop / discard a sound effect.
         *
         *	zargs[0] = number of bleep (1 or 2) or sample
         *	zargs[1] = operation to perform (samples only)
         *	zargs[2] = repeats and volume (play sample only)
         *	zargs[3] = end-of-sound routine (play sample only, optional)
         *
         * Note: Volumes range from 1 to 8, volume 255 is the default volume.
         *	 Repeats are stored in the high byte, 255 is infinite loop.
         *
         */

        internal static void ZSoundEffect()
        {
            zword number = Process.zargs[0];
            zword effect = Process.zargs[1];
            zword volume = Process.zargs[2];

            if (Process.zargc < 1)
            {
                number = 0;
            }
            if (Process.zargc < 2)
            {
                effect = EFFECT_PLAY;
            }
            if (Process.zargc < 3)
            {
                volume = 8;
            }

            if (number is >= 3 or 0)
            {
                locked = true;

                if (Main.StoryId == Story.LURKING_HORROR && (number is 9 or 16))
                {
                    if (effect == EFFECT_PLAY)
                    {
                        next_sample = number;
                        next_volume = volume;

                        locked = false;

                        if (!playing)
                        {
                            StartNextSample();
                        }
                    }
                    else
                    {
                        locked = false;
                    }

                    return;
                }

                playing = false;

                switch (effect)
                {
                case EFFECT_PREPARE:
                    OS.PrepareSample(number);
                    break;

                case EFFECT_PLAY:
                    StartSample(number, FastMem.Lo(volume), FastMem.Hi(volume),
                                (zword)((Process.zargc == 4) ? Process.zargs[3] : 0));
                    break;

                case EFFECT_STOP:
                    OS.StopSample(number);
                    break;

                case EFFECT_FINISH_WITH:
                    OS.FinishWithSample(number);
                    break;
                }

                locked = false;
            }