r/goldbox • • 19d ago

Gold Box Games RE Source Code

The best-laid schemes o’ mice an’ men
Gang aft agley,
An’ lea’e us nought but grief an’ pain,
For promis’d joy!

The reverse-engineered source code to every Gold Box game can now be found on my GitHub.

The Brazen Crows version of Pool of Radiance, including the native macOS, Windows, and Linux versions, can be found in the bc-pool-of-radiance repository. My last release is also available.

The source to SSI's versions, which compile byte for byte exact, can be found as follows:

The incomplete - but mostly done - versions of Dark Queen of Krynn and Forgotten Realms Unlimited Adventures are also available.

I hope someone can make use of it.

76 Upvotes

28 comments sorted by

4

u/grannypr0n 19d ago

Could you ballpark the amount of man hours and tokens that this took you? For reference for similar projects.

13

u/brazencrows-goldbox 19d ago edited 19d ago

TLDR answer: 16 weeks, ~300B tokens, $2,000 in subscriptions.

Longer response: Too many. I was naive and overconfident when I started. Then I got stubborn. Opus 4.6 and 4.8 weren't as good as current models; it seemed like every night was one problem or another I had to work through with them. This was not a "let the agent loose" effort. Turbo Pascal isn't as easy to reverse-engineer as C/C++ - it's like assembly vs Python in terms of model knowledge.

This was my "learn agentic engineering and add Fix to PoR" effort. I spent almost every evening on it, and every other weekend. Almost a month was dedicated to clean up - why the source looks as good as it does, and isn't a bunch of random function and variable names.

I can rip a Turbo Pascal 5.0, 5.5, and 6.0 game apart in a few days now; if you're working on one, let me know - I can send you the codegen levers knowledge base I have. I'm also a lot better at agent and context management.

Anthropic 20x Max (now Ultra) - $200/mo, 5 months. 2 accounts since late August. Another $400. OpenAI Pro 20x - $200/mo, 3 months. $2k altogether. Almost every week was max usage.

OpenAI usage began in August. It has my lifetime tokens measured at 41B - it was used almost exclusively for this.

Claude says: That puts the all-in total for Gold Box at about 250–280 B tokens. About 97% of that is cache reads, and output is roughly 0.25–0.4 B.

  1. Jun 19 – Jul 26: PoR and Curse. The method was worked out here, and all versions of both games matched. The wiki and re-tools both started in this stretch.
  2. Jul 13 – Aug 30: fan-out. Secret, Pools, Champions, Gateway and Treasures all matched. Gateway and Treasures took only 8–11 days each once the method and tools had matured.
  3. Sep 1 – Oct 12: utilities and the C titles. CONTROL/STARTUP matched, the build was consolidated across repos (Sep 16–22), DKK finished 09-16, DQK ~09-24 and FRUA 10-03 / 10-12. FRUA was the slowest because it is C linked with RTLink rather than Turbo Pascal.
  4. Oct 5 – Oct 26: cleanup run. Passes S1–S13 covered comments, names and docs. Most repos stop on 10-18, PoR's final commit on 10-21 is "We're done", and naming work in DQK/FRUA ran on to 10-24/26.

Other interesting stats: 19K commits, 853K lines of Turbo Pascal, 40K lines of Python, 174K lines of assembly, 234K lines of C between all games and versions. Not publicly available: about 200K lines of Python tooling, an Obsidian knowledge base with 4k commits, 120Mb in size.

The original disassembly repositories are a *lot* messier than the public repos.

4

u/senseofsensing 18d ago

I can rip a Turbo Pascal 5.0, 5.5, and 6.0 game apart in a few days now; if you're working on one, let me know - I can send you the codegen levers knowledge base I have. I'm also a lot better at agent and context management.

Perhaps create some agent skills that can be reused for anyone continuing these or doing similar decomps? You can have your AI analyze its entire work history and generate them and you can then tweak as needed.

Many thanks for your efforts on these.

5

u/brazencrows-goldbox 18d ago

That is an excellent idea, and I will do so.

3

u/Adventurous-Echo444 19d ago

I feel your pain. A lot of people think something like this can be done in a week, with a $20/mo plan, and a few prompts a day.

2

u/Apprehensive_Sleep20 18d ago

I have big thank because of sharing these. I working on Goldbox reverse-engineering since middle of 2023, but mostly just analyzed the decompiler/disassembler code with AI, not targeted true original source. But your work really speed up found bugs in my engine. I only have a close completed symbol names in Ghidra for Pool of Radiance only but because 16bit x86 code is cause ugly decompiler code my first source always was the Amiga version. Ubisoft made correct port of DAX engine on that platform in C better for Ghidra. Later games on Amiga already used a GLB engine, what was ported back to PC for Unlimited adventure.

2

u/PlayfulInterview984 18d ago

I have a similar experience having remastered about a dozen games. I have 2 Claude Code max subs and an Astra max, and they get completely used each week, mostly due to Fable. So remaking old dos games can be an expensive hobby

1

u/Bassfaceapollo 6d ago

Damn. That's quite a lot of effort and very expensive.

I was going to request that you consider reverse engineering the two Dark Sun games. But I don't think that this is a practical request.

Still, what you shared is bound to be immensely helpful. Thank you for sharing this!

2

u/grannypr0n 18d ago

What was your tasm and exepack version? I assume everything came from winworld?

3

u/brazencrows-goldbox 18d ago

TASM 1.0 and EXEPACK 4.06 - it's output was identical to 4.05 though, either work.

And yep, WinWorld and archive.org.

1

u/grannypr0n 18d ago

I have a working build! I had to copy my GoG POOLRAD into my OBJ folder because it crashed after "Loading... Please wait" when I copied by OBJ into my GoG folder, but who cares, it works!

6

u/xBipper 19d ago

Cool project but you might be putting yourself at risk of legal action. AFAIK those games aren't public domain, and the rights holder may not like you publishing source code for their IP. I'll be interested to see what happens, if anything.

5

u/brazencrows-goldbox 19d ago

https://en.wikipedia.org/wiki/Reverse_engineering

They have equivalent source now that has been considered lost, and I don't provide any of the copyrighted game data/IP. The source isn't actually SSI's; it's what I derived to match their binary output. If I had stolen their source from their servers, sure, I'd be in serious trouble.

If they want it taken down, I'd take it down - because I respect SNEG's work in this area. Or they could send a DMCA notice to GitHub.

5

u/vnbrtjtwd2 19d ago

About the worst would be a cease and desist notice, which would give you a set of time to remove the repos

6

u/grannypr0n 19d ago

This may save it

"The only game executables and data files included in project releases are ones I compiled or generated from this source. SSI's original retail game data is not included. You need to own a copy of Pool of Radiance to play. It is sold as part of Forgotten Realms: The Archives — Collection Two on GOG and Steam."

2

u/Nicodamos 19d ago

Who owns this now? SSI is long gone. Not sure if someone bought that studio.

6

u/Medical-Molasses615 19d ago

SNEG owns it. A few years ago they released everything on Steam.

1

u/Apprehensive_Sleep20 19d ago

If you don't mind I already forked and use it finish my goldbox engine for ScummVM

3

u/brazencrows-goldbox 19d ago

I don't mind in the slightest. The source is shared so that efforts like yours can continue, and the ecosystem as a whole can grow stronger.

2

u/Low_Championship_428 15d ago

I'm curious as to how you dealt with any memory limitations. The originals famously used Overlays to swap code segments in/out. Is that something you had to deal with?

1

u/grassisgreena 19d ago

I've been using your previous version on my MiSTer FPGA DOS core.

Can't wait to update it with this version!

1

u/Parlett316 19d ago

OP, I used RE to port War of the Lance war game to Godot, do you want any of that?

1

u/MonochromeSL 18d ago

Very nice. I’d just been working on COTAB revamp with better AI for quick, spell templates and other stuff - this will save me a bunch of time when o bf one to expand that work - legend.

1

u/ArmyAccording7914 9d ago

Any chances for more BC versions of ggoldbox games? Also - Any chances for Android APK for BC. I'd Love to have IT on tablet and phone

1

u/L4ll1g470r 2d ago

Out of curiosity, how massive a further development would the Amiga versions be?

At least the versions for Champions and Death Knights and Secret of the Silver Blades had enhanced graphics over dos, I think Curse of the Azure Bonds possibly, too.

The latter two have functioning mac versions that are easy to emulate, but my attempts with Champions and Death Knights have been fairly unsuccessful…

0

u/fischb 18d ago

You might want to share this on Quiver Launcher. People will be interested. https://quiverlauncher.com/