Stuck in unecessary subroutine loops

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
jotac
Posts: 12
Joined: Wed Feb 17, 2021 1:08 pm

Stuck in unecessary subroutine loops

Post by jotac » Wed Mar 03, 2021 3:44 pm

Hi folks!

I have my CPU and PPU background rendering implemented and I can run Donkey Kong and see its menu transition to the game map and see donkey kong.
However, the game is extremely slow. I measured the game loop and it executes fast (both the clocking of the system PPU and CPU and the SDL rendering). The main game loop does the following on average in time:
- system clock (cpu/ppu clocks + NMI): 900ns on average
- rendering: 487200ns when a frame is complete draw
- event processing: 9800ns

So that leads me to believe I am stuck in some subroutine more time than I should in terms of clock ticks.

Here is a demo of what I see:

https://drive.google.com/file/d/19DFxr3 ... sp=sharing

User avatar
Quietust
Posts: 1719
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: Stuck in unecessary subroutine loops

Post by Quietust » Wed Mar 03, 2021 6:03 pm

jotac wrote:
Wed Mar 03, 2021 3:44 pm
- system clock (cpu/ppu clocks + NMI): 900ns on average
- event processing: 9800ns
I'm not sure exactly what those numbers are supposed to mean, but if you want to emulate at full speed then the CPU needs to take less than 559ns to emulate a single cycle; similarly, the PPU needs to take less than 186ns per cycle on average.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

jotac
Posts: 12
Joined: Wed Feb 17, 2021 1:08 pm

Re: Stuck in unecessary subroutine loops

Post by jotac » Fri Mar 26, 2021 6:13 pm

Thx Quietust, ended up being a bug with an SDL version where polling for events was way too slow.

Post Reply