void midi_out(int v) { /* char b[80] ; sprintf(b,"midi out %2x",v&0xff) ; OUTDEBUG(b) ; */ SbDspWrite(0x38) ; SbDspWrite(v&0xff) ; }
NTSTATUS SbDspGetVersion( IN PUCHAR BasePort, OUT PUCHAR MajorVersion, OUT PUCHAR MinorVersion, IN ULONG Timeout) { NTSTATUS Status; /* Make sure our parameters are sane */ if ( ! MajorVersion ) return STATUS_INVALID_PARAMETER_2; if ( ! MinorVersion ) return STATUS_INVALID_PARAMETER_3; /* Send version request */ Status = SbDspWrite(BasePort, SB_DSP_VERSION, Timeout); if ( Status != STATUS_SUCCESS ) return Status; /* Get the major version */ Status = SbDspRead(BasePort, MajorVersion, Timeout); if ( Status != STATUS_SUCCESS ) return FALSE; /* Get the minor version */ Status = SbDspRead(BasePort, MinorVersion, Timeout); return Status; }
// [fold] [ int SbDetect(void) { int old; if (!SbDspReset()) return FALSE ; // Detecte la puce MIXER. audio.mixer = FALSE; old=SbMixerRead(0x22); SbMixerWrite(0x22,243); if (SbMixerRead(0x22)==243) { SbMixerWrite(0x22,old); audio.mixer = TRUE; } // Detecte la version du DSP sur la carte audio.dspversion=0; SbDspWrite(0xe1); // Get version number. audio.dspversion = SbDspRead()<<8; audio.dspversion |= SbDspRead(); // Determine le type de carte (8,PRO ou 16) if (!audio.mixer) audio.type=SB8; else { if (audio.dspversion<0x0400) audio.type=SBPRO; else audio.type=SB16; } // DEBUG: Pour l'instant on sucre la SB-PRO !! if (audio.type==SBPRO) { audio.type=SB8; audio.mixer=FALSE; } return TRUE ; }
//---------------------------------------------------- play sample with DMA void dma_play(void) { if (!AudioDevice) return ; outp(0x0a,4+audio.dma) ; // set mask bit channel outp(0x0c,0) ; // clear byte ptr outp(0x0b,0x48+audio.dma) ; // set DMA transfer mode outp(dmaports[audio.dma].offset,((int)audio_buffer1)&0xff) ; outp(dmaports[audio.dma].offset,((int)audio_buffer1>>8)&0xff) ; outp(dmaports[audio.dma].page,((int)audio_buffer1>>16)&0xf) ; outp(dmaports[audio.dma].length,(samples_to_generate-1)&0xff) ; outp(dmaports[audio.dma].length,((samples_to_generate-1)>>8)&0xff) ; outp(0x0a,audio.dma) ; // clear DMA mask bit switch(AudioDevice) { case AUDIODEVICE_NONE : return ; case AUDIODEVICE_SOUNDBLASTER : switch (audio.type) { case SB8: SbDspWrite(0x14); SbDspWrite(samples_to_generate-1); SbDspWrite((samples_to_generate-1)>>8); break; case SBPRO: SbDspWrite(0x48); SbDspWrite(samples_to_generate-1); SbDspWrite((samples_to_generate-1)>>8); SbDspWrite(0x91); break; case SB16: SbDspWrite(0x45); // DMA continue. break; } /* senddsp(audio.port,0x14) ; // DSP func 8 bit DAC senddsp(audio.port,(samples_to_generate)&0xff) ; senddsp(audio.port,(samples_to_generate>>8)&0xff) ; */ break ; } }
void init_soundcard() { switch(AudioDevice) { case AUDIODEVICE_NONE : break ; case AUDIODEVICE_SOUNDBLASTER: ; outp(0x0a,4+audio.dma); outp(0x0c,0x00); outp(0x0b,0x48 + audio.dma); outp(dmaports[audio.dma].offset,((int)audio_buffer1)&0xff) ; outp(dmaports[audio.dma].offset,((int)audio_buffer1>>8)&0xff) ; outp(dmaports[audio.dma].page,((int)audio_buffer1>>16)&0xf) ; outp(dmaports[audio.dma].length,(samples_to_generate-1)&0xff) ; outp(dmaports[audio.dma].length,((samples_to_generate-1)>>8)&0xff) ; outp(0x0a,audio.dma) ; // clear DMA mask bit SbDspWrite(0x40); SbDspWrite(256-1000000L/RENDITIONFREQ); //playback rate switch (audio.type) { case SB8: SbDspWrite(0x14); SbDspWrite(samples_to_generate-1); SbDspWrite((samples_to_generate-1)>>8); break; case SBPRO: SbDspWrite(0x48); SbDspWrite(samples_to_generate-1); SbDspWrite((samples_to_generate-1)>>8); SbDspWrite(0x91); break; case SB16: SbDspWrite(0xc6); // Play DMA 8 bits AUTO-LOOP (0xb6 pour 16bits) SbDspWrite(0x00); // 0x20 si STEREO SbDspWrite(samples_to_generate-1); SbDspWrite((samples_to_generate-1)>>8); break; } // Autorise sortie son. SbDspSpeakOn(); // senddsp(audio.port,0xd1) ; // turn on speaker ; // senddsp(audio.port,0x40) ; // set playback rate // senddsp(audio.port,211) ; break ; case AUDIODEVICE_GUS : if (init_gus()) printf("GUS seems OK...Cheers! ^_^\n\n") ; else { printf("GUS problem. :(\n\n") ; AudioDevice=AUDIODEVICE_NONE ; } break ; } }
void SbDspDmaStop(void) { SbDspWrite(0xd0); }
void SbDspDmaContinue(void) { SbDspWrite(0xd4); }
void SbDspSpeakOff(void) { SbDspWrite(0xd3); }
void SbDspSpeakOn(void) { SbDspWrite(0xd1); }