Resident Evil 2 will say goodbye to deprecated tech

As those following my recent twitter updates may have noticed, I’ve been rewriting a huge deal of code recently. So what does this translate to? Find out after the jump.

Like the title implies, I’ve been migrating Resident Evil 2 to more modern graphical and audio technology: I got XAudio2 in one corner for the sound and DirectX9 for the graphics. Long story short, it will not depend anymore on deprecated or non-working pre-Windows XP modules.

Here’s a list of what DirectX9 does compared to DirectDraw.

  • It provides native support to modern GPUs, instead of relying on some sort of hardware-software mixed emulation, effectively making rendering lightweight and more precise in general.
  • It allows to rewrite the whole rendering code in a manner closer to the original PlayStation sorted list approach, which removes the need of hacks used for approximated depth simulation. In other words, on PC it’s currently using a real z-buffer for depth while it’s internally emulating the PSX transformation engine (the GTE) and uses draw lists in order to keep everything in place.
  • Blending for texture mapping has been greatly revamped to support what the PlayStation was capable of. To give an example of the more advanced alpha blending used, here’s the player shadow (left original, right new one):The trick used on PlayStation with shadows was a grey texture that renders in reverse colors and subtracts what’s underneath it. The original PC blending approximates that by reversing the texture color in software and simply draws it as semi-transparent, while the new one can effectively produce subtractive blending and achieves the original intended effect. This applies to other effects, such as smoke clouds, water, etc.
  • It finally allows us to implement HD texture packs such as RE2 SHDP with very little effort or extra steps.

And now for sound with XAudio2, which replaces DirectSound:

  • In terms of raw power, the biggest advantage of XAudio2 is that it makes non-trivial tasks, such as looping music, completely painless. This will be used to fix a number of details that don’t quite match with the original sound, like a bunch of BGM tracks which can’t loop seamlessly by repeating the whole song.
  • The worst thing about the original engine is that it relied heavily on msacm (aka Windows Multimedia), a sorta deprecated Windows module responsible for codecs and other things. This module would be used to decompress and resample the game’s ADPCM audio. The problem with msacm is that it seems to fail in some scenarios for unknown reasons since it just won’t boot sometimes on Windows 8. This module was completely removed and replaced with a custom ADPCM decompressor and ffmpeg for resampling.
  • Native support for OGG decoding with ffmpeg and support for vanilla OGG with sound files that only have one sample (voices and BGMs). This used to be a little hacky before, since it would override the mmi modules (Windows Multimedia RIFF wave parser) and generated intermediate data, but now it’s entirely working with straight data feeding the XAudio2 driver, so it’s faster, uses less memory, and works even on audio files not intended for mods.
  • It removes the need to use sound quality settings, since stereo 44KHz sound is nowadays the most common audio format and isn’t that CPU intensive to process.

All this stuff will be coming to version 1.1.0 of RE2 Classic REbirth. Yes, I’m skipping 1.0.9 as this is technically a major milestone. Also, most of the code being used for this rewrite will be recycled on the first Resident Evil as well.