Skip to content

Commit

Permalink
fixed issue #1: SDL2 backend did not support 2 or 4 bit color, in gue…
Browse files Browse the repository at this point in the history
…st OS
  • Loading branch information
DavidLudwig committed Aug 10, 2017
1 parent 251c185 commit c6fefd0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 41 deletions.
6 changes: 5 additions & 1 deletion BasiliskII/src/CrossPlatform/video_blit.cpp
Expand Up @@ -498,12 +498,16 @@ bool Screen_blitter_init(VisualFormat const & visual_format, bool native_byte_or
#else
const bool use_sdl_video = false;
#endif
#if REAL_ADDRESSING || DIRECT_ADDRESSING
#if REAL_ADDRESSING || DIRECT_ADDRESSING || USE_SDL_VIDEO
if (mac_depth == 1 && !use_sdl_video && !visual_format.fullscreen) {

// Windowed 1-bit mode uses a 1-bit X image, so there's no need for special blitting routines
Screen_blit = Blit_Copy_Raw;

} else if (mac_depth == 16) {

Screen_blit = Blit_Copy_Raw;

} else {

// Compute RGB shift values
Expand Down
48 changes: 8 additions & 40 deletions BasiliskII/src/SDL/video_sdl.cpp
Expand Up @@ -810,6 +810,12 @@ static int update_sdl_video()
return 0;
}

static int update_sdl_video(SDL_Surface *s, int x, int y, int w, int h)
{
// HACK, dludwig@pobox.com: for now, just update the whole screen
return update_sdl_video();
}

void driver_base::set_video_mode(int flags)
{
int depth = sdl_depth_of_video_depth(VIDEO_MODE_DEPTH);
Expand Down Expand Up @@ -2061,43 +2067,6 @@ static void handle_events(void)
// Static display update (fixed frame rate, but incremental)
static void update_display_static(driver_base *drv)
{
// Lock surface, if required
if (SDL_MUSTLOCK(drv->s))
SDL_LockSurface(drv->s);

const VIDEO_MODE &mode = drv->mode;

memcpy(the_buffer_copy, the_buffer, the_buffer_size);

// HACK: Create a temporary surface, with which to use in color conversion
SDL_Surface * mid_surface = NULL;
switch (mode.depth) {
case VDEPTH_1BIT: {
const int pixels_per_byte = VIDEO_MODE_X / VIDEO_MODE_ROW_BYTES;
mid_surface = SDL_CreateRGBSurfaceFrom(the_buffer_copy, VIDEO_MODE_X, VIDEO_MODE_Y, 1, (VIDEO_MODE_X / pixels_per_byte), 1, 1, 1, 0);
} break;

// Consider using Screen_blit, for other depths

default: {
printf("WARNING: Unhandled depth mode in SDL backend: %s\n", NameOfDepth(mode.depth));
} break;
}

// Blit to screen surface
if (mid_surface) {
SDL_BlitSurface(mid_surface, NULL, drv->s, NULL);
SDL_FreeSurface(mid_surface);
}

// Unlock surface, if required
if (SDL_MUSTLOCK(drv->s))
SDL_UnlockSurface(drv->s);

// Refresh display
update_sdl_video();

/*
// Incremental update code
int wide = 0, high = 0;
uint32 x1, x2, y1, y2;
Expand Down Expand Up @@ -2181,7 +2150,7 @@ static void update_display_static(driver_base *drv)
SDL_UnlockSurface(drv->s);

// Refresh display
SDL_UpdateRect(drv->s, x1, y1, wide, high);
update_sdl_video(drv->s, x1, y1, wide, high);
}

} else {
Expand Down Expand Up @@ -2237,11 +2206,10 @@ static void update_display_static(driver_base *drv)
SDL_UnlockSurface(drv->s);

// Refresh display
SDL_UpdateRect(drv->s, x1, y1, wide, high);
update_sdl_video(drv->s, x1, y1, wide, high);
}
}
}
*/
}

// Static display update (fixed frame rate, bounding boxes based)
Expand Down

0 comments on commit c6fefd0

Please sign in to comment.