public ControlButton(ushort x, ushort y, uint resId, ButtonIds id, byte flag, ResMan pResMan, byte[] screenBuf,
ISystem system)
{
_x = x;
_y = y;
_id = id;
_flag = flag;
_resId = resId;
_resMan = pResMan;
_frameIdx = 0;
_resMan.ResOpen(_resId);
FrameHeader tmp = new FrameHeader(_resMan.FetchFrame(_resMan.FetchRes(_resId), 0));
_width = _resMan.ReadUInt16(tmp.width);
_width = (ushort)((_width > Screen.SCREEN_WIDTH) ? Screen.SCREEN_WIDTH : _width);
_height = _resMan.ReadUInt16(tmp.height);
if ((x == 0) && (y == 0))
{ // center the frame (used for panels);
_x = (ushort)((((640 - _width) / 2) < 0) ? 0 : ((640 - _width) / 2));
_y = (ushort)((((480 - _height) / 2) < 0) ? 0 : ((480 - _height) / 2));
}
_dstBuf = new ByteAccess(screenBuf, _y * Screen.SCREEN_WIDTH + _x);
_system = system;
}