コード例 #1
0
        protected virtual void KernelSetFunctions()
        {
            var args = GetStackList(30);

            switch (args[0])
            {
            case 3:
                // Dummy case
                break;

            case 4:
                GrabCursor(args[1], args[2], args[3], args[4]);
                break;

            case 5:
                FadeOut(args[1]);
                break;

            case 6:
                _fullRedraw = true;
                RedrawBGAreas();
                SetActorRedrawFlags();
                ProcessActors();
                FadeIn((byte)args[1]);
                break;

            // TODO: scumm6: start maniac
//                case 8:
//                    StartManiac();
//                    break;
            case 9:
                KillAllScriptsExceptCurrent();
                break;

            // TODO:scumm6: NukeFlObjects
//                case 104:                                                                       /* samnmax */
//                    NukeFlObjects(args[2], args[3]);
//                    break;
            case 107:                                                                           /* set actor scale */
            {
                var a = Actors[args[1]];
                a.SetScale(args[2], -1);
            }
            break;

            case 108:                                                                           /* create proc_special_palette */
            case 109:
                // Case 108 and 109 share the same function
                if (args.Length != 6)
                {
                    throw new InvalidOperationException(string.Format("KernelSetFunctions sub op {0}: expected 6 params but got {1}", args[0], args.Length));
                }
                SetShadowPalette(args[3], args[4], args[5], args[1], args[2], 0, 256);
                break;

            case 110:
                Gdi.ClearMaskBuffer(0);
                break;

            case 111:
            {
                var a     = Actors[args[1]];
                var modes = new int[2];
                Array.Copy(args, 2, modes, 0, args.Length - 2);
                a.ShadowMode = (byte)(modes[0] + modes[1]);
            }
            break;

            case 112:                                                                           /* palette shift? */
                SetShadowPalette(args[3], args[4], args[5], args[1], args[2], args[6], args[7]);
                break;

            case 114:
                // Sam & Max film noir mode
                if (Game.GameId == Scumm.IO.GameId.SamNMax)
                {
                    // At this point ScummVM will already have set
                    // variable 0x8000 to indicate that the game is
                    // in film noir mode. All we have to do here is
                    // to mark the palette as "dirty", because
                    // updatePalette() will desaturate the colors
                    // as they are uploaded to the backend.
                    //
                    // This actually works better than the original
                    // interpreter, where actors would sometimes
                    // still be drawn in color.
                    SetDirtyColors(0, 255);
                }
                else
                {
                    throw new InvalidOperationException("stub KernelSetFunctions_114()");
                }
                break;

            case 117:
                // Sam & Max uses this opcode in script-43, right
                // before a screensaver is selected.
                //
                // Sam & Max uses variable 132 to specify the number of
                // minutes of inactivity (no mouse movements) before
                // starting the screensaver, so setting it to 0 will
                // help in debugging.
                FreezeScripts(0x80);
                break;

            case 119:
                EnqueueObject(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], 0);
                break;

            case 120:
                SwapPalColors(args[1], args[2]);
                break;

            case 122:
                Variables[VariableSoundResult.Value] = IMuse.DoCommand(args.Length - 1, args.Skip(1).ToArray());
                break;

            case 123:
                CopyPalColor(args[2], args[1]);
                break;

            case 124:
                _saveSound = args[1] != 0;
                break;

            default:
                throw new NotSupportedException(string.Format("KernelSetFunctions: default case {0} (param count {1})", args[0], args.Length));
            }
        }