Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simulate the original palettized 8-bit mode using the SDL_Renderer backend #67

Open
nmlgc opened this issue Aug 28, 2024 · 0 comments
Open
Labels
Enhancement New feature or request Graphics Portability Porting the game away from 32-bit Windows ~≤1 push Projected number of pushes needed. Might turn out to get more expensive!

Comments

@nmlgc
Copy link
Owner

nmlgc commented Aug 28, 2024

In the README, pbg highlights the split between palettized DirectDraw 8-bit and direct-color Direct3D 16-bit modes as a particularly noteworthy aspect of the period in time when this game was written:

8bit/16bitカラーの混在、MIDI再生関連、浮動小数点数演算を避ける、あたりが懐かしポイントになるかと思います。

Consequently, I've kept both modes in runnable form in every one of my releases until P0275 to preserve this historic detail.

However, SDL_Renderer doesn't provide any way to set a bit depth for the final framebuffer. And while you can specify a bit depth for each texture, the APIs and underlying hardware mostly don't support anything below 8 bits per color channel, let alone a palettized mode with color key. The software renderer does support at least two 16-bit modes, but as soon as you need transparency, there's no way around a full 8-bit alpha channel, which is only available in 32-bit formats.
As a result, the initial build that will ship #4 will only render the original 16-bit graphics and won't offer the 8-bit ones. (It will come with a separate .exe containing the old DirectDraw/Direct3D backend, though.)

But we could still simulate the 8-bit mode to at least preserve the exact original look, even if it's technically not "true" 8-bit. SDL does have support for palettized surfaces (which is the entire reason why we can load the original .BMP graphics with a sequence of 4 function calls), and SDL_Renderer can software-render onto such a palettized 8-bit surface. Thus, the basic support shouldn't involve all too much work, but who knows which tiny little issues we're going to run into for a perfect simulation – after all, it took quite a while to figure out how and why the original paletted 8-bit mode even worked to begin with.

This is about porting the 8-bit mode to modern systems. It will (probably) not make the SDL build run at full speed on period-correct Windows 9x machines, although we'd have to measure exactly how much slower SDL's software renderer would perform on such systems when compared to DirectDraw.
And yes, this simulation implies full software rendering for the entire game, followed by an upconversion from 8-bit to 32-bit for GPU-accelerated scaling every frame. Even on modern systems, it will, ironically, be much slower than the regular direct-color render path.

Depends on #63, which can be seen as a partial version of this issue that only cares about preserving the original 8-bit mode's software geometry rendering.

@nmlgc nmlgc added Enhancement New feature or request Graphics ~≤1 push Projected number of pushes needed. Might turn out to get more expensive! Portability Porting the game away from 32-bit Windows labels Aug 28, 2024
@nmlgc nmlgc changed the title Simulate the original palettized 8-bit mode in SDL Simulate the original palettized 8-bit mode using the SDL_Renderer backend Oct 5, 2024
nmlgc added a commit that referenced this issue Oct 22, 2024
The only way to preserve the palettized 8-bit mode until #67. Also
reducing BLAKE3 to the generic C implementation as this build will
ultimately turn into the 32-bit Windows 98 build funded in #53.

Part of P0293, funded by Ember2528.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Graphics Portability Porting the game away from 32-bit Windows ~≤1 push Projected number of pushes needed. Might turn out to get more expensive!
Projects
None yet
Development

No branches or pull requests

1 participant