📄 dspproc.asm
字号:
dw -146,-146,-145,-144,-144,-143,-143,-142
dw -141,-141,-140,-139,-138,-137,-137,-136
dw -135,-134,-133,-132,-131,-130,-129,-128
dw -128,-126,-125,-124,-123,-122,-121,-120
dw -119,-118,-117,-116,-114,-113,-112,-111
dw -110,-109,-107,-106,-105,-104,-102,-101
dw -100, -99, -97, -96, -95, -93, -92, -91
dw -90, -88, -87, -86, -84, -83, -82, -80
dw -79, -78, -76, -75, -74, -72, -71, -70
dw -68, -67, -66, -64, -63, -62, -60, -59
dw -58, -56, -55, -54, -53, -51, -50, -49
dw -48, -46, -45, -44, -43, -41, -40, -39
dw -38, -37, -35, -34, -33, -32, -31, -30
dw -29, -28, -27, -26, -25, -24, -23, -22
dw -21, -20, -19, -18, -17, -16, -15, -14
dw -14, -13, -12, -11, -10, -10, -9, -8
dw -8, -7, -6, -6, -5, -5, -4, -4
dw -3, -3, -2, -2, -2, -1, -1, -1
dw 0, 0, 0, 0, 0, 0, 0, 0
ALIGN32
NEWSYM spcWptr, times 16 dd 0 ; SPC Write pointers (point to their own functions)
NEWSYM spcRptr, times 16 dd 0 ; SPC Read pointers (point to their own functions)
;dspWptr times 256 dd 0 ; DSP Write pointers (point to their own functions)
;dspRptr times 256 dd 0 ; DSP Read pointers (point to their own functions)
NEWSYM SoundQuality, dd 2
NEWSYM StereoSound, db 0
NEWSYM SBToSPC, dd 22050
NEWSYM NumBRRconv, dd 0
NEWSYM BufferSizeB, dd 320
NEWSYM BufferSizeW, dd 640
NEWSYM SBBufferLoc, dd 0
NEWSYM SBBufferMov, dd 0
NEWSYM SBBufferInc, dd 0
NEWSYM SoundInterrupt, dd 0
;TIME_CONSTANT = 256 - 1000000 / frequency
NEWSYM BufferSize, dw 320, 320, 320, 500, 320, 400, 400
NEWSYM BufferSizes, dw 320, 320, 500, 900, 400, 750, 750
NEWSYM SoundSpeeds, db 131, 165, 211, 233, 193, 225, 235 ; 8khz,11khz,22khz,44khz
NEWSYM SoundSpeedt, db 193, 210, 233 ; 8khz,11khz,22khz
NEWSYM SBToSPCSpeeds, dd 8000,10989,22222,43478,15874,32258,48000
NEWSYM SBToSPCSpeeds2, dd 8192,11289,22579,45158,16384,32768,48000
NEWSYM NumofSPCBlock, dd 626,456,228,114,314,156,104
NEWSYM SPCBlockNum, dd 0
NEWSYM NoiseSpeeds
dd 1,16,21,25,31,42,50,63,83,100,125,170,200,250,333,400,500,667,
dd 800,1000,1300,1600,2000,2700,3200,4000,5300,6400,8000,10700,
dd 16000,32000
NEWSYM conv2speedb
.next
mov eax,[esi]
mov ebx,[SBToSPC]
shr ebx,4
mul ebx
mov ebx,[SBRateb]
shr ebx,4
div ebx
cmp eax,0
jne .nozero
mov eax,1
.nozero
; mov [esi],eax
add esi,4
dec ecx
jnz .next
ret
%macro initpitchm 1
mov ax,[DSPMem+02h+%1*10h]
mov word[Voice0Pitch+%1*2],ax
xor ebx,ebx
xor edx,edx
and eax,03FFFh
shl eax,2
mov dl,ah
shl eax,24
mov ebx,[SBToSPC]
div ebx
shl eax,1
mov [Voice0Freq+%1*4],eax
; modpitch
%endmacro
NEWSYM initpitch
initpitchm 0
initpitchm 1
initpitchm 2
initpitchm 3
initpitchm 4
initpitchm 5
initpitchm 6
initpitchm 7
ret
%macro fixdspm 1
mov esi,%1
mov ecx,8
call conv2speedb
%endmacro
NEWSYM fixdsp
; mov dword[SBRateb],22050
cmp dword[SBRateb],0
je near .nofix
fixdspm Voice0Freq
fixdspm Voice0Time
fixdspm Voice0Attack
fixdspm Voice0Decay
fixdspm Voice0SustainR
fixdspm Voice0SustainR2
fixdspm Voice0IncNumber
fixdspm Voice0SLenNumber
fixdspm Voice0SEndNumber
fixdspm Voice0SEndLNumber
fixdspm Voice0DecreaseNumber
mov ebx,[SBToSPC]
mov [SBRateb],ebx
.nofix
ret
NEWSYM conv2speed
.next
mov eax,[edi]
mov ebx,[SBToSPC]
shr ebx,4
mul ebx
mov ebx,11025
shr ebx,4
div ebx
mov [esi],eax
add esi,4
add edi,4
dec ecx
jnz .next
ret
NEWSYM AdjustFrequency
cmp byte[UseCubicSpline],1
je .cubicspline
; Copy from Gaussian to DSPInterP
mov ebx,DSPInterP
mov edx,DSPInterP+2046
mov ecx,512
.intrploop
xor eax,eax
mov ax,[edx+1024]
mov [edx],ax
mov [ebx],ax
add ebx,2
sub edx,2
loop .intrploop
jmp .notgaussian
.cubicspline
; Copy from CubicSpline to DSPInterP
mov ebx,CubicSpline
mov edx,DSPInterP
mov ecx,1024
.intrploopb
xor eax,eax
mov ax,[ebx]
push ebx
mov bx,ax
sar bx,3
sub ax,bx
pop ebx
mov [edx],ax
add ebx,2
add edx,2
loop .intrploopb
.notgaussian
cmp byte[StereoSound],1
jne .nostereo8b
cmp byte[SBHDMA],0
jne .nostereo8b
; *****************************************
; *** ViBRA16X support by Peter Santing ***
; *****************************************
; before REALLY switching back to 8-bit sucky mono mode
; check that we're dealing with a ViBRA16X Creative Labs Card
cmp byte[vibracard], 1
je .nostereo8b
cmp dword[SoundQuality],2
jbe .nostereo8b
mov dword[SoundQuality],2
.nostereo8b
mov eax,[SoundQuality]
mov ebx,[NumofSPCBlock+eax*4]
cmp byte[StereoSound],1
jne .nostereo
shr ebx,1
.nostereo
mov [SPCBlockNum],ebx
.next
mov ecx,[SoundQuality]
mov eax,dword [SBToSPCSpeeds+ecx*4]
; code for supporting vibra cards (coded by Peter Santing)
cmp byte [vibracard], 1
je .vibrafix
cmp byte [SBHDMA],0
je .not16bit
mov eax,dword [SBToSPCSpeeds2+ecx*4]
.vibrafix
mov eax,dword [SBToSPCSpeeds2+ecx*4]
.not16bit
cmp byte[RaisePitch],0
jne .nopitchmodify
; *1000/1024
mov ebx,1024
mul ebx
xor edx,edx
mov ebx,1000
div ebx
.nopitchmodify
mov [SBToSPC],eax
mov [SBRateb],eax
; Init all rates
mov esi,EchoRate
mov edi,EchoRateO
mov ecx,16
call conv2speed
mov esi,AttackRate
mov edi,AttackRateO
mov ecx,16
call conv2speed
mov esi,DecayRate
mov edi,DecayRateO
mov ecx,8
call conv2speed
mov esi,SustainRate+4
mov edi,SustainRateO+4
mov ecx,31
call conv2speed
mov esi,Increase+4
mov edi,IncreaseO+4
mov ecx,31
call conv2speed
mov esi,IncreaseBent+4
mov edi,IncreaseBentO+4
mov ecx,31
call conv2speed
mov esi,Decrease+4
mov edi,DecreaseO+4
mov ecx,31
call conv2speed
mov esi,DecreaseRateExp+4
mov edi,DecreaseRateExpO+4
mov ecx,31
call conv2speed
mov dword[Voice0Pitch],0xFFFEFFFE
mov dword[Voice0Pitch+4],0xFFFEFFFE
mov dword[Voice0Pitch+8],0xFFFEFFFE
mov dword[Voice0Pitch+12],0xFFFEFFFE
ret
NEWSYM InitSPC
push eax
push ebx
push ecx
push edx
; Mirror Interpolation Table
mov ebx,Gaussian
mov ecx,512
.intloop
mov ax,[ebx]
or ax,ax
jz .nodec
dec ax
.nodec
mov [ebx],ax
dec ecx
jnz .intloop
call AdjustFrequency
mov ecx,32768
mov edx,32767
.nextvol
mov al,dh
imul dl
shr ax,7
movsx bx,al
mov [VolumeConvTable+edx*2],bx
dec edx
dec ecx
jnz .nextvol
mov eax,spcRam
mov ebx,0EFh
.loop2
mov byte[eax],0
inc eax
dec ebx
jnz .loop2
mov byte[spcX],0
xor eax,eax
xor ebx,ebx
mov ebp,spcRam
mov ax,0FFC9h
add ebp,eax
mov [spcPCRam],ebp
mov dword [spcS],1EFh
mov dword [spcRamDP],spcRam
; initialize all the SPC write registers
mov dword[spcWptr+0],SPCRegF0
mov dword[spcWptr+4],SPCRegF1
mov dword[spcWptr+8],SPCRegF2
mov dword[spcWptr+12],SPCRegF3
mov dword[spcWptr+16],SPCRegF4
mov dword[spcWptr+20],SPCRegF5
mov dword[spcWptr+24],SPCRegF6
mov dword[spcWptr+28],SPCRegF7
mov dword[spcWptr+32],SPCRegF8
mov dword[spcWptr+36],SPCRegF9
mov dword[spcWptr+40],SPCRegFA
mov dword[spcWptr+44],SPCRegFB
mov dword[spcWptr+48],SPCRegFC
mov dword[spcWptr+52],SPCRegFD
mov dword[spcWptr+56],SPCRegFE
mov dword[spcWptr+60],SPCRegFF
mov dword[spcRptr+0],RSPCRegF0
mov dword[spcRptr+4],RSPCRegF1
mov dword[spcRptr+8],RSPCRegF2
mov dword[spcRptr+12],RSPCRegF3
mov dword[spcRptr+16],RSPCRegF4
mov dword[spcRptr+20],RSPCRegF5
mov dword[spcRptr+24],RSPCRegF6
mov dword[spcRptr+28],RSPCRegF7
mov dword[spcRptr+32],RSPCRegF8
mov dword[spcRptr+36],RSPCRegF9
mov dword[spcRptr+40],RSPCRegFA
mov dword[spcRptr+44],RSPCRegFB
mov dword[spcRptr+48],RSPCRegFC
mov dword[spcRptr+52],RSPCRegFD
mov dword[spcRptr+56],RSPCRegFE
mov dword[spcRptr+60],RSPCRegFF
mov dword [dspRptr+00h],RDSPReg00
mov dword [dspRptr+04h],RDSPReg01
mov dword [dspRptr+08h],RDSPReg02
mov dword [dspRptr+0Ch],RDSPReg03
mov dword [dspRptr+010h],RDSPReg04
mov dword [dspRptr+014h],RDSPReg05
mov dword [dspRptr+018h],RDSPReg06
mov dword [dspRptr+01Ch],RDSPReg07
mov dword [dspRptr+020h],RDSPReg08
mov dword [dspRptr+024h],RDSPReg09
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -