My graphics library

This is a discussion on My graphics library within the C Programming forums, part of the General Programming Boards category; Its very very very incomplete and theres lots of problems If you can figure out a faster putpixel then please ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    140

    My graphics library

    Its very very very incomplete and theres lots of problems
    If you can figure out a faster putpixel then please show me, also I think the Line() function is kinda messed up (I wrote it myself, didnt look up anything on lines) This should compile under borland c++ and probably can be modified a little for other compilers. Im making it because I hate the borland dos graphics crap.

    use it however U like, just please tell me if you find any bugs or fixes for bugs and tell me what U think of it in general (I know its buggy)
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    #include <dos.h>
    
    //Scan codes, borrowed from allegro, I kinda messed them up
    //some are ascii and some are scan (oops)
    #define KEY_ESC               27
    #define KEY_1                 '1'
    #define KEY_2                 '2'
    #define KEY_3                 '3'
    #define KEY_4                 '4'
    #define KEY_5                 '5'
    #define KEY_6                 '6'
    #define KEY_7                 '7'
    #define KEY_8                 '8'
    #define KEY_9                 '9'
    #define KEY_0                 '0'
    #define KEY_MINUS             '-'
    #define KEY_EQUALS            '='
    #define KEY_BACKSPACE         14
    #define KEY_TAB               15
    #define KEY_Q                 16
    #define KEY_W                 17
    #define KEY_E                 18
    #define KEY_R                 19
    #define KEY_T                 20
    #define KEY_Y                 21
    #define KEY_U                 22
    #define KEY_I                 23
    #define KEY_O                 24
    #define KEY_P                 25
    #define KEY_OPENBRACE         26
    #define KEY_CLOSEBRACE        27
    #define KEY_ENTER             28
    #define KEY_CONTROL           29
    #define KEY_LCONTROL          29
    #define KEY_A                 30
    #define KEY_S                 31
    #define KEY_D                 32
    #define KEY_F                 33
    #define KEY_G                 34
    #define KEY_H                 35
    #define KEY_J                 36
    #define KEY_K                 37
    #define KEY_L                 38
    #define KEY_COLON             39
    #define KEY_QUOTE             40
    #define KEY_TILDE             41
    #define KEY_LSHIFT            42
    #define KEY_BACKSLASH         43
    #define KEY_Z                 44
    #define KEY_X                 45
    #define KEY_C                 46
    #define KEY_V                 47
    #define KEY_B                 48
    #define KEY_N                 49
    #define KEY_M                 50
    #define KEY_COMMA             51
    #define KEY_STOP              52
    #define KEY_SLASH             53
    #define KEY_RSHIFT            54
    #define KEY_ASTERISK          55
    #define KEY_ALT               56
    #define KEY_SPACE             57
    #define KEY_CAPSLOCK          58
    #define KEY_F1                59
    #define KEY_F2                60
    #define KEY_F3                61
    #define KEY_F4                62
    #define KEY_F5                63
    #define KEY_F6                64
    #define KEY_F7                65
    #define KEY_F8                66
    #define KEY_F9                67
    #define KEY_F10               68
    #define KEY_NUMLOCK           69
    #define KEY_SCRLOCK           70
    #define KEY_HOME              71
    #define KEY_UP                72
    #define KEY_PGUP              73
    #define KEY_MINUS_PAD         74
    #define KEY_LEFT              75
    #define KEY_5_PAD             76
    #define KEY_RIGHT             77
    #define KEY_PLUS_PAD          78
    #define KEY_END               79
    #define KEY_DOWN              80
    #define KEY_PGDN              81
    #define KEY_INSERT            82
    #define KEY_DEL               83
    #define KEY_PRTSCR            84
    #define KEY_F11               87
    #define KEY_F12               88
    #define KEY_LWIN              91
    #define KEY_RWIN              92
    #define KEY_MENU              93
    #define KEY_PAD               100
    #define KEY_RCONTROL          120
    #define KEY_ALTGR             121
    #define KEY_SLASH2            122
    #define KEY_PAUSE             123
    
    #define TimeInt 0x1C
    
    int SetVgaMode();
    int SetTextMode();
    int GetchScanCode();
    
    int GFXMODE;
    int OldBank;
    int bank=-5;
    
    short MouseCursor[8][8]=
    {
     1,1,1,1,0,0,0,0,
     1,1,0,0,0,0,0,0,
     1,0,1,0,0,0,0,0,
     1,0,0,1,0,0,0,0,
     0,0,0,0,1,0,0,0,
     0,0,0,0,0,1,0,0,
     0,0,0,0,0,0,1,0,
     0,0,0,0,0,0,0,1
    };
    
    unsigned short far *VideoMemory=(short *)0xA0000;
    unsigned int far *ClockMemory=(int *)0x46C;
    
    int SetGfxMode0() //320x200x256
    {
            GFXMODE=0;
    
    	asm
       {
          mov ah, 00H
          mov al, 13H
          int 10H
       }
    
    	return 0;
    }
    
    int SetGfxMode1() //640x480x256
    {
            GFXMODE=1;
            asm
            {
                    mov ax, 04F02H
                    mov bx, 0101H
                    int 10H
            }
            return 0;
    }
    
    int SetGfxMode2() //320x200x16m
    {
            GFXMODE=2;
            asm
            {
                    mov ax, 04F02H
                    mov bx, 010FH
                    int 10H
            }
            return 0;
    }
    
    int SetGfxMode3() //640x480x16m
    {
            GFXMODE=3;
            asm
            {
                    mov ax, 04F02H
                    mov bx, 0112H
                    int 10H
            }
            return 0;
    }
    
    int SetGfxMode4() //800x600x256
    {
            GFXMODE=4;
            asm
            {
                    mov ax, 04F02H
                    mov bx, 0103H
                    int 10H
            }
            return 0;
    }
    
    int SetGfxMode5() //1024x768x256
    {
            GFXMODE=5;
            asm
            {
                    mov ax, 04F02H
                    mov bx, 0105H
                    int 10H
            }
            return 0;
    }
    
    int SetGfxMode6() //800x600x16m
    {
            GFXMODE=6;
            asm
            {
                    mov ax, 04F02H
                    mov bx, 0115H
                    int 10H
            }
            return 0;
    }
    
    
    int SetGfxMode7() //1024x768x16m
    {
            GFXMODE=7;
            asm
            {
                    mov ax, 04F02H
                    mov bx, 0118H
                    int 10H
            }
            return 0;
    }
    
    
    
    int SetTextMode()
    {
    	asm
       {
          mov ah, 00H
          mov al, 03H
          int 10H
       }
    
    	return 0;
    }
    
    int GetClockTicks()
    {
    	return *ClockMemory;
    }
    
    //Its so big because it has a seperate thing for each of the graphics modes
    // if anyone figures out why its sooooooooo slowwwwwwww please let me know
    int putpixel(unsigned int x, int y, int col1, int col2, int col3) // col 2, 3 used in 16m
    {
       long offset=0L;
    
       if(GFXMODE==0)
       {
            x=((y*320)+x);
            asm
            {
                    mov bx, 0A000H
                    mov es, bx
                    mov bx, x
                    mov ax, col1
                    mov [es:bx], al
            }
       }
       if(GFXMODE==1)
       {
            offset=(long)y*640+(long)x;
            OldBank=bank;
            bank=offset>>16;
            x=offset;
    
            if(OldBank!=bank)
            {
            asm
            {
                    // set read bank
                    mov ax, 04F05H
                    mov bx, 0
                    mov dx, bank
                    int 10H
    
                    // set write bank
                    mov ax, 04F05H
                    mov bx, 1
                    mov dx, bank
                    int 10H
    
            }
            }
            asm
            {
                    mov bx, 0A000H
                    mov es, bx
                    mov bx, x
                    mov ax, col1
                    mov [es:bx], al
            }
    
       }
    
       if(GFXMODE==2)
       {
            offset=(long)y*320+(long)x;
            offset*=3;
            OldBank=bank;
            bank=offset>>16;
            x=offset;
    
            if(OldBank!=bank)
            {
            asm
            {
                    // set read bank
                    mov ax, 04F05H
                    mov bx, 0
                    mov dx, bank
                    int 10H
    
                    // set write bank
                    mov ax, 04F05H
                    mov bx, 1
                    mov dx, bank
                    int 10H
    
            }
            }
            asm
            {
                    mov bx, 0A000H
                    mov es, bx
                    mov bx, x
    
                    mov ax, col3
                    mov [es:bx], al
    
                    inc bx
                    mov ax, col2
                    mov [es:bx], al
    
                    inc bx
                    mov ax, col1
                    mov [es:bx], al
            }
    
       }
    
    
          if(GFXMODE==3)
       {
            offset=(long)y*640+(long)x;
            offset*=3;
            OldBank=bank;
            bank=offset>>16;
            x=offset;
    
            if(OldBank!=bank)
            {
            asm
            {
                    // set read bank
                    mov ax, 04F05H
                    mov bx, 0
                    mov dx, bank
                    int 10H
    
                    // set write bank
                    mov ax, 04F05H
                    mov bx, 1
                    mov dx, bank
                    int 10H
    
            }
            }
            asm
            {
                    mov bx, 0A000H
                    mov es, bx
                    mov bx, x
    
                    mov ax, col3
                    mov [es:bx], al
    
                    inc bx
                    mov ax, col2
                    mov [es:bx], al
    
                    inc bx
                    mov ax, col1
                    mov [es:bx], al
            }
    
       }
    
          if(GFXMODE==4)
       {
            offset=(long)y*800+(long)x;
            OldBank=bank;
            bank=offset>>16;
            x=offset;
    
            if(OldBank!=bank)
            {
            asm
            {
                    // set read bank
                    mov ax, 04F05H
                    mov bx, 0
                    mov dx, bank
                    int 10H
    
                    // set write bank
                    mov ax, 04F05H
                    mov bx, 1
                    mov dx, bank
                    int 10H
    
            }
            }
            asm
            {
                    mov bx, 0A000H
                    mov es, bx
                    mov bx, x
                    mov ax, col1
                    mov [es:bx], al
            }
    
       }
    
          if(GFXMODE==5)
       {
            offset=(long)y*1024+(long)x;
            OldBank=bank;
            bank=offset>>16;
            x=offset;
    
            if(OldBank!=bank)
            {
            asm
            {
                    // set read bank
                    mov ax, 04F05H
                    mov bx, 0
                    mov dx, bank
                    int 10H
    
                    // set write bank
                    mov ax, 04F05H
                    mov bx, 1
                    mov dx, bank
                    int 10H
    
            }
            }
            asm
            {
                    mov bx, 0A000H
                    mov es, bx
                    mov bx, x
                    mov ax, col1
                    mov [es:bx], al
            }
    
       }
    
             if(GFXMODE==6)
       {
            offset=(long)y*800+(long)x;
            offset*=3;
            OldBank=bank;
            bank=offset>>16;
            x=offset;
    
            if(OldBank!=bank)
            {
            asm
            {
                    // set read bank
                    mov ax, 04F05H
                    mov bx, 0
                    mov dx, bank
                    int 10H
    
                    // set write bank
                    mov ax, 04F05H
                    mov bx, 1
                    mov dx, bank
                    int 10H
    
            }
            }
            asm
            {
                    mov bx, 0A000H
                    mov es, bx
                    mov bx, x
    
                    mov ax, col3
                    mov [es:bx], al
    
                    inc bx
                    mov ax, col2
                    mov [es:bx], al
    
                    inc bx
                    mov ax, col1
                    mov [es:bx], al
            }
    
       }
    
             if(GFXMODE==7)
       {
            offset=(long)y*1024+(long)x;
            offset*=3;
            OldBank=bank;
            bank=offset>>16;
            x=offset;
    
            if(OldBank!=bank)
            {
            asm
            {
                    // set read bank
                    mov ax, 04F05H
                    mov bx, 0
                    mov dx, bank
                    int 10H
    
                    // set write bank
                    mov ax, 04F05H
                    mov bx, 1
                    mov dx, bank
                    int 10H
    
            }
            }
            asm
            {
                    mov bx, 0A000H
                    mov es, bx
                    mov bx, x
    
                    mov ax, col3
                    mov [es:bx], al
    
                    inc bx
                    mov ax, col2
                    mov [es:bx], al
    
                    inc bx
                    mov ax, col1
                    mov [es:bx], al
            }
    
       }
    
    
    	return 0;
    }
    
    
    
    
    
    
    //reads the pixel at xy, value is which one
    //in in 256 color mode value doesnt matter but
    //in 16m color mode value determines what value to grab
    //1 is red 2 is green 3 is blue
    int getpixel(unsigned int x, int y, int value)
    {
       long offset=0L;
       int val;
    
       if(GFXMODE==0)
       {
            x=((y*320)+x);
            asm
            {
                    mov bx, 0A000H
                    mov es, bx
                    mov bx, x
                    mov ax, [es:bx]
    					 mov val, ax
            }
       		return val;
       }
       if(GFXMODE==1)
       {
            offset=(long)y*640+(long)x;
            OldBank=bank;
            bank=offset>>16;
            x=offset;
    
            if(OldBank!=bank)
            {
            asm
            {
                    // set read bank
                    mov ax, 04F05H
                    mov bx, 0
                    mov dx, bank
                    int 10H
    
                    // set write bank
                    mov ax, 04F05H
                    mov bx, 1
                    mov dx, bank
                    int 10H
    
            }
            }
            asm
            {
                    mov bx, 0A000H
                    mov es, bx
                    mov bx, x
                    mov ax, [es:bx]
                    mov val, ax
            }
    
       }
    
       if(GFXMODE==2)
       {
            offset=(long)y*320+(long)x;
            offset*=3;
            OldBank=bank;
            bank=offset>>16;
            x=offset;
    
            if(OldBank!=bank)
            {
            asm
            {
                    // set read bank
                    mov ax, 04F05H
                    mov bx, 0
                    mov dx, bank
                    int 10H
    
                    // set write bank
                    mov ax, 04F05H
                    mov bx, 1
                    mov dx, bank
                    int 10H
    
            }
            }
    
            asm
            {
                    mov bx, 0A000H
                    mov es, bx
                    mov bx, x
            }
    
            if(value==3)
            {
            	asm
            	{
            	        mov ax, [es:bx]
            	        mov val, ax
            	}
            	return val;
            }
            if(value==2)
            {
            	asm
            	{
            	        inc bx
            	        mov ax, [es:bx]
            	        mov val, ax
            	}
            	return val;
            }
            if(value==1)
            {
            	asm
            	{
            	        inc bx
            	        inc bx
            	        mov ax, [es:bx]
            	        mov val, ax
            	}
            	return val;
            }
    
       }
    
    
          if(GFXMODE==3)
       {
            offset=(long)y*640+(long)x;
            offset*=3;
            OldBank=bank;
            bank=offset>>16;
            x=offset;
    
            if(OldBank!=bank)
            {
            asm
            {
                    // set read bank
                    mov ax, 04F05H
                    mov bx, 0
                    mov dx, bank
                    int 10H
    
                    // set write bank
                    mov ax, 04F05H
                    mov bx, 1
                    mov dx, bank
                    int 10H
    
            }
            }
    
            asm
            {
                    mov bx, 0A000H
                    mov es, bx
                    mov bx, x
            }
    
            if(value==3)
            {
            	asm
            	{
            	        mov ax, [es:bx]
            	        mov val, ax
            	}
            	return val;
            }
            if(value==2)
            {
            	asm
            	{
            	        inc bx
            	        mov ax, [es:bx]
            	        mov val, ax
            	}
            	return val;
            }
            if(value==1)
            {
            	asm
            	{
            	        inc bx
            	        inc bx
            	        mov ax, [es:bx]
            	        mov val, ax
            	}
            	return val;
            }
       }
    
          if(GFXMODE==4)
       {
            offset=(long)y*800+(long)x;
            OldBank=bank;
            bank=offset>>16;
            x=offset;
    
            if(OldBank!=bank)
            {
            asm
            {
                    // set read bank
                    mov ax, 04F05H
                    mov bx, 0
                    mov dx, bank
                    int 10H
    
                    // set write bank
                    mov ax, 04F05H
                    mov bx, 1
                    mov dx, bank
                    int 10H
    
            }
            }
            asm
            {
                    mov bx, 0A000H
                    mov es, bx
                    mov bx, x
                    mov ax, [es:bx]
                    mov val, ax
            }
    
       }
    
          if(GFXMODE==5)
       {
            offset=(long)y*1024+(long)x;
            OldBank=bank;
            bank=offset>>16;
            x=offset;
    
            if(OldBank!=bank)
            {
            asm
            {
                    // set read bank
                    mov ax, 04F05H
                    mov bx, 0
                    mov dx, bank
                    int 10H
    
                    // set write bank
                    mov ax, 04F05H
                    mov bx, 1
                    mov dx, bank
                    int 10H
    
            }
            }
            asm
            {
                    mov bx, 0A000H
                    mov es, bx
                    mov bx, x
                    mov ax, [es:bx]
                    mov val, ax
            }
    
       }
    
             if(GFXMODE==6)
       {
            offset=(long)y*800+(long)x;
            offset*=3;
            OldBank=bank;
            bank=offset>>16;
            x=offset;
    
            if(OldBank!=bank)
            {
            asm
            {
                    // set read bank
                    mov ax, 04F05H
                    mov bx, 0
                    mov dx, bank
                    int 10H
    
                    // set write bank
                    mov ax, 04F05H
                    mov bx, 1
                    mov dx, bank
                    int 10H
    
            }
            }
    
            asm
            {
                    mov bx, 0A000H
                    mov es, bx
                    mov bx, x
            }
    
            if(value==3)
            {
            	asm
            	{
            	        mov ax, [es:bx]
            	        mov val, ax
            	}
            	return val;
            }
            if(value==2)
            {
            	asm
            	{
            	        inc bx
            	        mov ax, [es:bx]
            	        mov val, ax
            	}
            	return val;
            }
            if(value==1)
            {
            	asm
            	{
            	        inc bx
            	        inc bx
            	        mov ax, [es:bx]
            	        mov val, ax
            	}
            	return val;
            }
    
       }
    
             if(GFXMODE==7)
       {
            offset=(long)y*1024+(long)x;
            offset*=3;
            OldBank=bank;
            bank=offset>>16;
            x=offset;
    
            if(OldBank!=bank)
            {
            asm
            {
                    // set read bank
                    mov ax, 04F05H
                    mov bx, 0
                    mov dx, bank
                    int 10H
    
                    // set write bank
                    mov ax, 04F05H
                    mov bx, 1
                    mov dx, bank
                    int 10H
    
            }
            }
    
            asm
            {
                    mov bx, 0A000H
                    mov es, bx
                    mov bx, x
            }
    
            if(value==3)
            {
            	asm
            	{
            	        mov ax, [es:bx]
            	        mov val, ax
            	}
            	return val;
            }
            if(value==2)
            {
            	asm
            	{
            	        inc bx
            	        mov ax, [es:bx]
            	        mov val, ax
            	}
            	return val;
            }
            if(value==1)
            {
            	asm
            	{
            	        inc bx
            	        inc bx
            	        mov ax, [es:bx]
            	        mov val, ax
            	}
            	return val;
            }
    
       }
    
    
    	return 0;
    }
    
    
    
    
    
    
    
    int SetPalette(int index, int r, int g, int b)
    {
    
       outp(0x03c8, index);
       outp(0x03c9, r);
       outp(0x03c9, g);
       outp(0x03c9, b);
    
    	return 0;
    }
    
    //needs some help
    int Line(int x1, int y1, int x2, int y2, int col1, int col2, int col3)
    {
       float x, y;
       float slope;
       float rise;
       float run;
    
       if(y2>y1)
       rise=y2-y1;
       if(y2<y1)
       rise=(y1-y2)*(-1);
    
       if(x2>x1)
       run=x2-x1;
       if(x2<x1)
       run=(x1-x2)*(-1);
    
       if(rise==0||run==0)
       return 0;
       slope=(rise/run);
    
       if(x1<x2)
       {
       	x=x1;
       	y=y1;
          while(x<x2&&y<y2)
          {
             if( (slope<=1&&slope>0)||(slope>=(-1)&&slope<0))
             {
                    x++;
                    y+=slope;
             }
    
             if(slope>1||slope<(-1))
             {
                    x+=1/slope;
                    y+=slope/slope;
             }
             putpixel(x, y, col1, col2, col3);
          }
       }
       if(x1>x2)
       {
       	x=x2;
       	y=y2;
          while(x<x1&&y<y1)
          {
             if( (slope<=1&&slope>0)||(slope>=(-1)&&slope<0))
             {
                    x++;
                    y+=slope;
             }
    
             if(slope>1||slope<(-1))
             {
                    x+=1/slope;
                    y+=slope/slope;
             }
    
             putpixel(x, y, col1, col2, col3);
          }
    
       }
    	return 0;
    }
    
    int Rect(int x1, int y1, int x2, int y2, int col1, int col2, int col3)
    {
            int X1, Y1, X2, Y2;
    
            for(X1=x1;X1<x2;X1++)
            putpixel(X1, y1, col1, col2, col3);
    
            for(Y1=y1;Y1<y2+1;Y1++)
            putpixel(x2, Y1, col1, col2, col3);
    
            for(X1=x1;X1<x2;X1++)
            putpixel(X1, y2, col1, col2, col3);
    
            for(Y1=y1;Y1<y2;Y1++)
            putpixel(x1, Y1, col1, col2, col3);
    
    
            return 0;
    }
    
    int RectFill(int x1, int y1, int x2, int y2, int col1, int col2, int col3)
    {
            int a, b;
    
            for(b=y1;b<y2;b++)
            for(a=x1;a<x2;a++)
            putpixel(a, b, col1, col2, col3);
            return 0;
    }
    
    int ClearScreen(int col1, int col2, int col3)
    {
            unsigned int a;
    
            if(GFXMODE==0)
            RectFill(0, 0, 320, 200, col1, col2, col3);
            if(GFXMODE==1)
            RectFill(0, 0, 640, 480, col1, col2, col3);
            if(GFXMODE==2)
            RectFill(0, 0, 320, 200, col1, col2, col3);
            if(GFXMODE==3)
            RectFill(0, 0, 640, 480, col1, col2, col3);
            if(GFXMODE==4)
            RectFill(0, 0, 800, 600, col1, col2, col3);
            if(GFXMODE==5)
            RectFill(0, 0, 1024, 768, col1, col2, col3);
            if(GFXMODE==6)
            RectFill(0, 0, 800, 600, col1, col2, col3);
            if(GFXMODE==7)
            RectFill(0, 0, 1024, 768, col1, col2, col3);
    
            return 0;
    }
    
    int InitMouse()
    {
    	int buttons;
    	int installed;
    
       asm
       {
       	mov ax, 0
          int 33H
    
          mov installed, ax
          mov buttons, bx
       }
    
       if(installed!=0)
       return buttons;
    
       else
       return 0;
    }
    
    int GetButtonStatus()
    {
    	int ButtonStatus;
    
       asm
       {
       	mov ax, 03H
          int 33H
          mov ButtonStatus, bx
       }
    
    	return ButtonStatus;
    }
    
    int GetMouseX()
    {
       int x;
    
       asm
       {
       	mov ax, 03H
          int 33H
       	mov x, cx
       }
    
    	return x;
    }
    
    int GetMouseY()
    {
       int y;
    
       asm
       {
       	mov ax, 03H
          int 33H
       	mov y, dx
       }
    
    	return y;
    }
    
    int SetMouseRange(int MinX, int MinY, int MaxX, int MaxY)
    {
       asm
       {
    		mov ax, 07H
       	mov cx, MinX
       	mov dx, MaxX
       	int 33H
    		mov ax, 08H
       	mov cx, MinY
       	mov dx, MaxY
       	int 33H
       }
    	return 0;
    }
    
    void interrupt MousePointer()
    {
       int a, b;
       static short save[8][8][3];
       static int oldx, oldy;
    
    	if(GFXMODE==2||GFXMODE==3||GFXMODE==6||GFXMODE==7)
       {
    		for(a=0;a<8;a++)
    		for(b=0;b<8;b++)
          {
    			putpixel(oldx+a, oldy+b, save[a][b][0], save[a][b][1], save[a][b][2]);
          }
       }
    
    	if(GFXMODE==1||GFXMODE==4||GFXMODE==5||GFXMODE==6)
       {
    		for(a=0;a<8;a++)
    		for(b=0;b<8;b++)
          {
    			putpixel(oldx+a, oldy+b, save[a][b][0], 0, 0);
          }
       }
    
    
       oldx=GetMouseX();
       oldy=GetMouseY();
    
    	if(GFXMODE==2||GFXMODE==3||GFXMODE==6||GFXMODE==7)
       {
    		for(a=0;a<8;a++)
    		for(b=0;b<8;b++)
          {
          	save[a][b][0]=getpixel(oldx+a, oldy+b, 1);
          	save[a][b][1]=getpixel(oldx+a, oldy+b, 2);
          	save[a][b][2]=getpixel(oldx+a, oldy+b, 3);
    
          }
       }
    
    	if(GFXMODE==1||GFXMODE==4||GFXMODE==5||GFXMODE==6)
       {
    		for(a=0;a<8;a++)
    		for(b=0;b<8;b++)
          {
          	save[a][b][0]=getpixel(oldx+a, oldy+b, 0);
          }
       }
    
       for(a=0;a<8;a++)
       for(b=0;b<8;b++)
    	{
       	if(GFXMODE==2||GFXMODE==3||GFXMODE==6||GFXMODE==7)
          {
          	if(MouseCursor[a][b]!=0)
    			putpixel(oldx+a, oldy+b, MouseCursor[a][b]*255, MouseCursor[a][b]*255, MouseCursor[a][b]*255);
          }
    		if(GFXMODE==1||GFXMODE==4||GFXMODE==5||GFXMODE==6)
    		{
          	if(MouseCursor[a][b]!=0)
    			putpixel(oldx+a, oldy+b, MouseCursor[a][b]*15, MouseCursor[a][b]*255, MouseCursor[a][b]*255);
          }
       }
    }
    
    
    //I would write it in assembly but I cant get it to work so im using the
    //dos function :( if you know how to do it in asm please email me and explain, thanks.
    //ramso13@email.com
    int HookMousePointer()
    {
    	setvect(TimeInt, MousePointer);
    	return 0;
    }
    
    int main()
    {
       
       return 0;
    }
    Last edited by stupid_mutt; 11-27-2001 at 01:51 PM.

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    140

    ugh, that looks bad

    damn, I didnt know it would look so bad pasted.
    Acos is good

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Paste between [c0de] [/c0de] tags, where 0 is o, looks much better.

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Using else-if's on these might help a little (or a return after each if is complete):

    if(GFXMODE==0)
    {
    }
    else if(GFXMODE==1)
    {
    }

    else if(GFXMODE==2)
    {
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using graphics library
    By arch in forum C++ Programming
    Replies: 2
    Last Post: 01-11-2008, 04:31 PM
  2. GD Graphics Library
    By Welder in forum Windows Programming
    Replies: 0
    Last Post: 11-01-2007, 07:46 PM
  3. Game Programming FAQ
    By TechWins in forum Game Programming
    Replies: 5
    Last Post: 09-29-2004, 03:00 AM
  4. Need some help choosing a good graphics library
    By dead_cell in forum Game Programming
    Replies: 31
    Last Post: 01-08-2003, 01:30 PM
  5. Graphics library?
    By Paninaro in forum C Programming
    Replies: 6
    Last Post: 06-24-2002, 09:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21