Platform CPM - z88dk/z88dk GitHub Wiki

Classic library support (+cpm)

  • Native console output
  • Native console input
  • ANSI vt100 engine
  • Generic console
    • Redefinable font
    • UDG support
    • Paper colour
    • Ink colour
    • Inverse attribute
    • Bold attribute
    • Underline attribute
  • Lores graphics
  • Hires graphics
  • PSG sound
  • One bit sound
  • Inkey driver
  • Hardware joystick
  • File I/O
  • Interrupts
  • RS232

z88dk provides extra libraries for many CP/M machines that support accessing functionality such as sound, graphics etc

The new library also has a CP/M target, which can be reached by supplying -subtype=new for sccz80, or -subtype=sdcc_ix, or -subtype=sdcc_iy for sdcc compiler, respectively.

The CP/M platform is a surprisingly useful port when used in combination with ZXCC, the two together can easily test whether an algorithm works, or whether there's an issue in the compiled output code.

ZXCC is trivial to extend, and you can easily permit access to serial ports, host system calls, advanced paging techniques etc testing out many areas of your code.

Quick Start

zcc +cpm -lm -lndos -o adventure.com adv_a.c

zcc +cpm -lm -o ddir.com ddir.c

The ndos.lib library is useful to save memory when file support is not necessary.

Without specifying a -o option, a file called a.com is produced, this can be run with zxcc as follows:

zxcc a.com

By default, z88dk will generate code suitable for running on a z80 based machine, to compile for an 8080 machine add the option -clib=8080:

zcc +cpm -clib=8080 -lm -lndos -o adventure.com adv_a.c

Alternatively for an 8085 machine:

zcc +cpm -clib=8085 -lm -lndos -o adventure.com adv_a.c

Creating a disc

appmake supports creating a number of CP/M disc formats that can be used directly by emulators or easily converted using 3rd party tools. Many of these can be produced as part of the compilation step using the -subtype=XXXX -create-app options.

To create a disc image with a binary, you can use the following command:

 z88dk-appmake +cpmdisk -f [format] -b [binary file]

The file will be created on disc with a .COM extension.

The supported formats are displayed by specifying the -h option:

 z88dk-appmake +cpmdisk -h

Library Support

Besides the standard library routines, the ''bdos(int func,int arg)'' and the the ''bios(int func,int arg,int arg2)'' function calls allows direct access to the bios of the system.

Generic console

A hardware agnostic generic console that maps into ADM-3A control codes is available. This permits portability of <conio.h> code across CP/M targets that do not have a specific implementation. To use it add the following command line parameters:

--generic-console -pragma-define:CONSOLE_COLUMNS=X -pragma-define:CONSOLE_ROWS=Y

Where X and Y are replaced with the size of the screen. The maximum supported screen size is 80x25.

File access

The classic CP/M target supports file access and distinguishes between text and binary files. A sector cache is implemented within the fcntl functions to speed up byte-orientated read and write operations.

The default configuration provides space for 3 FCBs, to configure more use the pragma: -pragma-define:CLIB_OPEN_MAX=nn

'stdin' and 'stdout' redirection is also supported at startup, by passing the "<filein" or ">fileout" command arguments. This will have an impact on FCB usage.

A fixed program name for argv[0] can be set with the following #pragma directive: #pragma string name

Optimization

There are a couple of #pragma commands which might be used to cut down the size of the resultant executable:

  • -pragma-define:CRT_ENABLE_COMMANDLINE=0 - Disable command line argument parsing
  • -pragma-define:CRT_COMMANDLINE_REDIRECTION=0 - Disable command line argument redirection ('<', '>')
  • -pragma-define:CRT_OPEN_MAX=0 - Disable file support, you will link with -lndos
  • #pragma output noprotectmsdos - strip the MS-DOS protection header

Hardware specific extensions

Some hardware specific functions have been adapted to run on both native platorm and generic CP/M environment (the 'gfx' prefix is used for library modules including graphics extensions only).

Additionally, the following options support the following S100 video cards which were common additions to early 8080 machines such as the Altair 8800, IMSAI.

  • --vti -pragma-export:VTI_DISPLAY=0xc000 Support for display on the VTI graphics card. Change VTI_DISPLAY to the address configured with the hardware dip switches.
  • --vio Support for generic console and lores graphics on the VIO graphics card.
  • --vdm Support for generic console and very lores graphics on the Altair 8800 VDM-1 graphics card.

Program boot protection

The code generated for CP/M based computers is protecting by default the MS-DOS environment.

In a similar way we can extend the protection to the 8080 based systems (which could crash if compiled for the Z80).

Just add to your source program:

#pragma output protect8080

Disk image tricks

The 'samdisk' tool by Andrew Owen provides powerful features to convert between the disk images or edit them.

A very useful option permits to copy the boot tracks from a valid system disk and overwrite the approximation introduced by appmake.

In example, supposing we created a disk image for LNW-80, we can borrow the 3 boot sectors from another disk image:

samdisk --cyls=3 --merge lnw80.imd a.imd

CP/M related Links

⚠️ **GitHub.com Fallback** ⚠️