Jump to content
  • Advertisement
Sign in to follow this  
directNoob

[asm 80x86] Clear Screen.

This topic is 3969 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Rockoon1.

No, I havent meant a c compiler but a assembler. A normal assembler like
MASM or something like this.

Anyway. I trust you that this doesnt work! As I said, I just have a little experience.

But what can I do due to this problem? How can I clear the screen without
using compiler or OS dependent function? Like System("cls" ), wich works under win, but I think this doesnt work under any other OS, or any other compiler, like the borland compiler?!

Do you have any suggestions?

Thanks
Alex

Share this post


Link to post
Share on other sites
Advertisement
By using conditional compilation to separate OS specific code. Oh, and don't use system("cls") under windows either. Use the functions here for windows. There's an example here on how to write the program, but it doesn't say how to get the handle to the console windows. You can get it by calling "GetConsoleWindow" Function.

Share this post


Link to post
Share on other sites
You're really confused. You cannot access physical VRAM or BIOS interrupts on Windows or Linux or any recent OS.

If you want to do that then

1) get a DOS compiler
2) install DOS, or download a DOS emulator, or use the DOS emulator that is included with Windows

The console you see when you create a console application with a Windows compiler is not a "real" console anyway, it's a regular Windows GUI that just looks like a console.

Share this post


Link to post
Share on other sites
@nobodynews:
Thanks. But System("cls") works perfectly with the win c++ console app.

But the problem is, the work Im doing will not be compiled under win, so it wont be compiled under VC++ compiler. This is the reason I need to do it in c++/c in
ANSI C style. It must work with other compilers. But I am using win and VC++.
But I strongly program ANSI C and avoid windows related functions!
Because without the win .dll s, the code is worthless under the testers environment.

@outRider:
Ah, ok. I thought I can get somthing like a virtual VRAM which is responsible for drawing the dos console.

So you say there is no other way to clear the screen but System(..) or the one along with the borland compiler clrcls() or how it is call ?!

Alex

Share this post


Link to post
Share on other sites
Quote:

@nobodynews:
Thanks. But System("cls") works perfectly with the win c++ console app.

Of course. However, the command "cls" is Windows specific, even if System() is not. Because you are looking for portability, you should not use this.

Quote:

But the problem is, the work Im doing will not be compiled under win, so it wont be compiled under VC++ compiler. This is the reason I need to do it in c++/c in
ANSI C style. It must work with other compilers. But I am using win and VC++.

There is no ANSI compatible method to clear the screen. As others have pointed out, on modern operating systems, you must either directly or indirectly go through the system API.

This can be done by either using your provided System API (For example, the Win32 API), or another library. This is all in combination with conditional compilation (As nobodynews mentioned) to insure different variants for different systems.

Quote:

@outRider:
Ah, ok. I thought I can get somthing like a virtual VRAM which is responsible for drawing the dos console.

Under the DOS NTVDM, it does give you a virtual address space. However, this is only 16 bit DOS applications, which have an emulated real mode envirement.

Hence, if you are developing a 16 bit DOS application, you can directly access video memory by writing to its mapped region (By default text modes is 0xb8000)

Remember that there is a difference between Win32 console applications on 16bit DOS programs. Win32 console programs look like a DOS program, but are 32 bit, NOT 16 bit.

Quote:

So you say there is no other way to clear the screen but System(..) or the one along with the borland compiler clrcls() or how it is call ?!

Of course there is. You must keep in mind, however, that no matter which option you choose, it is system specific.

If portability is of concern, perhaps you can try using a portable library or API instead?

Share this post


Link to post
Share on other sites
Hi crypter.

Quote:

Of course there is. You must keep in mind, however, that no matter which option you choose, it is system specific.


But this means that there is no way.:(
The work Im doing is a implementation for a course at the university and the tester just copies the .h and .cpp files. This also means, I cant include any additional libs or .h or .cpp files.

This is very sad that there is no propper way to clear the screen system indipendent.

However. Then I do it the stupid way and just scroll a lines with cout << endl.

Thanks
Alex

Share this post


Link to post
Share on other sites
Quote:
Original post by directNoob
This is very sad that there is no propper way to clear the screen system indipendent.

When C was created your average state of the art human-accessable output device was a jumped-up typewriter connected to the computer. You can't clear the screen of a typewriter. C++ doesn't improve things in this regard.

It's unfortunate. In general, if it's not an abstraction on top of a file you can't do IO with it using the standard C/C++ library in any sort of portable way. You either need non-portable code or a third-party library that does the non-portable stuff for you.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!