Thread: 3 Questions

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    109

    3 Questions

    1. How do you change the font and background colour when in MS DOS?

    2. I'm about to make a game with a lot of text what is the best way to store it eg. text file or binary?

    3. Also is ther a way you can get the time and import it into your program (eg. My game is going to use the real time)?

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    2) Binary if you care about speed a lot. In a text game it shouldn't matter though. If you want someone editing it just make it text, if not binary.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  4. #4
    Casual Visitor
    Join Date
    Oct 2001
    Posts
    350
    I've been playing around with a few functions that you *might* be able to use. These are good only for real dos. They will not (at least not yet) work in a 32bit win32 console program. These are used in MSVC ver 1 and the target is a dos exe.

    Code:
    /* curosr funcs.c */
    
    typedef unsigned char tiny;
    
    tiny getCursorX(void)
    {
          tiny xpos;
    
          _asm
         {
              xor bh,bh
              mov ah,0x03
              int 0x10
    
              mov xpos,dh
              int 0x10
          }
        
          return xpos;
    }
    
    tiny getCursorY(void)
    {
          tiny ypos;
          
          _asm
         {
             xor bh,bh
             mov ah,0x03
             int 0x10
       
             mov ypos,dl
             int 0x10
          }
    
           return ypos;
    }
    
    void exitDOS(void)
    {
          _asm
          {
              mov ah,0x02
              mov bh,0
              mov dx,0
              int 0x10
    
              mov ah,0x09
              xor bh,bh
              mov cx,2000
              mov bl,0x07
              mov al,' '
              int 0x10
           }
    }
    
    /* a fun one to use */
    
    void centerText(tiny sxpos, tiny expos, tiny sypos, tiny eypos, tiny color, char message[])
    {
         tiny center;
    
         center = (79 - strlen(message)) / 2;
    
         _asm
        {
             mov ah,6
             xor al,al
             mov bh,color
             mov ch,sxpos
             mov cl,sypos
             mov dh,expos
             mov dl,eypos
             int 0x10
         }
    
         setCursor(sxpos,center), printf("%s", message);
    }
    Put the prototypes in a single header. Probably buggy code, but it does what I want for now.
    I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >3. Also is ther a way you can get the time and import it into your program (eg. My game is going to use the real time)?
    Code:
    #include <stdio.h>
    #include <time.h>
    
    int main ( void )
    {
      time_t sys_time;
      sys_time = time ( NULL );
      printf ( "%s", ctime ( &sys_time ) );
      return 0;
    }
    -Prelude
    My best code is written with the delete key.

  6. #6
    Registered User fletch's Avatar
    Join Date
    Jul 2002
    Posts
    176
    I've been playing around with a few functions that you *might* be able to use. These are good only for real dos. They will not (at least not yet) work in a 32bit win32 console program. These are used in MSVC ver 1 and the target is a dos exe.
    Yeah, unfortunately Windows doesn't like those 0x10 interrupt calls. However, Windows does provide some API functions that work just as well for moving the cursor and changing colors. Try SetConsoleTextAttribute, GetConsoleScreenBufferInfo, SetConsoleCursorPosition, FillConsoleOutputAttribute, FillConsoleOutputCharacter, SetConsoleCursorInfo, etc. These are all included in windows.h
    "Logic is the art of going wrong with confidence."
    Morris Kline

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 08:47 AM
  2. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  3. Several Questions, main one is about protected memory
    By Tron 9000 in forum C Programming
    Replies: 3
    Last Post: 06-02-2005, 07:42 AM
  4. Trivial questions - what to do?
    By Aerie in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 12-26-2004, 09:44 AM
  5. questions questions questions.....
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-14-2001, 07:22 AM