Exemple #1
0
        static public void _cvt_w_s_impl(CpuThreadState CpuThreadState, int FD, int FS)
        {
            //Console.WriteLine("_cvt_w_s_impl: {0}", CpuThreadState.FPR[FS]);
            switch (CpuThreadState.Fcr31.RM)
            {
            case CpuThreadState.FCR31.TypeEnum.Rint: CpuThreadState.FPR_I[FD] = (int)MathFloat.Rint(CpuThreadState.FPR[FS]); break;

            case CpuThreadState.FCR31.TypeEnum.Cast: CpuThreadState.FPR_I[FD] = (int)CpuThreadState.FPR[FS]; break;

            case CpuThreadState.FCR31.TypeEnum.Ceil: CpuThreadState.FPR_I[FD] = (int)MathFloat.Ceil(CpuThreadState.FPR[FS]); break;

            case CpuThreadState.FCR31.TypeEnum.Floor: CpuThreadState.FPR_I[FD] = (int)MathFloat.Floor(CpuThreadState.FPR[FS]); break;
            }
        }
        public static int _cvt_w_s_impl(CpuThreadState cpuThreadState, float fs)
        {
            //Console.WriteLine("_cvt_w_s_impl: {0}", CpuThreadState.FPR[FS]);
            switch (cpuThreadState.Fcr31.Rm)
            {
            case CpuThreadState.Fcr31Struct.TypeEnum.Rint: return((int)MathFloat.Rint(fs));

            case CpuThreadState.Fcr31Struct.TypeEnum.Cast: return((int)MathFloat.Cast(fs));

            case CpuThreadState.Fcr31Struct.TypeEnum.Ceil: return((int)MathFloat.Ceil(fs));

            case CpuThreadState.Fcr31Struct.TypeEnum.Floor: return((int)MathFloat.Floor(fs));
            }

            throw new InvalidCastException("RM has an invalid value!!");
            //case CpuThreadState.FCR31.TypeEnum.Floor: CpuThreadState.FPR_I[FD] = (int)MathFloat.Floor(CpuThreadState.FPR[FS]); break;
        }