Mail Archives: djgpp/1997/02/02/13:36:08
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 -