Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macros: FP_SEG and FP_OFF

Status
Not open for further replies.

UmaGrama

Technical User
Sep 8, 2003
33
BR
Hi... I got this code from a tutorial though the two macros that is used in it cannot be found in the library dos.h which should had been. Here is the code, can anyone find a replacement or a suggestion I can make to go around this little problem?

--------------
//here it is:
#include <dos.h>
typedef struct
{
char page;
unsigned int offset;
unsigned int length;
}DMA_block;

void LoadPageAndOffset(DMA_block *blk, char *data)
{
unsigned int temp, segment, offset;
unsigned long foo;
segment = FP_SEG(data);
offset = FP_OFF(data);
blk-> (segment & 0xF000) >> 12;
temp = (segment & 0x0FFF) << 4;
foo = offset + temp;
if(foo > 0xFFFF)
blk->page++;
blk->offset = (unsigned int)foo;
}
-----------
What is strange is that I took a look in the Help Menu in Borland and there is a example using FP_OFF and FP_SEG but when I compile that example it gives me the same error that I get when I run my own prog.
 
Segment & Offset is from the old DOS days, their use is obsolete with Win95+ due to the enhanced mode the memory are managed now.

Segment/Offset is used in DOS up to Win3.11 and as such not an issue in BCB.

Totte
 
Thanks Totte!

What can I replace it with to get that function working?

UmaGrama
 
Well, as you're prohibitet from accessing the hardware directly when using WinNT, Win2K, WinXP or really any Win above 98 there's no point in loading a DMA-buffer or what?
Nevertheless, to assign a memory buffer you can use the keyword 'new'. Look in help.
Essentially you assign memory by doing:
new DMA_block; // Assign memory
now do the woodoo...
delete DMA_block; // Free the memory again

Totte
 
Ok... I understood your point of accessing the hardware.

This might go a little off topic but let me ask your opinion:

What I am doing is throwing a signal into a SB card and grabbing the data directly from the card to analyze it. The problem is that I am losing a lot of the data because I am not doing it fast enough. Therefore, I wanted to use the DMA to save it to see if I can do it quicker.

Is there a better way of doing such a thing?
 
OK, you got me! ;-)
I haven't the faintest idea how to interface to SB BUT i would believe that Windows or the driver opens up something like the DMA-access, filling the buffer supplyed by you with the captures in the rate set by you and maybe triggers some event at some time.
I'm SURE somebody in this forum knows a lot more than me about that so my suggestion is that you post a question about SB interfacing.

Totte
 
Just a reminder : why don't you use DirectX (DirectSound) if you need fast real-time interfacing with sound-hardware? DirectX has EVERYTHING you need for sound-programming!
 
Ok... Let me start a new discussion more specific to the SB interfacing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top