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

HD: World is not rendered #639

Open
link2xt opened this issue May 1, 2024 · 16 comments · May be fixed by #641
Open

HD: World is not rendered #639

link2xt opened this issue May 1, 2024 · 16 comments · May be fixed by #641

Comments

@link2xt
Copy link

link2xt commented May 1, 2024

Steps to reproduce:

  1. Install Linux version vangers_1_45_44317.sh from GOG.com.
  2. Clone this repository at commit 22accbb (current master branch at the time of writing) into ./Vangers
  3. Build the game and copy data files with this script:
#!/usr/bin/env bash
cmake -B build Vangers
cmake --build build -j2
rm -fr safe_place
mkdir safe_place
cp -r "$HOME/GOG Games/Vangers/game/data"/* safe_place
cp -r ./Vangers/data/resource safe_place
cp build/src/vangers safe_place
  1. cd safe_place and run ./vangers

Menus work, but the world is not rendered:
1

The problem is reproducible both with Wayland and Xorg.

@link2xt
Copy link
Author

link2xt commented May 1, 2024

On stderr there are warnings like this when going to the world:

Layout for view 0x58bb2a1dd450 is already done
Layout for view 0x58bb2a1dd3b0 is already done
Layout for view 0x58bb28143f00 is already done
Layout for view 0x58bb2ae7ab70 is already done
Layout for view 0x58bb2ac2ef70 is already done
Layout for view 0x58bb2ac2f0a0 is already done
Layout for view 0x58bb2a1c0200 is already done
Layout for view 0x58bb28db3690 is already done
Layout for view 0x58bb2ae92b20 is already done
Layout for view 0x58bb2ae929e0 is already done
Layout for view 0x58bb2ae928a0 is already done
Layout for view 0x58bb2ae85020 is already done
Layout for view 0x58bb2ae84ee0 is already done
Layout for view 0x58bb2ae84da0 is already done
Layout for view 0x58bb2ae92160 is already done
Layout for view 0x58bb2a1dd450 is already done
Layout for view 0x58bb2a1dd450 is already done
Layout for view 0x58bb2a1dd3b0 is already done
Layout for view 0x58bb2a1dd3b0 is already done
Layout for view 0x58bb28143f00 is already done
Layout for view 0x58bb28143f00 is already done
Layout for view 0x58bb2ae7ab70 is already done
Layout for view 0x58bb2ae7ab70 is already done

Full stdout log:

Set locale. Result:C
"VANGERS: One For The Road" by K-D Lab (SDL Version)
Release (ENG)
XGR_Screen::init
SDL_CreateWindowAndRenderer
SDL_Window created: 1280x720
Load and set icon
SDL_SetRenderDrawColor
SDL_RenderClear
SDL_RenderPresent
SDL_SetHint
XGR32_ScreenSurface = SDL_CreateRGBSurface
SDL_SetSurfacePalette
SDL_CreateTexture sdlTexture
SDL_ShowCursor
window show
window hidden
window show
window focus gained
Joystick not found
Set locale. Result:C
ScriptFile::load_bscriptresource/iscreen/oftr.scb file.
Start load decomp trees
XGR_Screen::set_resolution: 800, 600
XGR32_ScreenSurface = SDL_CreateRGBSurface
SDL_SetSurfacePalette
SDL_CreateTexture sdlTexture
XGR_Screen::set_resolution: 800, 600
Resolution didn't change
iScreenDispatcher::save_data
iScreenDispatcher::save_data
uniVangPrepare
ScriptFile::load_bscriptresource/actint/aci_hi.scb file.
ScriptFile::load_bscriptresource/actint/acs_low.scb file.
Warning: Bad seek in file.
Warning: XStream::seek applies when the end of the file reached. resource/bml/sign.fnt
DiagenDispatcher::init data/room.lst
Strange deltas clockDelta:7 Timer:1
Start load decomp trees
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
  WARNING: layout is already done
vrtMap::analyzeINI thechain/fostral/world.ini
Compressed format detected...
Get compressed tables for V_SIZE:16384
Start load decomp trees
PrepareLight
PalettePrepare
iGameMap::iGameMap
iGameMap::reset
vrtMap::analyzeINI thechain/fostral/world.ini
Compressed format detected...
Start load decomp trees
Strange deltas clockDelta:7 Timer:1
window focus lost
Exit!

@link2xt
Copy link
Author

link2xt commented May 1, 2024

I also built tag 2.0 (commit 60b4dec) with cherry-picked commit 99ba4e5. Same problem there.

@link2xt
Copy link
Author

link2xt commented May 1, 2024

Looking at the history, I suspect HD (#488) which got merged in a343f9b.
So I checked out da1a916 and avcodec fix:

$ git checkout da1a9162bae3221579b92eb580083e4731ac4215
$ git cherry-pick --no-commit 99ba4e5a1fa6da4ff40af36e2b3eb7b5ec526b65
$ git reset

And it works, map renders before HD PR:
1

Then I tested commit a343f9b, there map is black.

@link2xt
Copy link
Author

link2xt commented May 1, 2024

In fullscreen it is also broken.

@link2xt
Copy link
Author

link2xt commented May 1, 2024

World is rendered on the master branch (commit 22accbb) with this patch:

diff --git a/src/road.cpp b/src/road.cpp
index c0b5722..c12b2b0 100644
--- a/src/road.cpp
+++ b/src/road.cpp
@@ -2055,7 +2055,7 @@ void iGameMap::draw(int self)
                FirstDraw = 0;
 //2D Rendring in game.
 #ifdef ACTINT
-               XGR_Obj.set_2d_render_buffer();
+               XGR_Obj.set_default_render_buffer();
                //XGR_Obj.fill(2);
                if(GeneralSystemSkip) {
                        aScrDisp -> redraw();

But I don't understand what exactly this does, "fixed" it by trying to understand the code and changing random things.

@link2xt link2xt changed the title World is not rendered HD: World is not rendered May 2, 2024
@link2xt
Copy link
Author

link2xt commented May 8, 2024

Another patch that "fixes" the rendering of the world:

diff --git a/lib/xgraph/xgraph.cpp b/lib/xgraph/xgraph.cpp
index 9da17c0..4e0457e 100644
--- a/lib/xgraph/xgraph.cpp
+++ b/lib/xgraph/xgraph.cpp
@@ -865,7 +865,9 @@ void XGR_Screen::blitRgba(uint32_t *dstRgba, uint8_t *screenIndexes, uint32_t *s
 				*dstRgba = XGR32_PaletteCache[*screen2DIndexes];
 			} else if (((uint8_t*)screen2DRgba)[3] != 0) {
 				*dstRgba = *screen2DRgba;
-			} else {
+			}
+
+			if (*screenIndexes != 0) {
 				*dstRgba = XGR32_PaletteCache[*screenIndexes];
 			}

This makes default buffer take precedence over 2d buffer. The result is this:
1
Obviously broken (even cursor is not shown), but it shows that map is actually rendered into default buffer.

So apparently the problem is that 2D buffer is not "tranparent", but is black where the map should be.

@link2xt
Copy link
Author

link2xt commented May 8, 2024

Another change:

diff --git a/src/actint/actint.cpp b/src/actint/actint.cpp
index e984445..917080b 100644
--- a/src/actint/actint.cpp
+++ b/src/actint/actint.cpp
@@ -3300,7 +3300,7 @@ void actIntDispatcher::redraw(void)
 			}
 			break;
 	}
-	if(!(flags & AS_FULL_REDRAW)){
+	if(false && !(flags & AS_FULL_REDRAW)){
 		XGR_MouseObj.flags &= ~XGM_PROMPT_ACTIVE;
 		XGR_Obj.fill(0);
 		for(int i = 0; i < curIbs -> backs.size(); i++) {

With only this patch applied the result is this one:
1

So apparently somewhere within this if something draws non-transparent black background where the map should be.

@link2xt
Copy link
Author

link2xt commented May 8, 2024

I have tracked down the problem to this:

diff --git a/src/actint/actint.cpp b/src/actint/actint.cpp
index e984445..a42b7d3 100644
--- a/src/actint/actint.cpp
+++ b/src/actint/actint.cpp
@@ -3304,7 +3304,7 @@ void actIntDispatcher::redraw(void)
 		XGR_MouseObj.flags &= ~XGM_PROMPT_ACTIVE;
 		XGR_Obj.fill(0);
 		for(int i = 0; i < curIbs -> backs.size(); i++) {
-			curIbs -> backs[i] -> show(0);
+			//curIbs -> backs[i] -> show(0);
 		}
 		if(curMode == AS_INV_MODE && curMatrix && curMatrix -> back){
 			curMatrix -> back -> show();

With this change it looks like this:
1

So the problem is that background rendered into 2D buffer here is rendered without proper transparency.
bmlObject::show uses XGR_HIDDEN_FON flag but maybe it does not work as intended?

@link2xt
Copy link
Author

link2xt commented May 8, 2024

Here is another patch:

diff --git a/lib/xgraph/xgraph.cpp b/lib/xgraph/xgraph.cpp
index 9da17c0..578895c 100644
--- a/lib/xgraph/xgraph.cpp
+++ b/lib/xgraph/xgraph.cpp
@@ -446,7 +446,7 @@ void XGR_Screen::putspr(int x,int y,int sx,int sy,void* p,int mode)
 	} else {//Other
 		for(i = 0; i < _sy; i ++){
 			for(j = 0; j < _sx; j ++){
-				if(memBuf[j]){
+				if(memBuf[j] && memBuf[j] != 72){
 					scrBuf[j] = memBuf[j];
 				}
 			}

With this change it looks like this:
1

So it looks like the problem is that background images have 72 as the background color instead of 0.

I have printed curIbs -> backs[i] -> name and there are two items in curIbs -> backs, both pointing to resource/actint/800x600/screens/b600.bmp. So this is the image in question that has broken background.

chr(72) is the letter H and there are indeed a lot of them there in this file. Maybe it means "HIDDEN".

@link2xt link2xt linked a pull request May 8, 2024 that will close this issue
@link2xt
Copy link
Author

link2xt commented May 8, 2024

I made a fix: #641

@caiiiycuk
Copy link
Contributor

That's strange. We built steam version from master and it works fine, isn't it @stalkerg ?

@caiiiycuk
Copy link
Contributor

Prob, GOG resources is broken

@stalkerg
Copy link
Contributor

stalkerg commented May 8, 2024

Which exactly?

@link2xt
Copy link
Author

link2xt commented May 8, 2024

I am running version from GOG, vangers_1_45_44317.sh (sha256 a25e70fe7b1ace77d36968da8a5785b5d23ba1c76ec6b5db183e3d8792ad6c46).

Using this script to build and run (warning, it removes save files too):

#!/usr/bin/env bash
set -e
cmake -B build Vangers
cmake --build build -j2
rm -fr safe_place
mkdir safe_place
cp -r "$HOME/GOG Games/Vangers/game/data"/* safe_place
cp -r ./Vangers/data/resource safe_place

cp Vangers/data/actint/* safe_place/resource/actint/

cp build/src/vangers safe_place
cd safe_place
./vangers

Here is the version of the background that is full of H (72) where it should be transparent:

$ sha256sum resource/actint/800x600/screens/b600.bmp
e9e089597e2bb8cd5b65c55f4528d701a0bb545ef9c3c2b28a9bbff59d3555ea  resource/actint/800x600/screens/b600.bmp

Does steam use newer version of b600.bmp?

By the way Windows version on GOG is 1.46 and Linux version is 1.45. But steam version is probably 2.0?

So GOG version is outdated compared to Steam and its resources cannot be used? Is there a plan to upload 2.0 to GOG?

Also would be nice if you publish sha256sum of all game files so it can be checked that the latest versions of resources are used.

@stalkerg
Copy link
Contributor

@link2xt hello, sorry for the long response, probably we did this changes during HD remastering, in that case we should put all changes into this repo.
We will start discussion.

@link2xt
Copy link
Author

link2xt commented Jul 14, 2024

@stalkerg Why GOG version is outdated? Simple solution would be to upload the latest version to GOG, the same one as released on Steam but compiled without Steam integration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants