Patch SDL2 palette for 24bit ROM.

24bit ROM doesn't invoke video driver control. Therefore, a manual step
is required to add a black & white palette for guest_surface in SDL2.

Please check out [the screen cast here](https://youtu.be/br5Hjt9F6X4).

Signed-off-by: Ricky Zhang <rickyzhang@gmail.com>
This commit is contained in:
Ricky Zhang 2020-07-04 14:12:15 -04:00
parent 40f6c77775
commit e63c6b91dc
No known key found for this signature in database
GPG Key ID: 681AFAEF6CDEDB4C
1 changed files with 17 additions and 0 deletions

View File

@ -980,6 +980,23 @@ void driver_base::set_video_mode(int flags)
void driver_base::init()
{
set_video_mode(display_type == DISPLAY_SCREEN ? SDL_WINDOW_FULLSCREEN : 0);
// manually set palette for 24bit ROM
// 24 bit ROM Macintosh is BW screen. It doesn't setup palette by the ROM.
if (TwentyFourBitAddressing && !sdl_palette) {
const int nColor = 255;
sdl_palette = SDL_AllocPalette(nColor);
SDL_Color *p = sdl_palette->colors;
for (int i = 0; i < nColor; i++) {
if (0 == i %2) {
p->r = 0; p->g = 0; p->b = 0;
} else {
p->r = 255; p->g = 255; p->b = 255;
}
p++;
}
update_palette();
}
int aligned_height = (VIDEO_MODE_Y + 15) & ~15;
#ifdef ENABLE_VOSF