Open744 Simulator

Open744 project description

The text below was submitted to SourceForge in September 2006 upon registration of the Open744 project. Certain details in the implementation may have changed in the course of the project.

Introduction

The Aerowinx Precision Simulator (http://aerowinx.com), popularly known as "PS1", is a Computer Based Training tool for the Boeing 747-400 aircraft, with a user base of both professional flight training schools as well as serious amateurs. The sim is widely regarded as unsurpassed in its accuracy of systems and flight dynamics modelling. The last version, 1.3A, was released in July 2001. The author has publicly stated that he has stopped all development of the program, and all remaining stocks are being sold at reduced prices. Support is still being provided by keen amateurs at http://744.hoppie.nl; many add-on software packages also exist and are actively being developed.

Limitations

PS1 is strictly a 16-bit real-mode application written for the DOS environment in Turbo Pascal. There is support for EMS (Expanded Memory System) but absolutely no awareness of 32-bit x86 protected-mode technology, nor of any version of Microsoft Windows (tm). Hardware I/O is performed via BIOS calls or direct hardware port access; as such, supported devices are the keyboard, mouse, VGA, and game port joysticks. The Sound Blaster 16 series of sound cards are supported. There is no recognition of USB devices. There is completely no awareness of networking in the sim.

With the advent of Windows 2000 and XP, many users began finding difficulty running the sim, due to diminishing support of DOS programs and direct hardware access in these platforms. As development of the sim has completely ceased, it is rapidly attaining 'abandonware' status.

Current Trends

Since 1999, user-contributed software has been developed to workaround some of the above limitations. Networking support has been added, and in cooperation with other network applications, users are now able to fly the sim alongside other virtual pilots on the Internet, on networks such as VATSIM (Virtual Air Traffic Simulation, http://www.vatsim.net), providing air traffic control and live weather injection. Support for USB input devices (flight yokes, rudder pedals, integrated virtual cockpit controllers, etc) has been developed using a wrapper program running within the NT Virtual Dos Machine (NTVDM).

There is growing interest among the community in use of the sim under Linux (and similar OSes). Although DOS emulators already exist (DOSemu, DOSbox http://dosbox.sourceforge.net) they circumvent the hacks used by the user-contributed add-on software, effectively relegating PS1 back to its early, network-unaware days.

Goals

The Open744 project aims to be a portable wrapper, running on Win32, Linux and FreeBSD platforms, that allows execution of the original PS1 binaries, and provide advanced support of input devices, audio and networking.

Approach

Open744 runs PS1 in 16-bit protected mode. It provides handlers that correspond to original Pascal library code for device I/O, graphics (BGI Borland Graphical Interface), and floating point operations. It also handles requests for audio operations. The portable multimedia library used for the user interface is SDL Simple DirectMedia Library (http://libsdl.org).

Method

Open744 first forks: the parent (the 'systems engine') performs the tasks described below. The child initialises the SDL subsystems and performs user- and network-interface tasks. It maintains variables for mouse and joystick data.

PS1 binaries (the EXE and another OVR overlay file) are loaded into memory. 16-bit segments are identified, and LDT (local descriptor table) entries are allocated from the OS. Relocation of segment selectors is then performed, with reference to the relocation data in the EXE header and appended to each OVR segment.

Because PS1 was compiled with floating point emulation, these pseudo-opcodes need to be converted to x86 floating point opcodes. This is done for every procedure in all segments.

Pascal standard library calls made use of by PS1 are to be redirected to Open744 handlers, which perform the necessary tasks of device I/O, graphical operations, etc. In some cases (string manipulation), the native subroutines can be used, provided no 'segment arithmetic' is involved. Each Open744 handler consists of a small stub ('thunk') that manages 16- and 32-bit stacks, and copies arguments from the PS1 stack to the Open744 stack.

PS1 is started by jumping into the entry-point, which also switches the CPU into 16-bit mode. Thereafter, near calls (within the same segment) and far calls to another 16-bit segment proceed natively. Execution returns to Open744 when a thunk makes a far call, with arguments on the stack, to the Open744 code segment. Control is returned to PS1 by a reverse sequence, using far returns.

Communication between parent and child processes of Open744 uses a UNIX-domain socketpair and mmap'd shared memory, both of which are created before the fork. The parent sends BGI commands to the child through the socketpair; this is efficient and also ensures the graphics do not lag too far behind the systems engine. The shared memory area is used by the child process to send the systems engine data like hardware keycodes, logical keypush commands (these are commands for which no hardware keycode exists; they are handled in the systems engine by a hack), mouse and joystick status, and network air traffic information.

(On the Win32 platform, the parent process runs as a 32-bit DPMI application within NTVDM, while the child process is a Win32-native application. The 'child' is invoked by the 'parent' from the same binary executable file but with a commandline argument. Communication between the two processes uses shared memory and mutexes. Writing a NTVDM Virtual Device Driver is probably unavoidable.)


Contact the author: Ivan Ngeow <rimb1991(at)yahoo(dot)com>.