当前位置: 首页>>代码示例>>C#>>正文


C# Memory.Read8方法代码示例

本文整理汇总了C#中Memory.Read8方法的典型用法代码示例。如果您正苦于以下问题:C# Memory.Read8方法的具体用法?C# Memory.Read8怎么用?C# Memory.Read8使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Memory的用法示例。


在下文中一共展示了Memory.Read8方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Pop

 /// <summary>
 /// Pops the 16-bit register from the stack and increments the stack pointer by 2.
 /// </summary>
 private static ushort Pop(ref Memory mem, ref Registers regs)
 {
     ushort data = mem.Read8(regs.SP);
     regs.SP += 2;
     return data;
 }
开发者ID:ASSympt0te,项目名称:LameBoy,代码行数:9,代码来源:OpcodeTable.cs

示例2: DecodeCB

        /// <summary>
        /// Handles CB, a multibyte instruction.
        /// <b>XXX: This method should be rewritten due to its immense length.</b>
        /// </summary>
        /// <param name="opcode">The byte representing the opcode following the CB instruction</param>
        /// <param name="regs">All CPU registers</param>
        private static void DecodeCB(byte opcode, ref Registers regs, ref Memory mem)
        {
            int instrType = (opcode & 0xC0) >> 6;
            int argument = (opcode & 0x38) >> 3;
            int register = (opcode & 0x7);
            
            bool[] bits = new bool[0];

            switch (instrType)
            {
                case 0:
                    //Rotate/Shift
                    break;
                case 1:
                    //Test bit
                    switch (register)
                    {
                        case 0: bits = ByteToBits(regs.B); break;
                        case 1: bits = ByteToBits(regs.C); break;
                        case 2: bits = ByteToBits(regs.D); break;
                        case 3: bits = ByteToBits(regs.E); break;
                        case 4: bits = ByteToBits(regs.H); break;
                        case 5: bits = ByteToBits(regs.L); break;
                        case 6: bits = ByteToBits(mem.Read8(regs.HL)); break;
                        case 7: bits = ByteToBits(regs.A); break;
                    }
                    regs.Z = !bits[argument];
                    break;
                case 2:
                    //Reset bit
                    switch (register)
                    {
                        case 0:
                            //B
                            bits = ByteToBits(regs.B);
                            bits[argument] = false;
                            regs.B = BitsToByte(bits);
                            break;
                        case 1:
                            //C
                            bits = ByteToBits(regs.C);
                            bits[argument] = false;
                            regs.C = BitsToByte(bits);
                            break;
                        case 2:
                            //D
                            bits = ByteToBits(regs.D);
                            bits[argument] = false;
                            regs.D = BitsToByte(bits);
                            break;
                        case 3:
                            //E
                            bits = ByteToBits(regs.E);
                            bits[argument] = false;
                            regs.E = BitsToByte(bits);
                            break;
                        case 4:
                            //H
                            bits = ByteToBits(regs.H);
                            bits[argument] = false;
                            regs.H = BitsToByte(bits);
                            break;
                        case 5:
                            //L
                            bits = ByteToBits(regs.L);
                            bits[argument] = false;
                            regs.L = BitsToByte(bits);
                            break;
                        case 6:
                            //HL
                            bits = ByteToBits(mem.Read8(regs.HL));
                            bits[argument] = false;
                            regs.B = BitsToByte(bits);
                            break;
                        case 7:
                            //A
                            bits = ByteToBits(regs.A);
                            bits[argument] = false;
                            regs.A = BitsToByte(bits);
                            break;
                    }
                    break;
                case 3:
                    //Set bit
                    switch (register)
                    {
                        case 0:
                            //B
                            bits = ByteToBits(regs.B);
                            bits[argument] = true;
                            regs.B = BitsToByte(bits);
                            break;
                        case 1:
                            //C
//.........这里部分代码省略.........
开发者ID:ASSympt0te,项目名称:LameBoy,代码行数:101,代码来源:OpcodeTable.cs


注:本文中的Memory.Read8方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。