Commit 81ab1d53 authored by Steven Fuller's avatar Steven Fuller

wl_scale.c: Made DeCompileSprite simpler

parent 219c11c0
...@@ -22,6 +22,7 @@ SD_StartMusic((MusicGroup *)audiosegs[STARTMUSIC + chunk]); ...@@ -22,6 +22,7 @@ SD_StartMusic((MusicGroup *)audiosegs[STARTMUSIC + chunk]);
=> =>
SD_StartMusic(chunk); SD_StartMusic(chunk);
* merge wl_scale with wl_draw?
* refresh rate under svgalib is horrible. the screen keeps getting updated * refresh rate under svgalib is horrible. the screen keeps getting updated
midframe. it's due to the way CalcTics works midframe. it's due to the way CalcTics works
* rewrite hw (sound, input) code, remove stuff like SD_SetSoundMode * rewrite hw (sound, input) code, remove stuff like SD_SetSoundMode
...@@ -94,8 +95,6 @@ also, it should be able to compile without extensions ...@@ -94,8 +95,6 @@ also, it should be able to compile without extensions
* rename visable to visible * rename visable to visible
* create 'sound channels' with priority.. ie a door can only make one sound * create 'sound channels' with priority.. ie a door can only make one sound
at a time at a time
* change wl_scale to use mac wolf3d's version of scaling
wall drawing is done, just needed to fix sprite code
* cat file.c | perl -e 'while($in = <STDIN>) * cat file.c | perl -e 'while($in = <STDIN>)
{$in =~ s/\/\/(.*)$/\/\* \1\ *\//gm;print $in;}' {$in =~ s/\/\/(.*)$/\/\* \1\ *\//gm;print $in;}'
or or
......
...@@ -109,79 +109,67 @@ static void ScaleLineTrans(unsigned int height, byte *source, int x) ...@@ -109,79 +109,67 @@ static void ScaleLineTrans(unsigned int height, byte *source, int x)
static unsigned char *spritegfx[SPR_TOTAL]; static unsigned char *spritegfx[SPR_TOTAL];
/* TODO: merge FlipWall into function below */
static byte *FlipWall(byte *dat, int w, int h)
{
byte *buf;
int i, j;
buf = (byte *)malloc(w * h);
for (j = 0; j < h; j++)
for (i = 0; i < w; i++)
buf[j*w+i] = dat[i*w+j];
return buf;
}
static void DeCompileSprite(int shapenum) static void DeCompileSprite(int shapenum)
{ {
t_compshape *ptr; t_compshape *ptr;
unsigned char *buf; unsigned char *buf;
int srcx = 32; int srcx;
int slinex = 31;
int stopx;
unsigned short int *cmdptr; unsigned short int *cmdptr;
short int *linecmds;
unsigned char *pixels;
int y, y0, y1;
MM_GetPtr((void *)&buf, 64 * 64); MM_GetPtr((void *)&buf, 64 * 64);
memset(buf, 255, 64 * 64);
ptr = PM_GetSpritePage(shapenum); ptr = PM_GetSpritePage(shapenum);
memset(buf, 255, 64 * 64); cmdptr = &ptr->dataofs[31 - ptr->leftpix];
for (srcx = 31; srcx >= ptr->leftpix; srcx--) {
linecmds = (short *)((unsigned char *)ptr + *cmdptr--);
stopx = ptr->leftpix;
cmdptr = &ptr->dataofs[31-stopx];
while ( --srcx >=stopx ) {
short *linecmds = (short *)((unsigned char *)ptr + *cmdptr--);
slinex--;
while (linecmds[0]) { while (linecmds[0]) {
int y; y0 = linecmds[2] / 2;
int y0 = linecmds[2] / 2; y1 = linecmds[0] / 2;
int y1 = linecmds[0] / 2 - 1; pixels = (unsigned char *)ptr + y0 + linecmds[1];
unsigned char *pixels = (unsigned char *)ptr + y0 + linecmds[1];
for (y=y0; y<=y1; y++) { for (y = y0; y < y1; y++) {
unsigned char color = *pixels++; //*(buf + slinex + (y*64)) = *pixels;
*(buf + slinex + (y*64)) = color; *(buf + (srcx*64) + y) = *pixels;
pixels++;
} }
linecmds += 3; linecmds += 3;
} }
} }
slinex = 31;
stopx = ptr->rightpix;
if (ptr->leftpix < 31) { if (ptr->leftpix < 31) {
srcx = 31; srcx = 32;
cmdptr = &ptr->dataofs[32 - ptr->leftpix]; cmdptr = &ptr->dataofs[32 - ptr->leftpix];
} else { } else {
srcx = ptr->leftpix - 1; srcx = ptr->leftpix;
cmdptr = &ptr->dataofs[0]; cmdptr = &ptr->dataofs[0];
} }
while (++srcx <= stopx) {
short *linecmds = (short *)((unsigned char *)ptr + *cmdptr++); for (; srcx <= ptr->rightpix; srcx++) {
linecmds = (short *)((unsigned char *)ptr + *cmdptr++);
while (linecmds[0]) { while (linecmds[0]) {
int y; y0 = linecmds[2] / 2;
int y0 = linecmds[2] / 2; y1 = linecmds[0] / 2;
int y1 = linecmds[0] / 2 - 1; pixels = (unsigned char *)ptr + y0 + linecmds[1];
unsigned char *pixels = (unsigned char *)ptr + y0 + linecmds[1];
for (y=y0; y<=y1; y++) { for (y = y0; y < y1; y++) {
unsigned char color = *pixels++; //*(buf + slinex + (y*64)) = *pixels;
*(buf + slinex + (y*64)) = color; *(buf + (srcx*64) + y) = *pixels;
pixels++;
} }
linecmds += 3; linecmds += 3;
} }
slinex++;
} }
spritegfx[shapenum] = FlipWall(buf, 64, 64); spritegfx[shapenum] = buf;
MM_FreePtr((void *)&buf);
} }
void ScaleShape(int xcenter, int shapenum, unsigned height) void ScaleShape(int xcenter, int shapenum, unsigned height)
...@@ -195,7 +183,7 @@ void ScaleShape(int xcenter, int shapenum, unsigned height) ...@@ -195,7 +183,7 @@ void ScaleShape(int xcenter, int shapenum, unsigned height)
for (p = xcenter - (height >> 3), x = 0; x < (64 << 16); x += scaler, p++) { for (p = xcenter - (height >> 3), x = 0; x < (64 << 16); x += scaler, p++) {
if ((p < 0) || (p >= viewwidth) || (wallheight[p] >= height)) if ((p < 0) || (p >= viewwidth) || (wallheight[p] >= height))
continue; continue;
ScaleLineTrans((height >> 2) + 0, spritegfx[shapenum] + ((x >> 16) << 6), p); ScaleLineTrans(height >> 2, 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