Victor R. Volkman received a BS in Computer Science from Michigan Technological University, He has been a frequent contributor to C/C++ Users Journal since 1987. He is currently employed as Senior Analyst at H.C.I.A. of Ann Arbor, Michigan. He can be reached by dial-in at the HAL 9000 BBS (313) 663-4173 or by Usenet mail to sysop@hal9k.com.
New Acquisitions
- MultiJoy (CUG #427): software and schematics to interface six digital joysticks on one parallel port. Includes source in C and Pascal.
- Pictor (CUG #428): text-mode video library for C programmers that includes windowing, GUI, hypertext help, and much more.
- Chess for C++, Fastclok, and KBFake (CUG #429): a simple chess program in C++, accelerated clock in interrupts, and serial port redirection in three separate archives.
CUG 427: Multiple Joystick Interface
Christof Ruch (Clausthal, Germany) submits the Multi Joystick Interface package. This package makes it possible to connect up to six digital joysticks (Atari type) to the parallel port of your PC. For test (or two-player gaming) purposes, the keyboard can emulate two joysticks, so you can try out the games before you actually decide to build an interface. This archive includes instructions for building the interface, test programs for checking your interface, and Pascal and C interface routines. Several arcade type games are already publicly available for this system, though none are included with the CUG archive.As you may recall, the original IBM PC offered analog joystick ports on an optional interface card (see Bibliography). This joystick adapter had a fixed I/O address and could support only two joysticks on the PC. Furthermore, polling analog joysticks required a considerable amount of wall-clock time because you had to wait for the Resistance/Capacitance (R/C) circuit to dissipate after each poll. The older digital joysticks offer less resolution (only 8 possible direction indicators), but can be read with greater speed and precision. The Multi Joystick Interface works with digital joysticks only.
The C version of Multi Joystick Interface works specifically with Borland C++ 3.1. The Pascal version works with Borland Turbo Pascal. The code should be portable to other platforms and only uses a few lines of inline assembler code.
Please note that the construction of the hardware interface requires you to etch your own printed circuit board (PCB). Fortunately, this archive includes a PCB layout in PostScript, HP PCL, and PCX file formats. And, of course, you'll need to do some soldering to pull it all together. The interface does require power which can be supplied from your spare analog joystick port (+5VDC, GND) or from an inexpensive wall-type transformer. Ruch estimates the total cost of hardware to be about $30. Hardware construction instructions appear in both English and German languages.
The Multi Joystick Interface hardware documentation and software development kit are not public domain, but are copyrighted by Christof and Henning Ruch. However, the software is free as is the accompanying information. You may use it for whatever you wish, even using it to write public domain, freeware, shareware, and commercial software. You may not however redistribute modified versions of the source code, the executables, and the documentation files. The Multi Joystick Interface version 1.1 (as released on 03/24/94) is immediately available as CUG #427.
CUG 428: PICTOR Text-Mode Video Library
Jonathan Wood (Irvine, CA) contributes the PICTOR text-mode video library. PICTOR is a C-callable library for MS-DOS development that provides multipane stacked windows, pulldown menus, and hypertext help. PICTOR is more than just video: it also includes interrupt-driven serial communications, CTRL-C and critical error handler, on-screen clock, text compression, and even a sample text editor.The library provides many high-level routines, most of which are easily used with just one or two function calls. For example, the Ctrl-C, Ctrl-Break, and critical error handlers will all install (and uninstall automatically) with a single function call. The library also provides many low-level functions that provide support for custom routines that you create.
This package includes two sets of libraries: one for Microsoft C 7.0 and another for Borland C 3.0. Wherever practical, the library routines are ANSI C compatible; therefore, the library will link with programs compiled with C compilers from most other vendors with little or no modifications.
You may incorporate any of the copyrighted object code in executable form into your own programs, and you may use and distribute these programs royalty free, provided you include a copyright notice and that your product is substantially different than the library itself. Full licensing information is included with the archive. The PICTOR video library version 1.51 (as released on 03/15/94) is immediately available as the two-disk set CUG #428.
CUG 429: Chess for C++, Fastclok, and KBFake
This volume combines three relatively small but powerful archives on a single diskette. Walter Karas (Cary, NC) submits C++ source code for a simple MS-DOS chess game. Astute CUJ readers will remember that Walter Karas also contributed the SORTLIST AVL algorithms last year on CUG #395. Russell Taylor (University of North Carlina at Chapel Hill) contributes archives for redirecting serial I/O and accelerating the PC hardware clock.
CUG 429A: Chess for C++
The Chess for C++ game is very flexible in configuring both human and computer opponents. You can select either human or computer for both black and white playing sides. Thus, you can start a game with zero, one, or two human players. You can assign one of three skill levels to each computer opponent. The number of moves of look-ahead is two for skill level 1, three for skill level 2, and four for skill level 3.The program display is plain ASCII text, so it takes some getting used to (a white pawn appears as "PW," for example). But this simple display should make Chess for C++ somewhat easy to port to other platforms. An interested CUJ reader may wish improve on the interface with bitmap graphics of the chess pieces.
Chess for C++ is provided in source code format only so you must have a C++ compiler installed to use it. Chess for C++ version 1.2 (as released on 05/04/94) can be found on volume CUG #429.
CUG 429B: Fastclok and KBFake
Fastclok implements a more precise time than that provided by DOS. Specifically, it provides functions to increase the clock rate to around 1165 interrupts per second. This yields a granularity of 858 microseconds between clock pulses rather than the 55 milliseconds between normal PC clock pulses (18.2 times/second).Under the influence of Fastclok, the gettimeofday routine acts like the UNIX version, with the exception that time zone does not matter. gettimeofday returns the time in timeval structures that match their UNIX counterparts.
Programs must call the start_fasttimer routine before the gettimeofday routines will work. Likewise, a program must call the stop_fasttimer routine before the program terminates or a crash will result. For this reason, start_fasttimer installs the stop_fasttimer routine to be called at program exit.
Fastclok is implemented entirely in C with the exception of inline assembly language to execute the CLear Interrupt enable (CLI) and Set InTerrupt enable (STI) instructions. Only source code is provided for these routines so you must have a C compiler available to use them.
KBFake is a Terminate and Stay Resident (TSR) program that redirects the input from one of the serial lines so that incoming characters appear to have been typed on the keyboard. KBFake works by installing an interrupt handler for the serial port that is to be used. This handler inserts the characters coming in over the serial line into the keyboard buffer using the BIOS keyboard write call.
The code for this program is a mixture of the example for the keep function call in Borland C and various programming examples from the SIMTEL internet FTP site. The keep function call does not have a direct replacement in Microsoft C/C++.
This is an interrupt service routine. Accordingly, you must compile it with Test Stack Overflow disabled to get an executable file that will operate correctly. The CUG distribution of KBFake includes both C source and an MS-DOS executable.
Bibliography
Volkman, Victor R. "Complete Joystick Interface." The C Gazette, Vol. 5, No. 1, Autumn 1990. pp 8-21.