# 2D Graphics in CMD in C#

So, almost every programmer used Doom as inspiration for new Projects, right? So Doom and other classic MS-DOS game were played on something like Command Prompt. How do you display images in Command Prompt without using System.Windows.Forms? By the way, I don't accept add-ons. (It doesn't have to be 3D)

• Windows Command Line can display only text. You can not display images there. You should use some "rich" output, which supports pixels. I am not sure what Doom used in DOS, but now people usually use OpenGL or DirectX. – Ivan Kuckir May 18 '13 at 20:59
• Thanks Man. Maybe MS-DOS Command Prompt was better or something. :) – Helder Novais May 18 '13 at 22:44
• Doom was not played on something like Command Prompt. Something like Command Prompt was used to launch Doom, which did its own stuff. – user15805 May 18 '13 at 23:30
• Why do you have the need to try something so inefficient ( scratch that, it's not even possible)? Why not just use XNA or any other framework that produces FULLSCREEN windows. It's no different than what Dos games did ( going full screen that is ). Besides who uses pure MS-DOS these days to play games? – Sidar May 18 '13 at 23:36
• You people didn't get the fact that I don't care if it's 3D or not (Read the title!). It was just an example. I already worked with XNA, by the way. And, Sidar, I love to feel nostalgia, and I really liked MS-DOS and Command Prompt (I work with Vista). – Helder Novais May 19 '13 at 19:21

Games like Doom ran in 16 bit real mode under DOS. In this environment, there were system calls, called interrupts, that you could call to switch the display into several graphics modes.

The most popular at the time was mode 13h. It was called this, because you called interrupt 10h (h specify that this is a base 16 number), with register al loaded with 13h, ah set to zero. 16 bit assembly going something like:

xor ah,ah
mov al,13h
int 10h


Once in this mode, you could write directly to graphics memory that started at offset 0xA0000. See the wikipedia article, or many mode 13h tutorials on the web for how to do this.

Do note, to do any of this today, you need to have a compiler capable of outputting 16-bit code, or an 16-bit assembler.

Edit
To be clear, I answered to provide some historical background on your question, and to show you how you could do this sort of programming still today, if you wanted to, for purely educational purposes. Please note, this is not possible with C#.

• To add to the answer: IIRC, TASM works well on Windows XP. Alternatively, you can just DosBox the whole thing, on newer OSes. – user15805 May 19 '13 at 2:50
• Yeah, when I used to still do mode 13h programming I used TASM or Borland Turbo-C++, which supported 16-bit real mode executables. – Stephan van den Heuvel May 19 '13 at 3:14

Doom itself had little to nothing to do with the command line. They actually had APIs to do graphics back then, much of the use written ones use the method Stephan explained. I've also seen command line graphics done in C++ though, but it had to do with lots of code. None of this is possible in C#.

Anyway if you want to do graphics why bother with the command line? Try an API such as XNA or OpenTK?

I also would not advise such bland questions on this site. Please explain more next time!