Commit 82ef4cc1 authored by Steven Fuller's avatar Steven Fuller

Xlib Support. Forgot to return TRUE from SetupScalers (would cause

intermittent failures when going to gamemode).
parent 79356e2e
...@@ -4,8 +4,8 @@ CC = gcc ...@@ -4,8 +4,8 @@ CC = gcc
#CFLAGS = -g -Wall -O6 -fomit-frame-pointer -ffast-math -funroll-loops -mpentiumpro -mcpu=pentiumpro -march=pentiumpro #CFLAGS = -g -Wall -O6 -fomit-frame-pointer -ffast-math -funroll-loops -mpentiumpro -mcpu=pentiumpro -march=pentiumpro
#CFLAGS = -g -Wall #CFLAGS = -g -Wall
#CFLAGS = -g -DNOVGA #CFLAGS = -g -DNOVGA
#CFLAGS = -g CFLAGS = -g
CFLAGS = -Os -g #CFLAGS = -Os -g
#CFLAGS = -g -Wall -I/home/relnev/cvs/oal/include #CFLAGS = -g -Wall -I/home/relnev/cvs/oal/include
OBJS = Data.o Doors.o EnMove.o EnThink.o Intro.o Level.o \ OBJS = Data.o Doors.o EnMove.o EnThink.o Intro.o Level.o \
...@@ -13,15 +13,17 @@ OBJS = Data.o Doors.o EnMove.o EnThink.o Intro.o Level.o \ ...@@ -13,15 +13,17 @@ OBJS = Data.o Doors.o EnMove.o EnThink.o Intro.o Level.o \
RefBsp.o RefSprite.o Refresh.o Refresh2.o Sight.o Main.o \ RefBsp.o RefSprite.o Refresh.o Refresh2.o Sight.o Main.o \
StateDef.o WolfMain.o WolfIO.o InterMis.o Burger.o stub.o res.o StateDef.o WolfMain.o WolfIO.o InterMis.o Burger.o stub.o res.o
SOBJS = $(OBJS) vi_svga.o SOBJS = $(OBJS) vi_svga.o
XOBJS = $(OBJS) XOBJS = $(OBJS) vi_xlib.o
GOBJS = $(OBJS) GOBJS = $(OBJS)
LFLAGS = -lm LFLAGS = -lm
#LFLAGS = -lm -L/home/relnev/cvs/oal/linux/src -lopenal -lpthread -ldl #LFLAGS = -lm -L/home/relnev/cvs/oal/linux/src -lopenal -lpthread -ldl
#LFLAGS = -lm /home/relnev/ElectricFence-2.1/libefence.a
#LFLAGS = -lm /home/relnev/ElectricFence-2.2.2/libefence.a -lpthread #LFLAGS = -lm /home/relnev/ElectricFence-2.2.2/libefence.a -lpthread
SLFLAGS = $(LFLAGS) -lvga SLFLAGS = $(LFLAGS) -lvga
XLFLAGS = $(LFLAGS) -L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lXxf86dga #XLFLAGS = $(LFLAGS) -L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lXxf86dga
XLFLAGS = $(LFLAGS) -L/usr/X11R6/lib -lX11
GLFLAGS = $(LFLAGS) -L/usr/X11R6/lib -lX11 -lXext -lGL GLFLAGS = $(LFLAGS) -L/usr/X11R6/lib -lX11 -lXext -lGL
NASM = nasm NASM = nasm
...@@ -29,7 +31,7 @@ NASM = nasm ...@@ -29,7 +31,7 @@ NASM = nasm
.SUFFIXES: .asm .SUFFIXES: .asm
#all: swolf3d xwolf3d gwolf3d #all: swolf3d xwolf3d gwolf3d
all: swolf3d all: swolf3d xwolf3d
$(SOBJS): Sounds.h Sprites.h States.h Wolf.h burger.h wolfdef.h $(SOBJS): Sounds.h Sprites.h States.h Wolf.h burger.h wolfdef.h
$(XOBJS): Sounds.h Sprites.h States.h Wolf.h burger.h wolfdef.h $(XOBJS): Sounds.h Sprites.h States.h Wolf.h burger.h wolfdef.h
......
The README has not been written yet.
...@@ -30,7 +30,7 @@ void RenderWallLoop(Word x1,Word x2,Word distance) ...@@ -30,7 +30,7 @@ void RenderWallLoop(Word x1,Word x2,Word distance)
while (x1 < x2) { /* Time to draw? */ while (x1 < x2) { /* Time to draw? */
scaler = rw_scale >> FRACBITS; /* Get the draw scale */ scaler = rw_scale >> FRACBITS; /* Get the draw scale */
xscale[x1] = scaler; /* Save the scale factor */ xscale[x1] = scaler; /* Save the scale factor */
angle = xtoviewangle[x1]+rw_centerangle; angle = (xtoviewangle[x1]+rw_centerangle)&4095;/* TODO: for some reason i had to add this */
texturecolumn = rw_midpoint - SUFixedMul(finetangent[angle],distance); /* Which texture to use? */ texturecolumn = rw_midpoint - SUFixedMul(finetangent[angle],distance); /* Which texture to use? */
if ((Word)texturecolumn < rw_mintex) { if ((Word)texturecolumn < rw_mintex) {
texturecolumn = rw_mintex; texturecolumn = rw_mintex;
...@@ -47,7 +47,7 @@ void RenderWallLoop(Word x1,Word x2,Word distance) ...@@ -47,7 +47,7 @@ void RenderWallLoop(Word x1,Word x2,Word distance)
while (x1 < x2) { /* Time to draw? */ while (x1 < x2) { /* Time to draw? */
scaler = rw_scale >> FRACBITS; /* Get the draw scale */ scaler = rw_scale >> FRACBITS; /* Get the draw scale */
xscale[x1] = scaler; /* Save the scale factor */ xscale[x1] = scaler; /* Save the scale factor */
angle = xtoviewangle[x1]+rw_centerangle; angle = (xtoviewangle[x1]+rw_centerangle)&4095; /* TODO: same as above */
texturecolumn = SUFixedMul(finetangent[angle],distance)+rw_midpoint; /* Which texture to use? */ texturecolumn = SUFixedMul(finetangent[angle],distance)+rw_midpoint; /* Which texture to use? */
if ((Word)texturecolumn < rw_mintex) { if ((Word)texturecolumn < rw_mintex) {
texturecolumn = rw_mintex; texturecolumn = rw_mintex;
...@@ -322,7 +322,7 @@ void P_DrawSeg (saveseg_t *seg) ...@@ -322,7 +322,7 @@ void P_DrawSeg (saveseg_t *seg)
/* calc center angle for texture mapping*/ /* calc center angle for texture mapping*/
rw_centerangle = (centerangle-normalangle)&FINEMASK; rw_centerangle = (centerangle-normalangle)&FINEMASK;
if (rw_centerangle > FINEANGLES/2) { if (rw_centerangle > (FINEANGLES/2)) {
rw_centerangle -= FINEANGLES; rw_centerangle -= FINEANGLES;
} }
rw_centerangle += FINEANGLES/4; rw_centerangle += FINEANGLES/4;
......
...@@ -15,3 +15,7 @@ to it... ...@@ -15,3 +15,7 @@ to it...
* menu type stuff in svgalib version (would use the Fx keys to save game * menu type stuff in svgalib version (would use the Fx keys to save game
etc, text menus for options?) etc, text menus for options?)
* when saving/loading games, run them through htons/etc. * when saving/loading games, run them through htons/etc.
* added an 'and' hack to lines 33 and 50 in RefBsp.c Not sure if this causes
any problems (value was overflowing finetangent...)
* forget about major svgalib support?
...@@ -285,7 +285,7 @@ void UpdateFace(void) ...@@ -285,7 +285,7 @@ void UpdateFace(void)
**********************************/ **********************************/
void PrepPlayLoop (void) void PrepPlayLoop()
{ {
StartSong(SongListPtr[gamestate.mapon+2]); /* start music */ StartSong(SongListPtr[gamestate.mapon+2]); /* start music */
if (!SetupGameLevel()) { /* Load the game map */ if (!SetupGameLevel()) { /* Load the game map */
...@@ -293,6 +293,7 @@ void PrepPlayLoop (void) ...@@ -293,6 +293,7 @@ void PrepPlayLoop (void)
ReleaseScalers(); /* Release the compiled scalers */ ReleaseScalers(); /* Release the compiled scalers */
PlaySong(0); PlaySong(0);
while (!SetupGameLevel()) { /* Try loading it again */ while (!SetupGameLevel()) { /* Try loading it again */
printf("SetGameLevel returned 0...\n");
Again: Again:
ReleaseMap(); /* Oh oh... */ ReleaseMap(); /* Oh oh... */
if (!GameViewSize) { /* Smallest screen? */ if (!GameViewSize) { /* Smallest screen? */
...@@ -303,6 +304,7 @@ Again: ...@@ -303,6 +304,7 @@ Again:
} }
} }
if (!StartupRendering(GameViewSize)) { if (!StartupRendering(GameViewSize)) {
printf("StartupRendering returned 0...\n");
ReleaseScalers(); ReleaseScalers();
goto Again; goto Again;
} }
......
...@@ -23,6 +23,186 @@ unsigned long lMSB(unsigned long x) ...@@ -23,6 +23,186 @@ unsigned long lMSB(unsigned long x)
return x1 | x2 | x3 | x4; return x1 | x2 | x3 | x4;
} }
void FixMapList(maplist_t *m)
{
int i;
m->MaxMap = sMSB(m->MaxMap);
m->MapRezNum = sMSB(m->MapRezNum);
for (i = 0; i < m->MaxMap; i++) {
m->InfoArray[i].NextLevel = sMSB(m->InfoArray[i].NextLevel);
m->InfoArray[i].SecretLevel = sMSB(m->InfoArray[i].SecretLevel);
m->InfoArray[i].ParTime = sMSB(m->InfoArray[i].ParTime);
m->InfoArray[i].ScenarioNum = sMSB(m->InfoArray[i].ScenarioNum);
m->InfoArray[i].FloorNum = sMSB(m->InfoArray[i].FloorNum);
}
}
void InitData()
{
/*
InitSoundMusicSystem(8,8,5, 11025);
SoundListPtr = (Word *) LoadAResource(MySoundList);
RegisterSounds(SoundListPtr,FALSE);
ReleaseAResource(MySoundList);
*/
GetTableMemory();
MapListPtr = (maplist_t *) LoadAResource(rMapList);
FixMapList(MapListPtr);
SongListPtr = (unsigned short *) LoadAResource(rSongList);
WallListPtr = (unsigned short *) LoadAResource(MyWallList);
}
extern int VidSize;
Word ScaleX(Word x)
{
switch(VidSize) {
case 1:
return x*8/5;
case 2:
case 3:
return x*2;
}
return x;
}
Word ScaleY(Word y)
{
switch(VidSize) {
case 1:
y = (y*8/5)+64;
if (y == 217)
y++;
return y;
case 2:
return y*2;
case 3:
return y*2+80;
}
return y;
}
void ScaledDraw(Byte *gfx, Word scale, Byte *vid, LongWord TheFrac, Word TheInt, Word Width, LongWord Delta)
{
LongWord OldDelta;
while (scale--) {
*vid = *gfx;
vid += Width;
OldDelta = Delta;
Delta += TheFrac;
gfx += TheInt;
if (OldDelta > Delta)
gfx += 1;
}
}
void IO_ScaleWallColumn(Word x, Word scale, Word tile, Word column)
{
LongWord TheFrac;
Word TheInt;
LongWord y;
Byte *ArtStart;
if (scale) {
scale*=2;
TheFrac = 0x80000000UL / scale;
ArtStart = &ArtData[tile][column<<7];
if (scale<VIEWHEIGHT) {
y = (VIEWHEIGHT-scale)/2;
TheInt = TheFrac>>24;
TheFrac <<= 8;
ScaledDraw(ArtStart,scale,&VideoPointer[(y*VideoWidth)+x],
TheFrac,TheInt,VideoWidth, 0);
return;
}
y = (scale-VIEWHEIGHT)/2;
y *= TheFrac;
TheInt = TheFrac>>24;
TheFrac <<= 8;
ScaledDraw(&ArtStart[y>>24],VIEWHEIGHT,&VideoPointer[x],
TheFrac,TheInt,VideoWidth,y<<8);
}
}
typedef struct {
SWord Topy;
SWord Boty;
SWord Shape;
} PACKED SpriteRun;
void IO_ScaleMaskedColumn(Word x,Word scale, unsigned short *CharPtr,Word column)
{
Byte * CharPtr2;
int Y1,Y2;
Byte *Screenad;
SpriteRun *RunPtr;
LongWord TheFrac;
LongWord TFrac;
LongWord TInt;
Word RunCount;
int TopY;
Word Index;
LongWord Delta;
if (!scale)
return;
CharPtr2 = (Byte *) CharPtr;
TheFrac = 0x40000000/scale;
RunPtr = (SpriteRun *)&CharPtr[sMSB(CharPtr[column+1])/2];
Screenad = &VideoPointer[x];
TFrac = TheFrac<<8;
TInt = TheFrac>>24;
TopY = (VIEWHEIGHT/2)-scale;
while (RunPtr->Topy != 0xFFFF) {
Y1 = scale*(LongWord)sMSB(RunPtr->Topy)/128+TopY;
if (Y1 < VIEWHEIGHT) {
Y2 = scale*(LongWord)sMSB(RunPtr->Boty)/128+TopY;
if (Y2 > 0) {
if (Y2 > VIEWHEIGHT)
Y2 = VIEWHEIGHT;
Index = sMSB(RunPtr->Shape)+sMSB(RunPtr->Topy)/2;
Delta = 0;
if (Y1 < 0) {
Delta = (0-(LongWord)Y1)*TheFrac;
Index += (Delta>>24);
Delta <<= 8;
Y1 = 0;
}
RunCount = Y2-Y1;
if (RunCount)
ScaledDraw(&CharPtr2[Index],RunCount,
&Screenad[Y1*VideoWidth],TFrac,TInt,VideoWidth, Delta);
}
}
RunPtr++;
}
}
Boolean SetupScalers()
{
return TRUE;
}
void ReleaseScalers()
{
}
Byte *SmallFontPtr; Byte *SmallFontPtr;
void MakeSmallFont(void) void MakeSmallFont(void)
...@@ -244,19 +424,6 @@ void EndAllSound(void) ...@@ -244,19 +424,6 @@ void EndAllSound(void)
{ {
} }
void PurgeAllSounds(unsigned long minMemory)
{
}
Word ChooseGameDiff(void)
{
/* 0 = easy, 1 = normal, 2 = hard, 3 = death incarnate */
difficulty = 1;
SetAPalette(rGamePal);
return 1;
}
void FinishLoadGame(void) void FinishLoadGame(void)
{ {
} }
...@@ -10,21 +10,7 @@ Byte *gfxbuf; ...@@ -10,21 +10,7 @@ Byte *gfxbuf;
void keyboard_handler(int key, int press); void keyboard_handler(int key, int press);
void FixMapList(maplist_t *m)
{
int i;
m->MaxMap = sMSB(m->MaxMap);
m->MapRezNum = sMSB(m->MapRezNum);
for (i = 0; i < m->MaxMap; i++) {
m->InfoArray[i].NextLevel = sMSB(m->InfoArray[i].NextLevel);
m->InfoArray[i].SecretLevel = sMSB(m->InfoArray[i].SecretLevel);
m->InfoArray[i].ParTime = sMSB(m->InfoArray[i].ParTime);
m->InfoArray[i].ScenarioNum = sMSB(m->InfoArray[i].ScenarioNum);
m->InfoArray[i].FloorNum = sMSB(m->InfoArray[i].FloorNum);
}
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
...@@ -40,20 +26,7 @@ int main(int argc, char *argv[]) ...@@ -40,20 +26,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* InitData();
InitSoundMusicSystem(8,8,5, 11025);
SoundListPtr = (Word *) LoadAResource(MySoundList);
RegisterSounds(SoundListPtr,FALSE);
ReleaseAResource(MySoundList);
*/
GetTableMemory();
MapListPtr = (maplist_t *) LoadAResource(rMapList);
FixMapList(MapListPtr);
SongListPtr = (unsigned short *) LoadAResource(rSongList);
WallListPtr = (unsigned short *) LoadAResource(MyWallList);
NewGameWindow(0); /* 320x200 */ NewGameWindow(0); /* 320x200 */
//#ifndef NOVGA //#ifndef NOVGA
...@@ -71,6 +44,11 @@ void Quit(char *str) ...@@ -71,6 +44,11 @@ void Quit(char *str)
keyboard_close(); keyboard_close();
vga_setmode(TEXT); vga_setmode(TEXT);
FreeResources();
if (gfxbuf)
free(gfxbuf);
if (str && *str) { if (str && *str) {
fprintf(stderr, "%s\n", str); fprintf(stderr, "%s\n", str);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
...@@ -124,33 +102,6 @@ Word VidPics[] = {rFaceShapes,rFace512,rFace640,rFace640}; ...@@ -124,33 +102,6 @@ Word VidPics[] = {rFaceShapes,rFace512,rFace640,rFace640};
Word VidSize = -1; Word VidSize = -1;
int VidModes[] = { G320x200x256, G512x384x256, G640x400x256, G640x480x256 }; int VidModes[] = { G320x200x256, G512x384x256, G640x400x256, G640x480x256 };
Word ScaleX(Word x)
{
switch(VidSize) {
case 1:
return x*8/5;
case 2:
case 3:
return x*2;
}
return x;
}
Word ScaleY(Word y)
{
switch(VidSize) {
case 1:
y = (y*8/5)+64;
if (y == 217)
y++;
return y;
case 2:
return y*2;
case 3:
return y*2+80;
}
return y;
}
Word NewGameWindow(Word NewVidSize) Word NewGameWindow(Word NewVidSize)
{ {
...@@ -216,120 +167,6 @@ Word NewGameWindow(Word NewVidSize) ...@@ -216,120 +167,6 @@ Word NewGameWindow(Word NewVidSize)
return VidSize; return VidSize;
} }
void ScaledDraw(Byte *gfx, Word scale, Byte *vid, LongWord TheFrac, Word TheInt, Word Width, LongWord Delta)
{
LongWord OldDelta;
while (scale--) {
*vid = *gfx;
vid += Width;
OldDelta = Delta;
Delta += TheFrac;
gfx += TheInt;
if (OldDelta > Delta)
gfx += 1;
}
}
void IO_ScaleWallColumn(Word x, Word scale, Word tile, Word column)
{
LongWord TheFrac;
Word TheInt;
LongWord y;
Byte *ArtStart;
if (scale) {
scale*=2;
TheFrac = 0x80000000UL / scale;
ArtStart = &ArtData[tile][column<<7];
if (scale<VIEWHEIGHT) {
y = (VIEWHEIGHT-scale)/2;
TheInt = TheFrac>>24;
TheFrac <<= 8;
ScaledDraw(ArtStart,scale,&VideoPointer[(y*VideoWidth)+x],
TheFrac,TheInt,VideoWidth, 0);
return;
}
y = (scale-VIEWHEIGHT)/2;
y *= TheFrac;
TheInt = TheFrac>>24;
TheFrac <<= 8;
ScaledDraw(&ArtStart[y>>24],VIEWHEIGHT,&VideoPointer[x],
TheFrac,TheInt,VideoWidth,y<<8);
}
}
typedef struct {
SWord Topy;
SWord Boty;
SWord Shape;
} PACKED SpriteRun;
void IO_ScaleMaskedColumn(Word x,Word scale, unsigned short *CharPtr,Word column)
{
Byte * CharPtr2;
int Y1,Y2;
Byte *Screenad;
SpriteRun *RunPtr;
LongWord TheFrac;
LongWord TFrac;
LongWord TInt;
Word RunCount;
int TopY;
Word Index;
LongWord Delta;
if (!scale)
return;
CharPtr2 = (Byte *) CharPtr;
TheFrac = 0x40000000/scale;
RunPtr = (SpriteRun *)&CharPtr[sMSB(CharPtr[column+1])/2];
Screenad = &VideoPointer[x];
TFrac = TheFrac<<8;
TInt = TheFrac>>24;
TopY = (VIEWHEIGHT/2)-scale;
while (RunPtr->Topy != 0xFFFF) {
Y1 = scale*(LongWord)sMSB(RunPtr->Topy)/128+TopY;
if (Y1 < VIEWHEIGHT) {
Y2 = scale*(LongWord)sMSB(RunPtr->Boty)/128+TopY;
if (Y2 > 0) {
if (Y2 > VIEWHEIGHT)
Y2 = VIEWHEIGHT;
Index = sMSB(RunPtr->Shape)+sMSB(RunPtr->Topy)/2;
Delta = 0;
if (Y1 < 0) {
Delta = (0-(LongWord)Y1)*TheFrac;
Index += (Delta>>24);
Delta <<= 8;
Y1 = 0;
}
RunCount = Y2-Y1;
if (RunCount)
ScaledDraw(&CharPtr2[Index],RunCount,
&Screenad[Y1*VideoWidth],TFrac,TInt,VideoWidth, Delta);
}
}
RunPtr++;
}
}
Boolean SetupScalers()
{
}
void ReleaseScalers()
{
}
/* Keyboard Hack */ /* Keyboard Hack */
static int RSJ; static int RSJ;
...@@ -532,3 +369,13 @@ int DoEvents() ...@@ -532,3 +369,13 @@ int DoEvents()
} }
return 0; return 0;
} }
Word ChooseGameDiff(void)
{
/* 0 = easy, 1 = normal, 2 = hard, 3 = death incarnate */
difficulty = 3;
SetAPalette(rGamePal);
return 1;
}
\ No newline at end of file
This diff is collapsed.
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