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)
{
......
......@@ -12,8 +12,6 @@
#include <X11/keysymdef.h>
#include <X11/Xatom.h>
#include <X11/extensions/XShm.h>
#include <X11/extensions/xf86vmode.h>
#include <X11/extensions/xf86dga.h>
byte *gfxbuf = NULL;
byte *disbuf = NULL;
......@@ -28,16 +26,10 @@ Colormap cmap;
Atom wmDeleteWindow;
XShmSegmentInfo shminfo;
XF86VidModeModeInfo vidmode;
XF86VidModeModeInfo **vmmi;
XColor clr[256];
int indexmode;
int shmmode;
int fullscreen;
int dga;
byte *dgabuf;
int dgawidth, dgabank, dgamem, vwidth, vheight;
static byte cpal[768];
static word spal[768];
......@@ -177,7 +169,7 @@ void VL_Startup()
char data[8] = { 0x01 };
char *disp;
int attrmask, eventn, errorn, i, vmc;
int attrmask;
disp = getenv("DISPLAY");
......@@ -199,11 +191,6 @@ void VL_Startup()
| FocusChangeMask | StructureNotifyMask;
attrmask = CWColormap | CWEventMask;
if (fullscreen || dga) {
attrmask |= CWOverrideRedirect;
attr.override_redirect = True;
}
win = XCreateWindow(dpy, root, 0, 0, 320, 200, 0, CopyFromParent,
InputOutput, vi->visual, attrmask, &attr);
......@@ -236,11 +223,9 @@ void VL_Startup()
cursor = XCreatePixmapCursor(dpy, bitmap, bitmap, &fg, &bg, 0, 0);
XDefineCursor(dpy, win, cursor);
fullscreen = 0;
dga = 0;
shmmode = 0;
if (!MS_CheckParm("noshm") && !dga && (XShmQueryExtension(dpy) == True)) {
if (!MS_CheckParm("noshm") && (XShmQueryExtension(dpy) == True)) {
img = XShmCreateImage(dpy, vi->visual, vi->depth, ZPixmap,
NULL, &shminfo, 320, 200);
......@@ -252,7 +237,7 @@ void VL_Startup()
if (indexmode)
gfxbuf = disbuf;
else
gfxbuf = malloc(320 * 200 * 1);
gfxbuf = malloc(vwidth * vheight * 1);
if (XShmAttach(dpy, &shminfo) == True) {
printf("Using XShm Extension...\n");
......@@ -264,7 +249,7 @@ void VL_Startup()
}
}
if (!dga && (img == NULL)) {
if (img == NULL) {
XImage *imgtmp;
char *gb;
......@@ -276,14 +261,14 @@ void VL_Startup()
gfxbuf, 16, 1, 8, 16*4);
if (gfxbuf == NULL)
gfxbuf = malloc(320 * 200 * 1);
gfxbuf = malloc(vwidth * vheight * 1);
if (indexmode)
disbuf = gfxbuf;
else
disbuf = malloc(320 * 200 * (imgtmp->bits_per_pixel / 8));
disbuf = malloc(vwidth * vheight * (imgtmp->bits_per_pixel / 8));
img = XCreateImage(dpy, vi->visual, vi->depth, ZPixmap, 0,
(char *)disbuf, 320, 200, 8, 320 * (imgtmp->bits_per_pixel / 8));
(char *)disbuf, vwidth, vheight, 8, 0 * (imgtmp->bits_per_pixel / 8));
if (img == NULL) {
Quit("XCreateImage returned NULL");
......@@ -299,101 +284,8 @@ void VL_Startup()
XMapRaised(dpy, win);
}
#if 0
fullscreen = 0;
if (MS_CheckParm("fullscreen") && XF86VidModeQueryExtension(dpy, &eventn, &errorn)) {
XF86VidModeGetAllModeLines(dpy, screen, &vmc, (XF86VidModeModeInfo ***)&vmmi);
printf("VidMode: eventn = %d, error = %d, vmc = %d\n", eventn, errorn, vmc);
for (i = 0; i < vmc; i++) {
if ( (vmmi[i]->hdisplay == 320) && (vmmi[i]->vdisplay == 200) ) {
//XF86VidModeGetModeLine(dpy, screen, &errorn, (XF86VidModeModeLine *)&vidmode); /* TODO: 3rd parm? */
//memcpy(&vidmode, vmmi[0], sizeof(XF86VidModeModeInfo)); /* TODO: bah, why doesn't above work? */
//printf("%d, %d, %d\n", vidmode.hdisplay, vidmode.vdisplay, errorn);
if (XF86VidModeSwitchToMode(dpy, screen, vmmi[i]) == True) {
XF86VidModeLockModeSwitch(dpy, screen, True);
printf("Using VidMode!\n");
fullscreen = 1;
break;
}
}
}
dga = 0;
if (fullscreen && MS_CheckParm("dga") && XF86DGAQueryExtension(dpy, &eventn, &errorn)) {
if (geteuid()) {
fprintf(stderr, "must be root to use dga\n");
} else {
printf("DGA %d %d\n", eventn, errorn);
XF86DGAQueryVersion(dpy, &eventn, &errorn);
printf("DGA Version %d.%d\n", eventn, errorn);
XF86DGAQueryDirectVideo(dpy, screen, &i);
if (i & XF86DGADirectPresent) {
XF86DGAGetVideo(dpy, screen, (char **)&dgabuf, &dgawidth, &dgabank, &dgamem);
printf("addr = %p, width = %d, bank = %d, mem = %d\n", dgabuf, dgawidth, dgabank, dgamem);
gfxbuf = disbuf = dgabuf;
XF86DGAGetViewPortSize(dpy, screen, &vwidth, &vheight);
printf("width = %d, height = %d\n", vwidth, vheight);
gfxbuf = (byte *)malloc(320 * 200);
if (!indexmode)
disbuf = (byte *)malloc(320 * 4);
dga = 1;
}
}
}
}
XSetWindowColormap(dpy, win, cmap);
if (fullscreen || dga) {
XMapWindow(dpy, win);
XRaiseWindow(dpy, win);
//XGrabKeyboard(dpy, win, True, GrabModeAsync, GrabModeAsync, CurrentTime);
}
//XMapWindow(dpy, win);
if (fullscreen) {
//XMoveWindow(dpy, win, 0, 0);
XRaiseWindow(dpy, win);
XWarpPointer(dpy, None, win, 0, 0, 0, 0, 0, 0);
//XF86VidModeSetViewPort(dpy, screen, 0, 0);
//XSetInputFocus(dpy, win, RevertToNone, CurrentTime);
}
if (dga) {
XF86DGADirectVideo(dpy, screen, XF86DGADirectGraphics | XF86DGADirectKeyb);
XF86DGASetViewPort(dpy, screen, 0, 0);
}
printf("Mode: %s %s %s %s\n", fullscreen ? "Fullscreen" : "Windowed", dga ? "DGA" : "Standard", shmmode ? "Shm" : "NoShm", indexmode ? "Palette" : "TrueColor");
XFlush(dpy);
#endif
void VL_Shutdown()
{
if (fullscreen) {
XF86VidModeLockModeSwitch(dpy, screen, False);
//printf("%d, %d\n", vidmode.hdisplay, vidmode.vdisplay);
//XF86VidModeSwitchToMode(dpy, screen, &vidmode);
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;
......@@ -424,70 +316,19 @@ void VL_WaitVBL(int vbls)
void VW_UpdateScreen()
{
dword *ptri;
word *ptrs;
byte *ptrb, *ptrbd;
byte *ptrb;
int i;
if (dga) {
switch(vi->depth) {
case 8:
ptrb = dgabuf;
ptrbd = gfxbuf;
for(i = 0; i < 200; i++) {
memcpy(ptrb, ptrbd, 320);
ptrb += dgawidth;
ptrbd += 320;
}
return;
#if 0
case 15:
ptrs = (word *)disbuf;
for (i = 0; i < 64000; i++) {
*ptrs = (cpal[gfxbuf[i]*3+0] >> 1) << 10 |
(cpal[gfxbuf[i]*3+1] >> 1) << 5 |
(cpal[gfxbuf[i]*3+2] >> 1);
ptrs++;
}
break;
case 16:
ptrs = (word *)disbuf;
for (i = 0; i < 64000; i++) {
*ptrs = (cpal[gfxbuf[i]*3+0] >> 1) << 11 |
(cpal[gfxbuf[i]*3+1] >> 0) << 5 |
(cpal[gfxbuf[i]*3+2] >> 1);
ptrs++;
}
break;
case 24: /* not correct size */
ptrb = disbuf;
for (i = 0; i < 64000; i++) {
*ptrb = cpal[gfxbuf[i]*3+2] << 2; ptrb++;
*ptrb = cpal[gfxbuf[i]*3+1] << 2; ptrb++;
*ptrb = cpal[gfxbuf[i]*3+0] << 2; ptrb++;
ptrb++;
}
break;
#endif
}
}
if (indexmode == 0) {
switch(MyDepth) {
case 15:
ptrs = (word *)disbuf;
for (i = 0; i < 64000; i++) {
*ptrs = (cpal[gfxbuf[i]*3+0] >> 1) << 10 |
(cpal[gfxbuf[i]*3+1] >> 1) << 5 |
(cpal[gfxbuf[i]*3+2] >> 1);
ptrs++;
}
break;
case 16:
ptrs = (word *)disbuf;
for (i = 0; i < 64000; i++) {
*ptrs = (cpal[gfxbuf[i]*3+0] >> 1) << 11 |
(cpal[gfxbuf[i]*3+1] >> 0) << 5 |
(cpal[gfxbuf[i]*3+2] >> 1);
*ptrs = spal[gfxbuf[i]];
ptrs++;
}
break;
......@@ -500,14 +341,11 @@ void VW_UpdateScreen()
}
break;
case 32:
ptrb = disbuf;
ptri = (dword *)disbuf;
for (i = 0; i < 64000; i++) {
*ptrb = cpal[gfxbuf[i]*3+2] << 2; ptrb++;
*ptrb = cpal[gfxbuf[i]*3+1] << 2; ptrb++;
*ptrb = cpal[gfxbuf[i]*3+0] << 2; ptrb++;
ptrb++;
*ptri = ipal[gfxbuf[i]];
ptri++;
}
break;
}
}
......@@ -556,36 +394,6 @@ static void HandleXEvents()
/* ======================================================================== */
/*
=================
=
= VL_FillPalette
=
=================
*/
void VL_FillPalette(int red, int green, int blue)
{
int i;
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);
if (dga) XF86DGAInstallColormap(dpy, screen, cmap);
} else {
for (i = 0; i < 256; i++) {
cpal[i*3+0] = red;
cpal[i*3+1] = green;
cpal[i*3+2] = blue;
}
}
}
/*
=================
=
......@@ -605,9 +413,23 @@ void VL_SetPalette(const byte *palette)
clr[i].blue = palette[i*3+2] << 10;
}
XStoreColors(dpy, cmap, clr, 256);
if (dga) XF86DGAInstallColormap(dpy, screen, cmap);
} else {
memcpy(cpal, palette, 768);
for (i = 0; i < 256; i++) {
switch(MyDepth) {
case 8:
break;
case 15:
spal[i] = ((palette[i*3+0] >> 1) << 10) | ((palette[i*3+1] >> 1) << 5) | ((palette[i*3+2] >> 1) << 0);
break;
case 16:
spal[i] = ((palette[i*3+0] >> 1) << 11) | ((palette[i*3+1] >> 0) << 5) | ((palette[i*3+2] >> 1) << 0);
break;
case 32:
ipal[i] = (palette[i*3+0] << 18) | (palette[i*3+1] << 10) | (palette[i*3+2] << 2);
break;
}
}
VW_UpdateScreen();
}
}
......@@ -637,6 +459,9 @@ void VL_GetPalette(byte *palette)
int main(int argc, char *argv[])
{
vwidth = 320;
vheight = 200;
return WolfMain(argc, argv);
}
......@@ -680,127 +505,8 @@ void Quit(char *error)
exit(EXIT_SUCCESS);
}
/*
=============================================================================
PIXEL OPS
=============================================================================
*/
/*
=================
=
= VL_ClearVideo
=
= Fill the entire video buffer with a given color
=
=================
*/
void VL_ClearVideo(byte color)
{
memset(gfxbuf, color, 64000);
}
/*
=================
=
= 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)
{
if (dga) {
switch(vi->depth) {
case 8:
*(dgabuf + x2 + y2 * dgawidth) = *(gfxbuf + x1 + y1 * 320);
return;
}
return;
}
if (indexmode) {
XSetForeground(dpy, gc, *(gfxbuf + x1 + y1 * 320));
XDrawPoint(dpy, win, gc, x2, y2);
......
......@@ -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);
}
}
......
......@@ -12,34 +12,19 @@
=============================================================================
*/
/*
=============================================================================
LOCAL CONSTANTS
=============================================================================
*/
#define FOCALLENGTH (0x5700l) // in global coordinates
#define VIEWGLOBAL 0x10000 // globals visable flush to wall
/*
=============================================================================
GLOBAL VARIABLES
=============================================================================
*/
char str[80], str2[20];
//
// projection variables
//
fixed focallength;
int viewwidth;
int viewheight;
int viewwidth, viewheight;
int viewwidthwin, viewheightwin; /* for borders */
int xoffset, yoffset;
int vwidth, vheight; /* size of screen */
int viewsize;
int centerx;
int shootdelta; // pixels away from centerx a target can be
fixed scale;
......@@ -48,7 +33,6 @@ long heightnumerator;
boolean startgame,loadedgame;
int mouseadjustment;
/* These are refugees from wl_draw.c */
long frameon;
long lasttimecount;
fixed viewsin, viewcos;
......@@ -61,8 +45,6 @@ char configname[13] = "config.";
fixed sintable[ANGLES+ANGLES/4+1], *costable = sintable+(ANGLES/4);
unsigned xoffset, yoffset;
int _argc;
char **_argv;
......@@ -184,7 +166,6 @@ void ReadConfig()
//
// no config file, so select by hardware
//
/* max viewsize is 20 */
viewsize = 15;
}
......@@ -501,31 +482,160 @@ boolean LoadTheGame(int file,int x,int y)
return true;
}
/* ======================================================================== */
//===========================================================================
/*
==========================
=
= ShutdownId
=================
=
= Shuts down all ID_?? managers
= MS_CheckParm
=
==========================
=================
*/
void ShutdownId()
int MS_CheckParm(char *check)
{
US_Shutdown();
SD_Shutdown();
IN_Shutdown();
VW_Shutdown();
CA_Shutdown();
PM_Shutdown();
MM_Shutdown();
int i;
char *parm;
for (i = 1; i < _argc; i++) {
parm = _argv[i];
while (!isalpha(*parm)) // skip - / \ etc.. in front of parm
if (!*parm++)
break; // hit end of string without an alphanum
if (!stricmp(check, parm))
return i;
}
return 0;
}
//===========================================================================
/* ======================================================================== */
/*
=====================
=
= InitDigiMap
=
=====================
*/
static int wolfdigimap[] =
{
// These first sounds are in the upload version
#ifndef SPEAR
HALTSND, 0,
DOGBARKSND, 1,
CLOSEDOORSND, 2,
OPENDOORSND, 3,
ATKMACHINEGUNSND, 4,
ATKPISTOLSND, 5,
ATKGATLINGSND, 6,
SCHUTZADSND, 7,
GUTENTAGSND, 8,
MUTTISND, 9,
BOSSFIRESND, 10,
SSFIRESND, 11,
DEATHSCREAM1SND, 12,
DEATHSCREAM2SND, 13,
DEATHSCREAM3SND, 13,
TAKEDAMAGESND, 14,
PUSHWALLSND, 15,
LEBENSND, 20,
NAZIFIRESND, 21,
SLURPIESND, 22,
YEAHSND, 32,
#ifndef UPLOAD
// These are in all other episodes
DOGDEATHSND, 16,
AHHHGSND, 17,
DIESND, 18,
EVASND, 19,
TOT_HUNDSND, 23,
MEINGOTTSND, 24,
SCHABBSHASND, 25,
HITLERHASND, 26,
SPIONSND, 27,
NEINSOVASSND, 28,
DOGATTACKSND, 29,
LEVELDONESND, 30,
MECHSTEPSND, 31,
SCHEISTSND, 33,
DEATHSCREAM4SND, 34, // AIIEEE
DEATHSCREAM5SND, 35, // DEE-DEE
DONNERSND, 36, // EPISODE 4 BOSS DIE
EINESND, 37, // EPISODE 4 BOSS SIGHTING
ERLAUBENSND, 38, // EPISODE 6 BOSS SIGHTING
DEATHSCREAM6SND, 39, // FART
DEATHSCREAM7SND, 40, // GASP
DEATHSCREAM8SND, 41, // GUH-BOY!
DEATHSCREAM9SND, 42, // AH GEEZ!
KEINSND, 43, // EPISODE 5 BOSS SIGHTING
MEINSND, 44, // EPISODE 6 BOSS DIE
ROSESND, 45, // EPISODE 5 BOSS DIE
#endif
#else
//
// SPEAR OF DESTINY DIGISOUNDS
//
HALTSND, 0,
CLOSEDOORSND, 2,
OPENDOORSND, 3,
ATKMACHINEGUNSND, 4,
ATKPISTOLSND, 5,
ATKGATLINGSND, 6,
SCHUTZADSND, 7,
BOSSFIRESND, 8,
SSFIRESND, 9,
DEATHSCREAM1SND, 10,
DEATHSCREAM2SND, 11,
TAKEDAMAGESND, 12,
PUSHWALLSND, 13,
AHHHGSND, 15,
LEBENSND, 16,
NAZIFIRESND, 17,
SLURPIESND, 18,
LEVELDONESND, 22,
DEATHSCREAM4SND, 23, // AIIEEE
DEATHSCREAM3SND, 23, // DOUBLY-MAPPED!!!
DEATHSCREAM5SND, 24, // DEE-DEE
DEATHSCREAM6SND, 25, // FART
DEATHSCREAM7SND, 26, // GASP
DEATHSCREAM8SND, 27, // GUH-BOY!
DEATHSCREAM9SND, 28, // AH GEEZ!
GETGATLINGSND, 38, // Got Gat replacement
#ifndef SPEARDEMO
DOGBARKSND, 1,
DOGDEATHSND, 14,
SPIONSND, 19,
NEINSOVASSND, 20,
DOGATTACKSND, 21,
TRANSSIGHTSND, 29, // Trans Sight
TRANSDEATHSND, 30, // Trans Death
WILHELMSIGHTSND, 31, // Wilhelm Sight
WILHELMDEATHSND, 32, // Wilhelm Death
UBERDEATHSND, 33, // Uber Death
KNIGHTSIGHTSND, 34, // Death Knight Sight
KNIGHTDEATHSND, 35, // Death Knight Death
ANGELSIGHTSND, 36, // Angel Sight
ANGELDEATHSND, 37, // Angel Death
GETSPEARSND, 39, // Got Spear replacement
#endif
#endif
LASTSOUND
};
void InitDigiMap()
{
int *map;
for (map = wolfdigimap; *map != LASTSOUND; map += 2)
DigiMap[map[0]] = map[1];
}
//===========================================================================
/*
==================
......@@ -556,7 +666,7 @@ void BuildTables()
for (i=0;i<FINEANGLES/8;i++)
{
tang = tan( (i+0.5)/radtoint);
tang = tan((i+0.5)/radtoint);
finetangent[i] = tang*TILEGLOBAL;
finetangent[FINEANGLES/4-1-i] = 1/tang*TILEGLOBAL;
}
......@@ -586,8 +696,6 @@ void BuildTables()
=
= CalcProjection
=
= Uses focallength
=
====================
*/
......@@ -652,217 +760,59 @@ void SetupWalls()
}
}
//===========================================================================
/*
==========================
=
= SignonScreen
=
==========================
*/
void SignonScreen()
{
VL_SetPalette(gamepal);
VL_MemToScreen(introscn, 320, 200, 0, 0);
VW_UpdateScreen();
}
/*
==========================
=
= FinishSignon
=
==========================
*/
void FinishSignon()
void ShowViewSize(int width)
{
#ifndef SPEAR
VW_Bar(0, 189, 300, 11, introscn[0]);
WindowX = 0;
WindowW = 320;
PrintY = 190;
SETFONTCOLOR(14,4);
US_CPrint("Press a key");
VW_UpdateScreen();
if (!NoWait)
IN_Ack ();
VW_Bar(0, 189, 300, 11, introscn[0]);
int oldwidth,oldheight;
PrintY = 190;
SETFONTCOLOR(10,4);
oldwidth = viewwidthwin;
oldheight = viewheightwin;
US_CPrint("Working...");
VW_UpdateScreen();
viewwidthwin = width*16;
viewheightwin = width*16*HEIGHTRATIO;
DrawPlayBorder();
SETFONTCOLOR(0,15);
#else
if (!NoWait)
VW_WaitVBL(3*70);
#endif
viewheightwin = oldheight;
viewwidthwin = oldwidth;
}
//===========================================================================
/*
=================
=
= MS_CheckParm
=
=================
*/
int MS_CheckParm(char *check)
void NewViewSize(int width)
{
int i;
char *parm;
if (width > 20)
width = 20;
if (width < 4)
width = 4;
for (i = 1;i<_argc;i++)
{
parm = _argv[i];
width *= vwidth / 320;
while ( !isalpha(*parm) ) // skip - / \ etc.. in front of parm
if (!*parm++)
break; // hit end of string without an alphanum
if ((width*16) > vwidth)
width = vwidth / 16;
if ( !stricmp(check,parm) )
return i;
}
if ((width*16*HEIGHTRATIO) > (vheight - 40*vheight/200))
width = (vheight - 40*vheight/200)/8;
return 0;
}
viewwidthwin = width*16*320/vwidth;
viewheightwin = width*16*HEIGHTRATIO*320/vwidth;
viewsize = width*320/vwidth;
//===========================================================================
viewwidth = width*16;
viewheight = width*16*HEIGHTRATIO;
/*
=====================
=
= InitDigiMap
=
=====================
*/
centerx = viewwidth/2-1;
shootdelta = viewwidth/10;
static int wolfdigimap[] =
{
// These first sounds are in the upload version
#ifndef SPEAR
HALTSND, 0,
DOGBARKSND, 1,
CLOSEDOORSND, 2,
OPENDOORSND, 3,
ATKMACHINEGUNSND, 4,
ATKPISTOLSND, 5,
ATKGATLINGSND, 6,
SCHUTZADSND, 7,
GUTENTAGSND, 8,
MUTTISND, 9,
BOSSFIRESND, 10,
SSFIRESND, 11,
DEATHSCREAM1SND, 12,
DEATHSCREAM2SND, 13,
DEATHSCREAM3SND, 13,
TAKEDAMAGESND, 14,
PUSHWALLSND, 15,
LEBENSND, 20,
NAZIFIRESND, 21,
SLURPIESND, 22,
YEAHSND, 32,
#ifndef UPLOAD
// These are in all other episodes
DOGDEATHSND, 16,
AHHHGSND, 17,
DIESND, 18,
EVASND, 19,
TOT_HUNDSND, 23,
MEINGOTTSND, 24,
SCHABBSHASND, 25,
HITLERHASND, 26,
SPIONSND, 27,
NEINSOVASSND, 28,
DOGATTACKSND, 29,
LEVELDONESND, 30,
MECHSTEPSND, 31,
yoffset = (vheight-STATUSLINES*vheight/200-viewheight)/2;
xoffset = (vwidth-viewwidth)/2;
SCHEISTSND, 33,
DEATHSCREAM4SND, 34, // AIIEEE
DEATHSCREAM5SND, 35, // DEE-DEE
DONNERSND, 36, // EPISODE 4 BOSS DIE
EINESND, 37, // EPISODE 4 BOSS SIGHTING
ERLAUBENSND, 38, // EPISODE 6 BOSS SIGHTING
DEATHSCREAM6SND, 39, // FART
DEATHSCREAM7SND, 40, // GASP
DEATHSCREAM8SND, 41, // GUH-BOY!
DEATHSCREAM9SND, 42, // AH GEEZ!
KEINSND, 43, // EPISODE 5 BOSS SIGHTING
MEINSND, 44, // EPISODE 6 BOSS DIE
ROSESND, 45, // EPISODE 5 BOSS DIE
#endif
#else
//
// SPEAR OF DESTINY DIGISOUNDS
// calculate trace angles and projection constants
//
HALTSND, 0,
CLOSEDOORSND, 2,
OPENDOORSND, 3,
ATKMACHINEGUNSND, 4,
ATKPISTOLSND, 5,
ATKGATLINGSND, 6,
SCHUTZADSND, 7,
BOSSFIRESND, 8,
SSFIRESND, 9,
DEATHSCREAM1SND, 10,
DEATHSCREAM2SND, 11,
TAKEDAMAGESND, 12,
PUSHWALLSND, 13,
AHHHGSND, 15,
LEBENSND, 16,
NAZIFIRESND, 17,
SLURPIESND, 18,
LEVELDONESND, 22,
DEATHSCREAM4SND, 23, // AIIEEE
DEATHSCREAM3SND, 23, // DOUBLY-MAPPED!!!
DEATHSCREAM5SND, 24, // DEE-DEE
DEATHSCREAM6SND, 25, // FART
DEATHSCREAM7SND, 26, // GASP
DEATHSCREAM8SND, 27, // GUH-BOY!
DEATHSCREAM9SND, 28, // AH GEEZ!
GETGATLINGSND, 38, // Got Gat replacement
#ifndef SPEARDEMO
DOGBARKSND, 1,
DOGDEATHSND, 14,
SPIONSND, 19,
NEINSOVASSND, 20,
DOGATTACKSND, 21,
TRANSSIGHTSND, 29, // Trans Sight
TRANSDEATHSND, 30, // Trans Death
WILHELMSIGHTSND, 31, // Wilhelm Sight
WILHELMDEATHSND, 32, // Wilhelm Death
UBERDEATHSND, 33, // Uber Death
KNIGHTSIGHTSND, 34, // Death Knight Sight
KNIGHTDEATHSND, 35, // Death Knight Death
ANGELSIGHTSND, 36, // Angel Sight
ANGELDEATHSND, 37, // Angel Death
GETSPEARSND, 39, // Got Spear replacement
#endif
#endif
LASTSOUND
};
CalcProjection(FOCALLENGTH);
}
void InitDigiMap()
{
int *map;
//===========================================================================
for (map = wolfdigimap; *map != LASTSOUND; map += 2)
DigiMap[map[0]] = map[1];
}
#ifndef SPEARDEMO
#ifndef SPEAR
CP_iteminfo MusicItems={CTL_X,CTL_Y,6,0,32};
......@@ -905,7 +855,6 @@ CP_itemtype MusicMenu[]=
};
#endif
#ifndef SPEARDEMO
static int songs[]=
{
#ifndef SPEAR
......@@ -1017,6 +966,85 @@ void DoJukebox()
}
#endif
/* ======================================================================== */
/*
==========================
=
= SignonScreen
=
==========================
*/
void SignonScreen()
{
VL_SetPalette(gamepal);
VL_MemToScreen(introscn, 320, 200, 0, 0);
VW_UpdateScreen();
}
/*
==========================
=
= FinishSignon
=
==========================
*/
void FinishSignon()
{
#ifndef SPEAR
VW_Bar(0, 189, 300, 11, introscn[0]);
WindowX = 0;
WindowW = 320;
PrintY = 190;
SETFONTCOLOR(14,4);
US_CPrint("Press a key");
VW_UpdateScreen();
if (!NoWait)
IN_Ack ();
VW_Bar(0, 189, 300, 11, introscn[0]);
PrintY = 190;
SETFONTCOLOR(10,4);
US_CPrint("Working...");
VW_UpdateScreen();
SETFONTCOLOR(0,15);
#else
if (!NoWait)
VW_WaitVBL(3*70);
#endif
}
/* ======================================================================== */
/*
==========================
=
= ShutdownId
=
= Shuts down all ID_?? managers
=
==========================
*/
void ShutdownId()
{
US_Shutdown();
SD_Shutdown();
IN_Shutdown();
VW_Shutdown();
CA_Shutdown();
PM_Shutdown();
MM_Shutdown();
}
/*
==========================
......@@ -1084,64 +1112,6 @@ void InitGame()
// FinishSignon();
}
//===========================================================================
/*
==========================
=
= SetViewSize
=
==========================
*/
boolean SetViewSize(unsigned width, unsigned height)
{
viewwidth = width&~15; // must be divisable by 16
viewheight = height&~1; // must be even
centerx = viewwidth/2-1;
shootdelta = viewwidth/10;
yoffset = (200-STATUSLINES-viewheight)/2;
xoffset = (320-viewwidth)/2;
//
// calculate trace angles and projection constants
//
CalcProjection(FOCALLENGTH);
return true;
}
void ShowViewSize(int width)
{
int oldwidth,oldheight;
oldwidth = viewwidth;
oldheight = viewheight;
viewwidth = width*16;
viewheight = width*16*HEIGHTRATIO;
DrawPlayBorder();
viewheight = oldheight;
viewwidth = oldwidth;
}
void NewViewSize(int width)
{
CA_UpLevel();
MM_SortMem();
viewsize = width;
SetViewSize(width*16,width*16*HEIGHTRATIO);
CA_DownLevel();
}
//===========================================================================
/*
=====================
=
......
......@@ -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