From: "Matt" Newsgroups: comp.os.msdos.djgpp References: <3b3bca85 DOT sandmann AT clio DOT rice DOT edu> Subject: Re: DPMI problem Lines: 81 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Message-ID: Date: Sat, 30 Jun 2001 02:54:04 GMT NNTP-Posting-Host: 65.32.102.67 X-Complaints-To: abuse AT rr DOT com X-Trace: typhoon.tampabay.rr.com 993869644 65.32.102.67 (Fri, 29 Jun 2001 22:54:04 EDT) NNTP-Posting-Date: Fri, 29 Jun 2001 22:54:04 EDT Organization: RoadRunner - TampaBay To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Charles Sandmann" wrote in message news:3b3bca85 DOT sandmann AT clio DOT rice DOT edu... > > I have a game which accesses VGA memory (A000:0000) directly. In 16-bit > > mode, that's ok, but to get it to run under DJGPP I either have to rewrite > > the thing or map VGA memory to linear memory. There is a function to do > > that, but I can only do it with a DPMI 1.0 server. > > If you only plan to run under DOS, and use CWSDPMI, this feature is > available. But I don't recommend using it because of the portability > reasons. Portability is not an issue, since this is a DOS-only game. The Win32 port for obvious reasons doesn't use cwsdpmi (or the section of code that I'm playing with). > > Is there a way to accomplish the same thing (i.e. direct linear access to > > A000:0000 from my ds selector) with a DPMI 0.9 server? Right now I'm looking > > at the following options, and neither of them look good: > > > > 1. Use __djgpp_nearptr_enable(). The documentation recommends against this, > > and considering that I just overhauled a number of asm files and am aware of > > a number of bugs already, I'm not so sure I like the thought of being able > > to kill my system. > > Just try it. You probably won't kill the system - that's the worse case. > If worried you could do another method first, then fall back to near pointers > which are portable to everything except Windows NT type platforms. I would prefer not to, but if I am left with no other alternative I will. It seems more logical to me to map what I need from the physical address space into my linear address space. > > 2. Use function 02h to map the segment to a descriptor, use function 06h to > > locate the linear base of the descriptor, then use functions 07h and 08h to > > modify my ds segment so I can read that linear address. > > No, use sys/farptr.h instead. Best solution. Check the FAQ. > > > Is there any way to do it directly, or is there a DPMI 0.9 server which > > supports function 0508h (map device -> linear)? > > CWSDPMI (if DOS only). dosmemget/dosmemput functions in the library. > near pointers. far pointers. 4 different ways, which ever you are most > comfortable. Have fun. First of all, thank you for your response. I've already looked at dosmemget/dosmemput, and I can't use them due to the design of the game. I would prefer not to use near pointers due to the fact that it allows me to overwrite all of conventional memory (especially when you see comments like "why does this overwrite memory??"). Far pointers are the closest solution except that nearly all the code makes direct access to the VGA buffer and I would have to convert everything, including a number of assembly files. The easiest way in my assessment is to map As for cwsdpmi, prior to my original post I attempted mapping A000:0000 through the following code (My code actually checks return values, but I figured it was best to keep the post shorter): __dpmi_meminfo info; info.address = 0; info.size = (320 * 200); __dpmi_allocate_linear_memory(&info); __dpmi_map_conventional_memory_in_memory_block(&info, 0xA0000); The first call failed with error code 1284 (504h). I looked in the DPMI spec for function ax=504h and this is not listed as an error code. The DPMI server doesn't set an error code, but it sets the carry flag indicating an error. I made absolutely sure of this by attempting the same call using int386. I don't see what I'm doing wrong, if this is supposed to work? -Matt