www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/02/13:36:08

To: laswanson AT mwci DOT net
Cc: djgpp AT delorie DOT com
Subject: Re: compiler error or programmer error?
Message-ID: <19970202.132911.7567.3.fwec@juno.com>
References: <32F3B017 DOT 2CD0 AT mwci DOT net>
From: fwec AT juno DOT com (Mark T Logan)
Date: Sun, 02 Feb 1997 13:23:10 EST

On Sat, 01 Feb 1997 15:05:28 -0600 Larry Swanson <laswanson AT mwci DOT net>
writes:
>
>------------14B912EC69FA0
>Content-Transfer-Encoding: 7bit
>Content-Type: text/plain; charset=us-ascii
>
>> #include <go32.h>
>> #include <dpmi.h>
>> #include <sys/nearptr.h>
>> typedef unsigned char byte;
>>
>> byte *VGA=(byte *)0xA0000;
>> void SetMode(long Mode){
>>      __asm__("
>>      movl %0,%%eax\n
>>      int $0x10"
>>      :
>>      :"a"(Mode)
>>      :"eax");
>>      }
>>
>> void Pixel(x,y,Color){
>>
>>         __djgpp_nearptr_enable();
>>         VGA[y*320+x+__djgpp_conventional_base]=Color;
>>         __djgpp_nearptr_disable();
>>         }
>> void Line(x1,y1,x2,y2,Color){
>>      short px,py;/*x and y to be plotted*/
>>      float slopex;/*slope solved for x*/
>>      slopex=(x2-x1)/(y2-y1);
>>      px=x1+1;py=y1+1;
>>      for(px<x2;px++;py+=slopex){
>>         Pixel(px,py,Color);
>>         }
>>      }
>> void VerticalLine(topY,bottomY,x,Color){
>>      short py;/*x y to be plotted*/
>>      py=topY;
>>      for(py<bottomY;py++;){
>>         Pixel(x,py,Color);
>>         }
>>      }
>>
>>
>>
>>
>> int main(){
>>     short a,b,c,d,color=0;
>>     SetMode(0x13);
>>
>>     for(a=0;a<320;a++){
>>     VerticalLine(0,200,a,color);
>>     color++;
>>     if(color==255){
>>     color=0;}
>>
>>     }
>>
>>
>>     SetMode(3);
>>     return 0;
>> }
>The preceding code compiles and links fine.  But when I run the .exe 
>it
>crashes windows.  Is this a compiler error or just a stupid mistake by 
>a
>newbee?
>

I don't think that you can use (byte *)0xA0000 in DJGPP this has to do 
with the protected mode memory addressing scheme.  If you want
to do graphics with DJGPP, the easiest way to do it is to use the 
Allegro graphics library, and then concentrate on the more important
aspects of programming.  

- Raw text -


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