Mail Archives: djgpp/1998/05/02/13:50:24
Bruno Barberi Gnecco wrote:
>
> I'd like to output a file generated by TheDraw. It's documentation says to use:
>
> #include <stdio.h>
> #include <memory.h>
> #include "file.h" // this is the file containing data
> int main () {
> void far *screen;
> int offset = -162; t
> int x;
> for (x=0; x<IMAGEDATA_DEPTH; x++) {
> (long) screen = 0xB8000000+x*160+offset;
> memcpy (screen,&IMAGEDATA[x*IMAGEDATA_WIDTH*2],IMAGEDATA_WIDTH*2);
> }
> }
>
> But DJGPP doesn't accept the FAR keyword. How do I do?
That's because DJGPP applications run in protected mode, where the
methodology for accessing video memory (or any absolute hardware
address) is completely different. A full explanation is lengthy, but
you can find out for yourself by reading chapters 10, 17, and 18 of the
DJGPP Frequently Asked Questions list (v2/faq210b.zip from SimTel or
online at http://www.delorie.com/djgpp/v2faq/). There are also some
tutorials available; see the DJGPP User's Guide
(http://www.delorie.com/djgpp/doc/ug/) and Brennan's DJGPP2+Games
Resources (http://www.rt66.com/~brennan/djgpp/).
Just for kicks, I'll correct the above code for you using one of the
three methods described in FAQ chapter 18.4:
#include <stdio.h>
#include <sys/movedata.h>
#include "file.h" // this is the file containing data
int main( void )
{
int offset = -162;
int x;
for ( x = 0; x < IMAGEDATA_DEPTH; x++ )
dosmemput( &IMAGEDATA[x * IMAGEDATA_WIDTH * 2], IMAGEDATA_WIDTH
* 2, 0xb8000 + x * 160 + offset );
return 0;
}
I _think_ this will work. I can't test it because I don't have your
header file. It's not quite as fast as using near pointers but it's
safer.
hth
--
John M. Aldrich, aka Fighteer I <fighteer AT cs DOT com> UIN# 7406319
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d- s+:- a-->? C++>$ U@>++$ p>+ L>++ E>++ W++ N++ o+>++ K? w(---)
O- M-- V? PS+ PE Y+ PGP- t+(-) 5- X- R+(++) tv+() b+++ DI++ D++ G>++
e(*)>++++ h!() !r !y+()
------END GEEK CODE BLOCK------
- Raw text -