Thread: Drawing to the DOS screen with one function call

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    2

    Drawing to the DOS screen with one function call

    If I want to draw pixels in Mode13h in DOS, all I have to do is declaring the following:
    Code:
    unsigned char far *screen = MK_FP(0xA000, 0x0000);
    Now, I can access every of the 64000 pixels in the video memory by using the pointer as an array.

    How can I do this in text mode?

    As far as I know, in DOS text mode, each character occupies two bytes: One for the character value and one that saves the text color, the background color and the information if the text blinks.
    Now let's say I have an array of the size of 80 x 25 x 2 bytes. (columns x rows x (character + color + blinking)). How do I retreive access to the video memory so that I can use memcpy and fill the screen with the characters and colors declared in my array?

  2. #2
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Are you working in actual DOS or are you programming in Windows and just running a console program?
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  3. #3
    Registered User
    Join Date
    Aug 2011
    Posts
    2
    Actual DOS. But it's OK. I already found the solution:
    Code:
    MK_FP(0xB800, 0x0000);

  4. #4
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    So, what version of DOS are you using if you don't mind me asking?
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  5. #5
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by AndrewHunter View Post
    So, what version of DOS are you using if you don't mind me asking?
    Even more interesting... what compiler???

    DOS has been dead longer than my oldest grandchild has been alive!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 07-08-2011, 01:16 PM
  2. GDI - Drawing to the screen correctly
    By Tonto in forum Windows Programming
    Replies: 1
    Last Post: 06-24-2006, 09:53 PM
  3. Drawing something on the screen...
    By Finchie_88 in forum C++ Programming
    Replies: 3
    Last Post: 10-22-2004, 12:23 PM
  4. drawing to screen
    By Noobie in forum C++ Programming
    Replies: 11
    Last Post: 02-27-2003, 04:37 PM
  5. Drawing a line on the screen
    By Leano in forum C++ Programming
    Replies: 3
    Last Post: 01-31-2003, 09:24 PM