Tonight's tasks

OK, my major crashing problem is due to the fact that I was handling the stack the opposite of how I should. Pushing values onto the stack first writes the value to where the SP is located, then decrements the stack pointer. Popping off the stack increments the stack pointer, then reads back the value located at SP. With my stack logic updates, all games are at least running without crashing. No more code paths leading to weird places in memory (yay!). Of course, this also means my processor emulator class is most certainly 100% done now (yay again).

After reading over the docs I have determined that instead of doing per-frame rendering (as I'm doing now), I really need to do scanline rendering to most accurately depict the NES hardware's actual system. So it looks like tonight I will be tearing up my PPU logic, as well as throwing together some calculations in notepad to determine proper timings for things like hblank, vsync, as well as the internal clock speeds for everything.

I think what I will do is use MS offsets to determine when to do what next. For example, if I draw 60 times a second, I will, in the tight program loop, check to see if lastRender is >= 16, and if so, render. From what I'm reading, the NES games are VERY dependant on clock speeds for both rendering, as well as the processor. If I'm emulating them out of sync (which I obviously am right now), it will most likely cause all kinds of problems. For example, some games may want to split the screen half-way down. It would do this by modifying the screen scroll value halfway through the rendering of the screen. If I didn't do scanline rendering, this code would simply not work. We'll see how it all pans out in the near future. Stay tune!

2 comments:

TJ Locke said...

Awesome project! I'm very excited to see this progress and learn some low-level programming ideas/implementations in the process.

Tim Sarbin said...

Yeah, I'm just new to blogging so I'll have to find a happy balance between technical details and the general progress :)

Post a Comment