private UInt16 ReadWord(UInt16 address) { byte low = CpuRead(address); byte high = CpuRead((UInt16)(address + 1)); return(BitMagic.Combine(high, low)); }
private UInt16 StackPopWord() { byte low = StackPop(); byte high = StackPop(); return(BitMagic.Combine(high, low)); }
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); }
public bool ABS() { byte low = CpuRead(PC++); byte high = CpuRead(PC++); address = BitMagic.Combine(high, low); return(false); }
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); }
// 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++; }
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); }