Wolfenstein 3D for DOS/4GW!

After reading about the Blake Stone compile fixes, as it was a Wolf3d port, I came across a post on the forum Wolf3d Haven about trying to find the source code to something called wolf4gw.  Now wolf4gw is a port of the Borland C source of Wolfenstein 3d to Open Watcom C++‘s 32bit MS-DOS extender DOS/4GW, done by ‘ripper’.

The project eventually gave way to wolf4sdl, and as they say the rest is history.

Sadly it seems that just about all the source copies of wolf4gw were lost, except I did manage to find an ‘improved’ version simply refered to as wolf3dx.  From the blurb:

Tricob has released the Wolf4GW-based source code of WolfDX. Included is a text file called (Tricob).TXT.

So I have been using Watcom 10.0 for Duke Nukem 3d, however, this version relies on the _asm inline assembler which was introduced in Watcom 11.  However Watcom 11c had issues with some of the assembly forcing me to go even further to OpenWatcom 1.3.  For me the install was easy, I used CrossOver to install OpenWatcom for DOS-DOS32bit only, copied the compiler into DOSBox, and played mostly with the makefiles, and finally got a working exe!

Screen Shot 2013-07-12 at 11.57.24 AM Screen Shot 2013-07-12 at 11.58.00 AM

I know it may not look like much, but really it is running in 32bit protected mode!

Since all of this is open/freeware/shareware I can redistribute OpenWatcom, the source to wolf3dx, and the shareware levels of Wolfenstein.  Naturally I’m using DOSBox to compile and test, but you can use anything that can run MS-DOS 32bit stuff.

Download my archive here.

DJGPP 1.03 saved thanks to shovelware + cd.textfiles.com

I can’t stress enough just how awesome cd.textfiles.com is for finding ancient stuff!

I’m not sure why I started on this quest but I was looking for some old finicky DOS extender, and started hunting for Go32, the first DOS extender used by DJGPP.  And for the heck of it, I wanted to find the first version, which I pretty much had assumed was lost to the mists of time.

However the CD-ROM shareware collection called MegaROM-1 actually had a ‘full’ copy of one of the first versions of DJGPP, 1.03.

Installation is pretty straightforward, however you have to use pkunzip for all the various old ‘methods’ of storing data in zip files, I found infozip leaves things out..

Also DJGPP 1.03 uses a LOT of environment space.. which is more so a problem for people running real MS-DOS on real machines.. (there are some!)…

Hello World!

It runs in DOSBox, but there is no doubt some stack corruption as trying to run things like dos edit result in:

Packed file is corrupt

But at least we can run more than one copy, or use a native editor.

GO-32 from this era is *NOT* DPMI compliant, nor is it VCPI compliant.  And its based on GCC 1.39, which was a popular level with things like 386 BSD, although it seems early Linux used GCC 1.40 ..  The tool chain by default outputs the GNU a.out format, but relies on modifying the linker that was separately included in G++.  Later versions of GO32 included VCPI support, and near it’s end of life version 1.10 added support for DPMI which greatly simplified things like hooking IRQ’s and doing DMA.

For those who want to play, without the pkzip fun, I’ve slapped it into a single 7zip file.  It’s not even a megabyte.  But it was 1991, when 4MB of ram seemed like an incredible amount of memory!

Quake & QuakeWorld for MS-DOS update

So after a year+ of inactivity I’ve spent some time with Quake (netquake) and QuakeWorld for MS-DOS.  I had modified it to support the WatTCP stack for MS-DOS, allowing you to play over the internet with any MS-DOS PC with a packet driver.

After a good bit of prodding and playing with DJGPP I’ve updated everything to include some new tweaks for a malloc ‘bug’ (Quake assumes the memory is clean, which under DJGPP it isn’t) some limit increases (zone to 1MB, and increases in max edicts, models & sounds), and forcing the sound to 22050Hz.  The source code is now here.  As much as it pained me, I built it with this DJGPP under MS-DOS (On Qemu) and I’m keeping it here, as gcc 3 & 4 are incapable of building a working WatTCP or Quake.

Another big fix for QuakeWorld is that it now can run in 640×480, 800×600, and even 1024×768 if your video card is VESA 2.0 compatible!!!

Basically you can just replace the default exe’s in a Quake1 install and go from there.  If you do not have quake at all, you can always look for the shareware version.  QuakeWorld will require the commercial version for what it is worth. I’ve found it runs best with 32MB of ram.  I don’t know if that is even an issue in this day & age.  Quake1 will run in 16, but I have a feeling QuakeWorld runs in VM (thanks to CWSDPMI) and it does say it is using 32MB … Because I clear the ‘zone’ before Quake runs there may be a 30 second to 1 minute pause.  This is to be expected, just hold tight.

QuakeWorld at 640x480

QuakeWorld at 800x600

QuakeWorld at 1024x768

You can download either Quake.exe or Qw.exe.

Thanks to [hci]maraakate, for the hints on what to update where, and of course the testing on a ‘real pc’!`

Some history on DPMI

This is taken from a post by Michael Sokolov (of Quasijarus fame), all about DPMI.

   Mark H. Wood <address@hidden> wrote:
> Which spec is that? cwsdpmi, as I recall, implements DPMI 1.0, while
> Microsoft has never gone beyond 0.9. There are significant differences
> *in the spec.s*.

   Well, I have turned this semester's last paper in today, so I can spend
a few more hours enlightening the public... Warning: I am going to give a
lecture on DPMI. Feel free to skip this message, but if you do please
refrain from any further participation in the work on Lynx for DOS, since
an understanding of the material I present in this lecture is absolutely
essential to doing any work under DOS beyond 640 KB.

   DPMI has been born in the fall of 1989 in a bright flash of genius of
Microsoft's Ralph Lipe. At that time there was a flourishing DOS extender
industry led by Phar Lap, Rational Systems (later Tenberry Software), and
Ergo (formerly Eclipse and A. I. Architects). A DOS extender is some kind
of software solution (they come in all sorts of flavors) that allows an
application to execute in protected mode and yet retain access to the file
system and other services provided by DOS via an API that closely resembles
that of real-mode DOS (INT 21h and such) but with pointers to buffers and
such addressing memory outside the first MB via protected-mode selectors.

   DOS extenders from Phar Lap, Rational Systems, and Ergo are inherently
flawed in that they are built into apps. This has been done against all
rationale simply because the market demanded that a protected-mode apps
must not have any prerequisites and must run even in a bare environment
without any pre-existing protected-mode software. However, having a
separate DOS extender for every app is not much different from having a
separate power plant for every light bulb. Since they want to have no
prerequisites, these DOS extenders need to take the total control of the
CPU and build their own protected-mode environments. Of course, this
creates a hell of a problem when a machine IS running some protected-mode
software. In the days of Phar Lap and friends, there were two other kinds
of the latter in addition to DOS extenders: LIMulators and multitaskers.
The former are things like CEMM and EMM386 that provide LIM EMS services by
setting up a protected-mode environment and mapping some extended memory
into the UMB space. The latter provide multiple simultaneous DOS sessions
and allow the user to switch between them instantly. They do so again by
setting up a protected-mode environment and using to it manage several
different VMs. The result was that by 1989 there were three kinds of
protected-mode environments (LIMulators, multitaskers, and DOS extenders),
and all three were, oh big surprise, for the most part mutually exclusive.
There were some feeble attempts (VCPI being the primary example) to make
them live together, but they worked by making one environment totally yield
to the other, which is unacceptable for many reasons.

   Microsoft has entered the protected-mode-under-DOS field in the summer
of 1988 when Murray Sargent and David Weise wrote a DOS extender for a big
DOS app called Windows. Until then this app was running in pure real mode
and was limited by the (in)famous 640 KB barrier. Jumping over this barrier
was one of the primary goals for Windows v3.00. Murray Sargent's DOS
extender did this. It was a quick-and-dirty single-app DOS extender just
like the ones from Phar Lap and others. There was a problem, however. When
all this was happening in the summer of 1988, there already was a baby
called Windows/386 v2.xx. It was another protected-mode environment
developed independently by Ralph Lipe in 1987. It was not a DOS extender,
but a multitasker, and its purpose was to manage several independent VMs,
one running Windows and all others being DOS boxes. Although there were
several VMs, each was running in V86 (real-like) mode only, and no VM had
any ability to jump over the 640 KB barrier, even though each VM had its
own 640 KB of memory.

   Windows v3.00 was supposed to include both Windows/386 (so that it could
have the familiar DOS boxes) and Murray Sargent's DOS extender. There was a
problem, however. The two were mutually exclusive! It was exactly the same
eternal conflict between LIMulators, multitaskers, and DOS extenders that
the industry had been wrestling with for a couple of years by then, except
that the conflicting parties were parts of the same product! Clearly a
breath of fresh air was needed. And it came. From no one but Ralph Lipe,
the author of Windows/386. In a bright flash of genius, he realized that
building a separate DOS extender into every app, be it AutoCAD, Lotus
1-2-3, or Windows, is just as ridiculous as building a separate power plant
for every light bulb. However, getting rid of this kludge required adopting
a new industry standard. Just like in order to have the same power plant
serve everyone you have to agree upon a common standard on voltage,
waveform, and power factor, if you are going to have common protected-mode
DOS services for all apps you have to agree on the protected-mode DOS API.
A logical name for the generic API to the protected-mode DOS was DOS
Protected Mode Interface (DPMI), and it is the name that has ended up being
chosen.

   The specs published by the DPMI Committee and distributed by Intel only
vaguely resemble Ralph Lipe's DPMI. The INT 31h API they describe is only
the low-level building-block portion of Ralph Lipe's DPMI. Its high-level
portion is nothing less than a functional specification for Protected Mode
DOS (hence the name). It allows one to develop an add-on to DOS or even a
new version of DOS that would have a protected-mode API directly usable by
protected-mode DOS apps without the need for separate built-in DOS
extenders. Understandably this troubled Phar Lap and others a lot, since
Ralph Lipe's DPMI makes their products unnecessary. This is the setting in
which the most unfortunate event in the history of DOS has happened. Being
too used to Microsoft's evils, the industry had failed to think the problem
through and sided against Ralph Lipe. Before I continue any further, let me
make an analogy. Suppose a group of doctors were able to cure some dreadful
disease against which there were no vaccine and to which everyone were
prone. Suppose that they charged a lot of money for curing this disease and
made a good living on it. Then suppose that some guy came up with a vaccine
that once injected totally eliminated the possibility of getting this
disease. The vaccine would solve a major health problem, but it would also
push the doctors making great money on curing the disease out of business.
What do you think is more important, sparing millions of people of a major
health problem or keeping a group of lucky doctors in business?

   Unfortunately, the industry has chosen the latter. Ralph Lipe agreed not
to publicize his version of the DPMI spec and to create the so-called DPMI
Committee to write a "public" version of the spec that would please Phar
Lap and the rest of the gang. This Committee was practically headed by Bob
Moote, the vice-president and co-founder of Phar Lap and the author of
their 386|DOS Extender. It has prepared a castrated (deprived of the most
essential component) version of DPMI and released it under the name "DPMI
Version 0.9". It essentially comprises the low-level building-block portion
of True (Ralph Lipe's) DPMI. Fortunately, no committee in the world could
prevent Ralph Lipe from doing the right thing, and the Win386 component in
Windows v3.00+ implements the full True DPMI spec. As a result, DOS apps
running under its supervision (e.g., Windows itself) have immediate access
to Protected Mode DOS without built-in DOS extenders. Since this is the new
proper and vastly improved way of writing protected-mode DOS apps (sure
enough, Microsoft itself has used it in its C/C++ Compiler v7.00), Win386
rightfully does not support apps with built-in DOS extenders using kludges
like VCPI. Thus Bob Moote and his gang have made their version of DPMI a
subset of True DPMI rather than a completely different interface, so that
their DOS extenders could run under Win386.

   It is a very unfortunate fact that since Ralph Lipe has agreed not to
send out copies of his True DPMI spec most people associate the name DPMI
with Bob Moote's "Committee". There were, however, a few copies of the True
DPMI spec sent out to people like Borland. It is interesting to note that
the latter company has chosen True DPMI over Bob Moote's creature for their
protected-mode DOS tools. 16-bit Borland C and Pascal compilers are
targeted for the DOS/protected-mode-DOS/Windows triple, and the protected-
mode DOS versions of the tools use nothing but True DPMI. Also Borland
includes a True DPMI implementation of its own with these compilers. Given
that copies of the True DPMI spec are out there, I'm searching for them
much like Agent Mulder is searching for the truth about extraterrestrial
life and intelligence. Fortunately Bob Moote's "Committee" has never made
DPMI a trademark and Ralph Lipe's spec has never got Microsoft's copyright
stamped on it (it was just a rough dev draft quickly typed up in WinWord,
after all), meaning that if/when I find a copy of it I can immediately put
it up on my FTP site.

   Now you may ask "what is DPMI Version 1.0 then?" As I have said before,
Ralph Lipe and Bob Moote had radically different visions of DPMI, the
former seeking an interface between protected-mode DOS and its apps and the
latter seeking an interface for use by Phar Lap's DOS extenders. "DPMI
Version 0.9" has been produced perhaps in an hour by ripping out Ralph
Lipe's high-level APIs, but there are still references to it dangling
around, making it clear to anyone reading the spec that something is
obviously missing. Being dissatisfied with the fact that his ugly "DPMI
Version 0.9" still contained hints toward its original purpose and didn't
completely subvert to his ideology, he set out to write a spec that would
not contain a single word by Ralph Lipe and instead would be geared fully
toward Phar Lap's DOS extenders. The result is commonly known as "DPMI
Version 1.0". I still wonder why did Bob waste his time on writing it, as
it was clear even to a porcupine that it would never be implemented, since
its alleged purpose was light years apart from the real purpose of DPMI
(which started being accepted by the industry, partly because Microsoft and
Borland compilers used it). It is a grave mistake to treat "DPMI Version
1.0" as an improvement upon "DPMI Version 0.9", it is merely a further move
away from True DPMI.

   A very unfortunate fact is that DJGPP and CWSDPMI have chosen to use Bob
Moote's lopsided idea of DPMI instead of its true nature. Certainly this is
due to DJ Delorie simply not knowing about the existence of True DPMI,
which in turn is certainly due to the scarcity of the copies of the True
DPMI spec. It is still a pity, though, that DJGPP uses only the low-level
building-block APIs that are suitable to Bob Moote's selfish interests and
builds a separate power plant for every light bulb (i.e., builds the DOS
API translation engine into every app by making it a part of the
statically-linked libc.a).

   The conclusion of this lecture is that I need to continue searching for
the truth that is out there, so that I could finally bring it to light
after all these years (True DPMI: 1989, "DPMI Version 0.9": 1990, "DPMI
Version 1.0": 1991). This would mean finding a copy of the True DPMI spec,
putting it up on my FTP site, and writing a software development suite that
would produce apps for it, as well as writing a public-domain
implementation of it (to my knowledge all existing ones are commercial,
except possibly the DOS emulation under Linux).

   A billion thanks for reading! If you read up to here, please drop me a
note :-).

> Stuff compiled with DJGPP works just fine for me on Win95 [...]

   OK, so DJGPP is at least correct after all, although severely misguided
because of the lack of knowledge.

> [...] which is (among
> other things) a DPMI provider and certainly written by Microsoft.

   The Protected Mode DOS component of Windows 95 is virtually identical to
that of Windows v3.00 and v3.1x. In all of them it is written by Ralph Lipe
and is the reference implementation of True DPMI.

> The same stuff also seems just fine using cwsdpmi.

   OTOH, when I tried running a True DPMI client under CWSDPMI, it sent
about 2 KB of binary garbage to stdout and exited. Note that this client
does check for BobMootish DPMI hosts that implement only the low-level
building-block API and prints an appropriate error message if one is found,
so what I have seen indicates that CWSDPMI's implementation of the low-
level building-block API is also screwed. Well, it should be no surprise
for anyone that CWSDPMI is a specialized gadget for DJGPP and doesn't even
resemble True DPMI. If you want the latter without running Windows, your
current choices are (to my knowledge) 386Max and QEMM-386 with QDPMI. There
also is the Borland DPMI host, but it's 16-bit only. Oh, and OS/2, Windows
NT, and Novell DOS all implement True DPMI.

   Sincerely,
   Michael Sokolov
   Phone: 440-449-0299
   ARPA Internet SMTP mail: address@hidden

   P.S. It is really swinish for me to be bashing Bob Moote, since he has
once done me a significant personal favor, but I simply can't put my
personal interests and obligations above my duty to the industry.

   P.P.S. A lot of my knowledge of this subject has been derived from
direct phone conversations with the key players in this field, including
Murray Sargent, Ralph Lipe, Bob Moote, and Dan Spear (author of QEMM-386
and QDPMI).

jDosBox

So while looking for some Win32s nonsense, I stumbled onto RGB Classic Games, and they have this interesting thing to run dos games online. A quick glimmer of the DOSBox logo flashes by.. So I fire up doom and quickly exit and…

Yes it’s DOSBox.

But in my browser.. A little tearing it apart, and it’s actually a port of DOSBox to JAVA!

Seeing it can run 80386 code, namely DOS4G/W, I figured it’d be interesting to see how it’d handle Microsoft PowerStation Fortran & PharLap TNT.

You can try it if you feel inclined here.

It’s been a boring day

My package from Germany finally arrived…!

And it contains Phar Lap 386 versions 4.1 and 5.0!

But something arrived in the mail. So I spent 2 hours cleaning things up and fighting with Watcom getting a skeleton verison of Doom to build. It’s finally running. Now to do some keyboard/video stuff.

Maybe more later though. But I may have to bench them some how Dos4G/W vs Phar Lap 386…. I donno.

Aeon

I came across this 386 emulator, Aeon(updated to use archive.org, as it’s dead now). What is interesting is that it’s written in C#!

That’s right it’s all managed code…!

If you can run .net 4.0 you may want to check it out, it’s quite capable….

Doom on AeonYes it can run doom!

The DPMI is good enough to run doom, and quake! While slower then DosBOX, I’d still say it’s a contender, you can never have too many possibilities…

DBASE III and friends.

Do you remember the ‘dot’ prompt?

Dbase III

Dbase III

I’m sure most people have never heard, or seen the thing. But this was the wonderful world of dBase, a simple to use database utility that set the world on fire back in the CP/M, MS-DOS days. The cool thing about dBase was that you could program it, and the syntax was very easy to pick up, compared to SQL. And you could save your scripts into these .PRG files which were human readable, and quite capable of doing all kinds of fun things.

As people’s level of complexity grew with dBase, people started to deploy it as an application, which in this day in age isn’t that unheard of, it happens today in the form of the Access 2007 runtime. However back then, the big deal was taking your .PRG script files for dBase, and compiling them with a 3rd party compiler. For some reason the people behind dBase were slow to the market, so Nantucket Corporation, arrived with Clipper, a superset of the dBase language, that could translate the dBase scripts into code for a p-code interpreter (it’s the same thing as a virtual machine, like Sun’s java, or z-machine from Infocom). Naturally once you compiled your .PRG file, it could still access the same database files, that you had created in dBase III, or you could even create your own on the fly within the .PRG file.

Now what’s really cool about Clipper is that, not only could it compile the dBase PRG files, but you could also link in code from MASM (The Microsoft Assembler), and Microsoft C (Other C compilers can work too, but MS C works best, as Clipper seems to have been written in MSC.). So you can be free to write all kinds of strange and interesting things. So far I’ve only written a few things to call the video bios from Microsoft C.

So as a very basic example of this, let’s make a simple .PRG file.. I’m going to name this HI.PRG, and I’m going to call a function hic from the dBase script.

HI.PRG

? “Hello from clipper”
? “”
hic()

Now for the C program. *NOTE* that printf won’t work as the libc stdio isn’t initialized correctly.. However other stuff works fine, I’m sure there is a fix, somewhere, but I didn’t need it so it doesn’t matter. Also this program will work with both the “Summer ’87” compiler, and Clipper 5.3, however the syntax I’m going to give is specific to the Summer ’87 release.

HIC.C

#include <stdio.h>
#define CLIPPER void pascal

CLIPPER hic()
{
putch(‘a’);
}

Now we compiler & link everything like this:

clipper hi.prg -m
cl /c /FPa /AL hic.c
tlink hi.obj hic.obj clipper.lib

And this will now produce a hi.exe, that when executed will produce this output:

C:\TEMP>hi

hello from clipper
a
C:\TEMP

Ok, now this is all fun, however you’ll hit roadblocks eventually as the Summer ’87 compiler & library produces code that is meant for real mode on the 8086/8088 CPU. So if you are adding to an already ‘bloated’ 540kb program, you are going to run into trouble quickly. This is where Clipper 5.x comes into play.

Clipper 5.x introduced the ability to build & link programs for protected mode, provided you have a DOS Extender, that is tailored to Clipper. There were several available at the time, and around Clipper 5.3 they included the exospace product which was wrapped around Tenberry DOS Extender, DOS/16M.

Now you may be wondering, what is ‘real mode’, ‘protected mode’, and a ‘dos extender’, not to mention how they all interact with each other. I’ll try to explain this.

The old 8086/8088 CPU’s could address 1MB of ram on their 20bit address bus (2^20 is 1,048,576) and this memory is chopped up into 64kb segments. The IBM PC reserves the top 384kb for adapters, hardware shared memory, and the ROM BIOS, leaving 640kb for MS-DOS and your user programs. This is where that mis attributed quote 640kb ought to be enough for anyone comes from. This 8086/8088 ‘mode’ is called the ‘real’ mode.

Well remember leaving the old CP/M computers that typically had 48kb or 64kb of ram, 640kb seemed plenty at the time. Naturally it was a matter of time until people were making programs where they ran out of memory.

The solution from Intel was the 80286 processor which was fully backwards compatible with the 8088/8086, however it included a new mode of operation, protected mode, which when activated would supply a virtual address space of 1GB (1,073,741,824), and a 24bit memory bus (2^24 is 16,777,216), allowing users to access 16MB of ram.

Another big feature of protected mode, is that memory is then protected so if a program accesses memory that it shouldn’t, it’ll generate a protection fault. The 80286 also introduced TSS’s to support multitasking in hardware. The idea being with these two features a rouge program wouldn’t crash the entire OS.

Intel’s thinking was that the 8088/8086 software was a fad, and that once people saw the power of protected mode, they’d never want to leave it, so there is *NO* method for switching the 80286 back from protected mode to real mode once it’s been entered.

Naturally this would require a whole new operating system to function in protected mode, and it would be incompatible with old MS-DOS programs as they simply will not function in protected mode. IBM & Microsoft started to collaborate on this new OS, called OS/2. The biggest obstacle that faced the team was that a new operating system that didn’t support the growing ‘legacy’ base of MS-DOS applications would be doomed to fail. The IBM AT had this ‘cheat’ that while doing it’s POST in BIOS, the CPU would be switched to protected mode, to check & detect the memory. Then the instruction pointer would be saved in the start of ram, and the keyboard controller would be used to reset the CPU, allowing the BIOS to continue back in real mode. While this did work, it was far too slow for an operating system to use where you may need to switch several thousand times a second.

Gordon Letwin spent a lot of time on trying to find a way to switch the 80286 from protected mode to real mode, when he hit upon what is known as the triple fault. The idea is that you place your instruction pointer much like the keyboard controller reset method, but you then remove all ‘safety nets’ by clearing the interrupt table for the CPU, and cause it to crash by throwing an interrupt. The CPU can’t process the interrupt because the table is invalid, so it will end up doing a quick reset as the microcode assumes the processor has encountered a critical software problem.

This was a big save for OS/2 as now it could boot up into protected mode, run protected mode programs, and would allow the user to select a special ‘dos box’ that would switch the processor into real mode, and run MS-DOS programs while switching back & forth between real & protected mode to service interrupts, and allow OS/2 programs to continue to execute in the background.

However when the first version of OS/2 was released in 1988, it had a confusing topview like interface, which was full screen text, and didn’t appear to multi task as you could only work on one thing at a time.

So with that the idea of a dos extender was born.

The people behind Tenberry worked with Microsoft, and deiced that they could bring the number one benefit of protected mode, a larger address space, to MS-DOS by writing a special program, the DOS Extender. Since MS-DOS & the PC BIOS are real mode programs, and can’t function in protected mode, what Tenberry did was write a special loader that could load OS/2 programs into protected mode, but every time the program would make a MS-DOS call, the DOS Extender would intercept the call, switch the processor into real mode, make the call, then return to protected mode, and return the result to the program.

The result being that you didn’t have to install a new operating system, just rebuild your applications, link with the DOS Extender and now you could have access to 16MB of RAM!

Ok, so with that in mind, here is me rebuilding the same programs for protected mode.

C:\TEST>clipper hi.prg -m
CA-Clipper (R) 5.3
Copyright (c) 1985-1995, Computer Associates International, Inc.
Microsoft C Floating Point Support Routines
Copyright (c) Microsoft Corp 1984-1993. All Rights Reserved.
267K available
Compiling HI.PRG
Code size 61, Symbols 64, Constants 19

C:\TEST>cl /c /FPa /AL hic.c
Microsoft (R) C Optimizing Compiler Version 5.10
Copyright (c) Microsoft Corp 1984, 1985, 1986, 1987, 1988. All rights reserved.

hic.c

C:\TEST>exospace file hi.obj,hic.obj

ExoSpace for CA-Clipper 5.3
Copyright (c) 1993 – 1995 Computer Associates International Inc.

DOS/16M Copyright (c) Tenberry Software, Inc. 1987 – 1995

EX01 – General Linking Utility (for CA-Clipper ExoSpace). V2.11(w/VMM 6.01)
Copyright (c) Tenberyr Software, Inc. 1987 – 1994

Reading object files and library headers.
Processing library directories.
Extracting library objects.
Assigning selectors.
Preparing GDT image.
Writing code image to .EXP file.
Sorting 1737 relocations.
Building relocation tables.
Writing GDT image to .EXP file.

1044544 bytes used out of 44702592 bytes available.

Generating .\HI.EXE…

EXOSPACE : .\HI.EXE successfully linked

C:\TEST>

And we can now run the program!

DOS/16M Protected Mode Run-Time Version 6.01
Copyright (C) Tenberry Software Inc. 1987 – 1994

hello from clipper
a
C:\TEST>

As you can see, the only visible change to the user is the banner printed by the DOS Extender as the program executes. Now if the program makes a LOT of calls to DOS from protected mode it can get slow. It’s very noticeable say if you have a database that you read a record, parse it, then fetch another record. However if you need lots of ram you don’t have much of a choice… Not to mention that 286 DOS Extenders are limited to 16MB of Ram, very few (if any?!) support swapping, or allow programs to address the 1GB virtual address space.

The solution, again came from intel in the form of the 80386 CPU. The 386 is a superset of the 286, and like it, also supports the 286’s protected mode and the 8088/8086’s real mode. The 80386 also introduces a 32bit protected mode, v86 mode, and a method to quickly switch from protected to real mode.

So what does this mean for DOS Extenders? That a 386 DOS Extender will be significantly faster then a 286 DOS Extender. Also the v86 mode, supports virtual 8086 machines, allowing a 32bit DOS Extender to run MS-DOS in a virtual machine, and make MS-DOS & BIOS calls all from protected mode.

One great free 32bit Dos Extender for Clipper is CauseWay, which is now free!

So using the same object files generated from the DOS/16M extender, I just simply relink with CauseWay’s linker which will also link in the CauseWay extender. I’m not all that good with CauseWay’s syntax so I opted for a ‘response’ file, in the format of something exospace would use.

HI.LNK

FILE hi.obj,hic.obj
OUTPUT hi.exe
LIBRARY clipper.lib

Now running the CauseWay linker:

C:\TEST>wl32 /lc:exospace.def @hi.lnk
CauseWay WL32 for Clipper Version 1.32 Copyright 1993-1999 Michael Devore.
All rights reserved

Link of executable file successfully completed.

C:\TEST>

Then running the exe…

C:\TEST>hi

hello from clipper
a
C:\TEST>

All nice and transparent to the end user. And it feels significantly faster then the 286 extender when it comes to lots of MS-DOS transactions… I’ll have to time it, but right now you’ve only got my observation.

This post is way longer then I had originally thought so I’m going to break this up, but this blog post is an idea of what I’ll cover next time…

OS/2 1.x emulation via HXRT

I finally got this working, although I’ve got to sit down and work out the old makefile format to bind in the hxrt stub instead of running it all on the CLI…

So as a poor example, I used the ancient Fortran 5.1 to build up an OS/2 1.x VIO executable of dungeon, which would run happily on NT 3.1, but of course will not run on XP as they have removed the OS/2 subsystem.

Anyways it’s impossible to run the exe on dos, but fishing around I came across my old Visual C++ 1.5 CD, and on there was the Phar lap 286 dos extender. And one of the neat things it could do, was run simple OS/2 applications under MS-DOS!

So I bound the exe and now it’d run under MS-DOS.

phar lap 286 dungeon 2.5..6

phar lap 286 dungeon 2.5..6

However, since it’s a trial version, it’s limited to 2MB of ram, and you can’t redistribute the resulting exe. Now this is where HX DOS Extender (archive.org mirror/sourceforge mirror) comes in. Over the years, the HX dos extender has provided the functionality of the old Phar lap TNT dos extender by allowing you to run Win32 exe’s under MS-DOS, and it provides a pretty impressive subset of the Win32 api on MS-DOS.

So taking this lead, HX now has a 16 bit 286 centric version that provides a basic OS/2 emulation layer.

So by simply passing the OS/2 exe as a parameter to the DPMI loader (I haven’t quite worked out the stub syntax…) you can run the OS/2 build of dungeon under MS-DOS!

HX16 dungeon 2.5.6

HX16 dungeon 2.5.6

For anyone stuck with either legacy 16bit tools, or a need to support ancient systems, it’s certainly nicer with OS/2 as you have access to a LOT more memory! According to the documentation the HX extender should work nicely with the OpenWatcom Fortran & C, although I currently haven’t tested it.

What’s kind of interesting is that HX doesn’t work under DOSBox, while the Phar Lap 286 DOS Extender will….

Both of these dos extenders build on the old idea of the “Family API” where common API’s between OS/2 and MS-DOS could be mapped between the two OS’s, and a common “bound” executable could then run in either environment. However on the MS-DOS side, it’d be subject to the memory constraints of a realmode MS-DOS executable. The DOS extenders build on this idea, but provide access to additional memory, and a more feature rich OS/2 api.