VOGONS


First post, by eL_PuSHeR

User metadata
Rank l33t++
Rank
l33t++

Good day.

I've noticed that when you have several executable files with the same name, DosBox doesn't follow the common priority convention, that is, (from highest to lowest) -> .BAT .COM .EXE

Let's say you have a game folder with a A.BAT, A.COM and A.EXE, if you just type A [ENTER] under DosBox i think EXE is executed first which isn't right. That was my source of problems with Lost Files of Sherlock Holmes: Case of the Rose Tattoo until I figured it out. I had to type in HOLMES2.BAT for the BATCH file to run instead of HOLMES2.EXE

CAN YOU CONFIRM ON THIS?

Reply 1 of 15, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

might be broken.
It's the cvs version you are talking about. I recently changed that a bit.

Maybe i made a little mistake somewhere. So it might be fixed someday....

Water flows down the stream
How to ask questions the smart way!

Reply 2 of 15, by eL_PuSHeR

User metadata
Rank l33t++
Rank
l33t++

Thanks for the quick reply. Yes it's the CVS version. I just wanted to warn everyone because I was pulling my hair out until I figured it out. If you want to run a BATCH file that has the same name as the main executable, don't forget to write down the extension too.

Example: C:\>LOADIT.BAT

Reply 3 of 15, by dvwjr

User metadata
Rank Member
Rank
Member

Actually 'eL_PuSHeR', the developer/member "Qbix" has the emulation code for the command processor which is quite correct for Dosbox.

You have it wrong... Once the check for intrinsic commands is made by Command.com, the default external file type execution priority for MS/PC-DOS version 2.0+ to MSDOS version 8.0 is ".COM, .EXE, and lastly .BAT", so that DosBox is following the rules. One of the little remembered changes from DOS 1.x to DOS 2.x was that the execution priority was changed from the order ".BAT, .COM and .EXE" to the 'modern' and current ".COM, .EXE, .BAT" search order.

Batch files are text files that contain lists of other intrinsic, extrinsic, or batch commands. These files are processed by a s […]
Show full quote

Batch files are text files that contain lists of other intrinsic, extrinsic, or batch commands. These files are processed by a special interpreter that is built into the transient portion of COMMAND.COM. The interpreter reads the batch file one line at a time and carries out each of the specified operations in order.

In order to interpret a user's command, COMMAND.COM first looks to see if the user typed the name of a built-in (intrinsic) command that it can carry out directly. If not, it searches for an external command (executable program file) or batch file by the same name. The search is carried out first in the current directory of the current disk drive and then in each of the directories specified in the most recent PATH command. In each directory inspected, COMMAND.COM first tries to find a file with the extension .COM, then .EXE, and finally .BAT. If the search fails for all three file types in all of the possible locations, COMMAND.COM displays the familiar message

Bad command or file name

If a .COM file or a .EXE file is found, COMMAND.COM uses the MS-DOS EXEC function to load and execute it. The EXEC function builds a special data structure called a program segment prefix (PSP) above the resident portion of COMMAND.COM in the transient program area. The PSP contains various linkages and pointers needed by the application program. Next, the EXEC function loads the program itself, just above the PSP, and performs any relocation that may be necessary. Finally, it sets up the registers appropriately and transfers control to the entry point for the program. (Both the PSP and the EXEC function will be discussed in more detail in Chapters 3 and 12.) When the transient program has finished its job, it calls a special MS-DOS termination function that releases the transient program's memory and returns control to the program that caused the transient program to be loaded (COMMAND.COM, in this case).

Source: On-line copy of "Advanced MSDOS Programming" by Ray Duncan, Second Edition 1988 Microsoft Press

It was considered quite the authoritive book in the mid to late 1980s...

dvwjr

Reply 4 of 15, by icemann

User metadata
Rank Member
Rank
Member

And yet pretty much all dos-based games use batch files alot more than the exe files. And as dosbox is being done primarially to play dos games, shouldn`t the order be in the way it used to be. Rather than the last few versions of dos used.

Last edited by icemann on 2003-09-01, 05:28. Edited 1 time in total.

Reply 7 of 15, by dvwjr

User metadata
Rank Member
Rank
Member

Well, ask and ye shall receive. The first game for DOS was "DONKEY.BAS" written in IBM ROM BASIC by Bill Gates and another coder. It was included on the IBM PC-DOS 1.1 diskette sold with the original IBM PC.

Haven't you always wanted to try the first version of DOS? Maybe not, but I became interested when I read that all 1.x versions […]
Show full quote

Haven't you always wanted to try the first version of DOS? Maybe not,
but I became interested when I read that all 1.x versions of DOS came
with a game called DONKEY.BAS. The game in question was written by
Bill Gates and Neil Konzen - as you can see, IBM was pretty desperate
for things to include with DOS.

Source: TechKnight

Here was the first game included with IBM PC-DOS 1.1 - "DONKEY.BAS":

     REM The IBM Personal Computer Donkey
REM Version 1.10 (C)Copyright IBM Corp 1981, 1982
REM Licensed Material - Program Property of IBM
DEF SEG : POKE 106, 0
SAMPLES$ = "NO"
DIM CAR%(900)
GOTO 1010
SAMPLES$ = "YES"
1010 KEY OFF: SCREEN 0, 1: COLOR 15, 0, 0: WIDTH 40: CLS : LOCATE 5, 19: PRINT "IBM"
LOCATE 7, 12, 0: PRINT "Personal Computer"
COLOR 10, 0: LOCATE 10, 9, 0: PRINT CHR$(213) + STRING$(21, 205) + CHR$(184)
LOCATE 11, 9, 0: PRINT CHR$(179) + " DONKEY " + CHR$(179)
LOCATE 12, 9, 0: PRINT CHR$(179) + STRING$(21, 32) + CHR$(179)
LOCATE 13, 9, 0: PRINT CHR$(179) + " Version 1.10 " + CHR$(179)
LOCATE 14, 9, 0: PRINT CHR$(212) + STRING$(21, 205) + CHR$(190)
COLOR 15, 0: LOCATE 17, 4, 0: PRINT "(C) Copyright IBM Corp 1981, 1982"
COLOR 14, 0: LOCATE 23, 7, 0: PRINT "Press space bar to continue"
1100 IF INKEY$ <> "" THEN GOTO 1100
1110 CMD$ = INKEY$
IF CMD$ = "" THEN GOTO 1110
IF CMD$ = CHR$(27) THEN GOTO 1298
IF CMD$ = " " THEN GOTO 1160
GOTO 1110
1160 DEF SEG = 0
IF (PEEK(&H410) AND &H30) <> &H30 THEN DEF SEG : GOTO 1291
WIDTH 80: CLS : LOCATE 3, 1
PRINT "HOLD IT!"
PRINT "YOU'RE NOT USING THE COLOR/GRAPHICS MONITOR ADAPTER!"
PRINT "THIS PROGRAM USES GRAPHICS AND REQUIRES THAT ADAPTER."
PRINT "PRESS THE SPACE BAR TO CONTINUE."
DEF SEG
1240 IF INKEY$ <> "" THEN GOTO 1240
1250 CMD$ = INKEY$
IF CMD$ = "" THEN GOTO 1250
IF CMD$ = CHR$(27) THEN GOTO 1298
IF CMD$ = " " THEN GOTO 1298
GOTO 1250
1291 KEY OFF
ON ERROR GOTO 1295
PLAY "p16"
GOTO 1300
1295 COLOR 31, 0, 0
PRINT "THIS PROGRAM REQUIRES ADVANCED BASIC -- USE COMMAND 'BASICA'": COLOR 15, 0, 0:
FOR I = 1 TO 9000: NEXT: RESUME 1298
1298 ON ERROR GOTO 0
SCREEN 0, 1: COLOR 7, 0, 0: CLS : END
1300 REM
COLOR 0
DEFINT A-Y
SCREEN 1, 0: COLOR 8, 1
DIM Q%(500)
DIM D1%(150), D2%(150), C1%(200), C2%(200)
DIM DNK%(300)
GOSUB 1940
GOSUB 1780
CLS
DIM B%(300)
FOR I = 2 TO 300: B%(I) = -16384 + 192: NEXT
B%(0) = 2: B%(1) = 193
1540 REM
Show last 76 lines
     CX = 110: CLS
LINE (0, 0)-(305, 199), , B
LINE (6, 6)-(97, 195), 1, BF
LINE (183, 6)-(305, 195), 1, BF
LOCATE 3, 5: PRINT "Donkey"
LOCATE 3, 29: PRINT "Driver"
LOCATE 19, 25: PRINT "Press Space ";
LOCATE 20, 25: PRINT "Bar to switch";
LOCATE 21, 25: PRINT "lanes ";
LOCATE 23, 25: PRINT "Press ESC ";
LOCATE 24, 25: PRINT "to exit ";
FOR Y = 4 TO 199 STEP 20: LINE (140, Y)-(140, Y + 10): NEXT
CY = 105: CX = 105
LINE (100, 0)-(100, 199): LINE (180, 0)-(180, 199)
1670 LOCATE 5, 6: PRINT SD: LOCATE 5, 31: PRINT SM
CY = CY - 4: IF CY < 60 THEN 2230
PUT (CX, CY), CAR%, PRESET
DX = 105 + 42 * INT(RND * 2)
FOR Y = (RND * -4) * 8 TO 124 STEP 6
SOUND 20000, 1
A$ = INKEY$: IF A$ = CHR$(27) THEN 1298 ELSE POKE 106, 0:
IF LEN(A$) > 0 THEN LINE (CX, CY)-(CX + 28, CY + 44), 0, BF:
CX = 252 - CX: PUT (CX, CY), CAR%, PRESET: SOUND 200, 1
IF Y >= 3 THEN PUT (DX, Y), DNK%, PSET
IF CX = DX AND Y + 25 >= CY THEN 2060
IF Y AND 3 THEN PUT (140, 6), B%
NEXT: LINE (DX, 124)-(DX + 32, 149), 0, BF: GOTO 1670
1780 CLS
DRAW "S8C3"
DRAW "BM12,1r3m+1,3d2R1ND2u1r2d4l2u1l1"
DRAW "d7R1nd2u2r3d6l3u2l1d3m-1,1l3"
DRAW "m-1,-1u3l1d2l3u6r3d2nd2r1u7l1d1l2"
DRAW "u4r2d1nd2R1U2"
DRAW "M+1,-3"
DRAW "BD10D2R3U2M-1,-1L1M-1,1"
DRAW "BD3D1R1U1L1BR2R1D1L1U1"
DRAW "BD2BL2D1R1U1L1BR2R1D1L1U1"
DRAW "BD2BL2D1R1U1L1BR2R1D1L1U1"
LINE (0, 0)-(40, 60), , B
PAINT (1, 1)
REM DIM CAR%(900)
GET (1, 1)-(29, 45), CAR%
RETURN
1940 CLS
DRAW "S08"
DRAW "BM14,18"
DRAW "M+2,-4R8M+1,-1U1M+1,+1M+2,-1"
DRAW "M-1,1M+1,3M-1,1M-1,-2M-1,2"
DRAW "D3L1U3M-1,1D2L1U2L3D2L1U2M-1,-1"
DRAW "D3L1U5M-2,3U1"
PAINT (21, 14), 3
PRESET (37, 10): PRESET (40, 10)
PRESET (37, 11): PRESET (40, 11)
GET (13, 0)-(45, 25), DNK%
RETURN
2060 SD = SD + 1: LOCATE 14, 6: PRINT "BOOM!"
GET (DX, Y)-(DX + 16, Y + 25), D1%
D1X = DX: D1Y = Y: D2X = DX + 17
GET (DX + 17, Y)-(DX + 31, Y + 25), D2%
GET (CX, CY)-(CX + 14, CY + 44), C1%
GET (CX + 15, CY)-(CX + 28, CY + 44), C2%
C1X = CX: C1Y = CY: C2X = CX + 15
FOR P = 6 TO 0 STEP -1: Z = 1 / (2 ^ P): Z1 = 1 - Z
PUT (C1X, C1Y), C1%: PUT (C2X, C1Y), C2%
PUT (D1X, D1Y), D1%: PUT (D2X, D1Y), D2%
C1X = CX * Z1: D1Y = Y * Z1: C2X = C2X + (291 - C2X) * Z
D1X = DX * Z1: C1Y = C1Y + (155 - C1Y) * Z: D2X = D2X + (294 - D2X) * Z
PUT (C1X, C1Y), C1%: PUT (C2X, C1Y), C2%
PUT (D1X, D1Y), D1%: PUT (D2X, D1Y), D2%
SOUND 37 + RND * 200, 4: NEXT
FOR Y = 1 TO 2000: NEXT
CLS : GOTO 1540
2230 SM = SM + 1: LOCATE 7, 25: PRINT "Donkey loses!"
FOR Y = 1 TO 1000: NEXT
CLS : GOTO 1540

This will run with GWBASIC...

Have fun.

dvwjr

Last edited by dvwjr on 2003-09-01, 13:04. Edited 1 time in total.

Reply 10 of 15, by dvwjr

User metadata
Rank Member
Rank
Member

Originally posted by mrsbrisby:

maybe using a "SETVER" emulator could do the job. That way you could specify an old version where BAT was given higher priority.

Afraid not... The ".COM, .EXE, .BAT" is hardcoded in the Command.com command procesor. One could hack Command.com with a hex editor and change the order or extentions to anything one wanted, this ability has been there since DOS 2.x ... I doubt that that many people have availed themselves of this option.

Now with WinNT, Win2K and WinXP NTVDMs one could just alter the CMD.EXE environmental variable:

PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH

and change the order to anything desired...

dvwjr

Reply 11 of 15, by mrsbrisby

User metadata
Rank Newbie
Rank
Newbie

Originally posted by dvwjr
Afraid not... The ".COM, .EXE, .BAT" is hardcoded in the Command.com command procesor. One could hack Command.com with a hex editor and change the order or extentions to anything one wanted, this ability has been there since DOS 2.x ... I doubt that that many people have availed themselves of this option.

dosbox doesn't have a "real command.com" -- you're certainly welcome to use it (if it even works... no idea- no real command.com here), but then you're constrained to whatever shell you're using.

to put a finer point on it: how could the dosbox developers change this if they have to modify microsoft's command.com?

you've already pointed out that you knew this with an earlier statement:

Originally posted by dvwjr
...the developer/member "Qbix" has the emulation code for the command processor which is quite correct for Dosbox.

dosbox uses PROGRAMS_MakeFile() to make a program "appear" in Z:\ -- this is helpful as they don't take up any real-mode memory at this point (just enough to establish the secret handshake if run in a non-standard way)

a SETVER could just as easily be made, and like RESCAN, INTRO, MEM and MOUNT (and LOADFIX) it could modify dosbox's runtime- such as altering the logic in DOS_Shell::Which in src/shell/shell_misc.cpp to use a different order -- perhaps they could also do this using an "envrionment variable" like WinNT/2K/XP do (PATHEXT)-

how they do it isn't important. What is important that it's not only possible, it's nearly trivial.

I could spend a short while and hack a system to do exactly this. Not a lot of good it would do unless the developers actually want such functionality, which is the reasons for my probe.

... or perhaps you thought I meant something else? 😁

Reply 12 of 15, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

dosbox has a real command.com
it's actually damn complex and it does have the possibity to change the order in which the .com .exe .bat extension are used.

it's done in shell_execute (which in turn is part of our command.com) (actually in the call to which as you pointed out)

Setver as a command is defitely not needed.

(and we don't use the command.com from microsoft or somebody else. We got our own one and it's damn good 😉

that makefile actuall adds our command.com which is entered by that callback it sets up. It's really a command.com only a lot smaller than you are used to 😉

Water flows down the stream
How to ask questions the smart way!

Reply 13 of 15, by mrsbrisby

User metadata
Rank Newbie
Rank
Newbie
Qbix wrote:

dosbox has a real command.com

my appologies; I probably should have just mentioned it isn't outside dosbox, or real mode might have been better; that programs run inside dosbox call it, usually, instead of MS-DOS's command.com (or the windows' command.com (or the freedos command.com (etc)); and that no hex editing is actually necessary to change the order of things.

Originally posted by Qbix
Setver as a command is defitely not needed.

Well, it would be one (convenient) way of getting the command shell to exhibit semantics of older versions; but I did suggest the WinNT/2K/XP way as well, as an option...

Originally posted by Qbix
(and we don't use the command.com from microsoft or somebody else. We got our own one and it's damn good 😉

I didn't think I said otherwise 😜

well, except for the part of being "damn good" -- now that you mention it, the history/line editor could use some work. it seems it clobbers memory under some situations... [someone] should look into it 😁