]> git.pld-linux.org Git - packages/Frodo.git/blame - Frodo-16+bpp.patch
- adapted to PLD
[packages/Frodo.git] / Frodo-16+bpp.patch
CommitLineData
4e160860
JB
1diff -Nur Frodo.orig/Src/Display_x.i Frodo/Src/Display_x.i
2--- Frodo.orig/Src/Display_x.i Wed Aug 6 20:56:26 1997
3+++ Frodo/Src/Display_x.i Fri Jun 15 13:48:00 2001
4@@ -4,6 +4,8 @@
5 *
6 * Frodo (C) 1994-1997 Christian Bauer
7 * X11 stuff by Bernd Schmidt/Lutz Vieweg
8+ * Support for visuals >8 bits by Michael Krause
9+ * Support for visuals >16 bits by qboosh@pld.org.pl
10 */
11
12 #include "CmdPipe.h"
13@@ -35,7 +37,8 @@
14 static Visual *vis;
15 static XVisualInfo visualInfo;
16 static int bitdepth;
17-static char *bufmem;
18+static char *bufmem, *bufmem8;
19+static uint32 trans[1<<12];
20 static int hsize;
21
22 // For LED error blinking
23@@ -382,13 +385,10 @@
24
25 screen = XDefaultScreen(display);
26 rootwin = XRootWindow(display, screen);
27-#if 0
28 if (XMatchVisualInfo(display, screen, 16, TrueColor, &visualInfo)) {
29+ } else if (XMatchVisualInfo(display, screen, 32, TrueColor, &visualInfo)) {
30 } else if (XMatchVisualInfo(display, screen, 24, TrueColor, &visualInfo)) {
31- } else
32-#endif
33- if (XMatchVisualInfo(display, screen, 8, PseudoColor, &visualInfo)) {
34- /* for our HP boxes */
35+ } else if (XMatchVisualInfo(display, screen, 8, PseudoColor, &visualInfo)) {
36 } else if (XMatchVisualInfo(display, screen, 8, GrayScale, &visualInfo)) {
37 } else {
38 fprintf(stderr, "Can't obtain appropriate X visual\n");
39@@ -397,8 +397,8 @@
40
41 vis = visualInfo.visual;
42 bitdepth = visualInfo.depth;
43 pixbytes = (bitdepth == 24 || bitdepth == 32 ? 4 : bitdepth == 12 || bitdepth == 16 ? 2 : 1);
44- fprintf(stderr, "Using %d bit visual\n", bitdepth);
45+ fprintf(stderr, "Using %d bit visual%s", bitdepth, bitdepth>8 ? " - please use 8 bits for highest performance!\n" : "\n");
46
47 hsize = (DISPLAY_X + 3) & ~3;
48
49@@ -419,6 +419,10 @@
50 img = XCreateImage(display, vis, bitdepth, ZPixmap, 0, bufmem, hsize, DISPLAY_Y, 32, 0);
51 #endif
52
53+ if(bitdepth > 8) {
54+ bufmem8 = (char*)malloc(hsize * DISPLAY_Y);
55+ }
56+
57 cmap = XCreateColormap(display, rootwin, vis, AllocNone);
58
59 XParseColor(display, cmap, "#000000", &black);
60@@ -484,6 +488,32 @@
61 {
62 // Update C64 display
63 XSync(display, 0);
64+
65+ if(bitdepth == 16) {
66+ // Best thing would be to change
67+ // VIC.cpp so it could render directly into 16-bit or 32-bit
68+ // memory instead of into an 8-bit chunky buffer.
69+ uint16 *p = (uint16*)bufmem8, *x = p + hsize*DISPLAY_Y/2;
70+ uint32 *d = (uint32*)bufmem;
71+ while(p < x) {
72+ *d++ = trans[*p++ & 0x0fff];
73+ }
74+#if 0
75+ // Just a plain version. Might be necessary on non-i386
76+ // machines?
77+ uint8 *p = (uint8*)bufmem8, *x = p + hsize*DISPLAY_Y;
78+ uint16 *d = (uint16*)bufmem;
79+ while(p < x) {
80+ *d++ = eight2sixteen[*p++];
81+ }
82+#endif
83+ } else if(bitdepth >= 24) {
84+ uint8 *p = (uint8*)bufmem8, *x = p + hsize*DISPLAY_Y;
85+ uint32 *d = (uint32*)bufmem;
86+ while(p < x)
87+ *d++ = trans[*p++];
88+ }
89+
90 #if defined(X_USE_SHM)
91 XShmPutImage(display, mywin, black_gc, img, 0, 0, 0, 0, DISPLAY_X, DISPLAY_Y, 0);
92 #else
93@@ -566,7 +605,7 @@
94
95 uint8 *C64Display::BitmapBase(void)
96 {
97- return (uint8 *)bufmem;
98+ return (uint8*)(bitdepth>8 ? bufmem8 : bufmem);
99 }
100
101
102@@ -776,14 +815,36 @@
103 int i;
104 XColor col;
105 char str[20];
106+ uint32 eight2sixteen[16];
107
108 for (i=0; i< 256; i++) {
109+ if(bitdepth == 16) {
110+ colors[i] = i & 0x0f;
111+ if(i < 16) {
112+ eight2sixteen[i] = ((uint16(palette_red[i]) << 8) & 0xf800) | ((uint16(palette_green[i]) << 3) & 0x07e0) | (palette_blue[i] >> 3);
113+ }
114+ } else if(bitdepth >= 24) {
115+ colors[i] = i & 0x0f;
116+ if(i < 16)
117+ eight2sixteen[i] = (uint32(palette_red[i]) << 16) | (uint32(palette_green[i]) << 8) | palette_blue[i];
118+ } else {
119 sprintf(str, "rgb:%x/%x/%x", palette_red[i & 0x0f], palette_green[i & 0x0f], palette_blue[i & 0x0f]);
120 XParseColor(display, cmap, str, &col);
121 if (XAllocColor(display, cmap, &col))
122 colors[i] = col.pixel;
123 else
124 fprintf(stderr, "Couldn't get all colors\n");
125+ }
126+ }
127+
128+ if(bitdepth == 16) {
129+ // Table to translate two 8-bit src -> two 16-bit dest
130+ for(i=0; i<1<<12;i++) {
131+ trans[i] = eight2sixteen[i & 0x0f] | (eight2sixteen[i >> 8] << 16);
132+ }
133+ } else if(bitdepth >= 24) {
134+ for(i=0;i<16;i++)
135+ trans[i] = eight2sixteen[i];
136 }
137 }
138
This page took 0.120449 seconds and 4 git commands to generate.