Mail Archives: djgpp/1999/07/18/00:37:17
At 11:47 AM 7/18/99 +0800, you wrote:
>Hi,
>
>I added the memset(double_buffer,0,320*200) before I draw to my buffer but
>still gives me garbage instead of a single red dot at position (10,10).
>
>Any idee what goes wrong ?
>(source below)
>
>Thanks;
>Mark.
>
>
>
>
>#include <stdlib.h>
>#include <dos.h>
>#include <sys/movedata.h>
>#include <dpmi.h>
>
>typedef unsigned char byte;
>
>short screen;
>byte *double_buffer;
>
>void mode(byte mode){
> union REGS regs;
> regs.h.ah=0x00;
> regs.h.al=mode;
> int86(0x10, ®s, ®s);
>}
>
>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);
> }
>
> memset(double_buffer,0,320*200);
>
> double_buffer[10*320+10] = 4;
>
> while (inportb(0x3da) & 8);
> while (!(inportb(0x3da) & 8));
> movedata(_my_ds(),*double_buffer,screen,0,320*200);
Try:
movedata(_my_ds(),double_buffer,screen,0,320*200);
The problem is that *double_buffer is the value of the first pixel in your
dbl buffer, which is 0, so in essence, you're dumping your program code on
your screen !
-GodOfWar
>
> getch();
> mode(0x03);
>}
>
>
>
>
- Raw text -