#57 DOS/Shell enhancements

open
None
5
2012-09-07
2004-09-05
`Moe`
No

This patch "fixes" a few things:

  • corrects tab completion:

try entering "c:\ultrasnd\", then press <tab>
Expected result: "c:\ultrasnd\ULTRAMID.EXE" or similar
Current result: "ULTRAMID.EXE"
The patch fixes this.

  • enhances COPY command:

Enter "COPY a:setup.exe"
Expected result: interpretation as "COPY a:setup.exe ."
Current result: error message
The patch implements this.

Enter "COPY /b somefile some"
Expected result: copying of file in binary mode
Current result: error message
The patch makes COPY ignore /B and /T if given.
AFAIK, binary mode is only used when concatenating multiple
files with "+", but some batch files (install routines) nevertheless
add this switch for normal copy operation.

  • implements CHOICE command:

Enter "CHOICE /c:12 Select: /n"
Expected result: print "Select: " and wait for a keypress, setting
errorlevel 1 if "1" was pressed, and errorlevel 2 if "2" was
pressed.
Current result: error message
This patch implements CHOICE with the two switches /c and /n.
I do not know if there are more switches, but it seems like those
two are used most. It allows you to create simple menu
interfaces in batch files, and is used in some install routines.

  • implements dummy ATTRIB command:

Enter "ATTRIB -r -h somefile"
Expected result: making "somefile" read/write
Current result: error message
This patch simply makes ATTRIB act like REM. It does not alter
any attributes, not even readonly (which is the only attribute
universally available). It's just to silence any warnings.

  • implements ADDKEY command:

This is an extension which I created loosely based on a similar
tool in 4DOS (keystack). It allows you to add keys into the
keyboard buffer in order to skip intro screens, games' hardware
configuration questions and similar.

There are two modes of operation:

The first mode inserts keys into the BIOS keyboard buffer using
INT16. Advantage: easy to use. Disadvantage: Fails with many
programs.
For example, if you have Civilization 1 with the addon OPL-3
driver, You would normally have to enter "1" "6" "1" at every
startup. Using this command sequence in a batch file (including
the autoexec section of dosbox.ini), you can skip the config
questions:
ADDKEY 1 6 1
CIV.EXE

To skip the intro as well, use:
ADDKEY 1 6 1 Space
CIV.EXE

Allowed are all single characters, plus the special arguments
"Space" and "Enter", separated with spaces, as many as the
buffer can hold. It only works when the program in question uses
the BIOS to read the keyboard.

The second mode of operation uses the dosbox keyboard
handler to add keypresses. It is able to fool any and all
programs (something which pure dos tools, including 4DOS's
keystack, can't do), but has a more complicated syntax.
It works by generating keypress and keyrelease events with
user-specifiable timings. By default, a given key is pressed
immediately and then released again with no delay:
ADDKEY 52
would simulate the Enter key. The number is a dosbox keysym.
basically, 0x1 = 1, 0x2 = 2, ..., 0x9 = 9, 10 = 0, 11 = q, 21 = a,
and so on. 52 is Enter. You have to use "0x1" instead of "1", as
"1" is used by simple mode above.
However, many programs need some time until they start to
read the keyboard. So using this syntax, you cann add pauses:
ADDKEY p1000 52 p500 52
would simulate the enter key after 1 second (1000 ms), and
another enter key press after another pause of half a second
(1.5 seconds after the command was executed).
I haven't come across this yet, but some programs might also
be sensitive to key press duration, so there is a syntax to
configure it:
ADDKEY l100 52
would simulate an enter key press for 100ms. The duration is
kept for all subsequent keys until changed. This allows you to
simulate Shifted keypresses (or Alt/Control):
ADDKEY l100 54 l40 21
would be Alt-A (press left alt for 100 ms, and almost
immediately press the "a" key for 40ms)
This can be mixed freely:
ADDKEY 52 p1000 l100 54 l0 21 p100 52
would be:
Press Enter immediately, wait a second, press left-alt for
100ms, press "a" immediately thereafter with a duration of 0ms
(which is the default), wait 100ms (until left-alt has been
released), then press Enter again.

Do not mix "simple" keys with the advanced mode however, this
might produce unexpected results.

Using the right amount of pauses and keys, this allows you to
skip any opening questions, intro screens, even load a saved
game or similar, since the keys are inserted as if SDL read them
from the keyboard.

Discussion

  • `Moe`
    `Moe`
    2004-09-05

    Patch against current CVS

     
  • Peter Veenstra
    Peter Veenstra
    2004-09-08

    Logged In: YES
    user_id=535630

    hi Moe,

    Thank you for your patch.
    The key"inserter" is something i never knew it existed and I
    understand It's use but I find a bit unneeded. (I might
    change my mind though :)

    At the moment dosbox it's features are frozen. (testing and
    documenting stuff for the release)

    Only very simple stuff that doesn't break a thing is inserted
    I will include parts of the patch though. (like that very
    handy tab-completion improvement.will extend it a bit so /
    is accepted as wel for tab completion.) attrib and choice
    probably as well.

    Peter

     
  • `Moe`
    `Moe`
    2004-09-26

    Logged In: YES
    user_id=1045474

    Hah, imagine my astonishment when the last CVS update had merge
    failures because of the code being in ;)

    I've already noticed two small things about this patch, I'll probably fix it
    some day, but just so I won't forget them, they are: Tab-completion
    should also consider ":" so that "z:"<tab> works, not just "z:\"<tab>.
    Copy's + operator would be nice, just found an installer batch file (loom
    vga update) that uses it.

    About addkey:

    I like it very much, since I put a dosbox.conf into each of my games'
    dirs, and in there, I can skip configuration question found in older
    games. My TV will run many of these games (via mythtv), and since
    I'm not the only one playing, games should start up ready-to-use.
    About 10% of my games profit from that.

    (Btw, yes, I know about the feature freeze.)

     
  • `Moe`
    `Moe`
    2005-03-03

    Logged In: YES
    user_id=1045474

    As the other enhancements are already in CVS, here is the ADDKEY
    code again, standalone. Syntax has been improved to be easier, and
    problems with some changes to key handling have been resolved. Just
    an example to show the easier syntax:

    ADDKEY d e m o . e x e enter f2 enter p1000 l200 y p10000 c-c

    (Enter "demo.exe" followed by enter, then press f2, then enter, wait a
    second, press 'y' for 200msec, wait 10 seconds, press ctrl-c)

    There are no longer 2 modes of operation or anything, just this syntax:
    any char is just that char. special keys are recognized (Enter, PgUp,
    left, f11, and so on), p<number> waits some milliseconds, l<number>
    makes keys pressed the given amount of msecs. Works like a charm
    to skip configuration questions and similar startup input.

     
  • `Moe`
    `Moe`
    2005-03-03

    addkey command