Thread: Dos graphics?

  1. #1
    Resident nerd elnerdo's Avatar
    Join Date
    Apr 2005
    Location
    Northern NJ
    Posts
    51

    Dos graphics?

    Is there any way at all to do DOS graphics with C++? I've searched for days on this and I don't think it's possible. Simply a function to set a pixel to a certain color is all I need.
    nerds unite!

    I'm using windows XP.
    I'm using dev-C++ by bloodshed.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    there's a graphics library in some header file. but it's not standard and most compilers don't include it.
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  3. #3
    Registered User
    Join Date
    Apr 2005
    Posts
    4


    hey i use those all the time...
    email me at
    [email protected]
    or aim at
    nsannagable

    ... and i will give you a short tutorial

  4. #4
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    937
    Allegro? Is that DOS?
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  5. #5
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    It used to be. Now it is for alot of platforms and of course still dos.
    He is probably talking about 13h mode.
    Woop?

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well unless the OP gets around to posting the actual compiler and operating system in use, then there isn't much more that can be said.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Resident nerd elnerdo's Avatar
    Join Date
    Apr 2005
    Location
    Northern NJ
    Posts
    51
    Dev c++ by bloodshed and the operating system in use?

    Shouldn't "DOS graphics" make that obvious enough?
    nerds unite!

    I'm using windows XP.
    I'm using dev-C++ by bloodshed.

  8. #8
    Registered User
    Join Date
    Aug 2004
    Location
    San Diego, CA
    Posts
    313
    Nope. FreeDOS != MS-DOS != Windows 9X DOS != Windows NT DOS Emulation != ...

  9. #9
    Resident nerd elnerdo's Avatar
    Join Date
    Apr 2005
    Location
    Northern NJ
    Posts
    51
    Windows XP command prompt.
    nerds unite!

    I'm using windows XP.
    I'm using dev-C++ by bloodshed.

  10. #10
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Shouldn't "DOS graphics" make that obvious enough?
    No. It doesn't. DOS graphics can be done on virtually any 16-bit compiler. I recommend 32-bit DJGPP however. You can use Allegro for DOS if you want, but if you don't understand anything about programming games it won't be of much use to you.

    Here is a small DOS mode 13h unit.

    Code:
    #include <dos.h>
    
    typedef unsigned char BYTE;
    typedef unsigned int WORD;
    tyepdef unsigned long DWORD;
    
    #define TRUE 1
    #define FALSE 0
    
    #define XYTOMEM(x,y)  (((y)<<(8))+((y)<<(6))+(x))
    
    
    class Display
    {
      protected:
        int m_iBufferMode;
        BYTE far *m_pScreen;
        BYTE far *m_pBuffer;
        BYTE far *m_pSurface;
      public:
        Display(void):m_iBufferMode(FALSE),m_pScreen(0),m_pBuffer(0),m_pSurface(0) {}
        virtual ~Display(void) 
        {
           if (m_pBuffer) delete [] m_pBuffer;
           m_pBuffer=0;
           m_pScreen=0;
           m_pSurface=0;
        }
    
        void SetBufferMode(int bufmode=TRUE)
        {
           switch(bufmode)
           {
              case TRUE:  m_pSurface=m_pBuffer;m_iBufferMode=TRUE;break;
              default: m_pSurface=m_pScreen;m_iBufferMode=FALSE;break;
           }
             
        }
    
         int Init(void)
         {
            REGS regs;
            regs.x.ax=0x13;
            int86(0x10,& regs, & regs,);
            
            m_pBuffer=new BYTE[64000L];
            if (!m_pBuffer) return (-1);
    
            m_pScreen=(BYTE far *)MK_FP(0xA000,0);
            m_pSurface=m_pScreen;
    
            m_iBufferMode=FALSE;
            return TRUE;
         }
    
         void SetPixel(WORD offset,BYTE color)
         {
            m_pSurface[offset]=color;
         }
      
         void SetPixel(int x,int y,BYTE color)
         {
           m_pSurface[XYTOMEM(x,y)]=color;
         }
    
         BYTE GetPixel(WORD offset)
         {
            return m_pSurface[offset];
         }
    
         BYTE GetPixel(int x,int y)
         {
           return m_pSurface[XYTOMEM(x,y)];
         }
    
         //Always flips from buffer to screen no matter buffermode
         void Flip(void)
         {
            BYTE far *ptrBuf=m_pBuffer;
            BYTE far *ptrScrn=m_pScreen;
    
            asm {
              push  ds
              
              les di,[ptrScrn]
              lds si,[ptrBuf]
              mov ecx,32000d
              rep movsd
            
              pop ds
           }
        }
    };
    If I didn't make any errors this should work just fine. Add functions to the class as you see fit.
    Last edited by VirtualAce; 04-22-2005 at 08:57 PM.

  11. #11
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > Dev c++ by bloodshed
    > Windows XP
    Then start using LIBSDL (just look at the packages menu in dev-c++ and download a pre-configured package).
    Then goto http://www.libsdl.org/index.php and start reading examples, tutorials etc.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Graphics for DOS under Dev-C++
    By bubux in forum C Programming
    Replies: 16
    Last Post: 07-08-2002, 01:24 PM
  2. Dos graphics header
    By Vicious in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 05-14-2002, 12:24 PM
  3. Extremely Simple Graphics In Dos
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 03-07-2002, 07:25 PM
  4. Graphics in DOS help :)
    By PsThrough in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 01-19-2002, 04:02 PM
  5. VC++ graphics in dos.
    By StormySpike in forum C++ Programming
    Replies: 5
    Last Post: 09-28-2001, 10:24 AM