Opened 3 years ago

Closed 2 years ago

#12820 closed defect (fixed)

TWINE: boat window rendering is broken (renderPolygonsCopper)

Reported by: mgerhardy Owned by: mgerhardy
Priority: high Component: Engine: TwinE
Version: Keywords:
Cc: Game: Little Big Adventure

Description (last modified by mgerhardy)

This can be seen when using the trajectory idx 15

Use this debug console command to see the problem

set_holomap_trajectory 15

The windows of the ships aren't rendered correctly.

There are a few polygon render methods in the Renderer class that have a "FIXME: buggy" comment.

Attachments (2)

original_trajectory_holomap.jpeg (52.5 KB ) - added by mgerhardy 3 years ago.
scummvm_trajectory_holomap.png (141.6 KB ) - added by mgerhardy 3 years ago.

Download all attachments as: .zip

Change History (13)

by mgerhardy, 3 years ago

by mgerhardy, 3 years ago

comment:1 by mgerhardy, 3 years ago

Description: modified (diff)

comment:2 by mgerhardy, 3 years ago

Renderer::renderPolygonsBopper is the cause of these flickerings

comment:3 by mgerhardy, 3 years ago

This is the ida disassembly result - but atm this is not rendering anything...

#define LOWORD(x) (*((uint16 *)&(x)))
#define LOBYTE(x) (*((uint8 *)&(x)))

#define HIWORD(x) (*(((uint16 *)&(x)) + 1))
#define HIBYTE(x) (*(((uint8 *)&(x)) + 1))

static void memset32(void *target, uint32 val, unsigned int n) {
	uint32 *ptr = (uint32 *)target;
	for (unsigned int i = 0; i < n; ++i) {
		*ptr++ = val;
	}
}

void Renderer::renderPolygonsBopper(int vtop, int32 vsize, uint8 color) const {
	const int screenWidth = _engine->width();
	const int screenHeight = _engine->height();

	uint8 *v2 = (uint8 *)_engine->_frontVideoBuffer.getBasePtr(0, vtop);
	//v2 = screenLockupTable[(uint16)vtop] + frontVideoBuffer;
	int8 *v3 = (int8 *)&_polyTab[(uint16)vtop];
	int v5 = vsize; //(uint16)vbottom - (uint16)vtop + 1;

	int16 v14 = 0; // bx@9
	LOBYTE(v14) = color;

	int j = 0; // ecx@9
	HIWORD(j) = 0;

	do {
		uint16 v16 = *(uint16 *)(v3 + screenHeight * 2);
		int v7 = *(uint16 *)v3;
		v3 += 2;

		uint8 v34 = v16 < (uint16)v7;
		if (!v34) {
			LOWORD(j) = j + 1;
			void *v18 = (void *)(v7 + v2);
			HIBYTE(v14) = v14;
			LOWORD(v7) = v14;
			v7 <<= 16;
			LOWORD(v7) = v14;
			if ((intptr_t)v18 & 1) {
				*(uint8 *)v18 = v14;
				v18 = (char *)v18 + 1;
				--j;
			}
			char v19 = j;
			unsigned int v20 = (unsigned int)j / sizeof(int);
			memset32(v18, v7, v20);
			uint8 *v21 = ((uint8 *)v18 + sizeof(int) * v20);
			for (j = v19 & 2; j; --j)
				*(uint8 *)v21++ = v7;
			LOBYTE(v14) = v14 + 1;
			if (!(v14 & 0xF)) {
				while (1) {
					LOBYTE(v14) = v14 - 1;
					if (!(v14 & 0xF))
						break;
					v2 += screenWidth;
					--v5;
					if (!v5)
						return /*v7*/;
					uint16 v22 = *(uint16 *)(v3 + screenHeight * 2);
					v7 = *(uint16 *)v3;
					v3 += 2;
					v34 = v22 < (uint16)v7;
					if (!v34) {
						LOWORD(j) = j + 1;
						void *v24 = (void *)(v7 + v2);
						HIBYTE(v14) = v14;
						LOWORD(v7) = v14;
						v7 <<= 16;
						LOWORD(v7) = v14;
						if ((intptr_t)v24 & 1) {
							*(uint8 *)v24 = v14;
							v24 = (char *)v24 + 1;
							--j;
						}
						char v25 = j;
						unsigned int v26 = (unsigned int)j / sizeof(int);
						memset32(v24, v7, v26);
						uint8 *v27 = ((uint8 *)v24 + sizeof(int) * v26);
						for (j = v25 & 2; j; --j)
							*(uint8 *)v27++ = v7;
					}
				}
			}
		}
		v2 += screenWidth;
		--v5;
	} while (v5);
}

Version 1, edited 3 years ago by mgerhardy (previous) (next) (diff)

comment:4 by mgerhardy, 3 years ago

hacked in 015fbb079759f3ccf149b1b77d9bd1eaf74844f5 - but still needs a proper fix

comment:5 by mgerhardy, 3 years ago

Summary: TWINE: polygon rendering for the holomap trajectory vehicle rendering is brokenTWINE: polygon rendering for the holomap trajectory vehicle is broken

comment:6 by mgerhardy, 2 years ago

Priority: normalhigh

comment:7 by mgerhardy, 2 years ago

The same happens for the boat in scene 42 Proxim-City @ (Insel Proxi) and 24 Hafen von B�looga @ (Hauptinsel)

comment:8 by mgerhardy, 2 years ago

Summary: TWINE: polygon rendering for the holomap trajectory vehicle is brokenTWINE: boat window rendering is broken

comment:9 by mgerhardy, 2 years ago

Summary: TWINE: boat window rendering is brokenTWINE: boat window rendering is broken (renderPolygonsBopper)

comment:10 by mgerhardy, 2 years ago

Summary: TWINE: boat window rendering is broken (renderPolygonsBopper)TWINE: boat window rendering is broken (renderPolygonsCopper)

comment:11 by mgerhardy, 2 years ago

Owner: set to mgerhardy
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.