Solved

two easy questions

Posted on 1998-10-15
3
198 Views
Last Modified: 2010-04-15
1. why doesn't the ascii character -> (right arrow) work.
   every ascii chart I have seen says that this is hex 1A
   but it will not work. I get the others to work but not    that one.
2 I am writing a dos program that has a menu. I have set up   borders around the menu no problem now I want to color the   menu. how do I color just the menu background and not the   whole screen.  
0
Comment
Question by:strmtrpr
3 Comments
 
LVL 1

Accepted Solution

by:
mlaiosa earned 110 total points
Comment Utility
All the ascii charcters below 32 (0x20) have special meanings and for that reason, many of them cannot be displayed on the screen using standard out.  1A is one such charcter.  It is the End of FIle (EOF) charcter.

to display *any* ascii charcter on a display that is not MGA or HGC, and to set the color of any signal charcter, use the folowing: (I assume you are using TC for dos):

#include <dos.h>

void putchar(int x, int y, char c)
//puts the charcter c at x,y on the screen.
{
  *(char far *)MK_FP(0xb800,2*(y*80+x))=c;
}

char putchar(int x, int y)
//returns the charcter at x,y
{
  return *(char far *)MK_FP(0xb800,2*(y*80+x));
}

void setattr(int x, int y, int attr)
//set the attribute attr at x,y
{
  *(char far *)MK_FP(0xb800,2*(y*80+x)+1)=attr;
}

int getattr(int x, int y)
//get the attribute at x,y
{
  return *(char far *)MK_FP(0xb800,2*(y*80+x)+1);
}


for all those functions, the upper left corner of the screen is 0,0  They do not move the cursor, or care where it is.
valid attributes are 0x00 .. 0xff

the first hex digit is the background color and the second is the forground color.

I would reccomend doing some experiments to find what 0..f values generate what values and make some defines, ex:

#define black 0
#define blue 1
#define green 2
#define cyan 3

so that you could do stuf like:

putattr(5,15,(black<<4)+green);  //this will generate green on black
0
 

Author Comment

by:strmtrpr
Comment Utility
thank you answering so quickly.

0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
Actually, ASCII calls it the Substitute (SUB) character
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now