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) ...@@ -52,7 +52,7 @@ sdlwolf3d: $(DOBJS)
gcc -o sdlwolf3d $(DOBJS) $(DLFLAGS) gcc -o sdlwolf3d $(DOBJS) $(DLFLAGS)
clean: clean:
rm -rf swolf3d xwolf3d *.o rm -rf swolf3d xwolf3d sdlwolf3d *.o
distclean: clean distclean: clean
rm -rf *~ DEADJOE rm -rf *~ DEADJOE
......
...@@ -14,57 +14,14 @@ Sound Menu: ...@@ -14,57 +14,14 @@ Sound Menu:
* Sampling Rate: * Sampling Rate:
- 44100 - 44100
- 22050 - 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((MusicGroup *)audiosegs[STARTMUSIC + chunk]);
=> =>
SD_StartMusic(chunk); SD_StartMusic(chunk);
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
* fix fix fix different size stuff
* add ylookup
* remove farmapylookup? * remove farmapylookup?
* would be nice if Quit() used vsnprintf, etc * would be nice if Quit() used vsnprintf, etc
* actor walking through door is drawn in front of door: near end of E1M1 for * 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 typedef struct
{ {
......
#include "id_heads.h" #include "wl_def.h"
// Global variables // Global variables
boolean NoWait; boolean NoWait;
......
#include "id_heads.h" #include "wl_def.h"
/* ======================================================================== */
pictabletype *pictable; pictabletype *pictable;
...@@ -14,68 +12,6 @@ static byte palette1[256][3], palette2[256][3]; ...@@ -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() ...@@ -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; int pixperframe;
unsigned x, y, p, frame; unsigned x, y, p, frame;
...@@ -117,13 +53,13 @@ boolean FizzleFade(unsigned xx, unsigned yy, unsigned width,unsigned height, uns ...@@ -117,13 +53,13 @@ boolean FizzleFade(unsigned xx, unsigned yy, unsigned width,unsigned height, uns
rndval = 1; rndval = 1;
pixperframe = 64000/frames; pixperframe = 64000/frames;
IN_StartAck (); IN_StartAck();
frame=0; frame = 0;
set_TimeCount(0); set_TimeCount(0);
do { do {
if (abortable && IN_CheckAck ()) if (abortable && IN_CheckAck())
return true; return true;
for (p = 0; p < pixperframe; p++) { for (p = 0; p < pixperframe; p++) {
y = (rndval & 0x00FF) - 1; y = (rndval & 0x00FF) - 1;
...@@ -135,7 +71,7 @@ boolean FizzleFade(unsigned xx, unsigned yy, unsigned width,unsigned height, uns ...@@ -135,7 +71,7 @@ boolean FizzleFade(unsigned xx, unsigned yy, unsigned width,unsigned height, uns
} else } else
rndval >>= 1; rndval >>= 1;
if ((x>width) || (y>height)) if ((x > width) || (y > height))
continue; continue;
VL_DirectPlot(xx+x, yy+y, xx+x, yy+y); 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 ...@@ -145,10 +81,23 @@ boolean FizzleFade(unsigned xx, unsigned yy, unsigned width,unsigned height, uns
} }
frame++; frame++;
while (get_TimeCount() < frame) ; while (get_TimeCount() < frame);
} while (1); } 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) ...@@ -199,7 +148,6 @@ void VL_FadeOut(int start, int end, int red, int green, int blue, int steps)
screenfaded = true; screenfaded = true;
} }
/* /*
================= =================
= =
...@@ -212,7 +160,7 @@ void VL_FadeIn(int start, int end, const byte *palette, int steps) ...@@ -212,7 +160,7 @@ void VL_FadeIn(int start, int end, const byte *palette, int steps)
{ {
int i,j,delta; int i,j,delta;
VL_GetPalette (&palette1[0][0]); VL_GetPalette(&palette1[0][0]);
memcpy(&palette2[0][0],&palette1[0][0],sizeof(palette1)); memcpy(&palette2[0][0],&palette1[0][0],sizeof(palette1));
start *= 3; start *= 3;
...@@ -272,3 +220,236 @@ void VL_DeModeXize(byte *buf, int width, int height) ...@@ -272,3 +220,236 @@ void VL_DeModeXize(byte *buf, int width, int height)
memcpy(buf, mem, width * height); memcpy(buf, mem, width * height);
free(mem); 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; ...@@ -35,8 +35,6 @@ extern boolean screenfaded;
#define VW_Startup VL_Startup #define VW_Startup VL_Startup
#define VW_Shutdown VL_Shutdown #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_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_Vlin(y,z,x,c) VL_Vlin(x,y,(z)-(y)+1,c)
#define VW_WaitVBL VL_WaitVBL #define VW_WaitVBL VL_WaitVBL
...@@ -55,4 +53,6 @@ void LoadLatchMem(); ...@@ -55,4 +53,6 @@ void LoadLatchMem();
void VL_CacheScreen(int chunk); void VL_CacheScreen(int chunk);
void VW_Bar(int x, int y, int width, int height, int color);
#endif #endif
#include "id_heads.h" #include "wl_def.h"
#ifdef DOSISM /* TODO: bad name.. since djgpp code would use interrupt (maybe uclock?) most likely */ #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; boolean SoundSourcePresent, AdLibPresent, SoundBlasterPresent;
......
...@@ -8,8 +8,6 @@ extern byte *gfxbuf; ...@@ -8,8 +8,6 @@ extern byte *gfxbuf;
void VL_Startup(); void VL_Startup();
void VL_Shutdown(); void VL_Shutdown();
void VL_ClearVideo(byte color);
void VL_WaitVBL(int vbls); void VL_WaitVBL(int vbls);
void VW_UpdateScreen(); void VW_UpdateScreen();
...@@ -17,7 +15,7 @@ void VL_FillPalette(int red, int green, int blue); ...@@ -17,7 +15,7 @@ void VL_FillPalette(int red, int green, int blue);
void VL_SetPalette(const byte *palette); void VL_SetPalette(const byte *palette);
void VL_GetPalette(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_Hlin(unsigned x, unsigned y, unsigned width, unsigned color);
void VL_Vlin(int x, int y, int height, int 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); 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); ...@@ -28,6 +26,7 @@ void VL_DeModeXize(byte *buf, int width, int height);
void VL_DirectPlot(int x1, int y1, int x2, int y2); void VL_DirectPlot(int x1, int y1, int x2, int y2);
#define MaxPlayers 4 #define MaxPlayers 4
#define MaxJoys 2 #define MaxJoys 2
#define NumCodes 128 #define NumCodes 128
......
...@@ -81,46 +81,6 @@ void VL_Shutdown() ...@@ -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) ...@@ -133,8 +93,6 @@ void VL_SetPalette(const byte *palette)
{ {
} }
//===========================================================================
/* /*
================= =================
= =
...@@ -147,102 +105,6 @@ void VL_GetPalette(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) void VL_DirectPlot(int x1, int y1, int x2, int y2)
{ {
} }
......
/* id_vl.c */
#include "wl_def.h" #include "wl_def.h"
#include "SDL.h" #include "SDL.h"
...@@ -17,6 +15,9 @@ SDL_Surface *surface; ...@@ -17,6 +15,9 @@ SDL_Surface *surface;
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
vwidth = 320;
vheight = 200;
return WolfMain(argc, argv); return WolfMain(argc, argv);
} }
...@@ -38,8 +39,6 @@ void Quit(char *error) ...@@ -38,8 +39,6 @@ void Quit(char *error)
ShutdownId(); ShutdownId();
if (screen) { if (screen) {
printf("TODO: spiffy ansi screen goes here..\n");
/* doesn't look too good on console at the moment ...*/
//DisplayTextSplash(screen); //DisplayTextSplash(screen);
} }
...@@ -59,8 +58,8 @@ void VL_WaitVBL(int vbls) ...@@ -59,8 +58,8 @@ void VL_WaitVBL(int vbls)
void VW_UpdateScreen() void VW_UpdateScreen()
{ {
//VL_WaitVBL(1); //VL_WaitVBL(1);
memcpy(surface->pixels, gfxbuf, 64000); memcpy(surface->pixels, gfxbuf, vwidth*vheight);
SDL_UpdateRect(surface,0,0,0,0); SDL_UpdateRect(surface, 0, 0, 0, 0);
} }
/* /*
...@@ -74,19 +73,18 @@ void VW_UpdateScreen() ...@@ -74,19 +73,18 @@ void VW_UpdateScreen()
void VL_Startup() void VL_Startup()
{ {
if (gfxbuf == NULL) 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"); Quit("Couldn't init SDL");
} }
if (MS_CheckParm("fullscreen")) 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 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(); SDL_Quit();
Quit ("Couldn't set 320x200 mode"); Quit ("Couldn't set 320x200 mode");
} }
...@@ -115,56 +113,6 @@ void VL_Shutdown() ...@@ -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) ...@@ -184,7 +132,7 @@ void VL_SetPalette(const byte *palette)
colors[i].g = palette[i*3+1] << 2; colors[i].g = palette[i*3+1] << 2;
colors[i].b = palette[i*3+2] << 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) ...@@ -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) 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); //SDL_UpdateRect(surface, x1,y1,x1,y1);
} }
...@@ -875,7 +727,7 @@ boolean IN_UserInput(longword delay) ...@@ -875,7 +727,7 @@ boolean IN_UserInput(longword delay)
=================== ===================
*/ */
byte IN_MouseButtons (void) byte IN_MouseButtons()
{ {
return 0; return 0;
} }
...@@ -888,7 +740,7 @@ byte IN_MouseButtons (void) ...@@ -888,7 +740,7 @@ byte IN_MouseButtons (void)
=================== ===================
*/ */
byte IN_JoyButtons (void) byte IN_JoyButtons()
{ {
return 0; return 0;
} }
...@@ -102,39 +102,6 @@ void VL_Shutdown() ...@@ -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) ...@@ -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]); vga_setpalette(i, palette[i*3+0], palette[i*3+1], palette[i*3+2]);
} }
//===========================================================================
/* /*
================= =================
= =
...@@ -174,102 +138,6 @@ void VL_GetPalette(byte *palette) ...@@ -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) void VL_DirectPlot(int x1, int y1, int x2, int y2)
{ {
*(graph_mem + x1 + y1 * 320) = *(gfxbuf + x2 + y2 * 320); *(graph_mem + x1 + y1 * 320) = *(gfxbuf + x2 + y2 * 320);
...@@ -772,12 +640,15 @@ byte IN_MouseButtons (void) ...@@ -772,12 +640,15 @@ byte IN_MouseButtons (void)
=================== ===================
*/ */
byte IN_JoyButtons (void) byte IN_JoyButtons()
{ {
return 0; return 0;
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
vwidth = 320;
vheight = 200;
return WolfMain(argc, argv); return WolfMain(argc, argv);
} }
...@@ -107,7 +107,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine ...@@ -107,7 +107,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
win = hwnd; 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) ...@@ -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) ...@@ -416,9 +370,6 @@ void VL_SetPalette(const byte *palette)
VW_UpdateScreen(); VW_UpdateScreen();
} }
//===========================================================================
/* /*
================= =================
= =
...@@ -432,102 +383,6 @@ void VL_GetPalette(byte *palette) ...@@ -432,102 +383,6 @@ void VL_GetPalette(byte *palette)
memcpy(palette, mypal, 768); 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) void VL_DirectPlot(int x1, int y1, int x2, int y2)
{ {
......
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
#include <X11/keysymdef.h> #include <X11/keysymdef.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/extensions/XShm.h> #include <X11/extensions/XShm.h>
#include <X11/extensions/xf86vmode.h>
#include <X11/extensions/xf86dga.h>
byte *gfxbuf = NULL; byte *gfxbuf = NULL;
byte *disbuf = NULL; byte *disbuf = NULL;
...@@ -28,16 +26,10 @@ Colormap cmap; ...@@ -28,16 +26,10 @@ Colormap cmap;
Atom wmDeleteWindow; Atom wmDeleteWindow;
XShmSegmentInfo shminfo; XShmSegmentInfo shminfo;
XF86VidModeModeInfo vidmode;
XF86VidModeModeInfo **vmmi;
XColor clr[256]; XColor clr[256];
int indexmode; int indexmode;
int shmmode; int shmmode;
int fullscreen;
int dga;
byte *dgabuf;
int dgawidth, dgabank, dgamem, vwidth, vheight;
static byte cpal[768]; static byte cpal[768];
static word spal[768]; static word spal[768];
...@@ -177,7 +169,7 @@ void VL_Startup() ...@@ -177,7 +169,7 @@ void VL_Startup()
char data[8] = { 0x01 }; char data[8] = { 0x01 };
char *disp; char *disp;
int attrmask, eventn, errorn, i, vmc; int attrmask;
disp = getenv("DISPLAY"); disp = getenv("DISPLAY");
...@@ -199,11 +191,6 @@ void VL_Startup() ...@@ -199,11 +191,6 @@ void VL_Startup()
| FocusChangeMask | StructureNotifyMask; | FocusChangeMask | StructureNotifyMask;
attrmask = CWColormap | CWEventMask; attrmask = CWColormap | CWEventMask;
if (fullscreen || dga) {
attrmask |= CWOverrideRedirect;
attr.override_redirect = True;
}
win = XCreateWindow(dpy, root, 0, 0, 320, 200, 0, CopyFromParent, win = XCreateWindow(dpy, root, 0, 0, 320, 200, 0, CopyFromParent,
InputOutput, vi->visual, attrmask, &attr); InputOutput, vi->visual, attrmask, &attr);
...@@ -236,11 +223,9 @@ void VL_Startup() ...@@ -236,11 +223,9 @@ void VL_Startup()
cursor = XCreatePixmapCursor(dpy, bitmap, bitmap, &fg, &bg, 0, 0); cursor = XCreatePixmapCursor(dpy, bitmap, bitmap, &fg, &bg, 0, 0);
XDefineCursor(dpy, win, cursor); XDefineCursor(dpy, win, cursor);
fullscreen = 0;
dga = 0;
shmmode = 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, img = XShmCreateImage(dpy, vi->visual, vi->depth, ZPixmap,
NULL, &shminfo, 320, 200); NULL, &shminfo, 320, 200);
...@@ -252,7 +237,7 @@ void VL_Startup() ...@@ -252,7 +237,7 @@ void VL_Startup()
if (indexmode) if (indexmode)
gfxbuf = disbuf; gfxbuf = disbuf;
else else
gfxbuf = malloc(320 * 200 * 1); gfxbuf = malloc(vwidth * vheight * 1);
if (XShmAttach(dpy, &shminfo) == True) { if (XShmAttach(dpy, &shminfo) == True) {
printf("Using XShm Extension...\n"); printf("Using XShm Extension...\n");
...@@ -264,7 +249,7 @@ void VL_Startup() ...@@ -264,7 +249,7 @@ void VL_Startup()
} }
} }
if (!dga && (img == NULL)) { if (img == NULL) {
XImage *imgtmp; XImage *imgtmp;
char *gb; char *gb;
...@@ -276,14 +261,14 @@ void VL_Startup() ...@@ -276,14 +261,14 @@ void VL_Startup()
gfxbuf, 16, 1, 8, 16*4); gfxbuf, 16, 1, 8, 16*4);
if (gfxbuf == NULL) if (gfxbuf == NULL)
gfxbuf = malloc(320 * 200 * 1); gfxbuf = malloc(vwidth * vheight * 1);
if (indexmode) if (indexmode)
disbuf = gfxbuf; disbuf = gfxbuf;
else 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, 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) { if (img == NULL) {
Quit("XCreateImage returned NULL"); Quit("XCreateImage returned NULL");
...@@ -299,101 +284,8 @@ void VL_Startup() ...@@ -299,101 +284,8 @@ void VL_Startup()
XMapRaised(dpy, win); 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() 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) ) { if ( !shmmode && (gfxbuf != NULL) ) {
free(gfxbuf); free(gfxbuf);
gfxbuf = NULL; gfxbuf = NULL;
...@@ -424,70 +316,19 @@ void VL_WaitVBL(int vbls) ...@@ -424,70 +316,19 @@ void VL_WaitVBL(int vbls)
void VW_UpdateScreen() void VW_UpdateScreen()
{ {
dword *ptri;
word *ptrs; word *ptrs;
byte *ptrb, *ptrbd; byte *ptrb;
int i; 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) { if (indexmode == 0) {
switch(MyDepth) { switch(MyDepth) {
case 15: 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: case 16:
ptrs = (word *)disbuf; ptrs = (word *)disbuf;
for (i = 0; i < 64000; i++) { for (i = 0; i < 64000; i++) {
*ptrs = (cpal[gfxbuf[i]*3+0] >> 1) << 11 | *ptrs = spal[gfxbuf[i]];
(cpal[gfxbuf[i]*3+1] >> 0) << 5 |
(cpal[gfxbuf[i]*3+2] >> 1);
ptrs++; ptrs++;
} }
break; break;
...@@ -500,14 +341,11 @@ void VW_UpdateScreen() ...@@ -500,14 +341,11 @@ void VW_UpdateScreen()
} }
break; break;
case 32: case 32:
ptrb = disbuf; ptri = (dword *)disbuf;
for (i = 0; i < 64000; i++) { for (i = 0; i < 64000; i++) {
*ptrb = cpal[gfxbuf[i]*3+2] << 2; ptrb++; *ptri = ipal[gfxbuf[i]];
*ptrb = cpal[gfxbuf[i]*3+1] << 2; ptrb++; ptri++;
*ptrb = cpal[gfxbuf[i]*3+0] << 2; ptrb++;
ptrb++;
} }
break;
} }
} }
...@@ -556,36 +394,6 @@ static void HandleXEvents() ...@@ -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) ...@@ -605,9 +413,23 @@ void VL_SetPalette(const byte *palette)
clr[i].blue = palette[i*3+2] << 10; clr[i].blue = palette[i*3+2] << 10;
} }
XStoreColors(dpy, cmap, clr, 256); XStoreColors(dpy, cmap, clr, 256);
if (dga) XF86DGAInstallColormap(dpy, screen, cmap);
} else { } else {
memcpy(cpal, palette, 768); 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(); VW_UpdateScreen();
} }
} }
...@@ -637,6 +459,9 @@ void VL_GetPalette(byte *palette) ...@@ -637,6 +459,9 @@ void VL_GetPalette(byte *palette)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
vwidth = 320;
vheight = 200;
return WolfMain(argc, argv); return WolfMain(argc, argv);
} }
...@@ -680,127 +505,8 @@ void Quit(char *error) ...@@ -680,127 +505,8 @@ void Quit(char *error)
exit(EXIT_SUCCESS); 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) 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) { if (indexmode) {
XSetForeground(dpy, gc, *(gfxbuf + x1 + y1 * 320)); XSetForeground(dpy, gc, *(gfxbuf + x1 + y1 * 320));
XDrawPoint(dpy, win, gc, x2, y2); XDrawPoint(dpy, win, gc, x2, y2);
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "wl_menu.h" #include "wl_menu.h"
#include "foreign.h" #include "foreign.h"
extern int vwidth, vheight; /* size of screen */
/* /*
============================================================================= =============================================================================
...@@ -55,9 +57,7 @@ ...@@ -55,9 +57,7 @@
#define MINDIST (0x5800l) #define MINDIST (0x5800l)
#define MAXSCALEHEIGHT 512 /* largest scale on largest view */ #define MAXVIEWWIDTH 1280
#define MAXVIEWWIDTH 320
#define MAPSIZE 64 // maps are 64*64 max #define MAPSIZE 64 // maps are 64*64 max
...@@ -676,14 +676,16 @@ extern char str[80], str2[20]; ...@@ -676,14 +676,16 @@ extern char str[80], str2[20];
extern fixed focallength; extern fixed focallength;
extern unsigned viewangles; 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 centerx;
extern int shootdelta; extern int shootdelta;
extern boolean startgame,loadedgame; extern boolean startgame,loadedgame;
extern int mouseadjustment; extern int mouseadjustment;
extern unsigned xoffset, yoffset;
// //
// math tables // math tables
...@@ -695,7 +697,6 @@ extern fixed sintable[], *costable; ...@@ -695,7 +697,6 @@ extern fixed sintable[], *costable;
extern char configname[13]; extern char configname[13];
void CalcProjection (long focal); void CalcProjection (long focal);
boolean SetViewSize (unsigned width, unsigned height);
void NewGame (int difficulty,int episode); void NewGame (int difficulty,int episode);
void NewViewSize (int width); void NewViewSize (int width);
boolean LoadTheGame(int file,int x,int y); boolean LoadTheGame(int file,int x,int y);
...@@ -726,7 +727,6 @@ extern unsigned spearangle; ...@@ -726,7 +727,6 @@ extern unsigned spearangle;
extern boolean spearflag; extern boolean spearflag;
void DrawPlayBorder (void);
void ScanInfoPlane (void); void ScanInfoPlane (void);
void SetupGameLevel (void); void SetupGameLevel (void);
void DrawPlayScreen (void); void DrawPlayScreen (void);
...@@ -735,10 +735,10 @@ void GameLoop (void); ...@@ -735,10 +735,10 @@ void GameLoop (void);
void ClearMemory (void); void ClearMemory (void);
void PlayDemo(int demonumber); void PlayDemo(int demonumber);
int PlayDemoFromFile(char *demoname); int PlayDemoFromFile(char *demoname);
void RecordDemo (void); void RecordDemo();
void DrawPlayBorder (void); void DrawHighScores();
void DrawHighScores(void); void DrawPlayBorder();
void DrawPlayBorderSides (void); void DrawPlayBorderSides();
#define PlaySoundLocTile(s,tx,ty) PlaySoundLocGlobal(s,(((long)(tx) << TILESHIFT) + (1L << (TILESHIFT - 1))),(((long)ty << TILESHIFT) + (1L << (TILESHIFT - 1)))) #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) #define PlaySoundLocActor(s,ob) PlaySoundLocGlobal(s,(ob)->x,(ob)->y)
...@@ -782,7 +782,7 @@ extern int buttonjoy[4]; ...@@ -782,7 +782,7 @@ extern int buttonjoy[4];
extern boolean buttonheld[NUMBUTTONS]; extern boolean buttonheld[NUMBUTTONS];
extern int viewsize; extern int viewsize;
// //
// curent user input // curent user input
......
...@@ -522,7 +522,7 @@ static void DrawSpans(int x1, int x2, int height) ...@@ -522,7 +522,7 @@ static void DrawSpans(int x1, int x2, int height)
fixed startxfrac, startyfrac; fixed startxfrac, startyfrac;
byte *toprow; byte *toprow;
toprow = planeylookup[height]+(320*yoffset+xoffset); toprow = planeylookup[height]+(vwidth*yoffset+xoffset);
mr_rowofs = mirrorofs[height]; mr_rowofs = mirrorofs[height];
mr_xstep = (viewsin / height) >> 1; mr_xstep = (viewsin / height) >> 1;
...@@ -562,8 +562,8 @@ static void SetPlaneViewSize() ...@@ -562,8 +562,8 @@ static void SetPlaneViewSize()
halfheight = viewheight >> 1; halfheight = viewheight >> 1;
for (y = 0; y < halfheight; y++) { for (y = 0; y < halfheight; y++) {
planeylookup[y] = gfxbuf + (halfheight-1-y)*320; planeylookup[y] = gfxbuf + (halfheight-1-y)*vwidth;
mirrorofs[y] = (y*2+1)*320; mirrorofs[y] = (y*2+1)*vwidth;
if (y > 0) if (y > 0)
basedist[y] = GLOBAL1/2*scale/y; basedist[y] = GLOBAL1/2*scale/y;
...@@ -684,21 +684,21 @@ void ThreeDRefresh() ...@@ -684,21 +684,21 @@ 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) static void ScaledDraw(byte *gfx, int scale, byte *vid, unsigned long tfrac, unsigned long tint, unsigned long delta)
{ {
unsigned long OldDelta; unsigned long OldDelta;
while (scale--) { while (scale--) {
*vid = *gfx; *vid = *gfx;
vid += 320; /* TODO: compiled in constant! */ vid += vwidth;
OldDelta = delta; OldDelta = delta;
delta += tfrac; delta += tfrac;
gfx += tint; gfx += tint;
if (OldDelta > delta) if (OldDelta > delta)
gfx += 1; gfx += 1;
} }
} }
static void ScaledDrawTrans(byte *gfx, int scale, byte *vid, unsigned long tfrac, unsigned long tint, unsigned long delta) static void ScaledDrawTrans(byte *gfx, int scale, byte *vid, unsigned long tfrac, unsigned long tint, unsigned long delta)
...@@ -708,7 +708,7 @@ static void ScaledDrawTrans(byte *gfx, int scale, byte *vid, unsigned long tfrac ...@@ -708,7 +708,7 @@ static void ScaledDrawTrans(byte *gfx, int scale, byte *vid, unsigned long tfrac
while (scale--) { while (scale--) {
if (*gfx != 255) if (*gfx != 255)
*vid = *gfx; *vid = *gfx;
vid += 320; /* TODO: compiled in constant! */ vid += vwidth;
OldDelta = delta; OldDelta = delta;
delta += tfrac; delta += tfrac;
gfx += tint; gfx += tint;
...@@ -718,7 +718,7 @@ static void ScaledDrawTrans(byte *gfx, int scale, byte *vid, unsigned long tfrac ...@@ -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 TheFrac;
unsigned long TheInt; unsigned long TheInt;
...@@ -732,7 +732,7 @@ void ScaleLine(unsigned int height, byte *source, int x) ...@@ -732,7 +732,7 @@ void ScaleLine(unsigned int height, byte *source, int x)
TheInt = TheFrac >> 24; TheInt = TheFrac >> 24;
TheFrac <<= 8; TheFrac <<= 8;
ScaledDraw(source, height, gfxbuf + (y * 320) + x + xoffset, ScaledDraw(source, height, gfxbuf + (y * vwidth) + x + xoffset,
TheFrac, TheInt, 0); TheFrac, TheInt, 0);
return; return;
...@@ -744,7 +744,7 @@ void ScaleLine(unsigned int height, byte *source, int x) ...@@ -744,7 +744,7 @@ void ScaleLine(unsigned int height, byte *source, int x)
TheInt = TheFrac >> 24; TheInt = TheFrac >> 24;
TheFrac <<= 8; 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); TheFrac, TheInt, y << 8);
} }
} }
...@@ -756,14 +756,14 @@ static void ScaleLineTrans(unsigned int height, byte *source, int x) ...@@ -756,14 +756,14 @@ static void ScaleLineTrans(unsigned int height, byte *source, int x)
unsigned long y; unsigned long y;
if (height) { if (height) {
TheFrac = 0x40000000UL / height; TheFrac = (64 << 16) / height;
if (height < viewheight) { if (height < viewheight) {
y = yoffset + (viewheight - height) / 2; y = yoffset + (viewheight - height) / 2;
TheInt = TheFrac >> 24; TheInt = TheFrac >> 24;
TheFrac <<= 8; TheFrac <<= 8;
ScaledDrawTrans(source, height, gfxbuf + (y * 320) + x + xoffset, ScaledDrawTrans(source, height, gfxbuf + (y * vwidth) + x + xoffset,
TheFrac, TheInt, 0); TheFrac, TheInt, 0);
return; return;
...@@ -775,10 +775,80 @@ static void ScaleLineTrans(unsigned int height, byte *source, int x) ...@@ -775,10 +775,80 @@ static void ScaleLineTrans(unsigned int height, byte *source, int x)
TheInt = TheFrac >> 24; TheInt = TheFrac >> 24;
TheFrac <<= 8; 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); 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]; static unsigned char *spritegfx[SPR_TOTAL];
......
...@@ -589,18 +589,18 @@ void SetupGameLevel() ...@@ -589,18 +589,18 @@ void SetupGameLevel()
void DrawPlayBorderSides() void DrawPlayBorderSides()
{ {
int xl, yl; int xl, yl;
xl = 160-viewwidth/2; xl = 160-viewwidthwin/2;
yl = (200-STATUSLINES-viewheight)/2; yl = (200-STATUSLINES-viewheightwin)/2;
if (xl == 0) { if (xl == 0) {
return; return;
} else { } else {
VW_Bar(0,0,xl-1,200-STATUSLINES,127); 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+viewheightwin,xl-1,0);
VW_Vlin(yl-1,yl+viewheight,xl+viewwidth,125); VW_Vlin(yl-1,yl+viewheightwin,xl+viewwidthwin,125);
} }
} }
...@@ -618,18 +618,18 @@ void DrawPlayBorder() ...@@ -618,18 +618,18 @@ void DrawPlayBorder()
VW_Bar(0,0,320,200-STATUSLINES+1,127); VW_Bar(0,0,320,200-STATUSLINES+1,127);
xl = 160-viewwidth/2; xl = 160-viewwidthwin/2;
yl = (200-STATUSLINES-viewheight)/2; yl = (200-STATUSLINES-viewheightwin)/2;
VW_Bar(xl,yl,viewwidth,viewheight+1,0); VW_Bar(xl,yl,viewwidthwin,viewheightwin+1,0);
if (xl == 0) { if (xl == 0) {
VW_Hlin(0,viewwidth-1,viewheight,125); VW_Hlin(0,viewwidthwin-1,viewheightwin,125);
} else { } else {
VW_Hlin(xl-1,xl+viewwidth,yl-1,0); VW_Hlin(xl-1,xl+viewwidthwin,yl-1,0);
VW_Hlin(xl-1,xl+viewwidth,yl+viewheight,125); VW_Hlin(xl-1,xl+viewwidthwin,yl+viewheightwin,125);
VW_Vlin(yl-1,yl+viewheight,xl-1,0); VW_Vlin(yl-1,yl+viewheightwin,xl-1,0);
VW_Vlin(yl-1,yl+viewheight,xl+viewwidth,125); VW_Vlin(yl-1,yl+viewheightwin,xl+viewwidthwin,125);
VW_Plot(xl-1,yl+viewheight,124); VW_Plot(xl-1,yl+viewheightwin,124);
} }
} }
......
...@@ -12,43 +12,27 @@ ...@@ -12,43 +12,27 @@
============================================================================= =============================================================================
*/ */
/*
=============================================================================
LOCAL CONSTANTS
=============================================================================
*/
#define FOCALLENGTH (0x5700l) // in global coordinates #define FOCALLENGTH (0x5700l) // in global coordinates
#define VIEWGLOBAL 0x10000 // globals visable flush to wall #define VIEWGLOBAL 0x10000 // globals visable flush to wall
/* char str[80], str2[20];
=============================================================================
GLOBAL VARIABLES fixed focallength;
============================================================================= int viewwidth, viewheight;
*/ int viewwidthwin, viewheightwin; /* for borders */
int xoffset, yoffset;
int vwidth, vheight; /* size of screen */
int viewsize;
char str[80], str2[20]; int centerx;
int shootdelta; // pixels away from centerx a target can be
fixed scale;
long heightnumerator;
boolean startgame,loadedgame;
int mouseadjustment;
//
// projection variables
//
fixed focallength;
int viewwidth;
int viewheight;
int centerx;
int shootdelta; // pixels away from centerx a target can be
fixed scale;
long heightnumerator;
boolean startgame,loadedgame;
int mouseadjustment;
/* These are refugees from wl_draw.c */
long frameon; long frameon;
long lasttimecount; long lasttimecount;
fixed viewsin, viewcos; fixed viewsin, viewcos;
...@@ -61,8 +45,6 @@ char configname[13] = "config."; ...@@ -61,8 +45,6 @@ char configname[13] = "config.";
fixed sintable[ANGLES+ANGLES/4+1], *costable = sintable+(ANGLES/4); fixed sintable[ANGLES+ANGLES/4+1], *costable = sintable+(ANGLES/4);
unsigned xoffset, yoffset;
int _argc; int _argc;
char **_argv; char **_argv;
...@@ -184,7 +166,6 @@ void ReadConfig() ...@@ -184,7 +166,6 @@ void ReadConfig()
// //
// no config file, so select by hardware // no config file, so select by hardware
// //
/* max viewsize is 20 */
viewsize = 15; viewsize = 15;
} }
...@@ -501,214 +482,6 @@ boolean LoadTheGame(int file,int x,int y) ...@@ -501,214 +482,6 @@ boolean LoadTheGame(int file,int x,int y)
return true; return true;
} }
/* ======================================================================== */
/*
==========================
=
= ShutdownId
=
= Shuts down all ID_?? managers
=
==========================
*/
void ShutdownId()
{
US_Shutdown();
SD_Shutdown();
IN_Shutdown();
VW_Shutdown();
CA_Shutdown();
PM_Shutdown();
MM_Shutdown();
}
/* ======================================================================== */
/*
==================
=
= BuildTables
=
= Calculates:
=
= scale projection constant
= sintable/costable overlapping fractional tables
=
==================
*/
static const float radtoint = (float)FINEANGLES/2.0f/PI;
void BuildTables()
{
int i;
float angle,anglestep;
double tang;
fixed value;
//
// calculate fine tangents
//
for (i=0;i<FINEANGLES/8;i++)
{
tang = tan( (i+0.5)/radtoint);
finetangent[i] = tang*TILEGLOBAL;
finetangent[FINEANGLES/4-1-i] = 1/tang*TILEGLOBAL;
}
//
// costable overlays sintable with a quarter phase shift
// ANGLES is assumed to be divisable by four
//
angle = 0;
anglestep = PI/2/ANGLEQUAD;
for (i=0;i<=ANGLEQUAD;i++)
{
value=GLOBAL1*sin(angle);
sintable[i]=
sintable[i+ANGLES]=
sintable[ANGLES/2-i] = value;
sintable[ANGLES-i]=
sintable[ANGLES/2+i] = -value;
angle += anglestep;
}
}
/*
====================
=
= CalcProjection
=
= Uses focallength
=
====================
*/
void CalcProjection(long focal)
{
int i;
long intang;
float angle;
double tang;
int halfview;
double facedist;
focallength = focal;
facedist = focal+MINDIST;
halfview = viewwidth/2; // half view in pixels
//
// calculate scale value for vertical height calculations
// and sprite x calculations
//
scale = halfview*facedist/(VIEWGLOBAL/2);
//
// divide heightnumerator by a posts distance to get the posts height for
// the heightbuffer. The pixel height is height>>2
//
heightnumerator = (TILEGLOBAL*scale)>>6;
//
// calculate the angle offset from view angle of each pixel's ray
//
for (i=0;i<halfview;i++)
{
// start 1/2 pixel over, so viewangle bisects two middle pixels
tang = (long)i*VIEWGLOBAL/viewwidth/facedist;
angle = atan(tang);
intang = angle*radtoint;
pixelangle[halfview-1-i] = intang;
pixelangle[halfview+i] = -intang;
}
}
/*
===================
=
= SetupWalls
=
= Map tile values to scaled pics
=
===================
*/
void SetupWalls()
{
int i;
for (i=1;i<MAXWALLTILES;i++)
{
horizwall[i]=(i-1)*2;
vertwall[i]=(i-1)*2+1;
}
}
//===========================================================================
/*
==========================
=
= 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
}
//=========================================================================== //===========================================================================
/* /*
...@@ -721,21 +494,19 @@ void FinishSignon() ...@@ -721,21 +494,19 @@ void FinishSignon()
int MS_CheckParm(char *check) int MS_CheckParm(char *check)
{ {
int i; int i;
char *parm; char *parm;
for (i = 1;i<_argc;i++) for (i = 1; i < _argc; i++) {
{
parm = _argv[i]; parm = _argv[i];
while ( !isalpha(*parm) ) // skip - / \ etc.. in front of parm while (!isalpha(*parm)) // skip - / \ etc.. in front of parm
if (!*parm++) if (!*parm++)
break; // hit end of string without an alphanum break; // hit end of string without an alphanum
if ( !stricmp(check,parm) ) if (!stricmp(check, parm))
return i; return i;
} }
return 0; return 0;
} }
...@@ -864,6 +635,185 @@ void InitDigiMap() ...@@ -864,6 +635,185 @@ void InitDigiMap()
DigiMap[map[0]] = map[1]; DigiMap[map[0]] = map[1];
} }
//===========================================================================
/*
==================
=
= BuildTables
=
= Calculates:
=
= scale projection constant
= sintable/costable overlapping fractional tables
=
==================
*/
static const float radtoint = (float)FINEANGLES/2.0f/PI;
void BuildTables()
{
int i;
float angle,anglestep;
double tang;
fixed value;
//
// calculate fine tangents
//
for (i=0;i<FINEANGLES/8;i++)
{
tang = tan((i+0.5)/radtoint);
finetangent[i] = tang*TILEGLOBAL;
finetangent[FINEANGLES/4-1-i] = 1/tang*TILEGLOBAL;
}
//
// costable overlays sintable with a quarter phase shift
// ANGLES is assumed to be divisable by four
//
angle = 0;
anglestep = PI/2/ANGLEQUAD;
for (i=0;i<=ANGLEQUAD;i++)
{
value=GLOBAL1*sin(angle);
sintable[i]=
sintable[i+ANGLES]=
sintable[ANGLES/2-i] = value;
sintable[ANGLES-i]=
sintable[ANGLES/2+i] = -value;
angle += anglestep;
}
}
/*
====================
=
= CalcProjection
=
====================
*/
void CalcProjection(long focal)
{
int i;
long intang;
float angle;
double tang;
int halfview;
double facedist;
focallength = focal;
facedist = focal+MINDIST;
halfview = viewwidth/2; // half view in pixels
//
// calculate scale value for vertical height calculations
// and sprite x calculations
//
scale = halfview*facedist/(VIEWGLOBAL/2);
//
// divide heightnumerator by a posts distance to get the posts height for
// the heightbuffer. The pixel height is height>>2
//
heightnumerator = (TILEGLOBAL*scale)>>6;
//
// calculate the angle offset from view angle of each pixel's ray
//
for (i=0;i<halfview;i++)
{
// start 1/2 pixel over, so viewangle bisects two middle pixels
tang = (long)i*VIEWGLOBAL/viewwidth/facedist;
angle = atan(tang);
intang = angle*radtoint;
pixelangle[halfview-1-i] = intang;
pixelangle[halfview+i] = -intang;
}
}
/*
===================
=
= SetupWalls
=
= Map tile values to scaled pics
=
===================
*/
void SetupWalls()
{
int i;
for (i=1;i<MAXWALLTILES;i++)
{
horizwall[i]=(i-1)*2;
vertwall[i]=(i-1)*2+1;
}
}
void ShowViewSize(int width)
{
int oldwidth,oldheight;
oldwidth = viewwidthwin;
oldheight = viewheightwin;
viewwidthwin = width*16;
viewheightwin = width*16*HEIGHTRATIO;
DrawPlayBorder();
viewheightwin = oldheight;
viewwidthwin = oldwidth;
}
void NewViewSize(int width)
{
if (width > 20)
width = 20;
if (width < 4)
width = 4;
width *= vwidth / 320;
if ((width*16) > vwidth)
width = vwidth / 16;
if ((width*16*HEIGHTRATIO) > (vheight - 40*vheight/200))
width = (vheight - 40*vheight/200)/8;
viewwidthwin = width*16*320/vwidth;
viewheightwin = width*16*HEIGHTRATIO*320/vwidth;
viewsize = width*320/vwidth;
viewwidth = width*16;
viewheight = width*16*HEIGHTRATIO;
centerx = viewwidth/2-1;
shootdelta = viewwidth/10;
yoffset = (vheight-STATUSLINES*vheight/200-viewheight)/2;
xoffset = (vwidth-viewwidth)/2;
//
// calculate trace angles and projection constants
//
CalcProjection(FOCALLENGTH);
}
//===========================================================================
#ifndef SPEARDEMO
#ifndef SPEAR #ifndef SPEAR
CP_iteminfo MusicItems={CTL_X,CTL_Y,6,0,32}; CP_iteminfo MusicItems={CTL_X,CTL_Y,6,0,32};
CP_itemtype MusicMenu[]= CP_itemtype MusicMenu[]=
...@@ -905,7 +855,6 @@ CP_itemtype MusicMenu[]= ...@@ -905,7 +855,6 @@ CP_itemtype MusicMenu[]=
}; };
#endif #endif
#ifndef SPEARDEMO
static int songs[]= static int songs[]=
{ {
#ifndef SPEAR #ifndef SPEAR
...@@ -1017,6 +966,85 @@ void DoJukebox() ...@@ -1017,6 +966,85 @@ void DoJukebox()
} }
#endif #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() ...@@ -1084,64 +1112,6 @@ void InitGame()
// FinishSignon(); // 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) ...@@ -2417,24 +2417,21 @@ void DrawCustKeys(int hilight)
// CHANGE SCREEN VIEWING SIZE // CHANGE SCREEN VIEWING SIZE
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void CP_ChangeView(void) void CP_ChangeView()
{ {
int exit=0,oldview,newview; int exit = 0, oldview, newview;
ControlInfo ci; ControlInfo ci;
WindowX=WindowY=0; WindowX=WindowY=0;
WindowW=320; WindowW=320;
WindowH=200; WindowH=200;
newview=oldview=viewwidth/16; newview=oldview=viewsize;
DrawChangeView(oldview); DrawChangeView(oldview);
do do {
{
CheckPause(); CheckPause();
ReadAnyControl(&ci); ReadAnyControl(&ci);
switch(ci.dir) switch(ci.dir) {
{
case dir_South: case dir_South:
case dir_West: case dir_West:
newview--; newview--;
...@@ -2464,20 +2461,16 @@ void CP_ChangeView(void) ...@@ -2464,20 +2461,16 @@ void CP_ChangeView(void)
PicturePause(); PicturePause();
if (ci.button0 || IN_KeyDown(sc_Enter)) if (ci.button0 || IN_KeyDown(sc_Enter))
exit=1; exit = 1;
else if (ci.button1 || IN_KeyDown(sc_Escape)) { else if (ci.button1 || IN_KeyDown(sc_Escape)) {
viewwidth=oldview*16;
SD_PlaySound(ESCPRESSEDSND); SD_PlaySound(ESCPRESSEDSND);
MenuFadeOut(); MenuFadeOut();
return; return;
} }
} while(!exit); } while(!exit);
if (oldview != newview) {
if (oldview!=newview) SD_PlaySound(SHOOTSND);
{
SD_PlaySound (SHOOTSND);
Message(STR_THINK"..."); Message(STR_THINK"...");
NewViewSize(newview); NewViewSize(newview);
} }
......
...@@ -38,8 +38,6 @@ int buttonscan[NUMBUTTONS] = ...@@ -38,8 +38,6 @@ int buttonscan[NUMBUTTONS] =
int buttonmouse[4]={bt_attack,bt_strafe,bt_use,bt_nobutton}; int buttonmouse[4]={bt_attack,bt_strafe,bt_use,bt_nobutton};
int buttonjoy[4]={bt_attack,bt_strafe,bt_use,bt_run}; int buttonjoy[4]={bt_attack,bt_strafe,bt_use,bt_run};
int viewsize;
boolean buttonheld[NUMBUTTONS]; boolean buttonheld[NUMBUTTONS];
boolean demorecord,demoplayback; 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