Mail Archives: djgpp/2000/02/26/01:39:32
On Fri, 25 Feb 2000 21:51:48 -0500, Trancelucid
<trancelucid AT videotron DOT ca> wrote:
>I'm porting some source of mine (from Watcom and TC) to DJGPP, and the
>main problem I'm having right now is accessing 0xA0000.
If you're having trouble with getting video to work,
you can always look at how Allegro does it.
>I read the libc reference
C:\>info libc
>and a few tutorials on the net, and the most popular buffer-to-
>video functions seem to be memcpy() and _farpokeb().. I have
>some unanswered questions, and I'd like your opinion on the matter.
If you're copying data in far memory (e.g. blitting), use movedata().
>It may be off-topic, but just for curiosity...
Read on. This kind of question is frequently asked but not offtopic.
>Why can you access
>0xA0000 in Watcom and not in DJGPP?
Watcom automatically nearptrs all memory. DJGPP doesn't, primarily
because it's descended from a GNU tool, and GNU is a protected OS.
>Both are 32bit compilers, so why would you need to
>disable protection to access video memory in DJGPP?
You don't.
>How (un)safe is it to disable protection to access
>video memory with memcpy()?
You could _potentially_ overwrite the OS, leading to a crash or a
corrupted FAT. Very bad. And according to Murphy, very probable. It
happened when I was using TroubleSpace (officially DriveSpace from MS-
DOS 6.22); good thing I was using DoubleGuard (extra layer of memory
protection for DriveSpace drives).
However, if you ask DPMI for a selector that covers segment
0xa0000-0xaffff, you can movedata() the pixels in via a farpointer.
Think of movedata() as a DJGPP-specific farpointer memcpy().
C:\>info libc alpha movedata
>As for _farpokeb(), is there a way to make it faster?
_farpokel() can potentially be four times faster as it moves
four times as much per instruction. (However, the optimizer...)
I think movedata() uses _farpokel() internally.
>Right now I use it
>in a for loop:
>
>for(i=0;i<64000;i++)
> _farpokeb(_dos_ds,0xA0000,+i,buffer[i]);
The optimizer may be casting your char*'s to long*'s and using
_farpokel().
>Also, when I use optimization parameters (-O3), both seem the same
>speed.. Are they the same code when optimized? And how can I look if
>they use the same asm instructions?
There is a switch to get GCC to show its assembler opcodes. Browse
the GCC manual:
C:\>info gcc
>Is there any faster way than those 2?
Not on Intel.
--
Damian Yerrick http://yerricde.tripod.com/
Comment on story ideas: http://home1.gte.net/frodo/quickjot.html
AOL is sucks! Find out why: http://anti-aol.org/faqs/aas/
View full sig: http://www.rose-hulman.edu/~yerricde/sig.html
This is McAfee VirusScan. Add these two lines to your .sig to
prevent the spread of .sig viruses. http://www.mcafee.com/
- Raw text -