From 6b3b94bafc8dd9cb777ae4cf148ff99e7f2ba7c3 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 12 Apr 2001 06:53:07 +0000 Subject: [PATCH] sound crashing bug fixes snd_dma.c, {nq,qw}/source/cl_parse.c: change the type of snd_worldmodel from * to ** and init snd_worldmodel with the ADDRESS of cl.worldmodel so its changes get seen by snd_dma snd_mixa.S: picize --- libs/audio/targets/snd_dma.c | 6 +-- libs/audio/targets/snd_mixa.S | 95 ++++++++++++++++++++++++++--------- nq/source/cl_parse.c | 3 +- qw/source/cl_parse.c | 4 +- 4 files changed, 77 insertions(+), 31 deletions(-) diff --git a/libs/audio/targets/snd_dma.c b/libs/audio/targets/snd_dma.c index 9a56da641..f88524066 100644 --- a/libs/audio/targets/snd_dma.c +++ b/libs/audio/targets/snd_dma.c @@ -135,7 +135,7 @@ int fakedma_updates = 15; // FIXME: Evil hack that doesn't deserve to see the light of day. // (pending merge of nq and qw client_stat_t's) extern int snd_viewentity; -extern struct model_s *snd_worldmodel; +extern struct model_s **snd_worldmodel; void S_AmbientOff (void) @@ -715,10 +715,10 @@ S_UpdateAmbientSounds (void) return; // calc ambient sound levels - if (!snd_worldmodel) + if (!*snd_worldmodel) return; - l = Mod_PointInLeaf (listener_origin, snd_worldmodel); + l = Mod_PointInLeaf (listener_origin, *snd_worldmodel); if (!l || !ambient_level->value) { for (ambient_channel = 0; ambient_channel < NUM_AMBIENTS; ambient_channel++) diff --git a/libs/audio/targets/snd_mixa.S b/libs/audio/targets/snd_mixa.S index e135fc383..33eebca9e 100644 --- a/libs/audio/targets/snd_mixa.S +++ b/libs/audio/targets/snd_mixa.S @@ -52,6 +52,9 @@ #define count 12+16 .globl C(SND_PaintChannelFrom8) +#ifdef PIC + .type C(SND_PaintChannelFrom8),@function +#endif C(SND_PaintChannelFrom8): pushl %esi // preserve register variables pushl %edi @@ -93,25 +96,44 @@ LRightSet: addl %edi,%esi shll $7,%eax addl %ecx,%edi + addl %ecx,%esi shll $7,%edx movl %edi,ch_pos(%ebx) - addl $(C(snd_scaletable)),%eax - addl $(C(snd_scaletable)),%edx - subl %ebx,%ebx - movb -1(%esi,%ecx,1),%bl + +#ifdef PIC + call .Lpic1 +.Lpic1: popl %ebx + addl $_GLOBAL_OFFSET_TABLE_+[.-.Lpic1],%ebx + + leal C(snd_scaletable)@GOTOFF(%ebx,%eax),%eax + leal C(snd_scaletable)@GOTOFF(%ebx,%edx),%edx + + leal C(paintbuffer)@GOTOFF(%ebx),%ebx +#else + leal C(snd_scaletable)(%eax),%eax + leal C(snd_scaletable)(%edx),%edx + + leal C(paintbuffer),%ebx +#endif + pushl %ebx // save paintbuffer offset testl $1,%ecx + leal 0(%ebx,%ecx,psp_size),%ecx + movl $0,%ebx + movb -1(%esi),%bl jz LMix8Loop movl (%eax,%ebx,4),%edi movl (%edx,%ebx,4),%ebp - addl C(paintbuffer)+psp_left-psp_size(,%ecx,psp_size),%edi - addl C(paintbuffer)+psp_right-psp_size(,%ecx,psp_size),%ebp - movl %edi,C(paintbuffer)+psp_left-psp_size(,%ecx,psp_size) - movl %ebp,C(paintbuffer)+psp_right-psp_size(,%ecx,psp_size) - movb -2(%esi,%ecx,1),%bl + addl psp_left-psp_size(%ecx),%edi + addl psp_right-psp_size(%ecx),%ebp + movl %edi,psp_left-psp_size(%ecx) + movl %ebp,psp_right-psp_size(%ecx) + movb -2(%esi),%bl - decl %ecx + subl $psp_size,%ecx + decl %esi + cmpl (%esp),%ecx jz LDone // for (i=0 ; i