Commit d9136e3d authored by Steven Fuller's avatar Steven Fuller

wl_draw.c: Moved functions around, merged wl_scale.c

vi_xlib.c: now fullscreen resets to the previous mode with dga
parent 3d7829b5
......@@ -10,7 +10,7 @@ OBJS = objs.o misc.o id_ca.o id_vh.o id_us.o \
wl_act1.o wl_act2.o wl_agent.o wl_game.o \
wl_inter.o wl_menu.o wl_play.o wl_state.o wl_text.o wl_main.o \
wl_debug.o gfxsave.o
ROBJS = wl_draw.o wl_scale.o
ROBJS = wl_draw.o
SOBJS = $(OBJS) $(ROBJS) vi_svga.o
XOBJS = $(OBJS) $(ROBJS) vi_xlib.o
......
......@@ -22,8 +22,11 @@ SD_StartMusic((MusicGroup *)audiosegs[STARTMUSIC + chunk]);
=>
SD_StartMusic(chunk);
* clean up vi_xlib.c: fix vid mode changing, fix dga for non8bit modes and
the nonpalette setting stuff... lots of if statements
also, it should be able to compile without extensions
also, update xlib code with new knowledge of how things work
* getenv so that you can point an env. var to the proper dir
* merge wl_scale with wl_draw?
* refresh rate under svgalib is horrible. the screen keeps getting updated
midframe. it's due to the way CalcTics works
* rewrite hw (sound, input) code, remove stuff like SD_SetSoundMode
......@@ -86,9 +89,6 @@ screen update
* make sure none of the non-loader code tries to handle gfx/sound data
directly
* when window loses focus, it should clear the keys
* clean up vi_xlib.c: fix vid mode changing, fix dga for non8bit modes and
the nonpalette setting stuff... lots of if statements
also, it should be able to compile without extensions
* rename visable to visible
* create 'sound channels' with priority.. ie a door can only make one sound
at a time
......
......@@ -193,6 +193,6 @@ void DisplayTextSplash(byte *text)
else
printf(" ");
}
/* TODO: reset color */
printf("%c[m", 27);
printf("\n");
}
......@@ -413,14 +413,6 @@ void VL_Startup()
void VL_Shutdown()
{
if (dga) {
XF86DGADirectVideo(dpy, screen, 0);
XUngrabKeyboard(dpy, CurrentTime);
free(gfxbuf);
free(disbuf);
gfxbuf = disbuf = NULL;
}
if (fullscreen) {
XF86VidModeLockModeSwitch(dpy, screen, False);
//printf("%d, %d\n", vidmode.hdisplay, vidmode.vdisplay);
......@@ -428,6 +420,14 @@ void VL_Shutdown()
XF86VidModeSwitchToMode(dpy, screen, vmmi[0]);
}
if (dga) {
XF86DGADirectVideo(dpy, screen, 0);
XUngrabKeyboard(dpy, CurrentTime);
free(gfxbuf);
free(disbuf);
gfxbuf = disbuf = NULL;
}
if ( !shmmode && (gfxbuf != NULL) ) {
free(gfxbuf);
gfxbuf = NULL;
......@@ -597,7 +597,7 @@ void VL_FillPalette(int red, int green, int blue)
void VL_SetPalette(const byte *palette)
{
int i;
if (indexmode) {
for (i = 0; i < 256; i++) {
clr[i].red = palette[i*3+0] << 10;
......
......@@ -1058,7 +1058,7 @@ void SpawnPlayer (int tilex, int tiley, int dir)
player->flags = FL_NEVERMARK;
Thrust (0,0); // set some variables
InitAreas ();
InitAreas();
}
......@@ -1074,7 +1074,7 @@ void SpawnPlayer (int tilex, int tiley, int dir)
===============
*/
void KnifeAttack (objtype *ob)
void KnifeAttack (objtype *ob)
{
objtype *check,*closest;
long dist;
......@@ -1104,14 +1104,14 @@ void KnifeAttack (objtype *ob)
}
// hit something
DamageActor (closest,US_RndT() >> 4);
DamageActor(closest, US_RndT() >> 4);
}
void GunAttack (objtype *ob)
void GunAttack(objtype *ob)
{
objtype *check,*closest,*oldclosest;
objtype *check, *closest, *oldclosest;
int damage;
int dx,dy,dist;
long viewdist;
......@@ -1157,7 +1157,7 @@ void GunAttack (objtype *ob)
}
if (closest == oldclosest)
return; // no more targets, all missed
return; // no more targets, all missed
//
// trace a line from player to enemey
......
This diff is collapsed.
/* wl_scale.c */
#include "wl_def.h"
typedef struct
{
word leftpix, rightpix;
word dataofs[64];
/* table data after dataofs[rightpix-leftpix+1] */
} PACKED t_compshape;
/* ======================================================================== */
/* TODO: this accesses gfxbuf directly! */
static void ScaledDraw(byte *gfx, int scale, byte *vid, unsigned long tfrac, unsigned long tint, unsigned long delta)
{
unsigned long OldDelta;
while (scale--) {
*vid = *gfx;
vid += 320; /* TODO: compiled in constant! */
OldDelta = delta;
delta += tfrac;
gfx += tint;
if (OldDelta > delta)
gfx += 1;
}
}
static void ScaledDrawTrans(byte *gfx, int scale, byte *vid, unsigned long tfrac, unsigned long tint, unsigned long delta)
{
unsigned long OldDelta;
while (scale--) {
if (*gfx != 255)
*vid = *gfx;
vid += 320; /* TODO: compiled in constant! */
OldDelta = delta;
delta += tfrac;
gfx += tint;
if (OldDelta > delta)
gfx += 1;
}
}
void ScaleLine(unsigned int height, byte *source, int x)
{
unsigned long TheFrac;
unsigned long TheInt;
unsigned long y;
if (height) {
TheFrac = 0x40000000UL / height;
if (height < viewheight) {
y = yoffset + (viewheight - height) / 2;
TheInt = TheFrac >> 24;
TheFrac <<= 8;
ScaledDraw(source, height, gfxbuf + (y * 320) + x + xoffset,
TheFrac, TheInt, 0);
return;
}
y = (height - viewheight) / 2;
y *= TheFrac;
TheInt = TheFrac >> 24;
TheFrac <<= 8;
ScaledDraw(&source[y >> 24], viewheight, gfxbuf + (yoffset * 320) + x + xoffset,
TheFrac, TheInt, y << 8);
}
}
static void ScaleLineTrans(unsigned int height, byte *source, int x)
{
unsigned long TheFrac;
unsigned long TheInt;
unsigned long y;
if (height) {
TheFrac = 0x40000000UL / height;
if (height < viewheight) {
y = yoffset + (viewheight - height) / 2;
TheInt = TheFrac >> 24;
TheFrac <<= 8;
ScaledDrawTrans(source, height, gfxbuf + (y * 320) + x + xoffset,
TheFrac, TheInt, 0);
return;
}
y = (height - viewheight) / 2;
y *= TheFrac;
TheInt = TheFrac >> 24;
TheFrac <<= 8;
ScaledDrawTrans(&source[y >> 24], viewheight, gfxbuf + (yoffset * 320) + x + xoffset,
TheFrac, TheInt, y << 8);
}
}
static unsigned char *spritegfx[SPR_TOTAL];
static void DeCompileSprite(int shapenum)
{
t_compshape *ptr;
unsigned char *buf;
int srcx;
unsigned short int *cmdptr;
short int *linecmds;
unsigned char *pixels;
int y, y0, y1;
MM_GetPtr((void *)&buf, 64 * 64);
memset(buf, 255, 64 * 64);
ptr = PM_GetSpritePage(shapenum);
cmdptr = &ptr->dataofs[31 - ptr->leftpix];
for (srcx = 31; srcx >= ptr->leftpix; srcx--) {
linecmds = (short *)((unsigned char *)ptr + *cmdptr--);
while (linecmds[0]) {
y0 = linecmds[2] / 2;
y1 = linecmds[0] / 2;
pixels = (unsigned char *)ptr + y0 + linecmds[1];
for (y = y0; y < y1; y++) {
//*(buf + slinex + (y*64)) = *pixels;
*(buf + (srcx*64) + y) = *pixels;
pixels++;
}
linecmds += 3;
}
}
if (ptr->leftpix < 31) {
srcx = 32;
cmdptr = &ptr->dataofs[32 - ptr->leftpix];
} else {
srcx = ptr->leftpix;
cmdptr = &ptr->dataofs[0];
}
for (; srcx <= ptr->rightpix; srcx++) {
linecmds = (short *)((unsigned char *)ptr + *cmdptr++);
while (linecmds[0]) {
y0 = linecmds[2] / 2;
y1 = linecmds[0] / 2;
pixels = (unsigned char *)ptr + y0 + linecmds[1];
for (y = y0; y < y1; y++) {
//*(buf + slinex + (y*64)) = *pixels;
*(buf + (srcx*64) + y) = *pixels;
pixels++;
}
linecmds += 3;
}
}
spritegfx[shapenum] = buf;
}
void ScaleShape(int xcenter, int shapenum, unsigned height)
{
unsigned int scaler = (64 << 16) / (height >> 2);
unsigned int x, p;
if (spritegfx[shapenum] == NULL)
DeCompileSprite(shapenum);
for (p = xcenter - (height >> 3), x = 0; x < (64 << 16); x += scaler, p++) {
if ((p < 0) || (p >= viewwidth) || (wallheight[p] >= height))
continue;
ScaleLineTrans(height >> 2, spritegfx[shapenum] + ((x >> 16) << 6), p);
}
}
void SimpleScaleShape(int xcenter, int shapenum, unsigned height)
{
unsigned int scaler = (64 << 16) / height;
unsigned int x, p;
if (spritegfx[shapenum] == NULL)
DeCompileSprite(shapenum);
for (p = xcenter - (height / 2), x = 0; x < (64 << 16); x += scaler, p++) {
if ((p < 0) || (p >= viewwidth))
continue;
ScaleLineTrans(height, spritegfx[shapenum] + ((x >> 16) << 6), p);
}
}
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