예제 #1
0
        /// <summary>
        ///     Gets TEV Stage parameters.
        /// </summary>
        /// <param name="stage">The stage (0-5)</param>
        /// <returns></returns>
        public RenderBase.OTextureCombiner getTevStage(byte stage)
        {
            RenderBase.OTextureCombiner output = new RenderBase.OTextureCombiner();

            ushort baseCommand = 0;

            switch (stage)
            {
            case 0: baseCommand = PICACommand.tevStage0Source; break;

            case 1: baseCommand = PICACommand.tevStage1Source; break;

            case 2: baseCommand = PICACommand.tevStage2Source; break;

            case 3: baseCommand = PICACommand.tevStage3Source; break;

            case 4: baseCommand = PICACommand.tevStage4Source; break;

            case 5: baseCommand = PICACommand.tevStage5Source; break;

            default: throw new Exception("PICACommandReader: Invalid TevStage number!");
            }

            //Source
            uint source = getParameter(baseCommand);

            output.rgbSource[0] = (RenderBase.OCombineSource)(source & 0xf);
            output.rgbSource[1] = (RenderBase.OCombineSource)((source >> 4) & 0xf);
            output.rgbSource[2] = (RenderBase.OCombineSource)((source >> 8) & 0xf);

            output.alphaSource[0] = (RenderBase.OCombineSource)((source >> 16) & 0xf);
            output.alphaSource[1] = (RenderBase.OCombineSource)((source >> 20) & 0xf);
            output.alphaSource[2] = (RenderBase.OCombineSource)((source >> 24) & 0xf);

            //Operand
            uint operand = getParameter((ushort)(baseCommand + 1));

            output.rgbOperand[0] = (RenderBase.OCombineOperandRgb)(operand & 0xf);
            output.rgbOperand[1] = (RenderBase.OCombineOperandRgb)((operand >> 4) & 0xf);
            output.rgbOperand[2] = (RenderBase.OCombineOperandRgb)((operand >> 8) & 0xf);

            output.alphaOperand[0] = (RenderBase.OCombineOperandAlpha)((operand >> 12) & 0xf);
            output.alphaOperand[1] = (RenderBase.OCombineOperandAlpha)((operand >> 16) & 0xf);
            output.alphaOperand[2] = (RenderBase.OCombineOperandAlpha)((operand >> 20) & 0xf);

            //Operator
            uint combine = getParameter((ushort)(baseCommand + 2));

            output.combineRgb   = (RenderBase.OCombineOperator)(combine & 0xffff);
            output.combineAlpha = (RenderBase.OCombineOperator)(combine >> 16);

            //Scale
            uint scale = getParameter((ushort)(baseCommand + 4));

            output.rgbScale   = (ushort)((scale & 0xffff) + 1);
            output.alphaScale = (ushort)((scale >> 16) + 1);

            return(output);
        }
        /// <summary>
        ///     Gets TEV Stage parameters.
        /// </summary>
        /// <param name="stage">The stage (0-5)</param>
        /// <returns></returns>
        public RenderBase.OTextureCombiner getTevStage(byte stage)
        {
            RenderBase.OTextureCombiner output = new RenderBase.OTextureCombiner();

            ushort baseCommand = 0;
            switch (stage)
            {
                case 0: baseCommand = PICACommand.tevStage0Source; break;
                case 1: baseCommand = PICACommand.tevStage1Source; break;
                case 2: baseCommand = PICACommand.tevStage2Source; break;
                case 3: baseCommand = PICACommand.tevStage3Source; break;
                case 4: baseCommand = PICACommand.tevStage4Source; break;
                case 5: baseCommand = PICACommand.tevStage5Source; break;
                default: throw new Exception("PICACommandReader: Invalid TevStage number!");
            }

            //Source
            uint source = getParameter(baseCommand);

            output.rgbSource[0] = (RenderBase.OCombineSource)(source & 0xf);
            output.rgbSource[1] = (RenderBase.OCombineSource)((source >> 4) & 0xf);
            output.rgbSource[2] = (RenderBase.OCombineSource)((source >> 8) & 0xf);

            output.alphaSource[0] = (RenderBase.OCombineSource)((source >> 16) & 0xf);
            output.alphaSource[1] = (RenderBase.OCombineSource)((source >> 20) & 0xf);
            output.alphaSource[2] = (RenderBase.OCombineSource)((source >> 24) & 0xf);

            //Operand
            uint operand = getParameter((ushort)(baseCommand + 1));

            output.rgbOperand[0] = (RenderBase.OCombineOperandRgb)(operand & 0xf);
            output.rgbOperand[1] = (RenderBase.OCombineOperandRgb)((operand >> 4) & 0xf);
            output.rgbOperand[2] = (RenderBase.OCombineOperandRgb)((operand >> 8) & 0xf);

            output.alphaOperand[0] = (RenderBase.OCombineOperandAlpha)((operand >> 12) & 0xf);
            output.alphaOperand[1] = (RenderBase.OCombineOperandAlpha)((operand >> 16) & 0xf);
            output.alphaOperand[2] = (RenderBase.OCombineOperandAlpha)((operand >> 20) & 0xf);

            //Operator
            uint combine = getParameter((ushort)(baseCommand + 2));

            output.combineRgb = (RenderBase.OCombineOperator)(combine & 0xffff);
            output.combineAlpha = (RenderBase.OCombineOperator)(combine >> 16);

            //Scale
            uint scale = getParameter((ushort)(baseCommand + 4));

            output.rgbScale = (ushort)((scale & 0xffff) + 1);
            output.alphaScale = (ushort)((scale >> 16) + 1);

            return output;
        }