Fixing graphical glitches

Discuss PoP1 for DOS here.
David
The Prince of Persia
The Prince of Persia
Posts: 2848
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Fixing graphical glitches

Post by David »

dmitrys wrote: February 28th, 2021, 7:39 am There is also a related bug which is caused by a different function. The top of the pillar base becomes pixelated after the jump where kid's hands were.
The "pixelation" is just the wall behind the pillar appearing where it shouldn't.


Both the previous parts and this part of the bug is caused by the following code:

Code: Select all

	restore_peels();
	draw_wipes(0);
	draw_table(0); // backtable
	//printf("midtable_count = %d\n", midtable_count); // debug
	draw_table(3); // midtable
	draw_wipes(1);
	draw_table(1); // foretable
The game first draws the background wipes and images (backtable), then the prince (midtable), then the foreground wipes and images (foretable).
When the prince is drawn, the game stores what is behind him on the screen. This is called "peel".
In the next frame, this stored image is restored to the screen (restore_peels). (The name comes from "peeling off".)

Since the peel image is made before drawing the foreground images, restoring it will erase any foreground image where it overlaps the prince.

The part of the big pillar at the top of the screen is drawn using a background wipe (black background) and a foreground image.
Peeling will erase the pillar image and restore the black background.
In my fix for the previous part I removed the wipe if the tile above the prince is the top half of a big pillar.

In this part, an additional wall image is drawn after the background wipe, but still before the prince, so the peel restores that instead.

The question is now, why does not happen only on the top of the screen and not elsewhere?

dmitrys wrote: February 28th, 2021, 7:39 am I commented on how I fixed it in the commit for the first fix.
(Here is the commit: https://github.com/NagyD/SDLPoP/commit/ ... 09fde76d8c )

My idea is to move draw_tile_floorright() into the if block:

Code: Select all

#ifdef FIX_BIGPILLAR_JUMP_UP
		if (curr_tile != tiles_9_bigpillar_top)
#endif
		{
			draw_tile_wipe(3);
			draw_tile_floorright();
		}
User avatar
dmitrys
Developer
Developer
Posts: 195
Joined: October 1st, 2020, 6:05 am

Re: Fixing graphical glitches

Post by dmitrys »

I thought I had tried this but had problems with initial room rendering.

But now it seems to work great. Thanks.
David
The Prince of Persia
The Prince of Persia
Posts: 2848
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Fixing graphical glitches

Post by David »

I committed the change I mentioned above: https://github.com/NagyD/SDLPoP/commit/ ... 8350f1fcd7
User avatar
dmitrys
Developer
Developer
Posts: 195
Joined: October 1st, 2020, 6:05 am

Re: Fixing graphical glitches

Post by dmitrys »

I finally found a proper fix for this issue. What happens is the "tile_col" variable contains the value of the column in the next room while the code uses the drawn room to position the guard. So when the guard is bumped by the "spiked()" method, he appears at column 0 or 1 of the drawn room instead of column 0 or 1 of the room to the right, ala column 10/11 of the drawn room.

This issue happens in both PoP1 and SDLPoP. But it does not normally cause any problems since by default guards disappear when they leave the room. The guard is still going to be at the wrong place but he is invisible and is not going to trigger buttons, etc. But when the "offscreen guards disappearing" fix is enabled the guard is actually teleported to the wrong room and can trigger tiles, spikes, etc.

This issue is also happening with chompers and when a guard bumps into a gate in another room. I guess it can be used a trick but its use is limited since a lot of players use DOSBox or do not enable fixes.


I am going to create a PR soon to recalculate the tile column only when the fix is enabled.
Post Reply