I need some help with fetching opcodes. For some reason, my emulator reads the first 4 opcodes of Pong fine, but the fifth is seen as FFEA, when it should be A2EA.
Here's how I fetch opcodes:
Code:
regs.OP = (unsigned short)( (RAM[regs.PC] << 8) | RAM[regs.PC + 1] );
Here's how I do the classic case/switch statement:
Code:
switch( ((regs.OP & 0xF000) >> 12) )
The emu loads the ROM fine, and in RAM, the contents are correct. So it's not a loading issue.