vujadin / KhaNES

NES emulatior written in Kha/Haxe - ported from vNES
21 stars 3 forks source link

Question about CPU.hx #1

Open lucas-aragno opened 6 years ago

lucas-aragno commented 6 years ago

Hey ! first that all nice project! I'm reading different emulator implementations trying to learn a little bit more about how they work in im learning a lot from this codebase. Although I have a small question that you might be able to help me with.

I don't fully understand the values on the cycTable on the CPU.hx implementation could you explain what those numbers mean?

Thanks in advance!

vujadin commented 6 years ago

Hi. Numbers in cycTable means nothing in current implementation. You can safely delete that table and the emu will work just fine. The idea was "probably" (have in mind that I'm not original author, I just ported it from JAVA) to make CPU 'cycle accurate' and cycTable holds number of cycles each CPU instruction takes to execute.

'...Many games would make changes mid-frame so that the PPU would do one thing for one part of the screen and something else for the other — often used for split scrolling or rendering a score bar. This required precise timing and knowing exactly how many CPU cycles each instruction used. Things like this make emulation hard...'

It ended up with simpler (and less accurate) but faster method sacrificing overall emulator accuracy/quality (graphics glitches can be seen in games like MikeTyson PunchOut, Dracula...).