⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dsp.asm

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 ASM
📖 第 1 页 / 共 5 页
字号:
      mov [AdsrBlocksLeft+%1],al
      sub ebx,edx
      push ebx
      push eax
      mov ebx,eax
      mov eax,edx
      xor edx,edx
      or ebx,ebx
      jz .oopszero
      div ebx
.oopszero
      mov [Voice0Time+%1*4],eax
      mov [GainDecBendDataTime+%1*4],eax
      pop eax
      pop ebx
      mov edx,ebx
      mov ebx,64
      sub bl,al
      mov eax,edx
      xor edx,edx
      div ebx
      mov [AdsrNextTimeDepth+%1*4],eax
      mov dword[Voice0EnvInc+%1*4],0
      mov al,[GainDecBendDataDat+%1]
      mov [Voice0EnvInc+%1*4+2],al
      mov ebx,[Voice0Time+%1*4]
      xor edx,edx

      mov dh,122
      mov dl,[Voice0EnvInc+%1*4+2]
      xor eax,eax
      mov al,[VolumeConvTable+edx*2]
      xor edx,edx
      shl eax,16
      mov dl,[Voice0EnvInc+%1*4+2]
      neg eax
      shl edx,16
      add eax,edx
      xor edx,edx
      mov byte[GainDecBendDataPos+%1],0
      div ebx
      neg eax
      mov [Voice0IncNumber+%1*4],eax
      pop edx
      pop ebx
      pop eax
      mov byte [Voice0State+%1],9
      ret
%%decayover
      sub edx,ebx
      push ebx
      mov eax,edx
      xor ebx,ebx
      mov bl,[DSPMem+06h+%1*10h]
      shr bl,5
      xor bl,07h
      mul ebx
      mov ebx,7
      div ebx
      pop ebx
      add ebx,eax
      mov dword[Voice0EnvInc+%1*4],007FFFFFh
      shr ebx,5
      mov dword[Voice0Time+%1*4],ebx
      mov [GainDecBendDataTime+%1*4],ebx
      xor edx,edx

      mov dh,118
      mov dl,[Voice0EnvInc+%1*4+2]
      xor eax,eax
      mov al,[VolumeConvTable+edx*2]
      xor edx,edx
      shl eax,16
      mov dl,[Voice0EnvInc+%1*4+2]
      neg eax
      shl edx,16
      add eax,edx
      xor edx,edx
      mov byte[GainDecBendDataPos+%1],0
      div ebx
      neg eax
      mov [Voice0IncNumber+%1*4],eax
      pop edx
      pop ebx
      pop eax
      mov byte [Voice0State+%1],7
      ret
%endmacro

%macro VoiceAdsr 1
      test byte[MuteVoiceF],1 << %1
      jnz near .nogain
      cmp byte[Voice0State+%1],200
      je near .nogain
      cmp [DSPMem+05h+%1*10h],al
      je near .nogain
      test al,80h
      jz near .gain
      mov [DSPMem+05h+%1*10h],al
      SwitchSustain %1
      ret
.nogain
      mov [DSPMem+05h+%1*10h],al
      ret
.gain
      cmp byte[Voice0Status+%1],1
      jne .nogain
      cmp word[DSPMem+06h+%1*10h],0A0E0h
      je .nogain
      test byte[DSPMem+05h+%1*10h],80h
      jz near .gain2
      cmp byte[Voice0State+%1],8
      je .gain1
      cmp byte[Voice0State+%1],2
      jae near .gain2
.gain1
      mov [DSPMem+05h+%1*10h],al
      ProcessGain %1   ; Normal
      ret
.gain2
      mov [DSPMem+05h+%1*10h],al
      cmp byte [Voice0State+%1],210
      jne %%noendofsamp2
      push eax
      push ebx
      mov al,%1
      call VoiceStarter
      mov dword[Voice0EnvInc+%1*4],007FFFFFh
      pop ebx
      pop eax
%%noendofsamp2
      ProcessGain2 %1
      ret
%endmacro

%macro VoiceAdsr2 1
      test byte[MuteVoiceF],1 << %1
      jnz near .noadsrswitch
      cmp byte[Voice0State+%1],200
      je near .noadsrswitch
      cmp [DSPMem+06h+%1*10h],al
      je near .noadsrswitch
      mov [DSPMem+06h+%1*10h],al
      test byte[DSPMem+05h+%1*10h],80h
      jz near .noadsrswitch
      SwitchSustain %1
      ret
.noadsrswitch
      mov [DSPMem+06h+%1*10h],al
      ret
%endmacro


%macro VoiceGain 1
      test byte[MuteVoiceF],1 << %1
      jnz near .nogain
      cmp byte[Voice0State+%1],200
      je near .nogain
      cmp [DSPMem+07h+%1*10h],al
      je near .nogain
      mov [DSPMem+07h+%1*10h],al
      cmp byte[Voice0Status+%1],1
      jne .nogain
      test byte[DSPMem+05h+%1*10h],80h
      jz .gain
.nogain
      mov [DSPMem+07h+%1*10h],al
      ret
.gain
      cmp byte [Voice0State+%1],210
      jne %%noendofsamp
      push eax
      push ebx
      mov al,%1
      call VoiceStarter
      pop ebx
      pop eax
%%noendofsamp
      ProcessGain2 %1
%endmacro

NEWSYM ADSRGAINSwitch, db 0

;Write DSP Registers functions

NEWSYM WDSPReg00       ; Voice  0  Volume Left                                                                                                                                                                                                                                                     
;      cmp byte[RevStereo],1
;      je .rev
      mov [DSPMem+00h],al
      ret
.rev
      mov [DSPMem+01h],al
      ret

NEWSYM WDSPReg01       ; Voice  0  Volume Right                                                                                                                                                                                                                                                    
;      cmp byte[RevStereo],1
;      je .rev
      mov [DSPMem+01h],al
      ret
.rev
      mov [DSPMem+00h],al
      ret

NEWSYM WDSPReg02       ; Voice  0  Pitch Low                                                                                                                                                                                                                                                       
      mov [DSPMem+02h],al
      ret

NEWSYM WDSPReg03       ; Voice  0  Pitch High                                                                                                                                                                                                                                                      
      mov [DSPMem+03h],al
      ret

NEWSYM WDSPReg04       ; Voice  0  SCRN                                                                                                                                                                                                                                                            
      mov [DSPMem+04h],al
      ret

NEWSYM TempValueSnd, db 0

NEWSYM WDSPReg05       ; Voice  0  ADSR (1)
      inc byte[TempValueSnd]
      VoiceAdsr 0
      ret

NEWSYM WDSPReg06       ; Voice  0  ADSR (2)                                                                                                                                                                                                                                                        
      inc byte[TempValueSnd]
      VoiceAdsr2 0
      ret

NEWSYM WDSPReg07       ; Voice  0  GAIN                                                                                                                                                                                                                                                            
      inc byte[TempValueSnd]
      VoiceGain 0
      ret

NEWSYM WDSPReg08       ; Voice  0  ENVX
      mov [DSPMem+08h],al
      ret

NEWSYM WDSPReg09       ; Voice  0  OUTX
      mov [DSPMem+09h],al
      ret

NEWSYM WDSPReg0A       ; Voice  0                                                                                                                                                                                                                                                                  
      mov [DSPMem+0Ah],al
      ret

NEWSYM WDSPReg0B       ; Voice  0                                                                                                                                                                                                                                                                  
      mov [DSPMem+0Bh],al
      ret

NEWSYM WDSPReg0C       ; Voice  0                                                                                                                                                                                                                                                                  
      mov [DSPMem+0Ch],al
      push eax
      and eax,0FFh
      mov al,[VolumeTableb+eax]
      mov ah,[MusicVol]
      mov al,[VolumeConvTable+eax*2]
;      cmp byte[RevStereo],1
;      je .rev
      mov [GlobalVL],al
      pop eax
      ret
.rev
      mov [GlobalVR],al
      pop eax
      ret

NEWSYM WDSPReg0D       ; Echo Feedback                                                                                                                                                                                                                                                             
      mov [DSPMem+0Dh],al
      push eax
      and eax,0FFh
      mov al,[VolumeTableb+eax]
      mov [EchoFB],eax
      pop eax
      ret

NEWSYM WDSPReg0E       ; Voice  0                                                                                                                                                                                                                                                                  
      mov [DSPMem+0Eh],al
      ret

NEWSYM WDSPReg0F       ; Voice  0  Echo coefficient                                                                                                                                                                                                                                                
      mov [DSPMem+0Fh],al
      push eax
      movsx eax,al
      mov [FIRTAPVal0],eax
      pop eax
      ret

NEWSYM WDSPReg10       ; Voice  1  Volume Left                                                                                                                                                                                                                                                     
;      cmp byte[RevStereo],1
;      je .rev
      mov [DSPMem+10h],al
      ret
.rev
      mov [DSPMem+11h],al
      ret

NEWSYM WDSPReg11       ; Voice  1  Volume Right                                                                                                                                                                                                                                                    
;      cmp byte[RevStereo],1
;      je .rev
      mov [DSPMem+11h],al
      ret
.rev
      mov [DSPMem+10h],al
      ret

NEWSYM WDSPReg12       ; Voice  1  Pitch Low                                                                                                                                                                                                                                                       
      mov [DSPMem+012h],al
      ret

NEWSYM WDSPReg13       ; Voice  1  Pitch High                                                                                                                                                                                                                                                      
      mov [DSPMem+013h],al
      ret

NEWSYM WDSPReg14       ; Voice  1  SCRN                                                                                                                                                                                                                                                            
      mov [DSPMem+14h],al
      ret

NEWSYM WDSPReg15       ; Voice  1  ADSR (1)                                                                                                                                                                                                                                                        
      VoiceAdsr 1
      ret

NEWSYM WDSPReg16       ; Voice  1  ADSR (2)                                                                                                                                                                                                                                                        
      VoiceAdsr2 1
      ret

NEWSYM WDSPReg17       ; Voice  1  GAIN                                                                                                                                                                                                                                                            
      VoiceGain 1
      ret

NEWSYM WDSPReg18       ; Voice  1  ENVX                                                                                                                                                                                                                                                            
      mov [DSPMem+018h],al
      ret

NEWSYM WDSPReg19       ; Voice  1  OUTX                                                                                                                                                                                                                                                            
      mov [DSPMem+019h],al
      ret

NEWSYM WDSPReg1A       ; Voice  1                                                                                                                                                                                                                                                                  
      mov [DSPMem+01Ah],al
      ret

NEWSYM WDSPReg1B       ; Voice  1                                                                                                                                                                                                                                                                  
      mov [DSPMem+01Bh],al
      ret

NEWSYM WDSPReg1C       ; Voice  1                                                                                                                                                                                                                                                                  
      mov [DSPMem+01Ch],al
      push eax
      and eax,0FFh
      mov al,[VolumeTableb+eax]
      mov ah,[MusicVol]
      mov al,[VolumeConvTable+eax*2]
;      cmp byte[RevStereo],1
;      je .rev
      mov [GlobalVR],al
      pop eax
      ret
.rev
      mov [GlobalVL],al
      pop eax
      ret

NEWSYM WDSPReg1D       ; Voice  1                                                                                                                                                                                                                                                                  
      mov [DSPMem+01Dh],al
      ret

NEWSYM WDSPReg1E       ; Voice  1                         

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -