From e63c6b91dc0aaa5fd3731cf17850f3aad546d235 Mon Sep 17 00:00:00 2001 From: Ricky Zhang Date: Sat, 4 Jul 2020 14:12:15 -0400 Subject: [PATCH] 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 --- BasiliskII/src/SDL/video_sdl2.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/BasiliskII/src/SDL/video_sdl2.cpp b/BasiliskII/src/SDL/video_sdl2.cpp index 032023f4..646c28f5 100644 --- a/BasiliskII/src/SDL/video_sdl2.cpp +++ b/BasiliskII/src/SDL/video_sdl2.cpp @@ -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