Jump to content

Java & Python in DOSBox


3371-Alpha

Recommended Posts

Anyone know where you can get a version of those two runtimes for DOS(Box)? Some mods require Java & Python & I'm running the DOS version of Enemy Unknown which sort of inhibits me from using them. Although I could run some of those mods externally outside DOSBox, for the sake of convenience I'd like to run it within DOSBox in sync with the game.

 

EDIT: I've currently found a runtime for Java in DOS called LeDos and another for Python called PythonD (NOTE: PythonD requires a DPMI host, such as CWSDPMI, install it by copying the CWSDPMI.EXE into the bin\python folder). There's a problem with both runtimes however. First, LeDos can only run java source files (.java files) & class files which inhibits It from being useful for mods that use jar files, such as BB's Toolkit. PythonD has a similar issue. I'm attempting to run the very obscure Python based Base Fixer patch, but It always seems to fail. One theory I have for it's failure is that it requires Python 2.5. The readme for Base Fixer seems to reference Python 2.5 while PythonD is based on 2.4. Perhaps they're incompatible. Any thoughts?

 

EDIT (again): I seem to have solved the Python issue. All I needed to do is setup the Autoexec arguments in DOSBox's settings (config file). To do so just add the following:

SET PYTHONCASEOK=1
SET PYTHONHOME=c:/PythonD
SET PYTHONDIR=c:\Python
PATH c:\PythonD\bin\python\;%PATH%

Note: the above autoexec lines assume PythonD has been installed in a virtual drive C and that it has been configured to automatically mount on DOSBox's startup. If you use the DOSBox based Boxer Emulator (Mac Only) then you don't need to worry about configuring your drives to automatically mount as it automatically records your last mounted drives as well as their drive letters.

The first line tells PythonD to ignore case sensitivity and long file name support (this variable isn't needed if you have a LFN Driver, I was unable to make one run under DOSBox so I added the variable instead).

The second line tells DOSBox the location of your python installation. This is the folder that contains the "bin", "lib" & "site_python" sub-folders. CADDIT recommends calling the folder "PythonD". Renaming it shouldn't do any harm, just as long as its path is defined in the Autoexec. Be sure to use the UNIX-style forward slash when typing the directory segments instead of the DOS/Windows style backslash, otherwise it wont be detected.

The third line adds a DOS Prefix for convenience.

The last line adds the PythonD executable to the PATH. This will enable you to use PythonD as if it were a built-in, default dos command (i.e. without having to change directories to execute it).

Additional autoexec variables (that we don't really need for Basefixer) can be found on the PythonD download page.

 

If you can't make a LFN Driver work (as mentioned above), then you should edit BaseFixer.py and replace the line

backupfilename=filename + '.bak'

with

backupfilename=gamepath + gamedir + '/base.bak'

This will patch Base Fixer's builtin backup process to make it use only one extension (it normally calls the file "base.dat.bak") as non-LFN enabled DOS freaks out otherwise. You can change the "base.bak" part of the code to change the name the backup file is saved as. The name cannot be more then 8 characters in length (excluding the file extension) otherwise DOSBox will return a "Unknown command or file name" error. Speaking of which, you may also want to rename the BaseFixer.bat & .py files (I called mine "BF.py" & "BF.bat") and edit xcuhook4 & BaseFixer.bat(BF.bat) to reference said new names.

UPDATE: Thanks to BB, there is now a working addon file to allow BaseFixer to run with xcomutil 9.7. Just paste this into Notepad/TextEdit, edit line 43 to reference the new names and save as a bat file.

 

Even after Successfully making Base Fixer run, I still do seem to have recovered another (possible) error from PythonD. After running BaseFixer, the output states "Running under 8.3 DOS. rlcompleter not available". I do not know if this has a genuine impact on anything as it seems to work fine otherwise.

As for LeDos, I think it's safe to say it's doomed to fail as implementing jar support would require modification of the source code, which is far beyond my current skill level.

 

Considering no one has commented to this thread, I'm just going to leave this content here in case someone else is in a situation similar to the one I'm in (can't run the Windows version of X-COM, mods requiring Windows, the WINE compatibility layer or even the Windows OS it's self, due to the fact that you're using a non-x86 based platform, there by forcing you to use DOS emulation as your only means to play the game series), or you have no interest in playing X-COM (or video gaming in general) but simply want a way to run Python applets in DOSBox and merely stumbled upon this thread on google or something.

 

UPDATE: TFTD Support (experimental)

Normally BaseFixer wont work on TFTD due to it using a different format for BASE.DAT, luckily they're similar enough that editing a few offsets listed in the script will make it work.

 

First find the following line:

offset = thisbase * 292

Replace the 292 with 296. Next, find the following few lines:

detshortoff=offset+16
detlongoff=offset+18
dethyperoff=offset+20

They should be right next to each other. Replace 16 with 212, 18 with 214 and 20 with 216.

Now go to the lines

facaddr = offset+22+(slot)

and

completionoff = offset+22+(slot)+36

Replace the 22(s) with 218.

 

Now unfortunately the TFTD BASE.DAT isn't just in a different format, it's slightly larger too. Browse the whole script and every 2336 (which represents the size the the BASE.DAT file) needs to be replaced with 2368. There are several but afterwards the script should work.

 

It may be worth noting that the script will still use UFO Defense/Enemy Unknown terms instead of their TFTD equivalents. To iron this out simply browse the script for lines that begin with the word print. These are the lines that display output text on screen when the script is run. Replace the words Radar with Sonar, Hyper-Wave Decoder with Transmission Resolver and plain old hyperwave with magnetic. You could also optionally replace Dirt with Sea Water or Sand, however given that we don't even know how deep X-COM bases were located in the seas I'll leave you to decide which to use, if any. That should do it.

 

Special thanks to NFK and UFOPaedia's BASE.DAT pages, it would have been impossible without you!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...