Upcoming Events
Unite 2010
11/10 - 11/12 @ Montréal, Canada

GDC China
12/5 - 12/7 @ Shanghai, China

Asia Game Show 2010
12/24 - 12/27  

GDC 2011
2/28 - 3/4 @ San Francisco, CA

More events...
Quick Stats
102 people currently visiting GDNet.
2406 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!
Link to us Events 4 Gamers
Intel sponsors gamedev.net search:

  Contents

 Introduction
 Arising Conflicts
 Resolving Conflicts
 Bitmapped Fonts
 Conclusion

 Printable version

 


Arising Conflicts

When I first started, I thought that all a console had to do was retrieve keyboard messages from the user and print them to the screen. Then, you just compare strings, right? Wrong!

When I tried to make my leap to creating the console, I encountered many annoying problems. Before we get into the problems you should consider before starting the console, I would like you to do this:

Open up the MS-DOS console in Windows, and type a few commands (even invalid commands). Notice how the DOS console responds to invalid commands by printing "Bad command or file name". Type a few copy commands to copy files from one place to another. This time, notice how the copy command accepts two "arguments" (source file and destination file). Lastly, notice that as the DOS window gets filled, the lines in the top get scrolled up and out of view. These are all things to consider, since we're trying to make a "clone" of this console in DirectDraw. Based on the observations we've done, the following could be considered problems we need to overcome:

We need a way to receive the line input the user has typed.

We need a way to copy the input we received into something that I call "the console buffer". A console buffer will have all the lines that user has input. When a console buffer is filled fully (i.e., maximum number of lines have been added), the first line is removed, and the first line becomes the second, second becomes third, and so on. And the last line is free to take any new input.

We must be able to process the line input we have received from the user. This includes separating the "command" (what the user wants to do) from any supplied "arguments" (if any are required by the command). An example of this would be:

       copy myfile.txt myfile2.txt

myfile.txt and myfile2.txt are arguments of the command copy.

We also need to put a "prompt" where needed. A prompt is like the "C:\>" in the DOS console. Lines that the user enters input on start with the prompt. Lines that give feedback to the user (like "Bad command or file name") don't require a prompt.

Since we're creating the console in DirectDraw, we also need to consider the character size, number of pixels to leave after each character, and after each line. We must also keep in mind the maximum number of characters that can fit on the screen. It might sound too much, but once we find that shortcut, we will reach home quickly. So let's get started.


Next : Resolvng Conflicts