added support for 2/4-bit modes on 8-bit visuals

This commit is contained in:
cebix 2001-07-06 22:00:39 +00:00
parent 6ff613c341
commit 0e7b5acffe
2 changed files with 61 additions and 34 deletions

View File

@ -261,6 +261,32 @@ static void Blit_Copy_Raw(uint8 * dest, const uint8 * source, uint32 length)
#define FB_DEPTH 24
#include "video_blit.h"
/* -------------------------------------------------------------------------- */
/* --- 2/4-bit indexed to 8-bit mode conversion --- */
/* -------------------------------------------------------------------------- */
static void Blit_Expand_2_To_8(uint8 * dest, const uint8 * p, uint32 length)
{
uint8 *q = (uint8 *)dest;
for (int i=0; i<length; i++) {
uint8 c = *p++;
*q++ = c >> 6;
*q++ = (c >> 4) & 3;
*q++ = (c >> 2) & 3;
*q++ = c & 3;
}
}
static void Blit_Expand_4_To_8(uint8 * dest, const uint8 * p, uint32 length)
{
uint8 *q = (uint8 *)dest;
for (int i=0; i<length; i++) {
uint8 c = *p++;
*q++ = c >> 4;
*q++ = c & 0x0f;
}
}
/* -------------------------------------------------------------------------- */
/* --- 2/4/8-bit indexed to 16-bit mode color expansion --- */
/* -------------------------------------------------------------------------- */
@ -402,32 +428,36 @@ bool Screen_blitter_init(XVisualInfo * visual_info, bool native_byte_order, vide
bool blitter_found = false;
// 2/4/8-bit mode on 16/32-bit screen?
if (visualFormat.depth > 8) {
// 2/4/8-bit mode on 8/16/32-bit screen?
if (visualFormat.depth == 8) {
if (mac_depth == VDEPTH_2BIT) {
if (visual_info->depth <= 16) {
Screen_blit = Blit_Expand_2_To_16;
blitter_found = true;
} else {
Screen_blit = Blit_Expand_2_To_32;
blitter_found = true;
}
Screen_blit = Blit_Expand_2_To_8;
blitter_found = true;
} else if (mac_depth == VDEPTH_4BIT) {
if (visual_info->depth <= 16) {
Screen_blit = Blit_Expand_4_To_16;
blitter_found = true;
} else {
Screen_blit = Blit_Expand_4_To_32;
blitter_found = true;
}
Screen_blit = Blit_Expand_4_To_8;
blitter_found = true;
}
} else if (visualFormat.depth == 15 || visualFormat.depth == 16) {
if (mac_depth == VDEPTH_2BIT) {
Screen_blit = Blit_Expand_2_To_16;
blitter_found = true;
} else if (mac_depth == VDEPTH_4BIT) {
Screen_blit = Blit_Expand_4_To_16;
blitter_found = true;
} else if (mac_depth == VDEPTH_8BIT) {
if (visual_info->depth <= 16) {
Screen_blit = Blit_Expand_8_To_16;
blitter_found = true;
} else {
Screen_blit = Blit_Expand_8_To_32;
blitter_found = true;
}
Screen_blit = Blit_Expand_8_To_16;
blitter_found = true;
}
} else if (visualFormat.depth == 24 || visualFormat.depth == 32) {
if (mac_depth == VDEPTH_2BIT) {
Screen_blit = Blit_Expand_2_To_32;
blitter_found = true;
} else if (mac_depth == VDEPTH_4BIT) {
Screen_blit = Blit_Expand_4_To_32;
blitter_found = true;
} else if (mac_depth == VDEPTH_8BIT) {
Screen_blit = Blit_Expand_8_To_32;
blitter_found = true;
}
}

View File

@ -67,7 +67,7 @@ using std::sort;
#include "user_strings.h"
#include "video.h"
#define DEBUG 0
#define DEBUG 1
#include "debug.h"
@ -218,11 +218,8 @@ static bool find_visual_for_depth(video_depth depth)
break;
#ifdef ENABLE_VOSF
case VDEPTH_2BIT:
case VDEPTH_4BIT: // VOSF blitters can convert 2/4-bit -> 16/32-bit
min_depth = 15;
max_depth = 32;
break;
case VDEPTH_8BIT: // VOSF blitters can convert 8-bit -> 16/32-bit
case VDEPTH_4BIT: // VOSF blitters can convert 2/4/8-bit -> 8/16/32-bit
case VDEPTH_8BIT:
min_depth = 8;
max_depth = 32;
break;
@ -525,10 +522,8 @@ driver_base::~driver_base()
void driver_base::update_palette(void)
{
if (cmap[0] && cmap[1]) {
int num = 256;
if (IsDirectMode(VideoMonitor.mode))
num = vis->map_entries; // Palette is gamma table
else if (color_class == DirectColor)
int num = vis->map_entries;
if (!IsDirectMode(VideoMonitor.mode) && color_class == DirectColor)
return; // Indexed mode on true color screen, don't set CLUT
XStoreColors(x_display, cmap[0], palette, num);
XStoreColors(x_display, cmap[1], palette, num);
@ -1655,13 +1650,15 @@ void video_set_palette(uint8 *pal, int num_in)
// Convert colors to XColor array
int num_out = 256;
bool stretch = false;
if (IsDirectMode(VideoMonitor.mode)) {
// If X is in 565 mode we have to stretch the gamma table from 32 to 64 entries
num_out = vis->map_entries;
stretch = true;
}
XColor *p = palette;
for (int i=0; i<num_out; i++) {
int c = (i * num_in) / num_out;
int c = (stretch ? (i * num_in) / num_out : i);
p->red = pal[c*3 + 0] * 0x0101;
p->green = pal[c*3 + 1] * 0x0101;
p->blue = pal[c*3 + 2] * 0x0101;