Xref: news2.mv.net comp.os.msdos.djgpp:5325 From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: (Q) Soundcard drivers, DMA, and you. Date: Mon, 24 Jun 1996 11:18:20 +0100 Organization: The University of York, UK Lines: 54 Message-ID: NNTP-Posting-Host: tower.york.ac.uk Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII In-Reply-To: <4qbva8$neq@panix.com> To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp On 20 Jun 1996, Jonathan D. Feinberg wrote: > I've got Ensoniq's protected mode driver source for their Soundscape > card. I have hopes of perhaps integrating Soundscape support into > Allegro 2.x. However, I have never written a driver before, and know > exactly nothing about the use of interrupts, DMA, the port functions, > etc. This is a huge steak to chew on. I'm hoping that you folks > can point me to texts, ftp sites, etc. that will lead me gently > towards enlightenment. A Soundscape driver would be fantastic, but you are right, it's a lot to take on. Good luck with it! As a starting place, I'd suggest working on the MIDI playback side of things. I don't know exactly how the Ensoniq handles MIDI, but if it is anything like most other wavetable cards, it can probably be done with port writes, avoiding the need for messy stuff like dma and interrupt handing. You should probably start by copying one of the existing Allegro MIDI drivers (the GUS one would be a good choice, since it doesn't contain any code yet) to see where everything has to go. For a MIDI driver, you provide functions to detect the soundcard, initialise it, turn notes on and off, and alter the volume/pitch of notes while they are playing. This can probably all be done with port accesses, in which case you just need to #include and write your code. Plus you need to lock all the memory the driver touches, since it is called inside the timer interrupt handler: this means you need to use Allegro's LOCK_VARIABLE() macro on all your global and static data, and LOCK_FUNCTION() on all the non-inline functions. > referring especially to functions that read and write to > peripheral devices ("outportb", for example). Any comments? outportb() is there in djgpp, along with outportw(), outportl(), and inport versions of all three. The stuff that differs from other DOS compilers is the interrupt handling: djgpp doesn't understand the 'interrupt' keyword and setvect() function. Since you are doing this with Allegro, you can use the interrupt and dma functions in irq.c and dma.c: look at the SB driver for an example of how they work. Basically you write a C function for your interrupt handler and then install_irq(int irq_number, int (*function)()); I think that is right: I don't have the source here to check. Your C function should return zero or one depending on whether it wants to iret or chain to the old handler (for a soundcard interrupt you probably don't want to chain), and don't forget an outportb(0x20, 0x20) at the end of the interrupt handler to acknowledge it with the interrupt controller. /* * Shawn Hargreaves. Why is 'phonetic' spelt with a ph? * Check out Allegro and FED on http://www.york.ac.uk/~slh100/ */