Page 1 of 1

LEGO Island mentioned in XP source code

Posted: Wed Dec 28, 2022 9:29 pm
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);
Source page on GitHub

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.

Re: LEGO Island mentioned in XP source code

Posted: Wed Dec 28, 2022 9:38 pm
by CrabHead
inb4 the entire lego island source code found in win 10 source code KEKW

Re: LEGO Island mentioned in XP source code

Posted: Wed Dec 28, 2022 11:01 pm
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.

Re: LEGO Island mentioned in XP source code

Posted: Thu Dec 29, 2022 1:15 am
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).

Re: LEGO Island mentioned in XP source code

Posted: Wed Jan 04, 2023 11:22 am
by TinglesMagicWords
Incredible!

Software really is just all smoke and mirrors. It blows my mind at times that anything works at all.

Re: LEGO Island mentioned in XP source code

Posted: Sat Jan 07, 2023 10:34 pm
by klegs
I find it funny that as early as Windows XP there were already issues with running LEGO Island,

Re: LEGO Island mentioned in XP source code

Posted: Fri Sep 08, 2023 8:47 pm
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?

Re: LEGO Island mentioned in XP source code

Posted: Sun Sep 10, 2023 3:28 am
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.