Mail Archives: djgpp/1997/07/11/18:08:04
This is a multi-part message in MIME format.
--------------78A03B0C67F4
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
from: csantill AT lausd DOT k12 DOT ca DOT us
I'm having problems try to access VGA mem. I've looked it up in the FAQ
& Game Programming MegaSite. I've gotten this code to compile(w/much
tinkering) but all I get is a blank screen & a stall. Any help would be
much appreciated. The code is attached here:
--------------78A03B0C67F4
Content-Type: text/plain; charset=us-ascii; name="pixels.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="pixels.c"
#include <sys/nearptr.h>
#include <go32.h>
#include <dpmi.h>
#include <dos.h>
#include <time.h>
#define GRAPHICS 0x013
#define TEXT 0x03
/* Simple program to test speed of code - Only test how long it take
to fill the screen 256 times(all colors)
I'm expecting between 45-55 frames per sec
I get about 40 frames per sec in TP 7 (286/16-Bit compiler)
" " " 30 " " " " ASIC (8086 compiler)
" " " 25 " " " " QBASIC (Interpreted)
*/
// From Matt Reiferson's Game Programming Mega Site
char *video_buffer = (char *)0xA0000;
void Set_Video_Mode(int mode)
{
__dpmi_regs r;
r.x.ax = mode;
__dpmi_int(0x10, &r);
}
// From Matt Reiferson's Game Programming Mega Site
void Plot_Pixel(int x, int y, char color)
{
video_buffer[(y << 8) + (y << 6) + x] = color;
}
// From the FAQ - 18.4
void Set_Pixel(int x, int y, char c)
{
// Is the 0xA000 the correct segment to poke to?
_farpokeb(_dos_ds, 0xA000*16+(y<<8)+(y<<6)+x, c);
}
void main(void)
{
// From the FAQ - 18.4 - Someone told me to initialize it in main
short video_memory = __dpmi_segment_to_descriptor(0xA000);
int x,y,co;
unsigned char c;
uclock_t t[2][2];
/* disable all memory protection */
__djgpp_nearptr_enable();
video_buffer += __djgpp_conventional_base;
/* go to graphics mode */
Set_Video_Mode(GRAPHICS);
uclock();
/* fill up the screen with random pixels */
t[1][1]=uclock();
for(co=0; co==510; co=co+2)
{
c=co/2; // <- Limit of char data type (DIV)
for(y=0;y==199;y++)
for(x=0;x==319;x++)
Plot_Pixel(x,y,c);
}
t[1][2]=uclock();
// Now do it like the FAQ
t[2][1]=uclock();
for(co=0; co==510; co=co+2)
{
c=co/2; // <- Limit of char data type (DIV)
for(y=0;y==199;y++)
for(x=0;x==319;x++)
Set_Pixel(x,y,c);
}
t[2][2]=uclock();
/* go back to text mode */
Set_Video_Mode(TEXT);
/* reenable memory protection */
__djgpp_nearptr_disable();
// I'm not sure these 2 line are correct
printf("1. Reiferson fps = %i\n",
((t[1][2]-t[1][1])/CLOCKS_PER_SEC)/256);
printf("2. FAQ fps = %i\n",
((t[2][2]-t[2][1])/CLOCKS_PER_SEC)/256);
exit(0);
}
--------------78A03B0C67F4--
- Raw text -