Hi Steven,
I`m not sure whether you want to put just a picture file (like a bmp or PCX)
onto screen or just the raw data.
Have you already loaded it?
Are you using a raw file?
Anyway, I use raw files meself for everything, including sound files.
So heres a quick piccy display proggy I did a few months ago for a diskmag.
Its raw format(which means you have to convert your pictures to raw).
Also it uses a separate palette file (I did this on purpose, but a little
modification will let you load a straigh raw).
Oh, its only 320x200x256 piccies (you dont think i`d give you my mode-x
stuff do ya!)
anyway, heres the listing....
--------------------- cut here ---------------------------
// Stuart`s RAW Palette & Grafix Loader
// Date : 8/4/1997 - Revision 1
#include
#include
#include
#include
#include
unsigned int *Offs;
unsigned char *vga = (unsigned char *) MK_FP(0xA000, 0); /* VGA Screen */
void PutPixel (int x, int y,unsigned char Col, unsigned char *Where);
void LoadRAW()
{
fstream file;
unsigned int ctr=0;
char buffer;
file.open("Your piccyfile name",ios::in | ios::binary);
ctr=0;
while(ctr < 64000)
{
file.read(&buffer,1);
PutPixel(ctr,0,buffer,vga);
ctr++;
}
file.close(); //We are now finished with the file.
}
void SetMCGA()
{
_AX = 0x0013;
geninterrupt (0x10);
}
void LoadPAL()
{
fstream file;
char *vgapalette;
char buffer;
file.open("Your palette file name", ios::in | ios::binary);
char current[768];
vgapalette = (char *)malloc(768);
file.read(vgapalette,768);
memcpy(current,vgapalette,768);
int counter=0; // Colour counter
char *pal=&vgapalette[0]; //Entry pointer
while(counter < 256)
{
asm mov dx,3c8h;
_AL = counter; //Entry counter
asm out dx,al; //Output entry to VGA
asm inc dx; //Next location
_AL = *pal;
asm out dx, al
pal++;
_AL = *pal;
asm out dx, al
pal++;
_AL = *pal;
asm out dx, al
pal++;
counter++;
}
free(vgapalette);
file.close(); //We are now finished with the file.
}
// this code is what actually puts the pixel from a virtual screen
// in memory, if you`ve created one (not implemented in example)
// You need a NULL pointer at the start and then a malloc command later
void PutPixel (int x, int y,unsigned char Col, unsigned char *Where)
{
memset(Where+(x+(y*320)),Col,1);
}
void main()
{
Offs = (unsigned int *)calloc(400,0);
SetMCGA();
LoadPAL();
LoadRAW();
getch();
}
-------------------- cut here --------------------
As I dont know how far you`ve got so far (whether you`ve got your virtuals
defined, or if your using virtuals!), its a bit pointless me posting
anymore code(ie retrace). I`m assuming you`ve got a virtual as you said
you wanted to know how to get a piccy in memory onto screen.
If the Putpixel command was all that you wanted, then thats in there,
just putpixel your memory info onto screen using a for loop
i.e for (y=0;y<200;y++)
{
for (x=0;x<320;x++)
{
putpixel(X,Y,col,where);
};
};
You`ve gotta think it through rationally, use pseudocode or something
like it!
Anyway, I hope i`ve helped, if I `ve missed the boat completely (as I dont
code Qbasic and i assumed Bload stood for Binary Load??? I dunno!) then
let us know, and I`ll try to hack something else together..
Ok, well good luck and let us have a copy of that game once its finished
(I`m doing a multiplayer Tank Attack game at the mo, using modem comms,
major four play action!!!). Oh, by the way, the code was compiled using
Turbo C++ (Borland) so it might need some conversion if your using Watcom
or something else.
Okay, see ya.
Stuart Miller >>>>>>>> 2:251/56.13 >>>>>>> Hmmm,nice!!
--- Terminate 4.00
---------------
* Origin: Terminate is available from a dealer near you! (2:251/56.13)
|