Forums

Forums (http://www.abandonia.com/vbullet/index.php)
-   Programming (http://www.abandonia.com/vbullet/forumdisplay.php?f=25)
-   -   A tiny but useful contraption (http://www.abandonia.com/vbullet/showthread.php?t=28560)

The Fifth Horseman 06-04-2012 07:44 PM

A tiny but useful contraption
 
1 Attachment(s)
Right, so I've solved the problem with Warcraft 2 today, but then it struck me that a more generalized version of the utility I've created for it might have a wider use for us.

I'm attaching a copy of the updated program, compiled into a DOS executable using a 20 year old version of Borland Turbo C.
Source code (C)


Now, what DOES it do?
Let's assume you're peparing a game archive and the particular game needs something to be mounted under a separate drive letter. Do we know where the user will chuck the game archive? Do we know what mount commands will work? Nope. It would save both us and the users some grief if we were able to automatically determine the required paths...
And that's exactly where this little toy comes in.
You'll need to include three things in the game directory: the first is of course the utility itself. The second is a startup batch script, like this:
Code:

@echo off
@cls
mount > mounts.txt
prep
start

The third and last is a batch.txt file where you'll include the mounting commands (and any other commands you need to execute). If you've written any batch scripts before, you'll remember that variables are substituted into commands by using %variablename%.

What my tool does is create a start.bat, setting four variables there: absolutepath, mountpath, dosboxpath and dosboxdrive and then appending the contents of batch.txt

%absolutepath% is the absolute path on the host system to the current directory in DOSBox.
%mountpath% is the path on the host system to the directory mounted as the current drive in DOSBox.
%dosboxpath% is the path to the current directory in DOSBox from the root of the current drive.
%dosboxdrive% is the letter of the current drive in DOSBox.

So let's say for an example that the tool generated these variable assignments:
Code:

SET absolutepath=c:\games\dosgames\WAR2
SET mountpath=c:\games\dosgames
SET dosboxpath=\WAR2
SET dosboxdrive=C

And appended this batch script:
The rest of the script

Now what will happen in the example is that depending on the user's choice, either the \TOD or \DP subdirectory of the current DOSBox directory will be mounted as the cdrom drive d, no matter how the current directory is named or what is its' path.

Japo 06-04-2012 10:20 PM

Nice. I didn't even know you could get that information from running mount without parameters.


The current time is 11:24 AM (GMT)

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.