Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graphical issues when moving camera position during character movement #551

Open
Tercus opened this issue Jun 8, 2017 · 4 comments
Open
Labels
bug performance vanilla Bugs that exist in the original JA2 game

Comments

@Tercus
Copy link

Tercus commented Jun 8, 2017

I'm getting heavy graphical artefacts when I'm moving the camera, while a character is moving on the screen. It gets a lot worse, if "Merc Lights during Movement" is enabled. If it is disabled, the Mercenary is simply not visible until he has reached his destination

Attached are two videos, because it is hard to explain and it was too difficult to create it as gif. The first video shows how it is without the option enabled and the second one with it enabled.
JA2 Debug.zip

@JAsmine-ja2
Copy link
Collaborator

"Merc Lights during Movement" is known to cause a lot of trouble. This problem is known to v1.13, too. I don't think, they came up with a better solution than deactivating this option.

@JAsmine-ja2 JAsmine-ja2 added the bug label Jun 9, 2017
@lynxlynxlynx lynxlynxlynx added the vanilla Bugs that exist in the original JA2 game label Jun 9, 2017
@chmallon
Copy link

chmallon commented Oct 1, 2017

I think, this is solvable -- mostly by getting rid of unnecessary surfaces for rendering.
When I originally ported JA2, I tried to translate the low-level rendering mechanics faithfully.
It seems, this was faithful enough to also retain this vanilla display bug.
Scrolling is done by copying the screen buffer (aka back buffer) to itself (this also causes the blitting problems with SDL < 2.0.5 and < 1.2.13) while rendering is done on the frame buffer.
Usually (part of) the frame buffer is copied to the screen buffer.
I think the problem is as follows:
When merc lighting during movement is on, this causes parts from the frame buffer, which were not updated nor scrolled, to be copied to the screen buffer.
Probably this copying is triggered by the call chain ExecuteOverhead() -> DeleteSoldierLight() -> LightSpriteDestroy() -> LightSpriteDirty().
This low-level rendering is unnecessarily complicated (and was even more complicated originally when it used DirectX), so by simplifying it, the scroll+moving light glitch could be solved.

Fun experiment:
Try non-video scrolling, i.e. scrolling by re-renderding instead of copying.
Hit ALT+V. (if you did not remove this functionality)
Then scrolling while a luminous merc moves should not jump around anymore.
Though the merc itself will not be visible while scrolling due to a bug in ScrollBackground().

@flaviojs
Copy link
Contributor

flaviojs commented Apr 1, 2019

I was considering creating another issue, but it's probably the same underlying cause so I'll post it here.

After entering cheat mode (CTRL+GABBI) and enabling the display of FPS (CTRL+F), you will see traces of the text while you scroll around. This resembles what you show in the second video.

It gets "fixed" by itself when I stop scrolling. Not sure of the internals, but it feels like it should be marking tiles/sections as dirty (to fully redraw them) but doesn't.

I tried looking at the tile engine and though "here be dragons"...
It looks like the kind of thing that should be "rustified".

Issue #738 mentions "Replace all/most blit code with SDL function calls and load resources as SDL textures". This issue might get fixed when that is implemented.

@lynxlynxlynx
Copy link
Member

So, is anything left to do here, besides potential optimizations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug performance vanilla Bugs that exist in the original JA2 game
Projects
None yet
Development

No branches or pull requests

5 participants