Back to the source: ReDMCSB

Use this forum to discuss dungeon editors and other tools, like DMute (by George Gilbert, also working for RTC dungeons), DM Builder (by Sphenx), and ADGE by `rain. Includes DM editing tips and tricks.
Forum rules
Please read the Forum rules and policies before posting.
User avatar
ChristopheF
Encyclopedist
Posts: 1537
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Back to the source: ReDMCSB

Post by ChristopheF »

I've been working for nearly 5 years to reverse engineer the Atari ST versions of DM and CSB, and today I release the result of my work, named ReDMCSB (Reverse Engineered Dungeon Master/Chaos Strikes Back).
It contains source code (C language and a few parts in assembly) for all executable code on the game disk of all known Atari ST versions:
  • Dungeon Master for Atari ST 1.0a English (no version visible in dialog boxes)
  • Dungeon Master for Atari ST 1.0b English (version '1.0' visible in dialog boxes)
  • Dungeon Master for Atari ST 1.1 English
  • Dungeon Master for Atari ST 1.2 English
  • Dungeon Master for Atari ST 1.2 German
  • Dungeon Master for Atari ST 1.3a French (version 1.3 visible in dialog boxes)
  • Dungeon Master for Atari ST 1.3b French (variant, version 1.3 also visible in dialog boxes)
  • Chaos Strikes Back for Atari ST 2.0 English
  • Chaos Strikes Back for Atari ST 2.1 English
The source code is as accurate as possible: once compiled with the Megamax C compiler version 1.1 (also supplied in the package) it generates machine code nearly identical to the one in the original games. All the differences come from the fact that I used a different version of the compiler than the one FTL used and not because the source code is 'wrong'. If I can get my hands on version 1.2 of the Megamax C compiler, I'm pretty sure the source code will be proved to be 'perfect' by generating executables strictly identical to the originals.

The source code contains:
  • Meaningful and consistent names for all functions and their parameters, global and local variables, constants and macros.
  • Comments.
  • Conditional compilation directives allowing compilation of each version from the same source code. They also provide easy identification of the differences between versions
  • Conditional compilation directives allowing compilation without the copy protection. They also provide easy identification of all code related to the copy protection

The package does not contain as much documentation as I would like because it is very time consuming to write accurate documentation, but you will find the list of all known bugs and all changes between versions as well as a detailed description of the copy protection, and some more.

Download the package, and check the readme in the DOC folder for more information.
http://dmweb.free.fr/Stuff/ReDMCSB_Release2.7z

Previous release: http://dmweb.free.fr/Stuff/ReDMCSB_Release1.7z
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Re: Back to the source: ReDMCSB

Post by Paul Stevens »

I've been working for nearly 5 years to reverse engineer
does not contain as much documentation as I would like because it is very time consuming
I see. The reverse engineering went pretty quickly then.

Oh my goodness! What a monumental effort. Did you
deal with the Hint Oracle? I looked a bit and did not see it.
User avatar
ChristopheF
Encyclopedist
Posts: 1537
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Re: Back to the source: ReDMCSB

Post by ChristopheF »

I have only worked on the game disk and not the utility disk, so there is no hint oracle. On the utility disk, there is a start.prg that was developed with Megamax C (I have the source code for this one too although it is not part of this package). Other executable files use a custom 'FTL' format (start.prg contains the code to load these files) and they were not compiled with Megamax C.
They were developed and cross compiled on Macintosh, but I have not yet worked on these FTL files to identify the compiler that was used.
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Back to the source: ReDMCSB

Post by Sophia »

:shock: :shock: :shock: :shock: :shock:
User avatar
ebeneezergude
Expert
Posts: 345
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Back to the source: ReDMCSB

Post by ebeneezergude »

Sophia, 'Concise and Honest' I get, but what does :shock: :shock: :shock: :shock: :shock: mean....?! ;-) Penny for your thoughts?
sixfourfour
Novice
Posts: 15
Joined: Thu Mar 04, 2010 7:43 pm

Re: Back to the source: ReDMCSB

Post by sixfourfour »

WOW. Had a quick look around. I'll do more for sure. THANKS for sharing what you know. That original game, for me, was and is a timeless classic.

THANKS!
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Back to the source: ReDMCSB

Post by Sophia »

It means I am impressed.
This is quite an effort!
User avatar
Chaos-Shaman
High Lord
Posts: 2642
Joined: Wed May 03, 2006 7:26 pm
Location: The Gates of Hell

Re: Back to the source: ReDMCSB

Post by Chaos-Shaman »

5 years is a long time, pure devotion and love for the magical game.
keep your gor coin handy
User avatar
Bit
Arch Master
Posts: 1064
Joined: Mon Mar 03, 2008 10:53 am
Location: Nuts trees

Re: Back to the source: ReDMCSB

Post by Bit »

Just amazing!
Matching up with the compiler... so, digging out all the compiler's patterns in all their dependencies...
Paul told me I'm nuts when I started the recompilation of DM2 (and I'm still in the nuts trees, but there is light in the end of the tunnel) - and kentaro pointed me to the Watcom compiler. But that deep that it matches...
/me bows!!!

btw: didn't look into the source yet, but if it is pretty pure C (without Windows-API like CSBwin is), I probably can spend the extensions to handle true-color-graphic. I went through that when doing my recompilation - there are more different parts than one would think, including such things as fluxcage/teleporter-graphic on the sideview etc. It's just - I had to kill the old caching system for that...
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Back to the source: ReDMCSB

Post by Gambit37 »

An amazing effort Christophe! And there was I thinking that only Mr Stevens was crazy enough to undertake such an effort...

It's amazing what one can achieve with dedication and focus. I'm altogether too easily distracted to finish things.

Well done. :-)
User avatar
ChristopheF
Encyclopedist
Posts: 1537
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Re: Back to the source: ReDMCSB

Post by ChristopheF »

Thanks everybody! I agree with 'nuts' and 'crazy' :)

@Bit
I'm sure the methods I've used would also work on DM2 if you have the correct compiler version. The DM2 program is much larger, though.

About the 5 years, I want to add that it has not been a full time job at all, it is just that I started around 5 years ago. I don't know how many hours I spent on all this... probably several hundreds.
When I started, I knew nothing about 68000 assembly and the inner workings of the Atari ST, compilers/linkers. I learned a lot.
I spent less than 3 years working on the disassembled code. Around 8 months working with Megamax C and converting all assembly code to C code. Then more than one year to understand how everything worked, give nice names to functions and variables, and write the documentation (the list of bugs took me a lot of time to build).
User avatar
dungeon.master
Artisan
Posts: 178
Joined: Wed Dec 25, 2002 8:29 pm

Re: Back to the source: ReDMCSB

Post by dungeon.master »

Bravo Christophe ! :D

Amazing work, I started to read the protection and bugs sections : it's really impressive.

About the protection I remember that it was very nasty : a friend who mades a copy from my original has a lot of troubles with it :lol:
He said that its party was killed by giant fireballs coming from nowhere, some areas or weapons were not avalaible, the games hangs after 1 or 2 hours playing etc ... Just enough to make you buy the original :lol: :lol:

I also appreciate the efforts you put to list and explains the several bugs.

THANKS !
In Search Of Dungeon Master Grail
But
Resting Now, as
Banned User
User avatar
terkio
Mon Master
Posts: 937
Joined: Tue Jul 10, 2012 8:24 pm

Re: Back to the source: ReDMCSB

Post by terkio »

Many thanks. :D
An outstanding professional work. The ultimate knowledge on DM and CSB.
I recently said, the Dungeon Master Encyclopedia has everything....Now, it has everything including the source code and all to build.
"You can be on the right track and still get hit by a train!" Alfred E. Neuman
User avatar
Bit
Arch Master
Posts: 1064
Joined: Mon Mar 03, 2008 10:53 am
Location: Nuts trees

Re: Back to the source: ReDMCSB

Post by Bit »

Gave the 'make' a work - takes some time (even with Altgr-X), but completed!
Still, that work is more incredible than anyone of us can imagine.
User avatar
ChristopheF
Encyclopedist
Posts: 1537
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Re: Back to the source: ReDMCSB

Post by ChristopheF »

Release 2 is now available (Updated link in the first post of this thread)

This minor release has updates to the documentation (mainly additional bugs are documented) and a few minor changes here and there. Check the History section in Readme.htm
zoinkers
Novice
Posts: 19
Joined: Tue Feb 11, 2014 8:09 pm

Re: Back to the source: ReDMCSB

Post by zoinkers »

As an ex-Amiga user, I'm interested in looking over the source code of the Amiga versions you did. I see in the quora post by Doug Bell, you even did the PC version. Is there a v3 release coming? :-)
User avatar
ChristopheF
Encyclopedist
Posts: 1537
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Re: Back to the source: ReDMCSB

Post by ChristopheF »

Doug Bell mentioned my work on ReDMCSB here: https://www.quora.com/Is-it-possible-to ... ource-code

There is definitely a Release 3 package in the works. In the past weeks, I have been working on merging my Amiga source code with the Atari ST source code from Releases 1 and 2. I had to update quite a lot of small details here and there and split the source code over more files so that things are consistent and also to avoid code duplication. I still have a lot of work though to make the code cleaner, but right now I can compile both Atari ST and Amiga versions from the same set of source code (using conditional compilation directives). Note that for Amiga, this only covers versions 2.x as versions 3.x are quite different (cross compiled on Macintosh, and with some major differences in the code itself).

If you want to have a glimpse into the source code in its current state, send me an email and I'll reply with a preview package.
zoinkers
Novice
Posts: 19
Joined: Tue Feb 11, 2014 8:09 pm

Re: Back to the source: ReDMCSB

Post by zoinkers »

Thanks for the info. I'm happy to wait for the final polished release :-)
zoinkers
Novice
Posts: 19
Joined: Tue Feb 11, 2014 8:09 pm

Re: Back to the source: ReDMCSB

Post by zoinkers »

How's things going Christophe?
User avatar
ChristopheF
Encyclopedist
Posts: 1537
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Re: Back to the source: ReDMCSB

Post by ChristopheF »

I have been working for some months on the versions that were compiled on Macintosh (the ones that have .FTL executable files = X68000 and Amiga 3.x versions). Each of these versions contains several .FTL files: one for the game engine and others containing 'drivers' or other programs (swoosh FTL logo, champion editor, anim engine, etc.).
As of now, I have only completed the main program of DM/CSB for X68000 and I will soon complete the one from CSB 3.1 Amiga (the other amiga versions should follow quickly as they are very similar).
I still have a few months of work though before this is completed.
zoinkers
Novice
Posts: 19
Joined: Tue Feb 11, 2014 8:09 pm

Re: Back to the source: ReDMCSB

Post by zoinkers »

Crikey, that's dedication. Is there any chance of a point release to scrape through?
User avatar
ChristopheF
Encyclopedist
Posts: 1537
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Re: Back to the source: ReDMCSB

Post by ChristopheF »

If you want to have a look, I can share my work-in-progress unified source code for Atari, Amiga, PC, PC-98 and X68000.
If you're interested in Amiga versions, I'd wait a few weeks so I can at least complete the work on the game engine in these versions.
FGoset
Neophyte
Posts: 1
Joined: Sat Jun 17, 2017 4:00 pm

Re: Back to the source: ReDMCSB

Post by FGoset »

Many thanks for your work. I'm currently writing a clone of DM and this will be very helpful to understand many of the hidden aspects of this game.
zosodk69
Novice
Posts: 13
Joined: Wed May 11, 2005 8:50 pm
Location: Michigan, US

Re: Back to the source: ReDMCSB

Post by zosodk69 »

ChristopheF wrote: Tue Mar 21, 2017 7:58 am If you want to have a look, I can share my work-in-progress unified source code for Atari, Amiga, PC, PC-98 and X68000.
If you're interested in Amiga versions, I'd wait a few weeks so I can at least complete the work on the game engine in these versions.
Christophe, I'm very interested in seeing the progress you've made on reversing the Amiga versions. I recently made a personal hack of the WHDLoad DM slave to incorporate WASD keys for movement (similar to a modern FPS). While reversing the binary, I was greatly aided by the ST code you published in Release 2. I was tripped up by some of the differences I encountered in the Amiga version, however. I'd like to further expand this to hack to include more complicated actions like spellcasting with the keyboard. A while back you'd indicated your willingness to share a preview of the work you've completed. Does this offer still stand?
-=[dave]=-
User avatar
ChristopheF
Encyclopedist
Posts: 1537
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Re: Back to the source: ReDMCSB

Post by ChristopheF »

You can check this archive: http://dmweb.free.fr/Stuff/ReDMCSB_WIP20210206.7z

It contains:
- the source code for all programs from all known versions of DM/CSB except the SNES console versions
- emulators, compilers, tools and scripts to fully automate the build of all the executables
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Back to the source: ReDMCSB

Post by Gambit37 »

Hi Christophe, in your research for ReDMCSB, did you determine if creating Ful Bombs was possible in any version? I know that Doug Bell said it's possible in an early version of DM, but I'm still not sure if he's mistaken?
User avatar
ChristopheF
Encyclopedist
Posts: 1537
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Re: Back to the source: ReDMCSB

Post by ChristopheF »

Definitely not possible in any of the versions I have studied. He was probably referring to early beta versions and not any released one.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Back to the source: ReDMCSB

Post by Gambit37 »

Great, thanks for the confirmation :)
zosodk69
Novice
Posts: 13
Joined: Wed May 11, 2005 8:50 pm
Location: Michigan, US

Re: Back to the source: ReDMCSB

Post by zosodk69 »

ChristopheF wrote: Mon Apr 12, 2021 8:24 am You can check this archive: http://dmweb.free.fr/Stuff/ReDMCSB_WIP20210206.7z

It contains:
- the source code for all programs from all known versions of DM/CSB except the SNES console versions
- emulators, compilers, tools and scripts to fully automate the build of all the executables
Most of the Amiga 3.x binaries are compiled on an Apple Macintosh with Think C? Why do you suppose that is?

One of the neat things about the source compiled with Aztec C is that we get the .ASM artifacts with symbols intact. I'm not familiar with the Mac compile workflow. Is there a way to get the compiled assembly for, say, KAOS.FTL?
-=[dave]=-
User avatar
ChristopheF
Encyclopedist
Posts: 1537
Joined: Sun Oct 24, 1999 2:36 pm
Location: France
Contact:

Re: Back to the source: ReDMCSB

Post by ChristopheF »

Trust me, I do not "suppose": I know that cross-compilation with the Think C compiler running on Macintosh was used for all .FTL files (that is all Amiga 3.x, Atari ST CSB Utility disk, and X68000 binaries, except the loaders that were compiled on the native platform).
The initial clue was that each FTL file contains a few Macintosh specific instructions (Line A instructions of the 68000 processor that translate to Macintosh toolbox calls). These instructions are part of the Think C loader that the compiler adds at the very beginning of all compiled programs. Of course it is bypassed in FTL files as they run on other platforms: this is part of the conversion from the compiled Macintosh executable file format to the proprietary .FTL executable file format.
Then the fact that ReDMCSB executables are so close to the original .FTL files (and even perfectly identical for the smallest ones) proves that the compilers I have used are the correct ones (Think C 4 and 5, that last one being used only for the KAOS.FTL in DM 3.6).

Think C does not have any feature to output the assembly corresponding to the compiled code. The only way for that is to use a disassembler on the generated executable.
Post Reply

Return to “Editors and Tools (DMute, DM Builder, ADGE, etc.)”