Commit d7208f64 authored by Steven Fuller's avatar Steven Fuller

The Very-Very-Very Slow version.

Wolfenstein 3D is now capable of running in (almost) any screen resolution
(using a few hacks).
parent 50a0ca9f
......@@ -52,7 +52,7 @@ sdlwolf3d: $(DOBJS)
gcc -o sdlwolf3d $(DOBJS) $(DLFLAGS)
clean:
rm -rf swolf3d xwolf3d *.o
rm -rf swolf3d xwolf3d sdlwolf3d *.o
distclean: clean
rm -rf *~ DEADJOE
......
......@@ -14,57 +14,14 @@ Sound Menu:
* Sampling Rate:
- 44100
- 22050
------------------------------------------------------------------------------
[Indexed?]:
Yes:
- palette (8bit)
No:
- truecolor (15, 16, 24, 32)
[Shm?]:
Yes:
- XShmImage
No:
- XImage
[Windowed]:
- [Indexed?]
- [Shm?]
[DGA1?]:
Yes:
- YES
No:
- NO
[DGA2?]:
Yes:
- YES
No:
- [DGA1?]
[DGA?]:
- [DGA2?]
Yes:
- [Indexed?]
No:
- [Windowed]
[Fullscreen?]:
Yes:
- [DGA?]
No:
- [Windowed]
[Init]:
- [Fullscreen?]
------------------------------------------------------------------------------
*
SD_StartMusic((MusicGroup *)audiosegs[STARTMUSIC + chunk]);
=>
SD_StartMusic(chunk);
------------------------------------------------------------------------------
* fix fix fix different size stuff
* add ylookup
* remove farmapylookup?
* would be nice if Quit() used vsnprintf, etc
* actor walking through door is drawn in front of door: near end of E1M1 for
......
#include "id_heads.h"
#include "wl_def.h"
typedef struct
{
......
#include "id_heads.h"
#include "wl_def.h"
// Global variables
boolean NoWait;
......
#include "id_heads.h"
/* ======================================================================== */
#include "wl_def.h"
pictabletype *pictable;
......@@ -14,68 +12,6 @@ static byte palette1[256][3], palette2[256][3];
/* ======================================================================== */
void VW_DrawPropString(char *string)
{
fontstruct *font;
int width, step, height;
byte *source, *dest, *ptrs, *ptrd;
byte ch;
font = (fontstruct *)grsegs[STARTFONT+fontnumber];
height = font->height;
dest = gfxbuf + py * 320 + px;
while ((ch = *string++) != 0) {
width = step = font->width[ch];
source = ((byte *)font)+font->location[ch];
while (width--) {
height = font->height;
ptrs = source;
ptrd = dest;
while (height--) {
if (*ptrs)
*ptrd = fontcolor;
ptrs += step;
ptrd += 320;
}
source++;
dest++;
}
}
}
void VWL_MeasureString(char *string, word *width, word *height,
fontstruct *font)
{
/* proportional width */
*height = font->height;
for (*width = 0;*string;string++)
*width += font->width[*((byte *)string)];
}
void VW_MeasurePropString (char *string, word *width, word *height)
{
VWL_MeasureString(string,width,height,(fontstruct *)grsegs[STARTFONT+fontnumber]);
}
void VWB_DrawTile8(int x, int y, int tile)
{
VL_MemToScreen(grsegs[STARTTILE8]+(tile*64), 8, 8, x, y);
}
void VWB_DrawPic(int x, int y, int chunknum)
{
int picnum = chunknum - STARTPICS;
unsigned width,height;
x &= ~7;
width = pictable[picnum].width;
height = pictable[picnum].height;
VL_MemToScreen(grsegs[chunknum],width,height,x,y);
}
/*
===================
=
......@@ -108,7 +44,7 @@ void LoadLatchMem()
===================
*/
boolean FizzleFade(unsigned xx, unsigned yy, unsigned width,unsigned height, unsigned frames, boolean abortable)
boolean FizzleFade(unsigned xx, unsigned yy, unsigned width, unsigned height, unsigned frames, boolean abortable)
{
int pixperframe;
unsigned x, y, p, frame;
......@@ -117,13 +53,13 @@ boolean FizzleFade(unsigned xx, unsigned yy, unsigned width,unsigned height, uns
rndval = 1;
pixperframe = 64000/frames;
IN_StartAck ();
IN_StartAck();
frame=0;
frame = 0;
set_TimeCount(0);
do {
if (abortable && IN_CheckAck ())
if (abortable && IN_CheckAck())
return true;
for (p = 0; p < pixperframe; p++) {
y = (rndval & 0x00FF) - 1;
......@@ -135,7 +71,7 @@ boolean FizzleFade(unsigned xx, unsigned yy, unsigned width,unsigned height, uns
} else
rndval >>= 1;
if ((x>width) || (y>height))
if ((x > width) || (y > height))
continue;
VL_DirectPlot(xx+x, yy+y, xx+x, yy+y);
......@@ -145,10 +81,23 @@ boolean FizzleFade(unsigned xx, unsigned yy, unsigned width,unsigned height, uns
}
frame++;
while (get_TimeCount() < frame) ;
while (get_TimeCount() < frame);
} while (1);
}
void VL_FillPalette(int red, int green, int blue)
{
char pal[768];
int i;
for (i = 0; i < 256; i++) {
pal[i*3+0] = red;
pal[i*3+1] = green;
pal[i*3+2] = blue;
}
VL_SetPalette(pal);
}
/*
=================
=
......@@ -199,7 +148,6 @@ void VL_FadeOut(int start, int end, int red, int green, int blue, int steps)
screenfaded = true;
}
/*
=================
=
......@@ -212,7 +160,7 @@ void VL_FadeIn(int start, int end, const byte *palette, int steps)
{
int i,j,delta;
VL_GetPalette (&palette1[0][0]);
VL_GetPalette(&palette1[0][0]);
memcpy(&palette2[0][0],&palette1[0][0],sizeof(palette1));
start *= 3;
......@@ -272,3 +220,236 @@ void VL_DeModeXize(byte *buf, int width, int height)
memcpy(buf, mem, width * height);
free(mem);
}
/*
=================
=
= VL_Plot
=
=================
*/
static void VL_Plot(int x, int y, int color)
{
int xend, yend, xfrac, yfrac, xs, ys;
xend = x + 1;
yend = y + 1;
xfrac = (vwidth << 16) / 320;
yfrac = (vheight << 16) / 200;
x *= xfrac;
y *= yfrac;
xend *= xfrac;
yend *= yfrac;
xfrac = (320 << 16) / vwidth;
yfrac = (200 << 16) / vheight;
for (xs = x; xs < xend; xs += xfrac)
for (ys = y; ys < yend; ys += yfrac)
*(gfxbuf + (ys >> 16) * vwidth + (xs >> 16)) = color;
/*
*(gfxbuf + vwidth * y + x) = color;
*/
}
void VW_Plot(int x, int y, int color)
{
*(gfxbuf + vwidth * y + x) = color;
}
void VW_DrawPropString(char *string)
{
fontstruct *font;
int width, step, height, x, xs, y;
byte *source, *ptrs;
/* byte *dest, *ptrd; */
byte ch;
font = (fontstruct *)grsegs[STARTFONT+fontnumber];
height = font->height;
xs = 0;
while ((ch = *string++) != 0) {
width = step = font->width[ch];
source = ((byte *)font)+font->location[ch];
for (x = 0; x < width; x++) {
height = font->height;
ptrs = source;
for (y = 0; y < height; y++) {
if (*ptrs)
VL_Plot(px+xs, py+y, fontcolor);
ptrs += step;
}
xs++;
source++;
}
}
/*
dest = gfxbuf + py * vwidth + px;
while ((ch = *string++) != 0) {
width = step = font->width[ch];
source = ((byte *)font)+font->location[ch];
while (width--) {
height = font->height;
ptrs = source;
ptrd = dest;
while (height--) {
if (*ptrs)
*ptrd = fontcolor;
ptrs += step;
ptrd += vwidth;
}
source++;
dest++;
}
}
*/
}
void VWL_MeasureString(char *string, word *width, word *height,
fontstruct *font)
{
/* proportional width */
*height = font->height;
for (*width = 0;*string;string++)
*width += font->width[*((byte *)string)];
}
void VW_MeasurePropString (char *string, word *width, word *height)
{
VWL_MeasureString(string,width,height,(fontstruct *)grsegs[STARTFONT+fontnumber]);
}
void VWB_DrawTile8(int x, int y, int tile)
{
VL_MemToScreen(grsegs[STARTTILE8]+(tile*64), 8, 8, x, y);
}
void VWB_DrawPic(int x, int y, int chunknum)
{
int picnum = chunknum - STARTPICS;
unsigned width,height;
x &= ~7;
width = pictable[picnum].width;
height = pictable[picnum].height;
VL_MemToScreen(grsegs[chunknum],width,height,x,y);
}
/*
=================
=
= VL_Hlin
=
=================
*/
void VL_Hlin(unsigned x, unsigned y, unsigned width, unsigned color)
{
int w;
for (w = 0; w < width; w++)
VL_Plot(x+w, y, color);
/*
memset(gfxbuf + vwidth * y + x, color, width);
*/
}
/*
=================
=
= VL_Vlin
=
=================
*/
void VL_Vlin(int x, int y, int height, int color)
{
int h;
for (h = 0; h < height; h++)
VL_Plot(x, y+h, color);
/*
byte *ptr = gfxbuf + vwidth * y + x;
while (height--) {
*ptr = color;
ptr += vwidth;
}
*/
}
/*
=================
=
= VL_Bar
=
=================
*/
void VW_Bar(int x, int y, int width, int height, int color)
{
int w, h;
for (w = 0; w < width; w++)
for (h = 0; h < height; h++)
VL_Plot(x+w, y+h, color);
/*
byte *ptr;
width *= vwidth / 320;
height *= vheight / 200;
x *= vwidth / 320;
y *= vheight / 200;
ptr = gfxbuf + vwidth * y + x;
while (height--) {
memset(ptr, color, width);
ptr += vwidth;
}
*/
}
void VL_Bar(int x, int y, int width, int height, int color)
{
byte *ptr = gfxbuf + vwidth * y + x;
while (height--) {
memset(ptr, color, width);
ptr += vwidth;
}
}
/*
=================
=
= VL_MemToScreen
=
= Draws a block of data to the screen.
=
=================
*/
void VL_MemToScreen(const byte *source, int width, int height, int x, int y)
{
int w, h;
for (w = 0; w < width; w++)
for (h = 0; h < height; h++)
VL_Plot(x+w, y+h, source[h*width+w]);
/*
byte *ptr = gfxbuf + vwidth * y + x;
while(height--) {
memcpy(ptr, source, width);
source += width;
ptr += vwidth;
}
*/
}
......@@ -35,8 +35,6 @@ extern boolean screenfaded;
#define VW_Startup VL_Startup
#define VW_Shutdown VL_Shutdown
#define VW_Bar VL_Bar
#define VW_Plot VL_Plot
#define VW_Hlin(x,z,y,c) VL_Hlin(x,y,(z)-(x)+1,c)
#define VW_Vlin(y,z,x,c) VL_Vlin(x,y,(z)-(y)+1,c)
#define VW_WaitVBL VL_WaitVBL
......@@ -55,4 +53,6 @@ void LoadLatchMem();
void VL_CacheScreen(int chunk);
void VW_Bar(int x, int y, int width, int height, int color);
#endif
#include "id_heads.h"
#include "wl_def.h"
#ifdef DOSISM /* TODO: bad name.. since djgpp code would use interrupt (maybe uclock?) most likely */
......
#include "id_heads.h"
#include "wl_def.h"
boolean SoundSourcePresent, AdLibPresent, SoundBlasterPresent;
......
......@@ -8,8 +8,6 @@ extern byte *gfxbuf;
void VL_Startup();
void VL_Shutdown();
void VL_ClearVideo(byte color);
void VL_WaitVBL(int vbls);
void VW_UpdateScreen();
......@@ -17,7 +15,7 @@ void VL_FillPalette(int red, int green, int blue);
void VL_SetPalette(const byte *palette);
void VL_GetPalette(byte *palette);
void VL_Plot(int x, int y, int color);
void VW_Plot(int x, int y, int color);
void VL_Hlin(unsigned x, unsigned y, unsigned width, unsigned color);
void VL_Vlin(int x, int y, int height, int color);
void VL_Bar(int x, int y, int width, int height, int color);
......@@ -28,6 +26,7 @@ void VL_DeModeXize(byte *buf, int width, int height);
void VL_DirectPlot(int x1, int y1, int x2, int y2);
#define MaxPlayers 4
#define MaxJoys 2
#define NumCodes 128
......
......@@ -81,46 +81,6 @@ void VL_Shutdown()
//===========================================================================
/*
=================
=
= VL_ClearVideo
=
= Fill the entire video buffer with a given color
=
=================
*/
void VL_ClearVideo(byte color)
{
memset(gfxbuf, color, 64000);
}
/*
=============================================================================
PALETTE OPS
To avoid snow, do a WaitVBL BEFORE calling these
=============================================================================
*/
/*
=================
=
= VL_FillPalette
=
=================
*/
void VL_FillPalette(int red, int green, int blue)
{
}
//===========================================================================
/*
=================
=
......@@ -133,8 +93,6 @@ void VL_SetPalette(const byte *palette)
{
}
//===========================================================================
/*
=================
=
......@@ -147,102 +105,6 @@ void VL_GetPalette(byte *palette)
{
}
/*
=============================================================================
PIXEL OPS
=============================================================================
*/
/*
=================
=
= VL_Plot
=
=================
*/
void VL_Plot(int x, int y, int color)
{
*(gfxbuf + 320 * y + x) = color;
}
/*
=================
=
= VL_Hlin
=
=================
*/
void VL_Hlin(unsigned x, unsigned y, unsigned width, unsigned color)
{
memset(gfxbuf + 320 * y + x, color, width);
}
/*
=================
=
= VL_Vlin
=
=================
*/
void VL_Vlin (int x, int y, int height, int color)
{
byte *ptr = gfxbuf + 320 * y + x;
while (height--) {
*ptr = color;
ptr += 320;
}
}
/*
=================
=
= VL_Bar
=
=================
*/
void VL_Bar(int x, int y, int width, int height, int color)
{
byte *ptr = gfxbuf + 320 * y + x;
while (height--) {
memset(ptr, color, width);
ptr += 320;
}
}
/*
============================================================================
MEMORY OPS
============================================================================
*/
/*
=================
=
= VL_MemToScreen
=
= Draws a block of data to the screen.
=
=================
*/
void VL_MemToScreen(const byte *source, int width, int height, int x, int y)
{
byte *ptr = gfxbuf + 320 * y + x;
while(height--) {
memcpy(ptr, source, width);
source += width;
ptr += 320;
}
}
void VL_DirectPlot(int x1, int y1, int x2, int y2)
{
}
......
/* id_vl.c */
#include "wl_def.h"
#include "SDL.h"
......@@ -17,6 +15,9 @@ SDL_Surface *surface;
int main (int argc, char *argv[])
{
vwidth = 320;
vheight = 200;
return WolfMain(argc, argv);
}
......@@ -38,8 +39,6 @@ void Quit(char *error)
ShutdownId();
if (screen) {
printf("TODO: spiffy ansi screen goes here..\n");
/* doesn't look too good on console at the moment ...*/
//DisplayTextSplash(screen);
}
......@@ -59,8 +58,8 @@ void VL_WaitVBL(int vbls)
void VW_UpdateScreen()
{
//VL_WaitVBL(1);
memcpy(surface->pixels, gfxbuf, 64000);
SDL_UpdateRect(surface,0,0,0,0);
memcpy(surface->pixels, gfxbuf, vwidth*vheight);
SDL_UpdateRect(surface, 0, 0, 0, 0);
}
/*
......@@ -74,19 +73,18 @@ void VW_UpdateScreen()
void VL_Startup()
{
if (gfxbuf == NULL)
gfxbuf = malloc(320 * 200 * 1);
gfxbuf = malloc(vwidth * vheight * 1);
if (SDL_Init (SDL_INIT_VIDEO) < 0) {
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
Quit("Couldn't init SDL");
}
if (MS_CheckParm("fullscreen"))
surface = SDL_SetVideoMode (320,200,8, SDL_SWSURFACE|SDL_HWPALETTE| SDL_FULLSCREEN);
surface = SDL_SetVideoMode(vwidth, vheight, 8, SDL_SWSURFACE|SDL_HWPALETTE|SDL_FULLSCREEN);
else
surface = SDL_SetVideoMode (320,200,8, SDL_SWSURFACE|SDL_HWPALETTE);
surface = SDL_SetVideoMode(vwidth, vheight, 8, SDL_SWSURFACE|SDL_HWPALETTE);
if (surface == NULL)
{
if (surface == NULL) {
SDL_Quit();
Quit ("Couldn't set 320x200 mode");
}
......@@ -115,56 +113,6 @@ void VL_Shutdown()
//===========================================================================
/*
=================
=
= VL_ClearVideo
=
= Fill the entire video buffer with a given color
=
=================
*/
void VL_ClearVideo(byte color)
{
memset(gfxbuf, color, 64000);
}
/*
=============================================================================
PALETTE OPS
To avoid snow, do a WaitVBL BEFORE calling these
=============================================================================
*/
/*
=================
=
= VL_FillPalette
=
=================
*/
void VL_FillPalette(int red, int green, int blue)
{
SDL_Color colors[256];
int i;
for (i = 0; i < 256; i++)
{
colors[i].r = red << 2;
colors[i].g = green << 2;
colors[i].b = blue << 2;
}
SDL_SetColors (surface, colors, 0, 256);
}
//===========================================================================
/*
=================
=
......@@ -184,7 +132,7 @@ void VL_SetPalette(const byte *palette)
colors[i].g = palette[i*3+1] << 2;
colors[i].b = palette[i*3+2] << 2;
}
SDL_SetColors (surface, colors, 0, 256);
SDL_SetColors(surface, colors, 0, 256);
}
......@@ -209,105 +157,9 @@ void VL_GetPalette(byte *palette)
}
}
/*
=============================================================================
PIXEL OPS
=============================================================================
*/
/*
=================
=
= VL_Plot
=
=================
*/
void VL_Plot(int x, int y, int color)
{
*(gfxbuf + 320 * y + x) = color;
}
/*
=================
=
= VL_Hlin
=
=================
*/
void VL_Hlin(unsigned x, unsigned y, unsigned width, unsigned color)
{
memset(gfxbuf + 320 * y + x, color, width);
}
/*
=================
=
= VL_Vlin
=
=================
*/
void VL_Vlin (int x, int y, int height, int color)
{
byte *ptr = gfxbuf + 320 * y + x;
while (height--) {
*ptr = color;
ptr += 320;
}
}
/*
=================
=
= VL_Bar
=
=================
*/
void VL_Bar(int x, int y, int width, int height, int color)
{
byte *ptr = gfxbuf + 320 * y + x;
while (height--) {
memset(ptr, color, width);
ptr += 320;
}
}
/*
============================================================================
MEMORY OPS
============================================================================
*/
/*
=================
=
= VL_MemToScreen
=
= Draws a block of data to the screen.
=
=================
*/
void VL_MemToScreen(const byte *source, int width, int height, int x, int y)
{
byte *ptr = gfxbuf + 320 * y + x;
while(height--) {
memcpy(ptr, source, width);
source += width;
ptr += 320;
}
}
void VL_DirectPlot(int x1, int y1, int x2, int y2)
{
*(((Uint8 *)surface->pixels) + x1 + y1 * 320) = *(gfxbuf + x2 + y2 * 320);
*(((Uint8 *)surface->pixels) + x1 + y1 * vwidth) = *(gfxbuf + x2 + y2 * vwidth);
//SDL_UpdateRect(surface, x1,y1,x1,y1);
}
......@@ -875,7 +727,7 @@ boolean IN_UserInput(longword delay)
===================
*/
byte IN_MouseButtons (void)
byte IN_MouseButtons()
{
return 0;
}
......@@ -888,7 +740,7 @@ byte IN_MouseButtons (void)
===================
*/
byte IN_JoyButtons (void)
byte IN_JoyButtons()
{
return 0;
}
......@@ -102,39 +102,6 @@ void VL_Shutdown()
//===========================================================================
/*
=================
=
= VL_ClearVideo
=
= Fill the entire video buffer with a given color
=
=================
*/
void VL_ClearVideo(byte color)
{
memset(gfxbuf, color, 64000);
}
/*
=================
=
= VL_FillPalette
=
=================
*/
void VL_FillPalette(int red, int green, int blue)
{
int i;
for (i = 0; i < 256; i++)
vga_setpalette(i, red, green, blue);
}
//===========================================================================
/*
=================
=
......@@ -151,9 +118,6 @@ void VL_SetPalette(const byte *palette)
vga_setpalette(i, palette[i*3+0], palette[i*3+1], palette[i*3+2]);
}
//===========================================================================
/*
=================
=
......@@ -174,102 +138,6 @@ void VL_GetPalette(byte *palette)
}
}
/*
=============================================================================
PIXEL OPS
=============================================================================
*/
/*
=================
=
= VL_Plot
=
=================
*/
void VL_Plot(int x, int y, int color)
{
*(gfxbuf + 320 * y + x) = color;
}
/*
=================
=
= VL_Hlin
=
=================
*/
void VL_Hlin(unsigned x, unsigned y, unsigned width, unsigned color)
{
memset(gfxbuf + 320 * y + x, color, width);
}
/*
=================
=
= VL_Vlin
=
=================
*/
void VL_Vlin (int x, int y, int height, int color)
{
byte *ptr = gfxbuf + 320 * y + x;
while (height--) {
*ptr = color;
ptr += 320;
}
}
/*
=================
=
= VL_Bar
=
=================
*/
void VL_Bar(int x, int y, int width, int height, int color)
{
byte *ptr = gfxbuf + 320 * y + x;
while (height--) {
memset(ptr, color, width);
ptr += 320;
}
}
/*
============================================================================
MEMORY OPS
============================================================================
*/
/*
=================
=
= VL_MemToScreen
=
= Draws a block of data to the screen.
=
=================
*/
void VL_MemToScreen(const byte *source, int width, int height, int x, int y)
{
byte *ptr = gfxbuf + 320 * y + x;
while(height--) {
memcpy(ptr, source, width);
source += width;
ptr += 320;
}
}
void VL_DirectPlot(int x1, int y1, int x2, int y2)
{
*(graph_mem + x1 + y1 * 320) = *(gfxbuf + x2 + y2 * 320);
......@@ -772,12 +640,15 @@ byte IN_MouseButtons (void)
===================
*/
byte IN_JoyButtons (void)
byte IN_JoyButtons()
{
return 0;
}
int main(int argc, char *argv[])
{
vwidth = 320;
vheight = 200;
return WolfMain(argc, argv);
}
......@@ -107,7 +107,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
win = hwnd;
return WolfMain(0, NULL); /* TODO ... need to do something for silly windows */
return WolfMain(0, NULL); /* TODO ... need to parse commandline */
}
/*
......@@ -356,52 +356,6 @@ void VL_Shutdown (void)
//===========================================================================
/*
=================
=
= VL_ClearVideo
=
= Fill the entire video buffer with a given color
=
=================
*/
void VL_ClearVideo(byte color)
{
memset(gfxbuf, color, 64000);
}
/*
=============================================================================
PALETTE OPS
To avoid snow, do a WaitVBL BEFORE calling these
=============================================================================
*/
/*
=================
=
= VL_FillPalette
=
=================
*/
void VL_FillPalette(int red, int green, int blue)
{
int i;
for (i = 0; i < 256; i++) {
mypal[i*3+0] = red;
mypal[i*3+1] = green;
mypal[i*3+2] = blue;
}
}
//===========================================================================
/*
=================
=
......@@ -416,9 +370,6 @@ void VL_SetPalette(const byte *palette)
VW_UpdateScreen();
}
//===========================================================================
/*
=================
=
......@@ -432,102 +383,6 @@ void VL_GetPalette(byte *palette)
memcpy(palette, mypal, 768);
}
/*
=============================================================================
PIXEL OPS
=============================================================================
*/
/*
=================
=
= VL_Plot
=
=================
*/
void VL_Plot(int x, int y, int color)
{
*(gfxbuf + 320 * y + x) = color;
}
/*
=================
=
= VL_Hlin
=
=================
*/
void VL_Hlin(unsigned x, unsigned y, unsigned width, unsigned color)
{
memset(gfxbuf + 320 * y + x, color, width);
}
/*
=================
=
= VL_Vlin
=
=================
*/
void VL_Vlin (int x, int y, int height, int color)
{
byte *ptr = gfxbuf + 320 * y + x;
while (height--) {
*ptr = color;
ptr += 320;
}
}
/*
=================
=
= VL_Bar
=
=================
*/
void VL_Bar(int x, int y, int width, int height, int color)
{
byte *ptr = gfxbuf + 320 * y + x;
while (height--) {
memset(ptr, color, width);
ptr += 320;
}
}
/*
============================================================================
MEMORY OPS
============================================================================
*/
/*
=================
=
= VL_MemToScreen
=
= Draws a block of data to the screen.
=
=================
*/
void VL_MemToScreen(const byte *source, int width, int height, int x, int y)
{
byte *ptr = gfxbuf + 320 * y + x;
while(height--) {
memcpy(ptr, source, width);
source += width;
ptr += 320;
}
}
void VL_DirectPlot(int x1, int y1, int x2, int y2)
{
......
This diff is collapsed.
......@@ -6,6 +6,8 @@
#include "wl_menu.h"
#include "foreign.h"
extern int vwidth, vheight; /* size of screen */
/*
=============================================================================
......@@ -55,9 +57,7 @@
#define MINDIST (0x5800l)
#define MAXSCALEHEIGHT 512 /* largest scale on largest view */
#define MAXVIEWWIDTH 320
#define MAXVIEWWIDTH 1280
#define MAPSIZE 64 // maps are 64*64 max
......@@ -676,14 +676,16 @@ extern char str[80], str2[20];
extern fixed focallength;
extern unsigned viewangles;
extern int viewwidth;
extern int viewheight;
extern int viewwidth, viewheight;
extern int viewwidthwin, viewheightwin;
extern int xoffset, yoffset;
extern int centerx;
extern int shootdelta;
extern boolean startgame,loadedgame;
extern int mouseadjustment;
extern unsigned xoffset, yoffset;
//
// math tables
......@@ -695,7 +697,6 @@ extern fixed sintable[], *costable;
extern char configname[13];
void CalcProjection (long focal);
boolean SetViewSize (unsigned width, unsigned height);
void NewGame (int difficulty,int episode);
void NewViewSize (int width);
boolean LoadTheGame(int file,int x,int y);
......@@ -726,7 +727,6 @@ extern unsigned spearangle;
extern boolean spearflag;
void DrawPlayBorder (void);
void ScanInfoPlane (void);
void SetupGameLevel (void);
void DrawPlayScreen (void);
......@@ -735,10 +735,10 @@ void GameLoop (void);
void ClearMemory (void);
void PlayDemo(int demonumber);
int PlayDemoFromFile(char *demoname);
void RecordDemo (void);
void DrawPlayBorder (void);
void DrawHighScores(void);
void DrawPlayBorderSides (void);
void RecordDemo();
void DrawHighScores();
void DrawPlayBorder();
void DrawPlayBorderSides();
#define PlaySoundLocTile(s,tx,ty) PlaySoundLocGlobal(s,(((long)(tx) << TILESHIFT) + (1L << (TILESHIFT - 1))),(((long)ty << TILESHIFT) + (1L << (TILESHIFT - 1))))
#define PlaySoundLocActor(s,ob) PlaySoundLocGlobal(s,(ob)->x,(ob)->y)
......
......@@ -522,7 +522,7 @@ static void DrawSpans(int x1, int x2, int height)
fixed startxfrac, startyfrac;
byte *toprow;
toprow = planeylookup[height]+(320*yoffset+xoffset);
toprow = planeylookup[height]+(vwidth*yoffset+xoffset);
mr_rowofs = mirrorofs[height];
mr_xstep = (viewsin / height) >> 1;
......@@ -562,8 +562,8 @@ static void SetPlaneViewSize()
halfheight = viewheight >> 1;
for (y = 0; y < halfheight; y++) {
planeylookup[y] = gfxbuf + (halfheight-1-y)*320;
mirrorofs[y] = (y*2+1)*320;
planeylookup[y] = gfxbuf + (halfheight-1-y)*vwidth;
mirrorofs[y] = (y*2+1)*vwidth;
if (y > 0)
basedist[y] = GLOBAL1/2*scale/y;
......@@ -684,14 +684,14 @@ void ThreeDRefresh()
/* ======================================================================== */
/* TODO: this accesses gfxbuf directly! */
#if 0
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! */
vid += vwidth;
OldDelta = delta;
delta += tfrac;
gfx += tint;
......@@ -708,7 +708,7 @@ static void ScaledDrawTrans(byte *gfx, int scale, byte *vid, unsigned long tfrac
while (scale--) {
if (*gfx != 255)
*vid = *gfx;
vid += 320; /* TODO: compiled in constant! */
vid += vwidth;
OldDelta = delta;
delta += tfrac;
gfx += tint;
......@@ -718,7 +718,7 @@ static void ScaledDrawTrans(byte *gfx, int scale, byte *vid, unsigned long tfrac
}
}
void ScaleLine(unsigned int height, byte *source, int x)
static void ScaleLine(unsigned int height, byte *source, int x)
{
unsigned long TheFrac;
unsigned long TheInt;
......@@ -732,7 +732,7 @@ void ScaleLine(unsigned int height, byte *source, int x)
TheInt = TheFrac >> 24;
TheFrac <<= 8;
ScaledDraw(source, height, gfxbuf + (y * 320) + x + xoffset,
ScaledDraw(source, height, gfxbuf + (y * vwidth) + x + xoffset,
TheFrac, TheInt, 0);
return;
......@@ -744,7 +744,7 @@ void ScaleLine(unsigned int height, byte *source, int x)
TheInt = TheFrac >> 24;
TheFrac <<= 8;
ScaledDraw(&source[y >> 24], viewheight, gfxbuf + (yoffset * 320) + x + xoffset,
ScaledDraw(&source[y >> 24], viewheight, gfxbuf + (yoffset * vwidth) + x + xoffset,
TheFrac, TheInt, y << 8);
}
}
......@@ -756,14 +756,14 @@ static void ScaleLineTrans(unsigned int height, byte *source, int x)
unsigned long y;
if (height) {
TheFrac = 0x40000000UL / height;
TheFrac = (64 << 16) / height;
if (height < viewheight) {
y = yoffset + (viewheight - height) / 2;
TheInt = TheFrac >> 24;
TheFrac <<= 8;
ScaledDrawTrans(source, height, gfxbuf + (y * 320) + x + xoffset,
ScaledDrawTrans(source, height, gfxbuf + (y * vwidth) + x + xoffset,
TheFrac, TheInt, 0);
return;
......@@ -775,10 +775,80 @@ static void ScaleLineTrans(unsigned int height, byte *source, int x)
TheInt = TheFrac >> 24;
TheFrac <<= 8;
ScaledDrawTrans(&source[y >> 24], viewheight, gfxbuf + (yoffset * 320) + x + xoffset,
ScaledDrawTrans(&source[y >> 24], viewheight, gfxbuf + (yoffset * vwidth) + x + xoffset,
TheFrac, TheInt, y << 8);
}
}
#endif
static void ScaledDraw(byte *gfx, int count, byte *vid, unsigned int frac, unsigned int delta)
{
while (count--) {
*vid = gfx[frac >> 16];
vid += vwidth;
frac += delta;
}
}
static void ScaledDrawTrans(byte *gfx, int scale, byte *vid, unsigned int frac, unsigned int delta)
{
while (scale--) {
if (gfx[frac >> 16] != 255)
*vid = gfx[frac >> 16];
vid += vwidth;
frac += delta;
}
}
static void ScaleLine(unsigned int height, byte *source, int x)
{
unsigned long TheFrac;
unsigned long y;
if (height) {
TheFrac = (64 << 16) / height;
if (height < viewheight) {
y = yoffset + (viewheight - height) / 2;
ScaledDraw(source, height, gfxbuf + (y * vwidth) + x + xoffset,
0, TheFrac);
return;
}
y = (height - viewheight) / 2;
y *= TheFrac;
ScaledDraw(source, viewheight, gfxbuf + (yoffset * vwidth) + x + xoffset,
y, TheFrac);
}
}
static void ScaleLineTrans(unsigned int height, byte *source, int x)
{
unsigned long TheFrac;
unsigned long y;
if (height) {
TheFrac = 0x00400000UL / height;
if (height < viewheight) {
y = yoffset + (viewheight - height) / 2;
ScaledDrawTrans(source, height, gfxbuf + (y * vwidth) + x + xoffset,
0, TheFrac);
return;
}
y = (height - viewheight) / 2;
y *= TheFrac;
ScaledDrawTrans(&source[y >> 24], viewheight, gfxbuf + (yoffset * vwidth) + x + xoffset,
y, TheFrac);
}
}
static unsigned char *spritegfx[SPR_TOTAL];
......
......@@ -590,17 +590,17 @@ void DrawPlayBorderSides()
{
int xl, yl;
xl = 160-viewwidth/2;
yl = (200-STATUSLINES-viewheight)/2;
xl = 160-viewwidthwin/2;
yl = (200-STATUSLINES-viewheightwin)/2;
if (xl == 0) {
return;
} else {
VW_Bar(0,0,xl-1,200-STATUSLINES,127);
VW_Bar(xl+viewwidth+1,0,xl-2,200-STATUSLINES,127);
VW_Bar(xl+viewwidthwin+1,0,xl-2,200-STATUSLINES,127);
VW_Vlin(yl-1,yl+viewheight,xl-1,0);
VW_Vlin(yl-1,yl+viewheight,xl+viewwidth,125);
VW_Vlin(yl-1,yl+viewheightwin,xl-1,0);
VW_Vlin(yl-1,yl+viewheightwin,xl+viewwidthwin,125);
}
}
......@@ -618,18 +618,18 @@ void DrawPlayBorder()
VW_Bar(0,0,320,200-STATUSLINES+1,127);
xl = 160-viewwidth/2;
yl = (200-STATUSLINES-viewheight)/2;
VW_Bar(xl,yl,viewwidth,viewheight+1,0);
xl = 160-viewwidthwin/2;
yl = (200-STATUSLINES-viewheightwin)/2;
VW_Bar(xl,yl,viewwidthwin,viewheightwin+1,0);
if (xl == 0) {
VW_Hlin(0,viewwidth-1,viewheight,125);
VW_Hlin(0,viewwidthwin-1,viewheightwin,125);
} else {
VW_Hlin(xl-1,xl+viewwidth,yl-1,0);
VW_Hlin(xl-1,xl+viewwidth,yl+viewheight,125);
VW_Vlin(yl-1,yl+viewheight,xl-1,0);
VW_Vlin(yl-1,yl+viewheight,xl+viewwidth,125);
VW_Plot(xl-1,yl+viewheight,124);
VW_Hlin(xl-1,xl+viewwidthwin,yl-1,0);
VW_Hlin(xl-1,xl+viewwidthwin,yl+viewheightwin,125);
VW_Vlin(yl-1,yl+viewheightwin,xl-1,0);
VW_Vlin(yl-1,yl+viewheightwin,xl+viewwidthwin,125);
VW_Plot(xl-1,yl+viewheightwin,124);
}
}
......
This diff is collapsed.
......@@ -2417,24 +2417,21 @@ void DrawCustKeys(int hilight)
// CHANGE SCREEN VIEWING SIZE
//
////////////////////////////////////////////////////////////////////
void CP_ChangeView(void)
void CP_ChangeView()
{
int exit=0,oldview,newview;
int exit = 0, oldview, newview;
ControlInfo ci;
WindowX=WindowY=0;
WindowW=320;
WindowH=200;
newview=oldview=viewwidth/16;
newview=oldview=viewsize;
DrawChangeView(oldview);
do
{
do {
CheckPause();
ReadAnyControl(&ci);
switch(ci.dir)
{
switch(ci.dir) {
case dir_South:
case dir_West:
newview--;
......@@ -2464,20 +2461,16 @@ void CP_ChangeView(void)
PicturePause();
if (ci.button0 || IN_KeyDown(sc_Enter))
exit=1;
exit = 1;
else if (ci.button1 || IN_KeyDown(sc_Escape)) {
viewwidth=oldview*16;
SD_PlaySound(ESCPRESSEDSND);
MenuFadeOut();
return;
}
} while(!exit);
if (oldview!=newview)
{
SD_PlaySound (SHOOTSND);
if (oldview != newview) {
SD_PlaySound(SHOOTSND);
Message(STR_THINK"...");
NewViewSize(newview);
}
......
......@@ -38,8 +38,6 @@ int buttonscan[NUMBUTTONS] =
int buttonmouse[4]={bt_attack,bt_strafe,bt_use,bt_nobutton};
int buttonjoy[4]={bt_attack,bt_strafe,bt_use,bt_run};
int viewsize;
boolean buttonheld[NUMBUTTONS];
boolean demorecord,demoplayback;
......
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