Mail Archives: djgpp/1997/02/01/17:14:12
From: | Larry Swanson <laswanson AT mwci DOT net>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | compiler error or programmer error?
|
Date: | Sat, 01 Feb 1997 15:05:28 -0600
|
Organization: | MidWest Communications, Inc.
|
Lines: | 137
|
Message-ID: | <32F3B017.2CD0@mwci.net>
|
NNTP-Posting-Host: | dial-44.man.mwci.net
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
------------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?
------------14B912EC69FA0
Content-Transfer-Encoding: 7bit
Content-Type: text/html; charset=us-ascii
<HTML><BODY>
<DT>> #include <go32.h><BR>
> #include <dpmi.h><BR>
> #include <sys/nearptr.h><BR>
> typedef unsigned char byte;<BR>
> <BR>
> byte *VGA=(byte *)0xA0000;<BR>
> void SetMode(long Mode){<BR>
> __asm__("<BR>
> movl %0,%%eax\n<BR>
> int $0x10"<BR>
> :<BR>
> :"a"(Mode)<BR>
> :"eax");<BR>
> }<BR>
> <BR>
> void Pixel(x,y,Color){<BR>
> <BR>
> __djgpp_nearptr_enable();<BR>
> VGA[y*320+x+__djgpp_conventional_base]=Color;<BR>
> __djgpp_nearptr_disable();<BR>
> }<BR>
> void Line(x1,y1,x2,y2,Color){<BR>
> short px,py;/*x and y to be plotted*/<BR>
> float slopex;/*slope solved for x*/<BR>
> slopex=(x2-x1)/(y2-y1);<BR>
> px=x1+1;py=y1+1;<BR>
> for(px<x2;px++;py+=slopex){<BR>
> Pixel(px,py,Color);<BR>
> }<BR>
> }<BR>
> void VerticalLine(topY,bottomY,x,Color){<BR>
> short py;/*x y to be plotted*/<BR>
> py=topY;<BR>
> for(py<bottomY;py++;){<BR>
> Pixel(x,py,Color);<BR>
> }<BR>
> }<BR>
> <BR>
> <BR>
> <BR>
> <BR>
> int main(){<BR>
> short a,b,c,d,color=0;<BR>
> SetMode(0x13);<BR>
> <BR>
> for(a=0;a<320;a++){<BR>
> VerticalLine(0,200,a,color);<BR>
> color++;<BR>
> if(color==255){<BR>
> color=0;}<BR>
> <BR>
> }<BR>
> <BR>
> <BR>
> SetMode(3);<BR>
> return 0;<BR>
> }<BR>
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?</DT>
</BODY>
</HTML>
------------14B912EC69FA0--
- Raw text -