Back

SpaceCadetPinball – Decompilation of 3D Pinball for Windows

234 points14 hoursgithub.com
gavinray13 minutes ago

Could anyone speak more about how this decompilation is done from a technical perspective?

This looks nothing like the pseudocode C that IDA/Ghidra spit out, so how would you go about doing this even?

It says in the README:

  Tools used: Ghidra, Ida, Visual Studio

  What was done:

    All structures were populated, globals and locals named.
    All subs were decompiled, C pseudo code was converted to compilable C++. Loose (namespace?) subs were assigned to classes.
Which is a bit "Draw-the-rest-of-the-fucking-owl" for me. Or am I just clueless.
davidst8 hours ago

I am one of the original authors of Space Cadet pinball (along with Mike Sandige, lead programmer, and Kevin Gliner, producer and designer.) It is surprising and gratifying to see interest is still alive for our old game. And I can't help but be impressed by the ingenuity shown by both the decompiling effort and the playable web-based game.

mike_san6 hours ago

I'm impressed as well! It's exciting to see folks so enthusiastic about the game.

I took a deeper look at the github project. It's been a long time since I worked on the Space Cadet code, but the decompiled github code is pretty familiar. It's formatted differently of course, but I think it's actually better than the original. And, nice! Check it out David and Kevin: k4zmu2a got the quotes in! https://github.com/k4zmu2a/SpaceCadetPinball/blob/master/Spa...

Now I'll never live down how long I spent working on the flippers.

Bonus points for anyone who knows why the classes in the source are prefixed with a 'T'!

-Mike Sandige (Lead programmer on Space Cadet)

kingcharles31 minutes ago

Always interesting to see the things hidden in games. When I was in the biz I was aware of many easter eggs, a lot of which are still unknown to the public.

For instance, this sign in GTA:SA has the word "TFT" on the back which is a reference to a secret video game "Illuminati": https://gta-myths.fandom.com/wiki/Signs_(GTA_SA)?file=Egg_8....

nopakos4 hours ago

From wikipedia: "...[Danny Thorpe] in 1994 while at Borland, he contracted with Santa Cruz startup Cinematronics (David Stafford and Mike Sandige) to build a component model and collision physics engine for a software pinball game. Cinematronics licensed an early version of the pinball engine to Microsoft" Maybe Borland and Delphi has something to do with the 'T' prefixes. Source: https://en.wikipedia.org/wiki/Danny_Thorpe

pjmlp1 hour ago

Borland's C++ frameworks use the same convention, to this day.

mysterydip4 hours ago

Thanks to both of you. It took me a while to realize the depth built in. I tried making a pinball game many moons ago but couldn't get the ball to "feel" right (flippers as well).

How was that process? Did you go play physical tables, go for a realistic approach, or tweak magic numbers until it "felt right"?

veddox2 hours ago

Great to see you commenting here! :D

Were those quotes some kind of cheat system?

pjmlp1 hour ago

Borland C++ OWL and Turbo Vision. :)

secondcoming4 hours ago

> Bonus points for anyone who knows why the classes in the source are prefixed with a 'T'!

Was it written in, or ported from, Delphi?

alternatetwo2 hours ago

Has to be ported, since Delphi doesn't generate PDB7's.

Or at least written by someone familiar/used to Delphi, since Age of Empires utility classes are also prefixed with T, but the game was obviously written in Visual Studio - but some dev tools were written in Delphi, so somebody seems to have taken the naming scheme from there in that case.

pjmlp1 hour ago

Borland C++ frameworks used the same coding conventions as Turbo Pascal/Delphi.

They still use them.

_fat_santa25 minutes ago

Thank you sir, you brought many many hours of enjoyment to my childhood. I remember being excited to go to my Aunt's house because she had a computer with Windows XP (my family only had Windows 2000) and I could play your game.

And only on hacker news will I be replying to one of the authors.

BiteCode_dev3 hours ago

Well, in this day and age of bazooka DMCA take down, it's refreshing to see a game author happy about his game being gutted, and put online to play.

q-big2 hours ago

> it's refreshing to see a game author happy about his game being gutted, and put online to play.

The game author is typically not the copyright holder.

californical8 hours ago

Wow, this game was a staple in my childhood! Just wanted to let you know that your work brought me lots of happiness as a kid, so thank you :)

Out of curiosity, have you ever written about the experience? Technical challenges, the development culture, etc?

davidst8 hours ago

Thanks!

There were a couple of interviews with gaming magazines years ago. They would be hard to find today and didn't cover the topics you mentioned. Mike, Kevin, and I, really need to get together to tell the story some day.

coldacid2 hours ago

Please do! There are loads of us who would love to hear it all direct from you guys.

Cthulhu_7 hours ago

I played it before it was bundled with Windows, at the time I didn't think that much of it (I was more into Epic Pinball, spent so much time on the shareware version with the android themed board <_<), but it was a game we'd fire up Windows for. We probably got it off one of those shareware CD's, but I don't recall. Might have been off a diskette?

deknos7 hours ago

if the game would be available as open source and/or run on linux, that would be super... this was my first pc game when i was a little child

GTP4 hours ago

You can easily compile it on Linux following the instructions in the repo and grab the game assets from here: https://www.reddit.com/r/vitahacks/comments/pro8x1/comment/h... Tested on Arch Linux, works flawlessy!

scruffyherder6 hours ago

Check the SDL port or the emscripten

bloqs2 hours ago

Great to see you here David. Thanks for all the work over the years.

ur-whale8 hours ago

I can't help but wonder for old closed-source utilities and games like this: whatever happened to the original source code?

Is it still around, stashed in a vault a MSFT, or is it lost for ever?

Do you know?

And what would it take to convince a large corp. like MSFT to actually release the original under some open source license ... not like the thing has much value by now other than historical.

davidst8 hours ago

The rights belong to Electronic Arts today. They acquired Maxis who had acquired us (Cinematronics.) Microsoft may still have rights to continue publishing a version with the Windows operating system.

Microsoft, if you're reading this, we would be glad to provide assistance in getting 3D Pinball running again on the latest Windows OS.

leeter51 minutes ago

Given that the reason it was removed was IA-64 which isn't a thing anymore... this should be plausible. But also given where MS has gone with games as late I'd be surprised if they do. EA should just release all of Full Tilt! Pinball on steam or GoG if they haven't already.

papito1 hour ago

We played the hell out of it on our Windows 2000 machines during particularly boring IT labs in college, in early 2000s.

The physics just seemed so spot on. I installed Win2K on a VM recently, just for this.

Start Menu, type in "pinball". Ah....

_fat_santa24 minutes ago

Was it available on Windows 2000? I know it was a default on Windows XP. I was way too young back then to remember

papito19 minutes ago

Definitely. It was available (apparently) even with a Win95 upgrade pack, so it's very old.

I was not aware of it, however. I am not sure it was as easy to launch before, by just typing in "pinball" in the Start menu.

nspattak8 hours ago

it was the most joyful game that shipped with windows and it was also fun! I would like to play it again :)

baq4 hours ago

'twas a great little game. good job!

WalterGR13 hours ago

Not just decompiled.

What was done:

* All structures were populated, globals and locals named.

* All subs were decompiled, C pseudo code was converted to compilable C++. Loose (namespace?) subs were assigned to classes.

Edit: Wow, and a lot more: https://github.com/k4zmu2a/SpaceCadetPinball/commits/master

Also see “On the attempts to resurrect Space Cadet Pinball” by Raymond Chen: https://devblogs.microsoft.com/oldnewthing/20181221-00/?p=10...

gruez13 hours ago

>* All structures were populated, globals and locals named.

Microsoft provides that openly via debug symbols, so it's not even anything new.

WalterGR13 hours ago

Assuming it’s a debug build or a release build with absolutely no optimization. Otherwise at least some amount of manual work is suggested by the bullet point.

But are PDBs even available for it? I assumed Microsoft only releases PDBs for binaries used in development scenarios.

jamesfinlayson11 hours ago

Looks like a .pdb is available for it (no idea where it was sourced from but the readme says it's public).

+1
alternatetwo10 hours ago
devmor12 hours ago

If you read the README in the link, you will find the answer to your question.

+1
WalterGR11 hours ago
stefan_13 hours ago

Wikipedia suggests the copyright owner is Electronic Arts:

https://en.wikipedia.org/wiki/Cinematronics,_LLC

moffkalast6 hours ago

So we can all look forward to a reboot of space cadet on Windows 11 with lootboxes and microtransactions?

CodeArtisan13 hours ago

Be cautious that publishing source code generated in part or entirely from decompilation of copyrighted content may take you to court.

https://torrentfreak.com/take-two-sues-enthusiasts-behind-gt...

https://news.ycombinator.com/item?id=28402640

userbinator12 hours ago

I suspect the much more recent news article https://news.ycombinator.com/item?id=28809559 may have encouraged the author to publish this... and he was looking for a bug to fix, after all.

worker76742412 hours ago

That lets you decompile and likely publish a patch, not publish the complete derived source.

mhh__10 hours ago

Patch for what though? Is the ability to use a patch taken into account because a patch to clang on Linux and a patch to appleclang on Mac have very different interpretations

+1
marcan_4210 hours ago
ranger_danger11 hours ago

But there's hundreds of decompiled copies of Super Mario 64 on github and have been for years. Where's their court cases?

chii12 hours ago

if the purpose of the decompilation is for reverse engineering and api compatibility, there's a fair use argument.

So the OP would need to show that the purpose is indeed for reverse engineering. IANAL, so don't actually do it...

marcan_4211 hours ago

Decompiling may be legal, but publishing the decompiled source is almost always a copyright violation.

Interoperability is an argument for the legality of decompilation itself (i.e. you can ignore EULA clauses that say otherwise); it doesn't make the resulting code copyright-free or automatically eligible for fair use.

Lammy11 hours ago

The path to fixing the law is doing it anyway, letting the takedowns come, and then harnessing the collective frustration of people who want to see the things they grew up with be preserved.

marcan_4211 hours ago

There are reasonable fair use arguments to be made around preservation indeed (just look at what archive.org does). They just have nothing to do with the decompilation for interoperability story.

R0b0t111 hours ago

Why?

+1
marcan_4211 hours ago
brassattax13 hours ago

And it was forked and ported to emscripten! Amazing!

https://alula.github.io/SpaceCadetPinball

listic8 hours ago

Did it really have music like that? I only remember the sounds, for some reason.

twic5 hours ago

I don't remember the music either, possibly because i turned it off the first time i played, and never turned it back on. The menu option to turn music off doesn't work in the web version, sadly.

AshamedCaptain5 hours ago

Because the default was to keep the music off.

fsckboy12 hours ago

that is really cool!! but the flippers are a teeny bit sluggish, screws up my timing on some stuff I know how to do (gotta love gravity well)

LegitShady11 hours ago

In the graphics settings up the FPS and it seems to work a lot better for sluggishness.

gfiorav7 hours ago

Here are some interesting takes by the guy who ported it for XP at Microsoft. He says it would later prove very difficult to move to 64bit due to some low-level hacks/dependencies on word length in the collision detection code.

https://youtu.be/ThxdvEajK8g

22c13 hours ago

> On 64-bit bug that killed the game

I had heard about this bug, I think I saw it on Dave Plummer's YouTube channel[1]. I remember thinking at the time that I am surprised nobody has tried to decompile it and figure it out, looks like k4zmu2a did and couldn't find it. Now I have more questions about the original bug reports.

[1] https://www.youtube.com/channel/UCNzszbnvQeFzObW0ghk0Ckw

pedropaulovc13 hours ago

The bug lore came from Raymond Chen's blog post [1]

[1] Why was Pinball removed from Windows Vista? https://devblogs.microsoft.com/oldnewthing/20121218-00/?p=58...

selcuka12 hours ago

This comment made me chuckle and also a bit sad:

> [...] we simply couldn’t figure out why the collision detector was not working. Heck, we couldn’t even find the collision detector!

unnouinceput10 hours ago

And the continuation is:

"We had several million lines of code still to port, so we couldn’t afford to spend days studying the code trying to figure out what obscure floating point rounding error was causing collision detection to fail."

I'd say Ray is right, not lacking the skill, but lacking the time

+1
selcuka9 hours ago
garaetjjte2 hours ago

There's a documentary about it: https://www.youtube.com/watch?v=3EPTfOTC4Jw

GoblinSlayer7 hours ago

I unpacked pinball from 64-bit windows xp cd, played it and the only bug I see is that the launcher isn't well visible.

tanjtanjtanj9 minutes ago

I pirated (sorry) the Windows version of Space Cadet Pinball from some big torrent tracker (TBP, Demonoid?)some time after that blog post was put up and it worked on Windows 7. Last time I saw this story making the rounds, around 2017, I checked to see if it still worked on Windows 10 and to my surprise, it did. I don't know what sort of unofficial patch was applied if any, but it has been working on 64 bit windows for nearly a decade from what I can tell.

AshamedCaptain5 hours ago

It is incredible that even in 2021 people still parrot Chen's original _WRONG_ post about Pinball not being available in x64 Windows. We already even mentioned that in the original entry of his blog before the comments were removed.

Tens of "YouTube videos" appear in this thread and all of them simply parrot the same statement from Chen and not a single one of them even bothers to actually try Windows XP x64 edition and check whether Pinball is there not. Again only in some comments people seem to realize 'hey, you guys may be wrong .. there is a x64 pinball here after all, at least'.

I guess it's a sad reflection of our society.

worker76742412 hours ago

Makes me wonder why they removed Hearts from Windows 8

phinnaeus11 hours ago

Probably the same collision detector issue⸮

Gigachad12 hours ago

This is the line implementing the famous “hidden test” cheat https://github.com/k4zmu2a/SpaceCadetPinball/blob/8c4f38c0af...

Looks like there are other undiscovered cheat codes too.

TedDoesntTalk12 hours ago

What is the hidden test cheat? Your link brings me to the top of page

selcuka12 hours ago

    // Original allowed to enter cheats only before the first launch.
    std::memmove(&cheatBuffer[0], &cheatBuffer[1], 10);
    cheatBuffer[10] = key;

    if (strcmp(bufferEnd - 11, "hidden test") == 0)
    {
        pb::cheat_mode ^= true;
    }
Gigachad8 hours ago

Typing "hidden test" and hitting enter would cause the ball to be stuck to the mouse pointer rather than playing normally. I assume this was used to test the game features but it was left in the final build.

stuntkite12 hours ago

Finally! This has been lost for ages! I want to see someone do a breakdown on the ball physics!

Gonna archive this before it's wiped from the intenet.

swyx10 hours ago

this game was a huge part of my 12 year old childhood. really good times.

nazgulsenpai13 hours ago

I learned a lot about 3D Pinball recently on this video [0]. It's specifically about the 64bit versions of 3D Pinball (or the lack thereof) and the reasons why. Part of that is debugging which relates to this.

[0] https://youtu.be/3EPTfOTC4Jw

22c13 hours ago

Dave Plummer, the programmer who ported Space Cadet pinball to ship with Windows, also recently did a video on this.

https://www.youtube.com/watch?v=ThxdvEajK8g

pastage10 hours ago

The 1992 Pinball Dreams from DICE is still being published for new platforms latest release on the Amstrad.(but as unlicensed as this release seem to be)

phreezie8 hours ago

If you want to play a modern, hi-resolution 3D version of Space Cadet, there was a Visual Pinball port recently by JPSalas: https://www.vpforums.org/index.php?showtopic=47560

djmips4 hours ago

Not technically a port but recreation. Nice work!

ur-whale8 hours ago

Note that they used Ghidra (the NSA-developed decompiler), which, in spite of its shady origin, is a wonderful tool.

vadfa7 hours ago

How does ghidra compare nowadays to IDA? Is it good enough already to be used as a replacement to IDA and Hex-Rays decompilation, at least for x86 code?

saagarjha7 hours ago

That would depend on your needs. For me, at least, it's largely an adequate replacement-I'd rank it as "consistently at least 50% as good, sometimes up to 200% as good as IDA". For the price it's simply unbeatable.