protected virtual void KernelGetFunctions()
{
var vs = MainVirtScreen;
var args = GetStackList(30);
switch (args[0])
{
case 113:
// WORKAROUND for bug #899249: The scripts used for screen savers
// in Sam & Max use hard coded values for the maximum height and width.
// This causes problems in rooms (ie. Credits) where their values are
// lower, so we set result to zero if out of bounds.
if (args[1] >= 0 && args[1] <= vs.Width && args[2] >= 0 && args[2] <= vs.Height)
{
var nav = new PixelNavigator(vs.Surfaces[0]);
nav.GoTo(args[1], args[2]);
var pixel = nav.Read();
Push(pixel);
}
else
{
Push(0);
}
break;
case 115:
Push(GetSpecialBox(new Point((short)args[1], (short)args[2])));
break;
case 116:
Push(CheckXYInBoxBounds(args[3], new Point((short)args[1], (short)args[2])));
break;
case 206:
Push(RemapPaletteColor(args[1], args[2], args[3], -1));
break;
case 207:
{
var i = GetObjectIndex(args[1]);
Debug.Assert(i != 0);
Push(_objs[i].Position.X);
}
break;
case 208:
{
var i = GetObjectIndex(args[1]);
Debug.Assert(i != 0);
Push(_objs[i].Position.Y);
}
break;
case 209:
{
var i = GetObjectIndex(args[1]);
Debug.Assert(i != 0);
Push(_objs[i].Width);
}
break;
case 210:
{
var i = GetObjectIndex(args[1]);
Debug.Assert(i != 0);
Push(_objs[i].Height);
}
break;
case 211:
/*
13 = thrust
336 = thrust
328 = thrust
27 = abort
97 = left
331 = left
115 = right
333 = right
*/
Push(GetKeyState(args[1]));
break;
case 212:
{
var a = Actors[args[1]];
// This is used by walk scripts
Push(a.Frame);
}
break;
case 213:
{
var slot = GetVerbSlot(args[1], 0);
Push(Verbs[slot].CurRect.Left);
}
break;
case 214:
{
var slot = GetVerbSlot(args[1], 0);
Push(Verbs[slot].CurRect.Top);
}
break;
case 215:
if ((_extraBoxFlags[args[1]] & 0x00FF) == 0x00C0)
{
Push(_extraBoxFlags[args[1]]);
}
else
{
Push((int)GetBoxFlags((byte)args[1]));
}
break;
default:
throw new NotSupportedException(string.Format("KernelGetFunctions: default case {0}", args[0]));
}
}