• Most people probably don't realise this, but this forum has had two editors for a number of years. One is the xenForo default editor, and the other is a custom editor I made years back I called BBCEd.

    All the settings for which editor you use was lost during the upgrade. You can find the setting under Account Settings > Preferences > Editor.

CSE2

Feb 10, 2019 at 8:13 PM
Senior Member
CSE Discord Admin
"Master using it, and you can have this!"
Join Date: Jan 13, 2016
Location:
Posts: 76
#1
CSE2 (Cave Story Engine 2) is a decompilation of Cave Story made by me and Cucky, with an emphasis on accuracy to the original code. Through a combination of machine-conversion and by-hand translation, we've broken the original 2004 EXE back down to a recreation of its original C/C++ source code. As of yesterday, the game is fully completable: from First Cave to Ballos.

You can find the source code here. To compile it on Windows, you'll need an MSYS2 installation with MinGW-w64, though it should be easy to make it compile with Visual Studio.

Right now, one of the biggest deviations from the original code is the rebase from DirectX to SDL2. Personally, I plan to make a fork that moves back to DirectX, but for now SDL2 means better performance, and the ability to run CSE2 natively on Linux, so that's a bonus.

Hopefully I shouldn't have to explain how being able to work with plain C/C++ code will make advanced code modification easier. Writing a DLL chainloader to patch an EXE file is an absolute nightmare in comparison. Not to mention, this could open up the possibility of a community-maintained base for mods, with fancy things like extra TSC commands and Ogg support built right in.

Since this is the first release right after the project's completion, consider this a bit of an open beta. Inaccuracies could have slipped through without us noticing during playtesting. We've got plans in the future to make the code even more accurate (by compiling it with the same compiler Pixel did, and comparing the resulting ASM), but that's for another time. For now, if you spot anything even slightly off, please point it out here.

You can download a 64-bit Windows build here. Just add the data folder from the regular freeware version.

If you're really interested in the project, we have a Discord server for it here: https://discord.gg/ekbmYGK

I suppose I should tell a little story here, about how this thing even got off the ground. Back when I made my DLL loader, I was doing everything blind. I wasn't even using the assembly compendium. Then GabrielRavier(?) found out that the old Linux port accidentally contained debug symbols. These symbols contained the original names of practically every bit of code in the game.

With this info, almost everything you'd ever need to know about the game's code was laid out for all to see. It even gave us the names of each C++ file, and which functions they contained. All of this, combined with a good decompiler, meant making a decompilation was just a matter of putting these pieces together.

Anyway, er, enjoy.

EDIT: Cucky told me to add a screenshot so here's a screenshot. By changing one value in CommonDefines.h, you can make the screen not just wider, but taller:
1549833116759.png
 
Last edited:
Feb 10, 2019 at 8:39 PM
Aar Online
bored to death
Bobomb says: "I need a hug!"
Join Date: Oct 7, 2011
Location: elsewhere
Posts: 756
Age: 19
#3
How nifty! Hopefully this will open up the possibility for more consistent frame rates and the like, as I always noticed how wonky CS's frame output was when putting videos together.
 
Feb 10, 2019 at 8:51 PM
In my body, in my head
Forum Moderator
"Life begins and ends with Nu."
Join Date: Aug 28, 2009
Location: The Purple Zone
Posts: 5995
#4
trying to compile with g++ 8.2 i get the error
Code:
src/Star.cpp:111:14: error: expected initializer before ‘PutStar’
 void __cdecl PutStar(int fx, int fy)
              ^~~~~~~
 
Feb 10, 2019 at 9:05 PM
Senior Member
CSE Discord Admin
"Master using it, and you can have this!"
Join Date: Jan 13, 2016
Location:
Posts: 76
#5
Damn. Guess we missed one. It's probably just that __cdecl. It shouldn't be there.
 
Feb 10, 2019 at 9:12 PM
Junior Member
"Fresh from the Bakery"
Join Date: May 7, 2018
Location:
Posts: 12
#6
How nifty! Hopefully this will open up the possibility for more consistent frame rates and the like, as I always noticed how wonky CS's frame output was when putting videos together.
CSE2 seems to be much smoother in terms of framerate than the original

trying to compile with g++ 8.2 i get the error
Code:
src/Star.cpp:111:14: error: expected initializer before ‘PutStar’
void __cdecl PutStar(int fx, int fy)
              ^~~~~~~
We just fixed it
 
Feb 10, 2019 at 11:15 PM
Junior Member
"Fresh from the Bakery"
Join Date: May 7, 2018
Location:
Posts: 12
#8
Is there any way to compile this with normal MinGW, or does it really require w64?
it should work assuming GCC and the dependencies are supported
 
Feb 11, 2019 at 12:05 AM
In my body, in my head
Forum Moderator
"Life begins and ends with Nu."
Join Date: Aug 28, 2009
Location: The Purple Zone
Posts: 5995
#9
it's my understanding that w64 is the "real" mingw now and the other one is just kept around for legacy purposes, so you should probably be using that.
 
Feb 11, 2019 at 3:14 AM
Cave++ Developer
"..."
Join Date: Sep 22, 2012
Location: Hugging a tentacle monster
Posts: 395
#10
So how long 'till this gets Booster's Lab functionality? It'd be pretty neat to just have there be "plugins" that you could add in to your works to bring the engine to greater heights than what is normally shown in a csbd.
 
Feb 11, 2019 at 10:08 AM
gigantic immortal dog...?
"That dog!"
Join Date: Apr 18, 2006
Location: Forever wandering the tower...!
Posts: 1689
#11
Compiled it and I have to say it looks amazing so far!
Where's Waldo?


I'm rusty though... I couldn't figure out how to set the FPS to 60 to eliminate tearing before needing to quit. Ended up just setting "#define FRAMERATE 16" in Draw.cpp.
Now once this has all the features of the DLL loader... like smoothed movement for the higher graphics scaling (once I figure out how to do that...)! Or adding the ability to smoothly zoom in and out on characters! Ohh...! Though I guess accuracy will be the focus for now ;)
In any case, well done you two!
 
Last edited:
Feb 11, 2019 at 6:33 PM
Senior Member
"Master using it, and you can have this!"
Join Date: Nov 3, 2015
Location: Westminster, Colorado, U.S.A
Posts: 87
Age: 18
#12
Wow nice
 
Feb 11, 2019 at 6:46 PM
Senior Member
CSE Discord Admin
"Master using it, and you can have this!"
Join Date: Jan 13, 2016
Location:
Posts: 76
#13
So how long 'till this gets Booster's Lab functionality? It'd be pretty neat to just have there be "plugins" that you could add in to your works to bring the engine to greater heights than what is normally shown in a csbd.
A better question would be how long until Booster's Lab gets this-functionality.
 
Feb 12, 2019 at 12:07 AM
In my body, in my head
Forum Moderator
"Life begins and ends with Nu."
Join Date: Aug 28, 2009
Location: The Purple Zone
Posts: 5995
#15
hey no bullying
 
Feb 12, 2019 at 12:56 AM
Everything Else Is Irrelevant
Modding Community Discord Admin
"Bleep, Bloop, Bleep, Bloop"
Join Date: Apr 5, 2013
Location: In my mind and of my body.
Posts: 1581
Age: 21
#17
Actually just getting the mapdata moved to a Stage.tbl like CS+ would make it compatible with BL so that's a thing.
Also thank you guys for making the sound effects in their own folder, but what about the ORGs, the icons, and the credits bitmaps?
Since the stage file formats are identical, it should make modding, if people want to mod it, very easy to do since you won't have to deal with baked in things in the exe. (or have to recompile it just to see changes to these things)
 
Feb 12, 2019 at 3:13 PM
Senior Member
CSE Discord Admin
"Master using it, and you can have this!"
Join Date: Jan 13, 2016
Location:
Posts: 76
#18
But the sound effects aren't in their own folder...? They're in the EXE just like the original. And, again, CSE2's goal is accuracy, so splitting all the files and completely switching to CS+'s stage.tbl format is out of the question. That's a job for the 'community-maintained mod base' I mentioned at the start of the thread.

The closest we could possibly do is store stage.tbl in CS+'s format in the source code, and then write a converter that turns it into the vanilla format when the game is built, and embed it in the EXE. That would still leave the issue of Booster's Lab figuring out where the data folder is.
 
Last edited:
Feb 12, 2019 at 8:09 PM
Junior Member
"It's dangerous to go alone!"
Join Date: May 12, 2018
Location: United States
Posts: 30
#19
Last edited:
Feb 13, 2019 at 3:09 PM
Junior Member
"It's dangerous to go alone!"
Join Date: Feb 26, 2018
Location:
Posts: 38
#20
Nice. Now i won't need IDA anymore.
 
Top