By Pierre Sarrazin
CMOC is a 6809-generating cross-compiler for a subset of the C language. It produces assembler code for the Motorola 6809 processor in the Color Computer .BIN format, the Dragon computer, as well as the Motorola SREC and Vectrex formats. It runs under GNU/Linux and other Unix-like environments like Darwin and Cygwin. It requires the LWTOOLS assembler (lwasm) and linker, by William Astle.
The most significant difference between CMOC and a complete C compiler is the absence of bit fields and of a complete C standard library. Floats are only usable under Color Basic. CMOC comes with a small library that serves as a starting kit.
For a summary of the C features that are supported or not by CMOC, see the C Language Features section of the manual.
CMOC is free software distributed under the GNU General Public License, version 3 or later, except for the files of the USim simulator, which is used for testing.
The current version is 0.1.70. It was released on 2021-03-07.
Release notes for 0.1.70:
Release notes for 0.1.69:
Release notes for 0.1.68:
Release notes for 0.1.66 and 0.1.67:
I can be contacted (in French or English) at sarrazip at sarrazip dot com. (Questions regarding Vectrex-specific issues should be addressed to Johan Van den Brande.)
See SHA512 signatures of these and other files.
Space Bandits (by Jamie Cho)
newcmd (0.1.0) (Public domain)
(Published 2020-09-07.) This program replaces Basic's SKIPF command with a different command that does something else, and is implemented in C. The new command can interpret its arguments and store output values that the Basic program can use.
decbfile (0.1.5) (Public domain)
(Published 2021-03-07.) Library that offers read/write access to files on a floppy disk in the Disk Basic format. It uses Disk Basic's sector routine by default, but can be made to use a stand-alone version, therefore making Basic's presence unnecessary.
BGraph (0.1.3) (Public domain) 🐲
Graphics library that offers functions similar to Basic's LINE, DRAW, PAINT and CIRCLE commands. It does not assume the presence of the Color Basic interpreter. Version 0.1.3 adds support for setting up semigraphics modes 8, 12 and 24 and for setting, resetting and getting pixels in those modes. The sgdemo.c program shows these modes.
BSound (0.1.1) (Public domain) 🐲
Library that offers a function similar to Basic's PLAY command. It does not assume the presence of the Color Basic interpreter.
BControl (0.1.3) (Public domain) 🐲
(Published 2020-06-27.) Library that offers functions similar to Color Basic's INKEY$, JOYSTK and BUTTON. It does not assume the presence of the Color Basic interpreter. It can be compiled for OS-9,althbough only the keyboard is supported as of this version. Version 0.1.3 adds Joystick_selectAnalogMuxInputs() and Joystick_compareAxis(), which allow custom, faster axis polling.
Color Eights (0.1.12) (GPLv3) 🐲
A card game derived from Crazy Eights that I wrote with CMOC. Uses the Cardgame library (see below). It can be run both under Disk Basic and NitrOS-9 EOU (from a 32x16 terminal). Its source code (with that of Cardgame) can be studied as an example of how to develop for both OS-9 and Disk Basic.
Cardgame (0.1.10) (Public domain) 🐲
A PMODE 4 (card) game library. Contains the generic code used by my Color Eights game: drawing and erasing cards (32x42 pixels), and drawing text (uppercase 32x24 grid), in a PMODE 4 screen. Beep and "white noise" functions. Rename cardgame.c to something else, fill main() and code other functions. The 8x8 text font can be reused independently, as done by cc3dblb (see below). This library can be compiled for OS-9, but the sound features are not supported as of this version. Version 0.1.10 adds drawCharWithoutMovingCursor(), moveCursorLeft(), invertCharAtCursor(), waitForKeyWithAnimatedCursor(), readLineFromKeyboard(), runPMode4GameDoubleBufferLoop().
cc3dblb (0.1.1) (Public domain)
A skeleton for a CoCo 3 double-buffering game. Start a new game project by renaming the files, then recode the onFlip() function. Uses the 8x8 text font from the Cardgame library to print text on the graphics screen. Requires Cardgame and BGraph (see above).
CoCo MiniLisp (by Jamie Cho)
A port of Rui Ueyama's MiniLisp. Version 0.5.0, released in October 2017, uses CMOC's support for 32-bit arithmetic.
xdaliclock port (by Jamie Cho)
Splinter (by Jamie Cho)
A CoCo 3 break-the-bricks video game written by Jamie Cho with CMOC. Splinter features colorful 320x192 graphics and smooth animation.
hirestxt (0.3.1) (Public domain) 🐲
A library that redirects printf() to a software 51x24 or 42x24 black-on-green PMODE 4 text screen. (A sample program is included.) Optionally supports several VT52 terminal sequences (disable this with #define HIRESTEXT_NO_VT52). Useful to get true lowercase, including Latin-1 accented characters, on all CoCos.
Color Verbiste (0.1.5) (GPLv3)
nobasic (0.1.10) (Public domain*) 🐲
A program that puts the CoCo in all-RAM mode, overwrites the Basic interpreter, moves the program and the stack to the end of the 64K of RAM and redirects the 60 Hz interrupt, as an example of a program that can use the entire 64K of RAM. Contains a disk sector read demo and a CoCo 3 graphics mode demo. *Some code in dskcon.c comes from DECB.
bigapp (0.1.1) (Public domain)
A demo of a program that is too large to be loaded by Basic's LOADM command and uses the whole 64K of RAM. This demo also adds arbitrary data files (PMODE 4 screens) to the .bin so that this data gets loaded with the code. The user calls LOADM and EXEC on a small loader program that takes care of loading the large program. Requires a 64K CoCo and the decbfile library, available on this page.
autostart.c (0.1.2) (Public domain)
A program to be compiled as a boot loader
that goes on track 34, so that the CoCo's DOS command will execute it.
(The autostart.bin file is not meant to be loaded with LOADM.)
The program feeds Color Basic's console input with the command
Demo program that plots a mathematical function in PMODE 4 graphics. The program implements an expression parser and an RPN interpreter to evaluate the user's function across an interval. Requires hirestxt and BControl.
(Updated 2018-04-03.) This archive contains a .dsk image file that contains VARPTR.BAS and VARPTR.BIN. Type RUN"VARPTR" on a CoCo. The archive also contains the C source file, which is compilable under CMOC. The Basic and C listings can be studied to learn how to access Basic variables from a CMOC program.
A Perl script that lists the blocks of a CoCo Disk Basic .BIN file, along with the entry point.
Bouncy Ball (by Lee Patterson)
A game for all CoCos. (It does not come with the source code.)
CoCoTair: an 8080 emulator (by Mark Sherman)
This was Mark's
Retrochallenge in 2017.
This emulator can be used to run
(To compile with CMOC 0.1.66 or later, the makefile of this project must be edited
to remove the
DwTerm (by Michael Furman)
A DriveWire 4 Terminal Program for the Disk Basic environment. Can be used with other DriveWire-related programs written by Michael.
See the manual that comes with CMOC. There is also a PDF version (38 pages, 193 kB).
I have written a small manual titled CMOC for BASIC Programmers, which may help Basic programmers who want a quick reference on mapping Basic constructs to their equivalents in C.
As of January 2021, I am developing CMOC on an Ubuntu 20.04 GNU/Linux system using GCC 9.3.0.
CMOC cannot currently be compiled directly as a native Windows application, but it can be compiled under Cygwin. It has been shown to work under that Unix-like environment.
Cygwin is recommended over MinGW, where the pipe calls (popen()) do not behave as expected, as of Fall 2018. In particular, the apostrophes on the command lines composed by CMOC, when calling the C preprocessor, do not appear to be interpreted as they should by the shell called by popen().
Note that LWTOOLS should then also be compiled for Cygwin. Packages that were pre-built for Windows or MinGW will probably not work as CMOC expects.
The configure script should recognize that it is running on a Mac OS X system, but if it does not, the following instructions may help:
export LDFLAGS="-framework CoreFoundation"
Thanks to Jamie Cho for these Mac instructions.
Glen Hewlett has posted an article on his blog about using CMOC from Mac OS or Linux.
Last update to this page: 2021-03-07 19:28:11 EST5EDT