Gameboy Emulation - Performance Improvement Ideas

I already implement lazy flag resolving, and it did give a minor performance boost :smiley:

For example my SUB instruction has this as the very first line: https://github.com/SonoSooS/PicoGB/blob/fd01c294529dcfcb0259201d364c338d105b6a42/microcode.c#L1413
Which calls this function, which sets the two operands and the type of the flags that need to be calculated: https://github.com/SonoSooS/PicoGB/blob/fd01c294529dcfcb0259201d364c338d105b6a42/microcode.c#L468-L472
Then once needed for PUSH AF or DAA, I resolve the flags: https://github.com/SonoSooS/PicoGB/blob/fd01c294529dcfcb0259201d364c338d105b6a42/microcode.c#L496

N is inherent to the instruction, it's always a constant value (except for POP AF). Hc is the only flag which needs extra computation to resolve. Carry and Zero are so easy to calculate, and so often used, that it makes sense to calculate them in-line.