Message-ID: <002501be0d0f$0d1fa200$c5223182@marst96.m.resnet.pitt.edu> From: "mark reed" To: Subject: Re: Question regarding the use of __djgpp_nearptr_enable() Date: Tue, 10 Nov 1998 20:03:09 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3110.1 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Reply-To: djgpp AT delorie DOT com Something is wrong with that tutorial, isnt fill dma buffer called by an interrupt? and near ptr enable/disable is called in it ?? if you want to use nearptrs, call enable and disable once. I think someone just didnt want to bother learning how to do it without using nearptrs. What you can do, is go to http://www.soundblaster.com/wwwnew/tech/devcnr/sbhwfaq.html , and look for the question how do i get the sbhwpg (Sound Blaster HardWare Programming Guide) then download it, and it is a big manual in pdf i think, and i am sure it comes with source for watcom c++. look under samples/dmaw32 , thats the 32 bit protected mode dos watcom c++ source Watcom c++ is just like djgpp. Just replace their dos memory functions with the respeective djgpp dos memory functions. in watcom they call int86(0x31,whatver); with ax set to function number like 100 with djgpp you just call __dpmi_allocate_dos_memory if you need help just email me. I have source code and stuff, and havnet looked over it in a long time, so i wouldnt mine helping you and going back and remembering what i did :) i have never found a reason to use nearptrs, i have checked the speed and stuff, and there is really no diff (from what i remember i may be wrong, if i am let me know ) doing it this way is a lot better than following tutorials. you learn a lot more. Mark >Hello I am currently programming a sound player for soundblaster cards and I >have a question regarding the >__djgpp_nearptr_enable() function. > >I have seen tutorials on the web for programming the DMA but all them use >the __djgpp_nearptr_enable function. >I don't want to use that because it disable the memory protection. > >Here's some code from the tutorials: >-------------------------------------------------- > nearptrs then MKFP?? weird wheres the disable? >void *MK_FP(DWORD seg, DWORD ofs) >{ > if (!(_crt0_startup_flags & _CRT0_FLAG_NEARPTR)) > if >(!__djgpp_nearptr_enable()) ----------------------------------------------- - >> Oh no ! no memory protection! > return (void*)0; > return (void *) (seg*16+ofs+__djgpp_conventional_base); >} > > > >void Set_DMA() >{ > SegInfo.size = BUFFSIZE*2/16; > _go32_dpmi_allocate_dos_memory(&SegInfo); ------------> Allocate some dos >memory > phys = SegInfo.rm_segment<<4; > if ((phys >> 16) != ((phys+BUFFSIZE)>>16)) > { > phys+=BUFFSIZE; > printf(" Warning: Hit page division!\n"); > } > memset((BYTE *)MK_FP(SegInfo.rm_segment,0),0,BUFFSIZE); ----------> Set >buffer to 0 using nearpointer! > > /* Re-enable memory protection */ > __djgpp_nearptr_disable(); -------------------> This is a line >that I have put to return to the protected mem. >} > > >/* This function is called often!*/ >void Fill_DMA_buffer() >{ > this is in an interrupt right?? dont do this. dont need nearptrs or memset. >/* if I put: */ >(A) __djgpp_nearptr_enable(); ------------------> Does this line will >slow down my real time app.?? > >.... >/* COPY using DOS memory using Nearpointers */ > memset(...[DMAbuffer -> in DOS memory]) >.... >(B) __djgpp_nearptr_disable(); ------------------> Does this line will >slow down my real time app.?? > >} > > >If I want to have memory protection can I add the two lines (A) and (B) with >no major speed down?? >Or is there a better method to allocate DOS memory for the DMA transfert and >for Copying sound sample to DMA buffer (This mean copying dpmi memory to DOS >memory) without disabling memory protection. > > >Any suggestions or piece of code for the allocation and copy function will >be greatly appreciated! > >Thank you! > >Jonathan Villani >jonathan DOT villani AT videotron DOT ca > > > >