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

📄 dsp.asm

📁 linux下的任天堂模拟器代码。供大家参考。
💻 ASM
📖 第 1 页 / 共 4 页
字号:
      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 .nogain      cmp byte[Voice0State+%1],200      je .nogain      cmp [DSPMem+07h+%1*10h],al      je .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;Write DSP Registers functionsNEWSYM WDSPReg00       ; Voice  0  Volume Left      mov [DSPMem+00h],al      ret      mov [DSPMem+01h],al      retNEWSYM WDSPReg01       ; Voice  0  Volume Right      mov [DSPMem+01h],al      ret      mov [DSPMem+00h],al      retNEWSYM WDSPReg02       ; Voice  0  Pitch Low      mov [DSPMem+02h],al      retNEWSYM WDSPReg03       ; Voice  0  Pitch High      mov [DSPMem+03h],al      retNEWSYM WDSPReg04       ; Voice  0  SCRN      mov [DSPMem+04h],al      retNEWSYM WDSPReg05       ; Voice  0  ADSR (1)      VoiceAdsr 0      retNEWSYM WDSPReg06       ; Voice  0  ADSR (2)      VoiceAdsr2 0      retNEWSYM WDSPReg07       ; Voice  0  GAIN      VoiceGain 0      retNEWSYM WDSPReg08       ; Voice  0  ENVX      mov [DSPMem+08h],al      retNEWSYM WDSPReg09       ; Voice  0  OUTX      mov [DSPMem+09h],al      retNEWSYM WDSPReg0A       ; Voice  0      mov [DSPMem+0Ah],al      retNEWSYM WDSPReg0B       ; Voice  0      mov [DSPMem+0Bh],al      retNEWSYM WDSPReg0C       ; Voice  0      mov [DSPMem+0Ch],al      push eax      and eax,0FFh      mov al,[VolumeTableb+eax]      mov ah,[MusicVol]      mov al,[VolumeConvTable+eax*2]      mov [GlobalVL],al      pop eax      retNEWSYM WDSPReg0D       ; Echo Feedback      mov [DSPMem+0Dh],al      push eax      and eax,0FFh      mov al,[VolumeTableb+eax]      mov [EchoFB],eax      pop eax      retNEWSYM WDSPReg0E       ; Voice  0      mov [DSPMem+0Eh],al      retNEWSYM WDSPReg0F       ; Voice  0  Echo coefficient      mov [DSPMem+0Fh],al      push eax      movsx eax,al      mov [FIRTAPVal0],eax      pop eax      retNEWSYM WDSPReg10       ; Voice  1  Volume Left      mov [DSPMem+10h],al      retNEWSYM WDSPReg11       ; Voice  1  Volume Right      mov [DSPMem+11h],al      retNEWSYM WDSPReg12       ; Voice  1  Pitch Low      mov [DSPMem+012h],al      retNEWSYM WDSPReg13       ; Voice  1  Pitch High      mov [DSPMem+013h],al      retNEWSYM WDSPReg14       ; Voice  1  SCRN      mov [DSPMem+14h],al      retNEWSYM WDSPReg15       ; Voice  1  ADSR (1)      VoiceAdsr 1      retNEWSYM WDSPReg16       ; Voice  1  ADSR (2)      VoiceAdsr2 1      retNEWSYM WDSPReg17       ; Voice  1  GAIN      VoiceGain 1      retNEWSYM WDSPReg18       ; Voice  1  ENVX      mov [DSPMem+018h],al      retNEWSYM WDSPReg19       ; Voice  1  OUTX      mov [DSPMem+019h],al      retNEWSYM WDSPReg1A       ; Voice  1      mov [DSPMem+01Ah],al      retNEWSYM WDSPReg1B       ; Voice  1      mov [DSPMem+01Bh],al      retNEWSYM WDSPReg1C       ; Voice  1      mov [DSPMem+01Ch],al      push eax      and eax,0FFh      mov al,[VolumeTableb+eax]      mov ah,[MusicVol]      mov al,[VolumeConvTable+eax*2]      mov [GlobalVR],al      pop eax      retNEWSYM WDSPReg1D       ; Voice  1      mov [DSPMem+01Dh],al      retNEWSYM WDSPReg1E       ; Voice  1      mov [DSPMem+01Eh],al      retNEWSYM WDSPReg1F       ; Voice  1  Echo coefficient      mov [DSPMem+01Fh],al      push eax      movsx eax,al      mov [FIRTAPVal1],eax      pop eax      retNEWSYM WDSPReg20       ; Voice  2  Volume Left      mov [DSPMem+20h],al      retNEWSYM WDSPReg21       ; Voice  2  Volume Right      mov [DSPMem+21h],al      retNEWSYM WDSPReg22       ; Voice  2  Pitch Low      mov [DSPMem+022h],al      retNEWSYM WDSPReg23       ; Voice  2  Pitch High      mov [DSPMem+023h],al      retNEWSYM WDSPReg24       ; Voice  2  SCRN      mov [DSPMem+24h],al      retNEWSYM WDSPReg25       ; Voice  2  ADSR (1)      VoiceAdsr 2      retNEWSYM WDSPReg26       ; Voice  2  ADSR (2)      VoiceAdsr2 2      retNEWSYM WDSPReg27       ; Voice  2  GAIN      VoiceGain 2      retNEWSYM WDSPReg28       ; Voice  2  ENVX      mov [DSPMem+028h],al      retNEWSYM WDSPReg29       ; Voice  2  OUTX      mov [DSPMem+029h],al      retNEWSYM WDSPReg2A       ; Voice  2      mov [DSPMem+02Ah],al      retNEWSYM WDSPReg2B       ; Voice  2      mov [DSPMem+02Bh],al      retNEWSYM WDSPReg2C       ; Voice  2      mov [DSPMem+02Ch],al      push eax      and eax,0FFh      mov al,[VolumeTableb+eax]      mov ah,[MusicVol]      mov al,[VolumeConvTable+eax*2]      mov [EchoVL],al      pop eax      retNEWSYM WDSPReg2D       ; Voice  2      mov [DSPMem+02Dh],al      retNEWSYM WDSPReg2E       ; Voice  2      mov [DSPMem+02Eh],al      retNEWSYM WDSPReg2F       ; Voice  2  Echo coefficient      mov [DSPMem+02Fh],al      push eax      movsx eax,al      mov [FIRTAPVal2],eax      pop eax      retNEWSYM WDSPReg30       ; Voice  3  Volume Left      mov [DSPMem+30h],al      retNEWSYM WDSPReg31       ; Voice  3  Volume Right      mov [DSPMem+31h],al      retNEWSYM WDSPReg32       ; Voice  3  Pitch Low      mov [DSPMem+032h],al      retNEWSYM WDSPReg33       ; Voice  3  Pitch High      mov [DSPMem+033h],al      retNEWSYM WDSPReg34       ; Voice  3  SCRN      mov [DSPMem+34h],al      retNEWSYM WDSPReg35       ; Voice  3  ADSR (1)      VoiceAdsr 3      retNEWSYM WDSPReg36       ; Voice  3  ADSR (2)      VoiceAdsr2 3      retNEWSYM WDSPReg37       ; Voice  3  GAIN      VoiceGain 3      retNEWSYM WDSPReg38       ; Voice  3  ENVX      mov [DSPMem+038h],al      retNEWSYM WDSPReg39       ; Voice  3  OUTX      mov [DSPMem+039h],al      retNEWSYM WDSPReg3A       ; Voice  3      mov [DSPMem+03Ah],al      retNEWSYM WDSPReg3B       ; Voice  3      mov [DSPMem+03Bh],al      retNEWSYM WDSPReg3C       ; Voice  3      mov [DSPMem+03Ch],al      push eax      and eax,0FFh      mov al,[VolumeTableb+eax]      mov ah,[MusicVol]      mov al,[VolumeConvTable+eax*2]      mov [EchoVR],al      pop eax      retNEWSYM WDSPReg3D       ; Voice  3      mov byte[Voice0Noise],0      mov byte[Voice1Noise],0      mov byte[Voice2Noise],0      mov byte[Voice3Noise],0      mov byte[Voice4Noise],0      mov byte[Voice5Noise],0      mov byte[Voice6Noise],0      mov byte[Voice7Noise],0      test al,1      jz .TestVoice1      mov byte[Voice0Noise],1.TestVoice1      test al,2      jz .TestVoice2      mov byte[Voice1Noise],1.TestVoice2      test al,4      jz .TestVoice3      mov byte[Voice2Noise],1.TestVoice3      test al,8      jz .TestVoice4      mov byte[Voice3Noise],1.TestVoice4      test al,16      jz .TestVoice5      mov byte[Voice4Noise],1.TestVoice5      test al,32      jz .TestVoice6      mov byte[Voice5Noise],1.TestVoice6      test al,64      jz .TestVoice7      mov byte[Voice6Noise],1.TestVoice7      test al,128      jz .TestVoice8      mov byte[Voice7Noise],1.TestVoice8      mov [DSPMem+03Dh],al      retNEWSYM WDSPReg3E       ; Voice  3      mov [DSPMem+03Eh],al      retNEWSYM WDSPReg3F       ; Voice  3  Echo coefficient      mov [DSPMem+03Fh],al      push eax      movsx eax,al      mov [FIRTAPVal3],eax      pop eax      retNEWSYM WDSPReg40       ; Voice  4  Volume Left      mov [DSPMem+40h],al      retNEWSYM WDSPReg41       ; Voice  4  Volume Right      mov [DSPMem+41h],al      retNEWSYM WDSPReg42       ; Voice  4  Pitch Low      mov [DSPMem+042h],al      retNEWSYM WDSPReg43       ; Voice  4  Pitch High      mov [DSPMem+043h],al      retNEWSYM WDSPReg44       ; Voice  4  SCRN      mov [DSPMem+44h],al      retNEWSYM WDSPReg45       ; Voice  4  ADSR (1)      VoiceAdsr 4      retNEWSYM WDSPReg46       ; Voice  4  ADSR (2)      VoiceAdsr2 4      retNEWSYM WDSPReg47       ; Voice  4  GAIN      VoiceGain 4      retNEWSYM WDSPReg48       ; Voice  4  ENVX      mov [DSPMem+048h],al      retNEWSYM WDSPReg49       ; Voice  4  OUTX      mov [DSPMem+049h],al      retNEWSYM WDSPReg4A       ; Voice  4      mov [DSPMem+04Ah],al      retNEWSYM WDSPReg4B       ; Voice  4      mov [DSPMem+04Bh],al      retNEWSYM WDSPReg4C       ; Key On      push ebx      mov bl,[MuteVoiceF]      xor bl,0FFh      and bl,al      xor byte[DSPMem+05Ch],0FFh      jnz .notzero      and bl,[DSPMem+05Ch].notzero      xor byte[DSPMem+05Ch],0FFh      or byte[KeyOnStA],bl      pop ebx      test al,80h      jz .nokon      inc byte[SoundTest].nokon      mov [DSPMem+04Ch],al      push eax      xor al,0FFh      and byte[DSPMem+07Ch],al      pop eax      retNEWSYM ProcessKeyOn      test al,1      jz .TestVoice1      push edx      call Voice0Start      pop edx.TestVoice1      test al,2      jz .TestVoice2      push edx      call Voice1Start      pop edx.TestVoice2      test al,4      jz .TestVoice3      push edx      call Voice2Start      pop edx.TestVoice3      test al,8      jz .TestVoice4      push edx      call Voice3Start      pop edx.TestVoice4      test al,16      jz .TestVoice5      push edx      call Voice4Start      pop edx.TestVoice5      test al,32      jz .TestVoice6      push edx      call Voice5Start      pop edx.TestVoice6      test al,64      jz .TestVoice7      push edx      call Voice6Start      pop edx.TestVoice7      test al,128      jz .TestVoice8      push edx      call Voice7Start      pop edx.TestVoice8      test al,0FFh      jz .novoice      mov byte[keyonsn],1.novoice      retNEWSYM WDSPReg4D       ; Voice  4      mov [DSPMem+04Dh],al      retNEWSYM WDSPReg4E       ; Voice  4      mov [DSPMem+04Eh],al      retNEWSYM WDSPReg4F       ; Voice  4  Echo coefficient      mov [DSPMem+04Fh],al      push eax      movsx eax,al      mov [FIRTAPVal4],eax      pop eax      retNEWSYM WDSPReg50       ; Voice  5  Volume Left      mov [DSPMem+50h],al      retNEWSYM WDSPReg51       ; Voice  5  Volume Right      mov [DSPMem+51h],al      retNEWSYM WDSPReg52       ; Voice  5  Pitch Low      mov [DSPMem+052h],al      retNEWSYM WDSPReg53       ; Voice  5  Pitch High      mov [DSPMem+053h],al      retNEWSYM WDSPReg54       ; Voice  5  SCRN      mov [DSPMem+54h],al      retNEWSYM WDSPReg55       ; Voice  5  ADSR (1)      VoiceAdsr 5      retNEWSYM WDSPReg56       ; Voice  5  ADSR (2)      VoiceAdsr2 5      retNEWSYM WDSPReg57       ; Voice  5  GAIN      VoiceGain 5      retNEWSYM WDSPReg58       ; Voice  5  ENVX      mov [DSPMem+058h],al      retNEWSYM WDSPReg59       ; Voice  5  OUTX      mov [DSPMem+059h],al      retNEWSYM WDSPReg5A       ; Voice  5      mov [DSPMem+05Ah],al      retNEWSYM WDSPReg5B       ; Voice  5      mov [DSPMem+05Bh],al      ret%macro keyoffm 1    test byte[MuteVoiceF],1 << %1    jnz %%nokeyoff    push eax    push edx    push ebx    mov dword[Voice0Time+%1*4],255    mov eax,[Voice0EnvInc+%1*4]    shr eax,8    neg eax    mov [Voice0IncNumber+%1*4],eax    mov byte[Voice0State+%1],200    mov byte[DSPMem+08h+%1*10h],0    or byte[DSPMem+7Ch],1 << %1    pop ebx    pop edx    pop eax%%nokeyoff%endmacroNEWSYM WDSPReg5C       ; Key Off      push eax      xor al,0FFh      and byte[KeyOnStA],al      and byte[KeyOnStB],al      pop eax      test al,1      jz .TestVoice1      keyoffm 0.TestVoice1      test al,2      jz .TestVoice2      keyoffm 1.TestVoice2      test al,4      jz .TestVoice3      keyoffm 2.TestVoice3      test al,8      jz .TestVoice4      keyoffm 3.TestVoice4      test al,16      jz .TestVoice5      keyoffm 4.TestVoice5      test al,32      jz .TestVoice6      keyoffm 5.TestVoice6      test al,64      jz .TestVoice7

⌨️ 快捷键说明

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