Commit 3eeeabf5 authored by Steven Fuller's avatar Steven Fuller

Initial 15/16/24/32 depth support in vi_xlib. Removed gfxbuf from wl_main

and id_ca
parent b066f342
...@@ -66,11 +66,20 @@ and where is that stray pixel coming from (when using end game with largest ...@@ -66,11 +66,20 @@ and where is that stray pixel coming from (when using end game with largest
window size) in svgalib window size) in svgalib
* change id_sd to sd_oss, sd_win, sd_dos, sd_oal, etc * change id_sd to sd_oss, sd_win, sd_dos, sd_oal, etc
idea is that different <outputs> can share some drivers, unlike video idea is that different <outputs> can share some drivers, unlike video
although glx and x11 share a lot of code (i guess since gl will be a great
undertaking, better to keep them seperated)
* check filehandling (ex, file missing, bad file type, and such) * check filehandling (ex, file missing, bad file type, and such)
PlayDemoFromFile specifically PlayDemoFromFile specifically
* make sure all infinite loops are found (looping around Keyboard) * make sure all infinite loops are found (looping around Keyboard)
* deathcam went by too fast, and right before the fizzlefade was being done * deathcam went by too fast, and right before the fizzlefade was being done
on the border on the border
* move all references to gfxbuf to vi_* only (gl will need this anyway,
since it deprecates: id_vh, wl_draw, wl_scale)
by putting in code from id_vh (either by using Plot or just copying it in)
we can stop the large conversion before each UpdateScreen
* pause key
* what are special keys... ?
Specific: Specific:
* memory/sound intro screen goes * memory/sound intro screen goes
......
...@@ -975,9 +975,9 @@ void CA_CacheScreen(int chunk) ...@@ -975,9 +975,9 @@ void CA_CacheScreen(int chunk)
{ {
long pos,compressed,expanded; long pos,compressed,expanded;
memptr bigbufferseg; memptr bigbufferseg;
byte *source; byte *source, *dest;
int next; int next;
// //
// load the chunk into a buffer // load the chunk into a buffer
// //
...@@ -1001,11 +1001,12 @@ void CA_CacheScreen(int chunk) ...@@ -1001,11 +1001,12 @@ void CA_CacheScreen(int chunk)
// allocate final space, decompress it, and free bigbuffer // allocate final space, decompress it, and free bigbuffer
// Sprites need to have shifts made and various other junk // Sprites need to have shifts made and various other junk
// //
/* TODO: this cheats and expands to the 320x200 screen buffer */ MM_GetPtr((void *)&dest, expanded);
CAL_HuffExpand(source, gfxbuf, expanded, grhuffman); CAL_HuffExpand(source, dest, expanded, grhuffman);
/* and then fixes it also! */ VL_DeModeXize(dest, 320, 200);
VL_DeModeXize(gfxbuf, 320, 200); VL_MemToScreen(dest, 320, 200, 0, 0);
MM_FreePtr(&bigbufferseg); MM_FreePtr(&bigbufferseg);
MM_FreePtr((void *)&dest);
} }
//========================================================================== //==========================================================================
......
...@@ -81,7 +81,7 @@ typedef struct ...@@ -81,7 +81,7 @@ typedef struct
#include "id_sd.h" #include "id_sd.h"
#include "id_us.h" #include "id_us.h"
extern byte signon; extern byte signon[];
#define introscn signon #define introscn signon
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
extern byte *gfxbuf; extern byte *gfxbuf;
//===========================================================================
void VL_Startup(); void VL_Startup();
void VL_Shutdown(); void VL_Shutdown();
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <X11/extensions/XShm.h> #include <X11/extensions/XShm.h>
byte *gfxbuf = NULL; byte *gfxbuf = NULL;
byte *disbuf = NULL;
Display *dpy; Display *dpy;
int screen; int screen;
...@@ -25,6 +26,113 @@ Atom wmDeleteWindow; ...@@ -25,6 +26,113 @@ Atom wmDeleteWindow;
XColor clr[256]; XColor clr[256];
int indexmode;
int rbias, gbias, bbias;
int rmask, gmask, bmask;
unsigned char mypal[768];
Colormap GetVisual()
{
XVisualInfo vitemp;
Colormap cmap;
int i, numVisuals;
vitemp.screen = screen;
vitemp.depth = 8;
vitemp.class = PseudoColor;
vi = XGetVisualInfo(dpy, VisualScreenMask | VisualDepthMask |
VisualClassMask, &vitemp, &numVisuals);
if (vi && (numVisuals > 0)) {
indexmode = 1;
cmap = XCreateColormap(dpy, root, vi->visual, AllocAll);
for (i = 0; i < 256; i++) {
clr[i].pixel = i;
clr[i].flags = DoRed|DoGreen|DoBlue;
}
return cmap;
}
vitemp.depth = 15;
vitemp.class = TrueColor;
vi = XGetVisualInfo(dpy, VisualScreenMask | VisualDepthMask |
VisualClassMask, &vitemp, &numVisuals);
if (vi && (numVisuals > 0)) {
indexmode = 0;
printf("15: rm:%d gm:%d bm:%d cs:%d bpr:%d\n", vi->red_mask,
vi->green_mask, vi->blue_mask, vi->colormap_size,
vi->bits_per_rgb);
cmap = XCreateColormap(dpy, root, vi->visual, AllocNone);
return cmap;
}
vitemp.depth = 16;
vitemp.class = TrueColor;
vi = XGetVisualInfo(dpy, VisualScreenMask | VisualDepthMask |
VisualClassMask, &vitemp, &numVisuals);
if (vi && (numVisuals > 0)) {
indexmode = 0;
printf("16: rm:%d gm:%d bm:%d cs:%d bpr:%d\n", vi->red_mask,
vi->green_mask, vi->blue_mask, vi->colormap_size,
vi->bits_per_rgb);
cmap = XCreateColormap(dpy, root, vi->visual, AllocNone);
return cmap;
}
vitemp.depth = 24;
vitemp.class = TrueColor;
vi = XGetVisualInfo(dpy, VisualScreenMask | VisualDepthMask |
VisualClassMask, &vitemp, &numVisuals);
if (vi && (numVisuals > 0)) {
indexmode = 0;
printf("24: rm:%d gm:%d bm:%d cs:%d bpr:%d\n", vi->red_mask,
vi->green_mask, vi->blue_mask, vi->colormap_size,
vi->bits_per_rgb);
cmap = XCreateColormap(dpy, root, vi->visual, AllocNone);
return cmap;
}
vitemp.depth = 32;
vitemp.class = TrueColor;
vi = XGetVisualInfo(dpy, VisualScreenMask | VisualDepthMask |
VisualClassMask, &vitemp, &numVisuals);
if (vi && (numVisuals > 0)) {
indexmode = 0;
printf("32: rm:%d gm:%d bm:%d cs:%d bpr:%d\n", vi->red_mask,
vi->green_mask, vi->blue_mask, vi->colormap_size,
vi->bits_per_rgb);
cmap = XCreateColormap(dpy, root, vi->visual, AllocNone);
return cmap;
}
Quit("No usable visual found!");
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
/* TODO: move these to proper functions */ /* TODO: move these to proper functions */
...@@ -54,27 +162,7 @@ int main(int argc, char *argv[]) ...@@ -54,27 +162,7 @@ int main(int argc, char *argv[])
root = RootWindow(dpy, screen); root = RootWindow(dpy, screen);
vitemp.screen = screen; cmap = GetVisual(); /* GetVisual will quit for us if no visual.. */
vitemp.depth = 8;
vitemp.class = PseudoColor;
vi = XGetVisualInfo(dpy, VisualScreenMask | VisualDepthMask |
VisualClassMask, &vitemp, &numVisuals);
if ((vi == NULL) || (numVisuals == 0)) {
Quit("No visuals found!");
}
if (vi->class != PseudoColor) {
Quit("Currently no support for non-TrueColor visuals");
}
cmap = XCreateColormap(dpy, root, vi->visual, AllocAll);
for (i = 0; i < 256; i++) {
clr[i].pixel = i;
clr[i].flags = DoRed|DoGreen|DoBlue;
}
attr.colormap = cmap; attr.colormap = cmap;
attr.event_mask = KeyPressMask | KeyReleaseMask | ExposureMask; attr.event_mask = KeyPressMask | KeyReleaseMask | ExposureMask;
attrmask = CWColormap | CWEventMask; attrmask = CWColormap | CWEventMask;
...@@ -123,6 +211,14 @@ void VL_WaitVBL(int vbls) ...@@ -123,6 +211,14 @@ void VL_WaitVBL(int vbls)
void VW_UpdateScreen() void VW_UpdateScreen()
{ {
int i;
if (indexmode == 0) {
for (i = 0; i < 64000; i++) {
}
memcpy(disbuf, gfxbuf, 64000);
}
XPutImage(dpy, win, gc, img, 0, 0, 0, 0, 320, 200); XPutImage(dpy, win, gc, img, 0, 0, 0, 0, 320, 200);
} }
...@@ -134,15 +230,42 @@ void VW_UpdateScreen() ...@@ -134,15 +230,42 @@ void VW_UpdateScreen()
======================= =======================
*/ */
int BPP(int d)
{
switch(d) {
case 15:
case 16:
return 2;
case 24:
return 3;
case 32:
return 4;
default:
Quit("Sorry, BPP doesn't like that...");
}
}
void VL_Startup() void VL_Startup()
{ {
if (gfxbuf == NULL) if (gfxbuf == NULL)
gfxbuf = malloc(320 * 200 * 1); gfxbuf = malloc(320 * 200 * 1);
img = XCreateImage(dpy, vi->visual, 8, ZPixmap, 0, (char *)gfxbuf, 320, 200, if (indexmode)
8, 320); disbuf = gfxbuf;
else
disbuf = malloc(320 * 200 * BPP(vi->depth));
img = XCreateImage(dpy, vi->visual, vi->depth, ZPixmap, 0, (char *)disbuf, 320, 200,
8, 320 * BPP(vi->depth));
if (img == NULL) {
Quit("XCreateImage returned NULL");
}
XMapWindow(dpy, win); XMapWindow(dpy, win);
XFlush(dpy);
} }
/* /*
...@@ -159,6 +282,11 @@ void VL_Shutdown (void) ...@@ -159,6 +282,11 @@ void VL_Shutdown (void)
free(gfxbuf); free(gfxbuf);
gfxbuf = NULL; gfxbuf = NULL;
} }
if ( (indexmode == 0) && (disbuf != NULL) ) {
free(disbuf);
disbuf = NULL;
}
} }
//=========================================================================== //===========================================================================
...@@ -200,14 +328,22 @@ void VL_ClearVideo(byte color) ...@@ -200,14 +328,22 @@ void VL_ClearVideo(byte color)
void VL_FillPalette(int red, int green, int blue) void VL_FillPalette(int red, int green, int blue)
{ {
int i; int i;
for (i = 0; i < 256; i++) {
clr[i].red = red << 10;
clr[i].green = green << 10;
clr[i].blue = blue << 10;
}
XStoreColors(dpy, cmap, clr, 256); if (indexmode) {
for (i = 0; i < 256; i++) {
clr[i].red = red << 10;
clr[i].green = green << 10;
clr[i].blue = blue << 10;
}
XStoreColors(dpy, cmap, clr, 256);
} else {
for (i = 0; i < 256; i++) {
mypal[i*3+0] = red;
mypal[i*3+1] = green;
mypal[i*3+2] = blue;
}
}
} }
//=========================================================================== //===========================================================================
...@@ -222,11 +358,17 @@ void VL_FillPalette(int red, int green, int blue) ...@@ -222,11 +358,17 @@ void VL_FillPalette(int red, int green, int blue)
void VL_SetColor(int color, int red, int green, int blue) void VL_SetColor(int color, int red, int green, int blue)
{ {
clr[color].red = red << 10; if (indexmode) {
clr[color].green = green << 10; clr[color].red = red << 10;
clr[color].blue = blue << 10; clr[color].green = green << 10;
clr[color].blue = blue << 10;
XStoreColors(dpy, cmap, clr, 256); XStoreColors(dpy, cmap, clr, 256);
} else {
mypal[color*3+0] = red;
mypal[color*3+1] = green;
mypal[color*3+2] = blue;
}
} }
//=========================================================================== //===========================================================================
...@@ -241,9 +383,15 @@ void VL_SetColor(int color, int red, int green, int blue) ...@@ -241,9 +383,15 @@ void VL_SetColor(int color, int red, int green, int blue)
void VL_GetColor(int color, int *red, int *green, int *blue) void VL_GetColor(int color, int *red, int *green, int *blue)
{ {
*red = clr[color].red >> 10; if (indexmode) {
*green = clr[color].green >> 10; *red = clr[color].red >> 10;
*blue = clr[color].blue >> 10; *green = clr[color].green >> 10;
*blue = clr[color].blue >> 10;
} else {
*red = mypal[color*3+0];
*green = mypal[color*3+1];
*blue = mypal[color*3+2];
}
} }
//=========================================================================== //===========================================================================
...@@ -260,12 +408,20 @@ void VL_SetPalette(byte *palette) ...@@ -260,12 +408,20 @@ void VL_SetPalette(byte *palette)
{ {
int i; int i;
for (i = 0; i < 256; i++) { if (indexmode) {
clr[i].red = palette[i*3+0] << 10; for (i = 0; i < 256; i++) {
clr[i].green = palette[i*3+1] << 10; clr[i].red = palette[i*3+0] << 10;
clr[i].blue = palette[i*3+2] << 10; clr[i].green = palette[i*3+1] << 10;
} clr[i].blue = palette[i*3+2] << 10;
XStoreColors(dpy, cmap, clr, 256); }
XStoreColors(dpy, cmap, clr, 256);
} else {
for (i = 0; i < 256; i++) {
mypal[i*3+0] = palette[i*3+0];
mypal[i*3+1] = palette[i*3+1];
mypal[i*3+2] = palette[i*3+2];
}
}
} }
...@@ -283,10 +439,14 @@ void VL_GetPalette(byte *palette) ...@@ -283,10 +439,14 @@ void VL_GetPalette(byte *palette)
{ {
int i; int i;
for (i = 0; i < 256; i++) { if (indexmode) {
palette[i*3+0] = clr[i].red >> 10; for (i = 0; i < 256; i++) {
palette[i*3+1] = clr[i].green >> 10; palette[i*3+0] = clr[i].red >> 10;
palette[i*3+2] = clr[i].blue >> 10; palette[i*3+1] = clr[i].green >> 10;
palette[i*3+2] = clr[i].blue >> 10;
}
} else {
memcpy(palette, mypal, 768);
} }
} }
...@@ -396,6 +556,7 @@ void VL_DeModeXize(byte *buf, int width, int height) ...@@ -396,6 +556,7 @@ void VL_DeModeXize(byte *buf, int width, int height)
return; return;
} }
/* TODO: can this malloc be removed, and have this func swap each pixel? */
mem = malloc(width * height); mem = malloc(width * height);
ptr = buf; ptr = buf;
for (plane = 0; plane < 4; plane++) { for (plane = 0; plane < 4; plane++) {
...@@ -412,8 +573,36 @@ void VL_DeModeXize(byte *buf, int width, int height) ...@@ -412,8 +573,36 @@ void VL_DeModeXize(byte *buf, int width, int height)
void VL_DirectPlot(int x1, int y1, int x2, int y2) void VL_DirectPlot(int x1, int y1, int x2, int y2)
{ {
XSetForeground(dpy, gc, *(gfxbuf + x1 + y1 * 320)); if (indexmode) {
XDrawPoint(dpy, win, gc, x2, y2); XSetForeground(dpy, gc, *(gfxbuf + x1 + y1 * 320));
XDrawPoint(dpy, win, gc, x2, y2);
} else {
#if 0
unsigned char pix = *(gfxbuf + x1 + y1 * 320);
XColor c;
c.pixel = 0;
c.flags = DoRed|DoGreen|DoBlue;
c.red = mypal[pix*3+0] << 10;
c.green = mypal[pix*3+1] << 10;
c.blue = mypal[pix*3+2] << 10;
XStoreColor(dpy, cmap, &c);
XSetForeground(dpy, gc, 0);
XDrawPoint(dpy, win, gc, x2, y2);
#endif
#if 0
unsigned char pix = *(gfxbuf + x1 + y1 * 320);
XColor c;
c.pixel = 0;
c.flags = DoRed|DoGreen|DoBlue;
c.red = mypal[pix*3+0] << 10;
c.green = mypal[pix*3+1] << 10;
c.blue = mypal[pix*3+2] << 10;
XAllocColor(dpy, cmap, &c);
//XStoreColor(dpy, cmap, &c);
XSetForeground(dpy, gc, c.pixel);
XDrawPoint(dpy, win, gc, x2, y2);
#endif
}
} }
/* /*
......
...@@ -639,7 +639,7 @@ void SetupWalls (void) ...@@ -639,7 +639,7 @@ void SetupWalls (void)
void SignonScreen() void SignonScreen()
{ {
VL_SetPalette(&gamepal); VL_SetPalette(&gamepal);
VL_MemToScreen(&introscn, 320, 200, 0, 0); VL_MemToScreen(introscn, 320, 200, 0, 0);
VW_UpdateScreen(); VW_UpdateScreen();
} }
...@@ -656,7 +656,7 @@ void FinishSignon (void) ...@@ -656,7 +656,7 @@ void FinishSignon (void)
{ {
#ifndef SPEAR #ifndef SPEAR
VW_Bar (0,189,300,11, *gfxbuf); VW_Bar (0,189,300,11, introscn[0]);
WindowX = 0; WindowX = 0;
WindowW = 320; WindowW = 320;
PrintY = 190; PrintY = 190;
...@@ -669,7 +669,7 @@ void FinishSignon (void) ...@@ -669,7 +669,7 @@ void FinishSignon (void)
if (!NoWait) if (!NoWait)
IN_Ack (); IN_Ack ();
VW_Bar (0,189,300,11,*gfxbuf); VW_Bar (0,189,300,11, introscn[0]);
PrintY = 190; PrintY = 190;
SETFONTCOLOR(10,4); SETFONTCOLOR(10,4);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment