185 |
|
* Utility functions |
186 |
|
*/ |
187 |
|
|
188 |
+ |
// Map RGB color to pixel value (this only works in TrueColor/DirectColor visuals) |
189 |
+ |
static inline uint32 map_rgb(uint8 red, uint8 green, uint8 blue) |
190 |
+ |
{ |
191 |
+ |
return ((red >> rloss) << rshift) | ((green >> gloss) << gshift) | ((blue >> bloss) << bshift); |
192 |
+ |
} |
193 |
+ |
|
194 |
|
// Add mode to list of supported modes |
195 |
|
static void add_mode(uint32 width, uint32 height, uint32 resolution_id, uint32 bytes_per_row, video_depth depth) |
196 |
|
{ |
485 |
|
|
486 |
|
// Create normal X image if SHM doesn't work ("height + 2" for safety) |
487 |
|
if (!have_shm) { |
488 |
< |
int bytes_per_row = TrivialBytesPerRow(aligned_width, mode.depth); |
488 |
> |
int bytes_per_row = (mode.depth == VDEPTH_1BIT ? aligned_width/8 : TrivialBytesPerRow(aligned_width, DepthModeForPixelDepth(xdepth))); |
489 |
|
the_buffer_copy = (uint8 *)malloc((aligned_height + 2) * bytes_per_row); |
490 |
|
img = XCreateImage(x_display, vis, mode.depth == VDEPTH_1BIT ? 1 : xdepth, mode.depth == VDEPTH_1BIT ? XYBitmap : ZPixmap, 0, (char *)the_buffer_copy, aligned_width, aligned_height, 32, bytes_per_row); |
491 |
|
} |
1049 |
|
XStoreColors(x_display, cmap[1], palette, num); |
1050 |
|
} |
1051 |
|
|
1052 |
+ |
#ifdef ENABLE_VOSF |
1053 |
+ |
// Load gray ramp to 8->16/32 expand map |
1054 |
+ |
if (!IsDirectMode(mode) && (vis->c_class == TrueColor || vis->c_class == DirectColor)) |
1055 |
+ |
for (int i=0; i<256; i++) |
1056 |
+ |
ExpandMap[i] = map_rgb(i, i, i); |
1057 |
+ |
#endif |
1058 |
+ |
|
1059 |
|
// Create display driver object of requested type |
1060 |
|
switch (display_type) { |
1061 |
|
case DISPLAY_WINDOW: |
1246 |
|
int num = vis->map_entries; |
1247 |
|
for (int i=0; i<num; i++) { |
1248 |
|
int c = (i * 256) / num; |
1249 |
< |
palette[i].pixel = ((c >> rloss) << rshift) | ((c >> gloss) << gshift) | ((c >> bloss) << bshift); |
1249 |
> |
palette[i].pixel = map_rgb(c, c, c); |
1250 |
|
} |
1251 |
|
} |
1252 |
|
|
1295 |
|
add_mode(512, 384, 0x80, TrivialBytesPerRow(512, VDEPTH_1BIT), VDEPTH_1BIT); |
1296 |
|
add_mode(640, 480, 0x81, TrivialBytesPerRow(640, VDEPTH_1BIT), VDEPTH_1BIT); |
1297 |
|
add_mode(800, 600, 0x82, TrivialBytesPerRow(800, VDEPTH_1BIT), VDEPTH_1BIT); |
1298 |
< |
add_mode(832, 624, 0x83, TrivialBytesPerRow(832, VDEPTH_1BIT), VDEPTH_1BIT); |
1299 |
< |
add_mode(1024, 768, 0x84, TrivialBytesPerRow(1024, VDEPTH_1BIT), VDEPTH_1BIT); |
1300 |
< |
add_mode(1152, 870, 0x85, TrivialBytesPerRow(1152, VDEPTH_1BIT), VDEPTH_1BIT); |
1301 |
< |
add_mode(1280, 1024, 0x86, TrivialBytesPerRow(1280, VDEPTH_1BIT), VDEPTH_1BIT); |
1289 |
< |
add_mode(1600, 1200, 0x87, TrivialBytesPerRow(1600, VDEPTH_1BIT), VDEPTH_1BIT); |
1298 |
> |
add_mode(1024, 768, 0x83, TrivialBytesPerRow(1024, VDEPTH_1BIT), VDEPTH_1BIT); |
1299 |
> |
add_mode(1152, 870, 0x84, TrivialBytesPerRow(1152, VDEPTH_1BIT), VDEPTH_1BIT); |
1300 |
> |
add_mode(1280, 1024, 0x85, TrivialBytesPerRow(1280, VDEPTH_1BIT), VDEPTH_1BIT); |
1301 |
> |
add_mode(1600, 1200, 0x86, TrivialBytesPerRow(1600, VDEPTH_1BIT), VDEPTH_1BIT); |
1302 |
|
} |
1303 |
+ |
#ifdef ENABLE_VOSF |
1304 |
+ |
if (default_depth > VDEPTH_8BIT) { // 8-bit modes are also possible on 16/32-bit screens with VOSF blitters |
1305 |
+ |
add_mode(512, 384, 0x80, TrivialBytesPerRow(512, VDEPTH_8BIT), VDEPTH_8BIT); |
1306 |
+ |
add_mode(640, 480, 0x81, TrivialBytesPerRow(640, VDEPTH_8BIT), VDEPTH_8BIT); |
1307 |
+ |
add_mode(800, 600, 0x82, TrivialBytesPerRow(800, VDEPTH_8BIT), VDEPTH_8BIT); |
1308 |
+ |
add_mode(1024, 768, 0x83, TrivialBytesPerRow(1024, VDEPTH_8BIT), VDEPTH_8BIT); |
1309 |
+ |
add_mode(1152, 870, 0x84, TrivialBytesPerRow(1152, VDEPTH_8BIT), VDEPTH_8BIT); |
1310 |
+ |
add_mode(1280, 1024, 0x85, TrivialBytesPerRow(1280, VDEPTH_8BIT), VDEPTH_8BIT); |
1311 |
+ |
add_mode(1600, 1200, 0x86, TrivialBytesPerRow(1600, VDEPTH_8BIT), VDEPTH_8BIT); |
1312 |
+ |
} |
1313 |
+ |
#endif |
1314 |
|
add_mode(512, 384, 0x80, TrivialBytesPerRow(512, default_depth), default_depth); |
1315 |
|
add_mode(640, 480, 0x81, TrivialBytesPerRow(640, default_depth), default_depth); |
1316 |
|
add_mode(800, 600, 0x82, TrivialBytesPerRow(800, default_depth), default_depth); |
1317 |
< |
add_mode(832, 624, 0x83, TrivialBytesPerRow(832, default_depth), default_depth); |
1318 |
< |
add_mode(1024, 768, 0x84, TrivialBytesPerRow(1024, default_depth), default_depth); |
1319 |
< |
add_mode(1152, 870, 0x85, TrivialBytesPerRow(1152, default_depth), default_depth); |
1320 |
< |
add_mode(1280, 1024, 0x86, TrivialBytesPerRow(1280, default_depth), default_depth); |
1298 |
< |
add_mode(1600, 1200, 0x87, TrivialBytesPerRow(1600, default_depth), default_depth); |
1317 |
> |
add_mode(1024, 768, 0x83, TrivialBytesPerRow(1024, default_depth), default_depth); |
1318 |
> |
add_mode(1152, 870, 0x84, TrivialBytesPerRow(1152, default_depth), default_depth); |
1319 |
> |
add_mode(1280, 1024, 0x85, TrivialBytesPerRow(1280, default_depth), default_depth); |
1320 |
> |
add_mode(1600, 1200, 0x86, TrivialBytesPerRow(1600, default_depth), default_depth); |
1321 |
|
} |
1322 |
|
} else |
1323 |
|
add_mode(default_width, default_height, 0x80, TrivialBytesPerRow(default_width, default_depth), default_depth); |
1468 |
|
p++; |
1469 |
|
} |
1470 |
|
|
1471 |
+ |
#ifdef ENABLE_VOSF |
1472 |
+ |
// Recalculate pixel color expansion map |
1473 |
+ |
if (!IsDirectMode(VideoMonitor.mode) && (vis->c_class == TrueColor || vis->c_class == DirectColor)) { |
1474 |
+ |
for (int i=0; i<256; i++) |
1475 |
+ |
ExpandMap[i] = map_rgb(pal[i*3+0], pal[i*3+1], pal[i*3+2]); |
1476 |
+ |
|
1477 |
+ |
// We have to redraw everything because the interpretation of pixel values changed |
1478 |
+ |
LOCK_VOSF; |
1479 |
+ |
PFLAG_SET_ALL; |
1480 |
+ |
UNLOCK_VOSF; |
1481 |
+ |
memset(the_buffer_copy, 0, VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y); |
1482 |
+ |
} |
1483 |
+ |
#endif |
1484 |
+ |
|
1485 |
|
// Tell redraw thread to change palette |
1486 |
|
palette_changed = true; |
1487 |
|
|