|
|
1.1 ! root 1: // ! 2: // snd_mixa.s ! 3: // x86 assembly-language sound code ! 4: // ! 5: ! 6: #include "asm_i386.h" ! 7: #include "quakeasm.h" ! 8: ! 9: #if id386 ! 10: ! 11: .text ! 12: ! 13: //---------------------------------------------------------------------- ! 14: // 8-bit sound-mixing code ! 15: //---------------------------------------------------------------------- ! 16: ! 17: #define ch 4+16 ! 18: #define sc 8+16 ! 19: #define count 12+16 ! 20: ! 21: .globl C(SND_PaintChannelFrom8) ! 22: C(SND_PaintChannelFrom8): ! 23: pushl %esi // preserve register variables ! 24: pushl %edi ! 25: pushl %ebx ! 26: pushl %ebp ! 27: ! 28: // int data; ! 29: // short *lscale, *rscale; ! 30: // unsigned char *sfx; ! 31: // int i; ! 32: ! 33: movl ch(%esp),%ebx ! 34: movl sc(%esp),%esi ! 35: ! 36: // if (ch->leftvol > 255) ! 37: // ch->leftvol = 255; ! 38: // if (ch->rightvol > 255) ! 39: // ch->rightvol = 255; ! 40: movl ch_leftvol(%ebx),%eax ! 41: movl ch_rightvol(%ebx),%edx ! 42: cmpl $255,%eax ! 43: jna LLeftSet ! 44: movl $255,%eax ! 45: LLeftSet: ! 46: cmpl $255,%edx ! 47: jna LRightSet ! 48: movl $255,%edx ! 49: LRightSet: ! 50: ! 51: // lscale = snd_scaletable[ch->leftvol >> 3]; ! 52: // rscale = snd_scaletable[ch->rightvol >> 3]; ! 53: // sfx = (signed char *)sc->data + ch->pos; ! 54: // ch->pos += count; ! 55: andl $0xF8,%eax ! 56: addl $sfxc_data,%esi ! 57: andl $0xF8,%edx ! 58: movl ch_pos(%ebx),%edi ! 59: movl count(%esp),%ecx ! 60: addl %edi,%esi ! 61: shll $7,%eax ! 62: addl %ecx,%edi ! 63: shll $7,%edx ! 64: movl %edi,ch_pos(%ebx) ! 65: addl $C(snd_scaletable),%eax ! 66: addl $C(snd_scaletable),%edx ! 67: subl %ebx,%ebx ! 68: movb -1(%esi,%ecx,1),%bl ! 69: ! 70: testl $1,%ecx ! 71: jz LMix8Loop ! 72: ! 73: movl (%eax,%ebx,4),%edi ! 74: movl (%edx,%ebx,4),%ebp ! 75: addl C(paintbuffer)+psp_left-psp_size(,%ecx,psp_size),%edi ! 76: addl C(paintbuffer)+psp_right-psp_size(,%ecx,psp_size),%ebp ! 77: movl %edi,C(paintbuffer)+psp_left-psp_size(,%ecx,psp_size) ! 78: movl %ebp,C(paintbuffer)+psp_right-psp_size(,%ecx,psp_size) ! 79: movb -2(%esi,%ecx,1),%bl ! 80: ! 81: decl %ecx ! 82: jz LDone ! 83: ! 84: // for (i=0 ; i<count ; i++) ! 85: // { ! 86: LMix8Loop: ! 87: ! 88: // data = sfx[i]; ! 89: // paintbuffer[i].left += lscale[data]; ! 90: // paintbuffer[i].right += rscale[data]; ! 91: movl (%eax,%ebx,4),%edi ! 92: movl (%edx,%ebx,4),%ebp ! 93: addl C(paintbuffer)+psp_left-psp_size(,%ecx,psp_size),%edi ! 94: addl C(paintbuffer)+psp_right-psp_size(,%ecx,psp_size),%ebp ! 95: movb -2(%esi,%ecx,1),%bl ! 96: movl %edi,C(paintbuffer)+psp_left-psp_size(,%ecx,psp_size) ! 97: movl %ebp,C(paintbuffer)+psp_right-psp_size(,%ecx,psp_size) ! 98: ! 99: movl (%eax,%ebx,4),%edi ! 100: movl (%edx,%ebx,4),%ebp ! 101: movb -3(%esi,%ecx,1),%bl ! 102: addl C(paintbuffer)+psp_left-psp_size*2(,%ecx,psp_size),%edi ! 103: addl C(paintbuffer)+psp_right-psp_size*2(,%ecx,psp_size),%ebp ! 104: movl %edi,C(paintbuffer)+psp_left-psp_size*2(,%ecx,psp_size) ! 105: movl %ebp,C(paintbuffer)+psp_right-psp_size*2(,%ecx,psp_size) ! 106: ! 107: // } ! 108: subl $2,%ecx ! 109: jnz LMix8Loop ! 110: ! 111: LDone: ! 112: popl %ebp ! 113: popl %ebx ! 114: popl %edi ! 115: popl %esi ! 116: ! 117: ret ! 118: ! 119: ! 120: //---------------------------------------------------------------------- ! 121: // Transfer of stereo buffer to 16-bit DMA buffer code ! 122: //---------------------------------------------------------------------- ! 123: ! 124: .globl C(Snd_WriteLinearBlastStereo16) ! 125: C(Snd_WriteLinearBlastStereo16): ! 126: pushl %esi // preserve register variables ! 127: pushl %edi ! 128: pushl %ebx ! 129: ! 130: // int i; ! 131: // int val; ! 132: movl C(snd_linear_count),%ecx ! 133: movl C(snd_p),%ebx ! 134: movl C(snd_vol),%esi ! 135: movl C(snd_out),%edi ! 136: ! 137: // for (i=0 ; i<snd_linear_count ; i+=2) ! 138: // { ! 139: LWLBLoopTop: ! 140: ! 141: // val = (snd_p[i]*snd_vol)>>8; ! 142: // if (val > 0x7fff) ! 143: // snd_out[i] = 0x7fff; ! 144: // else if (val < (short)0x8000) ! 145: // snd_out[i] = (short)0x8000; ! 146: // else ! 147: // snd_out[i] = val; ! 148: movl -8(%ebx,%ecx,4),%eax ! 149: imull %esi,%eax ! 150: sarl $8,%eax ! 151: cmpl $0x7FFF,%eax ! 152: jg LClampHigh ! 153: cmpl $0xFFFF8000,%eax ! 154: jnl LClampDone ! 155: movl $0xFFFF8000,%eax ! 156: jmp LClampDone ! 157: LClampHigh: ! 158: movl $0x7FFF,%eax ! 159: LClampDone: ! 160: ! 161: // val = (snd_p[i+1]*snd_vol)>>8; ! 162: // if (val > 0x7fff) ! 163: // snd_out[i+1] = 0x7fff; ! 164: // else if (val < (short)0x8000) ! 165: // snd_out[i+1] = (short)0x8000; ! 166: // else ! 167: // snd_out[i+1] = val; ! 168: movl -4(%ebx,%ecx,4),%edx ! 169: imull %esi,%edx ! 170: sarl $8,%edx ! 171: cmpl $0x7FFF,%edx ! 172: jg LClampHigh2 ! 173: cmpl $0xFFFF8000,%edx ! 174: jnl LClampDone2 ! 175: movl $0xFFFF8000,%edx ! 176: jmp LClampDone2 ! 177: LClampHigh2: ! 178: movl $0x7FFF,%edx ! 179: LClampDone2: ! 180: shll $16,%edx ! 181: andl $0xFFFF,%eax ! 182: orl %eax,%edx ! 183: movl %edx,-4(%edi,%ecx,2) ! 184: ! 185: // } ! 186: subl $2,%ecx ! 187: jnz LWLBLoopTop ! 188: ! 189: // snd_p += snd_linear_count; ! 190: ! 191: popl %ebx ! 192: popl %edi ! 193: popl %esi ! 194: ! 195: ret ! 196: ! 197: ! 198: #endif // id386 ! 199:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.