Last active
December 11, 2015 01:08
-
-
Save Palmr/4520944 to your computer and use it in GitHub Desktop.
Return instruction for the gameboy cpu emulator I'm writing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Instructions::doReturn(CPU* cpu, BYTE pOpcode) { | |
if (pOpcode == 0xc9 | |
|| (pOpcode == 0xc0 && cpu->reg->getFlagZ() == 0) | |
|| (pOpcode == 0xc8 && cpu->reg->getFlagZ() == 1) | |
|| (pOpcode == 0xd0 && cpu->reg->getFlagC() == 0) | |
|| (pOpcode == 0xd8 && cpu->reg->getFlagC() == 1)) { | |
cpu->reg->setPC((WORD)((cpu->mem.readByte(cpu->reg->getSP() + 1) << 8) | cpu->mem.readByte(cpu->reg->getSP()))); | |
cpu->reg->incSP(2); | |
cpu->clock.m += 5; | |
cpu->clock.t += 20; | |
} | |
else { | |
cpu->clock.m += 2; | |
cpu->clock.t += 8; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment