Fixed bug when changing from 32-bit to 16-bit screenmodes

Screen size and colors were incorrect
This commit is contained in:
Dimitris Panokostas 2020-07-04 00:22:37 +02:00
parent 37ac96efb8
commit dde55f72f5
3 changed files with 49 additions and 37 deletions

View file

@ -359,7 +359,7 @@ void target_fixup_options(struct uae_prefs* p)
p->cs_cd32fmv = true;
}
p->picasso96_modeflags = RGBFF_CLUT | RGBFF_R5G6B5PC | RGBFF_R8G8B8A8;
p->picasso96_modeflags = RGBFF_CLUT | RGBFF_R5G6B5 | RGBFF_R8G8B8A8;
if (p->gfx_monitor.gfx_size.width == 0)
p->gfx_monitor.gfx_size.width = 720;
if (p->gfx_monitor.gfx_size.height == 0)
@ -385,7 +385,7 @@ void target_fixup_options(struct uae_prefs* p)
void target_default_options(struct uae_prefs* p, int type)
{
p->fast_copper = 0;
p->picasso96_modeflags = RGBFF_CLUT | RGBFF_R5G6B5PC | RGBFF_R8G8B8A8;
p->picasso96_modeflags = RGBFF_CLUT | RGBFF_R5G6B5 | RGBFF_R8G8B8A8;
p->kbd_led_num = -1; // No status on numlock
p->kbd_led_scr = -1; // No status on scrollock

View file

@ -166,7 +166,7 @@ static int display_thread(void *unused)
else
{
depth = 32;
rgb_mode = VC_IMAGE_RGBA32;
rgb_mode = VC_IMAGE_ARGB8888;
}
}
else
@ -683,7 +683,7 @@ static void open_screen(struct uae_prefs* p)
else
{
depth = 32;
pixel_format = SDL_PIXELFORMAT_RGBA32;
pixel_format = SDL_PIXELFORMAT_BGRA32;
}
if (amiberry_options.rotation_angle == 0 || amiberry_options.rotation_angle == 180)
@ -731,7 +731,7 @@ static void open_screen(struct uae_prefs* p)
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
}
screen = SDL_CreateRGBSurface(0, display_width, display_height, depth, 0, 0, 0, 0);
screen = SDL_CreateRGBSurfaceWithFormat(0, display_width, display_height, depth, pixel_format);
check_error_sdl(screen == nullptr, "Unable to create a surface");
texture = SDL_CreateTexture(renderer, pixel_format, SDL_TEXTUREACCESS_STREAMING, screen->w, screen->h);
@ -1491,13 +1491,15 @@ void gfx_set_picasso_state(int on)
screen_is_picasso = on;
open_screen(&currprefs);
if (screen != nullptr)
picasso_vidinfo.rowbytes = screen->pitch;
}
void gfx_set_picasso_modeinfo(uae_u32 w, uae_u32 h, uae_u32 depth, RGBFTYPE rgbfmt)
{
depth >>= 3;
if (!screen_is_picasso)
return;
black_screen_now();
gfx_set_picasso_colors(rgbfmt);
if (static_cast<unsigned>(picasso_vidinfo.width) == w &&
static_cast<unsigned>(picasso_vidinfo.height) == h &&
static_cast<unsigned>(picasso_vidinfo.depth) == depth &&
@ -1507,25 +1509,14 @@ void gfx_set_picasso_modeinfo(uae_u32 w, uae_u32 h, uae_u32 depth, RGBFTYPE rgbf
picasso_vidinfo.selected_rgbformat = rgbfmt;
picasso_vidinfo.width = w;
picasso_vidinfo.height = h;
picasso_vidinfo.depth = screen->format->BitsPerPixel;
picasso_vidinfo.depth = depth;
picasso_vidinfo.extra_mem = 1;
picasso_vidinfo.rowbytes = screen->pitch;
picasso_vidinfo.pixbytes = screen->format->BytesPerPixel;
picasso_vidinfo.rowbytes = static_cast<int>(w * (depth / 8));
picasso_vidinfo.pixbytes = static_cast<int>(depth / 8);
picasso_vidinfo.offset = 0;
if (screen_is_picasso)
{
open_screen(&currprefs);
if(screen != nullptr) {
picasso_vidinfo.rowbytes = screen->pitch;
picasso_vidinfo.rgbformat =
screen->format->BytesPerPixel == 4
? RGBFB_R8G8B8A8
: screen->format->BytesPerPixel == 2
? RGBFB_R5G6B5
: RGBFB_R8G8B8;
}
}
}
void gfx_set_picasso_colors(RGBFTYPE rgbfmt)

View file

@ -872,7 +872,8 @@ static void setconvert()
struct picasso96_state_struct* state = &picasso96_state;
vidinfo->picasso_convert = getconvert (state->RGBFormat, picasso_vidinfo.pixbytes);
vidinfo->host_mode = GetSurfacePixelFormat();
vidinfo->host_mode = picasso_vidinfo.pixbytes == 4 ? RGBFB_R8G8B8A8 : RGBFB_R5G6B5;
//vidinfo->host_mode = GetSurfacePixelFormat();
if (picasso_vidinfo.pixbytes == 4)
alloc_colors_rgb(8, 8, 8, 16, 8, 0, 0, 0, 0, 0, p96rc, p96gc, p96bc);
else
@ -4684,21 +4685,41 @@ static void copyallinvert(uae_u8 *src, uae_u8 *dst, int pwidth, int pheight, int
static void copyall(uae_u8* src, uae_u8* dst, int pwidth, int pheight, int srcbytesperrow, int srcpixbytes, int dstbytesperrow, int dstpixbytes, bool direct, int mode_convert)
{
struct picasso_vidbuf_description* vidinfo = &picasso_vidinfo;
int y, bytes;
if (direct)
{
auto w = pwidth * vidinfo->pixbytes;
for (y = 0; y < pheight; y++)
{
memcpy(dst, src, w);
dst += dstbytesperrow;
src += srcbytesperrow;
}
} else {
for (y = 0; y < pheight; y++)
copyrow(src, dst, 0, y, pwidth, srcbytesperrow, srcpixbytes, 0, y, dstbytesperrow, dstpixbytes, direct, mode_convert, p96_rgbx16);
struct picasso96_state_struct* state = &picasso96_state;
if (state->RGBFormat == RGBFB_R5G6B5) {
if (vidinfo->pixbytes == 2)
copy_screen_16bit_swap(dst, src, state->Width * state->Height * 2);
else
copy_screen_16bit_to_32bit(dst, src, state->Width * state->Height * 2);
}
else if (state->RGBFormat == RGBFB_CLUT) {
const auto pixels = state->Width * state->Height;
if (vidinfo->pixbytes == 2)
copy_screen_8bit_to_16bit(dst, src, pixels, vidinfo->clut);
else
copy_screen_8bit_to_32bit(dst, src, pixels, vidinfo->clut);
}
else {
if (vidinfo->pixbytes == 2)
copy_screen_32bit_to_16bit(dst, src, state->Width * state->Height * 4);
else
copy_screen_32bit_to_32bit(dst, src, state->Width * state->Height * 4);
}
//int y, bytes;
//if (direct)
//{
// auto w = pwidth * vidinfo->pixbytes;
// for (y = 0; y < pheight; y++)
// {
// memcpy(dst, src, w);
// dst += dstbytesperrow;
// src += srcbytesperrow;
// }
//} else {
// for (y = 0; y < pheight; y++)
// copyrow(src, dst, 0, y, pwidth, srcbytesperrow, srcpixbytes, 0, y, dstbytesperrow, dstpixbytes, direct, mode_convert, p96_rgbx16);
//}
}
uae_u8 *getrtgbuffer(int *widthp, int *heightp, int *pitch, int *depth, uae_u8 *palette)