joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.81k stars 383 forks source link

Run applications in (Linux) console #3968

Open excitoon opened 1 year ago

excitoon commented 1 year ago

Is your feature request related to a problem? Please describe.

Hey. I'd like to have possibility to run console applications without any windows and having their output (properly) redirected to host machine.

What you want

Hey. I'd like to have possibility to run console applications without any windows and having their output (properly) redirected to host machine.

Describe alternatives you've considered

I considered making dosbox-y, but I really do not want to.

Additional information

No response

Have you checked that no similar feature request(s) exist?

Code of Conduct & Contributing Guidelines

Torinde commented 1 year ago

Yes, that would be useful also for Windows and other host platforms. Related Console features:

excitoon commented 1 year ago

@Torinde Yeah, all of these are related and many can be solved simply by redirecting output. I guess I'll make this one as I need DEBUG.COM output so much.

excitoon commented 1 year ago

This is a stack of junk, however, look at 0x21/0x02 and 0x21/0x09 implementations:

        case 0x09:      /* Write string to STDOUT */
            {
                uint8_t c;uint16_t n=1;
                PhysPt buf=SegPhys(ds)+reg_dx;
                std::string str="";
                if (mem_readb(buf)=='T')
                    while ((c=mem_readb(buf++))!='$') {
                        str+=std::string(1, c);
                        if (str.length()>42) break;
                    }
                buf=SegPhys(ds)+reg_dx;
                reqwin=(str.length()==42&&!strncmp(str.c_str(),"This program cannot be run in DOS mode.",39))||(!strncmp(str.c_str(),"This program requires Microsoft Windows.",40))||(str.length()==38&&!strncmp(str.c_str(),"This program must be run under Win32",36));
                if (!winautorun||!reqwin||control->SecureMode()||!startquiet)
                    while ((c=mem_readb(buf++))!='$')
                        DOS_WriteFile(STDOUT,&c,&n);
                reg_al=c;
            }

And single characters skip all these checks:

        case 0x02:      /* Write character to STDOUT */
            {
                uint8_t c=reg_dl;uint16_t n=1;
                DOS_WriteFile(STDOUT,&c,&n);
                //Not in the official specs, but happens nonetheless. (last written character)
                reg_al=(c==9)?0x20:c; //strangely, tab conversion to spaces is reflected here
            }
            break;
excitoon commented 1 year ago

@joncampbell123 FYI

$ git add src/debug/debug_gui.cpp
The following paths are ignored by one of your .gitignore files:
src/debug
hint: Use -f if you really want to add them.
hint: Turn this message off by running
hint: "git config advice.addIgnoredFile false"
excitoon commented 1 year ago

Feel free to make pull requests to my branch. :)