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
fd76d414
Commit
fd76d414
authored
May 09, 2000
by
Steven Fuller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial port to Windows.
parent
93d851a3
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
1482 additions
and
135 deletions
+1482
-135
IDEAS
src/IDEAS
+6
-3
Makefile
src/Makefile
+3
-3
NOTES
src/NOTES
+28
-0
TODO
src/TODO
+5
-9
gfxsave.c
src/gfxsave.c
+1
-4
id_ca.c
src/id_ca.c
+1
-1
id_ca.h
src/id_ca.h
+1
-1
id_heads.h
src/id_heads.h
+41
-11
misc.c
src/misc.c
+26
-1
misc.h
src/misc.h
+4
-0
sd_null.c
src/sd_null.c
+10
-10
version.h
src/version.h
+1
-1
vi_comm.h
src/vi_comm.h
+1
-1
vi_glx.c
src/vi_glx.c
+37
-2
vi_svga.c
src/vi_svga.c
+37
-2
vi_wdx.c
src/vi_wdx.c
+1088
-0
vi_xlib.c
src/vi_xlib.c
+38
-2
wl_act2.c
src/wl_act2.c
+10
-10
wl_def.h
src/wl_def.h
+2
-0
wl_draw.c
src/wl_draw.c
+1
-1
wl_game.c
src/wl_game.c
+2
-2
wl_inter.c
src/wl_inter.c
+2
-9
wl_main.c
src/wl_main.c
+15
-55
wl_menu.c
src/wl_menu.c
+119
-6
wl_play.c
src/wl_play.c
+3
-1
No files found.
src/IDEAS
View file @
fd76d414
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
dataset?
dataset?
* A key to change viewsize while playing (note: max == 20, min == 5 or so...)
* A key to change viewsize while playing (note: max == 20, min == 5 or so...)
* Game able to cope at any virtual resolution in software mode. OpenGL
* Game able to cope at any virtual resolution in software mode. OpenGL
handles this transparently
handles this transparently
(after setting correct glViewport)
* Audio support using OpenAL (somewhat decently supported at the moment)
* Audio support using OpenAL (somewhat decently supported at the moment)
* Add support for the Mac version, if possible
* Add support for the Mac version, if possible
* Network support!
* Network support!
* Fully compile with no warnings/errors using -Wall -ansi -pedantic and with
* Fully compile with no warnings/errors using -Wall -ansi -pedantic and with
other compilers (would need to turn off warnings about unused parameters)
other compilers (would need to turn off warnings about unused parameters)
* Port to: Linux/SVGAlib, Linux/X (Windowed and DGA), Linux/OpenGL,
* Port to: Linux/SVGAlib, Linux/X (Windowed and DGA), Linux/OpenGL,
DOS/Allegro, Win32/GDI, Win32/DX, Win32/D3D, Win32/OpenGL, BeOS?, MacOS?
DOS/Allegro, Win32/GDI
?
, Win32/DX, Win32/D3D, Win32/OpenGL, BeOS?, MacOS?
* Ease in using demos. Playing demos from files, recording to files, batch
* Ease in using demos. Playing demos from files, recording to files, batch
playing, and so on.
playing, and so on.
* Make Wolf3D the game it was originally planned to be... More strategy...
* Make Wolf3D the game it was originally planned to be... More strategy...
...
@@ -17,9 +17,12 @@
...
@@ -17,9 +17,12 @@
regardless of future plans [IDEAS]) and no TODO/FIXME/XXXs in the source
regardless of future plans [IDEAS]) and no TODO/FIXME/XXXs in the source
code
code
* Have some sort of way of playing both digital and adlib sounds on all
* Have some sort of way of playing both digital and adlib sounds on all
platforms
platforms
(if possible)
* Test with other available mods (that were compatible with the original
* Test with other available mods (that were compatible with the original
game)
game)
* Unified input handling
* Unified input handling
* Configuration files and save games which work regardless of operating
* Configuration files and save games which work regardless of operating
system/processor/binary build
system/processor/binary build
* Suite of utilities to edit the game data.
* Building on previous idea, have some way to break out of requiring the
game to be recompiled for each game dataset
src/Makefile
View file @
fd76d414
...
@@ -3,13 +3,13 @@ CC = gcc
...
@@ -3,13 +3,13 @@ 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
#CFLAGS = -g -Wall
#CFLAGS = -g
#CFLAGS = -g
#
CFLAGS = -Os
CFLAGS
=
-Os
CFLAGS
=
-g
-Wall
-I
/home/relnev/cvs/oal/include
#
CFLAGS = -g -Wall -I/home/relnev/cvs/oal/include
OBJS
=
objs.o misc.o id_ca.o id_vh.o id_us.o
\
OBJS
=
objs.o misc.o id_ca.o id_vh.o id_us.o
\
wl_act1.o wl_act2.o wl_agent.o wl_game.o
\
wl_act1.o wl_act2.o wl_agent.o wl_game.o
\
wl_inter.o wl_menu.o wl_play.o wl_state.o wl_text.o wl_main.o
\
wl_inter.o wl_menu.o wl_play.o wl_state.o wl_text.o wl_main.o
\
wl_debug.o gfxsave.o sd_oal.o
# sd_null.o
wl_debug.o gfxsave.o sd_
null.o
# sd_
oal.o # sd_null.o
ROBJS
=
wl_draw.o wl_scale.o
ROBJS
=
wl_draw.o wl_scale.o
SOBJS
=
$(OBJS)
$(ROBJS)
vi_svga.o
SOBJS
=
$(OBJS)
$(ROBJS)
vi_svga.o
XOBJS
=
$(OBJS)
$(ROBJS)
vi_xlib.o
XOBJS
=
$(OBJS)
$(ROBJS)
vi_xlib.o
...
...
src/NOTES
View file @
fd76d414
Just some random facts/thoughts/ideas/musings:
Just some random facts/thoughts/ideas/musings:
* Wolfenstein 3D for:
- PC (released, of course) [May 5, 1992]
- PC Spear of Destiny 1992
- SNES
- Macintosh
- Jaguar
- Apple IIGS
- 3DO (? - not mentioned in apogee faq, but you can find cheatcodes for it)
* Rumored/Never Released?
- Atari Lynx
- Sega Genesis
- Japanese PC Version
- Spanish PC Version
- Japanese Mac Version
* Unofficial ports:
- Linux (this, xwolf, wolfgl)
- Windows (wolfgl)
- Acorn/Archemedes
* PC source released on:
- now many ports, projects, etc
- urls
* Mac source released January 22(?), 2000
- url
* TED source (editor used for tons of games including wolf3d)
Wolfenstein 3D was originally planned to be a much more complex game. ...
Wolfenstein 3D was originally planned to be a much more complex game. ...
... lots of unused code ... possibly from previous projects and incarnations
... lots of unused code ... possibly from previous projects and incarnations
of wolf3d.
of wolf3d.
...
...
src/TODO
View file @
fd76d414
...
@@ -17,6 +17,7 @@ actual gameplay/etc.
...
@@ -17,6 +17,7 @@ actual gameplay/etc.
* is that memory intro screen needed anymore? probably not, although it
* is that memory intro screen needed anymore? probably not, although it
would be nice to show what version is loaded, but doom just printed text
would be nice to show what version is loaded, but doom just printed text
and the intro screen which came with wolf3d has copyrighted images
and the intro screen which came with wolf3d has copyrighted images
maybe make a new intro screen...
* then, what about PG13? OH NO!!!! -- people would probably want the first
* then, what about PG13? OH NO!!!! -- people would probably want the first
two screens for nostalga
two screens for nostalga
* fix the input code, everything is spread out... ideally everything should
* fix the input code, everything is spread out... ideally everything should
...
@@ -33,7 +34,7 @@ outside the viewarea, leaving artifacts
...
@@ -33,7 +34,7 @@ outside the viewarea, leaving artifacts
* and upload builds with lots of wl6 code anyway (sound references were just
* and upload builds with lots of wl6 code anyway (sound references were just
ifndefed out)
ifndefed out)
* verify if the sounds and graphics are correctly numbered, once again...
* verify if the sounds and graphics are correctly numbered, once again...
* add a ViewMap?
* add a ViewMap?
* remove the #else at the end of each header since nothing is being doubly
* remove the #else at the end of each header since nothing is being doubly
included now (if ever)
included now (if ever)
* find and remove any function stubs (functions which just call another
* find and remove any function stubs (functions which just call another
...
@@ -51,7 +52,7 @@ metaname like sc_Left etc or something
...
@@ -51,7 +52,7 @@ metaname like sc_Left etc or something
update once per frame or such.. hm
update once per frame or such.. hm
and where is that stray pixel coming from (when using end game with largest
and where is that stray pixel coming from (when using end game with largest
window size) in svgalib
window size) in svgalib
no idea how to do fizzlefade in 16bit
.
no idea how to do fizzlefade in 16bit
X
* change id_sd to sd_oss, sd_win, sd_dos, sd_oal, etc
* change id_sd to sd_oss, sd_win, sd_dos, sd_oal, etc
idea is that different <outputs> can share some drivers, unlike video
idea is that different <outputs> can share some drivers, unlike video
although glx and x11 share a lot of code (i guess since gl will be a great
although glx and x11 share a lot of code (i guess since gl will be a great
...
@@ -68,7 +69,7 @@ by putting in code from id_vh (either by using Plot or just copying it in)
...
@@ -68,7 +69,7 @@ by putting in code from id_vh (either by using Plot or just copying it in)
we can stop the large conversion before each UpdateScreen
we can stop the large conversion before each UpdateScreen
but palette fades will still need it! damnit
but palette fades will still need it! damnit
* what are special keys... ?
* what are special keys... ?
* the higher
bitrate
s are a hack since a palette lookup has to be done
* the higher
depth
s are a hack since a palette lookup has to be done
for every byte when transferring to the pixmap, palette fades require a
for every byte when transferring to the pixmap, palette fades require a
screen update
screen update
* make sure none of the code tries to handle gfx/sound data directly
* make sure none of the code tries to handle gfx/sound data directly
...
@@ -80,9 +81,4 @@ of the game (namely stuff used for hit testing when firing weapon) in the
...
@@ -80,9 +81,4 @@ of the game (namely stuff used for hit testing when firing weapon) in the
draw loop.. start by cp wl_draw.c vi_ogl.c and just take out the actual
draw loop.. start by cp wl_draw.c vi_ogl.c and just take out the actual
drawing bits and replace with opengl.
drawing bits and replace with opengl.
* change visable -> visible
* change visable -> visible
* fix up windows port
Specific:
* memory/sound intro screen goes
- Trademarked images, only came with wolf3d 1.4's (I believe)
* copy protection goes
- Who needs a manual to look at the source?
src/gfxsave.c
View file @
fd76d414
#include <stdio.h>
#include "wl_def.h"
#include <stdlib.h>
#define PACKED __attribute__((packed))
typedef
struct
pcx_header_type
typedef
struct
pcx_header_type
{
{
...
...
src/id_ca.c
View file @
fd76d414
...
@@ -36,7 +36,7 @@ int mapon;
...
@@ -36,7 +36,7 @@ int mapon;
word
*
mapsegs
[
MAPPLANES
];
word
*
mapsegs
[
MAPPLANES
];
maptype
*
mapheaderseg
[
NUMMAPS
];
maptype
*
mapheaderseg
[
NUMMAPS
];
byte
*
audiosegs
[
NUMSNDCHUNKS
];
byte
*
audiosegs
[
NUMSNDCHUNKS
];
void
*
grsegs
[
NUMCHUNKS
];
byte
*
grsegs
[
NUMCHUNKS
];
byte
grneeded
[
NUMCHUNKS
];
byte
grneeded
[
NUMCHUNKS
];
byte
ca_levelbit
,
ca_levelnum
;
byte
ca_levelbit
,
ca_levelnum
;
...
...
src/id_ca.h
View file @
fd76d414
...
@@ -26,7 +26,7 @@ extern int mapon;
...
@@ -26,7 +26,7 @@ extern int mapon;
extern
word
*
mapsegs
[
MAPPLANES
];
extern
word
*
mapsegs
[
MAPPLANES
];
extern
maptype
*
mapheaderseg
[
NUMMAPS
];
extern
maptype
*
mapheaderseg
[
NUMMAPS
];
extern
byte
*
audiosegs
[
NUMSNDCHUNKS
];
extern
byte
*
audiosegs
[
NUMSNDCHUNKS
];
extern
void
*
grsegs
[
NUMCHUNKS
];
extern
byte
*
grsegs
[
NUMCHUNKS
];
extern
byte
grneeded
[
NUMCHUNKS
];
extern
byte
grneeded
[
NUMCHUNKS
];
extern
byte
ca_levelbit
,
ca_levelnum
;
extern
byte
ca_levelbit
,
ca_levelnum
;
...
...
src/id_heads.h
View file @
fd76d414
#ifndef __ID_HEADS_H__
#ifndef __ID_HEADS_H__
#define __ID_HEADS_H__
#define __ID_HEADS_H__
#ifdef _WIN32
/* TODO: rename dosism, because like djgpp has glob() */
#define DOSISM
/* for junk which isn't abstracted (namely stuff in wl_menu.c with glob/findfirst and misc.c) */
#undef HAVE_FFBLK
/* TODO: what to do with hacks like this */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <io.h>
#include <dos.h>
#define boolean BOOLEAN
#define false FALSE
#define true TRUE
#define PACKED
#pragma pack(1)
/* TODO: this unfortunately packs every struct... */
#define ssize_t SSIZE_T
#else
#undef DOSISM
#include <unistd.h>
#include <unistd.h>
#include <sys/time.h>
#include <values.h>
#include <glob.h>
#define PACKED __attribute__((packed))
#define LONGLONG long long
#define O_BINARY 0
typedef
enum
{
false
,
true
}
boolean
;
#endif
#include <ctype.h>
#include <ctype.h>
#include <errno.h>
#include <errno.h>
#include <fcntl.h>
#include <fcntl.h>
...
@@ -9,23 +46,17 @@
...
@@ -9,23 +46,17 @@
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <time.h>
#include <time.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <values.h>
#include <sys/types.h>
#include <sys/types.h>
#include <glob.h>
#include <math.h>
#include <math.h>
#include "misc.h"
#include "misc.h"
#include "version.h"
#include "version.h"
#define PACKED __attribute__((packed))
#ifndef O_BINARY
#define O_BINARY 0
#endif
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
#ifndef SPEAR
#ifndef SPEAR
...
@@ -52,7 +83,7 @@
...
@@ -52,7 +83,7 @@
/* ---------------- */
/* ---------------- */
typedef
enum
{
false
,
true
}
boolean
;
typedef
unsigned
char
byte
;
typedef
unsigned
char
byte
;
typedef
unsigned
short
int
word
;
typedef
unsigned
short
int
word
;
typedef
unsigned
long
longword
;
typedef
unsigned
long
longword
;
...
@@ -79,7 +110,6 @@ extern const byte introscn[];
...
@@ -79,7 +110,6 @@ extern const byte introscn[];
extern
const
byte
gamepal
[];
extern
const
byte
gamepal
[];
int
MS_CheckParm
(
char
*
string
);
int
MS_CheckParm
(
char
*
string
);
int
WolfMain
(
int
argc
,
char
*
argv
[]);
void
Quit
(
char
*
error
);
void
Quit
(
char
*
error
);
#undef PI
#undef PI
...
...
src/misc.c
View file @
fd76d414
#include "id_heads.h"
#include "id_heads.h"
#ifdef DOSISM
/* TODO: bad name.. since djgpp code would use interrupt (maybe uclock?) most likely */
#define TICKCOUNT 70
long
TimeCount
;
double
AdjClock
=
CLOCKS_PER_SEC
/
TICKCOUNT
;
double
LastClock
;
void
set_TimeCount
(
unsigned
long
count
)
{
/* TODO: would using queryperformancecounter be better? */
TimeCount
=
count
;
LastClock
=
clock
();
}
unsigned
long
get_TimeCount
()
{
return
(
unsigned
long
)(
TimeCount
+
((
clock
()
-
LastClock
)
/
AdjClock
));
}
#else
/* DOSISM */
/* TimeCount from David Haslam -- dch@sirius.demon.co.uk */
static
struct
timeval
t0
;
static
struct
timeval
t0
;
static
long
tc0
;
static
long
tc0
;
/* From David Haslam -- dch@sirius.demon.co.uk */
void
set_TimeCount
(
unsigned
long
t
)
void
set_TimeCount
(
unsigned
long
t
)
{
{
tc0
=
t
;
tc0
=
t
;
...
@@ -69,3 +92,5 @@ char *ultoa(unsigned long value, char *string, int radix)
...
@@ -69,3 +92,5 @@ char *ultoa(unsigned long value, char *string, int radix)
sprintf
(
string
,
"%lu"
,
value
);
sprintf
(
string
,
"%lu"
,
value
);
return
string
;
return
string
;
}
}
#endif
/* DOSISM */
src/misc.h
View file @
fd76d414
...
@@ -10,6 +10,8 @@ void SavePCXRGBToFile(unsigned char *buf, int width, int height, char *name);
...
@@ -10,6 +10,8 @@ void SavePCXRGBToFile(unsigned char *buf, int width, int height, char *name);
void
set_TimeCount
(
unsigned
long
t
);
void
set_TimeCount
(
unsigned
long
t
);
unsigned
long
get_TimeCount
();
unsigned
long
get_TimeCount
();
#ifndef DOSISM
long
filelength
(
int
handle
);
long
filelength
(
int
handle
);
#define stricmp strcasecmp
#define stricmp strcasecmp
...
@@ -20,6 +22,8 @@ char *itoa(short int value, char *string, int radix);
...
@@ -20,6 +22,8 @@ char *itoa(short int value, char *string, int radix);
char
*
ltoa
(
long
value
,
char
*
string
,
int
radix
);
char
*
ltoa
(
long
value
,
char
*
string
,
int
radix
);
char
*
ultoa
(
unsigned
long
value
,
char
*
string
,
int
radix
);
char
*
ultoa
(
unsigned
long
value
,
char
*
string
,
int
radix
);
#endif
/* DOSISM */
#else
#else
#error "fix me TODO"
#error "fix me TODO"
#endif
#endif
src/sd_null.c
View file @
fd76d414
...
@@ -36,7 +36,6 @@ static boolean sbNoCheck,sbNoProCheck;
...
@@ -36,7 +36,6 @@ static boolean sbNoCheck,sbNoProCheck;
static
byte
sbOldIntMask
=
-
1
;
static
byte
sbOldIntMask
=
-
1
;
static
byte
*
sbNextSegPtr
;
static
byte
*
sbNextSegPtr
;
static
longword
sbNextSegLen
;
static
longword
sbNextSegLen
;
static
SampledSound
*
sbSamples
;
// SoundSource variables
// SoundSource variables
boolean
ssNoCheck
;
boolean
ssNoCheck
;
...
@@ -166,7 +165,7 @@ void SD_PositionSound(int leftvol,int rightvol)
...
@@ -166,7 +165,7 @@ void SD_PositionSound(int leftvol,int rightvol)
// SD_PlaySound() - plays the specified sound on the appropriate hardware
// SD_PlaySound() - plays the specified sound on the appropriate hardware
//
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
boolean
SD_PlaySound
(
soundnames
sound
)
void
SD_PlaySound
(
soundnames
sound
)
{
{
boolean
ispos
;
boolean
ispos
;
int
lp
,
rp
;
int
lp
,
rp
;
...
@@ -179,7 +178,6 @@ boolean SD_PlaySound(soundnames sound)
...
@@ -179,7 +178,6 @@ boolean SD_PlaySound(soundnames sound)
ispos
=
nextsoundpos
;
ispos
=
nextsoundpos
;
nextsoundpos
=
false
;
nextsoundpos
=
false
;
return
false
;
}
}
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
...
@@ -317,8 +315,9 @@ byte lefttable[ATABLEMAX][ATABLEMAX * 2] = {
...
@@ -317,8 +315,9 @@ byte lefttable[ATABLEMAX][ATABLEMAX * 2] = {
{
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
}
{
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
}
};
};
void
SetSoundLoc
(
fixed
gx
,
fixed
gy
)
void
SetSoundLoc
(
fixed
gx
,
fixed
gy
)
{
{
#if 0
fixed xt,yt;
fixed xt,yt;
int x,y;
int x,y;
...
@@ -352,6 +351,7 @@ void SetSoundLoc(fixed gx,fixed gy)
...
@@ -352,6 +351,7 @@ void SetSoundLoc(fixed gx,fixed gy)
x = ATABLEMAX - 1;
x = ATABLEMAX - 1;
leftchannel = lefttable[x][y + ATABLEMAX];
leftchannel = lefttable[x][y + ATABLEMAX];
rightchannel = righttable[x][y + ATABLEMAX];
rightchannel = righttable[x][y + ATABLEMAX];
#endif
}
}
/*
/*
...
@@ -368,14 +368,14 @@ void PlaySoundLocGlobal(word s,fixed gx,fixed gy)
...
@@ -368,14 +368,14 @@ void PlaySoundLocGlobal(word s,fixed gx,fixed gy)
{
{
SetSoundLoc
(
gx
,
gy
);
SetSoundLoc
(
gx
,
gy
);
SD_PositionSound
(
leftchannel
,
rightchannel
);
SD_PositionSound
(
leftchannel
,
rightchannel
);
if
(
SD_PlaySound
(
s
))
{
SD_PlaySound
(
s
);
globalsoundx
=
gx
;
globalsoundy
=
gy
;
globalsoundx
=
gx
;
}
globalsoundy
=
gy
;
}
}
void
UpdateSoundLoc
()
void
UpdateSoundLoc
(
fixed
x
,
fixed
y
,
int
angle
)
{
{
if
(
SoundPositioned
)
if
(
SoundPositioned
)
{
{
...
...
src/version.h
View file @
fd76d414
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
/* SDM = 2 */
/* SDM = 2 */
/* SOD = 3 */
/* SOD = 3 */
#ifndef WMODE
#ifndef WMODE
#define WMODE
1
#define WMODE
0
#endif
#endif
#if WMODE == 0
#if WMODE == 0
...
...
src/vi_comm.h
View file @
fd76d414
...
@@ -22,7 +22,7 @@ void VL_Hlin(unsigned x, unsigned y, unsigned width, unsigned color);
...
@@ -22,7 +22,7 @@ void VL_Hlin(unsigned x, unsigned y, unsigned width, unsigned color);
void
VL_Vlin
(
int
x
,
int
y
,
int
height
,
int
color
);
void
VL_Vlin
(
int
x
,
int
y
,
int
height
,
int
color
);
void
VL_Bar
(
int
x
,
int
y
,
int
width
,
int
height
,
int
color
);
void
VL_Bar
(
int
x
,
int
y
,
int
width
,
int
height
,
int
color
);
void
VL_MemToScreen
(
byte
*
source
,
int
width
,
int
height
,
int
x
,
int
y
);
void
VL_MemToScreen
(
const
byte
*
source
,
int
width
,
int
height
,
int
x
,
int
y
);
void
VL_DeModeXize
(
byte
*
buf
,
int
width
,
int
height
);
void
VL_DeModeXize
(
byte
*
buf
,
int
width
,
int
height
);
...
...
src/vi_glx.c
View file @
fd76d414
/* id_vl.c */
/* id_vl.c */
#include "
id_heads
.h"
#include "
wl_def
.h"
#include <X11/Xlib.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <X11/keysym.h>
...
@@ -34,6 +34,41 @@ int attrib[] = {
...
@@ -34,6 +34,41 @@ int attrib[] = {
None
None
};
};
/*
==========================
=
= Quit
=
==========================
*/
void
Quit
(
char
*
error
)
{
/* TODO: blah blah blah */
memptr
screen
=
NULL
;
if
(
!
error
||
!*
error
)
{
CA_CacheGrChunk
(
ORDERSCREEN
);
screen
=
grsegs
[
ORDERSCREEN
];
WriteConfig
();
}
else
if
(
error
)
{
CA_CacheGrChunk
(
ERRORSCREEN
);
screen
=
grsegs
[
ERRORSCREEN
];
}
ShutdownId
();
if
(
screen
)
{
printf
(
"TODO: spiffy ansi screen goes here..
\n
"
);
}
if
(
error
&&
*
error
)
{
fprintf
(
stderr
,
"Quit: %s"
,
error
);
exit
(
EXIT_FAILURE
);
}
exit
(
EXIT_SUCCESS
);
}
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
/* TODO: move this to the proper functions */
/* TODO: move this to the proper functions */
...
@@ -368,7 +403,7 @@ void VL_Bar(int x, int y, int width, int height, int color)
...
@@ -368,7 +403,7 @@ void VL_Bar(int x, int y, int width, int height, int color)
=================
=================
*/
*/
void
VL_MemToScreen
(
byte
*
source
,
int
width
,
int
height
,
int
x
,
int
y
)
void
VL_MemToScreen
(
const
byte
*
source
,
int
width
,
int
height
,
int
x
,
int
y
)
{
{
byte
*
ptr
=
gfxbuf
+
320
*
y
+
x
;
byte
*
ptr
=
gfxbuf
+
320
*
y
+
x
;
while
(
height
--
)
{
while
(
height
--
)
{
...
...
src/vi_svga.c
View file @
fd76d414
/* id_vl.c */
/* id_vl.c */
#include "
id_heads
.h"
#include "
wl_def
.h"
#include <vga.h>
#include <vga.h>
#include <vgakeyboard.h>
#include <vgakeyboard.h>
byte
*
gfxbuf
=
NULL
;
byte
*
gfxbuf
=
NULL
;
/*
==========================
=
= Quit
=
==========================
*/
void
Quit
(
char
*
error
)
{
/* TODO: blah blah blah */
memptr
screen
=
NULL
;
if
(
!
error
||
!*
error
)
{
CA_CacheGrChunk
(
ORDERSCREEN
);
screen
=
grsegs
[
ORDERSCREEN
];
WriteConfig
();
}
else
if
(
error
)
{
CA_CacheGrChunk
(
ERRORSCREEN
);
screen
=
grsegs
[
ERRORSCREEN
];
}
ShutdownId
();
if
(
screen
)
{
printf
(
"TODO: spiffy ansi screen goes here..
\n
"
);
}
if
(
error
&&
*
error
)
{
fprintf
(
stderr
,
"Quit: %s"
,
error
);
exit
(
EXIT_FAILURE
);
}
exit
(
EXIT_SUCCESS
);
}
void
VL_WaitVBL
(
int
vbls
)
void
VL_WaitVBL
(
int
vbls
)
{
{
vga_waitretrace
();
vga_waitretrace
();
...
@@ -228,7 +263,7 @@ void VL_Bar(int x, int y, int width, int height, int color)
...
@@ -228,7 +263,7 @@ void VL_Bar(int x, int y, int width, int height, int color)
=================
=================
*/
*/
void
VL_MemToScreen
(
byte
*
source
,
int
width
,
int
height
,
int
x
,
int
y
)
void
VL_MemToScreen
(
const
byte
*
source
,
int
width
,
int
height
,
int
x
,
int
y
)
{
{
byte
*
ptr
=
gfxbuf
+
320
*
y
+
x
;
byte
*
ptr
=
gfxbuf
+
320
*
y
+
x
;
while
(
height
--
)
{
while
(
height
--
)
{
...
...
src/vi_wdx.c
0 → 100644
View file @
fd76d414
#include "wl_def.h"
#include <windows.h>
#include <ddraw.h>
#include <dinput.h>
#include <direct.h>
byte
*
gfxbuf
=
NULL
;
HWND
win
;
IDirectInput
*
lpDI
;
IDirectInputDevice
*
lpDIKeyboard
;
int
hCrt
;
FILE
*
hf
;
IDirectDraw
*
lpDD
;
IDirectDrawSurface
*
lpDDSPrimary
;
IDirectDrawSurface
*
lpDDSBuffer
;
IDirectDrawClipper
*
lpDDC
;
LPDDSCAPS
lpDDSCaps
;
DDSURFACEDESC
ddsd
;
byte
mypal
[
768
];
void
WolfDirectDrawPaint
();
HRESULT
CALLBACK
WndProc
(
HWND
hwnd
,
UINT
iMsg
,
WPARAM
wParam
,
LPARAM
lParam
);
void
CheckEvents
();
int
WINAPI
WinMain
(
HINSTANCE
hInstance
,
HINSTANCE
hPrevInstance
,
LPSTR
lpCmdLine
,
int
iCmdShow
)
{
static
char
szAppName
[]
=
"Wolf3D"
;
HWND
hwnd
;
WNDCLASSEX
wndclass
;
wndclass
.
cbSize
=
sizeof
(
wndclass
);
wndclass
.
style
=
CS_HREDRAW
|
CS_VREDRAW
;
wndclass
.
lpfnWndProc
=
WndProc
;
wndclass
.
cbClsExtra
=
0
;
wndclass
.
cbWndExtra
=
0
;
wndclass
.
hInstance
=
hInstance
;
wndclass
.
hIcon
=
LoadIcon
(
NULL
,
IDI_APPLICATION
);
wndclass
.
hCursor
=
LoadCursor
(
NULL
,
IDC_ARROW
);
wndclass
.
hbrBackground
=
(
HBRUSH
)
GetStockObject
(
WHITE_BRUSH
);
wndclass
.
lpszMenuName
=
NULL
;
wndclass
.
lpszClassName
=
szAppName
;
wndclass
.
hIconSm
=
LoadIcon
(
NULL
,
IDI_APPLICATION
);
RegisterClassEx
(
&
wndclass
);
hwnd
=
CreateWindow
(
szAppName
,
GAMENAME
,
WS_OVERLAPPEDWINDOW
,
CW_USEDEFAULT
,
CW_USEDEFAULT
,
320
,
200
,
NULL
,
NULL
,
hInstance
,
NULL
);
ShowWindow
(
hwnd
,
iCmdShow
);
UpdateWindow
(
hwnd
);
if
(
DirectDrawCreate
(
NULL
,
&
lpDD
,
NULL
)
!=
DD_OK
)
{
MessageBox
(
hwnd
,
"ugh"
,
"ugh"
,
MB_OK
);
return
0
;
}
if
(
IDirectDraw_SetCooperativeLevel
(
lpDD
,
hwnd
,
DDSCL_NORMAL
)
!=
DD_OK
)
{
MessageBox
(
hwnd
,
"hi"
,
"hi"
,
MB_OK
);
}
// if (IDirectDraw_SetDisplayMode(lpDD, 320, 200, 8) != DD_OK) {
// MessageBox(hwnd, "hi2", "hi", MB_OK);
// }
ddsd
.
dwSize
=
sizeof
(
ddsd
);
ddsd
.
dwFlags
=
DDSD_CAPS
;
ddsd
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
;
if
(
IDirectDraw_CreateSurface
(
lpDD
,
&
ddsd
,
&
lpDDSPrimary
,
NULL
)
!=
DD_OK
)
{
MessageBox
(
hwnd
,
"hi3"
,
"hi"
,
MB_OK
);
}
if
(
IDirectDraw_CreateClipper
(
lpDD
,
0
,
&
lpDDC
,
NULL
)
!=
DD_OK
)
{
MessageBox
(
hwnd
,
"hi4"
,
"hi"
,
MB_OK
);
}
if
(
IDirectDrawClipper_SetHWnd
(
lpDDC
,
0
,
hwnd
)
!=
DD_OK
)
{
MessageBox
(
hwnd
,
"hi5"
,
"hi"
,
MB_OK
);
}
if
(
IDirectDrawSurface_SetClipper
(
lpDDSPrimary
,
lpDDC
)
!=
DD_OK
)
{
MessageBox
(
hwnd
,
"hi6"
,
"hi"
,
MB_OK
);
}
ddsd
.
dwFlags
=
DDSD_CAPS
|
DDSD_WIDTH
|
DDSD_HEIGHT
;
ddsd
.
ddsCaps
.
dwCaps
=
DDSCAPS_OFFSCREENPLAIN
|
DDSCAPS_SYSTEMMEMORY
;
ddsd
.
dwWidth
=
320
;
ddsd
.
dwHeight
=
200
;
if
(
IDirectDraw_CreateSurface
(
lpDD
,
&
ddsd
,
&
lpDDSBuffer
,
NULL
)
!=
DD_OK
)
{
MessageBox
(
hwnd
,
"hi7"
,
"hi"
,
MB_OK
);
}
if
(
DirectInputCreate
(
hInstance
,
DIRECTINPUT_VERSION
,
&
lpDI
,
NULL
)
!=
DI_OK
)
{
MessageBox
(
hwnd
,
"hi8"
,
"hi"
,
MB_OK
);
}
if
(
IDirectInput_CreateDevice
(
lpDI
,
&
GUID_SysKeyboard
,
&
lpDIKeyboard
,
NULL
)
!=
DD_OK
)
{
MessageBox
(
hwnd
,
"hi9"
,
"hi"
,
MB_OK
);
}
IDirectInputDevice_SetDataFormat
(
lpDIKeyboard
,
&
c_dfDIKeyboard
);
if
(
IDirectInputDevice_SetCooperativeLevel
(
lpDIKeyboard
,
hwnd
,
DISCL_NONEXCLUSIVE
|
DISCL_FOREGROUND
)
!=
DD_OK
)
{
MessageBox
(
hwnd
,
"hi10"
,
"hi"
,
MB_OK
);
}
win
=
hwnd
;
return
WolfMain
(
0
,
NULL
);
/* TODO ... need to do something for silly windows */
}
/*
==========================
=
= Quit
=
==========================
*/
void
Quit
(
char
*
error
)
{
/* TODO: blah blah blah */
memptr
screen
=
NULL
;
if
(
!
error
||
!*
error
)
{
CA_CacheGrChunk
(
ORDERSCREEN
);
screen
=
grsegs
[
ORDERSCREEN
];
WriteConfig
();
}
else
if
(
error
)
{
CA_CacheGrChunk
(
ERRORSCREEN
);
screen
=
grsegs
[
ERRORSCREEN
];
}
ShutdownId
();
if
(
screen
)
{
printf
(
"TODO: spiffy ansi screen goes here..
\n
"
);
}
if
(
error
&&
*
error
)
{
MessageBox
(
win
,
error
,
"Error!"
,
MB_ICONEXCLAMATION
|
MB_OK
);
}
SendMessage
(
win
,
WM_CLOSE
,
0
,
0
);
for
(;;)
CheckEvents
();
/* We sent our death wish, now we wait */
}
void
WolfDirectDrawPaint
()
{
int
x
;
unsigned
short
int
*
ptr
;
HWND
hwnd
;
if
(
!
lpDD
)
return
;
if
(
!
gfxbuf
)
return
;
if
(
IDirectDrawSurface_Lock
(
lpDDSBuffer
,
NULL
,
&
ddsd
,
DDLOCK_SURFACEMEMORYPTR
,
NULL
)
!=
DD_OK
)
{
MessageBox
(
win
,
"eh?"
,
"hrm"
,
MB_OK
);
return
;
}
IDirectDrawClipper_GetHWnd
(
lpDDC
,
&
hwnd
);
ptr
=
ddsd
.
lpSurface
;
for
(
x
=
0
;
x
<
64000
;
x
++
)
{
*
ptr
=
(
mypal
[
gfxbuf
[
x
]
*
3
+
0
]
>>
3
)
<<
13
|
(
mypal
[
gfxbuf
[
x
]
*
3
+
1
]
>>
3
)
<<
8
|
(
mypal
[
gfxbuf
[
x
]
*
3
+
2
]
>>
3
)
<<
2
;
ptr
++
;
}
//memcpy(ddsd.lpSurface, gfxbuf, 64000);
IDirectDrawSurface_Unlock
(
lpDDSBuffer
,
ddsd
.
lpSurface
);
if
(
IDirectDrawSurface_IsLost
(
lpDDSPrimary
))
{
printf
(
"eh2?
\n
"
);
exit
(
1
);
}
/*
{
RECT srcrect={0,0,320, 200};
RECT dstrect;
GetWindowRect(hwnd,&dstrect);
dstrect.top+=42;
dstrect.bottom-=4;
dstrect.left+=4;
dstrect.right-=4;
IDirectDrawSurface_Blt(lpDDSPrimary, &dstrect, lpDDSBuffer, &srcrect, 0, NULL);
}
*/
{
/* TODO: need to get and save window border sizes (setting default size needs this too) */
RECT
srcrect
=
{
0
,
0
,
320
,
200
};
RECT
dstrect
;
GetWindowRect
(
hwnd
,
&
dstrect
);
IDirectDrawSurface_Blt
(
lpDDSPrimary
,
&
dstrect
,
lpDDSBuffer
,
&
srcrect
,
0
,
NULL
);
}
}
byte
keys
[
256
];
byte
oldk
[
256
];
void
keyboard_handler
(
int
,
int
);
int
DIKToScancode
(
int
i
)
{
switch
(
i
)
{
case
DIK_LEFT
:
return
sc_LeftArrow
;
case
DIK_RIGHT
:
return
sc_RightArrow
;
case
DIK_UP
:
return
sc_UpArrow
;
case
DIK_DOWN
:
return
sc_DownArrow
;
default:
return
i
;
}
}
void
WolfDirectInputUpdateKeys
()
{
int
i
;
if
(
IDirectInputDevice_GetDeviceState
(
lpDIKeyboard
,
256
,
keys
)
!=
DI_OK
)
{
if
(
IDirectInputDevice_Acquire
(
lpDIKeyboard
)
!=
DI_OK
)
return
;
if
(
IDirectInputDevice_GetDeviceState
(
lpDIKeyboard
,
256
,
keys
)
!=
DI_OK
)
return
;
}
for
(
i
=
0
;
i
<
256
;
i
++
)
if
(
keys
[
i
]
!=
oldk
[
i
])
keyboard_handler
(
DIKToScancode
(
i
),
keys
[
i
]
?
1
:
0
);
memcpy
(
oldk
,
keys
,
sizeof
(
oldk
));
}
void
CheckEvents
()
{
MSG
msg
;
while
(
PeekMessage
(
&
msg
,
NULL
,
0
,
0
,
PM_REMOVE
))
{
if
(
msg
.
message
==
WM_QUIT
)
break
;
TranslateMessage
(
&
msg
);
DispatchMessage
(
&
msg
);
}
WolfDirectInputUpdateKeys
();
if
(
msg
.
message
==
WM_QUIT
)
exit
(
msg
.
wParam
);
}
HRESULT
CALLBACK
WndProc
(
HWND
hwnd
,
UINT
iMsg
,
WPARAM
wParam
,
LPARAM
lParam
)
{
PAINTSTRUCT
ps
;
HDC
hdc
;
switch
(
iMsg
)
{
case
WM_CREATE
:
#ifdef _DEBUG
AllocConsole
();
hCrt
=
_open_osfhandle
((
long
)
GetStdHandle
(
STD_OUTPUT_HANDLE
),
_O_TEXT
);
hf
=
_fdopen
(
hCrt
,
"w"
);
*
stdout
=
*
hf
;
setvbuf
(
stdout
,
NULL
,
_IONBF
,
0
);
*
stderr
=
*
hf
;
setvbuf
(
stderr
,
NULL
,
_IONBF
,
0
);
#endif
/* TODO */
_chdir
(
"C:
\\
wolfsrc
\\
src
\\
test
\\
"
);
/* - oh well, if path is not found, CWD will still be the same (for end user use) */
return
0
;
case
WM_COMMAND
:
break
;
case
WM_ERASEBKGND
:
break
;
case
WM_PAINT
:
hdc
=
BeginPaint
(
hwnd
,
&
ps
);
WolfDirectDrawPaint
(
hwnd
);
EndPaint
(
hwnd
,
&
ps
);
break
;
case
WM_CLOSE
:
IDirectDrawSurface_Release
(
lpDDSBuffer
);
IDirectDrawClipper_Release
(
lpDDC
);
IDirectDrawSurface_Release
(
lpDDSPrimary
);
IDirectDraw_Release
(
lpDD
);
#ifdef _DEBUG
FreeConsole
();
fclose
(
hf
);
close
(
hCrt
);
#endif
DestroyWindow
(
hwnd
);
return
0
;
case
WM_DESTROY
:
PostQuitMessage
(
0
);
return
0
;
}
return
DefWindowProc
(
hwnd
,
iMsg
,
wParam
,
lParam
);
}
void
VL_WaitVBL
(
int
vbls
)
{
}
void
VW_UpdateScreen
()
{
/* VL_WaitVBL(1); */
WolfDirectDrawPaint
();
}
/*
=======================
=
= VL_Startup
=
=======================
*/
void
VL_Startup
(
void
)
{
if
(
gfxbuf
==
NULL
)
gfxbuf
=
malloc
(
320
*
200
*
1
);
}
/*
=======================
=
= VL_Shutdown
=
=======================
*/
void
VL_Shutdown
(
void
)
{
if
(
gfxbuf
!=
NULL
)
{
free
(
gfxbuf
);
gfxbuf
=
NULL
;
}
}
//===========================================================================
/*
=================
=
= VL_ClearVideo
=
= Fill the entire video buffer with a given color
=
=================
*/
void
VL_ClearVideo
(
byte
color
)
{
memset
(
gfxbuf
,
color
,
64000
);
}
/*
=============================================================================
PALETTE OPS
To avoid snow, do a WaitVBL BEFORE calling these
=============================================================================
*/
/*
=================
=
= VL_FillPalette
=
=================
*/
void
VL_FillPalette
(
int
red
,
int
green
,
int
blue
)
{
int
i
;
for
(
i
=
0
;
i
<
256
;
i
++
)
{
mypal
[
i
*
3
+
0
]
=
red
;
mypal
[
i
*
3
+
1
]
=
green
;
mypal
[
i
*
3
+
2
]
=
blue
;
}
}
//===========================================================================
/*
=================
=
= VL_SetPalette
=
=================
*/
void
VL_SetPalette
(
const
byte
*
palette
)
{
memcpy
(
mypal
,
palette
,
768
);
VW_UpdateScreen
();
}
//===========================================================================
/*
=================
=
= VL_GetPalette
=
=================
*/
void
VL_GetPalette
(
byte
*
palette
)
{
memcpy
(
palette
,
mypal
,
768
);
}
/*
=============================================================================
PIXEL OPS
=============================================================================
*/
/*
=================
=
= VL_Plot
=
=================
*/
void
VL_Plot
(
int
x
,
int
y
,
int
color
)
{
*
(
gfxbuf
+
320
*
y
+
x
)
=
color
;
}
/*
=================
=
= VL_Hlin
=
=================
*/
void
VL_Hlin
(
unsigned
x
,
unsigned
y
,
unsigned
width
,
unsigned
color
)
{
memset
(
gfxbuf
+
320
*
y
+
x
,
color
,
width
);
}
/*
=================
=
= VL_Vlin
=
=================
*/
void
VL_Vlin
(
int
x
,
int
y
,
int
height
,
int
color
)
{
byte
*
ptr
=
gfxbuf
+
320
*
y
+
x
;
while
(
height
--
)
{
*
ptr
=
color
;
ptr
+=
320
;
}
}
/*
=================
=
= VL_Bar
=
=================
*/
void
VL_Bar
(
int
x
,
int
y
,
int
width
,
int
height
,
int
color
)
{
byte
*
ptr
=
gfxbuf
+
320
*
y
+
x
;
while
(
height
--
)
{
memset
(
ptr
,
color
,
width
);
ptr
+=
320
;
}
}
/*
============================================================================
MEMORY OPS
============================================================================
*/
/*
=================
=
= VL_MemToScreen
=
= Draws a block of data to the screen.
=
=================
*/
void
VL_MemToScreen
(
const
byte
*
source
,
int
width
,
int
height
,
int
x
,
int
y
)
{
byte
*
ptr
=
gfxbuf
+
320
*
y
+
x
;
while
(
height
--
)
{
memcpy
(
ptr
,
source
,
width
);
source
+=
width
;
ptr
+=
320
;
}
}
/* TODO: can this go in id_vh.c? */
void
VL_DeModeXize
(
byte
*
buf
,
int
width
,
int
height
)
{
byte
*
mem
,
*
ptr
,
*
destline
;
int
plane
,
x
,
y
;
if
(
width
&
3
)
{
printf
(
"Not divisible by 4?
\n
"
);
return
;
}
/* TODO: is there a better way without mallocing extra memory? */
mem
=
malloc
(
width
*
height
);
ptr
=
buf
;
for
(
plane
=
0
;
plane
<
4
;
plane
++
)
{
destline
=
mem
;
for
(
y
=
0
;
y
<
height
;
y
++
)
{
for
(
x
=
0
;
x
<
width
/
4
;
x
++
)
*
(
destline
+
x
*
4
+
plane
)
=
*
ptr
++
;
destline
+=
width
;
}
}
memcpy
(
buf
,
mem
,
width
*
height
);
free
(
mem
);
}
void
VL_DirectPlot
(
int
x1
,
int
y1
,
int
x2
,
int
y2
)
{
}
/*
=============================================================================
GLOBAL VARIABLES
=============================================================================
*/
//
// configuration variables
//
boolean
MousePresent
;
boolean
JoysPresent
[
MaxJoys
];
// Global variables
boolean
Keyboard
[
NumCodes
];
boolean
Paused
;
char
LastASCII
;
ScanCode
LastScan
;
KeyboardDef
KbdDefs
=
{
sc_Control
,
sc_Alt
,
sc_Home
,
sc_UpArrow
,
sc_PgUp
,
sc_LeftArrow
,
sc_RightArrow
,
sc_End
,
sc_DownArrow
,
sc_PgDn
};
ControlType
Controls
[
MaxPlayers
];
/*
=============================================================================
LOCAL VARIABLES
=============================================================================
*/
static
byte
ASCIINames
[]
=
// Unshifted ASCII for scan codes
{
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
0
,
27
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'0'
,
'-'
,
'='
,
8
,
9
,
// 0
'q'
,
'w'
,
'e'
,
'r'
,
't'
,
'y'
,
'u'
,
'i'
,
'o'
,
'p'
,
'['
,
']'
,
13
,
0
,
'a'
,
's'
,
// 1
'd'
,
'f'
,
'g'
,
'h'
,
'j'
,
'k'
,
'l'
,
';'
,
39
,
'`'
,
0
,
92
,
'z'
,
'x'
,
'c'
,
'v'
,
// 2
'b'
,
'n'
,
'm'
,
','
,
'.'
,
'/'
,
0
,
'*'
,
0
,
' '
,
0
,
0
,
0
,
0
,
0
,
0
,
// 3
0
,
0
,
0
,
0
,
0
,
0
,
0
,
'7'
,
'8'
,
'9'
,
'-'
,
'4'
,
'5'
,
'6'
,
'+'
,
'1'
,
// 4
'2'
,
'3'
,
'0'
,
127
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
// 5
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
// 6
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
// 7
},
ShiftNames
[]
=
// Shifted ASCII for scan codes
{
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
0
,
27
,
'!'
,
'@'
,
'#'
,
'$'
,
'%'
,
'^'
,
'&'
,
'*'
,
'('
,
')'
,
'_'
,
'+'
,
8
,
9
,
// 0
'Q'
,
'W'
,
'E'
,
'R'
,
'T'
,
'Y'
,
'U'
,
'I'
,
'O'
,
'P'
,
'{'
,
'}'
,
13
,
0
,
'A'
,
'S'
,
// 1
'D'
,
'F'
,
'G'
,
'H'
,
'J'
,
'K'
,
'L'
,
':'
,
34
,
'~'
,
0
,
'|'
,
'Z'
,
'X'
,
'C'
,
'V'
,
// 2
'B'
,
'N'
,
'M'
,
'<'
,
'>'
,
'?'
,
0
,
'*'
,
0
,
' '
,
0
,
0
,
0
,
0
,
0
,
0
,
// 3
0
,
0
,
0
,
0
,
0
,
0
,
0
,
'7'
,
'8'
,
'9'
,
'-'
,
'4'
,
'5'
,
'6'
,
'+'
,
'1'
,
// 4
'2'
,
'3'
,
'0'
,
127
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
// 5
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
// 6
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
// 7
},
SpecialNames
[]
=
// ASCII for 0xe0 prefixed codes
{
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
// 0
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
13
,
0
,
0
,
0
,
// 1
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
// 2
0
,
0
,
0
,
0
,
0
,
'/'
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
// 3
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
// 4
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
// 5
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
// 6
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
// 7
};
static
boolean
IN_Started
;
static
boolean
CapsLock
;
static
ScanCode
CurCode
,
LastCode
;
static
Direction
DirTable
[]
=
// Quick lookup for total direction
{
dir_NorthWest
,
dir_North
,
dir_NorthEast
,
dir_West
,
dir_None
,
dir_East
,
dir_SouthWest
,
dir_South
,
dir_SouthEast
};
// Internal routines
void
keyboard_handler
(
int
code
,
int
press
)
{
static
boolean
special
;
byte
k
,
c
;
k
=
code
;
if
(
k
==
0xe0
)
// Special key prefix
special
=
true
;
else
if
(
k
==
0xE1
)
// Handle Pause key
Paused
=
true
;
else
{
if
(
press
==
0
)
{
// DEBUG - handle special keys: ctl-alt-delete, print scrn
Keyboard
[
k
]
=
false
;
}
else
// Make code
{
LastCode
=
CurCode
;
CurCode
=
LastScan
=
k
;
Keyboard
[
k
]
=
true
;
if
(
special
)
c
=
SpecialNames
[
k
];
else
{
if
(
k
==
sc_CapsLock
)
{
CapsLock
^=
true
;
}
if
(
Keyboard
[
sc_LShift
]
||
Keyboard
[
sc_RShift
])
// If shifted
{
c
=
ShiftNames
[
k
];
if
((
c
>=
'A'
)
&&
(
c
<=
'Z'
)
&&
CapsLock
)
c
+=
'a'
-
'A'
;
}
else
{
c
=
ASCIINames
[
k
];
if
((
c
>=
'a'
)
&&
(
c
<=
'z'
)
&&
CapsLock
)
c
-=
'a'
-
'A'
;
}
}
if
(
c
)
LastASCII
=
c
;
}
special
=
false
;
}
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetMouseDelta() - Gets the amount that the mouse has moved from the
// mouse driver
//
///////////////////////////////////////////////////////////////////////////
static
void
INL_GetMouseDelta
(
int
*
x
,
int
*
y
)
{
*
x
=
0
;
*
y
=
0
;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetMouseButtons() - Gets the status of the mouse buttons from the
// mouse driver
//
///////////////////////////////////////////////////////////////////////////
static
word
INL_GetMouseButtons
(
void
)
{
return
0
;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_GetJoyAbs() - Reads the absolute position of the specified joystick
//
///////////////////////////////////////////////////////////////////////////
void
IN_GetJoyAbs
(
word
joy
,
word
*
xp
,
word
*
yp
)
{
*
xp
=
0
;
*
yp
=
0
;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetJoyDelta() - Returns the relative movement of the specified
// joystick (from +/-127)
//
///////////////////////////////////////////////////////////////////////////
void
INL_GetJoyDelta
(
word
joy
,
int
*
dx
,
int
*
dy
)
{
*
dx
=
0
;
*
dy
=
0
;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetJoyButtons() - Returns the button status of the specified
// joystick
//
///////////////////////////////////////////////////////////////////////////
static
word
INL_GetJoyButtons
(
word
joy
)
{
return
0
;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_StartKbd() - Sets up my keyboard stuff for use
//
///////////////////////////////////////////////////////////////////////////
static
void
INL_StartKbd
(
void
)
{
IN_ClearKeysDown
();
}
///////////////////////////////////////////////////////////////////////////
//
// INL_ShutKbd() - Restores keyboard control to the BIOS
//
///////////////////////////////////////////////////////////////////////////
static
void
INL_ShutKbd
(
void
)
{
}
///////////////////////////////////////////////////////////////////////////
//
// INL_StartMouse() - Detects and sets up the mouse
//
///////////////////////////////////////////////////////////////////////////
static
boolean
INL_StartMouse
(
void
)
{
return
false
;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_ShutMouse() - Cleans up after the mouse
//
///////////////////////////////////////////////////////////////////////////
static
void
INL_ShutMouse
(
void
)
{
}
///////////////////////////////////////////////////////////////////////////
//
// IN_SetupJoy() - Sets up thresholding values and calls INL_SetJoyScale()
// to set up scaling values
//
///////////////////////////////////////////////////////////////////////////
void
IN_SetupJoy
(
word
joy
,
word
minx
,
word
maxx
,
word
miny
,
word
maxy
)
{
}
///////////////////////////////////////////////////////////////////////////
//
// INL_StartJoy() - Detects & auto-configures the specified joystick
// The auto-config assumes the joystick is centered
//
///////////////////////////////////////////////////////////////////////////
static
boolean
INL_StartJoy
(
word
joy
)
{
return
false
;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_ShutJoy() - Cleans up the joystick stuff
//
///////////////////////////////////////////////////////////////////////////
static
void
INL_ShutJoy
(
word
joy
)
{
JoysPresent
[
joy
]
=
false
;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_Startup() - Starts up the Input Mgr
//
///////////////////////////////////////////////////////////////////////////
void
IN_Startup
(
void
)
{
boolean
checkjoys
,
checkmouse
;
word
i
;
if
(
IN_Started
)
return
;
checkjoys
=
true
;
checkmouse
=
true
;
if
(
MS_CheckParm
(
"nojoy"
))
checkjoys
=
false
;
if
(
MS_CheckParm
(
"nomouse"
))
checkmouse
=
false
;
INL_StartKbd
();
MousePresent
=
checkmouse
?
INL_StartMouse
()
:
false
;
for
(
i
=
0
;
i
<
MaxJoys
;
i
++
)
JoysPresent
[
i
]
=
checkjoys
?
INL_StartJoy
(
i
)
:
false
;
IN_Started
=
true
;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_Shutdown() - Shuts down the Input Mgr
//
///////////////////////////////////////////////////////////////////////////
void
IN_Shutdown
(
void
)
{
word
i
;
if
(
!
IN_Started
)
return
;
INL_ShutMouse
();
for
(
i
=
0
;
i
<
MaxJoys
;
i
++
)
INL_ShutJoy
(
i
);
INL_ShutKbd
();
IN_Started
=
false
;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_ClearKeysDown() - Clears the keyboard array
//
///////////////////////////////////////////////////////////////////////////
void
IN_ClearKeysDown
(
void
)
{
LastScan
=
sc_None
;
LastASCII
=
key_None
;
memset
(
Keyboard
,
0
,
sizeof
(
Keyboard
));
}
///////////////////////////////////////////////////////////////////////////
//
// IN_ReadControl() - Reads the device associated with the specified
// player and fills in the control info struct
//
///////////////////////////////////////////////////////////////////////////
void
IN_ReadControl
(
int
player
,
ControlInfo
*
info
)
{
boolean
realdelta
=
false
;
word
buttons
;
int
dx
,
dy
;
Motion
mx
,
my
;
ControlType
type
;
KeyboardDef
*
def
;
dx
=
dy
=
0
;
mx
=
my
=
motion_None
;
buttons
=
0
;
IN_CheckAck
();
switch
(
type
=
Controls
[
player
])
{
case
ctrl_Keyboard
:
def
=
&
KbdDefs
;
if
(
Keyboard
[
def
->
upleft
])
mx
=
motion_Left
,
my
=
motion_Up
;
else
if
(
Keyboard
[
def
->
upright
])
mx
=
motion_Right
,
my
=
motion_Up
;
else
if
(
Keyboard
[
def
->
downleft
])
mx
=
motion_Left
,
my
=
motion_Down
;
else
if
(
Keyboard
[
def
->
downright
])
mx
=
motion_Right
,
my
=
motion_Down
;
if
(
Keyboard
[
def
->
up
])
my
=
motion_Up
;
else
if
(
Keyboard
[
def
->
down
])
my
=
motion_Down
;
if
(
Keyboard
[
def
->
left
])
mx
=
motion_Left
;
else
if
(
Keyboard
[
def
->
right
])
mx
=
motion_Right
;
if
(
Keyboard
[
def
->
button0
])
buttons
+=
1
<<
0
;
if
(
Keyboard
[
def
->
button1
])
buttons
+=
1
<<
1
;
realdelta
=
false
;
break
;
case
ctrl_Joystick1
:
case
ctrl_Joystick2
:
INL_GetJoyDelta
(
type
-
ctrl_Joystick
,
&
dx
,
&
dy
);
buttons
=
INL_GetJoyButtons
(
type
-
ctrl_Joystick
);
realdelta
=
true
;
break
;
case
ctrl_Mouse
:
INL_GetMouseDelta
(
&
dx
,
&
dy
);
buttons
=
INL_GetMouseButtons
();
realdelta
=
true
;
break
;
}
if
(
realdelta
)
{
mx
=
(
dx
<
0
)
?
motion_Left
:
((
dx
>
0
)
?
motion_Right
:
motion_None
);
my
=
(
dy
<
0
)
?
motion_Up
:
((
dy
>
0
)
?
motion_Down
:
motion_None
);
}
else
{
dx
=
mx
*
127
;
dy
=
my
*
127
;
}
info
->
x
=
dx
;
info
->
xaxis
=
mx
;
info
->
y
=
dy
;
info
->
yaxis
=
my
;
info
->
button0
=
buttons
&
(
1
<<
0
);
info
->
button1
=
buttons
&
(
1
<<
1
);
info
->
button2
=
buttons
&
(
1
<<
2
);
info
->
button3
=
buttons
&
(
1
<<
3
);
info
->
dir
=
DirTable
[((
my
+
1
)
*
3
)
+
(
mx
+
1
)];
}
///////////////////////////////////////////////////////////////////////////
//
// IN_Ack() - waits for a button or key press. If a button is down, upon
// calling, it must be released for it to be recognized
//
///////////////////////////////////////////////////////////////////////////
boolean
btnstate
[
8
];
void
IN_StartAck
(
void
)
{
unsigned
i
,
buttons
;
//
// get initial state of everything
//
IN_ClearKeysDown
();
memset
(
btnstate
,
0
,
sizeof
(
btnstate
));
buttons
=
IN_JoyButtons
()
<<
4
;
if
(
MousePresent
)
buttons
|=
IN_MouseButtons
();
for
(
i
=
0
;
i
<
8
;
i
++
,
buttons
>>=
1
)
if
(
buttons
&
1
)
btnstate
[
i
]
=
true
;
}
boolean
IN_CheckAck
(
void
)
{
unsigned
i
,
buttons
;
CheckEvents
();
/* get all events */
if
(
LastScan
)
return
true
;
buttons
=
IN_JoyButtons
()
<<
4
;
if
(
MousePresent
)
buttons
|=
IN_MouseButtons
();
for
(
i
=
0
;
i
<
8
;
i
++
,
buttons
>>=
1
)
if
(
buttons
&
1
)
{
if
(
!
btnstate
[
i
])
return
true
;
}
else
btnstate
[
i
]
=
false
;
return
false
;
}
void
IN_Ack
(
void
)
{
IN_StartAck
();
// return; /* TODO: fix when keyboard implemented */
while
(
!
IN_CheckAck
())
;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_UserInput() - Waits for the specified delay time (in ticks) or the
// user pressing a key or a mouse button. If the clear flag is set, it
// then either clears the key or waits for the user to let the mouse
// button up.
//
///////////////////////////////////////////////////////////////////////////
boolean
IN_UserInput
(
longword
delay
)
{
longword
lasttime
;
lasttime
=
get_TimeCount
();
IN_StartAck
();
do
{
if
(
IN_CheckAck
())
return
true
;
}
while
(
(
get_TimeCount
()
-
lasttime
)
<
delay
);
return
false
;
}
//===========================================================================
/*
===================
=
= IN_MouseButtons
=
===================
*/
byte
IN_MouseButtons
(
void
)
{
return
0
;
}
/*
===================
=
= IN_JoyButtons
=
===================
*/
byte
IN_JoyButtons
(
void
)
{
return
0
;
}
src/vi_xlib.c
View file @
fd76d414
/* id_vl.c */
/* id_vl.c */
#include "
id_heads
.h"
#include "
wl_def
.h"
#include <sys/ipc.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/shm.h>
...
@@ -44,6 +44,41 @@ int main(int argc, char *argv[])
...
@@ -44,6 +44,41 @@ int main(int argc, char *argv[])
return
WolfMain
(
argc
,
argv
);
return
WolfMain
(
argc
,
argv
);
}
}
/*
==========================
=
= Quit
=
==========================
*/
void
Quit
(
char
*
error
)
{
/* TODO: blah blah blah */
memptr
screen
=
NULL
;
if
(
!
error
||
!*
error
)
{
CA_CacheGrChunk
(
ORDERSCREEN
);
screen
=
grsegs
[
ORDERSCREEN
];
WriteConfig
();
}
else
if
(
error
)
{
CA_CacheGrChunk
(
ERRORSCREEN
);
screen
=
grsegs
[
ERRORSCREEN
];
}
ShutdownId
();
if
(
screen
)
{
printf
(
"TODO: spiffy ansi screen goes here..
\n
"
);
}
if
(
error
&&
*
error
)
{
fprintf
(
stderr
,
"Quit: %s"
,
error
);
exit
(
EXIT_FAILURE
);
}
exit
(
EXIT_SUCCESS
);
}
/*
/*
=======================
=======================
=
=
...
@@ -470,6 +505,7 @@ void VL_SetPalette(const byte *palette)
...
@@ -470,6 +505,7 @@ void VL_SetPalette(const byte *palette)
}
}
XStoreColors
(
dpy
,
cmap
,
clr
,
256
);
XStoreColors
(
dpy
,
cmap
,
clr
,
256
);
}
else
{
}
else
{
/* TODO: memcpy? */
for
(
i
=
0
;
i
<
256
;
i
++
)
{
for
(
i
=
0
;
i
<
256
;
i
++
)
{
mypal
[
i
*
3
+
0
]
=
palette
[
i
*
3
+
0
];
mypal
[
i
*
3
+
0
]
=
palette
[
i
*
3
+
0
];
mypal
[
i
*
3
+
1
]
=
palette
[
i
*
3
+
1
];
mypal
[
i
*
3
+
1
]
=
palette
[
i
*
3
+
1
];
...
@@ -606,7 +642,7 @@ void VL_Bar(int x, int y, int width, int height, int color)
...
@@ -606,7 +642,7 @@ void VL_Bar(int x, int y, int width, int height, int color)
=================
=================
*/
*/
void
VL_MemToScreen
(
byte
*
source
,
int
width
,
int
height
,
int
x
,
int
y
)
void
VL_MemToScreen
(
const
byte
*
source
,
int
width
,
int
height
,
int
x
,
int
y
)
{
{
byte
*
ptr
=
gfxbuf
+
320
*
y
+
x
;
byte
*
ptr
=
gfxbuf
+
320
*
y
+
x
;
while
(
height
--
)
{
while
(
height
--
)
{
...
...
src/wl_act2.c
View file @
fd76d414
...
@@ -1612,8 +1612,8 @@ void T_Launch (objtype *ob)
...
@@ -1612,8 +1612,8 @@ void T_Launch (objtype *ob)
deltay
=
ob
->
y
-
player
->
y
;
deltay
=
ob
->
y
-
player
->
y
;
angle
=
atan2
(
deltay
,
deltax
);
angle
=
atan2
(
deltay
,
deltax
);
if
(
angle
<
0
)
if
(
angle
<
0
)
angle
=
M_
PI
*
2
+
angle
;
angle
=
PI
*
2
+
angle
;
iangle
=
angle
/
(
M_
PI
*
2
)
*
ANGLES
;
iangle
=
angle
/
(
PI
*
2
)
*
ANGLES
;
if
(
ob
->
obclass
==
deathobj
)
if
(
ob
->
obclass
==
deathobj
)
{
{
T_Shoot
(
ob
);
T_Shoot
(
ob
);
...
@@ -2269,8 +2269,8 @@ void T_SchabbThrow (objtype *ob)
...
@@ -2269,8 +2269,8 @@ void T_SchabbThrow (objtype *ob)
deltay
=
ob
->
y
-
player
->
y
;
deltay
=
ob
->
y
-
player
->
y
;
angle
=
atan2
(
deltay
,
deltax
);
angle
=
atan2
(
deltay
,
deltax
);
if
(
angle
<
0
)
if
(
angle
<
0
)
angle
=
M_
PI
*
2
+
angle
;
angle
=
PI
*
2
+
angle
;
iangle
=
angle
/
(
M_
PI
*
2
)
*
ANGLES
;
iangle
=
angle
/
(
PI
*
2
)
*
ANGLES
;
GetNewActor
();
GetNewActor
();
new
->
state
=
&
s_needle1
;
new
->
state
=
&
s_needle1
;
...
@@ -2311,8 +2311,8 @@ void T_GiftThrow (objtype *ob)
...
@@ -2311,8 +2311,8 @@ void T_GiftThrow (objtype *ob)
deltay
=
ob
->
y
-
player
->
y
;
deltay
=
ob
->
y
-
player
->
y
;
angle
=
atan2
(
deltay
,
deltax
);
angle
=
atan2
(
deltay
,
deltax
);
if
(
angle
<
0
)
if
(
angle
<
0
)
angle
=
M_
PI
*
2
+
angle
;
angle
=
PI
*
2
+
angle
;
iangle
=
angle
/
(
M_
PI
*
2
)
*
ANGLES
;
iangle
=
angle
/
(
PI
*
2
)
*
ANGLES
;
GetNewActor
();
GetNewActor
();
new
->
state
=
&
s_rocket
;
new
->
state
=
&
s_rocket
;
...
@@ -2902,8 +2902,8 @@ void T_FakeFire (objtype *ob)
...
@@ -2902,8 +2902,8 @@ void T_FakeFire (objtype *ob)
deltay
=
ob
->
y
-
player
->
y
;
deltay
=
ob
->
y
-
player
->
y
;
angle
=
atan2
(
deltay
,
deltax
);
angle
=
atan2
(
deltay
,
deltax
);
if
(
angle
<
0
)
if
(
angle
<
0
)
angle
=
M_
PI
*
2
+
angle
;
angle
=
PI
*
2
+
angle
;
iangle
=
angle
/
(
M_
PI
*
2
)
*
ANGLES
;
iangle
=
angle
/
(
PI
*
2
)
*
ANGLES
;
GetNewActor
();
GetNewActor
();
new
->
state
=
&
s_fire1
;
new
->
state
=
&
s_fire1
;
...
@@ -3766,9 +3766,9 @@ void A_StartDeathCam (objtype *ob)
...
@@ -3766,9 +3766,9 @@ void A_StartDeathCam (objtype *ob)
fangle
=
atan2
(
dy
,
dx
);
// returns -pi to pi
fangle
=
atan2
(
dy
,
dx
);
// returns -pi to pi
if
(
fangle
<
0
)
if
(
fangle
<
0
)
fangle
=
M_
PI
*
2
+
fangle
;
fangle
=
PI
*
2
+
fangle
;
player
->
angle
=
fangle
/
(
M_
PI
*
2
)
*
ANGLES
;
player
->
angle
=
fangle
/
(
PI
*
2
)
*
ANGLES
;
//
//
// try to position as close as possible without being in a wall
// try to position as close as possible without being in a wall
...
...
src/wl_def.h
View file @
fd76d414
...
@@ -726,7 +726,9 @@ boolean LoadTheGame(int file,int x,int y);
...
@@ -726,7 +726,9 @@ boolean LoadTheGame(int file,int x,int y);
boolean
SaveTheGame
(
int
file
,
int
x
,
int
y
);
boolean
SaveTheGame
(
int
file
,
int
x
,
int
y
);
void
ShowViewSize
(
int
width
);
void
ShowViewSize
(
int
width
);
void
ShutdownId
(
void
);
void
ShutdownId
(
void
);
void
WriteConfig
(
void
);
int
WolfMain
(
int
argc
,
char
*
argv
[]);
/*
/*
=============================================================================
=============================================================================
...
...
src/wl_draw.c
View file @
fd76d414
...
@@ -847,7 +847,7 @@ void AsmRefresh (void)
...
@@ -847,7 +847,7 @@ void AsmRefresh (void)
ytile
+=
ytilestep
;
ytile
+=
ytilestep
;
xintercept
+=
xstep
;
xintercept
+=
xstep
;
goto
horizcheck
;
goto
horizcheck
;
nextpix:
nextpix:
;
}
}
}
}
...
...
src/wl_game.c
View file @
fd76d414
...
@@ -962,9 +962,9 @@ void Died()
...
@@ -962,9 +962,9 @@ void Died()
fangle
=
atan2
(
dy
,
dx
);
// returns -pi to pi
fangle
=
atan2
(
dy
,
dx
);
// returns -pi to pi
if
(
fangle
<
0
)
if
(
fangle
<
0
)
fangle
=
M_
PI
*
2
+
fangle
;
fangle
=
PI
*
2
+
fangle
;
iangle
=
fangle
/
(
M_
PI
*
2
)
*
ANGLES
;
iangle
=
fangle
/
(
PI
*
2
)
*
ANGLES
;
if
(
player
->
angle
>
iangle
)
if
(
player
->
angle
>
iangle
)
{
{
...
...
src/wl_inter.c
View file @
fd76d414
...
@@ -1277,8 +1277,7 @@ void CopyProtection(void)
...
@@ -1277,8 +1277,7 @@ void CopyProtection(void)
whichone
,
whichpicked
[
4
]
=
{
0
,
0
,
0
,
0
},
quiztype
,
whichmem
,
whichone
,
whichpicked
[
4
]
=
{
0
,
0
,
0
,
0
},
quiztype
,
whichmem
,
memberpicked
[
5
]
=
{
0
,
0
,
0
,
0
,
0
},
wordpicked
[
5
]
=
{
0
,
0
,
0
,
0
,
0
},
whichword
;
memberpicked
[
5
]
=
{
0
,
0
,
0
,
0
,
0
},
wordpicked
[
5
]
=
{
0
,
0
,
0
,
0
,
0
},
whichword
;
char
inputbuffer
[
20
],
char
message
[
30
],
inputbuffer
[
20
];
message
[
80
];
enum
enum
{
{
...
@@ -1485,13 +1484,7 @@ void CopyProtection(void)
...
@@ -1485,13 +1484,7 @@ void CopyProtection(void)
}
}
}
}
ClearMemory
();
Quit
(
DosMessages
[
US_RndT
()
%
9
]);
ShutdownId
();
strcpy
(
message
,
DosMessages
[
US_RndT
()
%
9
]);
printf
(
"%s
\n
"
,
message
);
exit
(
1
);
}
}
#endif // SPEARDEMO
#endif // SPEARDEMO
...
...
src/wl_main.c
View file @
fd76d414
...
@@ -85,9 +85,9 @@ char **_argv;
...
@@ -85,9 +85,9 @@ char **_argv;
fixed
FixedByFrac
(
fixed
a
,
fixed
b
)
fixed
FixedByFrac
(
fixed
a
,
fixed
b
)
{
{
long
long
ra
=
a
;
LONGLONG
ra
=
a
;
long
long
rb
=
b
;
LONGLONG
rb
=
b
;
long
long
r
;
LONGLONG
r
;
r
=
ra
*
rb
;
r
=
ra
*
rb
;
r
>>=
16
;
r
>>=
16
;
...
@@ -138,7 +138,7 @@ void ReadConfig(void)
...
@@ -138,7 +138,7 @@ void ReadConfig(void)
SMMode
sm
;
SMMode
sm
;
SDSMode
sds
;
SDSMode
sds
;
#if 0 /* TODO */
if ( (file = open(configname,O_BINARY | O_RDONLY)) != -1)
if ( (file = open(configname,O_BINARY | O_RDONLY)) != -1)
{
{
//
//
...
@@ -184,6 +184,7 @@ void ReadConfig(void)
...
@@ -184,6 +184,7 @@ void ReadConfig(void)
MainItems.curpos=0;
MainItems.curpos=0;
}
}
else
else
#endif
{
{
//
//
// no config file, so select by hardware
// no config file, so select by hardware
...
@@ -521,15 +522,15 @@ boolean LoadTheGame(int file,int x,int y)
...
@@ -521,15 +522,15 @@ boolean LoadTheGame(int file,int x,int y)
==========================
==========================
*/
*/
void
ShutdownId
(
void
)
void
ShutdownId
(
)
{
{
US_Shutdown
();
US_Shutdown
();
SD_Shutdown
();
SD_Shutdown
();
PM_Shutdown
();
IN_Shutdown
();
IN_Shutdown
();
VW_Shutdown
();
VW_Shutdown
();
CA_Shutdown
();
CA_Shutdown
();
PM_Shutdown
();
MM_Shutdown
();
MM_Shutdown
();
}
}
...
@@ -605,8 +606,6 @@ void BuildTables (void)
...
@@ -605,8 +606,6 @@ void BuildTables (void)
====================
====================
*/
*/
#include <sys/mman.h>
void
CalcProjection
(
long
focal
)
void
CalcProjection
(
long
focal
)
{
{
int
i
;
int
i
;
...
@@ -1153,14 +1152,14 @@ boolean SetViewSize(unsigned width, unsigned height)
...
@@ -1153,14 +1152,14 @@ boolean SetViewSize(unsigned width, unsigned height)
void
ShowViewSize
(
int
width
)
void
ShowViewSize
(
int
width
)
{
{
int
oldwidth
,
oldheight
;
int
oldwidth
,
oldheight
;
oldwidth
=
viewwidth
;
oldwidth
=
viewwidth
;
oldheight
=
viewheight
;
oldheight
=
viewheight
;
viewwidth
=
width
*
16
;
viewwidth
=
width
*
16
;
viewheight
=
width
*
16
*
HEIGHTRATIO
;
viewheight
=
width
*
16
*
HEIGHTRATIO
;
DrawPlayBorder
();
DrawPlayBorder
();
viewheight
=
oldheight
;
viewheight
=
oldheight
;
viewwidth
=
oldwidth
;
viewwidth
=
oldwidth
;
...
@@ -1180,45 +1179,6 @@ void NewViewSize(int width)
...
@@ -1180,45 +1179,6 @@ void NewViewSize(int width)
//===========================================================================
//===========================================================================
/*
==========================
=
= Quit
=
==========================
*/
void
Quit
(
char
*
error
)
{
memptr
screen
=
NULL
;
if
(
!
error
||
!*
error
)
{
CA_CacheGrChunk
(
ORDERSCREEN
);
screen
=
grsegs
[
ORDERSCREEN
];
WriteConfig
();
}
else
if
(
error
)
{
CA_CacheGrChunk
(
ERRORSCREEN
);
screen
=
grsegs
[
ERRORSCREEN
];
}
ShutdownId
();
if
(
screen
)
{
printf
(
"TODO: spiffy ansi screen goes here..
\n
"
);
}
if
(
error
&&
*
error
)
{
fprintf
(
stderr
,
"Quit: %s
\n
"
,
error
);
exit
(
EXIT_FAILURE
);
}
exit
(
EXIT_SUCCESS
);
}
//===========================================================================
/*
/*
=====================
=====================
=
=
...
...
src/wl_menu.c
View file @
fd76d414
...
@@ -2603,7 +2603,8 @@ void DrawOutline(int x,int y,int w,int h,int color1,int color2)
...
@@ -2603,7 +2603,8 @@ void DrawOutline(int x,int y,int w,int h,int color1,int color2)
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
void
SetupControlPanel
(
void
)
void
SetupControlPanel
(
void
)
{
{
#if 0 /* DOS VERSION */
#ifdef DOSISM
/* DOS VERSION */
#ifdef HAVE_FFBLK
struct
ffblk
f
;
struct
ffblk
f
;
int
which
;
int
which
;
...
@@ -2629,8 +2630,8 @@ void SetupControlPanel(void)
...
@@ -2629,8 +2630,8 @@ void SetupControlPanel(void)
//
//
// SEE WHICH SAVE GAME FILES ARE AVAILABLE & READ STRING IN
// SEE WHICH SAVE GAME FILES ARE AVAILABLE & READ STRING IN
//
//
strcpy
(
name
,
SaveName
);
if
(
!
findfirst
(
n
ame
,
&
f
,
0
))
if
(
!
findfirst
(
SaveNa
ame
,
&
f
,
0
))
do
do
{
{
which
=
f
.
ff_name
[
7
]
-
'0'
;
which
=
f
.
ff_name
[
7
]
-
'0'
;
...
@@ -2647,6 +2648,53 @@ void SetupControlPanel(void)
...
@@ -2647,6 +2648,53 @@ void SetupControlPanel(void)
}
}
}
while
(
!
findnext
(
&
f
));
}
while
(
!
findnext
(
&
f
));
#else
#else
struct
_finddata_t
f
;
int
which
;
long
hand
;
//
// CACHE GRAPHICS & SOUNDS
//
CA_CacheGrChunk
(
STARTFONT
+
1
);
#ifndef SPEAR
CacheLump
(
CONTROLS_LUMP_START
,
CONTROLS_LUMP_END
);
#else
CacheLump
(
BACKDROP_LUMP_START
,
BACKDROP_LUMP_END
);
#endif
SETFONTCOLOR
(
TEXTCOLOR
,
BKGDCOLOR
);
fontnumber
=
1
;
WindowH
=
200
;
if
(
!
ingame
)
CA_LoadAllSounds
();
else
MainMenu
[
savegame
].
active
=
1
;
//
// SEE WHICH SAVE GAME FILES ARE AVAILABLE & READ STRING IN
//
if
((
hand
=
_findfirst
(
SaveName
,
&
f
))
!=
-
1
)
do
{
which
=
f
.
name
[
7
]
-
'0'
;
if
(
which
<
10
)
{
int
handle
;
char
temp
[
32
];
SaveGamesAvail
[
which
]
=
1
;
handle
=
open
(
f
.
name
,
O_BINARY
);
read
(
handle
,
temp
,
32
);
close
(
handle
);
strcpy
(
&
SaveGameNames
[
which
][
0
],
temp
);
}
}
while
(
_findnext
(
hand
,
&
f
)
!=
-
1
);
#endif
#else
glob_t
globbuf
;
glob_t
globbuf
;
int
which
,
x
;
int
which
,
x
;
...
@@ -3180,7 +3228,7 @@ void Message(char *string)
...
@@ -3180,7 +3228,7 @@ void Message(char *string)
CA_CacheGrChunk
(
STARTFONT
+
1
);
CA_CacheGrChunk
(
STARTFONT
+
1
);
fontnumber
=
1
;
fontnumber
=
1
;
font
=
grsegs
[
STARTFONT
+
fontnumber
];
font
=
(
fontstruct
*
)
grsegs
[
STARTFONT
+
fontnumber
];
h
=
font
->
height
;
h
=
font
->
height
;
for
(
i
=
0
;
i
<
strlen
(
string
);
i
++
)
for
(
i
=
0
;
i
<
strlen
(
string
);
i
++
)
if
(
string
[
i
]
==
'\n'
)
if
(
string
[
i
]
==
'\n'
)
...
@@ -3320,9 +3368,10 @@ void ShootSnd(void)
...
@@ -3320,9 +3368,10 @@ void ShootSnd(void)
// CHECK FOR EPISODES
// CHECK FOR EPISODES
//
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
void
CheckForEpisodes
(
void
)
void
CheckForEpisodes
()
{
{
#if 0 /* DOS VERSION */
#ifdef DOSISM
/* DOS VERSION */
#ifdef HAVE_FFBLK
struct
ffblk
f
;
struct
ffblk
f
;
//
//
// ENGLISH
// ENGLISH
...
@@ -3386,6 +3435,70 @@ void CheckForEpisodes(void)
...
@@ -3386,6 +3435,70 @@ void CheckForEpisodes(void)
strcat
(
SaveName
,
extension
);
strcat
(
SaveName
,
extension
);
strcat
(
PageFileName
,
extension
);
strcat
(
PageFileName
,
extension
);
#else
struct
_finddata_t
f
;
//
// ENGLISH
//
#ifndef UPLOAD
#ifndef SPEAR
if
(
_findfirst
(
"*.WL6"
,
&
f
)
!=
-
1
)
{
strcpy
(
extension
,
"WL6"
);
NewEmenu
[
2
].
active
=
NewEmenu
[
4
].
active
=
NewEmenu
[
6
].
active
=
NewEmenu
[
8
].
active
=
NewEmenu
[
10
].
active
=
EpisodeSelect
[
1
]
=
EpisodeSelect
[
2
]
=
EpisodeSelect
[
3
]
=
EpisodeSelect
[
4
]
=
EpisodeSelect
[
5
]
=
1
;
}
else
if
(
_findfirst
(
"*.WL3"
,
&
f
)
!=
-
1
)
{
strcpy
(
extension
,
"WL3"
);
NewEmenu
[
2
].
active
=
NewEmenu
[
4
].
active
=
EpisodeSelect
[
1
]
=
EpisodeSelect
[
2
]
=
1
;
}
else
#endif
/* SPEAR */
#endif
/* UPLOAD */
#ifdef SPEAR
#ifndef SPEARDEMO
if
(
_findfirst
(
"*.SOD"
,
&
f
)
!=
-
1
)
{
strcpy
(
extension
,
"SOD"
);
}
else
Quit
(
"NO SPEAR OF DESTINY DATA FILES TO BE FOUND!"
);
#else
/* SPEARDEMO */
if
(
_findfirst
(
"*.SDM"
,
&
f
)
!=
-
1
)
{
strcpy
(
extension
,
"SDM"
);
}
else
Quit
(
"NO SPEAR OF DESTINY DEMO DATA FILES TO BE FOUND!"
);
#endif
/* SPEARDEMO */
#else
/* SPEAR */
if
(
_findfirst
(
"*.WL1"
,
&
f
)
!=
-
1
)
{
strcpy
(
extension
,
"WL1"
);
}
else
Quit
(
"NO WOLFENSTEIN 3-D DATA FILES to be found!"
);
#endif
/* SPEAR */
strcat
(
configname
,
extension
);
strcat
(
SaveName
,
extension
);
strcat
(
PageFileName
,
extension
);
#endif
#else
#else
glob_t
globbuf
;
glob_t
globbuf
;
//
//
...
...
src/wl_play.c
View file @
fd76d414
...
@@ -996,7 +996,9 @@ boolean palshifted;
...
@@ -996,7 +996,9 @@ boolean palshifted;
void
InitRedShifts
(
void
)
void
InitRedShifts
(
void
)
{
{
byte
*
workptr
,
*
baseptr
;
byte
*
workptr
;
const
byte
*
baseptr
;
int
i
,
j
,
delta
;
int
i
,
j
,
delta
;
...
...
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