mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-29 15:51:45 +00:00
sind_dma.c aufgeräumt
This commit is contained in:
parent
ca7ab15c1c
commit
1c161a9930
2 changed files with 33 additions and 87 deletions
|
@ -34,7 +34,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define SHELL_BLUE_COLOR 0xF3
|
||||
|
||||
#define SHELL_RG_COLOR 0xDC
|
||||
//#define SHELL_RB_COLOR 0x86
|
||||
#define SHELL_RB_COLOR 0x68
|
||||
#define SHELL_BG_COLOR 0x78
|
||||
|
||||
|
@ -74,20 +73,12 @@ typedef struct entity_s
|
|||
|
||||
struct image_s *skin; // NULL for inline skin
|
||||
int flags;
|
||||
#ifdef QMAX
|
||||
int renderfx;
|
||||
#endif
|
||||
} entity_t;
|
||||
|
||||
#define ENTITY_FLAGS 68
|
||||
|
||||
typedef struct
|
||||
{
|
||||
#ifdef QMAX
|
||||
qboolean spotlight;
|
||||
vec3_t direction;
|
||||
#endif
|
||||
|
||||
vec3_t origin;
|
||||
vec3_t color;
|
||||
float intensity;
|
||||
|
@ -98,17 +89,6 @@ typedef struct
|
|||
vec3_t origin;
|
||||
int color;
|
||||
float alpha;
|
||||
#ifdef QMAX
|
||||
vec3_t angle;
|
||||
float size;
|
||||
int flags;
|
||||
|
||||
float red;
|
||||
float green;
|
||||
float blue;
|
||||
|
||||
int image;
|
||||
#endif
|
||||
} particle_t;
|
||||
|
||||
typedef struct
|
||||
|
@ -141,8 +121,6 @@ typedef struct
|
|||
particle_t *particles;
|
||||
} refdef_t;
|
||||
|
||||
|
||||
|
||||
#define API_VERSION 3
|
||||
|
||||
//
|
||||
|
@ -180,18 +158,8 @@ typedef struct
|
|||
void (*EndRegistration) (void);
|
||||
|
||||
void (*RenderFrame) (refdef_t *fd);
|
||||
|
||||
#ifdef QMAX
|
||||
void (*AddStain) (vec3_t org, float intensity, float r, float g, float b);
|
||||
void (*SetParticlePicture) (int num, char *name);
|
||||
void (*DrawScaledPic) (int x, int y, float scale, float alpha, char *name);
|
||||
float (*CharMap_Scale) (void);
|
||||
void (*DrawStretchPic) (int x, int y, int w, int h, char *name, float alpha);
|
||||
void (*DrawChar) (int x, int y, int c, int alpha);
|
||||
#else
|
||||
void (*DrawStretchPic) (int x, int y, int w, int h, char *name);
|
||||
void (*DrawChar) (int x, int y, int c);
|
||||
#endif
|
||||
void (*DrawGetPicSize) (int *w, int *h, char *name); // will return 0 0 if not found
|
||||
void (*DrawPic) (int x, int y, char *name);
|
||||
void (*DrawTileClear) (int x, int y, int w, int h, char *name);
|
||||
|
@ -246,28 +214,8 @@ typedef struct
|
|||
qboolean (*Vid_GetModeInfo)( int *width, int *height, int mode );
|
||||
void (*Vid_MenuInit)( void );
|
||||
void (*Vid_NewWindow)( int width, int height );
|
||||
|
||||
#ifdef QMAX
|
||||
void (*SetParticlePics) (void);
|
||||
#endif
|
||||
} refimport_t;
|
||||
|
||||
#ifdef QMAX
|
||||
#define DIV254BY255 (0.9960784313725490196078431372549f)
|
||||
#define DIV255 (0.003921568627450980392156862745098f)
|
||||
#define DIV256 (0.00390625f)
|
||||
#define DIV512 (0.001953125f)
|
||||
#define TWOTHIRDS (0.666666666666666666666666666666666666666f)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t origin;
|
||||
vec3_t color;
|
||||
float intensity;
|
||||
} dstain_t;
|
||||
#endif
|
||||
|
||||
|
||||
// this is the only function actually exported at the linker level
|
||||
typedef refexport_t (*GetRefAPI_t) (refimport_t);
|
||||
|
||||
|
|
|
@ -448,17 +448,17 @@ void S_SpatializeOrigin (vec3_t origin, float master_vol, float dist_mult, int *
|
|||
|
||||
if (dma.channels == 1 || !dist_mult)
|
||||
{ // no attenuation = no spatialization
|
||||
rscale = 1.0;
|
||||
lscale = 1.0;
|
||||
rscale = 1.0f;
|
||||
lscale = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
rscale = 0.5 * (1.0 + dot);
|
||||
lscale = 0.5*(1.0 - dot);
|
||||
rscale = 0.5f * (1.0f + dot);
|
||||
lscale = 0.5f * (1.0f - dot);
|
||||
}
|
||||
|
||||
// add in distance effect
|
||||
scale = (1.0 - dist) * rscale;
|
||||
scale = (1.0f - dist) * rscale;
|
||||
*right_vol = (int) (master_vol * scale);
|
||||
if (*right_vol < 0)
|
||||
*right_vol = 0;
|
||||
|
@ -493,7 +493,7 @@ void S_Spatialize(channel_t *ch)
|
|||
else
|
||||
CL_GetEntitySoundOrigin (ch->entnum, origin);
|
||||
|
||||
S_SpatializeOrigin (origin, ch->master_vol, ch->dist_mult, &ch->leftvol, &ch->rightvol);
|
||||
S_SpatializeOrigin (origin, (float)ch->master_vol, ch->dist_mult, &ch->leftvol, &ch->rightvol);
|
||||
}
|
||||
|
||||
|
||||
|
@ -564,9 +564,9 @@ void S_IssuePlaysound (playsound_t *ps)
|
|||
|
||||
// spatialize
|
||||
if (ps->attenuation == ATTN_STATIC)
|
||||
ch->dist_mult = ps->attenuation * 0.001;
|
||||
ch->dist_mult = ps->attenuation * 0.001f;
|
||||
else
|
||||
ch->dist_mult = ps->attenuation * 0.0005;
|
||||
ch->dist_mult = ps->attenuation * 0.0005f;
|
||||
ch->master_vol = ps->volume;
|
||||
ch->entnum = ps->entnum;
|
||||
ch->entchannel = ps->entchannel;
|
||||
|
@ -695,16 +695,16 @@ void S_StartSound(vec3_t origin, int entnum, int entchannel, sfx_t *sfx, float f
|
|||
ps->sfx = sfx;
|
||||
|
||||
// drift s_beginofs
|
||||
start = cl.frame.servertime * 0.001 * dma.speed + s_beginofs;
|
||||
start = (int)(cl.frame.servertime * 0.001f * dma.speed + s_beginofs);
|
||||
if (start < paintedtime)
|
||||
{
|
||||
start = paintedtime;
|
||||
s_beginofs = start - (cl.frame.servertime * 0.001 * dma.speed);
|
||||
s_beginofs = (int)(start - (cl.frame.servertime * 0.001f * dma.speed));
|
||||
}
|
||||
else if (start > paintedtime + 0.3 * dma.speed)
|
||||
else if (start > paintedtime + 0.3f * dma.speed)
|
||||
{
|
||||
start = paintedtime + 0.1 * dma.speed;
|
||||
s_beginofs = start - (cl.frame.servertime * 0.001 * dma.speed);
|
||||
start = (int)(paintedtime + 0.1f * dma.speed);
|
||||
s_beginofs = (int)(start - (cl.frame.servertime * 0.001f * dma.speed));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -714,7 +714,7 @@ void S_StartSound(vec3_t origin, int entnum, int entchannel, sfx_t *sfx, float f
|
|||
if (!timeofs)
|
||||
ps->begin = paintedtime;
|
||||
else
|
||||
ps->begin = start + timeofs * dma.speed;
|
||||
ps->begin = (int)(start + timeofs * dma.speed);
|
||||
|
||||
// sort into the pending sound list
|
||||
for (sort = s_pendingplays.next ;
|
||||
|
@ -870,7 +870,7 @@ void S_AddLoopSounds (void)
|
|||
ent = &cl_parse_entities[num];
|
||||
|
||||
// find the total contribution of all sounds of this type
|
||||
S_SpatializeOrigin (ent->origin, 255.0, SOUND_LOOPATTENUATE,
|
||||
S_SpatializeOrigin (ent->origin, 255.0f, SOUND_LOOPATTENUATE,
|
||||
&left_total, &right_total);
|
||||
for (j=i+1 ; j<cl.frame.num_entities ; j++)
|
||||
{
|
||||
|
@ -881,7 +881,7 @@ void S_AddLoopSounds (void)
|
|||
num = (cl.frame.parse_entities + j)&(MAX_PARSE_ENTITIES-1);
|
||||
ent = &cl_parse_entities[num];
|
||||
|
||||
S_SpatializeOrigin (ent->origin, 255.0, SOUND_LOOPATTENUATE,
|
||||
S_SpatializeOrigin (ent->origin, 255.0f, SOUND_LOOPATTENUATE,
|
||||
&left, &right);
|
||||
left_total += left;
|
||||
right_total += right;
|
||||
|
@ -948,7 +948,6 @@ void S_RawSamples (int samples, int rate, int width, int channels, byte *data)
|
|||
s_rawend = paintedtime;
|
||||
scale = (float)rate / dma.speed;
|
||||
|
||||
//Com_Printf ("%i < %i < %i\n", soundtime, paintedtime, s_rawend);
|
||||
if (channels == 2 && width == 2)
|
||||
{
|
||||
if (scale == 1.0)
|
||||
|
@ -967,7 +966,7 @@ void S_RawSamples (int samples, int rate, int width, int channels, byte *data)
|
|||
{
|
||||
for (i=0 ; ; i++)
|
||||
{
|
||||
src = i*scale;
|
||||
src = (int)(i*scale);
|
||||
if (src >= samples)
|
||||
break;
|
||||
dst = s_rawend&(MAX_RAW_SAMPLES-1);
|
||||
|
@ -983,7 +982,7 @@ void S_RawSamples (int samples, int rate, int width, int channels, byte *data)
|
|||
{
|
||||
for (i=0 ; ; i++)
|
||||
{
|
||||
src = i*scale;
|
||||
src = (int)(i*scale);
|
||||
if (src >= samples)
|
||||
break;
|
||||
dst = s_rawend&(MAX_RAW_SAMPLES-1);
|
||||
|
@ -998,7 +997,7 @@ void S_RawSamples (int samples, int rate, int width, int channels, byte *data)
|
|||
{
|
||||
for (i=0 ; ; i++)
|
||||
{
|
||||
src = i*scale;
|
||||
src = (int)(i*scale);
|
||||
if (src >= samples)
|
||||
break;
|
||||
dst = s_rawend&(MAX_RAW_SAMPLES-1);
|
||||
|
@ -1013,7 +1012,7 @@ void S_RawSamples (int samples, int rate, int width, int channels, byte *data)
|
|||
{
|
||||
for (i=0 ; ; i++)
|
||||
{
|
||||
src = i*scale;
|
||||
src = (int)(i*scale);
|
||||
if (src >= samples)
|
||||
break;
|
||||
dst = s_rawend&(MAX_RAW_SAMPLES-1);
|
||||
|
@ -1161,8 +1160,7 @@ void S_Update_(void)
|
|||
}
|
||||
|
||||
// mix ahead of current position
|
||||
endtime = soundtime + s_mixahead->value * dma.speed;
|
||||
//endtime = (soundtime + 4096) & ~4095;
|
||||
endtime = (int)(soundtime + s_mixahead->value * dma.speed);
|
||||
|
||||
// mix to an even submission block size
|
||||
endtime = (endtime + dma.submission_chunk-1)
|
||||
|
@ -1195,11 +1193,11 @@ void S_Play(void)
|
|||
{
|
||||
if (!strrchr(Cmd_Argv(i), '.'))
|
||||
{
|
||||
strcpy(name, Cmd_Argv(i));
|
||||
strncpy(name, Cmd_Argv(i), sizeof(name)-5);
|
||||
strcat(name, ".wav");
|
||||
}
|
||||
else
|
||||
strcpy(name, Cmd_Argv(i));
|
||||
strncpy(name, Cmd_Argv(i), sizeof(name)-1);
|
||||
sfx = S_RegisterSound(name);
|
||||
S_StartSound(NULL, cl.playernum+1, 0, sfx, 1.0, 1.0, 0);
|
||||
i++;
|
||||
|
|
Loading…
Reference in a new issue