CSE2 - The Cave Story decompilation project

May 24, 2020 at 9:45 PM
War criminal
"Life begins and ends with Nu."
Join Date: Jun 27, 2013
Location: Phoenix
Posts: 2758
Age: 29
But yeah, currently <PHY, <MIM, and <MS4 are available.
PogChamp Now to wait for the <VAR set to be implemented so all essential custom TSC commands can be in!
 
May 25, 2020 at 8:10 PM
Indie game enthusiast
"What is a man!? A miserable pile of secrets! But enough talk, have at you!"
Join Date: Apr 18, 2006
Location: Forever wandering the tower...!
Posts: 1787
Not hearing any of the ogg soundtracks at all when selecting their option using 2.1 enhanced (Tested New and Remastered, copied from CS+, option is selectable).
Is it just me?
 
May 26, 2020 at 1:35 AM
Senior Member
CSE Discord Admin
"Fly, Fly, Fly!"
Join Date: Jan 13, 2016
Location:
Posts: 132
Whoops, sorry - my Windows builder had bad CMake settings. If you redownload CSE2E, the problem should be fixed now.
 
May 26, 2020 at 8:47 AM
Indie game enthusiast
"What is a man!? A miserable pile of secrets! But enough talk, have at you!"
Join Date: Apr 18, 2006
Location: Forever wandering the tower...!
Posts: 1787
Whoops, sorry - my Windows builder had bad CMake settings. If you redownload CSE2E, the problem should be fixed now.
Nice, all are playing now. Though, I found an org playback bug when the window lost focus. I started with org playback, then switched to ogg. However, whenever I click off the window and regain focus, the last org in memory will start back up along with the ogg that is supposed to play.
 
Jul 12, 2020 at 8:41 PM
Indie game enthusiast
"What is a man!? A miserable pile of secrets! But enough talk, have at you!"
Join Date: Apr 18, 2006
Location: Forever wandering the tower...!
Posts: 1787
Was testing the spinoff Tweaks branch when I realized v-sync + 60 fps seems to quickly fill up the input buffer. Try jumping and shooting and spamming movement keys while v-sync + 60 fps is on. It should end up with Quote reading commands in a delayed fashion. The first time it happened I just froze xD It was basically as if I had triggered some kind of AI mode for Quote, as I had stopped pushing buttons but he was running around on his own randomly firing at enemies for a short bit.
(This is especially noticeable if you have a rapidfire button binded!)

v-sync off eliminates this
 
Jul 13, 2020 at 12:14 AM
Senior Member
CSE Discord Admin
"Fly, Fly, Fly!"
Join Date: Jan 13, 2016
Location:
Posts: 132
Oh wow, thanks for catching that. It turns out I converted some WinAPI code to SDL2 incorrectly (it only processes one input per frame instead of every available input like the original does).
 
Jul 15, 2020 at 8:00 PM
Senior Member
CSE Discord Admin
"Fly, Fly, Fly!"
Join Date: Jan 13, 2016
Location:
Posts: 132
Things have been a little slow lately, so here's more of a maintenance release:

CSE2 v2.1.1

Binaries:
CSE2 - Portable
CSE2 - Enhanced

Enhanced
Support for a new soundtrack has been added: DM Dokuro's 'Cave Story Arranged'. You might remember this from my old DLL loader - unlike the DLL loader, however, this version supports the jingles and has proper looping support.

In addition, each soundtrack has had its volume adjusted, to prevent some being significantly louder than others.

Portable
The other major change is more of a technical one - the software sound mixer that fulfils the role DirectSound did in the original EXE has been converted from floating-point to integer-only. This should eliminate inconsistencies between platforms, avoid annoying rounding-errors (like the ones that once caused some annoying hissing a few releases ago), and be faster in general.

Another fun change was that I found a bug in the FreeType setup CSE2 uses to render fonts: now monochrome text should render much better at low resolutions, thanks to proper hinting being enabled.

Before:
p373860-0-unknown.png


After:
p373860-1-unknown.png


This finally makes 320x240 viable without needing to use Courier New. Unfortunately, neither Japanese font CSE2 uses provides hinting for low resolutions.

Oh right, another change - the Japanese font has been switched from Noto Mono to Migu 1M. It's much smaller (3MB vs 16MB), renders better (Noto draws too low for some reason), and displays at the right size using Cave Story's original font size values.

This is a bit of a minor change, but SDL2 and FreeType have been upgraded from 2.0.10 and 2.10.1 to 2.0.12 and 2.10.2, respectively, so hopefully some under-the-hood improvements have made it into this release.

Two bugs have been fixed as well: the audio buzzing in the Wii U port should be gone now, and the bug mentioned in the post above about delayed user inputs has also been fixed.

Accurate
Nothing too groundbreaking has happened in this branch, unfortunately. Some constants and enums have been added here and there, and some fixes for undefined-behaviour have been backported from the portable branch, but that's about it.
 
Last edited:
Aug 25, 2020 at 8:02 PM
Senior Member
CSE Discord Admin
"Fly, Fly, Fly!"
Join Date: Jan 13, 2016
Location:
Posts: 132
CSE2's had a bit of a shuffle. Basically, the Enhanced branch has been killed-off - I don't want to be in charge of making a definitive version of Cave Story; it's just not my thing. Instead, I'm leaving that up to the various forks out there. The CSE2 project will now focus on providing an accurate base for these forks to build upon.

To go into more detail, the Enhanced branch turned out to be way more complex than I expected. For example, people have requested stuff like user-defined aspect ratios, resolutions, and support for CS+ features. That's not even getting into the modding side of things: ideally, a modding-focussed engine would support the entire TSC+ set of commands, and rain even made a PR for a debug console. This is all far beyond what I had in mind for the project.

Not only was there scope-creep, but the Enhanced branch also represented a massive conflict of interests: the Accurate and Portable branches are all about being as close to the original code as possible - Enhanced isn't. There are a bunch of times where I've shot-down features because they require too many modifications to the engine, even though that shouldn't be a factor at all. It also doesn't help that I've never made a Cave Story mod in my life, and here I am dictating what features should be added to an engine specifically intended for modding.

It just doesn't make sense for me to be handling this kind of project. Truth be told, the Enhanced branch has always just been my personal definitive build of Cave Story: if I wanted a feature, I'd add it - if someone else wanted a feature that I didn't like, I wouldn't add it. Remember that debug console I mentioned? That PR never got merged - I didn't want to maintain it.

So, instead of derailing the project like that, I'm just going to make it official - the Enhanced branch has been repurposed as my own personal CSE2 fork: CSE2EX. Great name, I know.

Hopefully forks will pick up where the Enhanced branch left off. Cave Story: Tweaked is providing an accessibility and quality-of-life focussed version of CSE2 that might appeal to those who just want a better Cave Story. As for you modders out there, Cucky's working on something that will hopefully be ready to show off soon. The Discord server has been expanded to include these projects.

If you're any good at C or C++, I recommend getting out there and making/contributing to a fork. It will only make CSE2 bigger and better.
 
Last edited:
Sep 24, 2020 at 8:05 PM
Senior Member
CSE Discord Admin
"Fly, Fly, Fly!"
Join Date: Jan 13, 2016
Location:
Posts: 132
For anyone really new to C++ who wants to compile CSE2, I've added a guide (with pictures) to the main post. Unlike other guides, this one uses Visual Studio, which should hopefully simplify a lot of the compilation process while also providing a handy-dandy IDE for making code modifications.
 
Last edited:
Oct 18, 2020 at 5:23 PM
Senior Member
CSE Discord Admin
"Fly, Fly, Fly!"
Join Date: Jan 13, 2016
Location:
Posts: 132
Well, I guess this is the first portable-only CSE2 update:

CSE2 v2.2
Download here

Font overhaul

The main focus of this update is the font system, which has always been the least accurate part of CSE2.

Where do I begin... well, for starters, the font system no longer emulates a bug in the original game: if you run the original freeware EXE in Windows XP, you'll notice the font doesn't have any anti-aliasing. In Windows Vista and later, however, it does. Anti-aliasing is bad because it conflicts with the game's colour-keying system, causing text to have an ugly crusty black-blue-and-red outline:
p368707-0-unknown.png


This bug has been fixed because CSE2 portable has had a slight shift in direction: rather than providing an accurate emulation of the original EXE as it is on modern PCs, it now provides an accurate emulation of the original EXE as it was back-in-the-day. Since PCs of the era didn't have anti-aliasing enabled (at least not by default), this bug has been corrected.

Unrelated bugs in the font renderer have also been fixed, increasing compatibility with alternate fonts.

Speaking of fonts, Courier New and MS Gothic have made a return: previously they were removed for legal reasons and replaced with DejaVu Mono and Migu1M, but now they've been brought back, and they're more accurate than ever:

You see, even with the original Courier New font file, CSE2 Portable didn't actually render it the same as the original EXE. This is because the original EXE uses Windows to render the font, while CSE2 uses FreeType. The two do not render identically:
unknown.png


To work around this, I've overhauled the font renderer to not use FreeType at all: rather than generating characters from a font file, CSE2 now simply has a big PNG file containing a complete set of pre-rendered characters. This allows for text rendering to match the original EXE with 100% accuracy.

This method also presumably works around the legal issue that prevented the use of Courier New and MS Gothic before, since apparently typefaces cannot be protected by copyright - only the font files themselves.

Misc.

Window resizing has been added, to make 320x240 mode useable on modern high-DPI systems. The official Cave Story beta images show the game running at 320x240, so it seems that this was the way Pixel intended the game to be played.
sc020218.png


An under-the-hood change has also been made to the way text blits are batched:

Previously, CSE2 relied on the cute_spritebatch.h library to maintain a texture atlas. On top of being plain overkill, this had two issues:
  • cute_spritebatch.h was written in C++11, while the rest of CSE2 used C++98.
  • cute_spritebatch.h was very complex, and did a lot of texture creation/destruction internally. This caused frameskipping for some users.
To address this, I've replaced it with my own texture-atlas system, which has neither of these issues.

The accurate branch has had some minor updates too: a little extra documentation here, a few authentic struct names restored there, etc.

Closing

Hopefully, now that I'm done with this, I can finally start working on CSE2EX. It's nice to finally have accurate font rendering: that's been a problem area for as long as CSE2 has existed. Heck, I think it might have even been a problem for CSE1.
 
Last edited:
Oct 18, 2020 at 9:05 PM
Senior Member
"Fly, Fly, Fly!"
Join Date: Nov 3, 2015
Location: Westminster, Colorado, U.S.A
Posts: 128
cse2ex finally poggers champ

clownacy we have matching post count omg when can we get friendship bracelets and sit at the same lunch table <3<3
 
Nov 23, 2020 at 5:41 PM
War criminal
"Life begins and ends with Nu."
Join Date: Jun 27, 2013
Location: Phoenix
Posts: 2758
Age: 29
Looks like CSE2 got taken down by Nicalis.
 
Nov 23, 2020 at 6:28 PM
War criminal
"Life begins and ends with Nu."
Join Date: Jun 27, 2013
Location: Phoenix
Posts: 2758
Age: 29
Nov 23, 2020 at 7:41 PM
Mint Online
Deliverer of Sweets
Bobomb says: "I need a hug!"
Join Date: Jul 20, 2015
Location: Under sea level or something
Posts: 785
Age: 25
This doesn't really seem super right, not only do I remember CSE2 being not the 1:1 source code of the freeware game (though I could be wrong) but the infringed work that's being referred to are their switch/steam ports.
Unless they more clearly express their ownership over the freeware version something just feels off about it.
 
Nov 23, 2020 at 7:45 PM
Neophyte Member
"Fresh from the Bakery"
Join Date: Nov 23, 2020
Location:
Posts: 3
I hope this serves as a wake-up call to remove Ewan from your server.
stay mad
This doesn't really seem super right, not only do I remember CSE2 being not the 1:1 source code of the freeware game (though I could be wrong) but the infringed work that's being referred to are their switch/steam ports.
Unless they more clearly express their ownership over the freeware version something just feels off about it.
There's somebody in the CSE2 server pretending to be a lawyer with random tidbits like "I'm in contact with an ex nicalis employee who confirmed with me that the purchase of the cave story IP from pixel included the original freeware game and source".
 
Last edited:
Top