Пример #1
0
        private UInt16 ReadWord(UInt16 address)
        {
            byte low  = CpuRead(address);
            byte high = CpuRead((UInt16)(address + 1));

            return(BitMagic.Combine(high, low));
        }
Пример #2
0
        private UInt16 StackPopWord()
        {
            byte low  = StackPop();
            byte high = StackPop();

            return(BitMagic.Combine(high, low));
        }
Пример #3
0
        public bool IND()
        {
            byte low  = CpuRead(PC++);
            byte high = CpuRead(PC++);

            UInt16 ptr = BitMagic.Combine(high, low);

            byte addrLow, addrHigh;

            // hardware bug
            if (low == 0x00FF)
            {
                addrLow  = CpuRead((ptr));
                addrHigh = CpuRead((UInt16)(ptr & 0xFF00));
            }
            else
            {
                addrLow  = CpuRead(ptr);
                addrHigh = CpuRead((UInt16)(ptr + 1));
            }

            address = BitMagic.Combine(addrHigh, addrLow);

            return(false);
        }
Пример #4
0
        public bool ABS()
        {
            byte low  = CpuRead(PC++);
            byte high = CpuRead(PC++);

            address = BitMagic.Combine(high, low);

            return(false);
        }
Пример #5
0
        public bool IZX()
        {
            byte t = CpuRead(PC++);

            // address is in zero page
            byte addrLow  = CpuRead((UInt16)((t + X) & 0x00FF));
            byte addrHigh = CpuRead((UInt16)((t + X + 1) & 0x00FF));

            address = BitMagic.Combine(addrHigh, addrLow);

            return(false);
        }
Пример #6
0
        // global system clock
        public void Clock()
        {
            ppu.Clock();

            if (clockCounter % 3 == 0)
            {
                if (dmaStarted)
                {
                    if (dmaDummy)
                    {
                        if (clockCounter % 2 == 1)
                        {
                            dmaDummy = false;
                        }
                    }
                    else
                    {
                        if (clockCounter % 2 == 0)
                        {
                            UInt16 address = BitMagic.Combine(dmaPage, dmaAddress);
                            dmaData = CpuRead(address);
                        }
                        else
                        {
                            ppu.Oam[dmaAddress++] = dmaData;

                            // after 256 writes dmaAddress loops back to zero
                            if (dmaAddress == 0)
                            {
                                dmaStarted = false;
                                dmaDummy   = true;
                            }
                        }
                    }
                }
                else
                {
                    cpu.Clock();
                }
            }

            if (ppu.EmitNmi)
            {
                cpu.NMI();
            }

            clockCounter++;
        }
Пример #7
0
        public bool IZY()
        {
            byte t = CpuRead(PC++);

            // address is in zero page
            byte addrLow  = CpuRead((UInt16)(t & 0x00FF));
            byte addrHigh = CpuRead((UInt16)((t + 1) & 0x00FF));

            address  = BitMagic.Combine(addrHigh, addrLow);
            address += Y;

            // if page is crossed
            if (Page(address) != Page((UInt16)(addrHigh << 8)))
            {
                return(true);
            }

            return(false);
        }