www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/10/07:03:47

Date: Fri, 05 Sep 1997 19:52:02 -0600
From: sanderson AT emails DOT com
Subject: Problem with my code
Newsgroups: rec.games.programmer,comp.os.msdos.djgpp
Message-ID: <873506976.23494@dejanews.com>
Organization: Deja News Posting Service
Lines: 75
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I can't seem to figure out what is wrong with the following code. It
should clear the screen to read, clear the buffer to white and then blit
the buffer onto the screen. Unfortunately it does none of these!
void clear (BITMAP *bmp, int color)
{
   long lcolor;
   unsigned char *address;
   int seg;

   seg = bmp->seg;
   address = bmp->address;

   lcolor = color | (color << 8);
   lcolor = lcolor | (lcolor << 16);

   __asm__ __volatile__ ("\n

      pushw %%es \n
      movl %1, %%edi \n
      movw %0, %%es \n
      movl $16000, %%ecx \n
      movl %2, %%eax \n
      rep \n
      stosl \n
      popw %%es"
      :
      : "g" (seg), "g" (address), "g" (lcolor)
      : "edi", "eax", "ecx", "memory");
}

void display_buffer()
{
   unsigned char *baddress, *vaddress;
   int seg;

   baddress = buffer->address;
   vaddress = screen->address;
   seg = buffer->seg;

   __asm__ __volatile__ ("\n
      pushw %%ds \n
      pushw %%es \n
      movw %0, %%es \n
      movl %1, %%ds\n
      movl %2, %%esi \n
      movl %3, %%edi \n
      movl $16000, %%ecx \n
      rep \n
      movsl \n
      popw %%es \n
      popw %%ds"
      :
      : "g" (_dos_ds), "g" (seg), "g" (baddress), "g" (vaddress)
      : "edi", "ecx", "esi", "memory");
}

main ()
{
   set_graphics_mode(VGA);
   clear (screen,4);
   clear (buffer,7);
   display_buffer();
   getch();
   set_graphics_mode(TEXT);
}

Before you tell me, I know all about Allegro (does this code look a little
familiar?). This is just for fun :) Anyway I'd appreciate any help with
this.

Thanks
Steve Anderson

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet

- Raw text -


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