www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/17/10:17:22

Message-Id: <3.0.1.32.19990717221624.0069d798@apiitkl.edu.my>
X-Sender: df990244 AT apiitkl DOT edu DOT my
X-Mailer: Windows Eudora Light Version 3.0.1 (32)
Date: Sat, 17 Jul 1999 22:16:24 +0800
To: djgpp AT delorie DOT com
From: Mark <rhosts AT bigfoot DOT com>
Subject: double buffering prob. in 13h mode.
Mime-Version: 1.0
Reply-To: djgpp AT delorie DOT com

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, &regs, &regs);
}

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019