openfodder icon indicating copy to clipboard operation
openfodder copied to clipboard

Helicopter intro not scrolling smoothly

Open vanfanel opened this issue 6 years ago • 3 comments

Hi!

I am at last using my own built GNU/Linux version of OpenFodder. Its built against latest SDL 2.0.10, etc and works fine.

However, I have observed that the helicopter intro sequence is not smooth as in Amiga and RiscOS (RiscOS version runs natively on the Pi, BTW!). The game originally synced video during this sequence to vsync, so it was ~50FPS, while OpenFodder seems to be doing about half-the-framerate, which in a modern display would be ~30FPS. I am sure the solution would be to allow OpenFodder to render this sequence "as fast as possible", so SDL2 blocks on the rendering function: SDL_RenderPresent() is synchronous so it blocks if VSYNC is ON until VSYNC arrives. DO NOT rely on SDL_Delay() for video speed control, because it will generate micro-stuttering in this smooth scrolling sequence: let the game sync to vsync, so video will be smooth no matter what exact physical display rate is.

vanfanel avatar Sep 22 '19 12:09 vanfanel

Thanks for the report,

I haven't really had time to work on OF lately, but no doubt you are probably correct as the "sleep" portion of the engine is based on the DOS port (although it was changed, as the DOS version ran too fast in game, and way too fast in the menu - compared to the Amiga version)

segrax avatar Sep 28 '19 06:09 segrax

Now that 1.6.0 is out and you are again on it, maybe the scrolling sequences can be revisited? Just let it run as fast as possible, limited by VSYNC as in an Amiga game, that will do! :)

vanfanel avatar Jan 06 '20 17:01 vanfanel

Now that 1.6.0 is out and you are again on it, maybe the scrolling sequences can be revisited? Just let it run as fast as possible, limited by VSYNC as in an Amiga game, that will do! :)

I also think it is a great idea!

drozumek avatar Feb 04 '20 12:02 drozumek

Briefing screen is very choppy on windows.

csrednicki avatar May 28 '23 22:05 csrednicki

hey @vanfanel ,

ive taken a look at this, and the problem i found with just VSYNC, is it goes too fast. The Amiga seems to take about 6 seconds for the entire scene based on a couple of random CF videos i looked at on youtube.

On my machine with just vsync, OF takes 3 seconds. That being said, the current release takes about 7 seconds.. so it is definitely running slower than it should be.

I can get it closer to the Amiga by slightly reducing the delay delta for these screens

segrax avatar Jun 01 '23 22:06 segrax

@segrax With just VSYNC (no delay deltas at all) on a 60Hz screen mode, it should run exactly as fast as the Amiga version, and totally smooth. Delay deltas always cause small stuttering... Don't use delays, please, use VSYNC.

vanfanel avatar Jun 02 '23 08:06 vanfanel

I've recorded how it looks under Windows 11 https://github.com/OpenFodder/openfodder/assets/12281282/783089f5-bfb2-481c-81f7-12e26749f4bd and this is how it should look based on original https://youtu.be/1XUqK4l3VAU?t=186

csrednicki avatar Jun 02 '23 09:06 csrednicki

@vanfanel This is how it looks without the delay and with SDL_RENDERER_PRESENTVSYNC set.. 60Hz display mode

https://github.com/OpenFodder/openfodder/assets/1327406/3545e4ab-3c3c-40bd-9186-acf824a4c553

segrax avatar Jun 03 '23 12:06 segrax

@segrax That's expected on a 60Hz mode, but it's perfectly fine: It has the speed of an NTSC Amiga. On a 50Hz mode, it should have the same speed as in a PAL Amiga.

vanfanel avatar Jun 03 '23 12:06 vanfanel

@segrax Helicopter animation in this version is way too fast, it has duration of around 2 seconds. In Amiga PAL version it has 7 seconds. Even in 60Hz it should take around 6 seconds. I've captured original animation under winuae 5 in 50/60Hz.

50Hz: https://github.com/OpenFodder/openfodder/assets/12281282/5f9644bf-8981-4ed0-9a10-3aac17db8173

60Hz: https://github.com/OpenFodder/openfodder/assets/12281282/a4aea453-b294-4e1c-8845-7b854d2b496f

csrednicki avatar Jun 03 '23 22:06 csrednicki

alright, turns out the PC and Amiga version have slightly different data for the helicopter sequence, PC version basically doubled all the values

Its still not a perfect match to the original, but i don't have the time to single step debug it vs the amiga version at the moment to find the exact difference. the code looks good to the eye, so its probably something simple.

we are displaying slightly more of the screen than the original, so that maybe a factor too

https://github.com/OpenFodder/openfodder/assets/1327406/e55dff6a-752a-4a5f-b403-98cdf11d4326

segrax avatar Jun 04 '23 05:06 segrax

@segrax wow, this looks very smooth! Is the sound from amiga version or pc because it sounds different than on amiga? Great work!

csrednicki avatar Jun 04 '23 13:06 csrednicki

for some reason the audio in the video i posted sounds much worse than it actually does on my machine but..

the amiga sound/music has always been slightly off, im not really sure why.. the RJP/Paula code is from ScummVM, so i don't really know much about it

but it does sound like there is two problems,

  1. one instrument is louder in OF than on the Amiga
  2. the track starts playing from an offset 1 or 2 seconds later on the Amiga than in OF

this one is better... but still not correct, ive also just updated the Paula code from ScummVM

https://github.com/OpenFodder/openfodder/assets/1327406/194b6021-6ac0-48e7-9018-4f5e1acd36d1

segrax avatar Jun 04 '23 21:06 segrax

@segrax Finally got to see the progress with this after building latest sources! Incredible, scroll is now PERFECT!

Too bad I can't play the actual game :(

https://github.com/OpenFodder/openfodder/issues/69

vanfanel avatar Jun 07 '23 16:06 vanfanel

So was the problem fixed?

drnovice avatar Jul 06 '23 10:07 drnovice

Yes, I will close this now that we are in super-happy-smoothy land!

vanfanel avatar Jul 06 '23 10:07 vanfanel