Mail Archives: djgpp/1999/07/17/10:17:22
Hello,
I got this snippet from the DJGPP FAQ using short screen =
__dpmi_segment_to_descriptor(0xa000) and the movedata() function.
I tried to implement it in a simple program. But it gives me garbage on the
screen. A sreen full of ramdom colored pixels while it suppose to put just
a single vertical red line on the screen.
Can anyone help me out here ?
(See below for the source)
Thanks;
Mark.
#include <stdlib.h>
#include <dos.h>
#include <sys/movedata.h>
#include <dpmi.h>
typedef unsigned char byte;
byte *double_buffer;
short screen;
void mode(byte mode){
union REGS regs;
regs.h.ah=0x00;
regs.h.al=mode;
int86(0x10, ®s, ®s);
}
void vline(int x, int y1, int y2, byte color){
for(;y2>=y1;y2--)
double_buffer[y2*320+x] = color;
}
main(){
mode(0x13);
screen = __dpmi_segment_to_descriptor(0xa000);
if (screen == -1){
printf("error getting a selector.\n");
exit(1);
}
double_buffer = (byte *)malloc(320*200);
if (double_buffer==NULL){
printf("Not enough memory for double buffer.\n");
exit(1);
}
vline(100,15,150,4);
while (inportb(0x3da) & 8);
while (!(inportb(0x3da) & 8));
movedata(_my_ds(),*double_buffer,screen,0,320*200);
getch();
mode(0x03);
}
- Raw text -