dirkwhoffmann / vAmiga

vAmiga is a user-friendly Amiga 500, 1000, 2000 emulator for macOS
https://dirkwhoffmann.github.io/vAmiga
Other
293 stars 24 forks source link

Scroll flickers on Double Dragon 2 #731

Closed Gianmarco72 closed 1 year ago

Gianmarco72 commented 1 year ago

During the opening credits, the text flickers when scrolling upwards. I'm not sure if the issue is only on my iMac 21.5'' Intel i5 (2017), macOS 12.5. On UAE it seems to be perfect. I also remember that on my old A500 (with Kickstart 1.2) the scroll was smooth. Maybe there are some dropped frames?

vAmiga 2.1

Text_1 Text_2
dirkwhoffmann commented 1 year ago

I just had a look at it. The following video has been recorded with vAmiga's screen recorder. Everything is fluent:

https://user-images.githubusercontent.com/12561945/197838291-02049c85-1281-4cd8-9cb7-0d1a6a2a9d88.mp4

However, I can confirm the flickering in normal operation mode. I am almost sure it's simply related to the 50Hz (PAL) /60Hz (TFT) discrepancy. Because the frame skips are so visible, the game seems to be excellent candidate for testing VSYNC mode (which I plan to implement in the near future).

dirkwhoffmann commented 1 year ago

vAmiga will get a real VSYNC mode in the next release. It's not exposed to the GUI yet, but it can be enabled in RetroShell:

BildschirmĀ­foto 2022-11-01 um 15 59 32

After enabling, vAmiga switches to PULSED mode which means that the emulator thread waits for an external pulse before a new frame is computed. Pulses are sent by the GUI in the Metal drawing routine. Because the TFT refreshes at 60Hz, the Amiga's clock frequency increases to somewhat over 8MHz.

With VSYNC mode enabled, Double Dragon II runs smoothly. No more flickering.

I still need to take care of audio. When run in VSYNC mode, the sample frequency has to be adjusted accordingly.

dirkwhoffmann commented 1 year ago

Now, the audio unit is compatible with VSYNC mode, too.

I am still unsure where to integrate the VSYNC option in the GUI. One possible place would be the Chipset panel, because VSYNC has a big impact on the clock frequency. Another possible place would be the Video panel. I am wondering where most users would search for this option... šŸ¤”

nicolasbauw commented 1 year ago

Personally, my first intuition would be to search in the Video panel.

idrougge commented 1 year ago

I definitely wouldn't expect the chipset panel to contain settings for my Macintosh display.

Gianmarco72 commented 1 year ago

Personally, my first intuition would be to search in the Video panel.

I agree too. I would expect to find it in the video panel section.

nicolasbauw commented 1 year ago

Because the TFT refreshes at 60Hz, the Amiga's clock frequency increases to somewhat over 8MHz.

My flat screens support 50 Hz. When I used a PC, UAE switched to 50 Hz when in full screen. And for windowed mode, I can live with a display set permanently at 50 Hz.

dirkwhoffmann commented 1 year ago

Thanks a lot for the feedback! Now I think it's clear that the option needs to be part of the Video panel:

BildschirmĀ­foto 2022-11-03 um 06 53 55

There is a new handy debug option, too: Now, the audio buffer fill level can be observed in the status bar.

dirkwhoffmann commented 1 year ago

I just got aware of the fact that later Macs can run in 50Hz mode:

BildschirmĀ­foto 2022-11-03 um 08 09 07

Together with the new VSYNC option this is great news. It means that vAmiga can run at native speed with perfect frame timing (it already does so on my dev machine).

@mithrendal: If iPads can run in 50Hz mode, too, this could also be a great option for the Web port.

mithrendal commented 1 year ago

vAmiga switches to PULSED mode which means that the emulator thread waits for an external pulse before a new frame is computed.

vAmigaWeb has a pulsed mode from the beginning on ... same as vc64web ... i.e. the HTML5 requestAnimationFrame event callback triggers the execution and display of one amiga frame.

In case that the display has a higher refresh rate than 50Hz (typically 60Hz) some emulation frames will be skipped ... resulting in a 50 Hz emulation but in a not so smooth motion on amiga games ... if smooth motion has a higher priority than emulation speed to the user the vsync switch would help to get it execute an amiga frame on each display frame right ?

I will look into it...

PS: what is the difference between NTSC and VSYNC on a 60Hz display ? Is the difference only the resolution of emulated screen ? What about the sound speed ? I bet the NTSC plays at a higher speed than the VSYNC at 60, right?

dirkwhoffmann commented 1 year ago

what is the difference between NTSC and VSYNC on a 60Hz display ?

In PERIODIC mode, frame computation is triggered by a 60 Hz timer which runs side by side with the 60 Hz Metal drawing routine. In PULSED mode, frame computation is triggered by the Metal drawing routine itself. Hence, PULSED mode is more robust in this case as it cannot get out of sync with the drawing routine.

I bet the NTSC plays at a higher speed than the VSYNC at 60, right?

No. Independent of the current mode (PULSED PAL, PERIODIC PAL, PULSED NTSC, PERIODIC NTSC), the Muxer always aims at producing 44100 sound samples per second.

dirkwhoffmann commented 1 year ago

Fixed in v2.2b1