private static int MirrorNametable(UInt16 address, Cartridge.MirrorMode mirrorMode) { int nameTableId = Nametable.NametableId(address); switch (mirrorMode) { case Cartridge.MirrorMode.VERTICAL: if (nameTableId == 0 || nameTableId == 2) { return(0); } else { return(1); } case Cartridge.MirrorMode.HORIZONTAL: if (nameTableId == 0 || nameTableId == 1) { return(0); } else { return(1); } } return(0); }
public void Write(UInt16 address, Cartridge.MirrorMode mirrorMode, byte data) { UInt16 maskedAddress = Nametable.MaskAddress(address); int id = Nametable.MirrorNametable(maskedAddress, mirrorMode); int offset = Nametable.Offset(maskedAddress); nameTable[id, offset] = data; }
public byte Read(UInt16 address, Cartridge.MirrorMode mirrorMode) { UInt16 maskedAddress = Nametable.MaskAddress(address); int id = Nametable.MirrorNametable(maskedAddress, mirrorMode); int offset = Nametable.Offset(maskedAddress); return(nameTable[id, offset]); }