VOGONS


First post, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

The header says it all. I've patched the CLS command in shell_cmds.cpp so that it sets the video mode I use for my custom build, but it would be good to have CLS work the way it does under real DOS, where it preserves the current video mode.

I understand that this feature is useless for games, and that the developers will not spend time on the question. I'm asking only in the hope that someone else has figured out how to do this. Many thanks for any help.

Reply 1 of 6, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author
void DOS_Shell::CMD_CLS(char * args) {
HELP("CLS");
Bit8u mode=mem_readb(BIOS_VIDEO_MODE);
if (mode<=3 || mode==7) WriteOut("\e[2J");
else {
reg_ax=(Bit16u)mode;
CALLBACK_RunRealInt(0x10);
}
}

You'll need to add any special text mode number you're using to the condition, because it only uses the ANSI clear for normal text modes (like real DOS) as written.

Reply 2 of 6, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie
ripsaw8080 wrote:
You'll need to add any special text mode number you're using to the condition, because it only uses the ANSI clear for normal te […]
Show full quote
void DOS_Shell::CMD_CLS(char * args) {
HELP("CLS");
Bit8u mode=mem_readb(BIOS_VIDEO_MODE);
if (mode<=3 || mode==7) WriteOut("\e[2J");
else {
reg_ax=(Bit16u)mode;
CALLBACK_RunRealInt(0x10);
}
}

You'll need to add any special text mode number you're using to the condition, because it only uses the ANSI clear for normal text modes (like real DOS) as written.

Thank you! That was fast...!

Quick question while I prepare to try this out:

Thanks to you and h-a-l, I have a custom modes numbered 56, 57, and 58 (all hex). In the condition statement, do I use "mode==0x056" or "mode==56", etc., or something like

.. || (mode>=56 && mode<=58)

?? Apologies for thanking you for your answer by asking another question!

Reply 3 of 6, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author
if (mode<=3 || mode==7 || (mode>=0x54 && mode<=0x58))

That covers the existing SVGA text modes plus the custom ones.

Alternatively, this will cover any text mode, even ones added later:

#include "../ints/int10.h"
...
void DOS_Shell::CMD_CLS(char * args) {
HELP("CLS");
if (CurMode->type==M_TEXT) WriteOut("\e[2J");
else {
reg_ax=(Bit16u)CurMode->mode;
CALLBACK_RunRealInt(0x10);
}
}

Reply 4 of 6, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

About to implement your alternative version. Thank you!

Reply 5 of 6, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

Works perfectly (as you already knew, of course)! Thank you again.

Reply 6 of 6, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie
ripsaw8080 wrote:
[…]
Show full quote
#include "../ints/int10.h"
...
void DOS_Shell::CMD_CLS(char * args) {
HELP("CLS");
if (CurMode->type==M_TEXT) WriteOut("\e[2J");
else {
reg_ax=(Bit16u)CurMode->mode;
CALLBACK_RunRealInt(0x10);
}
}

For anyone who wants to us this code, one small addition:

The code quoted above works perfectly with GNU compilers, but in Microsoft Visual C++, the "\e" escape sequence is illegal, so \e needs to be replaced with \033, like this:

#include "../ints/int10.h"
...
void DOS_Shell::CMD_CLS(char * args) {
HELP("CLS");
if (CurMode->type==M_TEXT) WriteOut("\033[2J");
else {
reg_ax=(Bit16u)CurMode->mode;
CALLBACK_RunRealInt(0x10);
}
}

Thanks again to ripsaw for solving this problem!