Removing unused variables

This commit is contained in:
eukos 2015-08-22 23:57:32 +02:00
parent 89c24da057
commit d96f532e3a
22 changed files with 179 additions and 4160 deletions

2
README
View file

@ -29,7 +29,7 @@ For sound, please get the Open Sound System running.
- Water translucency and refractions
- Low detail modes
- Distance fog
- Can communicate to 32bit versions of XMMS for music playback
- Can communicate to 32bit versions of XMMS for music playback (or 64 when used with xmms-ctl)
*************
Compiling

View file

@ -1,893 +0,0 @@
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Quake is a trademark of Id Software, Inc., (c) 1996 Id Software, Inc. All
// rights reserved.
#include <dpmi.h>
#include "globaldef.h"
#include "dosisms.h"
extern cvar_t *bgmvolume;
#define ADDRESS_MODE_HSG 0
#define ADDRESS_MODE_RED_BOOK 1
#define STATUS_ERROR_BIT 0x8000
#define STATUS_BUSY_BIT 0x0200
#define STATUS_DONE_BIT 0x0100
#define STATUS_ERROR_MASK 0x00ff
#define ERROR_WRITE_PROTECT 0
#define ERROR_UNKNOWN_UNIT 1
#define ERROR_DRIVE_NOT_READY 2
#define ERROR_UNKNOWN_COMMAND 3
#define ERROR_CRC_ERROR 4
#define ERROR_BAD_REQUEST_LEN 5
#define ERROR_SEEK_ERROR 6
#define ERROR_UNKNOWN_MEDIA 7
#define ERROR_SECTOR_NOT_FOUND 8
#define ERROR_OUT_OF_PAPER 9
#define ERROR_WRITE_FAULT 10
#define ERROR_READ_FAULT 11
#define ERROR_GENERAL_FAILURE 12
#define ERROR_RESERVED_13 13
#define ERROR_RESERVED_14 14
#define ERROR_BAD_DISK_CHANGE 15
#define COMMAND_READ 3
#define COMMAND_WRITE 12
#define COMMAND_PLAY_AUDIO 132
#define COMMAND_STOP_AUDIO 133
#define COMMAND_RESUME_AUDIO 136
#define READ_REQUEST_AUDIO_CHANNEL_INFO 4
#define READ_REQUEST_DEVICE_STATUS 6
#define READ_REQUEST_MEDIA_CHANGE 9
#define READ_REQUEST_AUDIO_DISK_INFO 10
#define READ_REQUEST_AUDIO_TRACK_INFO 11
#define READ_REQUEST_AUDIO_STATUS 15
#define WRITE_REQUEST_EJECT 0
#define WRITE_REQUEST_RESET 2
#define WRITE_REQUEST_AUDIO_CHANNEL_INFO 3
#define STATUS_DOOR_OPEN 0x00000001
#define STATUS_DOOR_UNLOCKED 0x00000002
#define STATUS_RAW_SUPPORT 0x00000004
#define STATUS_READ_WRITE 0x00000008
#define STATUS_AUDIO_SUPPORT 0x00000010
#define STATUS_INTERLEAVE_SUPPORT 0x00000020
#define STATUS_BIT_6_RESERVED 0x00000040
#define STATUS_PREFETCH_SUPPORT 0x00000080
#define STATUS_AUDIO_MANIPLUATION_SUPPORT 0x00000100
#define STATUS_RED_BOOK_ADDRESS_SUPPORT 0x00000200
#define MEDIA_NOT_CHANGED 1
#define MEDIA_STATUS_UNKNOWN 0
#define MEDIA_CHANGED -1
#define AUDIO_CONTROL_MASK 0xd0
#define AUDIO_CONTROL_DATA_TRACK 0x40
#define AUDIO_CONTROL_AUDIO_2_TRACK 0x00
#define AUDIO_CONTROL_AUDIO_2P_TRACK 0x10
#define AUDIO_CONTROL_AUDIO_4_TRACK 0x80
#define AUDIO_CONTROL_AUDIO_4P_TRACK 0x90
#define AUDIO_STATUS_PAUSED 0x0001
#pragma pack(1)
struct playAudioRequest
{
char addressingMode;
int startLocation;
int sectors;
};
struct readRequest
{
char mediaDescriptor;
short bufferOffset;
short bufferSegment;
short length;
short startSector;
int volumeID;
};
struct writeRequest
{
char mediaDescriptor;
short bufferOffset;
short bufferSegment;
short length;
short startSector;
int volumeID;
};
struct cd_request
{
char headerLength;
char unit;
char command;
short status;
char reserved[8];
union
{
struct playAudioRequest playAudio;
struct readRequest read;
struct writeRequest write;
} x;
};
struct audioChannelInfo_s
{
char code;
char channel0input;
char channel0volume;
char channel1input;
char channel1volume;
char channel2input;
char channel2volume;
char channel3input;
char channel3volume;
};
struct deviceStatus_s
{
char code;
int status;
};
struct mediaChange_s
{
char code;
char status;
};
struct audioDiskInfo_s
{
char code;
char lowTrack;
char highTrack;
int leadOutStart;
};
struct audioTrackInfo_s
{
char code;
char track;
int start;
char control;
};
struct audioStatus_s
{
char code;
short status;
int PRstartLocation;
int PRendLocation;
};
struct reset_s
{
char code;
};
union readInfo_u
{
struct audioChannelInfo_s audioChannelInfo;
struct deviceStatus_s deviceStatus;
struct mediaChange_s mediaChange;
struct audioDiskInfo_s audioDiskInfo;
struct audioTrackInfo_s audioTrackInfo;
struct audioStatus_s audioStatus;
struct reset_s reset;
};
#pragma pack()
#define MAXIMUM_TRACKS 100
typedef struct
{
int start;
int length;
qboolean isData;
} track_info;
typedef struct
{
qboolean valid;
int leadOutAddress;
track_info track[MAXIMUM_TRACKS];
byte lowTrack;
byte highTrack;
} cd_info;
static struct cd_request *cdRequest;
static union readInfo_u *readInfo;
static cd_info cd;
static qboolean playing = false;
static qboolean wasPlaying = false;
static qboolean mediaCheck = false;
static qboolean initialized = false;
static qboolean enabled = true;
static qboolean playLooping = false;
static short cdRequestSegment;
static short cdRequestOffset;
static short readInfoSegment;
static short readInfoOffset;
static byte remap[256];
static byte cdrom;
static byte playTrack;
static byte cdvolume;
static int RedBookToSector(int rb)
{
byte minute;
byte second;
byte frame;
minute = (rb >> 16) & 0xff;
second = (rb >> 8) & 0xff;
frame = rb & 0xff;
return minute * 60 * 75 + second * 75 + frame;
}
static void CDAudio_Reset(void)
{
cdRequest->headerLength = 13;
cdRequest->unit = 0;
cdRequest->command = COMMAND_WRITE;
cdRequest->status = 0;
cdRequest->x.write.mediaDescriptor = 0;
cdRequest->x.write.bufferOffset = readInfoOffset;
cdRequest->x.write.bufferSegment = readInfoSegment;
cdRequest->x.write.length = sizeof(struct reset_s);
cdRequest->x.write.startSector = 0;
cdRequest->x.write.volumeID = 0;
readInfo->reset.code = WRITE_REQUEST_RESET;
regs.x.ax = 0x1510;
regs.x.cx = cdrom;
regs.x.es = cdRequestSegment;
regs.x.bx = cdRequestOffset;
dos_int86 (0x2f);
}
static void CDAudio_Eject(void)
{
cdRequest->headerLength = 13;
cdRequest->unit = 0;
cdRequest->command = COMMAND_WRITE;
cdRequest->status = 0;
cdRequest->x.write.mediaDescriptor = 0;
cdRequest->x.write.bufferOffset = readInfoOffset;
cdRequest->x.write.bufferSegment = readInfoSegment;
cdRequest->x.write.length = sizeof(struct reset_s);
cdRequest->x.write.startSector = 0;
cdRequest->x.write.volumeID = 0;
readInfo->reset.code = WRITE_REQUEST_EJECT;
regs.x.ax = 0x1510;
regs.x.cx = cdrom;
regs.x.es = cdRequestSegment;
regs.x.bx = cdRequestOffset;
dos_int86 (0x2f);
}
static int CDAudio_GetAudioTrackInfo(byte track, int *start)
{
byte control;
cdRequest->headerLength = 13;
cdRequest->unit = 0;
cdRequest->command = COMMAND_READ;
cdRequest->status = 0;
cdRequest->x.read.mediaDescriptor = 0;
cdRequest->x.read.bufferOffset = readInfoOffset;
cdRequest->x.read.bufferSegment = readInfoSegment;
cdRequest->x.read.length = sizeof(struct audioTrackInfo_s);
cdRequest->x.read.startSector = 0;
cdRequest->x.read.volumeID = 0;
readInfo->audioTrackInfo.code = READ_REQUEST_AUDIO_TRACK_INFO;
readInfo->audioTrackInfo.track = track;
regs.x.ax = 0x1510;
regs.x.cx = cdrom;
regs.x.es = cdRequestSegment;
regs.x.bx = cdRequestOffset;
dos_int86 (0x2f);
if (cdRequest->status & STATUS_ERROR_BIT)
{
Con_DPrintf("CDAudio_GetAudioTrackInfo %04x\n", cdRequest->status & 0xffff);
return -1;
}
*start = readInfo->audioTrackInfo.start;
control = readInfo->audioTrackInfo.control & AUDIO_CONTROL_MASK;
return (control & AUDIO_CONTROL_DATA_TRACK);
}
static int CDAudio_GetAudioDiskInfo(void)
{
int n;
cdRequest->headerLength = 13;
cdRequest->unit = 0;
cdRequest->command = COMMAND_READ;
cdRequest->status = 0;
cdRequest->x.read.mediaDescriptor = 0;
cdRequest->x.read.bufferOffset = readInfoOffset;
cdRequest->x.read.bufferSegment = readInfoSegment;
cdRequest->x.read.length = sizeof(struct audioDiskInfo_s);
cdRequest->x.read.startSector = 0;
cdRequest->x.read.volumeID = 0;
readInfo->audioDiskInfo.code = READ_REQUEST_AUDIO_DISK_INFO;
regs.x.ax = 0x1510;
regs.x.cx = cdrom;
regs.x.es = cdRequestSegment;
regs.x.bx = cdRequestOffset;
dos_int86 (0x2f);
if (cdRequest->status & STATUS_ERROR_BIT)
{
Con_DPrintf("CDAudio_GetAudioDiskInfo %04x\n", cdRequest->status & 0xffff);
return -1;
}
cd.valid = true;
cd.lowTrack = readInfo->audioDiskInfo.lowTrack;
cd.highTrack = readInfo->audioDiskInfo.highTrack;
cd.leadOutAddress = readInfo->audioDiskInfo.leadOutStart;
for (n = cd.lowTrack; n <= cd.highTrack; n++)
{
cd.track[n].isData = CDAudio_GetAudioTrackInfo (n, &cd.track[n].start);
if (n > cd.lowTrack)
{
cd.track[n-1].length = RedBookToSector(cd.track[n].start) - RedBookToSector(cd.track[n-1].start);
if (n == cd.highTrack)
cd.track[n].length = RedBookToSector(cd.leadOutAddress) - RedBookToSector(cd.track[n].start);
}
}
return 0;
}
static int CDAudio_GetAudioStatus(void)
{
cdRequest->headerLength = 13;
cdRequest->unit = 0;
cdRequest->command = COMMAND_READ;
cdRequest->status = 0;
cdRequest->x.read.mediaDescriptor = 0;
cdRequest->x.read.bufferOffset = readInfoOffset;
cdRequest->x.read.bufferSegment = readInfoSegment;
cdRequest->x.read.length = sizeof(struct audioStatus_s);
cdRequest->x.read.startSector = 0;
cdRequest->x.read.volumeID = 0;
readInfo->audioDiskInfo.code = READ_REQUEST_AUDIO_STATUS;
regs.x.ax = 0x1510;
regs.x.cx = cdrom;
regs.x.es = cdRequestSegment;
regs.x.bx = cdRequestOffset;
dos_int86 (0x2f);
if (cdRequest->status & STATUS_ERROR_BIT)
return -1;
return 0;
}
static int CDAudio_MediaChange(void)
{
cdRequest->headerLength = 13;
cdRequest->unit = 0;
cdRequest->command = COMMAND_READ;
cdRequest->status = 0;
cdRequest->x.read.mediaDescriptor = 0;
cdRequest->x.read.bufferOffset = readInfoOffset;
cdRequest->x.read.bufferSegment = readInfoSegment;
cdRequest->x.read.length = sizeof(struct mediaChange_s);
cdRequest->x.read.startSector = 0;
cdRequest->x.read.volumeID = 0;
readInfo->mediaChange.code = READ_REQUEST_MEDIA_CHANGE;
regs.x.ax = 0x1510;
regs.x.cx = cdrom;
regs.x.es = cdRequestSegment;
regs.x.bx = cdRequestOffset;
dos_int86 (0x2f);
return readInfo->mediaChange.status;
}
// we set the volume to 0 first and then to the desired volume
// some cd-rom drivers seem to need it done this way
void CDAudio_SetVolume (byte volume)
{
if (!initialized || !enabled)
return;
cdRequest->headerLength = 13;
cdRequest->unit = 0;
cdRequest->command = COMMAND_WRITE;
cdRequest->status = 0;
cdRequest->x.read.mediaDescriptor = 0;
cdRequest->x.read.bufferOffset = readInfoOffset;
cdRequest->x.read.bufferSegment = readInfoSegment;
cdRequest->x.read.length = sizeof(struct audioChannelInfo_s);
cdRequest->x.read.startSector = 0;
cdRequest->x.read.volumeID = 0;
readInfo->audioChannelInfo.code = WRITE_REQUEST_AUDIO_CHANNEL_INFO;
readInfo->audioChannelInfo.channel0input = 0;
readInfo->audioChannelInfo.channel0volume = 0;
readInfo->audioChannelInfo.channel1input = 1;
readInfo->audioChannelInfo.channel1volume = 0;
readInfo->audioChannelInfo.channel2input = 2;
readInfo->audioChannelInfo.channel2volume = 0;
readInfo->audioChannelInfo.channel3input = 3;
readInfo->audioChannelInfo.channel3volume = 0;
regs.x.ax = 0x1510;
regs.x.cx = cdrom;
regs.x.es = cdRequestSegment;
regs.x.bx = cdRequestOffset;
dos_int86 (0x2f);
readInfo->audioChannelInfo.channel0volume = volume;
readInfo->audioChannelInfo.channel1volume = volume;
regs.x.ax = 0x1510;
regs.x.cx = cdrom;
regs.x.es = cdRequestSegment;
regs.x.bx = cdRequestOffset;
dos_int86 (0x2f);
cdvolume = volume;
}
void CDAudio_Play(byte track, qboolean looping)
{
int volume;
#ifdef ASS_MIDI
MIDIHIJACK(track, 1);
return;
#endif
if (!initialized || !enabled)
return;
if (!cd.valid)
return;
track = remap[track];
if (playing)
{
if (playTrack == track)
return;
CDAudio_Stop();
}
playLooping = looping;
if (track < cd.lowTrack || track > cd.highTrack)
{
Con_DPrintf("CDAudio_Play: Bad track number %u.\n", track);
return;
}
playTrack = track;
if (cd.track[track].isData)
{
Con_DPrintf("CDAudio_Play: Can not play data.\n");
return;
}
volume = (int)(bgmvolume->value * 255.0);
if (volume < 0)
{
Cvar_Set (bgmvolume, "0");
volume = 0;
}
else if (volume > 255)
{
Cvar_Set (bgmvolume, "1");
volume = 255;
}
CDAudio_SetVolume (volume);
cdRequest->headerLength = 13;
cdRequest->unit = 0;
cdRequest->command = COMMAND_PLAY_AUDIO;
cdRequest->status = 0;
cdRequest->x.playAudio.addressingMode = ADDRESS_MODE_RED_BOOK;
cdRequest->x.playAudio.startLocation = cd.track[track].start;
cdRequest->x.playAudio.sectors = cd.track[track].length;
regs.x.ax = 0x1510;
regs.x.cx = cdrom;
regs.x.es = cdRequestSegment;
regs.x.bx = cdRequestOffset;
dos_int86 (0x2f);
if (cdRequest->status & STATUS_ERROR_BIT)
{
Con_DPrintf("CDAudio_Play: track %u failed\n", track);
cd.valid = false;
playing = false;
return;
}
playing = true;
}
void CDAudio_Stop(void)
{
if (!initialized || !enabled)
return;
cdRequest->headerLength = 13;
cdRequest->unit = 0;
cdRequest->command = COMMAND_STOP_AUDIO;
cdRequest->status = 0;
regs.x.ax = 0x1510;
regs.x.cx = cdrom;
regs.x.es = cdRequestSegment;
regs.x.bx = cdRequestOffset;
dos_int86 (0x2f);
wasPlaying = playing;
playing = false;
}
void CDAudio_Pause(void)
{
CDAudio_Stop();
}
void CDAudio_Resume(void)
{
if (!initialized || !enabled)
return;
if (!cd.valid)
return;
if (!wasPlaying)
return;
cdRequest->headerLength = 13;
cdRequest->unit = 0;
cdRequest->command = COMMAND_RESUME_AUDIO;
cdRequest->status = 0;
regs.x.ax = 0x1510;
regs.x.cx = cdrom;
regs.x.es = cdRequestSegment;
regs.x.bx = cdRequestOffset;
dos_int86 (0x2f);
playing = true;
}
static void CD_f (void)
{
char *command;
int ret;
int n;
int startAddress;
if (Cmd_Argc() < 2)
return;
command = Cmd_Argv (1);
if (Q_strcasecmp(command, "on") == 0)
{
enabled = true;
return;
}
if (Q_strcasecmp(command, "off") == 0)
{
if (playing)
CDAudio_Stop();
enabled = false;
return;
}
if (Q_strcasecmp(command, "reset") == 0)
{
enabled = true;
if (playing)
CDAudio_Stop();
for (n = 0; n < 256; n++)
remap[n] = n;
CDAudio_Reset();
CDAudio_GetAudioDiskInfo();
return;
}
if (Q_strcasecmp(command, "remap") == 0)
{
ret = Cmd_Argc() - 2;
if (ret <= 0)
{
for (n = 1; n < 256; n++)
if (remap[n] != n)
Con_Printf(" %u -> %u\n", n, remap[n]);
return;
}
for (n = 1; n <= ret; n++)
remap[n] = Q_atoi(Cmd_Argv (n+1));
return;
}
#ifndef ASS_MIDI
if (!cd.valid)
{
Con_Printf("No CD in player.\n");
return;
}
#endif
if (Q_strcasecmp(command, "play") == 0)
{
CDAudio_Play(Q_atoi(Cmd_Argv (2)), false);
return;
}
if (Q_strcasecmp(command, "loop") == 0)
{
CDAudio_Play(Q_atoi(Cmd_Argv (2)), true);
return;
}
if (Q_strcasecmp(command, "stop") == 0)
{
CDAudio_Stop();
return;
}
if (Q_strcasecmp(command, "pause") == 0)
{
CDAudio_Pause();
return;
}
if (Q_strcasecmp(command, "resume") == 0)
{
CDAudio_Resume();
return;
}
if (Q_strcasecmp(command, "eject") == 0)
{
if (playing)
CDAudio_Stop();
CDAudio_Eject();
cd.valid = false;
return;
}
if (Q_strcasecmp(command, "info") == 0)
{
Con_Printf("%u tracks\n", cd.highTrack - cd.lowTrack + 1);
for (n = cd.lowTrack; n <= cd.highTrack; n++)
{
ret = CDAudio_GetAudioTrackInfo (n, &startAddress);
Con_Printf("Track %2u: %s at %2u:%02u\n", n, ret ? "data " : "music", (startAddress >> 16) & 0xff, (startAddress >> 8) & 0xff);
}
if (playing)
Con_Printf("Currently %s track %u\n", playLooping ? "looping" : "playing", playTrack);
Con_Printf("Volume is %u\n", cdvolume);
CDAudio_MediaChange();
Con_Printf("Status %04x\n", cdRequest->status & 0xffff);
return;
}
}
void CDAudio_Update(void)
{
int ret;
int newVolume;
static double lastUpdate;
if (!initialized || !enabled)
return;
if ((realtime - lastUpdate) < 0.25)
return;
lastUpdate = realtime;
if (mediaCheck)
{
static double lastCheck;
if ((realtime - lastCheck) < 5.0)
return;
lastCheck = realtime;
ret = CDAudio_MediaChange();
if (ret == MEDIA_CHANGED)
{
Con_DPrintf("CDAudio: media changed\n");
playing = false;
wasPlaying = false;
cd.valid = false;
CDAudio_GetAudioDiskInfo();
return;
}
}
newVolume = (int)(bgmvolume->value * 255.0);
if (newVolume != cdvolume)
{
if (newVolume < 0)
{
Cvar_Set (bgmvolume, "0");
newVolume = 0;
}
else if (newVolume > 255)
{
Cvar_Set (bgmvolume, "1");
newVolume = 255;
}
CDAudio_SetVolume (newVolume);
}
if (playing)
{
CDAudio_GetAudioStatus();
if ((cdRequest->status & STATUS_BUSY_BIT) == 0)
{
playing = false;
if (playLooping)
CDAudio_Play(playTrack, true);
}
}
}
int CDAudio_Init(void)
{
char *memory;
int n;
#ifndef ASS_MIDI
if (cls.state == ca_dedicated)
return -1;
if (COM_CheckParm("-nocdaudio"))
return -1;
if (COM_CheckParm("-cdmediacheck"))
mediaCheck = true;
regs.x.ax = 0x1500;
regs.x.bx = 0;
dos_int86 (0x2f);
if (regs.x.bx == 0)
{
Con_NotifyBox (
"MSCDEX not loaded, music is\n"
"disabled. Use \"-nocdaudio\" if you\n"
"wish to avoid this message in the\n"
"future. See README.TXT for help.\n"
);
return -1;
}
if (regs.x.bx > 1)
Con_DPrintf("CDAudio_Init: First CD-ROM drive will be used\n");
cdrom = regs.x.cx;
regs.x.ax = 0x150c;
regs.x.bx = 0;
dos_int86 (0x2f);
if (regs.x.bx == 0)
{
Con_NotifyBox (
"MSCDEX version 2.00 or later\n"
"required for music. See README.TXT\n"
"for help.\n"
);
Con_DPrintf("CDAudio_Init: MSCDEX version 2.00 or later required.\n");
return -1;
}
#endif
memory = dos_getmemory(sizeof(struct cd_request
) + sizeof(union readInfo_u));
if (memory == NULL)
{
Con_DPrintf("CDAudio_Init: Unable to allocate low memory.\n");
return -1;
}
cdRequest = (struct cd_request *)memory;
cdRequestSegment = ptr2real(cdRequest) >> 4;
cdRequestOffset = ptr2real(cdRequest) & 0xf;
readInfo = (union readInfo_u *)(memory + sizeof(struct cd_request));
readInfoSegment = ptr2real(readInfo) >> 4;
readInfoOffset = ptr2real(readInfo) & 0xf;
for (n = 0; n < 256; n++)
remap[n] = n;
initialized = true;
#ifndef ASS_MIDI
CDAudio_SetVolume (255);
if (CDAudio_GetAudioDiskInfo())
{
Con_Printf("CDAudio_Init: No CD in player.\n");
enabled = false;
}
#endif
Cmd_AddCommand ("cd", CD_f);
#ifndef ASS_MIDI
Con_Printf("CD Audio Initialized\n");
#endif
return 0;
}
void CDAudio_Shutdown(void)
{
if (!initialized)
return;
CDAudio_Stop();
}

View file

@ -1,497 +0,0 @@
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Quake is a trademark of Id Software, Inc., (c) 1996 Id Software, Inc. All
// rights reserved.
#include <windows.h>
#include <mmsystem.h> // 2001-12-10 Compilable with LCC-Win32 by Jeff Ford
#include "globaldef.h"
extern HWND mainwindow;
extern cvar_t *bgmvolume;
static qboolean cdValid = false;
static qboolean playing = false;
static qboolean wasPlaying = false;
static qboolean initialized = false;
static qboolean enabled = false;
static qboolean playLooping = false;
static float cdvolume;
static byte remap[100];
//static byte cdrom; // 2001-12-10 Reduced compiler warnings by Jeff Ford
static byte playTrack;
static byte maxTrack;
UINT wDeviceID;
static void CDAudio_Eject(void)
{
DWORD dwReturn;
if (dwReturn = mciSendCommand(wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN, (DWORD)NULL))
Con_DPrintf("MCI_SET_DOOR_OPEN failed (%i)\n", dwReturn);
}
static void CDAudio_CloseDoor(void)
{
DWORD dwReturn;
if (dwReturn = mciSendCommand(wDeviceID, MCI_SET, MCI_SET_DOOR_CLOSED, (DWORD)NULL))
Con_DPrintf("MCI_SET_DOOR_CLOSED failed (%i)\n", dwReturn);
}
static int CDAudio_GetAudioDiskInfo(void)
{
DWORD dwReturn;
MCI_STATUS_PARMS mciStatusParms;
cdValid = false;
mciStatusParms.dwItem = MCI_STATUS_READY;
dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD) (LPVOID) &mciStatusParms);
if (dwReturn)
{
Con_DPrintf("CDAudio: drive ready test - get status failed\n");
return -1;
}
if (!mciStatusParms.dwReturn)
{
Con_DPrintf("CDAudio: drive not ready\n");
return -1;
}
mciStatusParms.dwItem = MCI_STATUS_NUMBER_OF_TRACKS;
dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD) (LPVOID) &mciStatusParms);
if (dwReturn)
{
Con_DPrintf("CDAudio: get tracks - status failed\n");
return -1;
}
if (mciStatusParms.dwReturn < 1)
{
Con_DPrintf("CDAudio: no music tracks\n");
return -1;
}
cdValid = true;
maxTrack = mciStatusParms.dwReturn;
return 0;
}
#ifdef DUMB
void DUMBHIJACK(int i, qboolean loop);
#endif
void CDAudio_Play(byte track, qboolean looping)
{
DWORD dwReturn;
MCI_PLAY_PARMS mciPlayParms;
MCI_STATUS_PARMS mciStatusParms;
#ifdef ASS_MIDI
MIDIHIJACK(track, 1);
return;
#endif
#ifdef DUMB
DUMBHIJACK(track, 1);
return;
#endif
if (!enabled)
return;
if (!cdValid)
{
CDAudio_GetAudioDiskInfo();
if (!cdValid)
return;
}
track = remap[track];
if (track < 1 || track > maxTrack)
{
Con_DPrintf("CDAudio: Bad track number %u.\n", track);
return;
}
// don't try to play a non-audio track
mciStatusParms.dwItem = MCI_CDA_STATUS_TYPE_TRACK;
mciStatusParms.dwTrack = track;
dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (DWORD) (LPVOID) &mciStatusParms);
if (dwReturn)
{
Con_DPrintf("MCI_STATUS failed (%i)\n", dwReturn);
return;
}
if (mciStatusParms.dwReturn != MCI_CDA_TRACK_AUDIO)
{
Con_Printf("CDAudio: track %i is not audio\n", track);
return;
}
// get the length of the track to be played
mciStatusParms.dwItem = MCI_STATUS_LENGTH;
mciStatusParms.dwTrack = track;
dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (DWORD) (LPVOID) &mciStatusParms);
if (dwReturn)
{
Con_DPrintf("MCI_STATUS failed (%i)\n", dwReturn);
return;
}
if (playing)
{
if (playTrack == track)
return;
CDAudio_Stop();
}
mciPlayParms.dwFrom = MCI_MAKE_TMSF(track, 0, 0, 0);
mciPlayParms.dwTo = (mciStatusParms.dwReturn << 8) | track;
mciPlayParms.dwCallback = (DWORD)mainwindow;
dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_NOTIFY | MCI_FROM | MCI_TO, (DWORD)(LPVOID) &mciPlayParms);
if (dwReturn)
{
Con_DPrintf("CDAudio: MCI_PLAY failed (%i)\n", dwReturn);
return;
}
playLooping = looping;
playTrack = track;
playing = true;
if (cdvolume == 0.0)
CDAudio_Pause ();
}
void CDAudio_Stop(void)
{
DWORD dwReturn;
if (!enabled)
return;
if (!playing)
return;
if (dwReturn = mciSendCommand(wDeviceID, MCI_STOP, 0, (DWORD)NULL))
Con_DPrintf("MCI_STOP failed (%i)", dwReturn);
wasPlaying = false;
playing = false;
}
void CDAudio_Pause(void)
{
DWORD dwReturn;
MCI_GENERIC_PARMS mciGenericParms;
if (!enabled)
return;
if (!playing)
return;
mciGenericParms.dwCallback = (DWORD)mainwindow;
if (dwReturn = mciSendCommand(wDeviceID, MCI_PAUSE, 0, (DWORD)(LPVOID) &mciGenericParms))
Con_DPrintf("MCI_PAUSE failed (%i)", dwReturn);
wasPlaying = playing;
playing = false;
}
void CDAudio_Resume(void)
{
DWORD dwReturn;
MCI_PLAY_PARMS mciPlayParms;
if (!enabled)
return;
if (!cdValid)
return;
if (!wasPlaying)
return;
mciPlayParms.dwFrom = MCI_MAKE_TMSF(playTrack, 0, 0, 0);
mciPlayParms.dwTo = MCI_MAKE_TMSF(playTrack + 1, 0, 0, 0);
mciPlayParms.dwCallback = (DWORD)mainwindow;
dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_TO | MCI_NOTIFY, (DWORD)(LPVOID) &mciPlayParms);
if (dwReturn)
{
Con_DPrintf("CDAudio: MCI_PLAY failed (%i)\n", dwReturn);
return;
}
playing = true;
}
static void CD_f (void)
{
char *command;
int ret;
int n;
int startAddress;
if (Cmd_Argc() < 2)
return;
command = Cmd_Argv (1);
if (Q_strcasecmp(command, "on") == 0)
{
enabled = true;
return;
}
if (Q_strcasecmp(command, "off") == 0)
{
if (playing)
CDAudio_Stop();
enabled = false;
return;
}
if (Q_strcasecmp(command, "reset") == 0)
{
enabled = true;
if (playing)
CDAudio_Stop();
for (n = 0; n < 100; n++)
remap[n] = n;
CDAudio_GetAudioDiskInfo();
return;
}
if (Q_strcasecmp(command, "remap") == 0)
{
ret = Cmd_Argc() - 2;
if (ret <= 0)
{
for (n = 1; n < 100; n++)
if (remap[n] != n)
Con_Printf(" %u -> %u\n", n, remap[n]);
return;
}
for (n = 1; n <= ret; n++)
remap[n] = Q_atoi(Cmd_Argv (n+1));
return;
}
if (Q_strcasecmp(command, "close") == 0)
{
CDAudio_CloseDoor();
return;
}
if (!cdValid)
{
CDAudio_GetAudioDiskInfo();
if (!cdValid)
{
Con_Printf("No CD in player.\n");
return;
}
}
if (Q_strcasecmp(command, "play") == 0)
{
CDAudio_Play((byte)Q_atoi(Cmd_Argv (2)), false);
return;
}
if (Q_strcasecmp(command, "loop") == 0)
{
CDAudio_Play((byte)Q_atoi(Cmd_Argv (2)), true);
return;
}
if (Q_strcasecmp(command, "stop") == 0)
{
CDAudio_Stop();
return;
}
if (Q_strcasecmp(command, "pause") == 0)
{
CDAudio_Pause();
return;
}
if (Q_strcasecmp(command, "resume") == 0)
{
CDAudio_Resume();
return;
}
if (Q_strcasecmp(command, "eject") == 0)
{
if (playing)
CDAudio_Stop();
CDAudio_Eject();
cdValid = false;
return;
}
if (Q_strcasecmp(command, "info") == 0)
{
Con_Printf("%u tracks\n", maxTrack);
if (playing)
Con_Printf("Currently %s track %u\n", playLooping ? "looping" : "playing", playTrack);
else if (wasPlaying)
Con_Printf("Paused %s track %u\n", playLooping ? "looping" : "playing", playTrack);
Con_Printf("Volume is %f\n", cdvolume);
return;
}
}
LONG CDAudio_MessageHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (lParam != wDeviceID)
return 1;
switch (wParam)
{
case MCI_NOTIFY_SUCCESSFUL:
if (playing)
{
playing = false;
if (playLooping)
CDAudio_Play(playTrack, true);
}
break;
case MCI_NOTIFY_ABORTED:
case MCI_NOTIFY_SUPERSEDED:
break;
case MCI_NOTIFY_FAILURE:
Con_DPrintf("MCI_NOTIFY_FAILURE\n");
CDAudio_Stop ();
cdValid = false;
break;
default:
Con_DPrintf("Unexpected MM_MCINOTIFY type (%i)\n", wParam);
return 1;
}
return 0;
}
void CDAudio_Update(void)
{
if (!enabled)
return;
if (bgmvolume->value != cdvolume)
{
if (cdvolume)
{
Cvar_Set (bgmvolume, "0");
cdvolume = bgmvolume->value;
CDAudio_Pause ();
}
else
{
Cvar_Set (bgmvolume, "1");
cdvolume = bgmvolume->value;
CDAudio_Resume ();
}
}
}
int CDAudio_Init(void)
{
DWORD dwReturn;
MCI_OPEN_PARMS mciOpenParms;
MCI_SET_PARMS mciSetParms;
int n;
#ifndef ASS_MIDI
if (cls.state == ca_dedicated)
return -1;
if (!COM_CheckParm("-cdaudio")) // leilei - let's do the reverse, cd audio crashes, and is unsupported now... i can't even test it =(
return -1;
mciOpenParms.lpstrDeviceType = "cdaudio";
if (dwReturn = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_SHAREABLE, (DWORD) (LPVOID) &mciOpenParms))
{
Con_Printf("CDAudio_Init: MCI_OPEN failed (%i)\n", dwReturn);
return -1;
}
wDeviceID = mciOpenParms.wDeviceID;
// Set the time format to track/minute/second/frame (TMSF).
mciSetParms.dwTimeFormat = MCI_FORMAT_TMSF;
if (dwReturn = mciSendCommand(wDeviceID, MCI_SET, MCI_SET_TIME_FORMAT, (DWORD)(LPVOID) &mciSetParms))
{
Con_Printf("MCI_SET_TIME_FORMAT failed (%i)\n", dwReturn);
mciSendCommand(wDeviceID, MCI_CLOSE, 0, (DWORD)NULL);
return -1;
}
#endif
for (n = 0; n < 100; n++)
remap[n] = n;
initialized = true;
enabled = true;
#ifndef ASS_MIDI
if (CDAudio_GetAudioDiskInfo())
{
Con_Printf("CDAudio_Init: No CD in player.\n");
cdValid = false;
}
#endif
Cmd_AddCommand ("cd", CD_f);
#ifndef ASS_MIDI
Con_Printf("CD Audio Initialized\n");
#endif
return 0;
}
void CDAudio_Shutdown(void)
{
if (!initialized)
return;
CDAudio_Stop();
#ifndef ASS_MIDI
if (mciSendCommand(wDeviceID, MCI_CLOSE, MCI_WAIT, (DWORD)NULL))
Con_DPrintf("CDAudio_Shutdown: MCI_CLOSE failed\n");
#endif
}

View file

@ -1,658 +0,0 @@
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "globaldef.h"
#include "dosisms.h"
int BLASTER_GetDMAPos(void);
/*
===============================================================================
GUS SUPPORT
===============================================================================
*/
qboolean GUS_Init (void);
int GUS_GetDMAPos (void);
void GUS_Shutdown (void);
/*
===============================================================================
BLASTER SUPPORT
===============================================================================
*/
short *dma_buffer=0;
static int dma_size;
static int dma;
static int dsp_port;
static int irq;
static int low_dma;
static int high_dma;
static int mixer_port;
static int mpu401_port;
int dsp_version;
int dsp_minor_version;
int timeconstant=-1;
void PrintBits (byte b)
{
int i;
char str[9];
for (i=0 ; i<8 ; i++)
str[i] = '0' + ((b & (1<<(7-i))) > 0);
str[8] = 0;
Con_Printf ("%s (%i)", str, b);
}
void SB_Info_f(void)
{
Con_Printf ("BLASTER=%s\n", getenv("BLASTER"));
Con_Printf("dsp version=%d.%d\n", dsp_version, dsp_minor_version);
Con_Printf("dma=%d\n", dma);
if (timeconstant != -1)
Con_Printf("timeconstant=%d\n", timeconstant);
Con_Printf("dma position:%i\n", BLASTER_GetDMAPos ());
}
// =======================================================================
// Interprets BLASTER variable
// =======================================================================
int GetBLASTER(void)
{
char *BLASTER;
char *param;
BLASTER = getenv("BLASTER");
if (!BLASTER)
return 0;
param = strchr(BLASTER, 'A');
if (!param)
param = strchr(BLASTER, 'a');
if (!param)
return 0;
sscanf(param+1, "%x", &dsp_port);
param = strchr(BLASTER, 'I');
if (!param)
param = strchr(BLASTER, 'i');
if (!param)
return 0;
sscanf(param+1, "%d", &irq);
param = strchr(BLASTER, 'D');
if (!param)
param = strchr(BLASTER, 'd');
if (!param)
return 0;
sscanf(param+1, "%d", &low_dma);
param = strchr(BLASTER, 'H');
if (!param)
param = strchr(BLASTER, 'h');
if (param)
sscanf(param+1, "%d", &high_dma);
param = strchr(BLASTER, 'M');
if (!param)
param = strchr(BLASTER, 'm');
if (param)
sscanf(param+1, "%x", &mixer_port);
else
mixer_port = dsp_port;
param = strchr(BLASTER, 'P');
if (!param)
param = strchr(BLASTER, 'p');
if (param)
sscanf(param+1, "%x", &mpu401_port);
return 1;
}
// ==================================================================
// Resets DSP. Returns 0 on success.
// ==================================================================
int ResetDSP(void)
{
volatile int i;
dos_outportb(dsp_port + 6, 1);
for (i=65536 ; i ; i--) ;
dos_outportb(dsp_port + 6, 0);
for (i=65536 ; i ; i--)
{
if (!(dos_inportb(dsp_port + 0xe) & 0x80)) continue;
if (dos_inportb(dsp_port + 0xa) == 0xaa) break;
}
if (i) return 0;
else return 1;
}
int ReadDSP(void)
{
while (!(dos_inportb(dsp_port+0xe)&0x80)) ;
return dos_inportb(dsp_port+0xa);
}
void WriteDSP(int val)
{
while ((dos_inportb(dsp_port+0xc)&0x80)) ;
dos_outportb(dsp_port+0xc, val);
}
int ReadMixer(int addr)
{
dos_outportb(mixer_port+4, addr);
return dos_inportb(mixer_port+5);
}
void WriteMixer(int addr, int val)
{
dos_outportb(mixer_port+4, addr);
dos_outportb(mixer_port+5, val);
}
int oldmixervalue;
/*
================
StartSB
================
*/
void StartSB(void)
{
int i;
// version 4.xx startup code
if (dsp_version >= 4)
{
Con_Printf("Version 4 SB startup\n");
WriteDSP(0xd1); // turn on speaker
WriteDSP(0x41);
WriteDSP(shm->speed>>8);
WriteDSP(shm->speed&0xff);
WriteDSP(0xb6); // 16-bit output
WriteDSP(0x30); // stereo
WriteDSP((shm->samples-1) & 0xff); // # of samples - 1
WriteDSP((shm->samples-1) >> 8);
}
// version 3.xx startup code
else if (dsp_version == 3)
{
Con_Printf("Version 3 SB startup\n");
WriteDSP(0xd1); // turn on speaker
oldmixervalue = ReadMixer (0xe);
WriteMixer (0xe, oldmixervalue | 0x2);// turn on stereo
WriteDSP(0x14); // send one byte
WriteDSP(0x0);
WriteDSP(0x0);
for (i=0 ; i<0x10000 ; i++)
dos_inportb(dsp_port+0xe); // ack the dsp
timeconstant = 65536-(256000000/(shm->channels*shm->speed));
WriteDSP(0x40);
WriteDSP(timeconstant>>8);
WriteMixer (0xe, ReadMixer(0xe) | 0x20);// turn off filter
WriteDSP(0x48);
WriteDSP((shm->samples-1) & 0xff); // # of samples - 1
WriteDSP((shm->samples-1) >> 8);
WriteDSP(0x90); // high speed 8 bit stereo
}
// normal speed mono
else
{
Con_Printf("Version 2 SB startup\n");
WriteDSP(0xd1); // turn on speaker
timeconstant = 65536-(256000000/(shm->channels*shm->speed));
WriteDSP(0x40);
WriteDSP(timeconstant>>8);
WriteDSP(0x48);
WriteDSP((shm->samples-1) & 0xff); // # of samples - 1
WriteDSP((shm->samples-1) >> 8);
WriteDSP(0x1c); // normal speed 8 bit mono
}
}
static int page_reg[] = { 0x87, 0x83, 0x81, 0x82, 0x8f, 0x8b, 0x89, 0x8a };
static int addr_reg[] = { 0, 2, 4, 6, 0xc0, 0xc4, 0xc8, 0xcc };
static int count_reg[] = { 1, 3, 5, 7, 0xc2, 0xc6, 0xca, 0xce };
static int mode_reg;
static int flipflop_reg;
static int disable_reg;
static int clear_reg;
/*
================
StartDMA
================
*/
void StartDMA(void)
{
int mode;
int realaddr;
realaddr = ptr2real(dma_buffer);
// use a high dma channel if specified
if (high_dma && dsp_version >= 4) // 8 bit snd can never use 16 bit dma
dma = high_dma;
else
dma = low_dma;
Con_Printf ("Using DMA channel %i\n", dma);
if (dma > 3)
{
mode_reg = 0xd6;
flipflop_reg = 0xd8;
disable_reg = 0xd4;
clear_reg = 0xdc;
}
else
{
mode_reg = 0xb;
flipflop_reg = 0xc;
disable_reg = 0xa;
clear_reg = 0xe;
}
dos_outportb(disable_reg, dma|4); // disable channel
// set mode- see "undocumented pc", p.876
mode = (1<<6) // single-cycle
+(0<<5) // address increment
+(1<<4) // auto-init dma
+(2<<2) // read
+(dma&3); // channel #
dos_outportb(mode_reg, mode);
// set address
// set page
dos_outportb(page_reg[dma], realaddr >> 16);
if (dma > 3)
{ // address is in words
dos_outportb(flipflop_reg, 0); // prepare to send 16-bit value
dos_outportb(addr_reg[dma], (realaddr>>1) & 0xff);
dos_outportb(addr_reg[dma], (realaddr>>9) & 0xff);
dos_outportb(flipflop_reg, 0); // prepare to send 16-bit value
dos_outportb(count_reg[dma], ((dma_size>>1)-1) & 0xff);
dos_outportb(count_reg[dma], ((dma_size>>1)-1) >> 8);
}
else
{ // address is in bytes
dos_outportb(flipflop_reg, 0); // prepare to send 16-bit value
dos_outportb(addr_reg[dma], realaddr & 0xff);
dos_outportb(addr_reg[dma], (realaddr>>8) & 0xff);
dos_outportb(flipflop_reg, 0); // prepare to send 16-bit value
dos_outportb(count_reg[dma], (dma_size-1) & 0xff);
dos_outportb(count_reg[dma], (dma_size-1) >> 8);
}
dos_outportb(clear_reg, 0); // clear write mask
dos_outportb(disable_reg, dma&~4);
}
/*
==================
BLASTER_Init
Returns false if nothing is found.
==================
*/
qboolean BLASTER_Init(void)
{
int size;
int realaddr;
int rc;
int p;
shm = 0;
rc = 0;
//
// must have a blaster variable set
//
if (!GetBLASTER())
{
Con_NotifyBox (
"The BLASTER environment variable\n"
"is not set, sound effects are\n"
"disabled. See README.TXT for help.\n"
);
return 0;
}
if (ResetDSP())
{
Con_Printf("Could not reset SB");
return 0;
}
//
// get dsp version
//
WriteDSP(0xe1);
dsp_version = ReadDSP();
dsp_minor_version = ReadDSP();
// we need at least v2 for auto-init dma
if (dsp_version < 2)
{
Con_Printf ("Sound blaster must be at least v2.0\n");
return 0;
}
// allow command line parm to set quality down
p = COM_CheckParm ("-dsp");
if (p && p < com_argc - 1)
{
p = Q_atoi (com_argv[p+1]);
if (p < 2 || p > 4)
Con_Printf ("-dsp parameter can only be 2, 3, or 4\n");
else if (p > dsp_version)
Con_Printf ("Can't -dsp %i on v%i hardware\n", p, dsp_version);
else
dsp_version = p;
}
// everyone does 11khz sampling rate unless told otherwise
shm = &sn;
shm->speed = 11025;
rc = COM_CheckParm("-sspeed");
if (rc)
shm->speed = Q_atoi(com_argv[rc+1]);
// version 4 cards (sb 16) do 16 bit stereo
if (dsp_version >= 4)
{
shm->channels = 2;
shm->samplebits = 16;
}
// version 3 cards (sb pro) do 8 bit stereo
else if (dsp_version == 3)
{
shm->channels = 2;
shm->samplebits = 8;
}
// v2 cards do 8 bit mono
else
{
shm->channels = 1;
shm->samplebits = 8;
}
// v1 cards do excrement.
Cmd_AddCommand("sbinfo", SB_Info_f);
size = 4096;
// allocate 8k and get a 4k-aligned buffer from it
dma_buffer = dos_getmemory(size*2);
if (!dma_buffer)
{
Con_Printf("Couldn't allocate sound dma buffer");
return false;
}
realaddr = ptr2real(dma_buffer);
realaddr = (realaddr + size) & ~(size-1);
dma_buffer = (short *) real2ptr(realaddr);
dma_size = size;
memset(dma_buffer, 0, dma_size);
shm->soundalive = true;
shm->splitbuffer = false;
shm->samples = size/(shm->samplebits/8);
shm->samplepos = 0;
shm->submission_chunk = 1;
shm->buffer = (unsigned char *) dma_buffer;
shm->samples = size/(shm->samplebits/8);
StartDMA();
StartSB();
return true;
}
/*
==============
BLASTER_GetDMAPos
return the current sample position (in mono samples read)
inside the recirculating dma buffer, so the mixing code will know
how many sample are required to fill it up.
===============
*/
int BLASTER_GetDMAPos(void)
{
int count;
// this function is called often. acknowledge the transfer completions
// all the time so that it loops
if (dsp_version >= 4)
dos_inportb(dsp_port+0xf); // 16 bit audio
else
dos_inportb(dsp_port+0xe); // 8 bit audio
// clear 16-bit reg flip-flop
// load the current dma count register
if (dma < 4)
{
dos_outportb(0xc, 0);
count = dos_inportb(dma*2+1);
count += dos_inportb(dma*2+1) << 8;
if (shm->samplebits == 16)
count /= 2;
count = shm->samples - (count+1);
}
else
{
dos_outportb(0xd8, 0);
count = dos_inportb(0xc0+(dma-4)*4+2);
count += dos_inportb(0xc0+(dma-4)*4+2) << 8;
if (shm->samplebits == 8)
count *= 2;
count = shm->samples - (count+1);
}
// Con_Printf("DMA pos = 0x%x\n", count);
shm->samplepos = count & (shm->samples-1);
return shm->samplepos;
}
/*
==============
BLASTER_Shutdown
Reset the sound device for exiting
===============
*/
void BLASTER_Shutdown(void)
{
if (dsp_version >= 4)
{
}
else if (dsp_version == 3)
{
ResetDSP (); // stop high speed mode
WriteMixer (0xe, oldmixervalue); // turn stereo off and filter on
}
else
{
}
WriteDSP(0xd3); // turn off speaker
ResetDSP ();
dos_outportb(disable_reg, dma|4); // disable dma channel
}
/*
===============================================================================
INTERFACE
===============================================================================
*/
typedef enum
{
dma_none,
dma_blaster,
dma_gus
} dmacard_t;
dmacard_t dmacard;
/*
==================
SNDDM_Init
Try to find a sound device to mix for.
Returns false if nothing is found.
Returns true and fills in the "shm" structure with information for the mixer.
==================
*/
qboolean SNDDMA_Init(void)
{
if (GUS_Init ())
{
dmacard = dma_gus;
return true;
}
if (BLASTER_Init ())
{
dmacard = dma_blaster;
return true;
}
dmacard = dma_none;
return false;
}
/*
==============
SNDDMA_GetDMAPos
return the current sample position (in mono samples, not stereo)
inside the recirculating dma buffer, so the mixing code will know
how many sample are required to fill it up.
===============
*/
int SNDDMA_GetDMAPos(void)
{
switch (dmacard)
{
case dma_blaster:
return BLASTER_GetDMAPos ();
case dma_gus:
return GUS_GetDMAPos ();
case dma_none:
break;
}
return 0;
}
/*
==============
SNDDMA_Shutdown
Reset the sound device for exiting
===============
*/
void SNDDMA_Shutdown(void)
{
switch (dmacard)
{
case dma_blaster:
BLASTER_Shutdown ();
break;
case dma_gus:
GUS_Shutdown ();
break;
case dma_none:
break;
}
dmacard = dma_none;
return;
}
/*
==============
SNDDMA_Submit
Send sound to device if buffer isn't really the dma buffer
===============
*/
void SNDDMA_Submit(void)
{
}

File diff suppressed because it is too large Load diff

View file

@ -1,55 +0,0 @@
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "../engine/globaldef.h"
extern int desired_speed;
extern int desired_bits;
qboolean SNDDMA_Init(void)
{
int size;
size = 16384 + sizeof(dma_t);
shm = malloc (size);
memset((void*)shm, 0, size);
shm->buffer = (char*)shm + sizeof(dma_t);
shm->channels = 2;
shm->speed = desired_speed;
shm->samplebits = desired_bits;
shm->samples = 16384 / (desired_bits / 8);
shm->submission_chunk = 1;
return true;
}
// return the current sample position (in mono samples read)
// inside the recirculating dma buffer
int SNDDMA_GetDMAPos(void)
{
shm->samplepos = (int)(realtime*shm->speed*shm->channels) & (shm->samples-1);
return shm->samplepos;
}
void SNDDMA_Shutdown(void)
{
}

View file

@ -1,218 +0,0 @@
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/shm.h>
#include <sys/wait.h>
#include <stdio.h>
#include <sys/audioio.h>
#include <errno.h>
#include "../engine/globaldef.h"
int audio_fd;
int snd_inited;
static int bufpos;
static int wbufp;
static audio_info_t info;
#define BUFFER_SIZE 8192
unsigned char dma_buffer[BUFFER_SIZE];
unsigned char pend_buffer[BUFFER_SIZE];
int pending;
static int lastwrite = 0;
qboolean SNDDMA_Init(void)
{
int rc;
int fmt;
int tmp;
int i;
char *s;
int caps;
if (snd_inited) {
printf("Sound already init'd\n");
return;
}
shm = &sn;
shm->splitbuffer = 0;
audio_fd = open("/dev/audio", O_WRONLY|O_NDELAY);
if (audio_fd < 0) {
if (errno == EBUSY) {
Con_Printf("Audio device is being used by another process\n");
}
perror("/dev/audio");
Con_Printf("Could not open /dev/audio\n");
return (0);
}
if (ioctl(audio_fd, AUDIO_GETINFO, &info) < 0) {
perror("/dev/audio");
Con_Printf("Could not communicate with audio device.\n");
close(audio_fd);
return 0;
}
//
// set to nonblock
//
if (fcntl(audio_fd, F_SETFL, O_NONBLOCK) < 0) {
perror("/dev/audio");
close(audio_fd);
return 0;
}
AUDIO_INITINFO(&info);
shm->speed = 11025;
// try 16 bit stereo
info.play.encoding = AUDIO_ENCODING_LINEAR;
info.play.sample_rate = 11025;
info.play.channels = 2;
info.play.precision = 16;
if (ioctl(audio_fd, AUDIO_SETINFO, &info) < 0) {
info.play.encoding = AUDIO_ENCODING_LINEAR;
info.play.sample_rate = 11025;
info.play.channels = 1;
info.play.precision = 16;
if (ioctl(audio_fd, AUDIO_SETINFO, &info) < 0) {
Con_Printf("Incapable sound hardware.\n");
close(audio_fd);
return 0;
}
Con_Printf("16 bit mono sound initialized\n");
shm->samplebits = 16;
shm->channels = 1;
} else { // 16 bit stereo
Con_Printf("16 bit stereo sound initialized\n");
shm->samplebits = 16;
shm->channels = 2;
}
shm->soundalive = true;
shm->samples = sizeof(dma_buffer) / (shm->samplebits/8);
shm->samplepos = 0;
shm->submission_chunk = 1;
shm->buffer = (unsigned char *)dma_buffer;
snd_inited = 1;
return 1;
}
int SNDDMA_GetDMAPos(void)
{
if (!snd_inited)
return (0);
if (ioctl(audio_fd, AUDIO_GETINFO, &info) < 0) {
perror("/dev/audio");
Con_Printf("Could not communicate with audio device.\n");
close(audio_fd);
snd_inited = 0;
return (0);
}
return ((info.play.samples*shm->channels) % shm->samples);
}
int SNDDMA_GetSamples(void)
{
if (!snd_inited)
return (0);
if (ioctl(audio_fd, AUDIO_GETINFO, &info) < 0) {
perror("/dev/audio");
Con_Printf("Could not communicate with audio device.\n");
close(audio_fd);
snd_inited = 0;
return (0);
}
return info.play.samples;
}
void SNDDMA_Shutdown(void)
{
if (snd_inited) {
close(audio_fd);
snd_inited = 0;
}
}
/*
==============
SNDDMA_Submit
Send sound to device if buffer isn't really the dma buffer
===============
*/
void SNDDMA_Submit(void)
{
int samps;
int bsize;
int bytes, b;
static unsigned char writebuf[1024];
unsigned char *p;
int idx;
int stop = paintedtime;
extern int soundtime;
if (paintedtime < wbufp)
wbufp = 0; // reset
bsize = shm->channels * (shm->samplebits/8);
bytes = (paintedtime - wbufp) * bsize;
if (!bytes)
return;
if (bytes > sizeof(writebuf)) {
bytes = sizeof(writebuf);
stop = wbufp + bytes/bsize;
}
p = writebuf;
idx = (wbufp*bsize) & (BUFFER_SIZE - 1);
for (b = bytes; b; b--) {
*p++ = dma_buffer[idx];
idx = (idx + 1) & (BUFFER_SIZE - 1);
}
wbufp = stop;
if (write(audio_fd, writebuf, bytes) < bytes)
printf("audio can't keep up!\n");
}

View file

@ -1068,16 +1068,9 @@ void CL_RelinkEntities (void)
R_RocketTrail (oldorg, ent->origin, 6);
ent->forcelink = false;
if (!ent->model->flags && EF_GIB)
// ent->gushed = 0; // leilei - reset gushing...
#ifndef GLQUAKE
if (i == cl.viewentity && !chase_active->value && !reflectpass && !deathcam_yesiamdead)
continue;
#else
if (i == cl.viewentity && !chase_active->value && !deathcam_yesiamdead)
continue;
#endif
if (i == cl.viewentity && !chase_active->value && !deathcam_yesiamdead)
continue;
if ( ent->effects & EF_NODRAW )
continue;

View file

@ -417,6 +417,55 @@ void Host_Map_f (void)
}
}
/*
======================
Host_Model_f
handle a
model <modelname>
======================
*/
void Host_Model_f (void)
{
/* int i;
char name[MAX_QPATH];
edict_t *e;
model_t *m;
if (cmd_source != src_command)
return;
cls.demonum = -1; // stop demo loop in case this fails
CL_Disconnect ();
Host_ShutdownServer(false);
key_dest = key_game; // remove console or menu
for (i=0 ; i<Cmd_Argc() ; i++)
{
strcat (name, Cmd_Argv(i));
strcat (name, " ");
}
strcat (name, "\n");
Con_Printf("Loading model %s", name);
e = client->edict;
m = Mod_ForName (Cmd_Argv(1), false);
if (!m)
{
Con_Printf ("Can't load %s\n", Cmd_Argv(1));
return;
}
e->v.frame = 0;
cl.model_precache[(int)e->v.modelindex] = m;*/
}
/*
==================
Host_Changelevel_f
@ -2461,4 +2510,5 @@ void Host_InitCommands (void)
Cmd_AddCommand ("ng_nofbcolormap", GrabColorMapNoFB);
Cmd_AddCommand ("ng_altcolormap", GrabColorMapAlternative);
Cmd_AddCommand ("ng_satcolormap", GrabColorMapSaturation);
Cmd_AddCommand ("model", Host_Model_f);
}

View file

@ -267,7 +267,7 @@ extern cvar_t *vid_stretch_by_2;
#define MENU_BROKEN_OPTIONS 192
#define MENU_OVERBRIGHT 193
#define MENU_VIEW_OPTIONS 194
#define MENU_QUALITY_OPTIONS 195
#define MENU_SPRAY 196
#define MENU_BLOODHACK 197
#define MENU_PARTICLESET 198
@ -299,7 +299,7 @@ extern cvar_t *vid_stretch_by_2;
#define MENU_SATURATION 224
#define MENU_BLOODLEVEL 225
#define MENU_DYNAMIC 226
#define MENU_CONTENT_OPTIONS 227
#define MENU_MUZZLEBLEND 228
#define MENU_FOGQUALITY 229
#define MENU_WATERQUALITY 230
@ -309,9 +309,6 @@ extern cvar_t *vid_stretch_by_2;
#define MENU_FLARES 234
#define MENU_SHADING 235
#define MENU_HUD_OPTIONS 237
#define MENU_DEATHCAM 247
#define MENU_ASPECT 248
#define MENU_RETROSCALE 249
@ -328,25 +325,16 @@ int options_cursor;
menu_definition_t m_menu_options[] =
{ // Options Menu
{MENU_MAIN, MENU_OPTIONS}, // this is the ESC key function and title
{MENU_CUSTOMIZE_CONTROLS, MENU_SELECTABLE},
// {MENU_CUSTOMIZE_CONTROLS2, MENU_SELECTABLE},
{MENU_GO_TO_CONSOLE, MENU_SELECTABLE},
{MENU_CONTROL_OPTIONS, MENU_SELECTABLE},
{MENU_SOUND_OPTIONS, MENU_SELECTABLE},
{MENU_INTERNAL_OPTIONS, MENU_SELECTABLE},
// {MENU_CLIENT_OPTIONS, MENU_SELECTABLE}, // leilei - moved this to another submenu
// {MENU_SERVER_OPTIONS, MENU_SELECTABLE}, // also moved to another menu
{MENU_VIEW_OPTIONS, MENU_SELECTABLE},
{MENU_CUSTOMIZE_CONTROLS, MENU_SELECTABLE},
{MENU_VIDEO_OPTIONS, MENU_SELECTABLE},
{MENU_QUALITY_OPTIONS, MENU_SELECTABLE},
{MENU_CONTENT_OPTIONS, MENU_SELECTABLE},
// {MENU_COLORMAP_OPTIONS, MENU_SELECTABLE}, // deprecated
#ifdef EXPERIMENT
{MENU_BROKEN_OPTIONS, MENU_SELECTABLE},
#endif
{MENU_SOUND_OPTIONS, MENU_SELECTABLE},
{MENU_VIEW_OPTIONS, MENU_SELECTABLE},
{MENU_INTERNAL_OPTIONS, MENU_SELECTABLE},
{MENU_VIDEO_RESOLUTION, MENU_SELECTABLE},
{MENU_LOAD_DEFAULT_CFG, MENU_SELECTABLE},
//{MENU_HUD_OPTIONS, MENU_SELECTABLE}, // completely unfinished
{MENU_AUTOSAVER, MENU_SELECTABLE},
{0, 0}, // end of submenu
@ -369,10 +357,10 @@ menu_definition_t m_menu_control_options[] =
{MENU_OPTIONS, MENU_OPTIONS}, // this is the ESC key function and title
{MENU_ALWAYS_RUN, MENU_SELECTABLE},
{MENU_MOUSELOOK, MENU_SELECTABLE},
{MENU_LOOKSPRING, MENU_SELECTABLE},
{MENU_LOOKSTRAFE, MENU_SELECTABLE},
{MENU_MOUSESPEED, MENU_SELECTABLE},
{MENU_INVERT_MOUSE, MENU_SELECTABLE},
{MENU_LOOKSPRING, MENU_SELECTABLE},
{MENU_LOOKSTRAFE, MENU_SELECTABLE},
#ifdef _WIN32
{MENU_USE_MOUSE, MENU_INVISIBLE}, // only present in windowed mode on Win32
#endif
@ -430,121 +418,66 @@ menu_definition_t m_menu_server_options[] =
int video_options_cursor;
int view_options_cursor;
int quality_options_cursor;
int content_options_cursor;
int internal_options_cursor;
int preset_options_cursor;
int hud_options_cursor;
menu_definition_t m_menu_video_options[] =
{ // Video Options
{MENU_OPTIONS, MENU_OPTIONS}, // this is the ESC key function and title
// {MENU_SCREENSIZE, MENU_SELECTABLE}, // redundant
// {MENU_BRIGHTNESS, MENU_SELECTABLE}, // redundant
{MENU_CON_ALPHA, MENU_SELECTABLE},
{MENU_CON_HEIGHT, MENU_SELECTABLE},
{MENU_SHOW_FPS, MENU_SELECTABLE},
{MENU_COLOR, MENU_SELECTABLE},
{MENU_COLORED, MENU_SELECTABLE},
{MENU_WATERALPHA, MENU_SELECTABLE},
{MENU_WATERBLEND, MENU_SELECTABLE},
#ifdef GLQUAKE
{MENU_GL_MAXDEPTH, MENU_SELECTABLE},
#endif
{MENU_LOWDETAIL, MENU_SELECTABLE}, // VIRTUAL RES
{MENU_BRIGHTNESS, MENU_SELECTABLE}, // BRIGHTNESS
{MENU_SATURATION, MENU_SELECTABLE}, // COLOR
{MENU_CONTRAST, MENU_SELECTABLE}, // CONTRACT
{MENU_MIPDETAIL, MENU_SELECTABLE}, // TEXTURE DETAIL
{MENU_FILTERING, MENU_SELECTABLE}, // TEXTURE FILTERING
{MENU_SHADEDITHER, MENU_SELECTABLE}, // SHADED DITHER
{MENU_LERPMODELS, MENU_SELECTABLE}, // INTERPOLATION
{MENU_SHADOWHACK, MENU_SELECTABLE}, // MODEL SHADOWS
{MENU_SHADING, MENU_SELECTABLE}, // MODEL SHADING
{MENU_SHINYGRAYS, MENU_SELECTABLE}, // CHROME METAL
{MENU_DYNAMIC, MENU_SELECTABLE}, // DYNAMIC LIGHTS
{MENU_COLOREDDYNS, MENU_SELECTABLE}, // COLOUR DYNLIGHTS
{MENU_COLORED, MENU_SELECTABLE}, // COLORED LIGHTS
{MENU_FLARES, MENU_SELECTABLE}, // FLARES
{MENU_FLAMEHACK, MENU_SELECTABLE}, // FLAMES
{MENU_MUZZLEBLEND, MENU_SELECTABLE}, // MUZZLEBLEND
{MENU_TRANQUALITY, MENU_SELECTABLE}, // HQ WATER
{MENU_WATERALPHA, MENU_SELECTABLE}, // WATER ALPHA
{MENU_WATERBLEND, MENU_SELECTABLE}, // WATER BLEND
{MENU_WATERQUALITY, MENU_SELECTABLE}, // REFRACTIONS
#ifdef _WIN32
{MENU_USE_MOUSE, MENU_INVISIBLE}, // only present in windowed mode on Win32
#endif
{0, 0}, // end of submenu
};
// 2002-01-31 New menu system by Maddes end
menu_definition_t m_menu_quality_options[] =
{ // Video Options
{MENU_OPTIONS, MENU_OPTIONS}, // this is the ESC key function and title
//{MENU_LOWWORLD, MENU_SELECTABLE}, // no c implementation
{MENU_LOWDETAIL, MENU_SELECTABLE}, // crashes with water
//{MENU_LOWMODELS, MENU_SELECTABLE}, // unimplemented
{MENU_TRANQUALITY, MENU_SELECTABLE},
{MENU_WATERQUALITY, MENU_SELECTABLE},
//{MENU_LIGHTQUALITY, MENU_SELECTABLE}, // deprecated
{MENU_MIPDETAIL, MENU_SELECTABLE},
{MENU_FILTERING, MENU_SELECTABLE},
{MENU_LERPMODELS, MENU_SELECTABLE},
{MENU_SHADEDITHER, MENU_SELECTABLE},
{MENU_SHADING, MENU_SELECTABLE},
{MENU_DYNAMIC, MENU_SELECTABLE},
{0, 0}, // end of submenu
};
menu_definition_t m_menu_preset_options[] =
{ // Video Options
{MENU_OPTIONS, MENU_OPTIONS}, // this is the ESC key function and title
{0, 0}, // end of submenu
};
menu_definition_t m_menu_hud_options[] =
{ // Video Options
{MENU_OPTIONS, MENU_OPTIONS}, // this is the ESC key function and title
{MENU_SHADEDITHER, MENU_SELECTABLE},
{MENU_SHADING, MENU_SELECTABLE},
{MENU_DYNAMIC, MENU_SELECTABLE},
{0, 0}, // end of submenu
};
menu_definition_t m_menu_content_options[] =
{ // Content Hacks
{MENU_OPTIONS, MENU_OPTIONS}, // this is the ESC key function and title
{MENU_COLOREDDYNS, MENU_SELECTABLE},
{MENU_MUZZLEBLEND, MENU_SELECTABLE},
{MENU_SHINYGRAYS, MENU_SELECTABLE},
{MENU_SHADOWHACK, MENU_SELECTABLE},
{MENU_BLOODLEVEL, MENU_SELECTABLE},
{MENU_FLAMEHACK, MENU_SELECTABLE},
{MENU_FLARES, MENU_SELECTABLE},
{MENU_PARTICLESET, MENU_SELECTABLE},
{MENU_GIBBURST, MENU_SELECTABLE},
{MENU_BLOODBURST, MENU_SELECTABLE},
{MENU_PLAYERDEATH, MENU_SELECTABLE},
{MENU_STANDSTILL, MENU_SELECTABLE},
{0, 0}, // end of submenu
};
menu_definition_t m_menu_view_options[] =
{ // Video Options
{ // VIEW Options
{MENU_OPTIONS, MENU_OPTIONS}, // this is the ESC key function and title
{MENU_ASPECT, MENU_SELECTABLE},
{MENU_BRIGHTNESS, MENU_SELECTABLE},
{MENU_SATURATION, MENU_SELECTABLE},
{MENU_CONTRAST, MENU_SELECTABLE},
{MENU_OLDSTATBAR, MENU_SELECTABLE},
#ifdef _WIN32
// {MENU_STRETCHMODE,MENU_SELECTABLE}, // only present in windowed mode on Win32
#endif
{MENU_BOBMODEL, MENU_SELECTABLE},
{MENU_FOLLOWMODEL, MENU_SELECTABLE},
{MENU_LEANMODEL, MENU_SELECTABLE},
{MENU_GUNDRAW, MENU_SELECTABLE},
{MENU_GUNHOLD, MENU_SELECTABLE},
{MENU_DEATHCAM, MENU_SELECTABLE},
{MENU_SCREENSCALE, MENU_SELECTABLE},
{MENU_RETROSCALE, MENU_SELECTABLE},
{MENU_LOADSCREEN, MENU_SELECTABLE},
{MENU_ASPECT, MENU_SELECTABLE}, // ASPECT
{MENU_SCREENSCALE, MENU_SELECTABLE}, // GFX SCALE
{MENU_RETROSCALE, MENU_SELECTABLE}, // AUTOSCALE
{MENU_OLDSTATBAR, MENU_SELECTABLE}, // DRAW HUD
{MENU_SHOW_FPS, MENU_SELECTABLE}, // SHOW FPS
{MENU_BOBMODEL, MENU_SELECTABLE}, // BOB
{MENU_FOLLOWMODEL, MENU_SELECTABLE}, // FOLLOW
{MENU_LEANMODEL, MENU_SELECTABLE}, // LEAN
{MENU_GUNDRAW, MENU_SELECTABLE}, // DRAW
{MENU_GUNHOLD, MENU_SELECTABLE}, // FALL
{MENU_DEATHCAM, MENU_SELECTABLE}, // DEATHCAM
{MENU_PARTICLESET, MENU_SELECTABLE}, // PARTS
{MENU_BLOODLEVEL, MENU_SELECTABLE}, // VIOLENCE LEVEL
{MENU_BLOODBURST, MENU_SELECTABLE}, // BLOOD SOUNDS
{MENU_GIBBURST, MENU_SELECTABLE}, // GIB SOUNDS FSH
{MENU_PLAYERDEATH, MENU_SELECTABLE}, // QUIET DEATH
{MENU_STANDSTILL, MENU_SELECTABLE}, // STAND STILL
{MENU_LOADSCREEN, MENU_SELECTABLE}, // LOADING SCREENS
{MENU_CON_ALPHA, MENU_SELECTABLE}, // CON ALPHA
{MENU_CON_HEIGHT, MENU_SELECTABLE}, // CON HEIGHT
{MENU_COLOR, MENU_SELECTABLE}, // MENU FADE
{0, 0}, // end of submenu
};
int broken_options_cursor;
int broken_options_cursor;
menu_definition_t m_menu_broken_options[] =
{ // Video Options
{MENU_OPTIONS, MENU_OPTIONS}, // this is the ESC key function and title
@ -2176,18 +2109,6 @@ int M_DrawFunction (menu_definition_t *menu_definition, int y)
M_Print (16, y, " Video options");
y += 8;
break;
case MENU_QUALITY_OPTIONS:
M_Print (16, y, " Quality options");
y += 8;
break;
case MENU_HUD_OPTIONS:
M_Print (16, y, " HUD options");
y += 8;
break;
case MENU_CONTENT_OPTIONS:
M_Print (16, y, " Content hacks");
y += 8;
break;
case MENU_VIEW_OPTIONS:
M_Print (16, y, " View options");
y += 8;
@ -2233,7 +2154,7 @@ int M_DrawFunction (menu_definition_t *menu_definition, int y)
y += 8;
break;
case MENU_CON_ALPHA:
M_Print (16, y, " Console transparency");
M_Print (16, y, " Console alpha");
r = (1.0 - con_alpha->value);
M_DrawSlider (220, y, r);
y += 8;
@ -2289,7 +2210,7 @@ int M_DrawFunction (menu_definition_t *menu_definition, int y)
break;
case MENU_OLDSTATBAR:
M_Print (16, y, " draw hud");
M_Print (16, y, " Draw HUD");
M_DrawCheckbox (220, y, cl_sbar->value);
y += 8;
break;
@ -3083,35 +3004,6 @@ void M_ExecFunction (menu_definition_t *menu_definition, int key)
}
break;
// Quality options menu
case MENU_QUALITY_OPTIONS:
if (key == K_ENTER || key == K_JOY1 || key == K_ESCAPE)
{
current_menu = m_menu_quality_options;
current_cursor = &quality_options_cursor;
m_entersound = true;
}
break;
case MENU_HUD_OPTIONS:
if (key == K_ENTER || key == K_JOY1 || key == K_ESCAPE)
{
current_menu = m_menu_hud_options;
current_cursor = &hud_options_cursor;
m_entersound = true;
}
break;
case MENU_CONTENT_OPTIONS:
if (key == K_ENTER || key == K_JOY1 || key == K_ESCAPE)
{
current_menu = m_menu_content_options;
current_cursor = &content_options_cursor;
m_entersound = true;
}
break;
// View options menu
case MENU_VIEW_OPTIONS:
if (key == K_ENTER || key == K_JOY1 || key == K_ESCAPE)

View file

@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// only the refresh window will be updated unless these variables are flagged
int scr_copytop;
int scr_copyeverything;
int reflectavailable;
float scr_con_current;
float scr_conlines; // lines of console to display
float oldsbar;
@ -1116,7 +1116,11 @@ void SCR_ScreenShot_f (void)
//
// find a file name to save it to
//
#ifndef LINUX
strcpy(pcxname,"scrsh00.pcx");
#else
strcpy(pcxname,"scrsh00.xwd");
#endif
for (i=0 ; i<=99 ; i++)
{
@ -1132,6 +1136,8 @@ void SCR_ScreenShot_f (void)
return;
}
#ifndef LINUX
//
// save the pcx file
//
@ -1145,6 +1151,11 @@ void SCR_ScreenShot_f (void)
#endif
D_DisableBackBufferAccess (); // for adapters that can't stay mapped in
#else
sprintf(pcxnametwo, "xwd -name 'NGUNIX X11' -out %s", pcxname);
system(pcxnametwo);
#endif
Con_Printf ("Wrote %s\n", pcxname);
}
@ -1341,7 +1352,7 @@ extern client_state_t clsplit;
void SCR_ReallyRender (void)
{
reflectpass = 0;
V_RenderView ();
}
@ -1408,7 +1419,7 @@ void SCR_UpdateScreen (void)
oldsbar = cl_sbar->value;
vid.recalc_refdef = true;
}
if (!reflectpass){
if (vid.recalc_refdef)
{
// something changed, so reorder the screen
@ -1428,7 +1439,7 @@ void SCR_UpdateScreen (void)
}
pconupdate = NULL;
}
SCR_SetUpToDrawConsole ();
SCR_EraseCenterString ();

View file

@ -1299,7 +1299,7 @@ float lastgunbob;
int skipbob; // skip the update of the weapon bob (hack)
float gunbobthen = 0;
float gunaimtime;
extern vec3_t reflectorg;
void V_CalcRefdef (void)
{
entity_t *ent, *view;
@ -1382,8 +1382,7 @@ void V_CalcRefdef (void)
// k it's ended
VectorCopy (ent->origin, view->origin);
// if (reflectpass)
// VectorCopy (ent->origin, view->origin2);
view->origin[2] += cl.viewheight;
for (i=0 ; i<3 ; i++)
{
@ -1991,7 +1990,7 @@ the entity origin, so any view position inside that will be valid
*/
extern vrect_t scr_vrect;
void PushShadows (void); // shut up msvc.
extern int reflectpass;
void V_RenderView (void)
{
if (con_forcedup)
@ -2021,7 +2020,7 @@ void V_RenderView (void)
// D_DrawSparkTrans(r_refdef.vieworg,r_refdef.vieworg,15, 0);
}
if(!reflectpass)
if (cl.intermission)
{ // intermission / finale rendering
V_CalcIntermissionRefdef ();

View file

@ -122,7 +122,7 @@ extern qboolean r_dowarp;
// Fake Res
extern int r_docrap; // 160x100
extern int reflectpass; // 320x200, for water reflection
extern affinetridesc_t r_affinetridesc;
extern spritedesc_t r_spritedesc;

View file

@ -134,8 +134,6 @@ extern int ditheredrend;
D_SetupFrame
===============
*/
extern int reflectpass;
void D_SetupFrame (void)
{
int i;
@ -146,10 +144,6 @@ void D_SetupFrame (void)
d_viewbuffer = r_warpbuffer;
else if (r_dowarp)
d_viewbuffer = r_warpbuffer;
#ifdef WATERLOW
else if (reflectpass)
d_viewbuffer = r_reflectbuffer;
#endif
else
d_viewbuffer = (void *)(byte *)vid.buffer;
@ -159,10 +153,6 @@ void D_SetupFrame (void)
screenwidth = WARP_WIDTH;
else if (r_dowarp)
screenwidth = WARP_WIDTH;
#ifdef WATERLOW
else if (reflectpass)
screenwidth = WARP_WIDTH;
#endif
else
screenwidth = vid.rowbytes;
@ -191,13 +181,12 @@ void D_SetupFrame (void)
}
else
{
d_minmip = d_mipcap->value;
if (reflectpass)
d_minmip = 2; // leilei - force blurry textures for reflections
if (d_minmip > 3)
d_minmip = 3;
else if (d_minmip < 0)
d_minmip = 0;
d_minmip = d_mipcap->value;
if (d_minmip > 3)
d_minmip = 3;
else if (d_minmip < 0)
d_minmip = 0;
for (i=0 ; i<(NUM_MIPS-1) ; i++)
d_scalemip[i] = basemip[i] * d_mipscale->value;
@ -315,8 +304,7 @@ void D_SetupFrameExperimental (void)
else
{
d_minmip = d_mipcap->value;
if (reflectpass)
d_minmip = 2; // leilei - force blurry textures for reflections
if (d_minmip > 3)
d_minmip = 3;
else if (d_minmip < 0)

View file

@ -55,7 +55,7 @@ void D_Patch (void)
D_ViewChanged
================
*/
extern int reflectpass;
void D_ViewChanged (void)
{
#ifndef EGA
@ -65,10 +65,6 @@ void D_ViewChanged (void)
rowbytes = LOW_WIDTH;
else if (r_docrap == 2)
rowbytes = WARP_WIDTH;
#ifdef WATERLOW
if (reflectpass)
rowbytes = WARP_WIDTH;
#endif
else
rowbytes = vid.rowbytes;
@ -118,10 +114,6 @@ void D_ViewChanged (void)
rowbytes = WARP_WIDTH;
else if (r_dowarp)
rowbytes = WARP_WIDTH;
#ifdef WATERLOW
else if (reflectpass)
rowbytes = WARP_WIDTH;
#endif
else
rowbytes = vid.rowbytes;

View file

@ -46,8 +46,7 @@ extern pixel_t ditherTable[262144][4];
static byte *foggmap;
extern int wootel[32][32][32];
extern int reflectavailable;
int gonnareflect; // well are we gonna reflect or not?
extern cvar_t *r_tranquality;
extern cvar_t *r_wateralpha;
@ -432,8 +431,7 @@ void D_DrawTurbulent8SpanAlphaRefractions (void)
//wa = r_wateralpha->value;
// wa = depthen / 8192;
depthen = (depthen) >> 2;
if (reflectpass == 1)
return; // don't draw if we're doing water
do
{

View file

@ -32,7 +32,7 @@ extern qboolean r_dowarp;
D_Sky_uv_To_st
=================
*/
extern int reflectpass;
void D_Sky_uv_To_st (int u, int v, fixed16_t *s, fixed16_t *t)
{
float wu, wv, temp;
@ -56,14 +56,7 @@ void D_Sky_uv_To_st (int u, int v, fixed16_t *s, fixed16_t *t)
wv = 8192.0 * (float)(((int)vid.maxwarpheight>>1)-v) / temp;
}
#ifdef WATERLOW
else if(reflectpass == 1)
{
wu = 8192.0 * (float)(u-((int)vid.maxwarpwidth>>1)) / temp;
wv = 8192.0 * (float)(((int)vid.maxwarpheight>>1)-v) / temp;
}
#endif
else if(r_dowarp)
{
wu = 8192.0 * (float)(u-((int)320>>1)) / temp;

View file

@ -391,21 +391,13 @@ void D_SpriteDrawSpans_Blend_C (sspan_t *pspan, int blendmode)
if (flared){
btemp = mulTable[btemp][pacolor];
// btemp = menumap[btemp][3];
if (reflectpass) {
if (alfer < 1)
*pdest = addTable[host_colormap[btemp + (addlpha & 0xFF00)]][*pdest];
else
*pdest = addTable[btemp][*pdest];
*pz = izi >> 16;
}
else{
if (alfer < 1)
*pdest = addTable[*pdest][host_colormap[btemp + (addlpha & 0xFF00)]];
else
*pdest = addTable[btemp][*pdest];
*pz = izi >> 16;
}
}
else if (*pz <= (izi >> 16))
@ -824,21 +816,13 @@ void D_SpriteDrawSpans_Blend_C_Filter (sspan_t *pspan, int blendmode)
if (flared){
btemp = mulTable[btemp][pacolor];
//*btemp = menumap[*btemp][color];
if (reflectpass) {
if (alfer < 1)
*pdest = addTable[host_colormap[btemp + (addlpha & 0xFF00)]][*pdest];
else
*pdest = addTable[btemp][*pdest];
*pz = izi >> 16;
}
else{
if (alfer < 1)
*pdest = addTable[host_colormap[btemp + (addlpha & 0xFF00)]][*pdest];
else
*pdest = addTable[btemp][*pdest];
*pz = izi >> 16;
}
}
else if (*pz <= (izi >> 16))

View file

@ -56,11 +56,7 @@ int r_clipflags;
byte *r_warpbuffer;
byte *r_lowbuffer;
byte *r_fogbuffer;
#ifdef WATERREFLECTIONS
byte *r_reflectbuffer;
byte *r_lowreflectbuffer;
byte *r_warpreflectbuffer;
#endif
byte *r_shadowbuffer;
/*
byte *r_res2buffer;
@ -110,7 +106,7 @@ int r_polycount;
int r_drawnpolycount;
int r_wholepolycount;
void R_ApplyFog(void);
void R_ApplyDof(void);
#define VIEWMODNAME_LENGTH 256
char viewmodname[VIEWMODNAME_LENGTH+1];
int modcount;
@ -330,8 +326,6 @@ void R_Init_Cvars (void)
r_particlelit = Cvar_Get ("r_particlelit", "0", CVAR_ORIGINAL);
Cvar_SetValue (r_maxedges, (float)NUMSTACKEDGES);
Cvar_SetValue (r_maxsurfs, (float)NUMSTACKSURFACES);
}
// 2001-09-18 New cvar system by Maddes (Init) end
extern int overbrightmdl;
@ -481,18 +475,6 @@ CreatePassages ();
R_FinalizeAliasVerts ();
#endif
// leilei - sun hack
// TODO: Determine origin of sun from the map's sunlight key
// TODO2 : very obnoxious lens reflections
/*
{
vec3_t sun;
sun[0] = 1750;
sun[1] = 1750;
sun[2] = 1750;
R_FlareTest(sun, 1, 255, 255, 180, 0, NULL);
}
*/
}
@ -743,11 +725,7 @@ void R_MarkLeaves (void)
r_visframecount++;
r_oldviewleaf = r_viewleaf;
if (reflectpass){
vis = Mod_LeafPVS (r_viewleaf, cl.worldmodel);
}
else if (r_novis->value)
if (r_novis->value)
{
vis = solid;
memset (solid, 0xff, (cl.worldmodel->numleafs+7)>>3);
@ -793,7 +771,7 @@ static void R_DrawAliasEntity(qboolean viewmodel)
currententity->leifect = 0;
if (viewmodel)
{
if (!r_drawviewmodel->value || chase_active->value || cl.intermission || reflectpass)
if (!r_drawviewmodel->value || chase_active->value || cl.intermission)
return;
if (cl.items & IT_INVISIBILITY)
return;
@ -920,7 +898,7 @@ void R_DrawEntitiesOnList(void)
{
currententity = cl_visedicts[i];
if (currententity == &cl_entities[cl.viewentity] && !chase_active->value && !reflectpass)
if (currententity == &cl_entities[cl.viewentity] && !chase_active->value )
{
// don't draw the player
continue;
@ -1014,7 +992,7 @@ void R_DrawEntitiesOnList (void)
if (currententity == &cl_entities[cl.viewentity])
// 2000-01-09 ChaseCam fix by FrikaC start
{
if (!chase_active->value && !reflectpass && !deathcam_yesiamdead)
if (!chase_active->value && !deathcam_yesiamdead)
{
// 2000-01-09 ChaseCam fix by FrikaC end
continue; // don't draw the player
@ -1136,7 +1114,7 @@ void R_DrawEntitiesOnList (void)
// HACK - apply flares to static fires and torches.
// TODO: make this only work on makestatic (do it somewhere else? loadpointlight?)
#ifdef REALLYCRASHESITHINK
if (!cls.demoplayback && !cl.paused && !reflectpass){ // leilei - HACK - don't try this at demo (Crash workaround)
if (!cls.demoplayback && !cl.paused){ // leilei - HACK - don't try this at demo (Crash workaround)
// Torch
if (!strcmp (currententity->model->name, "progs/flame.mdl"))
{
@ -1262,7 +1240,7 @@ void R_DrawViewModel (void)
// 2000-01-09 ChaseCam fix by FrikaC start
if (chase_active->value || reflectpass || deathcam_yesiamdead)
if (chase_active->value || deathcam_yesiamdead)
{
return;
}
@ -1708,9 +1686,9 @@ r_refdef must be set before the first call
*/
int amilow;
extern int playersnd; // leilei - dsp effects
int reflectpass; // leilei - water reflection
int waterinsight; // leilei - water pixel shader
vec3_t reflectorg; // leilei - water reflection
extern pixel_t *d_viewbuffer;
#ifdef EXPREND
@ -1732,7 +1710,7 @@ void R_RenderShadows_ (void)
R_DrawEntitiesOnList ();
R_DrawViewModel ();
// R_DrawParticles ();
if (r_foundwater && !reflectpass)
if (r_foundwater )
{
r_drawwater = true;
}
@ -1753,61 +1731,15 @@ void R_RenderView_ (void)
byte lowbuffer[LOW_WIDTH * LOW_HEIGHT];
// reflections
#ifdef WATERREFLECTIONS
byte reflectbuffer[WARP_WIDTH * WARP_HEIGHT];
#endif
r_warpbuffer = warpbuffer;
#ifdef WATERREFLECTIONS
r_reflectbuffer = reflectbuffer;
#endif
r_lowbuffer = lowbuffer;
if (reflectpass){
{
float d;
// leilei - water reflections
// **- TODO -** proper mirror surface matrix
// flip it good
r_refdef.viewangles[PITCH] *= -1;
// Con_Printf("%f %f %f mirror\n", mirror_plane->normal[0],mirror_plane->normal[1],mirror_plane->normal[2]);
d = DotProduct (r_refdef.vieworg, mirror_plane->normal) - mirror_plane->dist + temp2->value;
// VectorMA (r_refdef.vieworg, -2*d, mirror_plane->normal, r_refdef.vieworg);
VectorMA (r_refdef.vieworg, -2*d, mirror_plane->normal, r_refdef.vieworg);
d = DotProduct (vpn, mirror_plane->normal);
// VectorMA (vpn, -2*d, mirror_plane->normal, vpn);
VectorMA (vpn, -2*d, mirror_plane->normal, vpn);
// r_refdef.viewangles[0] = -asin (vpn[2])/M_PI*180;
// r_refdef.viewangles[1] = atan2 (vpn[1], vpn[0])/M_PI*180;
// r_refdef.viewangles[2] = -r_refdef.viewangles[2];
r_refdef.viewangles[ROLL] *= -1;
}
}
if (r_timegraph->value || r_speeds->value || r_dspeeds->value)
r_time1 = Sys_FloatTime ();
#ifdef SPLIT
if (cursplit){
R_SetupFrameSplit ();
}
else
R_SetupFrame ();
#else
R_SetupFrame ();
#endif
R_MarkLeaves (); // done here so we know if we're in water
// make FDIV fast. This reduces timing precision after we've been running for a
@ -1819,8 +1751,7 @@ void R_RenderView_ (void)
if (!cl_entities[0].model || !cl.worldmodel)
Sys_Error ("R_RenderView: NULL worldmodel");
if (reflectpass)
r_drawwater = 0;
if (!r_dspeeds->value)
{
VID_UnlockBuffer ();
@ -1838,7 +1769,7 @@ if (reflectpass)
S_ExtraUpdate (); // don't let sound get messed up if going slow
VID_LockBuffer ();
}
if (!reflectpass)
if (r_dspeeds->value)
{
se_time2 = Sys_FloatTime ();
@ -1854,7 +1785,6 @@ if (!reflectpass)
dv_time1 = de_time2;
}
if(!reflectpass)
R_DrawViewModel ();
if (r_dspeeds->value)
@ -1870,23 +1800,22 @@ if(!reflectpass)
// test our flares.
if (!reflectpass)
R_TestFlares (); // leilei - flare testing
// if (foguse2)
// R_ApplyFog(); // you're too slow!
if (!reflectpass)
if (r_dspeeds->value)
dp_time2 = Sys_FloatTime ();
if (r_foundwater && !reflectpass)
if (r_foundwater)
{
r_drawwater = true;
R_EdgeDrawing ();
}
if (!reflectpass)
if (amilow != r_virtualmode->value)
{
amilow = r_virtualmode->value;
@ -1897,10 +1826,9 @@ if (!reflectpass)
vid.recalc_refdef = true;
}
//if (!reflectpass)
R_DrawFlares ();
if (!reflectpass){
if (overbrightmdl != r_overbrightmdl->value)
overbrightmdl = r_overbrightmdl->value;
if (particleset != r_particleset->value)
@ -1909,17 +1837,15 @@ if (!reflectpass)
particlespray = r_particlespray->value;
if (particleblood != r_particleblood->value)
particleblood = r_particleblood->value;
}
// now, render out lens flares afterward (sort hack)
// Screen Resolution Reduction
if(!reflectpass){
// if (r_docrap)
if (amilow) // 160x100
D_CrapScreen ();
@ -1930,22 +1856,21 @@ if (!reflectpass)
}
}
}
if (!reflectpass){
if (r_viewleaf->contents <= CONTENTS_WATER)
playersnd = 2;
else
playersnd = 0;
V_SetContentsColor (r_viewleaf->contents);
}
if (!reflectpass)
if (r_alphashift->value)
D_AlphaShift ();
if (!reflectpass){
if (r_timegraph->value)
R_TimeGraph ();
@ -1963,7 +1888,7 @@ if (!reflectpass)
if (r_reportedgeout->value && r_outofedges)
Con_Printf ("Short roughly %d edges\n", r_outofedges * 2 / 3);
}
// back to high floating-point precision
Sys_HighFPPrecision ();
}
@ -1987,12 +1912,6 @@ void R_RenderView (void)
if ( (long)(&r_warpbuffer) & 3 )
Sys_Error ("Globals are missaligned");
#ifdef WATERREFLECTIONS
if ( (long)(&r_reflectbuffer) & 3 )
Sys_Error ("Globals are missaligned");
#endif
if ( (long)(&r_lowbuffer) & 3 )
Sys_Error ("Globals are missaligned");
#ifdef EXPREND

View file

@ -404,9 +404,7 @@ void R_SetupFrame (void)
vrect_t vrect;
float w, h;
int dtail = 2; // leilei - screen detail
#ifdef SPLIT
cursplit = 0;
#endif
// don't allow cheats in multiplayer
if (cl.maxclients > 1)
{
@ -452,17 +450,6 @@ void R_SetupFrame (void)
numbtofpolys = 0;
// debugging
#if 0
r_refdef.vieworg[0] = 80;
r_refdef.vieworg[1] = 64;
r_refdef.vieworg[2] = 40;
r_refdef.viewangles[0] = 0;
r_refdef.viewangles[1] = 46.763641357;
r_refdef.viewangles[2] = 0;
#endif
// build the transformation matrix for the given view angles
VectorCopy (r_refdef.vieworg, modelorg);
VectorCopy (r_refdef.vieworg, r_origin);
@ -476,10 +463,6 @@ void R_SetupFrame (void)
r_dowarp = r_waterwarp->value && (r_viewleaf->contents <= CONTENTS_WATER);
inwat = s_underwater->value && (r_viewleaf->contents <= CONTENTS_WATER);
//r_docrapold = 0;
// r_docrap = 1;
//
if ((r_dowarp != r_dowarpold) || r_viewchanged || r_virtualmode->value || lcd_x->value || v_detail->value)
{
@ -494,15 +477,10 @@ void R_SetupFrame (void)
vrect.y = 0;
vrect.width = vid.width;
vrect.height = vid.height;
if (reflectpass){
R_SetVrect (&vrect, &r_refdef.vrect, 0);
R_ViewChanged (&vrect, 0, vid.aspect);
}
else
{
R_SetVrect (&vrect, &r_refdef.vrect, 0);
R_ViewChanged (&vrect, 0, vid.aspect);
}
}
else
@ -541,16 +519,11 @@ void R_SetupFrame (void)
vrect.y = 0;
vrect.width = vid.width;
vrect.height = vid.height;
if (reflectpass){
R_SetVrect (&vrect, &r_refdef.vrect, ((float)vid.height));
R_ViewChanged (&vrect, 0, vid.aspect);
}
else
{
R_SetVrect (&vrect, &r_refdef.vrect,
((float)vid.height));
R_ViewChanged (&vrect, 0, vid.aspect);
}
}
else
{
@ -644,12 +617,8 @@ void R_SetupFrame (void)
VectorCopy (vup, base_vup);
VectorCopy (modelorg, base_modelorg);
#ifndef PROTO
R_SetSkyFrame (); // Only do the sky moving on Quack
#endif
R_SetUpFrustumIndexes ();
r_cache_thrash = false;
// clear frame counts
@ -669,140 +638,3 @@ void R_SetupFrame (void)
D_SetupFrame ();
#endif
}
#ifdef SPLIT
void R_SetupFrameSplit (void)
{
int edgecount;
vrect_t vrect;
float w, h;
cursplit = 0;
// don't allow cheats in multiplayer
if (cl.maxclients > 1)
{
Cvar_Set (r_draworder, "0");
Cvar_Set (r_fullbright, "0");
Cvar_Set (r_ambient, "0");
Cvar_Set (r_drawflat, "0");
}
if (r_numsurfs->value)
{
if ((surface_p - surfaces) > r_maxsurfsseen)
r_maxsurfsseen = surface_p - surfaces;
Con_Printf ("Used %d of %d surfs; %d max\n", surface_p - surfaces,
surf_max - surfaces, r_maxsurfsseen);
}
if (r_numedges->value)
{
edgecount = edge_p - r_edges;
if (edgecount > r_maxedgesseen)
r_maxedgesseen = edgecount;
Con_Printf ("Used %d of %d edges; %d max\n", edgecount,
r_numallocatededges, r_maxedgesseen);
}
r_refdef.ambientlight = r_ambient->value;
if (r_refdef.ambientlight < 0)
r_refdef.ambientlight = 0;
if (!sv.active)
r_draworder->value = 0; // don't let cheaters look behind walls
R_CheckVariables ();
R_AnimateLight ();
r_framecount++;
numbtofpolys = 0;
// debugging
r_refdef.vieworg[0] = 80;
r_refdef.vieworg[1] = 64;
r_refdef.vieworg[2] = 40;
r_refdef.viewangles[0] = 0;
r_refdef.viewangles[1] = 46.763641357;
r_refdef.viewangles[2] = 0;
// build the transformation matrix for the given view angles
VectorCopy (r_refdef.vieworg, modelorg);
VectorCopy (r_refdef.vieworg, r_origin);
AngleVectors (r_refdef.viewangles, vpn, vright, vup);
// current viewleaf
r_oldviewleaf = r_viewleaf;
r_viewleaf = Mod_PointInLeaf (r_origin, cl.worldmodel);
scalefactoid = vid.height / vid.vconheight; // leilei
r_dowarpold = r_dowarp;
r_dowarp = r_waterwarp->value && (r_viewleaf->contents <= CONTENTS_WATER);
inwat = s_underwater->value && (r_viewleaf->contents <= CONTENTS_WATER);
// disable screen buffer effects in splitscreen
r_docrapold = 0;
r_docrap = 0;
r_dowarp = 0;
r_dowarpold = 0;
if ((r_dowarp != r_dowarpold) || r_viewchanged || r_virtualmode->value || lcd_x->value || v_detail->value)
{
{
vrect.x = 0;
vrect.y = 0;
vrect.width = vid.width;
vrect.height = vid.height;
R_ViewChanged (&vrect, (sb_what_lines / scalefactoid), vid.aspect);
}
r_viewchanged = false;
}
// start off with just the four screen edge clip planes
R_TransformFrustum ();
// save base values
VectorCopy (vpn, base_vpn);
VectorCopy (vright, base_vright);
VectorCopy (vup, base_vup);
VectorCopy (modelorg, base_modelorg);
#ifndef PROTO
R_SetSkyFrame (); // Only do the sky moving on Quack
#endif
R_SetUpFrustumIndexes ();
r_cache_thrash = false;
// clear frame counts
c_faceclip = 0;
d_spanpixcount = 0;
r_polycount = 0;
r_drawnpolycount = 0;
r_wholepolycount = 0;
r_amodels_drawn = 0;
r_outofsurfaces = 0;
r_outofedges = 0;
// WarpPalette();
D_SetupFrame ();
}
#endif

View file

@ -3473,14 +3473,10 @@ else
}
// make 'em move
#ifndef GLQUAKE
if (reflectpass || particletypeonly)
if (particletypeonly)
break;
#else
if (particletypeonly)
break;
#endif
if(particletypeonly == 0){
p->org[0] += p->vel[0] * frametime;
p->org[1] += p->vel[1] * frametime;
@ -4408,20 +4404,7 @@ void R_DrawFlares (void)
up[eh] *= 135;
}
if (reflectpass)
{
p->scale = (p->org[0] - r_refdef.vieworg[0])*vpn[0] + (p->org[1] - r_refdef.vieworg[1])*vpn[1]
+ (p->org[2] - r_refdef.vieworg[2])*vpn[2];
if (p->scale < 50)
p->scale = 0.06f;
else
p->scale = 0.02f + p->scale * 0.001;
p->scaley = p->scale * 5;
p->sprtype = SPR_VP_PARALLEL_UPRIGHT;
}
else
{
p->scale = (p->org[0] - r_refdef.vieworg[0])*vpn[0] + (p->org[1] - r_refdef.vieworg[1])*vpn[1]
+ (p->org[2] - r_refdef.vieworg[2])*vpn[2];
if (p->scale < 50)
@ -4431,7 +4414,7 @@ void R_DrawFlares (void)
p->scaley = p->scale;
p->sprtype = 5;
}
// new z check
if (p->amiseen)

View file

@ -58,7 +58,6 @@ int p_mouse_y;
int ignorenext;
int bits_per_pixel;
extern int deathcam_yesiamdead; // eukara - deathcam
extern int reflectavailable;
typedef struct
{