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

📄 sound.asm

📁 linux下的任天堂模拟器代码。供大家参考。
💻 ASM
📖 第 1 页 / 共 2 页
字号:
    mov ax,[BufferSizeB]    dec ax    call SB_dsp_write    mov al,ah    call SB_dsp_write    mov byte[SBDeinitType],1    mov al,090h   ; Sb 2.0 version...    cmp byte[.Versionnum],2    jne .noversion2    cmp byte[.Versionnum+1],0    je .slowspeed.noversion2    cmp byte[.Versionnum],1    ja .notversion1.slowspeed    mov byte[SBDeinitType],0    mov al,1Ch.notversion1    call SB_dsp_write    jmp .fixsurroundSECTION .bss.Versionnum resw 1SECTION .text; *****************************************; **** alternate ViBRA16X SB init code **** by Peter Santing; ***************************************** copied portions of original code; and modified it..vibrafix2    ; notify user that we're in ViBRA16x mode..    push eax    mov  dword[Msgptr], vibmsg    mov  eax, [MsgCount]    mov  [MessageOn], eax    pop  eax    ; Set Time-Constant Data ( = 256 - (1000000/sampling rate) )    ; 8000=131, 22050=210, 44100=233, 11025=165    ; Setup DMA    ; Select DMA channel    mov al,[SBDMA]    add al,4    mov dx,000Ah    out dx,al    ; Clear DMA    mov al,00h    mov dx,000Ch    out dx,al    ; Set autoinit/write (set as DAC)    mov al,58h    add al,[SBDMA]    mov dx,000Bh    out dx,al    ; Send Offset Address    mov al,[memoryloc]    mov dl,[SBDMA]    shl dl,1    out dx,al    mov al,[memoryloc+1]    out dx,al    ; Send length of entire block    mov ax,[BufferSizeW]    shl ax, 1    dec ax    inc dx    out dx,al    mov al,ah    out dx,al    ; Send page # (address/65536)    mov al,[memoryloc+2]    mov dh, 0    mov dl,[SBDMAPage]    out dx,al    ; turn on DMA    mov al,[SBDMA]    mov dx,000Ah    out dx,al    mov al,41h    call SB_dsp_write    push ecx    mov ecx,[SoundQuality]    mov al,[SBToSPCSpeeds2+ecx*4+1]    pop ecx    call SB_dsp_write    push ecx    mov ecx,[SoundQuality]    mov al,[SBToSPCSpeeds2+ecx*4]    pop ecx    call SB_dsp_write    ; Prepare SB for the first block    ; 16-bit auto-init, mono, unsigned    mov al,0B6h   ; Sb 16 version (DSP 4)    call SB_dsp_write    cmp byte[StereoSound],1    jne ._Mono._surround    mov al,30h    ; stereo/signed    call SB_dsp_write    jmp ._AfterStereo._Mono    mov al,10h    ; mono/signed    call SB_dsp_write._AfterStereo    ; Send Length-1 to DSP port    mov ax,[BufferSizeB]    dec ax    call SB_dsp_write    mov al,ah    call SB_dsp_write    ; Turn on speakers    mov al,0D1h    call SB_dsp_write    jmp .fixsurround; ******* end of alternate SB init code for ViBRA ********.init16bitlowhdma    ; Set Time-Constant Data ( = 256 - (1000000/sampling rate) )    ; 8000=131, 22050=210, 44100=233, 11025=165    mov al,40h    call SB_dsp_write    push ecx    mov ecx,[SoundQuality]    mov al,[SoundSpeeds+ecx]    pop ecx    call SB_dsp_write    mov edx,[memoryloc]    shr edx,1    mov [memoryloc2],edx    ; Setup DMA    ; turn off DMA;    mov al,[SBHDMA];    and al,03h;    or al,04h;    mov dx,00D4h;    out dx,al    ; Setup DMA    ; Select DMA channel    mov al,[SBHDMA]    and al,03h    or al,04h    mov dx,000Ah    out dx,al    ; clear flip-flop    mov dx,00D8h    xor al,al    out dx,al    ; Set autoinit/write (set as DAC)    mov al,[SBHDMA]    and al,3    add al,58h    mov dx,00D6h    out dx,al    ; Send Offset Address;    mov al,[memoryloc2];    mov dl,[SBHDMA];    and dl,3;    shl dl,2;    add dl,0C0h;    out dx,al;    mov al,[memoryloc2+1];    out dx,al    ; Send Offset Address    mov al,[memoryloc]    mov dl,[SBDMA]    shl dl,1    out dx,al    mov al,[memoryloc+1]    out dx,al    ; Send length of entire block    mov ax,[BufferSizeW]    dec ax    add dx,2    out dx,al    mov al,ah    out dx,al    ; Send page # (address/65536)    mov al,[memoryloc+2]    mov dl,[SBHDMAPage]    out dx,al    ; Prepare SB for the first block    ; 16-bit auto-init, mono, unsigned    mov al,0B6h   ; Sb 16 version (DSP 4)    call SB_dsp_write    cmp byte[StereoSound],1    jne .Monol.surroundl    mov al,30h    ; stereo/signed    call SB_dsp_write    jmp .AfterStereol.Monol    mov al,10h    ; mono/signed    call SB_dsp_write.AfterStereol    ; Send Length-1 to DSP port    mov ax,[BufferSizeB]    dec ax    call SB_dsp_write    mov al,ah    call SB_dsp_write    ; turn on DMA;    mov al,[SBHDMA];    and al,03h;    mov dx,00D4h;    out dx,al    ; Setup DMA    ; Select DMA channel    mov al,[SBHDMA]    and al,03h    mov dx,000Ah    out dx,al    ; Turn on speakers    mov al,0D1h    call SB_dsp_write    jmp .fixsurround.init16bit    ; Set Time-Constant Data ( = 256 - (1000000/sampling rate) )    ; 8000=131, 22050=210, 44100=233, 11025=165    mov al,41h    call SB_dsp_write    push ecx    mov ecx,[SoundQuality]    mov al,[SBToSPCSpeeds2+ecx*4+1]    pop ecx    call SB_dsp_write    push ecx    mov ecx,[SoundQuality]    mov al,[SBToSPCSpeeds2+ecx*4]    pop ecx    call SB_dsp_write    mov edx,[memoryloc]    shr edx,1    mov [memoryloc2],edx    ; Setup DMA    ; turn off DMA    mov al,[SBHDMA]    and al,03h    or al,04h    mov dx,00D4h    out dx,al    ; clear flip-flop    mov dx,00D8h    xor al,al    out dx,al    ; Set autoinit/write (set as DAC)    mov al,[SBHDMA]    and al,3    add al,58h    mov dx,00D6h    out dx,al    ; Send Offset Address    mov al,[memoryloc2]    mov dl,[SBHDMA]    and dl,3    shl dl,2    add dl,0C0h    out dx,al    mov al,[memoryloc2+1]    out dx,al    ; Send length of entire block    mov ax,[BufferSizeW]    dec ax    add dx,2    out dx,al    mov al,ah    out dx,al    ; Send page # (address/65536)    mov al,[memoryloc+2]    mov dl,[SBHDMAPage]    and al,0FEh    out dx,al    ; Prepare SB for the first block    ; 16-bit auto-init, mono, unsigned    mov al,0B6h   ; Sb 16 version (DSP 4)    call SB_dsp_write    cmp byte[StereoSound],1    jne .Mono.surround    mov al,30h    ; stereo/signed    call SB_dsp_write    jmp .AfterStereo.Mono    mov al,10h    ; mono/signed    call SB_dsp_write.AfterStereo    ; Send Length-1 to DSP port    mov ax,[BufferSizeB]    dec ax    call SB_dsp_write    mov al,ah    call SB_dsp_write    ; Turn on speakers    mov al,0D1h    call SB_dsp_write    ; turn on DMA    mov al,[SBHDMA]    and al,03h    mov dx,00D4h    out dx,al.fixsurround    retGetCDMAPos:    ; clear flipflop    xor ebx,ebx    mov bl,[SBDMA]    cmp byte[SBHDMA],4    jb .nohdma    mov bl,[SBHDMA]    mov dx,0Ch.nohdma    mov dx,0D8h    xor al,al    out dx,al    nop    nop    nop    nop    mov dx,[.wordcountport+ebx*2]    in al,dx    nop    nop    mov bl,al    in al,dx    nop    nop    nop    nop    mov bh,al    cmp byte[SBHDMA],4    jb .ldma2    add bx,bx.ldma2    ; value returned = bx, # of bytes left for transfer    mov cx,[BufferSizeB]    mov dx,cx    add cx,cx    cmp byte[SBHDMA],4    jb .ldmab    add cx,cx    add dx,dx.ldmab    sub cx,bx    mov byte[SBswitch],1    cmp cx,dx    jb .parta    mov byte[SBswitch],0.parta    retSECTION .data.wordcountport dw 1,3,5,7,0C2h,0C6h,0CAh,0CEhSECTION .text; old routines, doesn't work w/ sb live!    jmp .fin.loop    in al,dx    nop    nop    mov cl,al    in al,dx    nop    nop    nop    nop    mov ch,al    in al,dx    nop    nop    mov bl,al    in al,dx    mov bh,al    sub cx,bx    test cx,8000h    jz .notneg    neg cx.notneg    cmp byte[SBHDMA],4    jb .ldma    add cx,cx    add bx,bx.ldma    cmp cx,4    ja .loop.finNEWSYM SB_quality_limiter      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      cmp dword[SoundQuality],4      je .nostereo8b      mov dword[SoundQuality],2.nostereo8b      retNEWSYM SB_blank    push es    mov es,[sbselec]    mov edi,[sbpmofs]    mov ecx,320.loopa    mov dword[es:edi],0    add edi,4    dec ecx    jnz .loopa    pop es    ret;*******************************************************; Get Blaster            Locates SET BLASTER environment;*******************************************************NEWSYM getblaster    mov edx,.string2s    push edx    call getenv    pop edx    cmp eax,0    je near .nfound    mov esi,eax    mov byte[.cursetting],0.a    mov dl,[esi]    cmp dl,'a'    jb .nocap    cmp dl,'z'    ja .nocap    sub dl,'a'-'A'.nocap    inc esi    mov byte[.blfound],1    cmp dl,'A'    jne .afound    mov byte[.cursetting],1    mov word[SBPort],0    jmp .src.afound    cmp dl,'I'    jne .ifound    mov byte[.cursetting],2    mov byte[SBIrq],0    jmp .src.ifound    cmp dl,'D'    jne .dfound    mov byte[.cursetting],3    mov byte[SBDMA],0    jmp .src.dfound    cmp dl,'H'    jne .hfound    mov byte[.cursetting],4    mov byte[SBHDMA],0    jmp .src.hfound    cmp dl,' '    je .src2    cmp dl,0    je .src2    jmp .src3.src2    mov byte[.cursetting],0    jmp .src.src3    cmp byte[.cursetting],1    jne .nproca    shl word[SBPort],4    sub dl,48    add byte[SBPort],dl    add dl,48.nproca    cmp byte[.cursetting],2    jne .nproci    cmp byte[SBIrq],1    jne .no1    mov byte[SBIrq],10.no1    sub dl,48    add [SBIrq],dl    add dl,48.nproci    cmp byte[.cursetting],3    jne .nprocd    sub dl,48    mov [SBDMA],dl    add dl,48.nprocd    cmp byte[.cursetting],4    jne .nproch    sub dl,48    mov [SBHDMA],dl    add dl,48.nproch.src    cmp dl,0    jne near .a    cmp byte[.blfound],0    je near .nfound    cmp byte[SBIrq],2    jne .noirq9    mov byte[SBIrq],9.noirq9    mov al,[SBIrq]    add al,08h    cmp byte[SBIrq],7    jbe .nohighirq    add al,60h    add byte[PICRotateP],80h    add byte[PICMaskP],80h.nohighirq    mov [SBInt],al    cmp byte[SBDMA],0    jne .dma0    mov byte[SBDMAPage],87h.dma0    cmp byte[SBDMA],1    jne .dma1    mov byte[SBDMAPage],83h.dma1    cmp byte[SBDMA],2    jne .dma2    mov byte[SBDMAPage],81h.dma2    cmp byte[SBDMA],3    jne .dma3    mov byte[SBDMAPage],82h.dma3; ******************************************************; **** this piece of code is added by Peter Santing ****; **** it will enable ZSNES to use the full STEREO  ****; **** capability of the ViBRA16X line of creative  ****; **** instead of playing 8-bit MONOURAL sound      ****; ******************************************************;       cmp byte[SBHDMA], 0;       jne .vibradma0;       mov byte[SBDMAPage], 87h;       mov byte[vibracard], 1         ; set ViBRA16X mode.vibradma0        cmp byte[SBHDMA], 1        jne .vibradma1        mov byte[SBDMAPage], 83h        mov byte[vibracard], 1         ; set ViBRA16X mode.vibradma1        cmp byte[SBHDMA], 2        jne .vibradma2        mov byte[SBDMAPage], 81h        mov byte[vibracard], 1         ; set ViBRA16X mode.vibradma2        cmp byte[SBHDMA], 3        jne .vibradma3        mov byte[SBDMAPage], 82h        mov byte[vibracard], 1         ; set ViBRA16X mode.vibradma3        cmp byte[vibracard], 1        jne .vibrafix        push ax        mov  al, [SBHDMA]        mov  [SBDMA], al        pop  ax.vibrafix        cmp byte[SBHDMA],4        jae .hdma        ; vibra implementation (make sure that zSNES doesn't go back        ; to eight-bit-mode mono)        mov byte[SBHDMA],0        cmp byte[vibracard], 1        jne .hdma        push edx        mov edx, vibradetect        call PrintStr        ;call WaitForKey        pop  edx; ********** END OF ViBRA16X implementation code **********.hdma    cmp byte[SBHDMA],4    jne .hdma4    mov byte[SBHDMAPage],8Fh.hdma4    cmp byte[SBHDMA],5    jne .hdma5    mov byte[SBHDMAPage],8Bh.hdma5    cmp byte[SBHDMA],6    jne .hdma6    mov byte[SBHDMAPage],89h.hdma6    cmp byte[SBHDMA],7    jne .hdma7    mov byte[SBHDMAPage],8Ah.hdma7    cmp byte[DisplayS],1    je .displaysoundstuff    ret.nfound    cmp byte[soundon],0    je .nosound    mov byte[soundon],0    mov edx, .blasterstr    call PrintStr    call WaitForKey.nosound    ret.displaysoundstuff    mov edx,.blasterinfo    call PrintStr    xor eax,eax    mov ax,[SBPort]    call printhex    mov edx,.blinfob    call PrintStr    xor eax,eax    mov al,[SBIrq]    call printnum    mov edx,.blinfoc    call PrintStr    xor eax,eax    mov al,[SBDMA]    call printnum    mov edx,.blinfod    call PrintStr    xor eax,eax    mov al,[SBHDMA]    call printnum    mov edx,.blasterstr2b    call PrintStr    call WaitForKey    retSECTION .bss.blfound  resb 1.cursetting resb 1SECTION .data.string2s db 'BLASTER',0.blasterstr db 'ERROR : SET BLASTER environment NOT found!',10,13.blasterstr2 db 'Unable to enable sound.'.blasterstr2b db 10,13,10,13.blasterstr3 db 'Press any key to continue.',0.blasterinfo db 'Sound Blaster Detection Values : ',10,13,10,13.blinfoa db 'PORT  : ',0.blinfob db 13,10,'IRQ   : ',0.blinfoc db 13,10,'DMA   : ',0.blinfod db 13,10,'HDMA  : ',0NEWSYM PICRotateP, db 20hNEWSYM PICMaskP,   db 21h; Line added by Peter SantingNEWSYM vibradetect                 db 'Creative ViBRA16X PnP card detected (support coded by Peter Santing)', 13, 10                 db 'High-DMA is below dma #4', 13, 10                 db 13,10, 'you have now full 16-bit stereo sound with the surround option!', 13, 10, 0

⌨️ 快捷键说明

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