Cyningstan DOS Games

Games for Early PCs

CGALIB 2 Game Library

All of the games on this site since Star Cadre: Combat Class are based on the CGALIB 2 game library. CGALIB 2 is a collection of libraries, including a relatively fast, specialised C graphics library, a keyboard library, and a sound library.

For graphics it targets the CGA graphics adapter, specifically the 4-colour 320x200 CGA graphics modes, although it will also emulate these modes on the 640x200 screen using dithering, for clarity on monochrome devices. For speed it organises the screen into 4x1 pixel cells, making it more suitable for turn-based games than for action games that require pixel-perfect positioning.

For keyboard I/O it targets the XT/AT keyboard with 83 or 84 keys. The extended keys on a modern keyboard are mapped onto the equivalent keys on the XT/AT keyboard, for instance, the cursor movement keys map onto the equivalent numeric keypad keys.

For sound, it targets the PC speaker, and includes features both for sound effects and for music. It achieves something resembling harmony by playing all the notes staccato, and allowing chords to be reproduced with arpeggios of rapidly played short notes.

It builds on the capabilities of the CGALIB 1 Graphics Library, the KEYLIB Keyboard Library and the SPKLIB Sound Library with the following additions:

1. It provides a back buffer for screen output, making it easy to group together screen updates and implement them all at once. In CGALIB 1 the developer had to implement their own back buffer.

2. Fonts are no longer restricted to 4x6 pixels, but can now be any size, as long as the width is divisible by 4.

3. Graphics, keyboard input and sound are now gathered into the same library, so the developer doesn't have to bring together three separate libraries for a typical game project.

4. Improved utilties are provided for production of sound effects and music, sitting alongside the bitmap and font editors adapted from CGALIB 1.

5. The syntax has changed, and now more closely resembles object-oriented practice. This is still C, though, C++ is not required.

CGALIB 1 is provided in source and binary formats for the OpenWatcom C compiler. It includes a couple of rudimentary utilities for creating bitmap and font files, and it is supplied with a sample demonstration game.

CGALIB 2 Binaries

Download: cgalib2.zip
Size 240kb, downloads 4.

This is the CGALIB 2 binary distribution. Download this if you want to create your own projects based on CGALIB 2. (read more...)

CGALIB 2 Source Code

Download: cgasrc2.zip
Size 74kb, downloads 4.

This is the source code distribution for CGALIB, useful for seeing how CGALIB works or porting it to other compilers. (read more...)

CGALIB 2 Manual

Download: cgalib-manual.pdf
Size 755kb, downloads 4.

This is the full PDF manual for CGALIB 2. It includes an introduction, references for all the different modules, and a description of the asset generation utilities. There is plenty of sample code to illustrate the use of CGALIB 2's functions. (read more...)

Related Posts

CGALIB 2: Detail from the manual cover The CGALIB bitmap editor. The CGALIB font editor The CGALIB sound effect editor The CGALIB music editor

Comments

New Comment

Yes No