예제 #1
0
파일: Ppu.cs 프로젝트: Nyllcp/pNes
 public byte ReadPpuMemory(int address)
 {
     if (address < 0x3F00)
     {
         return(_cart.ReadCart(address));
     }
     else
     {
         return(paletteRam[address & 0x1F]);
     }
 }
예제 #2
0
파일: Core.cs 프로젝트: Nyllcp/pNes
        //Address range   Size Device
        //$0000-$07FF	$0800	2KB internal RAM
        //$0800-$0FFF	$0800	Mirrors of $0000-$07FF
        //$1000-$17FF	$0800
        //$1800-$1FFF	$0800
        //$2000-$2007	$0008	NES PPU registers
        //$2008-$3FFF	$1FF8 Mirrors of $2000-2007 (repeats every 8 bytes)
        //$4000-$4017	$0018	NES APU and I/O registers
        //$4018-$401F	$0008	APU and I/O functionality that is normally disabled.See CPU Test Mode.
        //$4020-$FFFF $BFE0 Cartridge space: PRG ROM, PRG RAM, and mapper registers (See Note)

        public byte ReadMemory(int address)
        {
            address &= 0xFFFF;
            if (address < 0x2000)
            {
                return(ram[address & 0x7FF]);
            }
            else if (address < 0x4000)
            {
                return(_ppu.ReadPpuRegister(address));
            }
            else if (address < 0x4020)
            {
                if (address == 0x4016)
                {
                    int val = 0;
                    if (strobingPad)
                    {
                        val = pad1 & 1;
                    }
                    else
                    {
                        val = (pad1 >> padShiftCounter++) & 1;
                    }
                    return((byte)(val |= 0x40));
                }
                else
                {
                    return(_apu.ReadApuRegister(address));
                }
            }
            else
            {
                //$4020-$FFFF $BFE0 Cartridge space: PRG ROM, PRG RAM, and mapper registers (See Note)
                return(_cart.ReadCart(address));
            }
        }