Scrolling in Emulator Stutters every 2 Seconds

All aspects of programming on the Commander X16.
Post Reply
Slevin
Posts: 29
Joined: Wed Mar 06, 2024 8:04 pm

Scrolling in Emulator Stutters every 2 Seconds

Post by Slevin »

I've implemented Matt's Tiles demonstration. The goal is to get an infinite horizontal scroll behavior. Unfortunately, running this code in the official emulator results in frame stuttering round about every 2 seconds.

Can it be, that the emulator is responsible for this issue? Maybe the emulator's framerate is not aligned with my monitors 60Hz. Is there a way to config the emulator? Or is the issue somewhere else to fix?

Many thanks
User avatar
desertfish
Posts: 1096
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Re: Scrolling in Emulator Stutters every 2 Seconds

Post by desertfish »

Try running the emulator with -fullscreen .

If your monitor isn't 60hz, tearing will likely occur if the emulator runs in a window because it refreshes at 60hz. But stuttering? Could it be that your computer is too weak and can't keep up with the emulator?
Slevin
Posts: 29
Joined: Wed Mar 06, 2024 8:04 pm

Re: Scrolling in Emulator Stutters every 2 Seconds

Post by Slevin »

Well, doesn't make any difference when running in fullscreen. My CPU takes about 7~8% to run the emulator, the machine should handle it just fine.

However, as long as you say that Matt's code is ok running on the current emulator it might be an issue on my side somehow, which I for now can't resolve. At least I know it's not the code. I'll give it a try next time I spin up a virtual machine running Linux, maybe it's just my Windows config.
TomXP411
Posts: 1781
Joined: Tue May 19, 2020 8:49 pm

Re: Scrolling in Emulator Stutters every 2 Seconds

Post by TomXP411 »

I don't think the emulator supports VSync, so there's no way to synchronize the start of a VERA frame with the start of a host system frame.

Doing so would actually be relatively complicated, since there's some amount of coupling with the X16 system clock, as well. If you delayed a VERA refresh until the host screen refreshed, you'd have to also hold the virtual CPU for the same amount of time, or the emulator would no longer replicate the behavior of hardware.

If it's possible to set a VSync flag in SDL, then it might be worth asking MooingLemur to add that as an option, but I doubt it would happen in R47. That release is already pretty full, with the 65C816 changes.
Slevin
Posts: 29
Joined: Wed Mar 06, 2024 8:04 pm

Re: Scrolling in Emulator Stutters every 2 Seconds

Post by Slevin »

Thanks TomXP411,

it's nothing that has to be done at all, it's just something I've encountered and therefore I want to be sure that this is not a problem with the code but with the current emulating software/hardware chain. It looks like a jitter/hickup, similar to a source vs. player framerate missmatch where the source is slightly slower (resulting in frame doubling). But since there are two layers involved it results additionally in some kind of hickup.

Anyhow, as long as everything else is fine just keep the cookies running.
Thanks and Cheers
funkheld
Posts: 322
Joined: Mon Feb 26, 2024 11:11 am

Re: Scrolling in Emulator Stutters every 2 Seconds

Post by funkheld »

I have a scrolling system with prog8 under windows.
works perfectly.
right/left/up/down with the vera command.
I still have the graphic screen behind it (image layer0) and circles on the graphic screen for testing.

the screen runs wonderfully like oil....

This is due to your system computer or prog-asm, not the x16.

Here I brought in a repeat for testing:
------------------------------
sub sr() {
repeat {
sys.wait(1)

z=z-1
if z==0 {
u=u-1
poke($9F38,u)
z=255
}
poke($9F37,z)
}
}
--------------------------------------

greeting
Attachments
scrollscr.jpg
scrollscr.jpg (75.09 KiB) Viewed 951 times
Post Reply