Commit db1e5877 authored by Steven Fuller's avatar Steven Fuller

* Moved sound/music items to Sounds.c

* Initial software gtk+ version
* Stub for glx version
* Added GPL Header to all source files
* Cleaned up TODO
parent 82ef4cc1
/********************************** /*
Copyright (C) 1992-1994 Id Software, Inc.
Burger library for the Macintosh. This program is free software; you can redistribute it and/or
Use Think.c or Code Warrior to compile. modify it under the terms of the GNU General Public License
Use SMART linking to link in just what you need as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
**********************************/ This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" /* Get the prototypes */ #include "wolfdef.h" /* Get the prototypes */
#include <string.h> #include <string.h>
...@@ -29,70 +40,6 @@ Word SystemState=3; ...@@ -29,70 +40,6 @@ Word SystemState=3;
#define BRGR 0x42524752 #define BRGR 0x42524752
/**********************************
Sound sub-system
**********************************/
/**********************************
Shut down the sound
**********************************/
void SoundOff(void)
{
PlaySound(0);
}
/**********************************
Play a sound resource
**********************************/
void PlaySound(Word SoundNum)
{
if (SoundNum) {
SoundNum+=127;
if (SoundNum&0x8000) { /* Mono sound */
EndSound(SoundNum&0x7fff);
}
BeginSound(SoundNum&0x7fff,11127<<17L);
} else {
EndAllSound();
}
}
/**********************************
Stop playing a sound resource
**********************************/
void StopSound(Word SoundNum)
{
EndSound(SoundNum+127);
}
static Word LastSong = -1;
void PlaySong(Word Song)
{
if (Song) {
if (SystemState&MusicActive) {
if (Song!=LastSong) {
BeginSongLooped(Song);
LastSong = Song;
}
return;
}
}
EndSong();
LastSong = -1;
}
/********************************** /**********************************
Graphics subsystem Graphics subsystem
...@@ -200,143 +147,6 @@ void DrawXMShape(Word x,Word y,void *ShapePtr) ...@@ -200,143 +147,6 @@ void DrawXMShape(Word x,Word y,void *ShapePtr)
DrawMShape(x,y,&ShapePtr2[2]); DrawMShape(x,y,&ShapePtr2[2]);
} }
/**********************************
Erase a masked shape
**********************************/
void EraseMBShape(Word x,Word y, void *ShapePtr, void *BackPtr)
{
unsigned char *ScreenPtr;
unsigned char *Screenad;
unsigned char *Backad;
unsigned char *BackPtr2;
unsigned char *MaskPtr;
Word Width;
Word Height;
Word Width2;
MaskPtr = ShapePtr; /* Get the pointer to the mask */
Width = sMSB(MaskPtr[1]); /* Get the width of the shape */
Height = sMSB(MaskPtr[3]); /* Get the height of the shape */
MaskPtr = &MaskPtr[(Width*Height)+4]; /* Index to the mask */
/* Point to the screen */
ScreenPtr = (unsigned char *) &VideoPointer[YTable[y]+x];
BackPtr2 = BackPtr;
BackPtr2 = &BackPtr2[(y*SCREENWIDTH)+x]; /* Index to the erase buffer */
do {
Width2 = Width; /* Init width count */
Screenad = ScreenPtr;
Backad = BackPtr2;
do {
if (!*MaskPtr++) {
*Screenad = *Backad;
}
++Screenad;
++Backad;
} while (--Width2);
ScreenPtr +=VideoWidth;
BackPtr2 += SCREENWIDTH;
} while (--Height);
}
/**********************************
Test for a shape collision
**********************************/
Word TestMShape(Word x,Word y,void *ShapePtr)
{
unsigned char *ScreenPtr;
unsigned char *Screenad;
unsigned char *MaskPtr;
unsigned char *ShapePtr2;
Word Width;
Word Height;
Word Width2;
ShapePtr2 = ShapePtr;
Width = sMSB(ShapePtr2[0]);
Height = sMSB(ShapePtr2[1]);
ShapePtr2 +=2;
MaskPtr = &ShapePtr2[Width*Height];
ScreenPtr = (unsigned char *) &VideoPointer[YTable[y]+x];
do {
Width2 = Width;
Screenad = ScreenPtr;
do {
if (!*MaskPtr++) {
if (*Screenad != *ShapePtr2) {
return 1;
}
}
++ShapePtr2;
++Screenad;
} while (--Width2);
ScreenPtr +=VideoWidth;
} while (--Height);
return 0;
}
/**********************************
Test for a masked shape collision
**********************************/
Word TestMBShape(Word x,Word y,void *ShapePtr,void *BackPtr)
{
unsigned char *ScreenPtr;
unsigned char *Screenad;
unsigned char *Backad;
unsigned char *BackPtr2;
unsigned char *MaskPtr;
Word Width;
Word Height;
Word Width2;
MaskPtr = ShapePtr; /* Get the pointer to the mask */
Width = sMSB(MaskPtr[0]); /* Get the width of the shape */
Height = sMSB(MaskPtr[1]); /* Get the height of the shape */
MaskPtr = &MaskPtr[(Width*Height)+2]; /* Index to the mask */
/* Point to the screen */
ScreenPtr = (unsigned char *) &VideoPointer[YTable[y]+x];
BackPtr2 = BackPtr;
BackPtr2 = &BackPtr2[(y*SCREENWIDTH)+x]; /* Index to the erase buffer */
do {
Width2 = Width; /* Init width count */
Screenad = ScreenPtr;
Backad = BackPtr2;
do {
if (!*MaskPtr++) {
if (*Screenad != *Backad) {
return 1;
}
}
++Screenad;
++Backad;
} while (--Width2);
ScreenPtr +=VideoWidth;
BackPtr2 += SCREENWIDTH;
} while (--Height);
return 0;
}
/**********************************
Show a full screen picture
**********************************/
void ShowPic(Word PicNum)
{
DrawShape(0,0,LoadAResource(PicNum)); /* Load the resource and show it */
ReleaseAResource(PicNum); /* Release it */
BlastScreen();
}
/********************************** /**********************************
Clear the screen to a specific color Clear the screen to a specific color
...@@ -359,152 +169,6 @@ void ClearTheScreen(Word Color) ...@@ -359,152 +169,6 @@ void ClearTheScreen(Word Color)
} while (--y); } while (--y);
} }
/**********************************
Draw a text string
**********************************/
void DrawAString(char *TextPtr)
{
while (TextPtr[0]) { /* At the end of the string? */
DrawAChar(TextPtr[0]); /* Draw the char */
++TextPtr; /* Continue */
}
}
/**********************************
Set the X/Y to the font system
**********************************/
void SetFontXY (Word x,Word y)
{
FontX = x;
FontY = y;
}
/**********************************
Make color zero invisible
**********************************/
void FontUseMask(void)
{
FontInvisible = 0;
FontSetColor(0,0);
}
/**********************************
Make color zero a valid color
**********************************/
void FontUseZero(void)
{
FontInvisible = -1;
FontSetColor(0,BLACK);
}
/**********************************
Set the color entry for the font
**********************************/
void FontSetColor(Word Num,Word Color)
{
FontOrMask[Num] = Color;
}
/**********************************
Install a font into memory
**********************************/
typedef struct FontStruct {
unsigned short FHeight;
unsigned short FLast;
unsigned short FFirst;
unsigned char FData;
} FontStruct;
void InstallAFont(Word FontNum)
{
FontStruct *FPtr;
if (FontLoaded) {
if (FontLoaded == FontNum) {
return;
}
ReleaseAResource(FontLoaded);
}
FontLoaded = FontNum;
FPtr = LoadAResource(FontNum);
FontHeight = SwapUShort(FPtr->FHeight);
FontLast = SwapUShort(FPtr->FLast);
FontFirst = SwapUShort(FPtr->FFirst);
FontWidths = &FPtr->FData;
FontPtr = &FontWidths[FontLast];
}
/**********************************
Draw a char to the screen
**********************************/
void DrawAChar(Word Letter)
{
Word XWidth;
Word Offset;
Word Width;
Word Height;
int Width2;
unsigned char *Font;
unsigned char *ScreenPtr;
unsigned char *Screenad;
unsigned char *FontOr;
Word Temp;
Word Temp2;
Letter -= FontFirst; /* Offset from the first entry */
if (Letter>=FontLast) { /* In the font? */
return; /* Exit then! */
}
XWidth = FontWidths[Letter]; /* Get the pixel width of the entry */
Width = (XWidth-1)/2;
Font = &FontPtr[Letter*2];
Offset = (Font[1]*256) + Font[0];
Font = &FontPtr[Offset];
ScreenPtr = (unsigned char *) &VideoPointer[YTable[FontY]+FontX];
FontX+=XWidth;
Height = FontHeight;
FontOr = &FontOrMask[0];
do {
Screenad = ScreenPtr;
Width2 = Width;
do {
Temp = *Font++;
Temp2 = Temp>>4;
if (Temp2 != FontInvisible) {
Screenad[0] = FontOr[Temp2];
}
Temp &= 0x0f;
if (Temp != FontInvisible) {
Screenad[1] = FontOr[Temp];
}
Screenad+=2; /* Next address */
} while(--Width2>=0);
ScreenPtr += VideoWidth;
} while (--Height);
}
/********************************** /**********************************
Palette Manager Palette Manager
...@@ -672,11 +336,52 @@ void DLZSS(Byte *Dest,Byte *Src,LongWord Length) ...@@ -672,11 +336,52 @@ void DLZSS(Byte *Dest,Byte *Src,LongWord Length)
++Dest; ++Dest;
--Length; --Length;
} else { } else {
/* TODO - sounds have this line the other way around */
RunCount = (Word) Src[0] | ((Word) Src[1]<<8); RunCount = (Word) Src[0] | ((Word) Src[1]<<8);
Fun = 0x1000-(RunCount&0xfff); Fun = 0x1000-(RunCount&0xfff);
BackPtr = Dest-Fun; BackPtr = Dest-Fun;
RunCount = ((RunCount>>12) & 0x0f) + 3; RunCount = ((RunCount>>12) & 0x0f) + 3;
if (Length >= RunCount) {
Length -= RunCount;
} else {
RunCount = Length;
Length = 0;
}
while (RunCount--) {
*Dest++ = *BackPtr++;
}
Src+=2;
}
BitBucket>>=1;
if (BitBucket==1) {
BitBucket = (Word)Src[0] | 0x100;
++Src;
}
} while (Length);
}
void DLZSSSound(Byte *Dest,Byte *Src,LongWord Length)
{
Word BitBucket;
Word RunCount;
Word Fun;
Byte *BackPtr;
if (!Length) {
return;
}
BitBucket = (Word) Src[0] | 0x100;
++Src;
do {
if (BitBucket&1) {
Dest[0] = Src[0];
++Src;
++Dest;
--Length;
} else {
RunCount = (Word) Src[1] | ((Word) Src[0]<<8);
Fun = 0x1000-(RunCount&0xfff);
BackPtr = Dest-Fun;
RunCount = ((RunCount>>12) & 0x0f) + 3;
if (Length >= RunCount) { if (Length >= RunCount) {
Length -= RunCount; Length -= RunCount;
} else { } else {
...@@ -703,15 +408,8 @@ void DLZSS(Byte *Dest,Byte *Src,LongWord Length) ...@@ -703,15 +408,8 @@ void DLZSS(Byte *Dest,Byte *Src,LongWord Length)
**********************************/ **********************************/
/* TODO - cheap way to find MSB problems */
#include <sys/types.h>
#include <signal.h>
void *AllocSomeMem(LongWord Size) void *AllocSomeMem(LongWord Size)
{ {
if (Size > 5000000)
kill(getpid(), SIGSEGV);
return (void *)malloc(Size); return (void *)malloc(Size);
} }
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
/********************************** /**********************************
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
#include <string.h> #include <string.h>
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* enmove.c*/ /* enmove.c*/
#include "wolfdef.h" #include "wolfdef.h"
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
/********************************** /**********************************
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
#include <ctype.h> #include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
#include <string.h> #include <string.h>
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
......
...@@ -3,18 +3,19 @@ CC = gcc ...@@ -3,18 +3,19 @@ CC = gcc
#CFLAGS = -Wall -O6 -fomit-frame-pointer -ffast-math -funroll-loops -mpentiumpro -mcpu=pentiumpro -march=pentiumpro #CFLAGS = -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 -O6 -fomit-frame-pointer -ffast-math -funroll-loops -mpentiumpro -mcpu=pentiumpro -march=pentiumpro
#CFLAGS = -g -Wall #CFLAGS = -g -Wall
#CFLAGS = -g -DNOVGA #CFLAGS = -g -Wall -ansi -pedantic
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 \
Missiles.o Music.o PlMove.o PlStuff.o PlThink.o PushWall.o \ Missiles.o Sounds.o PlMove.o PlStuff.o PlThink.o PushWall.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) vi_xlib.o XOBJS = $(OBJS) vi_xlib.o
GOBJS = $(OBJS) GOBJS = $(OBJS) vi_gtk.o
GLOBJS = $(OBJS) vi_glx.o
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
...@@ -24,22 +25,26 @@ LFLAGS = -lm ...@@ -24,22 +25,26 @@ LFLAGS = -lm
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 XLFLAGS = $(LFLAGS) -L/usr/X11R6/lib -lX11
GLFLAGS = $(LFLAGS) -L/usr/X11R6/lib -lX11 -lXext -lGL GLFLAGS = $(LFLAGS) `gtk-config --libs` # -L/usr/X11R6/lib -lX11 -lXi -lXext -lgdk -lgtk
GLLFLAGS = $(LFLAGS) -L/usr/X11R6/lib -lX11 -lXext -lGL
NASM = nasm NASM = nasm
.SUFFIXES: .asm .SUFFIXES: .asm
#all: swolf3d xwolf3d gwolf3d all: swolf3d xwolf3d gwolf3d glwolf3d
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
$(GOBJS): Sounds.h Sprites.h States.h Wolf.h burger.h wolfdef.h $(GOBJS): Sounds.h Sprites.h States.h Wolf.h burger.h wolfdef.h
$(GLOBJS): Sounds.h Sprites.h States.h Wolf.h burger.h wolfdef.h
.asm.o: .asm.o:
$(NASM) -f elf -o $@ $< $(NASM) -f elf -o $@ $<
vi_gtk.o: vi_gtk.c
gcc -c vi_gtk.c $(CFLAGS) `gtk-config --cflags`
swolf3d: $(SOBJS) swolf3d: $(SOBJS)
gcc -o swolf3d $(SOBJS) $(SLFLAGS) gcc -o swolf3d $(SOBJS) $(SLFLAGS)
...@@ -49,11 +54,14 @@ xwolf3d: $(XOBJS) ...@@ -49,11 +54,14 @@ xwolf3d: $(XOBJS)
gwolf3d: $(GOBJS) gwolf3d: $(GOBJS)
gcc -o gwolf3d $(GOBJS) $(GLFLAGS) gcc -o gwolf3d $(GOBJS) $(GLFLAGS)
glwolf3d: $(GLOBJS)
gcc -o glwolf3d $(GLOBJS) $(GLLFLAGS)
clean: clean:
rm -rf swolf3d xwolf3d gwolf3d *.o rm -rf swolf3d xwolf3d gwolf3d glwolf3d *.o
distclean: clean distclean: clean
rm -rf *~ DEADJOE rm -rf core *~ DEADJOE
forced: distclean all forced: distclean all
rm -rf *.o rm -rf *.o
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
/********************************** /**********************************
......
#include "wolfdef.h"
/**********************************
Stop the current song from playing
**********************************/
void StopSong(void)
{
PlaySong(0);
}
/**********************************
Play a new song
**********************************/
void StartSong(Word songnum)
{
PlaySong(songnum); /* Stop the previous song (If any) */
}
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
/********************************** /**********************************
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
/********************************** /**********************************
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
#define SHOTRATE 6 #define SHOTRATE 6
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
#define PWALLSPEED 4 /* Micropixels per 60th of a second */ #define PWALLSPEED 4 /* Micropixels per 60th of a second */
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
static Word checkcoord[11][4] = { /* Indexs to the bspcoord table */ static Word checkcoord[11][4] = { /* Indexs to the bspcoord table */
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
#include <string.h> #include <string.h>
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
#include <stdlib.h> #include <stdlib.h>
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
/********************************** /**********************************
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h"
/**********************************
Stop the current song from playing
**********************************/
void StopSong(void)
{
PlaySong(0);
}
/**********************************
Play a new song
**********************************/
void StartSong(Word songnum)
{
PlaySong(songnum); /* Stop the previous song (If any) */
}
void FreeSong()
{
}
void BeginSongLooped(Song)
{
}
void EndSong()
{
}
void BeginSound(short int theID, long theRate)
{
}
void EndSound(short int theID)
{
}
void EndAllSound(void)
{
}
/**********************************
Sound sub-system
**********************************/
/**********************************
Shut down the sound
**********************************/
void SoundOff(void)
{
PlaySound(0);
}
/**********************************
Play a sound resource
**********************************/
void PlaySound(Word SoundNum)
{
if (SoundNum) {
SoundNum+=127;
if (SoundNum&0x8000) { /* Mono sound */
EndSound(SoundNum&0x7fff);
}
BeginSound(SoundNum&0x7fff,11127<<17L);
} else {
EndAllSound();
}
}
/**********************************
Stop playing a sound resource
**********************************/
void StopSound(Word SoundNum)
{
EndSound(SoundNum+127);
}
static Word LastSong = -1;
void PlaySong(Word Song)
{
if (Song) {
if (SystemState&MusicActive) {
if (Song!=LastSong) {
BeginSongLooped(Song);
LastSong = Song;
}
return;
}
}
EndSong();
LastSong = -1;
}
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* generated by sndlink.exe */ /* generated by sndlink.exe */
enum { enum {
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* generated by sprgrab */ /* generated by sprgrab */
enum { enum {
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
state_t states[NUMSTATES] = { state_t states[NUMSTATES] = {
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* generated by statescr*/ /* generated by statescr*/
typedef enum { typedef enum {
......
* remove NOVGA when other ports are added. NOVGA is a hack for using TODO:
ElectricFence (since svgalib doesn't work too well with it) * Correct copyrights
- vi_ are mostly mine, with portions based on the original code
- move stuff out of stub.c to more proper places
* Pause key
* SVGAlib Hack:
- Require 320x200x256
- If user requests a gamemode which SVGAlib says it does not support, fail
- If SVGAlib does not support 512x384x256, allow the user to pan around
with the keypad arrow keys.
BUGS:
* drawing seems like its imprecise, stationary sprites move back and forth, * drawing seems like its imprecise, stationary sprites move back and forth,
and walls 'swim' when you move around, or sprites pop into different sizes and walls 'swim' when you move around, or sprites pop into different sizes
when are far enough and get closer/farther away when are far enough and get closer/farther away
* Word is 16bit damnit, wonder why in the MAC version its 32bits?!
* How about adding red/white shifts (from PC wolf3d)?
* it crashes somewhere, no reason why... * it crashes somewhere, no reason why...
#0 0x804fa55 in DrawXMShape (x=128, y=96, ShapePtr=0x8c8c8c8c) at #0 0x804fa55 in DrawXMShape (x=128, y=96, ShapePtr=0x8c8c8c8c) at
Burger.c:198 Burger.c:198
But what is trashing GameShapes's memory? But what is trashing GameShapes's memory?
I don't think GameShapes itself is being ran over, just the memory allocated I don't think GameShapes itself is being ran over, just the memory allocated
to it... to it...
* Pause key
* menu type stuff in svgalib version (would use the Fx keys to save game
etc, text menus for options?)
* 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 * added an 'and' hack to lines 33 and 50 in RefBsp.c Not sure if this causes
any problems (value was overflowing finetangent...) any problems (value was overflowing finetangent...)
* forget about major svgalib support? MISC:
IDEAS:
* Menu Keys
- ESC: Quit
- F1: Help
- XXX: Load Game
- XXX: Load Previously Loaded Game
- XXX: Save Game
- XXX: Save Game to Previously used File
- XXX: Options
* How about adding red/white shifts (from PC wolf3d)? So screen changes
color when you are hit or pick up items.
* when saving/loading games, run them through htons/etc.
#define MyMenuBar 128 /* application's menu bar */ /*
Copyright (C) 1992-1994 Id Software, Inc.
#define rAboutAlert 128 /* about alert */ This program is free software; you can redistribute it and/or
#define rUserAlert 129 /* error user alert */ modify it under the terms of the GNU General Public License
#define AskSizeWin 130 /* Ask for screen size window */ as published by the Free Software Foundation; either version 2
#define NewGameWin 131 /* Choose difficulty */ of the License, or (at your option) any later version.
#define Not607Win 132 /* Not system 6.0.7 or later */
#define NotColorWin 133 /* No color */
#define Not32QDWin 134 /* Not Quickdraw 32 */
#define SlowWarnWin 135 /* Your machine is slow */
#define SpeedTipsWin 136 /* Hints on speed */
#define ShareWareWin 137 /* Pay us $$$ */
#define GoSlowWin 138 /* You are not in 8 bit color mode */
#define EndGameWin 139 /* You won the shareware version */
#define LowMemWin 140 /* You are dangerously low on memory */
/* kSysEnvironsVersion is passed to SysEnvirons to tell it which version of the This program is distributed in the hope that it will be useful,
SysEnvRec we understand. */ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#define kSysEnvironsVersion 1 See the GNU General Public License for more details.
/* kOSEvent is the event number of the suspend/resume and mouse-moved events sent You should have received a copy of the GNU General Public License
by MultiFinder. Once we determine that an event is an osEvent, we look at the along with this program; if not, write to the Free Software
high byte of the message sent to determine which kind it is. To differentiate Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
suspend and resume events we check the resumeMask bit. */ */
#define kOSEvent app4Evt /* event used by MultiFinder */
#define kSuspendResumeMessage 1 /* high byte of suspend/resume event message */
#define kResumeMask 1 /* bit of message field for resume vs. suspend */
#define kMouseMovedMessage 0xFA /* high byte of mouse-moved event message */
#define kNoEvents 0 /* no events mask */
/* The following constants are used to identify menus and their items. The menu IDs
have an "m" prefix and the item numbers within each menu have an "i" prefix. */
#define mApple 128 /* Apple menu */
#define iAbout 1
#define iSpeedHint 2
#define iShareWare 3
#define mFile 129 /* File menu */
#define iNew 1
#define iOpen 2
#define iClose 4
#define iSave 5
#define iSaveAs 6
#define iQuit 8
#define mEdit 130 /* Edit menu */
#define iUndo 1
#define iCut 3
#define iCopy 4
#define iPaste 5
#define iClear 6
#define mOptions 131 /* Game menu */
#define iSound 1
#define iMusic 2
#define iScreenSize 3
#define iGovenor 4
#define iMouseControl 5
#define iUseQuickDraw 6
/* 1.01 - kTopLeft - This is for positioning the Disk Initialization dialogs. */
#define kDITop 0x0050
#define kDILeft 0x0070
/* kExtremeNeg and kExtremePos are used to set up wide open rectangles and regions. */
#define kExtremeNeg -32768
#define kExtremePos 32767 - 1 /* required to address an old region bug */
/* these #defines are used to set enable/disable flags of a menu */
#define AllItems 0b1111111111111111111111111111111 /* 31 flags */
#define NoItems 0b0000000000000000000000000000000
#define MenuItem1 0b0000000000000000000000000000001
#define MenuItem2 0b0000000000000000000000000000010
#define MenuItem3 0b0000000000000000000000000000100
#define MenuItem4 0b0000000000000000000000000001000
#define MenuItem5 0b0000000000000000000000000010000
#define MenuItem6 0b0000000000000000000000000100000
#define MenuItem7 0b0000000000000000000000001000000
#define MenuItem8 0b0000000000000000000000010000000
#define MenuItem9 0b0000000000000000000000100000000
#define MenuItem10 0b0000000000000000000001000000000
#define MenuItem11 0b0000000000000000000010000000000
#define MenuItem12 0b0000000000000000000100000000000
/* Burger resources */ /* Burger resources */
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
#include <string.h> #include <string.h>
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h" #include "wolfdef.h"
#include <string.h> #include <string.h>
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __BURGER_H__
#define __BURGER_H__
typedef unsigned int Word; typedef unsigned int Word;
typedef unsigned long LongWord; typedef unsigned long LongWord;
typedef unsigned char Byte; typedef unsigned char Byte;
...@@ -24,23 +46,14 @@ typedef unsigned short int SWord; ...@@ -24,23 +46,14 @@ typedef unsigned short int SWord;
#define SfxActive 1 #define SfxActive 1
#define MusicActive 2 #define MusicActive 2
#define VideoSize 64000
#define SetAuxType(x,y)
#define SetFileType(x,y)
extern unsigned char *VideoPointer; extern unsigned char *VideoPointer;
extern Word KeyModifiers;
extern Word ScanCode;
extern Word KilledSong;
extern Word SystemState; extern Word SystemState;
extern Word VideoWidth; extern Word VideoWidth;
extern LongWord LastTick; extern LongWord LastTick;
extern LongWord YTable[480]; extern LongWord YTable[480];
void DLZSS(Byte *Dest, Byte *Src,LongWord Length); void DLZSS(Byte *Dest, Byte *Src,LongWord Length);
LongWord SwapLong(LongWord Val);
unsigned short SwapUShort(unsigned short Val); unsigned short SwapUShort(unsigned short Val);
short SwapShort(short Val);
void WaitTick(void); void WaitTick(void);
void WaitTicks(Word TickCount); void WaitTicks(Word TickCount);
...@@ -50,8 +63,6 @@ LongWord ReadTick(void); ...@@ -50,8 +63,6 @@ LongWord ReadTick(void);
void *AllocSomeMem(LongWord Size); void *AllocSomeMem(LongWord Size);
void FreeSomeMem(void *MemPtr); void FreeSomeMem(void *MemPtr);
Word GetAKey(void);
Word AllKeysUp(void);
Word WaitKey(void); Word WaitKey(void);
void FlushKeys(void); void FlushKeys(void);
...@@ -61,25 +72,11 @@ void StopSound(Word SndNum); ...@@ -61,25 +72,11 @@ void StopSound(Word SndNum);
void PlaySong(Word SongNum); void PlaySong(Word SongNum);
void ClearTheScreen(Word Color); void ClearTheScreen(Word Color);
void ShowPic(Word PicNum);
void InitYTable(void); void InitYTable(void);
void InstallAFont(Word FontNum);
void FontUseMask(void);
void FontUseZero(void);
void SetFontXY(Word x,Word y);
void FontSetColor(Word Index,Word Color);
void DrawAString(char *TextPtr);
void DrawAChar(Word Letter);
void ultoa(LongWord Val,char *TextPtr);
Word GetRandom(Word Range);
void Randomize(void);
void DrawShape(Word x,Word y,void *ShapePtr); void DrawShape(Word x,Word y,void *ShapePtr);
void DrawXMShape(Word x,Word y,void *ShapePtr); void DrawXMShape(Word x,Word y,void *ShapePtr);
void DrawMShape(Word x,Word y,void *ShapePtr); void DrawMShape(Word x,Word y,void *ShapePtr);
void EraseMBShape(Word x,Word y, void *ShapePtr,void *BackPtr);
Word TestMShape(Word x,Word y,void *ShapePtr);
Word TestMBShape(Word x,Word y,void *ShapePtr,void *BackPtr);
void SetAPalette(Word PalNum); void SetAPalette(Word PalNum);
void SetAPalettePtr(unsigned char *PalPtr); void SetAPalettePtr(unsigned char *PalPtr);
...@@ -93,3 +90,5 @@ void KillAResource(Word RezNum); ...@@ -93,3 +90,5 @@ void KillAResource(Word RezNum);
void *LoadAResource2(Word RezNum,LongWord Type); void *LoadAResource2(Word RezNum,LongWord Type);
void ReleaseAResource2(Word RezNum,LongWord Type); void ReleaseAResource2(Word RezNum,LongWord Type);
void KillAResource2(Word RezNum,LongWord Type); void KillAResource2(Word RezNum,LongWord Type);
#endif
/*
Copyright (C) 2000 Steven Fuller <relnev@atdot.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -123,7 +142,6 @@ void *LoadAResource2(Word RezNum, LongWord Type) ...@@ -123,7 +142,6 @@ void *LoadAResource2(Word RezNum, LongWord Type)
} }
fprintf(stderr, "ERROR (LoadAResource2): %ld/%d was not found!\n", Type, RezNum); fprintf(stderr, "ERROR (LoadAResource2): %ld/%d was not found!\n", Type, RezNum);
AllocSomeMem(666666666); /* TODO: hack! */
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -141,7 +159,6 @@ void ReleaseAResource2(Word RezNum, LongWord Type) ...@@ -141,7 +159,6 @@ void ReleaseAResource2(Word RezNum, LongWord Type)
c = c->next; c = c->next;
} }
fprintf(stderr, "ERROR (ReleaseAResource2): %ld/%d was not found!\n", Type, RezNum); fprintf(stderr, "ERROR (ReleaseAResource2): %ld/%d was not found!\n", Type, RezNum);
AllocSomeMem(666666666); /* TODO: hack! */
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h> #include <unistd.h>
...@@ -400,30 +419,6 @@ Word WaitTicksEvent(Word Time) ...@@ -400,30 +419,6 @@ Word WaitTicksEvent(Word Time)
return RetVal; return RetVal;
} }
void FreeSong()
{
}
void BeginSongLooped(Song)
{
}
void EndSong()
{
}
void BeginSound(short int theID, long theRate)
{
}
void EndSound(short int theID)
{
}
void EndAllSound(void)
{
}
void FinishLoadGame(void) void FinishLoadGame(void)
{ {
} }
/*
Copyright (C) 1992-1994 Id Software, Inc.
Copyright (C) 2000 Steven Fuller <relnev@atdot.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
This is NOT the OpenGL version!
This is a COPY of vi_xlib.c as a placeholder!
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include "wolfdef.h"
Display *dpy;
int screen;
Window win, root;
XVisualInfo *vi;
GC gc;
XImage *img;
Colormap cmap;
Atom wmDeleteWindow;
XColor clr[256];
Byte *gfxbuf;
int main(int argc, char *argv[])
{
XSetWindowAttributes attr;
XVisualInfo vitemp;
XGCValues gcvalues;
Pixmap bitmap;
Cursor cursor;
XColor bg = { 0 };
XColor fg = { 0 };
char data[8] = { 0x01 };
char *display;
int mask, i;
if (argc != 2) {
fprintf(stderr, "usage: %s <mac wolf3d resource fork>\n", argv[0]);
exit(EXIT_FAILURE);
}
if (InitResources(argv[1])) {
fprintf(stderr, "could not load %s\n", argv[1]);
exit(EXIT_FAILURE);
}
display = getenv("DISPLAY");
dpy = XOpenDisplay(getenv(display));
if (dpy == NULL) {
fprintf(stderr, "Unable to open display %s\n", XDisplayName(display));
exit(EXIT_FAILURE);
}
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
vitemp.screen = screen;
vitemp.depth = 8;
vitemp.class = PseudoColor;
mask = VisualScreenMask | VisualDepthMask | VisualClassMask;
vi = XGetVisualInfo(dpy, mask, &vitemp, &i);
if ( !(vi && i) ) {
fprintf(stderr, "Unable to get a depth 8 PseudoColor visual on screen %d\n", screen);
exit(EXIT_FAILURE);
}
cmap = XCreateColormap(dpy, root, vi->visual, AllocAll);
for (i = 0; i < 256; i++) {
clr[i].pixel = i;
clr[i].flags = DoRed | DoGreen | DoBlue;
}
attr.colormap = cmap;
attr.event_mask = KeyPressMask | KeyReleaseMask | ExposureMask;
mask = CWColormap | CWEventMask;
win = XCreateWindow(dpy, root, 0, 0, 320, 200, 0, CopyFromParent,
InputOutput, vi->visual, mask, &attr);
if (win == None) {
fprintf(stderr, "Unable to create window\n");
exit(EXIT_FAILURE);
}
gcvalues.foreground = BlackPixel(dpy, screen);
gcvalues.background = WhitePixel(dpy, screen);
mask = GCForeground | GCBackground;
gc = XCreateGC(dpy, win, mask, &gcvalues);
XSetWMProperties(dpy, win, NULL, NULL, argv, argc, None, None, None);
XStoreName(dpy, win, "Wolfenstein 3D");
XSetIconName(dpy, win, "Wolfenstein 3D");
wmDeleteWindow = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
XSetWMProtocols(dpy, win, &wmDeleteWindow, 1);
bitmap = XCreateBitmapFromData(dpy, win, data, 8, 8);
cursor = XCreatePixmapCursor(dpy, bitmap, bitmap, &fg, &bg, 0, 0);
XDefineCursor(dpy, win, cursor);
XMapWindow(dpy, win);
XFlush(dpy);
InitData();
GameViewSize = 2;
NewGameWindow(GameViewSize);
ClearTheScreen(BLACK);
BlastScreen();
return WolfMain(argc, argv);
}
void Quit(char *str)
{
FreeResources();
if (img)
XDestroyImage(img);
if (str && *str) {
fprintf(stderr, "%s\n", str);
exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
}
void SetPalette(Byte *pal)
{
int i;
for (i = 0; i < 256; i++) {
clr[i].red = pal[i*3+0] << 8;
clr[i].green = pal[i*3+1] << 8;
clr[i].blue = pal[i*3+2] << 8;
}
XStoreColors(dpy, cmap, clr, 256);
}
void BlastScreen2(Rect *BlastRect)
{
BlastScreen();
}
int VidWidth, VidHeight, ViewHeight;
#define w VidWidth
#define h VidHeight
#define v ViewHeight
void BlastScreen()
{
XPutImage(dpy, win, gc, img, 0, 0, 0, 0, w, h);
}
Word VidXs[] = {320,512,640,640}; /* Screen sizes to play with */
Word VidYs[] = {200,384,400,480};
Word VidVs[] = {160,320,320,400};
Word VidPics[] = {rFaceShapes,rFace512,rFace640,rFace640};
Word VidSize = -1;
Word NewGameWindow(Word NewVidSize)
{
XSizeHints sizehints;
LongWord *LongPtr;
Byte *DestPtr;
int i;
printf("Called: %d\n", NewVidSize);
if (NewVidSize == VidSize)
return VidSize;
printf("Setting Size: %d (from %d)\n", NewVidSize, VidSize);
if (NewVidSize < 4) {
w = VidXs[NewVidSize];
h = VidYs[NewVidSize];
v = VidVs[NewVidSize];
} else {
fprintf(stderr, "Invalid Vid size: %d\n", NewVidSize);
exit(EXIT_FAILURE);
}
if (img) {
XDestroyImage(img);
/* free(gfxbuf); */
}
sizehints.min_width = sizehints.max_width = sizehints.base_width = w;
sizehints.min_height = sizehints.max_height = sizehints.base_height = h;
sizehints.flags = PMinSize | PMaxSize | PBaseSize;
XSetWMNormalHints(dpy, win, &sizehints);
XResizeWindow(dpy, win, w, h);
gfxbuf = (Byte *)malloc(w * h);
img = XCreateImage(dpy, vi->visual, vi->depth, ZPixmap, 0,
(char *)gfxbuf, w, h, 8, w);
if (img == NULL) {
fprintf(stderr, "XCreateImage returned NULL, Unable to create an XImage\n");
exit(EXIT_FAILURE);
}
VideoPointer = gfxbuf;
VideoWidth = w;
InitYTable();
SetAPalette(rBlackPal);
ClearTheScreen(BLACK);
BlastScreen();
LongPtr = (LongWord *) LoadAResource(VidPics[NewVidSize]);
if (GameShapes)
FreeSomeMem(GameShapes);
GameShapes = (Byte **)AllocSomeMem(lMSB(LongPtr[0]));
DLZSS((Byte *)GameShapes, (Byte *)&LongPtr[1], lMSB(LongPtr[0]));
ReleaseAResource(VidPics[NewVidSize]);
LongPtr = (LongWord *)GameShapes;
DestPtr = (Byte *)GameShapes;
for (i = 0; i < ((NewVidSize == 1) ? 57 : 47); i++)
GameShapes[i] = DestPtr + lMSB(LongPtr[i]);
VidSize = NewVidSize;
return VidSize;
}
/* Keyboard Hack */
static int RSJ;
static int keys[128];
void FlushKeys()
{
joystick1 = 0;
memset(keys, 0, sizeof(keys));
}
struct {
char code[13];
} CheatCodes[] = {
{ "XUSCNIELPPA" }, /* "XUSCNIELPPA" */
{ "IDDQD" }, /* "IDDQD" */
{ "BURGER" }, /* "BURGER" */
{ "WOWZERS" }, /* "WOWZERS" */
{ "LEDOUX" }, /* "LEDOUX" */
{ "SEGER" }, /* "SEGER" */
{ "MCCALL" }, /* "MCCALL" */
{ "APPLEIIGS" } /* "APPLEIIGS" */
};
const int CheatCount = sizeof(CheatCodes) / sizeof(CheatCodes[0]);
int CheatIndex;
#define SC_CURSORUPLEFT 1
#define SC_CURSORUP 2
#define SC_CURSORUPRIGHT 3
#define SC_CURSORRIGHT 4
#define SC_CURSORDOWNRIGHT 5
#define SC_CURSORDOWN 6
#define SC_CURSORDOWNLEFT 7
#define SC_CURSORLEFT 8
#define SC_CURSORBLOCKLEFT 9
#define SC_CURSORBLOCKRIGHT 10
#define SC_CURSORBLOCKUP 11
#define SC_CURSORBLOCKDOWN 12
#define SC_KEYPADENTER 13
#define SC_ENTER 14
#define SC_SPACE 15
#define SC_LEFTALT 16
#define SC_RIGHTALT 17
#define SC_LEFTCONTROL 18
#define SC_RIGHTCONTROL 19
#define SC_LEFTSHIFT 20
#define SC_RIGHTSHIFT 21
#define SC_B 22
void UpdateKeys(KeySym key, int press)
{
switch(key) {
case XK_KP_Home:
keys[SC_CURSORUPLEFT] = press;
break;
case XK_KP_Up:
keys[SC_CURSORUP] = press;
break;
case XK_KP_Page_Up:
keys[SC_CURSORUPRIGHT] = press;
break;
case XK_KP_Right:
keys[SC_CURSORRIGHT] = press;
break;
case XK_KP_Page_Down:
keys[SC_CURSORDOWNRIGHT] = press;
break;
case XK_KP_Down:
keys[SC_CURSORDOWN] = press;
break;
case XK_KP_End:
keys[SC_CURSORDOWNLEFT] = press;
break;
case XK_KP_Left:
keys[SC_CURSORLEFT] = press;
break;
case XK_Up:
keys[SC_CURSORBLOCKUP] = press;
break;
case XK_Down:
keys[SC_CURSORBLOCKDOWN] = press;
break;
case XK_Left:
keys[SC_CURSORBLOCKLEFT] = press;
break;
case XK_Right:
keys[SC_CURSORBLOCKRIGHT] = press;
break;
case XK_KP_Enter:
keys[SC_KEYPADENTER] = press;
break;
case XK_Return:
keys[SC_ENTER] = press;
break;
case XK_space:
keys[SC_SPACE] = press;
break;
case XK_Alt_L:
keys[SC_LEFTALT] = press;
break;
case XK_Alt_R:
keys[SC_RIGHTALT] = press;
break;
case XK_Control_L:
keys[SC_LEFTCONTROL] = press;
break;
case XK_Control_R:
keys[SC_RIGHTCONTROL] = press;
break;
case XK_Shift_L:
keys[SC_LEFTSHIFT] = press;
break;
case XK_Shift_R:
keys[SC_RIGHTSHIFT] = press;
break;
case XK_b:
keys[SC_B] = press;
break;
}
}
void keyboard_handler(KeySym keycode, int press)
{
int i;
UpdateKeys(keycode, press);
if (RSJ) {
if (press == 0) {
for (i = 0; i < CheatCount; i++) {
char *key = XKeysymToString(keycode);
if (key == NULL)
break;
if (strlen(key) != 1)
break;
if (CheatCodes[i].code[CheatIndex] == toupper(key[0])) {
CheatIndex++;
if (CheatCodes[i].code[CheatIndex] == 0) {
PlaySound(SND_BONUS);
switch (i) {
case 0:
case 4:
GiveKey(0);
GiveKey(1);
gamestate.godmode = TRUE;
break;
case 1:
gamestate.godmode^=TRUE;
break;
case 2:
gamestate.machinegun = TRUE;
gamestate.chaingun = TRUE;
gamestate.flamethrower = TRUE;
gamestate.missile = TRUE;
GiveAmmo(gamestate.maxammo);
GiveGas(99);
GiveMissile(99);
break;
case 3:
gamestate.maxammo = 999;
GiveAmmo(999);
break;
case 5:
GiveKey(0);
GiveKey(1);
break;
case 6:
playstate=EX_WARPED;
nextmap = gamestate.mapon+1;
if (MapListPtr->MaxMap<=nextmap)
nextmap = 0;
break;
case 7:
ShowPush ^= TRUE;
break;
}
CheatIndex = 0;
}
break;
}
}
if (i == CheatCount)
CheatIndex = 0;
}
joystick1 = 0;
if (press == 0) {
switch(keycode) {
case XK_1:
gamestate.pendingweapon = WP_KNIFE;
break;
case XK_2:
if (gamestate.ammo) {
gamestate.pendingweapon = WP_PISTOL;
}
break;
case XK_3:
if (gamestate.ammo && gamestate.machinegun) {
gamestate.pendingweapon = WP_MACHINEGUN;
}
break;
case XK_4:
if (gamestate.ammo && gamestate.chaingun) {
gamestate.pendingweapon = WP_CHAINGUN;
}
break;
case XK_5:
if (gamestate.gas && gamestate.flamethrower) {
gamestate.pendingweapon = WP_FLAMETHROWER;
}
break;
case XK_6:
if (gamestate.missiles && gamestate.missile) {
gamestate.pendingweapon = WP_MISSILE;
}
break;
case XK_period:
case XK_slash:
joystick1 = JOYPAD_START;
break;
case XK_Escape:
Quit(NULL); /* fast way out */
}
}
if (keys[SC_CURSORUPLEFT])
joystick1 |= (JOYPAD_UP|JOYPAD_LFT);
if (keys[SC_CURSORUP])
joystick1 |= JOYPAD_UP;
if (keys[SC_CURSORUPRIGHT])
joystick1 |= (JOYPAD_UP|JOYPAD_RGT);
if (keys[SC_CURSORRIGHT])
joystick1 |= JOYPAD_RGT;
if (keys[SC_CURSORDOWNRIGHT])
joystick1 |= (JOYPAD_DN|JOYPAD_RGT);
if (keys[SC_CURSORDOWN])
joystick1 |= JOYPAD_DN;
if (keys[SC_CURSORDOWNLEFT])
joystick1 |= (JOYPAD_DN|JOYPAD_LFT);
if (keys[SC_CURSORLEFT])
joystick1 |= JOYPAD_LFT;
if (keys[SC_CURSORBLOCKLEFT])
joystick1 |= JOYPAD_LFT;
if (keys[SC_CURSORBLOCKRIGHT])
joystick1 |= JOYPAD_RGT;
if (keys[SC_CURSORBLOCKUP])
joystick1 |= JOYPAD_UP;
if (keys[SC_CURSORBLOCKDOWN])
joystick1 |= JOYPAD_DN;
if (keys[SC_KEYPADENTER])
joystick1 |= JOYPAD_A;
if (keys[SC_ENTER])
joystick1 |= JOYPAD_A;
if (keys[SC_SPACE])
joystick1 |= JOYPAD_A;
if (keys[SC_LEFTALT])
joystick1 |= JOYPAD_TL;
if (keys[SC_RIGHTALT])
joystick1 |= JOYPAD_TR;
if (keys[SC_LEFTCONTROL])
joystick1 |= JOYPAD_B;
if (keys[SC_RIGHTCONTROL])
joystick1 |= JOYPAD_B;
if (keys[SC_LEFTSHIFT])
joystick1 |= (JOYPAD_X|JOYPAD_Y);
if (keys[SC_RIGHTSHIFT])
joystick1 |= (JOYPAD_X|JOYPAD_Y);
}
}
int HandleEvents()
{
XEvent event;
int ret = 0;
if (XPending(dpy)) {
do {
XNextEvent(dpy, &event);
switch(event.type) {
case KeyPress:
keyboard_handler(XKeycodeToKeysym(dpy, event.xkey.keycode, 0), 1);
/* ret = 1; */
break;
case KeyRelease:
keyboard_handler(XKeycodeToKeysym(dpy, event.xkey.keycode, 0), 0);
ret = 1;
break;
case Expose:
BlastScreen();
break;
case ClientMessage:
if (event.xclient.data.l[0] == wmDeleteWindow)
Quit(NULL);
break;
default:
break;
}
} while (XPending(dpy));
}
return ret;
}
void ReadSystemJoystick()
{
RSJ = 1;
HandleEvents();
}
int DoEvents()
{
RSJ = 0;
if (HandleEvents()) {
if (keys[SC_B]) { /* Special */
return 'B';
}
return 1;
}
return 0;
}
Word ChooseGameDiff()
{
/* 0 = easy, 1 = normal, 2 = hard, 3 = death incarnate */
difficulty = 1;
SetAPalette(rGamePal);
return 1;
}
/*
Copyright (C) 1992-1994 Id Software, Inc.
Copyright (C) 2000 Steven Fuller <relnev@atdot.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "wolfdef.h"
Byte *gfxbuf;
GtkWidget *win;
GtkWidget *main_vbox;
GtkWidget *menubar;
GtkItemFactory *item_factory;
GtkAccelGroup *accel_group;
GtkWidget *event_box;
GdkVisual *visual;
GdkImage *image;
GtkImage *image_area;
GdkColormap *cmap;
GdkColormap *cmapo;
GdkColor colors[256];
GdkColor coloro[256];
int image_focus = 1;
void Quit();
gint delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
{
g_print("delete_event\n");
return FALSE;
}
void destroy(GtkWidget *widget, gpointer data)
{
Quit(NULL);
}
static void menu_quit(GtkWidget *w, gpointer data)
{
destroy(w, data);
}
void RestoreColors()
{
int i;
for (i = 0; i < cmapo->size; i++)
gdk_color_change(cmap, &cmapo->colors[i]);
}
void UpdateColors()
{
int i;
for (i = 0; i < cmap->size; i++)
gdk_color_change(cmap, &colors[i]);
}
static void image_focus_in(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
UpdateColors();
image_focus = 1;
}
static void image_focus_out(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
RestoreColors();
image_focus = 0;
}
extern int KeyPressed;
void keyboard_handler(int key, int press);
static void key_press(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
/* g_print("press\n"); */
keyboard_handler(event->keyval, 1);
}
static void key_release(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
/* g_print("release\n"); */
keyboard_handler(event->keyval, 0);
KeyPressed = 1;
}
static void draw(GtkWidget *widget, GdkRectangle *area, gpointer user_data)
{
/* g_print("draw\n"); */
}
static void draw_default(GtkWidget *widget, gpointer user_data)
{
/* g_print("draw default\n"); */
}
static GtkItemFactoryEntry menu_items[] = {
{ "/_File", NULL, NULL, 0, "<Branch>" },
{ "/File/Quit", "<control>Q", menu_quit, 0, NULL },
};
int main(int argc, char *argv[])
{
gboolean s[256];
int i;
if (argc != 2) {
fprintf(stderr, "usage: %s <mac wolf3d resource fork>\n", argv[0]);
exit(EXIT_FAILURE);
}
if (InitResources(argv[1])) {
fprintf(stderr, "could not load %s\n", argv[1]);
exit(EXIT_FAILURE);
}
gtk_init(&argc, &argv);
visual = gdk_visual_get_best_with_depth(8);
if (visual == NULL) {
fprintf(stderr, "Unable to get a 8 bpp visual\n");
exit(EXIT_FAILURE);
}
gtk_widget_set_default_visual(visual);
cmapo = gdk_colormap_get_system();
cmap = gdk_colormap_new(visual, TRUE);
for (i = 0; i < 256; i++)
colors[i].pixel = i;
/* printf("%d\n", gdk_colormap_alloc_colors(cmap, colors, 256, TRUE, TRUE, s)); */
gtk_widget_set_default_colormap(cmap);
RestoreColors();
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(win), "Wolfenstein 3D");
gtk_signal_connect(GTK_OBJECT(win), "delete_event", GTK_SIGNAL_FUNC(delete_event), NULL);
gtk_signal_connect(GTK_OBJECT(win), "destroy", GTK_SIGNAL_FUNC(destroy), NULL);
gtk_signal_connect(GTK_OBJECT(win), "key_press_event", GTK_SIGNAL_FUNC(key_press), NULL);
gtk_signal_connect(GTK_OBJECT(win), "key_release_event", GTK_SIGNAL_FUNC(key_release), NULL);
gtk_widget_set_events(GTK_WIDGET(win), GDK_EXPOSURE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);
main_vbox = gtk_vbox_new(FALSE, 1);
gtk_container_border_width(GTK_CONTAINER(main_vbox), 1);
gtk_container_add(GTK_CONTAINER(win), main_vbox);
gtk_widget_show(main_vbox);
accel_group = gtk_accel_group_new();
item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group);
gtk_item_factory_create_items(item_factory, sizeof(menu_items) / sizeof(menu_items[0]), menu_items, NULL);
gtk_accel_group_attach(accel_group, GTK_OBJECT(win));
menubar = gtk_item_factory_get_widget(item_factory, "<main>");
gtk_box_pack_start(GTK_BOX(main_vbox), menubar, FALSE, TRUE, 0);
gtk_widget_show(menubar);
image = gdk_image_new(GDK_IMAGE_FASTEST, visual, 320, 200);
image_area = (GtkImage *)gtk_image_new(image, NULL);
gtk_signal_connect(GTK_OBJECT(image_area), "draw", GTK_SIGNAL_FUNC(draw), NULL);
gtk_signal_connect(GTK_OBJECT(image_area), "draw_default", GTK_SIGNAL_FUNC(draw_default), NULL);
event_box = gtk_event_box_new();
gtk_container_add(GTK_CONTAINER(main_vbox), event_box);
gtk_widget_show(event_box);
gtk_container_add(GTK_CONTAINER(event_box), GTK_WIDGET(image_area));
gtk_widget_show(GTK_WIDGET(image_area));
gtk_widget_set_events(GTK_WIDGET(event_box), GDK_BUTTON_PRESS_MASK);
gtk_signal_connect(GTK_OBJECT(event_box), "button_press_event", GTK_SIGNAL_FUNC(image_focus_in), NULL);
gtk_signal_connect(GTK_OBJECT(menubar), "button_press_event", GTK_SIGNAL_FUNC(image_focus_out), NULL);
/* gtk_widget_set_usize(GTK_WIDGET(image_area), 320, 200); */
/* gtk_box_pack_start(GTK_BOX(main_vbox), event_box, FALSE, TRUE, 0); */
/* gtk_widget_show(event_box); */
gtk_widget_realize(event_box);
/* gtk_box_pack_start(GTK_BOX(main_vbox), GTK_WIDGET(image_area), FALSE, TRUE, 0);
*/
/* gtk_widget_show(GTK_WIDGET(image_area)); */
/* UpdateColors(); */
gtk_widget_show(win);
InitData();
GameViewSize = 0;
NewGameWindow(GameViewSize);
ClearTheScreen(BLACK);
BlastScreen();
return WolfMain(argc, argv);
}
void Quit(char *str)
{
FreeResources();
/*
if (gfxbuf)
free(gfxbuf);
*/
if (image)
gdk_image_destroy(image);
if (str && *str) {
fprintf(stderr, "%s\n", str);
exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
}
void SetPalette(Byte *pal)
{
int i;
for (i = 0; i < 256; i++) {
colors[i].red = pal[i*3+0] << 8;
colors[i].green = pal[i*3+1] << 8;
colors[i].blue = pal[i*3+2] << 8;
if (image_focus) gdk_color_change(cmap, &colors[i]);
}
}
int VidWidth, VidHeight, ViewHeight;
#define w VidWidth
#define h VidHeight
#define v ViewHeight
void BlastScreen2(Rect *BlastRect)
{
/* BlastScreen(); */
GdkRectangle r;
int x;
char *ptrs, *ptrd;
r.x = BlastRect->left;
r.y = BlastRect->top;
r.width = BlastRect->right - BlastRect->left;
r.height = BlastRect->bottom - BlastRect->top;
memcpy(image->mem, gfxbuf, w * h);
/*
ptrs = gfxbuf + (w * r.y) + r.x;
ptrd = image->mem;
ptrd += (w * r.y) + r.x;
for (x = 0; x < r.height; x++) {
memcpy(ptrd, ptrs, r.width);
ptrs += w;
ptrd += w;
}
*/
gtk_widget_draw(GTK_WIDGET(image_area), &r);
}
void BlastScreen()
{
memcpy(image->mem, gfxbuf, w * h);
gtk_widget_draw(GTK_WIDGET(image_area), NULL);
/*
gtk_widget_draw_default(GTK_WIDGET(image_area));
gtk_widget_draw(GTK_WIDGET(image_area), NULL);
*/
}
Word VidXs[] = {320,512,640,640}; /* Screen sizes to play with */
Word VidYs[] = {200,384,400,480};
Word VidVs[] = {160,320,320,400};
Word VidPics[] = {rFaceShapes,rFace512,rFace640,rFace640};
Word VidSize = -1;
Word NewGameWindow(Word NewVidSize)
{
LongWord *LongPtr;
Byte *DestPtr;
int i;
printf("Called: %d\n", NewVidSize);
if (NewVidSize == VidSize)
return VidSize;
printf("Setting Size: %d (from %d)\n", NewVidSize, VidSize);
if (NewVidSize < 4) {
w = VidXs[NewVidSize];
h = VidYs[NewVidSize];
v = VidVs[NewVidSize];
} else {
fprintf(stderr, "Invalid Vid size: %d\n", NewVidSize);
exit(EXIT_FAILURE);
}
if (image) {
gdk_image_destroy(image);
}
image = gdk_image_new(GDK_IMAGE_FASTEST, visual, w, h);
gtk_image_set(image_area, image, NULL);
gtk_widget_set_usize(GTK_WIDGET(win), w, h);
gtk_widget_set_usize(GTK_WIDGET(image_area), w, h);
if (gfxbuf)
free(gfxbuf);
gfxbuf = malloc(w * h);
/* gfxbuf = image->mem; */
VideoPointer = gfxbuf;
VideoWidth = w;
InitYTable();
SetAPalette(rBlackPal);
ClearTheScreen(BLACK);
BlastScreen();
LongPtr = (LongWord *) LoadAResource(VidPics[NewVidSize]);
if (GameShapes)
FreeSomeMem(GameShapes);
GameShapes = (Byte **)AllocSomeMem(lMSB(LongPtr[0]));
DLZSS((Byte *)GameShapes, (Byte *)&LongPtr[1], lMSB(LongPtr[0]));
ReleaseAResource(VidPics[NewVidSize]);
LongPtr = (LongWord *)GameShapes;
DestPtr = (Byte *)GameShapes;
for (i = 0; i < ((NewVidSize == 1) ? 57 : 47); i++)
GameShapes[i] = DestPtr + lMSB(LongPtr[i]);
VidSize = NewVidSize;
return VidSize;
}
/* Keyboard Hack */
static int RSJ;
static int KeyPressed;
static int keys[128];
void FlushKeys()
{
joystick1 = 0;
memset(keys, 0, sizeof(keys));
}
struct {
char code[13];
} CheatCodes[] = {
{ "XUSCNIELPPA" }, /* "XUSCNIELPPA" */
{ "IDDQD" }, /* "IDDQD" */
{ "BURGER" }, /* "BURGER" */
{ "WOWZERS" }, /* "WOWZERS" */
{ "LEDOUX" }, /* "LEDOUX" */
{ "SEGER" }, /* "SEGER" */
{ "MCCALL" }, /* "MCCALL" */
{ "APPLEIIGS" } /* "APPLEIIGS" */
};
const int CheatCount = sizeof(CheatCodes) / sizeof(CheatCodes[0]);
int CheatIndex;
#define SC_CURSORUPLEFT 1
#define SC_CURSORUP 2
#define SC_CURSORUPRIGHT 3
#define SC_CURSORRIGHT 4
#define SC_CURSORDOWNRIGHT 5
#define SC_CURSORDOWN 6
#define SC_CURSORDOWNLEFT 7
#define SC_CURSORLEFT 8
#define SC_CURSORBLOCKLEFT 9
#define SC_CURSORBLOCKRIGHT 10
#define SC_CURSORBLOCKUP 11
#define SC_CURSORBLOCKDOWN 12
#define SC_KEYPADENTER 13
#define SC_ENTER 14
#define SC_SPACE 15
#define SC_LEFTALT 16
#define SC_RIGHTALT 17
#define SC_LEFTCONTROL 18
#define SC_RIGHTCONTROL 19
#define SC_LEFTSHIFT 20
#define SC_RIGHTSHIFT 21
#define SC_B 22
void UpdateKeys(int key, int press)
{
switch(key) {
case GDK_KP_Home:
keys[SC_CURSORUPLEFT] = press;
break;
case GDK_KP_Up:
keys[SC_CURSORUP] = press;
break;
case GDK_KP_Page_Up:
keys[SC_CURSORUPRIGHT] = press;
break;
case GDK_KP_Right:
keys[SC_CURSORRIGHT] = press;
break;
case GDK_KP_Page_Down:
keys[SC_CURSORDOWNRIGHT] = press;
break;
case GDK_KP_Down:
keys[SC_CURSORDOWN] = press;
break;
case GDK_KP_End:
keys[SC_CURSORDOWNLEFT] = press;
break;
case GDK_KP_Left:
keys[SC_CURSORLEFT] = press;
break;
case GDK_Up:
keys[SC_CURSORBLOCKUP] = press;
break;
case GDK_Down:
keys[SC_CURSORBLOCKDOWN] = press;
break;
case GDK_Left:
keys[SC_CURSORBLOCKLEFT] = press;
break;
case GDK_Right:
keys[SC_CURSORBLOCKRIGHT] = press;
break;
case GDK_KP_Enter:
keys[SC_KEYPADENTER] = press;
break;
case GDK_Return:
keys[SC_ENTER] = press;
break;
case GDK_space:
keys[SC_SPACE] = press;
break;
case GDK_Alt_L:
keys[SC_LEFTALT] = press;
break;
case GDK_Alt_R:
keys[SC_RIGHTALT] = press;
break;
case GDK_Control_L:
keys[SC_LEFTCONTROL] = press;
break;
case GDK_Control_R:
keys[SC_RIGHTCONTROL] = press;
break;
case GDK_Shift_L:
keys[SC_LEFTSHIFT] = press;
break;
case GDK_Shift_R:
keys[SC_RIGHTSHIFT] = press;
break;
case GDK_b:
keys[SC_B] = press;
break;
}
}
void keyboard_handler(int keycode, int press)
{
int i;
UpdateKeys(keycode, press);
if (RSJ) {
if (press == 0) {
for (i = 0; i < CheatCount; i++) {
char *key = gdk_keyval_name(keycode);
if (key == NULL)
break;
if (strlen(key) != 1)
break;
if (CheatCodes[i].code[CheatIndex] == toupper(key[0])) {
CheatIndex++;
if (CheatCodes[i].code[CheatIndex] == 0) {
PlaySound(SND_BONUS);
switch (i) {
case 0:
case 4:
GiveKey(0);
GiveKey(1);
gamestate.godmode = TRUE;
break;
case 1:
gamestate.godmode^=TRUE;
break;
case 2:
gamestate.machinegun = TRUE;
gamestate.chaingun = TRUE;
gamestate.flamethrower = TRUE;
gamestate.missile = TRUE;
GiveAmmo(gamestate.maxammo);
GiveGas(99);
GiveMissile(99);
break;
case 3:
gamestate.maxammo = 999;
GiveAmmo(999);
break;
case 5:
GiveKey(0);
GiveKey(1);
break;
case 6:
playstate=EX_WARPED;
nextmap = gamestate.mapon+1;
if (MapListPtr->MaxMap<=nextmap)
nextmap = 0;
break;
case 7:
ShowPush ^= TRUE;
break;
}
CheatIndex = 0;
}
break;
}
}
if (i == CheatCount)
CheatIndex = 0;
}
joystick1 = 0;
if (press == 0) {
switch(keycode) {
case GDK_1:
gamestate.pendingweapon = WP_KNIFE;
break;
case GDK_2:
if (gamestate.ammo) {
gamestate.pendingweapon = WP_PISTOL;
}
break;
case GDK_3:
if (gamestate.ammo && gamestate.machinegun) {
gamestate.pendingweapon = WP_MACHINEGUN;
}
break;
case GDK_4:
if (gamestate.ammo && gamestate.chaingun) {
gamestate.pendingweapon = WP_CHAINGUN;
}
break;
case GDK_5:
if (gamestate.gas && gamestate.flamethrower) {
gamestate.pendingweapon = WP_FLAMETHROWER;
}
break;
case GDK_6:
if (gamestate.missiles && gamestate.missile) {
gamestate.pendingweapon = WP_MISSILE;
}
break;
case GDK_period:
case GDK_slash:
joystick1 = JOYPAD_START;
break;
case GDK_Escape:
Quit(NULL); /* fast way out */
}
}
if (keys[SC_CURSORUPLEFT])
joystick1 |= (JOYPAD_UP|JOYPAD_LFT);
if (keys[SC_CURSORUP])
joystick1 |= JOYPAD_UP;
if (keys[SC_CURSORUPRIGHT])
joystick1 |= (JOYPAD_UP|JOYPAD_RGT);
if (keys[SC_CURSORRIGHT])
joystick1 |= JOYPAD_RGT;
if (keys[SC_CURSORDOWNRIGHT])
joystick1 |= (JOYPAD_DN|JOYPAD_RGT);
if (keys[SC_CURSORDOWN])
joystick1 |= JOYPAD_DN;
if (keys[SC_CURSORDOWNLEFT])
joystick1 |= (JOYPAD_DN|JOYPAD_LFT);
if (keys[SC_CURSORLEFT])
joystick1 |= JOYPAD_LFT;
if (keys[SC_CURSORBLOCKLEFT])
joystick1 |= JOYPAD_LFT;
if (keys[SC_CURSORBLOCKRIGHT])
joystick1 |= JOYPAD_RGT;
if (keys[SC_CURSORBLOCKUP])
joystick1 |= JOYPAD_UP;
if (keys[SC_CURSORBLOCKDOWN])
joystick1 |= JOYPAD_DN;
if (keys[SC_KEYPADENTER])
joystick1 |= JOYPAD_A;
if (keys[SC_ENTER])
joystick1 |= JOYPAD_A;
if (keys[SC_SPACE])
joystick1 |= JOYPAD_A;
if (keys[SC_LEFTALT])
joystick1 |= JOYPAD_TL;
if (keys[SC_RIGHTALT])
joystick1 |= JOYPAD_TR;
if (keys[SC_LEFTCONTROL])
joystick1 |= JOYPAD_B;
if (keys[SC_RIGHTCONTROL])
joystick1 |= JOYPAD_B;
if (keys[SC_LEFTSHIFT])
joystick1 |= (JOYPAD_X|JOYPAD_Y);
if (keys[SC_RIGHTSHIFT])
joystick1 |= (JOYPAD_X|JOYPAD_Y);
}
}
int HandleEvents()
{
KeyPressed = 0;
while (gtk_events_pending())
gtk_main_iteration();
return KeyPressed;
}
void ReadSystemJoystick()
{
RSJ = 1;
HandleEvents();
}
int DoEvents()
{
RSJ = 0;
if (HandleEvents()) {
if (keys[SC_B]) { /* Special */
return 'B';
}
return 1;
}
return 0;
}
Word ChooseGameDiff()
{
/* 0 = easy, 1 = normal, 2 = hard, 3 = death incarnate */
difficulty = 1;
SetAPalette(rGamePal);
return 1;
}
/*
Copyright (C) 1992-1994 Id Software, Inc.
Copyright (C) 2000 Steven Fuller <relnev@atdot.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -29,10 +49,10 @@ int main(int argc, char *argv[]) ...@@ -29,10 +49,10 @@ int main(int argc, char *argv[])
InitData(); InitData();
NewGameWindow(0); /* 320x200 */ NewGameWindow(0); /* 320x200 */
//#ifndef NOVGA
keyboard_init(); /* keyboard must be init'd after vga_setmode .. */ keyboard_init(); /* keyboard must be init'd after vga_setmode .. */
keyboard_seteventhandler(keyboard_handler); keyboard_seteventhandler(keyboard_handler);
//#endif
ClearTheScreen(BLACK); ClearTheScreen(BLACK);
BlastScreen(); BlastScreen();
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
Copyright (C) 2000 Steven Fuller <relnev@atdot.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
...@@ -121,8 +141,8 @@ void Quit(char *str) ...@@ -121,8 +141,8 @@ void Quit(char *str)
{ {
FreeResources(); FreeResources();
if (gfxbuf) if (img)
free(gfxbuf); XDestroyImage(img);
if (str && *str) { if (str && *str) {
fprintf(stderr, "%s\n", str); fprintf(stderr, "%s\n", str);
...@@ -188,7 +208,7 @@ Word NewGameWindow(Word NewVidSize) ...@@ -188,7 +208,7 @@ Word NewGameWindow(Word NewVidSize)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (gfxbuf) { if (img) {
XDestroyImage(img); XDestroyImage(img);
/* free(gfxbuf); */ /* free(gfxbuf); */
} }
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __WOLFDEF__ #ifndef __WOLFDEF__
#define __WOLFDEF__ #define __WOLFDEF__
...@@ -113,14 +132,14 @@ Word ScaleY(Word y); ...@@ -113,14 +132,14 @@ Word ScaleY(Word y);
#define JOYPAD_Y 0x4000 #define JOYPAD_Y 0x4000
#define JOYPAD_SELECT 0x2000 #define JOYPAD_SELECT 0x2000
#define JOYPAD_START 0x1000 #define JOYPAD_START 0x1000
#define JOYPAD_UP 0x800 #define JOYPAD_UP 0x0800
#define JOYPAD_DN 0x400 #define JOYPAD_DN 0x0400
#define JOYPAD_LFT 0x200 #define JOYPAD_LFT 0x0200
#define JOYPAD_RGT 0x100 #define JOYPAD_RGT 0x0100
#define JOYPAD_A 0x80 #define JOYPAD_A 0x0080
#define JOYPAD_X 0x40 #define JOYPAD_X 0x0040
#define JOYPAD_TL 0x20 #define JOYPAD_TL 0x0020
#define JOYPAD_TR 0x10 #define JOYPAD_TR 0x0010
/********************************** /**********************************
......
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