Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wolf3d
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
wolf3d
Commits
88291afa
Commit
88291afa
authored
Jun 17, 2000
by
Steven Fuller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More changes for GL and start of Motif frontends
parent
31fb323b
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
1439 additions
and
77 deletions
+1439
-77
GLDraw.c
macsrc/GLDraw.c
+30
-2
InterMis.c
macsrc/InterMis.c
+6
-19
Makefile
macsrc/Makefile
+25
-7
README
macsrc/README
+8
-7
SoftDraw.c
macsrc/SoftDraw.c
+72
-3
TODO
macsrc/TODO
+3
-3
burger.h
macsrc/burger.h
+1
-1
stub.c
macsrc/stub.c
+0
-33
vi_glxm.c
macsrc/vi_glxm.c
+674
-0
vi_xm.c
macsrc/vi_xm.c
+613
-0
wolfdef.h
macsrc/wolfdef.h
+7
-2
No files found.
macsrc/GLDraw.c
View file @
88291afa
...
...
@@ -185,7 +185,7 @@ void RedrawScreen()
BlastScreen
();
}
void
DrawShape
(
Word
x
,
Word
y
,
void
*
ShapePtr
)
void
ShowGetPsyched
(
)
{
}
...
...
@@ -193,6 +193,22 @@ void DrawPsyched(Word Index)
{
}
void
EndGetPsyched
()
{
}
void
InitInterMisPic
()
{
}
void
DrawInterMisPic
(
Word
index
)
{
}
void
FreeInitMisPic
()
{
}
void
DisplayScreen
(
Word
res
,
Word
pres
)
{
LongWord
*
PackPtr
;
...
...
@@ -813,20 +829,32 @@ void IO_AttackShape(Word shape)
void
DrawSprite
(
thing_t
*
t
)
{
static
GLfloat
arr
[
16
]
=
{
1
.
0
,
0
.
0
,
0
.
5
,
1
.
0
,
1
.
0
,
1
.
0
,
0
.
5
,
-
1
.
0
,
0
.
0
,
1
.
0
,
-
0
.
5
,
-
1
.
0
,
0
.
0
,
0
.
0
,
-
0
.
5
,
1
.
0
};
glPushMatrix
();
glTranslatef
(
-
(
GLfloat
)
t
->
x
/
256
.
0
,
0
,
-
(
GLfloat
)
t
->
y
/
256
.
0
);
glRotatef
(
90
.
0
+
((
GLfloat
)
gamestate
.
viewangle
/
(
GLfloat
)
ANGLES
*
360
.
0
),
0
.
0
,
1
.
0
,
0
.
0
);
ChangeTextureSimple
(
sprtex
[
t
->
sprite
]);
glBegin
(
GL_QUADS
);
#if 0
glTexCoord2f(1.0, 0.0); glVertex2f( 0.5, 1);
glTexCoord2f(1.0, 1.0); glVertex2f( 0.5, -1);
glTexCoord2f(0.0, 1.0); glVertex2f(-0.5, -1);
glTexCoord2f(0.0, 0.0); glVertex2f(-0.5, 1);
#else
glTexCoord2fv
(
&
arr
[
0
]);
glVertex2fv
(
&
arr
[
2
]);
glTexCoord2fv
(
&
arr
[
4
]);
glVertex2fv
(
&
arr
[
6
]);
glTexCoord2fv
(
&
arr
[
8
]);
glVertex2fv
(
&
arr
[
10
]);
glTexCoord2fv
(
&
arr
[
12
]);
glVertex2fv
(
&
arr
[
14
]);
#endif
glEnd
();
glPopMatrix
();
}
...
...
macsrc/InterMis.c
View file @
88291afa
...
...
@@ -22,8 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern
Word
NumberIndex
;
/* Hack for drawing numbers */
static
LongWord
BJTime
;
/* Time to draw BJ? */
static
Word
WhichBJ
;
/* Which BJ to show */
static
LongWord
Indexs
[
3
];
/* Offsets to BJ's true shapes */
static
Byte
*
BJPtr
;
/* Pointer to BJ's shapes */
static
Word
ParTime
;
/* Par time for level */
static
LongWord
BonusScore
;
/* Additional points */
...
...
@@ -46,7 +44,6 @@ static LongWord BonusScore; /* Additional points */
**********************************/
static
Rect
BJRect
=
{
48
,
73
,
48
+
142
,
73
+
131
};
/* Rect for BJ's picture */
static
void
ShowBJ
(
void
)
{
if
((
ReadTick
()
-
BJTime
)
>=
20
)
{
/* Time to draw a BJ? */
...
...
@@ -54,8 +51,7 @@ static void ShowBJ(void)
if
(
WhichBJ
!=
2
)
{
/* Thumbs up? */
WhichBJ
^=
1
;
/* Nope, toggle breathing */
}
DrawShape
(
73
,
48
,
&
BJPtr
[
Indexs
[
WhichBJ
]]);
/* Draw BJ */
BlastScreen2
(
&
BJRect
);
/* Update video */
DrawInterMisPic
(
WhichBJ
);
}
}
...
...
@@ -229,8 +225,6 @@ static void RollRatio(Word x,Word y,Word ratio)
void
LevelCompleted
(
void
)
{
Word
k
;
LongWord
*
PackPtr
;
LongWord
PackLength
;
/* setup */
...
...
@@ -244,17 +238,8 @@ void LevelCompleted(void)
DisplayScreen
(
rIntermission
,
rInterPal
);
BlastScreen
();
PackPtr
=
LoadAResource
(
rInterPics
);
PackLength
=
lMSB
(
PackPtr
[
0
]);
BJPtr
=
(
Byte
*
)
AllocSomeMem
(
PackLength
);
DLZSS
(
BJPtr
,(
Byte
*
)
&
PackPtr
[
1
],
PackLength
);
ReleaseAResource
(
rInterPics
);
memcpy
(
Indexs
,
BJPtr
,
12
);
/* Copy the index table */
Indexs
[
0
]
=
lMSB
(
Indexs
[
0
]);
Indexs
[
1
]
=
lMSB
(
Indexs
[
1
]);
Indexs
[
2
]
=
lMSB
(
Indexs
[
2
]);
InitInterMisPic
();
WhichBJ
=
0
;
/* Init BJ */
BJTime
=
ReadTick
()
-
50
;
/* Force a redraw */
BlastScreen
();
/* Draw the screen */
...
...
@@ -315,8 +300,10 @@ void LevelCompleted(void)
do
{
ShowBJ
();
/* Animate BJ */
}
while
(
!
WaitTicksEvent
(
1
));
/* Wait for a keypress */
FreeSomeMem
(
BJPtr
);
/* Release BJ's shapes */
FadeToBlack
();
/* Fade away */
FreeInitMisPic
();
IntermissionHack
=
FALSE
;
/* Release the hack */
NumberIndex
=
36
;
/* Restore the index */
}
...
...
macsrc/Makefile
View file @
88291afa
...
...
@@ -14,50 +14,68 @@ SOFTOBJS = RefSprite.o SoftDraw.o SoftDraw2.o
OGLOBJS
=
GLDraw.o
SOBJS
=
$(OBJS)
$(SOFTOBJS)
vi_svga.o
XOBJS
=
$(OBJS)
$(SOFTOBJS)
vi_xlib.o
XMOBJS
=
$(OBJS)
$(SOFTOBJS)
vi_xm.o
GOBJS
=
$(OBJS)
$(SOFTOBJS)
vi_gtk.o
GLOBJS
=
$(OBJS)
$(OGLOBJS)
vi_glx.o
GLXMOBJS
=
$(OBJS)
$(OGLOBJS)
vi_glxm.o
LFLAGS
=
-lm
#LFLAGS = -lm /home/relnev/ElectricFence-2.1/libefence.a
#LFLAGS = -lm /home/relnev/ElectricFence-2.2.2/libefence.a -lpthread
SLFLAGS
=
$(LFLAGS)
-lvga
#XLFLAGS = $(LFLAGS) -L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lXxf86dga
XLFLAGS
=
$(LFLAGS)
-L
/usr/X11R6/lib
-lX11
GLFLAGS
=
$(LFLAGS)
`
gtk-config
--libs
`
# -L/usr/X11R6/lib -lX11 -lXi -lXext -lgdk -lgtk
GLLFLAGS
=
$(LFLAGS)
-L
/usr/lib
-L
/usr/X11R6/lib
-lX11
-lXext
-lGL
SLFLAGS
=
$(LFLAGS)
-lvga
#XLFLAGS = $(LFLAGS) -L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lXxf86dga
XLFLAGS
=
$(LFLAGS)
-L
/usr/X11R6/lib
-lX11
XMLFLAGS
=
$(LFLAGS)
-L
/usr/X11R6/lib
-lX11
-L
/usr/local/motif/lib
GLFLAGS
=
$(LFLAGS)
`
gtk-config
--libs
`
# -L/usr/X11R6/lib -lX11 -lXi -lXext -lgdk -lgtk
GLLFLAGS
=
$(LFLAGS)
-L
/usr/lib
-L
/usr/X11R6/lib
-lX11
-lXext
-lGL
GLXMLFLAGS
=
$(LFLAGS)
-L
/usr/lib
-L
/usr/X11R6/lib
-L
/usr/local/motif/lib
-lX11
-lXext
-lGL
NASM
=
nasm
.SUFFIXES
:
.asm
all
:
swolf3d xwolf3d
gwolf3d gl
wolf3d
all
:
swolf3d xwolf3d
xmwolf3d gwolf3d glwolf3d glxm
wolf3d
$(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
$(XMOBJS)
:
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
$(GLXMOBJS)
:
Sounds.h Sprites.h States.h Wolf.h burger.h wolfdef.h
.asm.o
:
$(NASM)
-f
elf
-o
$@
$<
vi_xm.o
:
vi_xm.c
gcc
-c
vi_xm.c
$(CFLAGS)
-I
/usr/local/motif/include
vi_gtk.o
:
vi_gtk.c
gcc
-c
vi_gtk.c
$(CFLAGS)
`
gtk-config
--cflags
`
vi_glxm.o
:
vi_glxm.c
gcc
-c
vi_glxm.c
$(CFLAGS)
-I
/usr/local/motif/include
swolf3d
:
$(SOBJS)
gcc
-o
swolf3d
$(SOBJS)
$(SLFLAGS)
xwolf3d
:
$(XOBJS)
gcc
-o
xwolf3d
$(XOBJS)
$(XLFLAGS)
xmwolf3d
:
$(XMOBJS)
gcc
-o
xmwolf3d
$(XMOBJS)
$(XMLFLAGS)
gwolf3d
:
$(GOBJS)
gcc
-o
gwolf3d
$(GOBJS)
$(GLFLAGS)
glwolf3d
:
$(GLOBJS)
gcc
-o
glwolf3d
$(GLOBJS)
$(GLLFLAGS)
glxmwolf3d
:
$(GLXMOBJS)
gcc
-o
glxmwolf3d
$(GLXMOBJS)
$(GLXMLFLAGS)
clean
:
rm
-rf
swolf3d xwolf3d gwolf3d glwolf3d
*
.o
rm
-rf
swolf3d xwolf3d gwolf3d glwolf3d
xmwolf3d glxmwolf3d
*
.o
distclean
:
clean
rm
-rf
core
*
~ DEADJOE
...
...
macsrc/README
View file @
88291afa
...
...
@@ -4,7 +4,7 @@ Wolfenstein 3D is an Id Software game. This is a port of the Macintosh
version that was released by MacPlay in 1994. You can find information about
the source release at: http://www.maccentral.com/news/0001/24.wolf3d.shtml
WolfReadMe.txt, from that Mac Wolf3d source release, is also included with
this port.
this port.
This port is not supported by id Software.
Goals of this Project (Just what am I trying to do?): Like the PC verison,
this game (I consider the PC and Mac versions as different games) was only
...
...
@@ -59,19 +59,20 @@ the specifics.
Specifically:
swolf3d : The SVGAlib Version. Only supports 320x200x256 at the moment, so
only parts of the intro screens are shown (they are 512x384).
only parts of the intro screens are shown (they are 512x384). [Actually
now you can use different resolutions, but I'm not sure how stable it is.]
xwolf3d : The Xlib Version. Only supports 8bpp PseudoColor visuals.
xwolf3d : The Xlib Version. Only supports 8bpp PseudoColor visuals. Window
only at this time.
gwolf3d : The gtk+ Version. Only supports 8bpp visuals, but has a menu that
has a Quit option. I currently don't really like gtk+; anyone know of a
more complete api reference than the one on http://www.gtk.org? But I'll
use it so I can have menus and dialogs without having to create them in Xlib.
Any suggestions?
have to use it so I can have menus and dialogs without having to create them
in Xlib.
Any suggestions?
glwolf3d: The OpenGL Version (written using Xlib w/ GLX). I like it. Not
all graphics are currently shown (So when you have a blank screen, press
enter a few times to get passed the screens).
all graphics are currently shown, and a few things are still rough.
Note: The available targets (binaries) may change over time as I decide
which APIs work the best, etc.
...
...
macsrc/SoftDraw.c
View file @
88291afa
...
...
@@ -36,6 +36,75 @@ void InitYTable(void)
}
while
(
++
i
<
480
);
}
static
LongWord
PsyTime
;
void
ShowGetPsyched
(
void
)
{
LongWord
*
PackPtr
;
Byte
*
ShapePtr
;
LongWord
PackLength
;
Word
X
,
Y
;
PsyTime
=
ReadTick
()
+
60
*
2
;
ClearTheScreen
(
BLACK
);
BlastScreen
();
PackPtr
=
LoadAResource
(
rGetPsychPic
);
PackLength
=
lMSB
(
PackPtr
[
0
]);
ShapePtr
=
AllocSomeMem
(
PackLength
);
DLZSS
(
ShapePtr
,(
Byte
*
)
&
PackPtr
[
1
],
PackLength
);
X
=
(
VidWidth
-
224
)
/
2
;
Y
=
(
ViewHeight
-
56
)
/
2
;
DrawShape
(
X
,
Y
,
ShapePtr
);
FreeSomeMem
(
ShapePtr
);
ReleaseAResource
(
rGetPsychPic
);
BlastScreen
();
SetAPalette
(
rGamePal
);
}
void
EndGetPsyched
(
void
)
{
while
(
PsyTime
>
ReadTick
())
;
SetAPalette
(
rBlackPal
);
}
/*
The intermission picture (BJ)
*/
static
LongWord
Indexs
[
3
];
/* Offsets to BJ's true shapes */
static
Byte
*
BJPtr
;
/* Pointer to BJ's shapes */
void
InitInterMisPic
()
{
LongWord
*
PackPtr
;
LongWord
PackLength
;
PackPtr
=
LoadAResource
(
rInterPics
);
PackLength
=
lMSB
(
PackPtr
[
0
]);
BJPtr
=
(
Byte
*
)
AllocSomeMem
(
PackLength
);
DLZSS
(
BJPtr
,
(
Byte
*
)
&
PackPtr
[
1
],
PackLength
);
ReleaseAResource
(
rInterPics
);
memcpy
(
Indexs
,
BJPtr
,
12
);
/* Copy the index table */
Indexs
[
0
]
=
lMSB
(
Indexs
[
0
]);
Indexs
[
1
]
=
lMSB
(
Indexs
[
1
]);
Indexs
[
2
]
=
lMSB
(
Indexs
[
2
]);
}
static
Rect
BJRect
=
{
48
,
73
,
48
+
142
,
73
+
131
};
/* Rect for BJ's picture */
void
DrawInterMisPic
(
Word
index
)
{
DrawShape
(
BJRect
.
left
,
BJRect
.
top
,
&
BJPtr
[
Indexs
[
index
]]);
BlastScreen2
(
&
BJRect
);
}
void
FreeInitMisPic
()
{
FreeSomeMem
(
BJPtr
);
/* Release BJ's shapes */
}
void
DisplayScreen
(
Word
res
,
Word
pal
)
{
LongWord
*
PackPtr
;
...
...
@@ -201,9 +270,9 @@ void IO_ScaleWallColumn(Word x, Word scale, Word tile, Word column)
}
typedef
struct
{
SWord
Topy
;
SWord
Boty
;
SWord
Shape
;
S
hort
Word
Topy
;
S
hort
Word
Boty
;
S
hort
Word
Shape
;
}
PACKED
SpriteRun
;
void
IO_ScaleMaskedColumn
(
Word
x
,
Word
scale
,
unsigned
short
*
CharPtr
,
Word
column
)
...
...
macsrc/TODO
View file @
88291afa
...
...
@@ -23,9 +23,9 @@ TODO:
- Is GL_REPLACE faster than GL_MODULATE for textures?
- Save "draw state" so redrawing works right when screen is
resized/exposed
-
What about using CVAs for the Walls - when loading level create a
CVA with every wall entry, then just reference the right one (go by BSP
number)
-
GLX 1.3?
- As an experiement, see if adding CVAs to the wall code will speed
anything up?
* Documentation
* Sound!
- Need to write sound playing code (probably access /dev/dsp directly
...
...
macsrc/burger.h
View file @
88291afa
...
...
@@ -24,7 +24,7 @@ typedef unsigned int Word;
typedef
unsigned
long
LongWord
;
typedef
unsigned
char
Byte
;
typedef
unsigned
char
Boolean
;
typedef
unsigned
short
int
SWord
;
typedef
unsigned
short
int
S
hort
Word
;
#define BLACK 255
#define DARKGREY 250
...
...
macsrc/stub.c
View file @
88291afa
...
...
@@ -81,39 +81,6 @@ void PrintTimeCounter(TimeCounter *t, char *header)
printf
(
"Min: %lu, max:%lu
\n
"
,
t
->
mintime
,
t
->
maxtime
);
}
LongWord
PsyTime
;
void
ShowGetPsyched
(
void
)
{
LongWord
*
PackPtr
;
Byte
*
ShapePtr
;
LongWord
PackLength
;
Word
X
,
Y
;
PsyTime
=
ReadTick
()
+
60
*
2
;
ClearTheScreen
(
BLACK
);
BlastScreen
();
PackPtr
=
LoadAResource
(
rGetPsychPic
);
PackLength
=
lMSB
(
PackPtr
[
0
]);
ShapePtr
=
AllocSomeMem
(
PackLength
);
DLZSS
(
ShapePtr
,(
Byte
*
)
&
PackPtr
[
1
],
PackLength
);
X
=
(
VidWidth
-
224
)
/
2
;
Y
=
(
ViewHeight
-
56
)
/
2
;
DrawShape
(
X
,
Y
,
ShapePtr
);
FreeSomeMem
(
ShapePtr
);
ReleaseAResource
(
rGetPsychPic
);
BlastScreen
();
SetAPalette
(
rGamePal
);
}
void
EndGetPsyched
(
void
)
{
while
(
PsyTime
>
ReadTick
())
;
SetAPalette
(
rBlackPal
);
}
void
ShareWareEnd
(
void
)
{
SetAPalette
(
rGamePal
);
...
...
macsrc/vi_glxm.c
0 → 100644
View file @
88291afa
/*
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 <getopt.h>
#include <setjmp.h>
#include <Xm/MainW.h>
#include <X11/keysym.h>
#include <GL/gl.h>
#include <GL/glx.h>
#include <GL/glext.h>
#include "wolfdef.h"
Display
*
dpy
;
int
screen
;
Window
win
,
root
;
XVisualInfo
*
vi
;
GLXContext
ctx
;
Atom
wmDeleteWindow
;
#ifdef GL_EXT_shared_texture_palette
extern
int
UseSharedTexturePalette
;
extern
PFNGLCOLORTABLEEXTPROC
pglColorTableEXT
;
#endif
extern
int
CheckToken
(
const
char
*
str
,
const
char
*
item
);
int
VidWidth
,
VidHeight
,
ViewHeight
;
int
HandleEvents
();
extern
jmp_buf
ResetJmp
;
extern
Boolean
JumpOK
;
int
attrib
[]
=
{
GLX_RGBA
,
GLX_RED_SIZE
,
5
,
GLX_GREEN_SIZE
,
5
,
GLX_BLUE_SIZE
,
5
,
GLX_DEPTH_SIZE
,
16
,
GLX_DOUBLEBUFFER
,
None
};
int
main
(
int
argc
,
char
*
argv
[])
{
XSetWindowAttributes
attr
;
Colormap
cmap
;
Pixmap
bitmap
;
Cursor
cursor
;
XColor
bg
=
{
0
};
XColor
fg
=
{
0
};
char
data
[
8
]
=
{
0x01
};
char
*
display
;
const
char
*
ext
;
int
mask
,
major
,
minor
,
verbose
=
0
;
int
opt
;
while
((
opt
=
getopt
(
argc
,
argv
,
"v"
))
!=
-
1
)
{
switch
(
opt
)
{
case
'v'
:
verbose
=
1
;
break
;
default:
fprintf
(
stderr
,
"%d (%c) is unknown to me
\n
"
,
opt
,
opt
);
break
;
}
}
if
((
argc
-
optind
)
!=
1
)
{
fprintf
(
stderr
,
"usage: %s <mac wolf3d resource fork>
\n
"
,
argv
[
0
]);
exit
(
EXIT_FAILURE
);
}
if
(
InitResources
(
argv
[
optind
]))
{
fprintf
(
stderr
,
"could not load %s
\n
"
,
argv
[
optind
]);
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
);
if
(
glXQueryExtension
(
dpy
,
NULL
,
NULL
)
==
False
)
{
fprintf
(
stderr
,
"Display %s does not support the GLX Extension
\n
"
,
XDisplayName
(
display
));
exit
(
EXIT_FAILURE
);
}
if
(
glXQueryVersion
(
dpy
,
&
major
,
&
minor
)
==
False
)
{
fprintf
(
stderr
,
"glXQueryVersion returned False?
\n
"
);
exit
(
EXIT_FAILURE
);
}
else
if
(
verbose
)
{
printf
(
"GLX Version %d.%d
\n
"
,
major
,
minor
);
printf
(
"GLX Client:
\n
"
);
printf
(
"GLX_VENDOR: %s
\n
"
,
glXGetClientString
(
dpy
,
GLX_VENDOR
));
printf
(
"GLX_VERSION: %s
\n
"
,
glXGetClientString
(
dpy
,
GLX_VERSION
));
printf
(
"GLX_EXTENSIONS: %s
\n
"
,
glXGetClientString
(
dpy
,
GLX_EXTENSIONS
));
printf
(
"GLX Server:
\n
"
);
printf
(
"GLX_VENDOR: %s
\n
"
,
glXQueryServerString
(
dpy
,
screen
,
GLX_VENDOR
));
printf
(
"GLX_VERSION: %s
\n
"
,
glXQueryServerString
(
dpy
,
screen
,
GLX_VERSION
));
printf
(
"GLX_EXTENSIONS: %s
\n
"
,
glXQueryServerString
(
dpy
,
screen
,
GLX_EXTENSIONS
));
printf
(
"Both:
\n
"
);
printf
(
"GLX_EXTENSIONS: %s
\n
"
,
glXQueryExtensionsString
(
dpy
,
screen
));
}
vi
=
glXChooseVisual
(
dpy
,
screen
,
attrib
);
if
(
vi
==
NULL
)
{
fprintf
(
stderr
,
"No usable GL visual found on %s:%d
\n
"
,
XDisplayName
(
display
),
screen
);
exit
(
EXIT_FAILURE
);
}
ctx
=
glXCreateContext
(
dpy
,
vi
,
NULL
,
True
);
if
(
ctx
==
NULL
)
{
fprintf
(
stderr
,
"GLX context creation failed
\n
"
);
exit
(
EXIT_FAILURE
);
}
cmap
=
XCreateColormap
(
dpy
,
root
,
vi
->
visual
,
AllocNone
);
attr
.
colormap
=
cmap
;
attr
.
event_mask
=
KeyPressMask
|
KeyReleaseMask
|
ExposureMask
|
StructureNotifyMask
;
mask
=
CWColormap
|
CWEventMask
;
win
=
XCreateWindow
(
dpy
,
root
,
0
,
0
,
640
,
480
,
0
,
CopyFromParent
,
InputOutput
,
vi
->
visual
,
mask
,
&
attr
);
if
(
win
==
None
)
{
fprintf
(
stderr
,
"Unable to create window
\n
"
);
exit
(
EXIT_FAILURE
);
}
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
);
glXMakeCurrent
(
dpy
,
win
,
ctx
);
if
(
verbose
)
{
printf
(
"GL Library:
\n
"
);
printf
(
"GL_VENDOR: %s
\n
"
,
glGetString
(
GL_VENDOR
));
printf
(
"GL_RENDERER: %s
\n
"
,
glGetString
(
GL_RENDERER
));
printf
(
"GL_VERSION: %s
\n
"
,
glGetString
(
GL_VERSION
));
printf
(
"GL_EXTENSIONS: %s
\n
"
,
glGetString
(
GL_EXTENSIONS
));
}
XMapWindow
(
dpy
,
win
);
XFlush
(
dpy
);
ext
=
(
const
char
*
)
glGetString
(
GL_EXTENSIONS
);
#ifdef GL_EXT_shared_texture_palette
UseSharedTexturePalette
=
0
;
if
(
CheckToken
(
ext
,
"GL_EXT_shared_texture_palette"
))
{
pglColorTableEXT
=
glXGetProcAddressARB
((
unsigned
const
char
*
)
"glColorTableEXT"
);
if
(
pglColorTableEXT
)
{
UseSharedTexturePalette
=
1
;
printf
(
"GL_EXT_shared_texture_palette found...
\n
"
);
}
}
#endif
glShadeModel
(
GL_FLAT
);
InitData
();
SlowDown
=
1
;
GameViewSize
=
3
;
NewGameWindow
(
GameViewSize
);
ClearTheScreen
(
BLACK
);
BlastScreen
();
/* NoEnemies = 1; */
return
WolfMain
(
argc
,
argv
);
}
void
Quit
(
char
*
str
)
{
FreeResources
();
glXDestroyContext
(
dpy
,
ctx
);
if
(
str
&&
*
str
)
{
fprintf
(
stderr
,
"%s
\n
"
,
str
);
exit
(
EXIT_FAILURE
);
}
exit
(
EXIT_SUCCESS
);
}
void
BlastScreen2
(
Rect
*
BlastRect
)
{
BlastScreen
();
}
#define w VidWidth
#define h VidHeight
#define v ViewHeight
void
BlastScreen
()
{
GLint
error
;
glXSwapBuffers
(
dpy
,
win
);
error
=
glGetError
();
if
(
error
!=
GL_NO_ERROR
)
{
do
{
fprintf
(
stderr
,
"GL Error: %d
\n
"
,
error
);
error
=
glGetError
();
}
while
(
error
!=
GL_NO_ERROR
);
exit
(
EXIT_FAILURE
);
}
}
Word
VidXs
[]
=
{
320
,
512
,
640
,
640
};
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
;
if
(
NewVidSize
==
VidSize
)
return
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
);
}
sizehints
.
min_width
=
w
;
sizehints
.
min_height
=
h
;
sizehints
.
flags
=
PMinSize
;
XSetWMNormalHints
(
dpy
,
win
,
&
sizehints
);
XResizeWindow
(
dpy
,
win
,
w
,
h
);
SetAPalette
(
rBlackPal
);
ClearTheScreen
(
BLACK
);
BlastScreen
();
VidSize
=
NewVidSize
;
XSync
(
dpy
,
False
);
glXWaitGL
();
glXWaitX
();
HandleEvents
();
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"
},
{
"IDDQD"
},
{
"BURGER"
},
{
"WOWZERS"
},
{
"LEDOUX"
},
{
"SEGER"
},
{
"MCCALL"
},
{
"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
(
press
==
0
)
{
switch
(
keycode
)
{
case
XK_Escape
:
Quit
(
NULL
);
/* fast way out */
case
XK_F2
:
if
(
playstate
==
EX_STILLPLAYING
)
{
if
(
!
SaveGame
(
"wolf3d.sav"
))
fprintf
(
stderr
,
"Unable to save game
\n
"
);
}
break
;
case
XK_F3
:
if
(
!
LoadGame
(
"wolf3d.sav"
))
{
fprintf
(
stderr
,
"Unable to load game
\n
"
);
}
else
{
longjmp
(
ResetJmp
,
EX_LOADGAME
);
}
break
;
default:
break
;
}
}
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
;
}
}
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_TR
;
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
);
if
((
joystick1
&
(
JOYPAD_LFT
|
JOYPAD_RGT
))
==
(
JOYPAD_LFT
|
JOYPAD_RGT
))
joystick1
&=
~
(
JOYPAD_LFT
|
JOYPAD_RGT
);
if
((
joystick1
&
(
JOYPAD_UP
|
JOYPAD_DN
))
==
(
JOYPAD_UP
|
JOYPAD_DN
))
joystick1
&=
~
(
JOYPAD_UP
|
JOYPAD_DN
);
if
(
joystick1
&
JOYPAD_TR
)
{
if
(
joystick1
&
JOYPAD_LFT
)
{
joystick1
=
(
joystick1
&
~
(
JOYPAD_TR
|
JOYPAD_LFT
))
|
JOYPAD_TL
;
}
else
if
(
joystick1
&
JOYPAD_RGT
)
{
joystick1
=
joystick1
&
~
JOYPAD_RGT
;
}
else
{
joystick1
&=
~
JOYPAD_TR
;
}
}
}
}
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
=
0
;
break
;
case
Expose
:
RedrawScreen
();
break
;
case
ConfigureNotify
:
glViewport
(
0
,
0
,
event
.
xconfigure
.
width
,
event
.
xconfigure
.
height
);
glPixelZoom
(
1
.
0
f
,
-
1
.
0
f
);
glRasterPos2f
(
-
1
.
0
f
,
1
.
0
f
);
RedrawScreen
();
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
;
}
macsrc/vi_xm.c
0 → 100644
View file @
88291afa
/*
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 <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
=
3
;
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_TR
;
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
);
}
if
((
joystick1
&
(
JOYPAD_LFT
|
JOYPAD_RGT
))
==
(
JOYPAD_LFT
|
JOYPAD_RGT
))
joystick1
&=
~
(
JOYPAD_LFT
|
JOYPAD_RGT
);
if
((
joystick1
&
(
JOYPAD_UP
|
JOYPAD_DN
))
==
(
JOYPAD_UP
|
JOYPAD_DN
))
joystick1
&=
~
(
JOYPAD_UP
|
JOYPAD_DN
);
if
(
joystick1
&
JOYPAD_TR
)
{
if
(
joystick1
&
JOYPAD_LFT
)
{
joystick1
=
(
joystick1
&
~
(
JOYPAD_TR
|
JOYPAD_LFT
))
|
JOYPAD_TL
;
}
else
if
(
joystick1
&
JOYPAD_RGT
)
{
joystick1
=
joystick1
&
~
JOYPAD_RGT
;
}
else
{
joystick1
&=
~
JOYPAD_TR
;
}
}
}
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
=
0
;
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
;
}
macsrc/wolfdef.h
View file @
88291afa
...
...
@@ -30,10 +30,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define PACKED __attribute__((packed))
typedef
struct
{
int
left
;
int
top
;
int
righ
t
;
int
lef
t
;
int
bottom
;
int
right
;
}
Rect
;
...
...
@@ -584,6 +584,7 @@ extern Boolean rw_downside; /* True for dir_east and dir_south*/
extern
Byte
*
ArtData
[
64
];
extern
Byte
textures
[
MAPSIZE
*
2
+
5
][
MAPSIZE
];
/* 0-63 is horizontal, 64-127 is vertical*/
extern
void
SetPalette
(
Byte
*
pal
);
extern
void
DisplayScreen
(
Word
res
,
Word
pal
);
extern
void
InitRenderView
();
...
...
@@ -597,6 +598,10 @@ extern void FreeResources();
extern
void
RedrawScreen
();
extern
Boolean
SaveGame
(
char
*
file
);
extern
Boolean
LoadGame
(
char
*
file
);
extern
void
InitInterMisPic
();
extern
void
DrawInterMisPic
(
Word
index
);
extern
void
FreeInitMisPic
();
extern
void
BlastScreen
(
void
);
extern
void
BlastScreen2
(
Rect
*
BlastRect
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment