LEGO Island mentioned in XP source code

Reverse engineering and decompiling LEGO Island's main game binary (LEGO1.DLL)
Post Reply
User avatar
MattKC
Site Admin
Posts: 323
Joined: Mon Aug 22, 2022 1:05 am
Contact:

LEGO Island mentioned in XP source code

Post by MattKC »

While LEGO Island's retail source is yet to be leaked, Windows XP's has! And fascinatingly, it contains a hack/fix specifically for LEGO Island:

Code: Select all

// Lego Island fix
// 0x3f7ffe00 == 1 - 2/0xffff or 2 Z units from the maximum Z.  Integer math is faster
// and doesn't cause FP lib linker issues with the assembly.
INT32* pZ;
pZ = (INT32*)&TLVert[0].sz;
*pZ = (*pZ > 0x3f7ffe00) ? (0x3f7ffe00) : (*pZ);
pZ = (INT32*)&TLVert[1].sz;
*pZ = (*pZ > 0x3f7ffe00) ? (0x3f7ffe00) : (*pZ);
pZ = (INT32*)&TLVert[2].sz;
*pZ = (*pZ > 0x3f7ffe00) ? (0x3f7ffe00) : (*pZ);

The comment isn't super descriptive about exactly what this fixes in LEGO Island, but if you ignore the usage of hex and pointer trickery, the code itself is actually very straightforward. It simply clamps the Z values for each vertex of a triangle at 0.999969 (0x3f7ffe00 in hex). I guess 1.0 or higher cause some sort of problem in the game, and the fact that this fix had to be added at some point implies it used to work this way by default in earlier versions of Windows.

Could be interesting to try finding this code compiled in DDRAW.DLL (or whichever DLL it's in) and nopping it out to see if anything breaks.
User avatar
CrabHead
Posts: 196
Joined: Tue Dec 27, 2022 11:10 pm
Location: Poland
Contact:

Re: LEGO Island mentioned in XP source code

Post by CrabHead »

inb4 the entire lego island source code found in win 10 source code KEKW
KEKW Goin' Flipmode!
User avatar
acidiclight
Posts: 88
Joined: Tue Dec 27, 2022 10:53 pm
Location: MeteoTech Premises
Contact:

Re: LEGO Island mentioned in XP source code

Post by acidiclight »

You know you've made it as a gamedev when there's code in FUCKING WINDOWS ITSELF written SPECIFICALLY to get your game working.
acidic light

I'm a blind game developer. I write code because it's fun.
User avatar
flatrute
Posts: 307
Joined: Sat Dec 17, 2022 11:32 am
Location: Thành phố Hồ Chí Minh, Việt Nam
Contact:

Re: LEGO Island mentioned in XP source code

Post by flatrute »

acidiclight wrote: Wed Dec 28, 2022 11:01 pm You know you've made it as a gamedev when there's code in FUCKING WINDOWS ITSELF written SPECIFICALLY to get your game working.
I remember there is an article about the same thing happened but in Windows 95 and for SimCity respectively.

Edit: Prepositions is hard.
Edit: There are no spaces between the two words...
Edit of edit: I hate plural case (and definite article).
It turns out leaving an Internet identity behind is hard MikeBruh

My username is read as "flatorte".

[deleted] posts index

Avatar source
TinglesMagicWords
Posts: 9
Joined: Thu Dec 08, 2022 11:01 am

Re: LEGO Island mentioned in XP source code

Post by TinglesMagicWords »

Incredible!

Software really is just all smoke and mirrors. It blows my mind at times that anything works at all.
klegs
Posts: 15
Joined: Sat Jan 07, 2023 10:32 pm

Re: LEGO Island mentioned in XP source code

Post by klegs »

I find it funny that as early as Windows XP there were already issues with running LEGO Island,
AlphaGameDeveloper
Posts: 4
Joined: Fri May 05, 2023 5:22 pm
Location: United states of America (Or my own imagination)
Contact:

Re: LEGO Island mentioned in XP source code

Post by AlphaGameDeveloper »

I don't know C/C++, but is this similar to the injection method that Rebuilder uses?

P.S. Would it be possible for me to make my own Windows by recompiling the decomp on GitHub b/c it has the Makefil0 file?
AlphaGameDeveloper
Certified Lunatic

My Links:
User avatar
MattKC
Site Admin
Posts: 323
Joined: Mon Aug 22, 2022 1:05 am
Contact:

Re: LEGO Island mentioned in XP source code

Post by MattKC »

AlphaGameDeveloper wrote: Fri Sep 08, 2023 8:47 pm I don't know C/C++, but is this similar to the injection method that Rebuilder uses?
Nah this code isn't injected into the game, it's just a behavior that DirectDraw carries out specifically to not break LEGO Island.

Which makes me think... I wonder if WINE managed to replicate this too despite their policy of never looking at any of Windows' binary/source code? It feel very esoteric, yet LEGO Island seems to render fine on WINE's ddraw implementation.
AlphaGameDeveloper wrote: Fri Sep 08, 2023 8:47 pm P.S. Would it be possible for me to make my own Windows by recompiling the decomp on GitHub b/c it has the Makefil0 file?
I'm not entirely sure but I think the source is fully recompilable. Of course, don't expect to be able to redistribute whatever you make without getting slapped with a DMCA.
Post Reply