WEBVTT
Kind: captions
Language: en

00:00:02.500 --> 00:00:05.300
As the great philosopher Sonic the Hedgehog once said...

00:00:08.533 --> 00:00:12.633
You know it always makes me laugh a little bit when someone calls me "the LEGO Island guy", or

00:00:12.633 --> 00:00:15.900
my personal favorite, "the guy that's obsessed with LEGO Island".

00:00:15.900 --> 00:00:19.016
I mean yeah I've put an ungodly amount of effort into that game,

00:00:19.016 --> 00:00:21.366
even technically flying to another country for it, but

00:00:21.366 --> 00:00:26.166
out of all of the videos on my channel, LEGO Island is the main subject of only 3 of them.

00:00:26.166 --> 00:00:30.233
And to be totally honest, I don't actually play LEGO Island,

00:00:30.233 --> 00:00:31.683
at least not as an adult.

00:00:31.683 --> 00:00:33.183
Yeah I know, blasphemy.

00:00:33.183 --> 00:00:34.916
Santa Claus isn't real either, by the way.

00:00:34.916 --> 00:00:39.416
The fact is, it's a very short game with only about 30 minutes of gameplay for the average adult,

00:00:39.416 --> 00:00:43.416
and the puzzles and races are hardly challenging beyond the age of like 10.

00:00:43.416 --> 00:00:47.033
It is nostalgic, and you can tell the developers poured a lot of love and energy into it,

00:00:47.033 --> 00:00:50.066
but I don't think I've played it casually since...

00:00:50.066 --> 00:00:52.566
well, hell probably not since my let's play from 2015 -

00:00:52.566 --> 00:00:53.766
- please don't look that up.

00:00:53.766 --> 00:00:55.933
That's right, I'm putting my foot down!

00:00:55.933 --> 00:00:59.000
I'm tired of being known as "the LEGO Island guy".

00:01:03.366 --> 00:01:06.416
So I've decided to spend the next few years working on LEGO Island.

00:01:06.416 --> 00:01:07.883
Okay, so... why?

00:01:07.883 --> 00:01:13.216
Why would I want to decompile a game that I just admitted I have very little interest in regularly playing?

00:01:13.216 --> 00:01:16.450
Well, some of it is the first thing I mentioned, nostalgia, but

00:01:16.450 --> 00:01:18.733
actually a lot of it is the second.

00:01:18.733 --> 00:01:20.600
The more I've looked into the development of this game,

00:01:20.600 --> 00:01:23.050
the more I've delved into the code that comprises it,

00:01:23.050 --> 00:01:25.416
the more fascinated I've become.

00:01:25.416 --> 00:01:30.083
This was not some phoned-in hack job like a lot of branded video games we could talk about.

00:01:30.083 --> 00:01:33.516
This was a real labor of love by a group of people who were passionate about the kind of

00:01:33.516 --> 00:01:37.100
immersive experience they could make for kids with this brand new technology.

00:01:37.100 --> 00:01:40.050
And by brand new, I mean pretty revolutionary.

00:01:40.050 --> 00:01:45.116
3D games had obviously existed before, but they'd almost always been in confined spaces.

00:01:45.116 --> 00:01:48.000
 LEGO Island was one of the first to actually be open world.

00:01:48.000 --> 00:01:52.400
To let you stand on a rooftop and see an entire civilization stretching out in front of you.

00:01:52.400 --> 00:01:55.966
Which, the developers admitted, is why it's an island rather than a city.

00:01:55.966 --> 00:02:00.633
So they could have an in-universe reason to limit how much geometry had to be rendered at any given time.

00:02:00.633 --> 00:02:04.766
And it did all of this with, in retrospect, some pretty limited resources.

00:02:04.766 --> 00:02:08.683
Keep in mind, this was before the widespread adoption of 3D accelerated video cards,

00:02:08.683 --> 00:02:12.883
so the game had to be optimized enough to render entirely on the CPUs of the era.

00:02:12.883 --> 00:02:19.150
It also had to stream music, animation, video, and texture data off a measly 4x CD-ROM drive.

00:02:19.150 --> 00:02:23.683
That's only 600 KB/s, less than most peoples' internet connections today.

00:02:23.683 --> 00:02:25.716
Unless you're archive.org, of course.

00:02:25.716 --> 00:02:27.833
And there were no big name game engines back then,

00:02:27.833 --> 00:02:32.166
nearly all of this stuff was custom-written specifically for LEGO Island.

00:02:32.166 --> 00:02:36.133
For me, this game has become interesting in almost every single way...

00:02:36.133 --> 00:02:38.333
...except actually playing it.

00:02:38.333 --> 00:02:40.533
Not that I didn't think it was fun as a kid, just that

00:02:40.533 --> 00:02:44.000
as an adult, what I find fun about it is completely different.

00:02:44.000 --> 00:02:49.083
And that fascination with the technology is why for years I've wanted a LEGO Island decompilation.

00:02:49.083 --> 00:02:50.466
What is a decompilation?

00:02:50.466 --> 00:02:55.683
Pretty much exactly what it sounds like, converting compiled machine code back into source code.

00:02:55.683 --> 00:03:00.466
If you're in these nerdy retro gaming circles, you're probably already aware of some of the high profile ones.

00:03:00.466 --> 00:03:04.266
They take a lot of time and effort, so it's usually big news when one actually finishes.

00:03:04.266 --> 00:03:07.416
In fact "decompilation" I think is kind of a misleading word.

00:03:07.416 --> 00:03:09.733
It makes it sound like it's just compiling in reverse,

00:03:09.733 --> 00:03:13.666
like you can just pass it through some program and the whole thing is automatic.

00:03:13.666 --> 00:03:17.166
And it would be nice if it worked that way, but no.

00:03:17.166 --> 00:03:19.983
Compiling is considered a lossy process.

00:03:19.983 --> 00:03:24.933
When you write code, you're essentially giving the compiler a lot of instructions for what you want your program to do.

00:03:24.933 --> 00:03:28.566
But your program doesn't actually need to know most of that stuff in order to run.

00:03:28.566 --> 00:03:32.166
It doesn't care about function names or structs or classes,

00:03:32.166 --> 00:03:36.416
and more importantly, machine code doesn't really have the concept of variables.

00:03:36.416 --> 00:03:39.366
All it really has are registers and memory addresses,

00:03:39.366 --> 00:03:43.916
and it's up to the compiler to use those to do whatever you told it to do with your code.

00:03:43.916 --> 00:03:50.650
Decompilation is largely about trying to restore that information through context clues or educated guesses.

00:03:50.650 --> 00:03:53.533
A common analogy is that it's like trying to unbake a cake.

00:03:53.533 --> 00:03:58.100
You can't just stick it in a de-oven and unmix it to get all the ingredients back.

00:03:58.100 --> 00:04:00.383
But you can, with enough time and effort,

00:04:00.383 --> 00:04:04.483
reverse engineer a cake using context clues and educated guesses

00:04:04.483 --> 00:04:07.966
until you arrive at a recipe that produces more or less the same thing.

00:04:07.966 --> 00:04:10.283
And that is essentially decompilation.

00:04:10.283 --> 00:04:12.216
Not really an automated process,

00:04:12.216 --> 00:04:15.850
more like hand-translating code from one language to another,

00:04:15.850 --> 00:04:20.716
where the original code happens to be heavily obfuscated with little to no documentation.

00:04:20.716 --> 00:04:25.300
As you might expect, it's definitely challenging, but more than that it's just time consuming.

00:04:25.300 --> 00:04:28.766
Most completed decomps took years, even for a team of people.

00:04:28.766 --> 00:04:33.250
This decomp of Diablo reportedly took someone 3 years unemployed to complete,

00:04:33.250 --> 00:04:37.733
It's a tremendous commitment that most people simply don't have the time to follow through with.

00:04:37.733 --> 00:04:41.166
Do I think my chances of completing a LEGO Island decomp are any higher?

00:04:41.166 --> 00:04:42.866
No, not really.

00:04:42.866 --> 00:04:47.633
Usually decomp is reserved for widely popular games with high demand for modding or porting,

00:04:47.633 --> 00:04:50.900
especially if it's stranded on an old increasingly expensive console

00:04:50.900 --> 00:04:52.966
that still isn't perfectly emulated.

00:04:52.966 --> 00:04:55.450
LEGO Island is... none of those things.

00:04:55.450 --> 00:04:58.233
Like me, most people aren't interested in playing it regularly,

00:04:58.233 --> 00:05:04.400
and since it's on PC, I've already been able to write fixes and improvements through the much simpler process of injection.

00:05:04.400 --> 00:05:07.716
So what benefit would a decomp even provide?

00:05:07.716 --> 00:05:12.533
Well to be honest, mostly just a look at one of the most interesting codebases I've ever seen.

00:05:12.533 --> 00:05:14.600
How does the game actually work?

00:05:14.600 --> 00:05:18.350
How exactly do the game's infamous streaming asset packages work?

00:05:18.350 --> 00:05:22.783
Why does the game glitch out and crash whenever you try exiting on modern PCs?

00:05:22.783 --> 00:05:26.550
These questions, and many more, are what I'm hoping to answer with this project, and

00:05:26.550 --> 00:05:29.416
while technically a decomp isn't necessary to answer those,

00:05:29.416 --> 00:05:31.883
I figure if I'm going to be putting a lot of effort into reverse engineering

00:05:31.883 --> 00:05:35.066
and investigating anyway, I may as well go all the way.

00:05:35.066 --> 00:05:38.700
If I'm successful, we'll get a codebase that we can do whatever we want with.

00:05:38.700 --> 00:05:42.500
So that's what I'm doing, and yes, I said "if" I'm successful.

00:05:42.500 --> 00:05:45.733
This is part 1 of a series that I have no idea how long is gonna take

00:05:45.733 --> 00:05:47.900
or if it'll even be completed at all.

00:05:47.900 --> 00:05:51.450
I just think it'll be a lot of fun and hope we can at least get somewhere with it.

00:05:51.450 --> 00:05:53.766
But don't worry, this isn't all the channel is going to be now.

00:05:53.766 --> 00:05:56.533
My mind works best if I can rotate between a few projects, 

00:05:56.533 --> 00:05:58.350
so you'll be seeing some other stuff too.

00:05:58.350 --> 00:06:01.316
And it won't be another five months until the next one either.

00:06:01.316 --> 00:06:01.966
Hopefully.

00:06:01.966 --> 00:06:04.266
But no matter what happens, I hope you enjoy the journey.

00:06:04.266 --> 00:06:05.833
Let's get started.

00:06:12.216 --> 00:06:16.800
Now to begin, I should mention that this is not the first time I've tried to decompile this game.

00:06:16.800 --> 00:06:19.850
My first attempt was actually way back in 2019.

00:06:19.850 --> 00:06:21.200
Yeah, remember that?

00:06:21.200 --> 00:06:23.383
The world before the coronary virus?

00:06:23.383 --> 00:06:25.933
Doesn't that feel like an innocent and naive time now.

00:06:25.933 --> 00:06:27.466
And speaking of naive,

00:06:27.466 --> 00:06:30.566
I started that decomp around September and made the hilarious prediction

00:06:30.566 --> 00:06:34.083
that we'd be getting in-game by the end of the year.

00:06:39.183 --> 00:06:42.133
To be fair, it's not like I've been working on it consistently since then.

00:06:42.133 --> 00:06:44.833
I went through a couple bursts of productivity early on, but

00:06:44.833 --> 00:06:47.883
back then I was making it a lot harder on myself than I needed to.

00:06:47.883 --> 00:06:53.616
I was trying to decompile by looking at the game's raw assembly and hand-translating it line-by-line into C++,

00:06:53.616 --> 00:06:58.716
and this is just an incredibly difficult way to do it, and it's kinda why I gave up so early.

00:06:58.716 --> 00:07:01.883
Naturally, nobody really does it this way, at least not anymore.

00:07:01.883 --> 00:07:04.350
What they actually do is load it up into something like Ghidra,

00:07:04.350 --> 00:07:07.100
a free open source tool developed by the NSA.

00:07:07.100 --> 00:07:08.950
Yeah, your tax dollars at work!

00:07:08.950 --> 00:07:14.266
Ghidra will analyze a function in assembly and make a best effort attempt to decompile it into C.

00:07:14.266 --> 00:07:16.566
However, what you'll get at first is probably something that

00:07:16.566 --> 00:07:19.466
only vaguely resembles any C you've ever seen before.

00:07:19.466 --> 00:07:24.183
Indeed the first time I saw this years ago, I was confused and wondered what the point was.

00:07:24.183 --> 00:07:27.350
I mean, is it really *that* much more readable than x86 assembly?

00:07:27.350 --> 00:07:30.316
But what I didn't realize was this is where you come in.

00:07:30.316 --> 00:07:35.583
Ghidra figures out what it can on its own, but by giving it more information, the better of a job it can do.

00:07:35.583 --> 00:07:39.066
By specifying structs, enums, function names, and variables names,

00:07:39.066 --> 00:07:41.033
you can turn something that looks like this...

00:07:41.100 --> 00:07:44.700
into something that almost looks like it was written by a human being.

00:07:44.700 --> 00:07:48.400
While the code still may not be recompilable out of the gate,

00:07:48.400 --> 00:07:52.150
Ghidra calls it pseudocode and gives no guarantee that it can be used like regular code

00:07:52.150 --> 00:07:56.050
this at least is much more readable than x86 assembly,

00:07:56.050 --> 00:07:59.866
and you can work with it and smooth it out until it is recompilable.

00:07:59.866 --> 00:08:03.600
Congratulations you just generated source code from a compiled executable!

00:08:03.600 --> 00:08:06.383
This is why I say "decompilation" is a bit of a misnomer.

00:08:06.383 --> 00:08:08.916
You're not getting back the exact same code that went in,

00:08:08.916 --> 00:08:13.333
in fact, if you did recompile this code, even though it does all of the same things,

00:08:13.333 --> 00:08:17.000
it probably wouldn't result in the same machine code that you decompiled from

00:08:17.000 --> 00:08:19.100
at least, not without a lot more trial and error.

00:08:19.100 --> 00:08:21.650
Several factors from compiler and linker flags 

00:08:21.650 --> 00:08:24.450
to the exact order and placement of things in the code

00:08:24.450 --> 00:08:26.933
will influence how the compiler emits machine code,

00:08:26.933 --> 00:08:30.716
despite very minimally affecting overall functionality, if at all.

00:08:30.716 --> 00:08:37.183
And that's assuming you're using the exact same compiler and version of that compiler that the original developers did too.

00:08:37.183 --> 00:08:40.833
Basically there are a lot of factors to getting perfectly matching assembly and

00:08:40.833 --> 00:08:45.400
it's up to you much you want to figure all those things out to get a perfect byte matching decomp.

00:08:45.400 --> 00:08:47.966
But how exactly do you get information to give to Ghidra

00:08:47.966 --> 00:08:49.550
so its decomp cleans up?

00:08:49.550 --> 00:08:53.600
Well, unfortunately there isn't really a definitive answer for this.

00:08:53.600 --> 00:08:55.750
As unhelpful as it is to say,

00:08:55.750 --> 00:08:58.616
you just have to do what you can to figure it out.

00:08:58.616 --> 00:09:01.550
If you can find a part of the code where you do recognize what's happening,

00:09:01.550 --> 00:09:04.883
you can probably start naming some of the variables and function names.

00:09:04.883 --> 00:09:10.500
Then if you look at the code that uses those functions and variables, you might be able to recognize what they're doing,

00:09:10.500 --> 00:09:11.533
so on and so on.

00:09:11.533 --> 00:09:15.133
And again, the more information you give you Ghidra, the better its decomps will be across the board,

00:09:15.133 --> 00:09:19.966
and eventually it'll all kind of start to make sense, at least in theory.

00:09:19.966 --> 00:09:23.316
But if this is sounding like a long and laborious process, well,

00:09:23.316 --> 00:09:25.350
now you know why decomps take so long...

00:09:25.350 --> 00:09:27.633
Unless you're getting paid to do it, you really just have to do it because

00:09:27.633 --> 00:09:31.566
you're passionate and excited about making sense of obfuscated code.

00:09:32.116 --> 00:09:33.466
I still don't know why I don't have a girlfriend.

00:09:33.466 --> 00:09:36.866
But the good news is I'm really describing the worst case scenario here.

00:09:36.866 --> 00:09:38.366
Games don't run in a vacuum,

00:09:38.366 --> 00:09:42.333
at some point they'll have to make a call to the underlying operating system or hardware.

00:09:42.333 --> 00:09:46.250
Unless you're really unlucky, a lot of this stuff will have been documented somewhere before.

00:09:46.250 --> 00:09:49.200
For game consoles, you may have to rely on

00:09:49.200 --> 00:09:51.233
legally dubious leaked development manuals

00:09:51.233 --> 00:09:53.316
but in the case of desktop operating systems,

00:09:53.316 --> 00:09:55.700
their functions are usually pretty well documented.

00:09:55.700 --> 00:10:00.100
A Windows executable will in fact usually contain information in its import table about

00:10:00.100 --> 00:10:03.333
precisely what system calls from which DLLs it needs to run,

00:10:03.333 --> 00:10:06.700
and these function names will appear in Ghidra's pseudocode automatically.

00:10:06.700 --> 00:10:10.416
For example, if you see some code calling Windows' CreateWindow function,

00:10:10.416 --> 00:10:11.850
you know that that code...

00:10:11.850 --> 00:10:12.416
...well...

00:10:12.416 --> 00:10:13.533
...creates a window.

00:10:13.533 --> 00:10:17.466
Stuff like this will at least give you a starting point, albeit a fairly small one. 

00:10:17.466 --> 00:10:21.466
But depending on the game and how lucky you are, you may be able to get a lot more information.

00:10:21.466 --> 00:10:25.000
If you're extremely lucky, you'll be able to snag some debug symbols.

00:10:25.000 --> 00:10:28.216
Remember how I said a lot of information doesn't get included in compiled builds

00:10:28.216 --> 00:10:30.566
because it's not necessary for the program to run?

00:10:30.566 --> 00:10:34.983
That is true, unless you're a developer trying to find problems in the code.

00:10:34.983 --> 00:10:38.566
Then you pretty explicitly do want a way to relate the compiled build

00:10:38.566 --> 00:10:40.100
back to the original source code,

00:10:40.100 --> 00:10:42.700
and debug symbols are exactly that.

00:10:42.700 --> 00:10:46.783
Debug symbols will usually define global variables, function names,

00:10:46.783 --> 00:10:50.150
the source code file and line that each instruction came from,

00:10:50.150 --> 00:10:53.850
and can sometimes even define classes and their members and methods.

00:10:53.850 --> 00:10:56.183
This gives you a tremendous amount of help with decompiling because

00:10:56.183 --> 00:10:59.666
a lot of that educated guesswork becomes simply unnecessary.

00:10:59.666 --> 00:11:03.883
As such, debug symbols are almost never included with the final release of a program.

00:11:03.883 --> 00:11:07.316
Whenever they are, it's usually a grave mistake by the developer.

00:11:07.316 --> 00:11:12.100
That being said, a surprising number of PlayStation 2 games have indeed shipped with symbols,

00:11:12.100 --> 00:11:15.183
to the point where there's even an online index listing them all.

00:11:15.183 --> 00:11:17.700
Symbols can also be found on pre-release versions of games,

00:11:17.700 --> 00:11:20.633
like betas or review copies sent out for testing.

00:11:20.633 --> 00:11:22.433
Obviously these are not intended for public use

00:11:22.433 --> 00:11:24.683
and the legality of obtaining them is...

00:11:24.683 --> 00:11:25.833
...also dubious,

00:11:25.833 --> 00:11:27.983
but they don't call it hacking for no reason.

00:11:27.983 --> 00:11:29.516
Now how does that relate to LEGO Island?

00:11:29.516 --> 00:11:30.250
It doesn't.

00:11:30.250 --> 00:11:31.983
Despite all attempts to track some down,

00:11:31.983 --> 00:11:34.366
Mindscape did a good job of not letting any leak.

00:11:34.366 --> 00:11:38.200
But we do have some luck due to the way that LEGO Island was deployed.

00:11:38.200 --> 00:11:40.550
The game was split into two separate executables,

00:11:40.550 --> 00:11:42.850
ISLE.EXE, which is the front-end,

00:11:42.850 --> 00:11:46.216
and LEGO1.DLL, which contains the vast majority of the code.

00:11:46.216 --> 00:11:49.833
An executable's import table is not just limited to calls from the OS,

00:11:49.833 --> 00:11:54.533
calls to any DLL will usually be listed here, and LEGO1 is no exception.

00:11:54.533 --> 00:11:57.633
That means a decent amount of functions are already fully documented.

00:11:57.633 --> 00:12:02.250
Not just their names, but also their return values, calling conventions, and the parameters they take.

00:12:02.250 --> 00:12:05.000
Again, this gives us a starting point we can extrapolate from.

00:12:05.000 --> 00:12:09.266
While back in 2019 I focused all of my attention on the much more important LEGO1 DLL,

00:12:09.266 --> 00:12:13.116
I decided for this attempt, I'd start with the much simpler ISLE EXE.

00:12:13.116 --> 00:12:17.433
While it isn't quite as exciting, it would still be great to know how exactly to drive the game

00:12:17.433 --> 00:12:19.266
if we wanted to make a frontend of our own.

00:12:19.266 --> 00:12:21.066
So using the process I outlined before,

00:12:21.066 --> 00:12:24.250
I went ahead and decompiled all of ISLE.EXE.

00:12:24.250 --> 00:12:25.500
Not perfectly, yet,

00:12:25.500 --> 00:12:27.733
some functions are matching some of them aren't,

00:12:27.733 --> 00:12:31.066
and while my goal is to make it as accurate as possible within reason,

00:12:31.066 --> 00:12:34.133
it will almost certainly never be completely accurate because

00:12:34.133 --> 00:12:37.716
Mindscape used an old memory allocator library called SmartHeap,

00:12:37.716 --> 00:12:40.300
which is so old its logo looks like this,

00:12:40.300 --> 00:12:44.033
and yet still sells for $5000/year.

00:12:44.033 --> 00:12:50.116
So yeah considering the cost, and the fact we'd have to track down some specific obsolete version from 1997,

00:12:50.116 --> 00:12:52.000
I think it's fine if we just leave it.

00:12:52.000 --> 00:12:55.233
It's just a memory allocator, and while it apparently takes up about

00:12:55.233 --> 00:12:57.433
half the entire size of ISLE.EXE,

00:12:57.433 --> 00:13:00.350
the default allocators are basically the same thing.

00:13:00.350 --> 00:13:03.316
SmartHeap might have been a little more efficient for older computers, but

00:13:03.316 --> 00:13:06.033
on newer ones we probably won't notice any difference at all.

00:13:06.033 --> 00:13:07.616
But anyway without further ado,

00:13:07.616 --> 00:13:11.200
I present to you a technical analysis of ISLE.EXE.

00:13:11.866 --> 00:13:15.450
Now I made a decision not to bore you with every technical detail.

00:13:15.450 --> 00:13:19.283
It's probably not super interesting to hear that the first thing ISLE.EXE does

00:13:19.283 --> 00:13:22.716
is check if another instance is already running, and then closes itself if it is.

00:13:22.716 --> 00:13:25.533
Details like that I'm probably gonna skip over.

00:13:25.533 --> 00:13:27.250
Except for the fact that I already just said it.

00:13:27.250 --> 00:13:29.616
Compared to LEGO1, ISLE is tiny.

00:13:29.616 --> 00:13:33.650
It's a mere 85KB compared to LEGO1's over 1000.

00:13:33.650 --> 00:13:37.483
But I will say that despite that ISLE does more than you'd expect.

00:13:37.483 --> 00:13:39.600
You could probably guess that ISLE creates the main window

00:13:39.600 --> 00:13:42.450
and passes along keyboard and mouse input to LEGO1, but

00:13:42.450 --> 00:13:45.533
before that it does some pretty unusual things.

00:13:45.533 --> 00:13:48.083
For example, one of those things is:

00:13:48.083 --> 00:13:48.900
nothing.

00:13:48.900 --> 00:13:50.166
Yeah, nothing.

00:13:50.166 --> 00:13:52.550
As in, one of the first things LEGO Island does,

00:13:52.550 --> 00:13:54.400
just after telling LEGO1 to initialize,

00:13:54.400 --> 00:13:58.350
is sit around for 200 frames before it actually tries to load anything.

00:13:58.350 --> 00:13:59.983
I actually discovered this a while ago.

00:13:59.983 --> 00:14:02.566
I tried skipping it and found that, not only did nothing break,

00:14:02.566 --> 00:14:04.383
it actually launched faster, so

00:14:04.383 --> 00:14:07.300
I wrote it into Rebuilder as an optional patch you can enable.

00:14:07.300 --> 00:14:09.750
So... why is it doing this at all?

00:14:09.750 --> 00:14:12.866
My guess is that it's a pretty hacky way of ensuring that

00:14:12.866 --> 00:14:16.950
LEGO1 has finished initializing before it tries to do anything.

00:14:16.950 --> 00:14:21.216
Ideally, you'd find a way to send a signal when everything was ready.

00:14:21.216 --> 00:14:23.766
That way the delay is only as long as it needs to be,

00:14:23.766 --> 00:14:26.833
and you don't have to blindly wait for the worst case scenario.

00:14:26.833 --> 00:14:29.950
In fact, LEGO1 does send some events to the main window to

00:14:29.950 --> 00:14:31.933
tell it when to change cursors, which

00:14:31.933 --> 00:14:34.883
could have been used in this scenario too, but

00:14:34.883 --> 00:14:37.533
hey if you're under a time crunch and just need to finish the game,

00:14:37.533 --> 00:14:40.316
making it wait a few seconds gets the job done.

00:14:40.316 --> 00:14:43.100
I also found some things that I think are vestigial.

00:14:43.100 --> 00:14:46.666
As in things that used to serve a purpose but don't seem to anymore,

00:14:46.666 --> 00:14:48.033
and were never removed.

00:14:48.033 --> 00:14:49.650
The most baffling of which is the fact that

00:14:49.650 --> 00:14:53.283
LEGO Island tries to read an entry from WIN.INI.

00:14:53.283 --> 00:14:55.833
To understand why this is so strange, we have to go back.

00:14:55.833 --> 00:14:57.800
Like way back.

00:14:57.800 --> 00:14:59.583
Back in the days of Windows 1...

00:14:59.583 --> 00:15:02.816
There was no registry or anything like that for apps to store configuration,

00:15:02.816 --> 00:15:04.766
but there was WIN.INI.

00:15:04.766 --> 00:15:08.066
A single configuration file that Windows stored its settings in 

00:15:08.066 --> 00:15:11.233
and that apps could read and write to through the Windows API.

00:15:11.233 --> 00:15:14.766
It didn't take long for Microsoft to realize that every single app,

00:15:14.766 --> 00:15:16.550
as well as Windows itself,

00:15:16.550 --> 00:15:20.866
all meddling in the same file was perhaps not the greatest idea,

00:15:20.866 --> 00:15:23.816
so in Windows 3 they introduced new APIs that let apps

00:15:23.816 --> 00:15:27.366
create their own INI files rather than using Windows'.

00:15:27.366 --> 00:15:31.183
By Windows 95, WIN.INI was no longer being used by Windows itself.

00:15:31.183 --> 00:15:33.883
While many of its settings were still honored for backwards compatibility,

00:15:33.883 --> 00:15:36.533
Microsoft was very much discouraging its use,

00:15:36.533 --> 00:15:40.250
in favor of the newer Windows Registry, which LEGO Island uses.

00:15:40.250 --> 00:15:43.500
So why is it going anywhere near WIN.INI?

00:15:43.500 --> 00:15:46.516
To be totally honest, I don't really know.

00:15:46.516 --> 00:15:50.383
WIN.INI was essentially removed around XP-Vista-ish

00:15:50.383 --> 00:15:52.916
so I tried it on Windows 98 and found... 

00:15:52.916 --> 00:15:55.166
absolutely no difference at all.

00:15:55.166 --> 00:15:58.116
Judging by the name "MediaPath" I thought it might be another way to

00:15:58.116 --> 00:16:00.266
point to the game's streaming asset files,

00:16:00.266 --> 00:16:02.400
in addition to the ways that already exist,

00:16:02.400 --> 00:16:05.866
but if it does do that or indeed anything at all,

00:16:05.866 --> 00:16:07.850
I can't figure out how to use it.

00:16:07.850 --> 00:16:10.233
It does pass the result to LEGO1 though so

00:16:10.233 --> 00:16:12.100
maybe as we get deeper into this we'll get to see

00:16:12.100 --> 00:16:14.016
at least what it was supposed to do.

00:16:14.016 --> 00:16:15.483
Now we're getting into some bugs.

00:16:15.483 --> 00:16:17.600
Yeah, you thought this game's code was flawless?

00:16:17.600 --> 00:16:18.383
Well...

00:16:18.383 --> 00:16:20.000
I don't know what would have given you that idea.

00:16:20.416 --> 00:16:23.333
If you've played LEGO Island full screen within the last few years,

00:16:23.333 --> 00:16:24.900
 you may have run into this:

00:16:24.900 --> 00:16:29.450
this white bar across the top of the screen offsetting all of the visuals down.

00:16:29.450 --> 00:16:33.083
I've found it's a little inconsistent exactly when it occurs, but

00:16:33.083 --> 00:16:36.666
it started happening some time during the reign of Windows 10.

00:16:36.666 --> 00:16:38.416
Now it's easy to get mad at Microsoft

00:16:38.416 --> 00:16:40.733
when a Windows update breaks compatibility, but

00:16:40.733 --> 00:16:43.933
to be fair, this is LEGO Island's fault.

00:16:43.933 --> 00:16:47.200
When you create a window, you give Windows some style flags

00:16:47.200 --> 00:16:49.300
to tell it how you want that window to look.

00:16:49.300 --> 00:16:51.850
For example, when LEGO Island runs in windowed mode,

00:16:51.850 --> 00:16:55.600
it tells Windows to create a title bar, an icon/system menu

00:16:55.600 --> 00:16:57.266
which also gives it a close button,

00:16:57.266 --> 00:16:59.966
 a minimize button, and a maximize button.

00:16:59.966 --> 00:17:01.100
Pretty straightforward.

00:17:01.100 --> 00:17:04.400
When it runs in full screen, it tells Windows to...

00:17:04.766 --> 00:17:08.700
...create a title bar and an icon and close button?

00:17:08.700 --> 00:17:10.233
This is...

00:17:10.233 --> 00:17:11.766
well, there's no other word for it,

00:17:11.766 --> 00:17:12.383
wrong.

00:17:12.383 --> 00:17:15.483
You can see in this excerpt from the documentation of DirectX 5,

00:17:15.483 --> 00:17:16.816
the version this game uses,

00:17:16.816 --> 00:17:20.583
specifically saying you should use the "popup" style for full screen apps.

00:17:20.583 --> 00:17:22.716
And indeed if you force that value instead,

00:17:22.716 --> 00:17:24.316
which Rebuilder now does,

00:17:24.316 --> 00:17:25.833
the problem goes away.

00:17:25.833 --> 00:17:28.650
Yeah, so the white bar at the top of the screen,

00:17:28.650 --> 00:17:33.233
that's the title bar that LEGO Island specifically requested.

00:17:33.233 --> 00:17:35.866
Technically, older versions of Windows were actually

00:17:35.866 --> 00:17:38.650
less correct for not showing it.

00:17:38.650 --> 00:17:41.533
But this can be a pretty contentious topic in operating systems,

00:17:41.533 --> 00:17:46.150
is it ever permissible to break compatibility, even if it's for the greater good?

00:17:46.150 --> 00:17:47.833
If you're Apple, you say "[censored] yeah!

00:17:47.833 --> 00:17:50.516
"We don't care if we break an app that's only 3 years old!"

00:17:50.516 --> 00:17:53.316
However, Linus Torvalds, lead developer of the Linux kernel,

00:17:53.316 --> 00:17:56.016
has famously said "we don't break userspace"

00:17:56.016 --> 00:17:59.700
and that "If a change results in programs breaking, it's a bug in the kernel.

00:17:59.700 --> 00:18:02.383
"We never EVER blame the user programs."

00:18:02.383 --> 00:18:03.616
He also swore a lot.

00:18:03.616 --> 00:18:07.216
And for the most part Microsoft seems to feel the same way.

00:18:07.216 --> 00:18:10.700
Despite a lot of talk about old games breaking on newer versions of Windows,

00:18:10.700 --> 00:18:14.983
Microsoft has put a tremendous amount of effort into maintaining backwards compatibility,

00:18:14.983 --> 00:18:18.550
in some cases all the way back to MS-DOS from the early 80s.

00:18:18.550 --> 00:18:20.633
The fact is, if a program is written correctly,

00:18:20.633 --> 00:18:22.733
it'll run just as well on Windows 95

00:18:22.733 --> 00:18:25.283
as it will on the latest version of Windows 11.

00:18:25.283 --> 00:18:30.016
There are just a lot of programs that haven't been written correctly over the years,

00:18:30.016 --> 00:18:31.700
LEGO Island very much included.

00:18:31.700 --> 00:18:33.950
You could argue that Windows suffers by trying to stay

00:18:33.950 --> 00:18:37.033
faithful to such old and frequently broken technology.

00:18:37.033 --> 00:18:40.366
Though you could also argue that's Windows' primary selling point:

00:18:40.366 --> 00:18:44.250
a huge library of applications both new and old.

00:18:44.250 --> 00:18:46.333
 You could also see it as a necessary evil.

00:18:46.333 --> 00:18:49.500
Plenty of people need to use programs that are no longer being maintained

00:18:49.500 --> 00:18:51.316
and are not open source,

00:18:51.316 --> 00:18:54.700
and old games almost always fall into that category.

00:18:54.700 --> 00:18:56.666
As an example of how bad it could be,

00:18:56.666 --> 00:19:00.100
good luck trying to play a game on macOS more than 5 years old.

00:19:00.100 --> 00:19:02.383
Actually just good luck trying to play a game at all.

00:19:02.383 --> 00:19:06.833
Meanwhile if you peruse through the 2020 leak of the Windows XP source code,

00:19:06.833 --> 00:19:11.650
you can find a section that specifically mentions fixing something for LEGO Island.

00:19:11.650 --> 00:19:17.783
Yeah, there's code in Windows, probably still to this day, solely for this game.

00:19:17.783 --> 00:19:20.233
So even though we all give Microsoft a lot of [censored],

00:19:20.233 --> 00:19:21.500
plenty of it deserved,

00:19:21.500 --> 00:19:23.350
I do think they also deserve some credit

00:19:23.350 --> 00:19:26.266
for making sure these old games are still playable at all.

00:19:26.266 --> 00:19:30.116
And those are the biggest things I learned from decompiling ISLE.EXE,

00:19:30.116 --> 00:19:33.166
but like I said, we're not even in the meat of LEGO Island yet,

00:19:33.166 --> 00:19:35.200
nor have I even talked about other discoveries I've made

00:19:35.200 --> 00:19:38.683
outside of the decomp through reverse engineering the SI format.

00:19:38.683 --> 00:19:39.933
In the next parts, we'll look at that,

00:19:39.933 --> 00:19:42.933
as well as hopefully some interesting discoveries from LEGO1.

00:19:42.933 --> 00:19:44.933
If you're interested in trying out the decomp so far,

00:19:44.933 --> 00:19:46.400
there will be a link in the description, but

00:19:46.400 --> 00:19:48.666
keep in mind it is very much incomplete

00:19:48.666 --> 00:19:51.666
and what is there is still not 100% accurate,

00:19:51.666 --> 00:19:55.400
but it's a work in progress and I'm very excited to continue working on it.

00:19:55.400 --> 00:19:57.483
If you're interested too, stay tuned for more of that,

00:19:57.483 --> 00:19:59.883
as well as some other games I've been working on too.

00:19:59.883 --> 00:20:01.750
Now you may have noticed there's no sponsor on this video

00:20:01.750 --> 00:20:04.500
and it's because last year I played the whole game of 

00:20:04.500 --> 00:20:07.833
sponsors, deadlines, quantity over quality,

00:20:07.833 --> 00:20:09.066
and...

00:20:09.066 --> 00:20:10.300
I was pretty miserable!

00:20:10.300 --> 00:20:11.183
It wasn't great.

00:20:11.183 --> 00:20:14.183
I wanted to get back to just doing really interesting projects and

00:20:14.183 --> 00:20:15.533
making videos about them.

00:20:15.533 --> 00:20:18.166
And from what I can tell, I think you guys prefer it that way too.

00:20:18.166 --> 00:20:20.033
But there's a reason people play the YouTube game,

00:20:20.033 --> 00:20:22.933
and it's because it is so much more financially stable.

00:20:22.933 --> 00:20:25.466
And so if you'd like to help me out at all on that front,

00:20:25.466 --> 00:20:27.816
I would really appreciate it if you would check out my Patreon

00:20:27.816 --> 00:20:29.100
or become a member here on YouTube.

00:20:29.100 --> 00:20:30.800
And I really want to give a shout out to the people who have

00:20:30.800 --> 00:20:32.700
been Patrons or members this whole time

00:20:32.700 --> 00:20:35.333
as I've been figuring out what I want to do with this channel.

00:20:35.333 --> 00:20:36.516
It's really meant a lot to me.

00:20:36.516 --> 00:20:39.633
Finally, I've mentioned this on Twitter and on the community tab,

00:20:39.633 --> 00:20:42.466
but never in a video that for a little over a year now, 

00:20:42.466 --> 00:20:43.750
I've had a second channel.

00:20:43.750 --> 00:20:46.916
It's a lot more casual content, there's a lot of me telling life stories

00:20:46.916 --> 00:20:49.300
or checking out unusual stuff on the internet,

00:20:49.300 --> 00:20:52.633
but it's fun and if you want to see more of me between these longer videos,

00:20:52.633 --> 00:20:53.850
that's the place to go.

00:20:53.850 --> 00:20:55.166
Anyways thank you so much for watching,

00:20:55.166 --> 00:20:56.483
I really hope you enjoyed this video 

00:20:56.483 --> 00:20:58.800
and I'll see you all in the next one.

