static void WSS_PlayStop(void) { wss.timer_callback = NULL; wss_output(FALSE); wss_stop_dma(); VC_PlayStop(); }
/* Start playing from DMA buffer in either 8/16 bit mono/stereo */ boolean wss_start_dma(unsigned char mode, unsigned int freq) { int dmabuffsize; unsigned char format; /* Stop DMA transfer if it is enabled */ wss_stop_dma(); /* Sanity check: we support only 8-bit unsigned and 16-bit signed formats */ if (((mode & WSSMODE_16BITS) && !(mode & WSSMODE_SIGNED)) || (!(mode & WSSMODE_16BITS) && (mode & WSSMODE_SIGNED))) return FALSE; /* Find the nearest frequency divisor (rate) */ format = __wss_getrate(&freq); wss.mode = mode; /* Get a DMA buffer enough for a 1sec interval... 4K <= dmasize <= 32K */ dmabuffsize = freq; if (mode & WSSMODE_STEREO) dmabuffsize *= 2; if (mode & WSSMODE_16BITS) dmabuffsize *= 2; dmabuffsize >>= 2; if (dmabuffsize < 4096) dmabuffsize = 4096; if (dmabuffsize > 32768) dmabuffsize = 32768; dmabuffsize = (dmabuffsize + 255) & 0xffffff00; wss.dma_buff = dma_allocate(wss.dma, dmabuffsize); if (!wss.dma_buff) return FALSE; /* Fill DMA buffer with silence */ dmabuffsize = wss.dma_buff->size; if (mode & WSSMODE_SIGNED) memset(wss.dma_buff->linear, 0, dmabuffsize); else memset(wss.dma_buff->linear, 0x80, dmabuffsize); /* Check data size and build a WSSR_PLAY_FORMAT value accordingly */ wss.samples = dmabuffsize; if (mode & WSSMODE_16BITS) { wss.samples >>= 1; format |= WSSM_16BITS; }
/* Finish working with WSS */ boolean wss_close() { __dpmi_meminfo struct_info; if (!wss.open) return FALSE; wss.open--; /* Stop/free DMA buffer */ wss_stop_dma(); /* Unhook IRQ */ irq_unhook(wss.irq_handle); wss.irq_handle = NULL; /* Unlock the wss structure */ struct_info.address = __djgpp_base_address + (unsigned long)&wss; struct_info.size = sizeof(wss); __dpmi_unlock_linear_region(&struct_info); return TRUE; }
/* Reset WSS */ void wss_reset() { wss_stop_dma(); __wss_reset(); }