Example #1
0
        public bool PpuRead(NameTableMirrorMode mirrorMode, ushort address, out byte data)
        {
            if (address >= 0x2000 && address <= 0x3eff)
            {
                data = 0;

                address -= 0x2000;

                if (mirrorMode == NameTableMirrorMode.Horizontal)
                {
                    if (address >= 0x0000 && address <= 0x03ff) // First 1KiB maps to the first name table.
                    {
                        data = _tables[0][address & 0x03ff];
                    }
                    else if (address >= 0x0400 && address <= 0x07ff) // Second 1KiB maps back to the first name table.
                    {
                        data = _tables[0][address & 0x03ff];
                    }
                    else if (address >= 0x0800 && address <= 0x0bff) // Third 1KiB maps to the second name table.
                    {
                        data = _tables[1][address & 0x03ff];
                    }
                    else if (address >= 0x0c00 && address <= 0x0fff) // Fourth 1KiB maps back to the second name table.
                    {
                        data = _tables[1][address & 0x03ff];
                    }
                }
                else if (mirrorMode == NameTableMirrorMode.Vertical)
                {
                    if (address >= 0x0000 && address <= 0x03ff) // First 1KiB maps to the first name table.
                    {
                        data = _tables[0][address & 0x03ff];
                    }
                    else if (address >= 0x0400 && address <= 0x07ff) // Second 1KiB maps to the second name table.
                    {
                        data = _tables[1][address & 0x03ff];
                    }
                    else if (address >= 0x0800 && address <= 0x0bff) // Third 1KiB maps back to the first name table.
                    {
                        data = _tables[0][address & 0x03ff];
                    }
                    else if (address >= 0x0c00 && address <= 0x0fff) // Fourth 1KiB maps back to the second name table.
                    {
                        data = _tables[1][address & 0x03ff];
                    }
                }

                return(true);
            }

            data = 0;
            return(false);
        }
Example #2
0
        public override bool GetMirrorMode(out NameTableMirrorMode mirrorMode)
        {
            switch (_controlRegister & 0x3)
            {
            case 0b10:
                mirrorMode = NameTableMirrorMode.Vertical;
                return(true);

            case 0b11:
                mirrorMode = NameTableMirrorMode.Horizontal;
                return(true);

            default:     // TODO: Handle mirror modes 0b00 and 0b01.
                mirrorMode = NameTableMirrorMode.Vertical;
                return(true);
            }
        }
Example #3
0
        public virtual bool GetMirrorMode(out NameTableMirrorMode mirrorMode)
        {
            mirrorMode = NameTableMirrorMode.Horizontal;

            return(false);
        }