Commit b76bc11f authored by Steven Fuller's avatar Steven Fuller

sd_comm.c, wl_main.c: Moved InitDigiList to its own file.

wl_inter.c, id_ca.c: Removed PM_Preload, PreloadGraphics can do it itself.

id_ca.c: Added a PM_FreePage

sd_oal.c: Working OpenAL implementation. (no adlib sound yet)
parent 04cd0215
......@@ -10,7 +10,7 @@ CFLAGS = -g -Wall -pedantic
OBJS = objs.o misc.o id_ca.o id_vh.o id_us.o \
wl_act1.o wl_act2.o wl_act3.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_debug.o vi_comm.o
wl_debug.o vi_comm.o sd_comm.o
ROBJS = wl_draw.o
SOBJS = $(OBJS) $(ROBJS) vi_svga.o
XOBJS = $(OBJS) $(ROBJS) vi_xlib.o
......@@ -23,8 +23,10 @@ OBJS += sd_null.o
#CFLAGS += -D_REENTRANT
#LFLAGS += -lpthread
#OBJS += sd_oal.o
#CFLAGS += -D_REENTRANT
#LFLAGS += -lpthread #-lopenal
#CFLAGS += -D_REENTRANT -I/home/relnev/cvs/oal/include/
#LFLAGS += -lpthread -ldl -L/home/relnev/cvs/oal/linux/src/ -lopenal # /home/relnev/cvs/oal/linux/src/libopenal.a
#LFLAGS += -lpthread /home/relnev/ElectricFence-2.2.2/libefence.a
CFLAGS += `sdl-config --cflags`
......
......@@ -6,7 +6,7 @@ Just some random facts/thoughts/ideas/musings:
- SNES
- Macintosh
- Jaguar
- Apple IIGS [http://www.sheppyware.com/products/a2/wolf3d/]
- Apple IIGS: http://www.sheppyware.com/products/a2/wolf3d/
- 3DO
* Rumored/Never Released?
......@@ -20,8 +20,10 @@ Just some random facts/thoughts/ideas/musings:
- Linux (this, xwolf, wolfgl)
XWolf: http://www.sirius.demon.co.uk/xwolf/
- Amiga (port of my first pc wolf3d linux port)
[http://www.silab.dsi.unimi.it/~cs556770/wolf3d/]
- Windows (wolfgl) [http://www.sourceforge.net/projects/wolfgl/]
http://www.silab.dsi.unimi.it/~cs556770/wolf3d/
- Windows
WolfGL: http://www.sourceforge.net/projects/wolfgl/
Wolf DX: http://www.phoebe.co.uk/glwolf/
- Acorn/Archemedes
* PC source released August(?) ??, 1995:
......@@ -32,10 +34,10 @@ Just some random facts/thoughts/ideas/musings:
- http://www.wolf3dmansion.com/index.phtml
* Macintosh source released January 21, 2000
- http://www.maccentral.com/news/0001/24.wolf3d.shtml
* TED5 source (editor used for tons of games including wolf3d)
* TED5 source (map editor used for tons of games including wolf3d)
- ftp://ftp.3drealms.com/misc/ted5.zip
* Games which used the Wolfenstein 3D Engine:
- Blake Stone
- Blake Stone (Aliens of Gold, Planet Strike)
- Corridor 7
- Operation Body Count
......
......@@ -31,6 +31,9 @@ B I - add mouse support
B M - add joystick/gamepad support
P I - fill in the new fizzlefade function
P I - add sound "emulation" to the necessary targets so WaitSoundDone works
B R - autoconf/automake
P R - change boolean SD_PlaySound to void SD_PlaySound
P M - position pushwall sounds
Complete:
P I - fix or remove fizzle fade
......
......@@ -833,13 +833,18 @@ memptr PM_GetPage(int pagenum)
return page->addr;
}
void PM_Preload(boolean (*update)(int current, int total))
void PM_FreePage(int pagenum)
{
int i;
PageListStruct *page;
if (pagenum >= ChunksInFile)
Quit("PM_FreePage: Invalid page request");
for (i = 0; i < 50; i++)
update(i, 50); /* yay */
update(50, 50);
page = &PMPages[pagenum];
if (page->addr != NULL) {
MM_FreePtr((memptr)&page->addr);
page->addr = NULL;
}
}
void PM_Startup()
......
......@@ -72,11 +72,10 @@ extern PageListStruct *PMPages;
#define PM_GetSoundPage(v) PM_GetPage(PMSoundStart + (v))
#define PM_GetSpritePage(v) PM_GetPage(PMSpriteStart + (v))
memptr PM_GetPage(int pagenum);
void PM_FreePage(int pagenum);
void PM_Startup();
void PM_Shutdown();
void PM_Preload(boolean (*update)(int current, int total));
memptr PM_GetPage(int pagenum);
#endif
#include "wl_def.h"
/*
=====================
=
= InitDigiMap
=
=====================
*/
int DigiMap[LASTSOUND];
static int wolfdigimap[] =
{
#ifndef SPEAR
HALTSND, 0,
DOGBARKSND, 1,
CLOSEDOORSND, 2,
OPENDOORSND, 3,
ATKMACHINEGUNSND, 4,
ATKPISTOLSND, 5,
ATKGATLINGSND, 6,
SCHUTZADSND, 7,
GUTENTAGSND, 8,
MUTTISND, 9,
BOSSFIRESND, 10,
SSFIRESND, 11,
DEATHSCREAM1SND, 12,
DEATHSCREAM2SND, 13,
DEATHSCREAM3SND, 13,
TAKEDAMAGESND, 14,
PUSHWALLSND, 15,
LEBENSND, 20,
NAZIFIRESND, 21,
SLURPIESND, 22,
YEAHSND, 32,
#ifndef UPLOAD
DOGDEATHSND, 16,
AHHHGSND, 17,
DIESND, 18,
EVASND, 19,
TOT_HUNDSND, 23,
MEINGOTTSND, 24,
SCHABBSHASND, 25,
HITLERHASND, 26,
SPIONSND, 27,
NEINSOVASSND, 28,
DOGATTACKSND, 29,
LEVELDONESND, 30,
MECHSTEPSND, 31,
SCHEISTSND, 33,
DEATHSCREAM4SND, 34, /* AIIEEE */
DEATHSCREAM5SND, 35, /* DEE-DEE */
DONNERSND, 36, /* EPISODE 4 BOSS DIE */
EINESND, 37, /* EPISODE 4 BOSS SIGHTING */
ERLAUBENSND, 38, /* EPISODE 6 BOSS SIGHTING */
DEATHSCREAM6SND, 39, /* FART */
DEATHSCREAM7SND, 40, /* GASP */
DEATHSCREAM8SND, 41, /* GUH-BOY! */
DEATHSCREAM9SND, 42, /* AH GEEZ! */
KEINSND, 43, /* EPISODE 5 BOSS SIGHTING */
MEINSND, 44, /* EPISODE 6 BOSS DIE */
ROSESND, 45, /* EPISODE 5 BOSS DIE */
#endif
#else /* SPEAR OF DESTINY DIGISOUNDS */
HALTSND, 0,
CLOSEDOORSND, 2,
OPENDOORSND, 3,
ATKMACHINEGUNSND, 4,
ATKPISTOLSND, 5,
ATKGATLINGSND, 6,
SCHUTZADSND, 7,
BOSSFIRESND, 8,
SSFIRESND, 9,
DEATHSCREAM1SND, 10,
DEATHSCREAM2SND, 11,
TAKEDAMAGESND, 12,
PUSHWALLSND, 13,
AHHHGSND, 15,
LEBENSND, 16,
NAZIFIRESND, 17,
SLURPIESND, 18,
LEVELDONESND, 22,
DEATHSCREAM4SND, 23, // AIIEEE
DEATHSCREAM3SND, 23, // DOUBLY-MAPPED!!!
DEATHSCREAM5SND, 24, // DEE-DEE
DEATHSCREAM6SND, 25, // FART
DEATHSCREAM7SND, 26, // GASP
DEATHSCREAM8SND, 27, // GUH-BOY!
DEATHSCREAM9SND, 28, // AH GEEZ!
GETGATLINGSND, 38, // Got Gat replacement
#ifndef SPEARDEMO
DOGBARKSND, 1,
DOGDEATHSND, 14,
SPIONSND, 19,
NEINSOVASSND, 20,
DOGATTACKSND, 21,
TRANSSIGHTSND, 29, // Trans Sight
TRANSDEATHSND, 30, // Trans Death
WILHELMSIGHTSND, 31, // Wilhelm Sight
WILHELMDEATHSND, 32, // Wilhelm Death
UBERDEATHSND, 33, // Uber Death
KNIGHTSIGHTSND, 34, // Death Knight Sight
KNIGHTDEATHSND, 35, // Death Knight Death
ANGELSIGHTSND, 36, // Angel Sight
ANGELDEATHSND, 37, // Angel Death
GETSPEARSND, 39, // Got Spear replacement
#endif
#endif
LASTSOUND
};
void InitDigiMap()
{
int *map, i;
for (i = 0; i < LASTSOUND; i++)
DigiMap[i] = -1;
for (map = wolfdigimap; *map != LASTSOUND; map += 2)
DigiMap[map[0]] = map[1];
}
......@@ -45,7 +45,7 @@ extern boolean AdLibPresent, SoundBlasterPresent;
extern SDMode SoundMode;
extern SDSMode DigiMode;
extern SMMode MusicMode;
extern int DigiMap[];
extern void SD_Startup();
extern void SD_Shutdown();
......@@ -58,15 +58,18 @@ extern void SD_StopSound(),
SD_MusicOff(),
SD_FadeOutMusic();
extern boolean SD_MusicPlaying(),
SD_SetSoundMode(SDMode mode),
extern boolean SD_MusicPlaying(), SD_SetSoundMode(SDMode mode),
SD_SetMusicMode(SMMode mode);
extern word SD_SoundPlaying();
extern void SD_SetDigiDevice(SDSMode);
extern void SD_Poll();
void PlaySoundLocGlobal(word s, int id, fixed gx, fixed gy);
void UpdateSoundLoc(fixed x, fixed y, int angle);
extern int DigiMap[];
void InitDigiMap();
#endif
......@@ -5,17 +5,11 @@ boolean AdLibPresent, SoundBlasterPresent;
SDMode SoundMode, MusicMode;
SDSMode DigiMode;
int DigiMap[LASTSOUND];
static boolean SD_Started;
static boolean sqActive;
void SD_Poll()
{
}
void SD_SetDigiDevice(SDSMode mode)
{
}
......@@ -49,6 +43,8 @@ void SD_Startup()
{
if (SD_Started)
return;
InitDigiMap();
}
///////////////////////////////////////////////////////////////////////////
......
#include "wl_def.h"
boolean AdLibPresent, SoundBlasterPresent;
#include <AL/al.h>
#include <AL/alc.h>
#include <AL/alut.h>
/* old stuff */
boolean AdLibPresent, SoundBlasterPresent;
SDMode SoundMode, MusicMode;
SDSMode DigiMode;
static boolean SD_Started;
static boolean sqActive;
int DigiMap[LASTSOUND];
static boolean SD_Started;
/* AdLib Sound:
longword length;
word priority;
byte mChar, cChar, mScale, cScale, mAttack, cAttack, mSus, cSus,
mWave, cWave, nConn, voice, mode, unused[3];
byte block, data[];
*/
static boolean sqActive;
/* AdLib Music:
word length, data[];
(data is organized in reg|val (word) and tic count (word) pairs)
*/
#error "please ignore me for now, thanks"
/* PC Sound:
longword length;
word priority;
byte data[];
*/
void SD_Poll()
{
}
void SD_SetDigiDevice(SDSMode mode)
{
}
/* new stuff */
///////////////////////////////////////////////////////////////////////////
//
// SD_SetSoundMode() - Sets which sound hardware to use for sound effects
//
///////////////////////////////////////////////////////////////////////////
boolean SD_SetSoundMode(SDMode mode)
{
return false;
}
static int NumPCM;
struct _PCMSound {
byte *data;
int length;
int used;
ALuint handle;
} static *PCMSound;
struct _SoundData {
int priority;
/* PCM */
struct _PCMSound *pcm;
/* AdLib */
int alength;
byte mChar, cChar, mScale, cScale,
mAttack, cAttack, mSus, cSus,
mWave, cWave, nConn;
byte block;
byte *adata;
} static SoundData[LASTSOUND];
struct _MusicData {
int length;
word *regval;
word *count;
} static MusicData[LASTMUSIC];
#define CHANNELS 5 /* channel 0: adlib */
/* channel 1: local sounds */
/* channel 2+ positioned sounds */
struct _SoundChan {
int id; /* what is making the sound */
int sound; /* what is the sound */
int priority; /* priority of this sound */
int type; /* adlib or pcm? */
int pos; /* internal variable for soundplayer */
ALuint handle; /* OpenAL source handle */
} static SoundChan[CHANNELS];
///////////////////////////////////////////////////////////////////////////
//
// SD_SetMusicMode() - sets the device to use for background music
//
///////////////////////////////////////////////////////////////////////////
boolean SD_SetMusicMode(SMMode mode)
{
return false;
}
///////////////////////////////////////////////////////////////////////////
//
// SD_Startup() - starts up the Sound Mgr
//
///////////////////////////////////////////////////////////////////////////
void SD_Startup()
{
byte *p, *s;
int len, l, i, c;
if (SD_Started)
return;
alutInit(NULL, 0);
InitDigiMap();
p = PM_GetPage(ChunksInFile - 1); /* get pcm size table */
/* find how many full sounds there are */
c = PMSoundStart;
for (i = 0; i < 1024; i++) {
if (c >= (ChunksInFile - 1))
break;
len = p[i*4+2] | (p[i*4+3] << 8);
/* convert len into amount of pages used */
c += (len + (PMPageSize - 1)) / PMPageSize;
}
NumPCM = i;
MM_GetPtr((memptr)&PCMSound, sizeof(struct _PCMSound) * NumPCM);
for (i = 0; i < NumPCM; i++) {
PCMSound[i].length = len = p[i*4+2] | (p[i*4+3] << 8);
PCMSound[i].used = 0;
if (len) {
MM_GetPtr((memptr)&(PCMSound[i].data), len);
c = p[i*4+0] | (p[i*4+1] << 8);
s = PCMSound[i].data;
while (len > 0) {
l = (len >= PMPageSize) ? PMPageSize : len;
memcpy(s, PM_GetSoundPage(c), l);
PM_FreePage(c);
c++;
s += PMPageSize;
len -= PMPageSize;
}
} else {
PCMSound[i].data = NULL;
PCMSound[i].handle = -1;
}
}
for (i = 0; i < LASTSOUND; i++) {
CA_CacheAudioChunk(STARTADLIBSOUNDS + i);
s = audiosegs[STARTADLIBSOUNDS + i];
if (s) {
SoundData[i].alength = s[0] | (s[1] << 8) | (s[2] << 16) | (s[3] << 24);
SoundData[i].priority = s[4] | (s[5] << 8);
/* Rest of AdLib Sound stuff here */
if (DigiMap[i] != -1) {
struct _PCMSound *pcm = &PCMSound[DigiMap[i]];
if (pcm->used || pcm->data) {
SoundData[i].pcm = pcm;
if (!pcm->used) {
pcm->used = 1;
alGenBuffers(1, &(pcm->handle));
alBufferData(pcm->handle, AL_FORMAT_MONO8, pcm->data, pcm->length, 7000);
if (alGetError() != AL_NO_ERROR) {
fprintf(stderr, "AL error: trying to load pcm sound %d (sound %d)\n", DigiMap[i], i);
alDeleteBuffers(1, &(pcm->handle));
pcm->handle = -1;
} else {
MM_FreePtr((memptr)&(pcm->data));
pcm->data = NULL;
}
}
} else {
SoundData[i].pcm = NULL;
}
} else {
SoundData[i].pcm = NULL;
}
} else {
SoundData[i].priority = 0;
SoundData[i].alength = 0;
SoundData[i].pcm = NULL;
}
}
SoundChan[0].id = -1;
SoundChan[0].priority = -1;
for (i = 1; i < CHANNELS; i++) {
alGenSources(1, &(SoundChan[i].handle));
SoundChan[i].id = -1;
SoundChan[i].priority = -1;
alSourcei(SoundChan[i].handle, AL_SOURCE_RELATIVE, AL_FALSE);
/* alSourcef(SoundChan[i].handle, AL_ROLLOFF_FACTOR, 1.0f); */
}
alSourcei(SoundChan[1].handle, AL_SOURCE_RELATIVE, AL_TRUE);
alSourcef(SoundChan[i].handle, AL_ROLLOFF_FACTOR, 0.0f);
MusicData[0].length = 0; /* silence warnings for now */
SD_Started = true;
}
///////////////////////////////////////////////////////////////////////////
//
// SD_Shutdown() - shuts down the Sound Mgr
//
///////////////////////////////////////////////////////////////////////////
void SD_Shutdown()
{
if (!SD_Started)
......@@ -65,41 +209,138 @@ void SD_Shutdown()
SD_Started = false;
}
///////////////////////////////////////////////////////////////////////////
//
// SD_PlaySound() - plays the specified sound on the appropriate hardware
//
///////////////////////////////////////////////////////////////////////////
boolean SD_PlaySound(soundnames sound)
{
struct _SoundData *s = &SoundData[sound];
ALint val;
if (s->pcm) {
if (s->pcm->handle != -1) {
alGetSourceiv(SoundChan[1].handle, AL_SOURCE_STATE, &val);
if ((val != AL_PLAYING) || (s->priority >= SoundChan[1].priority)) {
SoundChan[1].sound = sound;
SoundChan[1].priority = s->priority;
alSourceStop(SoundChan[1].handle);
alSourcei(SoundChan[1].handle, AL_BUFFER, s->pcm->handle);
alSourcePlay(SoundChan[1].handle);
return false;
}
}
}
/* Adlib */
return false;
}
///////////////////////////////////////////////////////////////////////////
//
// SD_SoundPlaying() - returns the sound number that's playing, or 0 if
// no sound is playing
//
///////////////////////////////////////////////////////////////////////////
word SD_SoundPlaying()
void PlaySoundLocGlobal(word sound, int id, fixed gx, fixed gy)
{
return false;
struct _SoundData *s = &SoundData[sound];
ALfloat fval[3];
ALint val;
int i;
if (s->pcm) {
if (s->pcm->handle != -1) {
for (i = 2; i < CHANNELS; i++) {
if (id == SoundChan[i].id)
break;
}
if (i == CHANNELS) {
for (i = 2; i < CHANNELS; i++) {
alGetSourceiv(SoundChan[i].handle, AL_SOURCE_STATE, &val);
if (val != AL_PLAYING)
break;
}
}
if (i == CHANNELS) {
for (i = 2; i < CHANNELS; i++) {
if (s->priority >= SoundChan[i].priority)
break;
}
}
if (i != CHANNELS) {
SoundChan[i].id = id;
SoundChan[i].sound = sound;
SoundChan[i].priority = s->priority;
fval[0] = (ALfloat)gx / 32768.0f;
fval[1] = 0.0f;
fval[2] = (ALfloat)gy / 32768.0f;
alSourceStop(SoundChan[i].handle);
alSourcei(SoundChan[i].handle, AL_BUFFER, s->pcm->handle);
alSourcefv(SoundChan[i].handle, AL_POSITION, fval);
alSourcePlay(SoundChan[i].handle);
}
return;
}
}
/* AdLib */
SD_PlaySound(sound);
}
void UpdateSoundLoc(fixed x, fixed y, int angle)
{
ALfloat val[6];
val[0] = (ALfloat)x / 32768.0f;
val[1] = 0.0f;
val[2] = (ALfloat)y / 32768.0f;
alListenerfv(AL_POSITION, val);
val[0] = cos(angle * PI / 180.0f);
val[1] = 0.0f;
val[2] = -sin(angle * PI / 180.0f);
val[3] = 0.0f;
val[4] = 1.0f;
val[5] = 0.0f;
alListenerfv(AL_ORIENTATION, val);
}
///////////////////////////////////////////////////////////////////////////
//
// SD_StopSound() - if a sound is playing, stops it
//
///////////////////////////////////////////////////////////////////////////
void SD_StopSound()
{
int i;
/* Stop AdLib */
for (i = 1; i < CHANNELS; i++) {
SoundChan[i].id = -1;
SoundChan[i].sound = -1;
SoundChan[i].priority = -1;
alSourceStop(SoundChan[i].handle);
}
}
word SD_SoundPlaying()
{
/* returns 0 or currently playing sound */
/* this is only checked for GETGATLINGSND so to be pedantic */
/* return currently playing adlib else return the first found */
/* playing channel */
ALint val;
int i;
/* Check AdLib sound status */
for (i = 1; i < CHANNELS; i++) {
alGetSourceiv(SoundChan[i].handle, AL_SOURCE_STATE, &val);
if (val == AL_PLAYING)
return SoundChan[i].sound;
}
return false;
}
///////////////////////////////////////////////////////////////////////////
//
// SD_WaitSoundDone() - waits until the current sound is done playing
//
///////////////////////////////////////////////////////////////////////////
void SD_WaitSoundDone()
{
/* TODO: should also "work" when sound is disabled... */
......@@ -107,62 +348,40 @@ void SD_WaitSoundDone()
;
}
///////////////////////////////////////////////////////////////////////////
//
// SD_MusicOn() - turns on the sequencer
//
///////////////////////////////////////////////////////////////////////////
void SD_SetDigiDevice(SDSMode mode)
{
}
boolean SD_SetSoundMode(SDMode mode)
{
return false;
}
boolean SD_SetMusicMode(SMMode mode)
{
return false;
}
void SD_MusicOn()
{
sqActive = true;
}
///////////////////////////////////////////////////////////////////////////
//
// SD_MusicOff() - turns off the sequencer and any playing notes
//
///////////////////////////////////////////////////////////////////////////
void SD_MusicOff()
{
sqActive = false;
}
///////////////////////////////////////////////////////////////////////////
//
// SD_StartMusic() - starts playing the music pointed to
//
///////////////////////////////////////////////////////////////////////////
void SD_StartMusic(int music)
{
SD_MusicOff();
}
///////////////////////////////////////////////////////////////////////////
//
// SD_FadeOutMusic() - starts fading out the music. Call SD_MusicPlaying()
// to see if the fadeout is complete
//
///////////////////////////////////////////////////////////////////////////
void SD_FadeOutMusic()
{
}
///////////////////////////////////////////////////////////////////////////
//
// SD_MusicPlaying() - returns true if music is currently playing, false if
// not
//
///////////////////////////////////////////////////////////////////////////
boolean SD_MusicPlaying()
{
return false;
}
void PlaySoundLocGlobal(word s, int id, fixed gx, fixed gy)
{
SD_PlaySound(s);
}
void UpdateSoundLoc(fixed x, fixed y, int angle)
{
}
......@@ -19,8 +19,6 @@ static int leftchannel, rightchannel;
static volatile boolean SoundPositioned;
int DigiMap[LASTSOUND];
static word *DigiList;
static volatile boolean SD_Started;
......@@ -258,15 +256,13 @@ void SD_Startup()
{
audio_buf_info info;
int want, set;
int i;
if (SD_Started)
return;
Blah();
for (i = 0; i < LASTSOUND; i++)
DigiMap[i] = -1;
InitDigiMap();
OPL = OPLCreate(OPL_TYPE_YM3812, 3579545, 44100);
......@@ -573,6 +569,8 @@ void SD_MusicOff()
///////////////////////////////////////////////////////////////////////////
void SD_StartMusic(int music)
{
CA_CacheAudioChunk(music);
SD_MusicOff();
SD_MusicOn();
Music = (MusicGroup *)audiosegs[music];
......@@ -601,10 +599,6 @@ boolean SD_MusicPlaying()
return sqActive;
}
void SD_Poll()
{
}
void SD_SetDigiDevice(SDSMode mode)
{
}
......
......@@ -87,8 +87,8 @@ void VL_Startup()
//if (gfxbuf == NULL)
// gfxbuf = malloc(vwidth * vheight * 1);
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
/* TODO: renable parachute for release version? */
if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0) {
Quit("Couldn't init SDL");
}
......
......@@ -45,12 +45,11 @@ extern int vwidth, vheight; /* size of screen */
#define PLAYERSIZE MINDIST /* player radius */
#define MINACTORDIST 0x10000 /* minimum dist from player center */
/* to any actor center */
#define GLOBAL1 0x10000
#define TILESHIFT 16
#define UNSIGNEDSHIFT (TILESHIFT-8)
#define GLOBAL1 (1<<TILESHIFT)
#define TILEGLOBAL GLOBAL1
#define VIEWGLOBAL GLOBAL1
#define TILESHIFT 16
#define UNSIGNEDSHIFT 8
#define ANGLES 360 /* must be divisible by 4 */
#define ANGLEQUAD (ANGLES/4)
......@@ -741,7 +740,7 @@ void DrawPlayBorder();
void DrawPlayBorderSides();
void DrawStatusBar();
#define PlaySoundLocTile(s,tx,ty) PlaySoundLocGlobal(s,(int)((tx<<6)|(ty)),(((long)(tx) << TILESHIFT) + (1L << (TILESHIFT - 1))),(((long)ty << TILESHIFT) + (1L << (TILESHIFT - 1))))
#define PlaySoundLocTile(s,tx,ty) PlaySoundLocGlobal(s,(int)((tx<<6)|(ty)), (tx << TILESHIFT) + (1 << (TILESHIFT - 1)), (ty << TILESHIFT) + (1L << (TILESHIFT - 1)))
#define PlaySoundLocActor(s,ob) PlaySoundLocGlobal(s,(int)ob,(ob)->x,(ob)->y)
/*
......
......@@ -1041,18 +1041,15 @@ static void HitVertPWall()
#define DEG270 2700
#define DEG360 3600
#define xpartialbyystep() FixedByFrac(xpartial, ystep)
#define ypartialbyxstep() FixedByFrac(ypartial, xstep)
static int samex(int intercept, int tile)
{
if (xtilestep > 0) {
if ((intercept>>16) >= tile)
if ((intercept>>TILESHIFT) >= tile)
return 0;
else
return 1;
} else {
if ((intercept>>16) <= tile)
if ((intercept>>TILESHIFT) <= tile)
return 0;
else
return 1;
......@@ -1062,12 +1059,12 @@ static int samex(int intercept, int tile)
static int samey(int intercept, int tile)
{
if (ytilestep > 0) {
if ((intercept>>16) >= tile)
if ((intercept>>TILESHIFT) >= tile)
return 0;
else
return 1;
} else {
if ((intercept>>16) <= tile)
if ((intercept>>TILESHIFT) <= tile)
return 0;
else
return 1;
......@@ -1139,16 +1136,15 @@ for (postx = 0; postx < viewwidth; postx++) {
goto entry90;
}
/* add tilestep to fix raycasting problems? */
yintercept = viewy + xpartialbyystep(); // + xtilestep;
yintercept = viewy + FixedByFrac(xpartial, ystep); // + xtilestep;
xtile = focaltx + xtilestep;
xintercept = viewx + ypartialbyxstep(); // + ytilestep;
xintercept = viewx + FixedByFrac(ypartial, xstep); // + ytilestep;
ytile = focalty + ytilestep;
/* CORE LOOP */
#define TILE(n) ((n)>>16)
#define TILE(n) ((n)>>TILESHIFT)
/* check intersections with vertical walls */
vertcheck:
......@@ -1169,7 +1165,7 @@ vertentry:
goto passvert;
yintercept = doorhit;
xintercept = xtile << 16;
xintercept = xtile << TILESHIFT;
HitVertPWall();
} else {
/* vertdoor */
......@@ -1183,11 +1179,11 @@ vertentry:
goto passvert;
yintercept = doorhit;
xintercept = (xtile << 16) + 32768;
xintercept = (xtile << TILESHIFT) + TILEGLOBAL/2;
HitVertDoor();
}
} else {
xintercept = xtile << 16;
xintercept = xtile << TILESHIFT;
HitVertWall();
}
continue;
......@@ -1218,7 +1214,7 @@ horizentry:
goto passhoriz;
xintercept = doorhit;
yintercept = ytile << 16;
yintercept = ytile << TILESHIFT;
HitHorizPWall();
} else {
doorhit = xintercept + xstep / 2;
......@@ -1231,11 +1227,11 @@ horizentry:
goto passhoriz;
xintercept = doorhit;
yintercept = (ytile << 16) + 32768;
yintercept = (ytile << TILESHIFT) + TILEGLOBAL/2;
HitHorizDoor();
}
} else {
yintercept = ytile << 16;
yintercept = ytile << TILESHIFT;
HitHorizWall();
}
continue;
......
......@@ -1072,15 +1072,11 @@ startplayloop:
SD_StopSound();
SD_PlaySound(GETSPEARSND);
if (DigiMode != sds_Off)
{
if (DigiMode == sds_Off) {
long lasttimecount = get_TimeCount();
while(get_TimeCount() < (lasttimecount+150))
//while(SD_SoundPlaying()!=false)
SD_Poll();
}
else
while(get_TimeCount() < (lasttimecount+150)) ;
} else
SD_WaitSoundDone();
ClearMemory ();
......
......@@ -17,7 +17,7 @@ void ClearSplitVWB()
}
//==========================================================================
/* ======================================================================== */
#if defined(SPEAR) && !defined(SPEARDEMO)
////////////////////////////////////////////////////////
......@@ -90,7 +90,7 @@ void EndSpear()
}
#endif
//==========================================================================
/* ======================================================================== */
/*
==================
......@@ -236,11 +236,10 @@ void Victory()
EndSpear();
#endif
#endif // SPEARDEMO
#endif /* SPEARDEMO */
}
//==========================================================================
/* ======================================================================== */
/*
==================
......@@ -331,7 +330,7 @@ void Write(int x,int y,char *string)
//
// Breathe Mr. BJ!!!
//
void BJ_Breathe(void)
void BJ_Breathe()
{
static int which=0,max=10;
int pics[2]={L_GUYPIC,L_GUY2PIC};
......@@ -851,8 +850,6 @@ void LevelCompleted()
=
= PreloadGraphics
=
= Fill the cache up
=
=================
*/
......@@ -873,6 +870,8 @@ boolean PreloadUpdate(int current, int total)
void PreloadGraphics()
{
int i;
DrawLevel();
ClearSplitVWB();
......@@ -887,7 +886,10 @@ void PreloadGraphics()
VW_UpdateScreen();
VW_FadeIn();
PM_Preload(PreloadUpdate);
for (i = 0; i <= 40; i++)
PreloadUpdate(i, 50);
PreloadUpdate(50, 50);
IN_UserInput(70);
VW_FadeOut();
......
......@@ -60,7 +60,7 @@ fixed FixedByFrac(fixed a, fixed b)
int64_t r;
r = ra * rb;
r >>= 16;
r >>= TILESHIFT;
return (fixed)r;
}
......@@ -745,126 +745,6 @@ int MS_CheckParm(char *check)
return 0;
}
//===========================================================================
/*
=====================
=
= InitDigiMap
=
=====================
*/
static int wolfdigimap[] =
{
#ifndef SPEAR
HALTSND, 0,
DOGBARKSND, 1,
CLOSEDOORSND, 2,
OPENDOORSND, 3,
ATKMACHINEGUNSND, 4,
ATKPISTOLSND, 5,
ATKGATLINGSND, 6,
SCHUTZADSND, 7,
GUTENTAGSND, 8,
MUTTISND, 9,
BOSSFIRESND, 10,
SSFIRESND, 11,
DEATHSCREAM1SND, 12,
DEATHSCREAM2SND, 13,
DEATHSCREAM3SND, 13,
TAKEDAMAGESND, 14,
PUSHWALLSND, 15,
LEBENSND, 20,
NAZIFIRESND, 21,
SLURPIESND, 22,
YEAHSND, 32,
#ifndef UPLOAD
DOGDEATHSND, 16,
AHHHGSND, 17,
DIESND, 18,
EVASND, 19,
TOT_HUNDSND, 23,
MEINGOTTSND, 24,
SCHABBSHASND, 25,
HITLERHASND, 26,
SPIONSND, 27,
NEINSOVASSND, 28,
DOGATTACKSND, 29,
LEVELDONESND, 30,
MECHSTEPSND, 31,
SCHEISTSND, 33,
DEATHSCREAM4SND, 34, // AIIEEE
DEATHSCREAM5SND, 35, // DEE-DEE
DONNERSND, 36, // EPISODE 4 BOSS DIE
EINESND, 37, // EPISODE 4 BOSS SIGHTING
ERLAUBENSND, 38, // EPISODE 6 BOSS SIGHTING
DEATHSCREAM6SND, 39, // FART
DEATHSCREAM7SND, 40, // GASP
DEATHSCREAM8SND, 41, // GUH-BOY!
DEATHSCREAM9SND, 42, // AH GEEZ!
KEINSND, 43, // EPISODE 5 BOSS SIGHTING
MEINSND, 44, // EPISODE 6 BOSS DIE
ROSESND, 45, // EPISODE 5 BOSS DIE
#endif
#else /* SPEAR OF DESTINY DIGISOUNDS */
HALTSND, 0,
CLOSEDOORSND, 2,
OPENDOORSND, 3,
ATKMACHINEGUNSND, 4,
ATKPISTOLSND, 5,
ATKGATLINGSND, 6,
SCHUTZADSND, 7,
BOSSFIRESND, 8,
SSFIRESND, 9,
DEATHSCREAM1SND, 10,
DEATHSCREAM2SND, 11,
TAKEDAMAGESND, 12,
PUSHWALLSND, 13,
AHHHGSND, 15,
LEBENSND, 16,
NAZIFIRESND, 17,
SLURPIESND, 18,
LEVELDONESND, 22,
DEATHSCREAM4SND, 23, // AIIEEE
DEATHSCREAM3SND, 23, // DOUBLY-MAPPED!!!
DEATHSCREAM5SND, 24, // DEE-DEE
DEATHSCREAM6SND, 25, // FART
DEATHSCREAM7SND, 26, // GASP
DEATHSCREAM8SND, 27, // GUH-BOY!
DEATHSCREAM9SND, 28, // AH GEEZ!
GETGATLINGSND, 38, // Got Gat replacement
#ifndef SPEARDEMO
DOGBARKSND, 1,
DOGDEATHSND, 14,
SPIONSND, 19,
NEINSOVASSND, 20,
DOGATTACKSND, 21,
TRANSSIGHTSND, 29, // Trans Sight
TRANSDEATHSND, 30, // Trans Death
WILHELMSIGHTSND, 31, // Wilhelm Sight
WILHELMDEATHSND, 32, // Wilhelm Death
UBERDEATHSND, 33, // Uber Death
KNIGHTSIGHTSND, 34, // Death Knight Sight
KNIGHTDEATHSND, 35, // Death Knight Death
ANGELSIGHTSND, 36, // Angel Sight
ANGELDEATHSND, 37, // Angel Death
GETSPEARSND, 39, // Got Spear replacement
#endif
#endif
LASTSOUND
};
void InitDigiMap()
{
int *map;
for (map = wolfdigimap; *map != LASTSOUND; map += 2)
DigiMap[map[0]] = map[1];
}
/* ======================================================================== */
/*
......@@ -1217,7 +1097,6 @@ void InitGame()
//
// build some tables
//
InitDigiMap();
for (i = 0;i < MAPSIZE; i++)
{
......
......@@ -369,34 +369,6 @@ void US_ControlPanel(byte scancode)
break;
case backtodemo:
#ifdef SPEAR
/* TODO: why was this added for spear only? */
if (!ingame)
{
int start, i;
//
// DEALLOCATE ALL SOUNDS!
//
switch (SoundMode)
{
case sdm_PC:
start = STARTPCSOUNDS;
break;
case sdm_AdLib:
start = STARTADLIBSOUNDS;
break;
default:
start = 0;
break;
}
if (SoundMode != sdm_Off)
for (i=0;i<NUMSOUNDS;i++,start++)
if (audiosegs[start])
MM_SetPurge ((memptr)&audiosegs[start],3); // make purgable
}
#endif
MM_SortMem();
StartGame=1;
if (!ingame)
......@@ -439,7 +411,7 @@ void US_ControlPanel(byte scancode)
// RETURN/START GAME EXECUTION
#ifdef SPEAR
UnCacheLump (OPTIONS_LUMP_START,OPTIONS_LUMP_END);
UnCacheLump(OPTIONS_LUMP_START, OPTIONS_LUMP_END);
MM_SortMem();
#endif
}
......@@ -3177,18 +3149,12 @@ void StartCPMusic(int song)
lastmusic = song;
CA_CacheAudioChunk(STARTMUSIC + song);
SD_StartMusic(STARTMUSIC + song);
}
void FreeMusic()
{
SD_MusicOff();
if (lastmusic >= 0) {
CA_UnCacheAudioChunk(STARTMUSIC + lastmusic);
lastmusic = -1;
}
}
///////////////////////////////////////////////////////////////////////////
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment