← Manual LibraryVCC Plus 3.7.1 · Reading on the web

Try the exercises in VCC Plus. Example links download files here; open them in the app to work beside the emulator.

The complete book · PDF editionBook 6: Programming in C on the CoCo 3 — CMOC and Its APIs

198 pages · VCC Plus 3.7.1 · Keep a copy to read or print.

Download PDF
Contents

Chapter 5 of 9

Build a disk from a folder

Open a brand-new Hello Disk project. The guest will display five words. Only the headings live in the C files you first see. To find the five words, follow the build backward from the floppy to the Mac.

Meet the crew

Choose Develop → C Development… → New → Hello Disk. Give the project its own writable folder. In the editor's file list, open each of these files in turn.

File on the Mac Its job Where its contribution ends up
main.c Starts CoCo support, asks for the heading and the words, prints the result. Instructions in HELLO.BIN
src/display.c Prints the two fixed headings. Instructions and text in HELLO.BIN
src/disk.c Opens the guest file and prints the text it reads. Instructions and a reserved buffer in the running program
include/hello.h Declares the two functions and the shared count, so each C file knows their types. The compiler checks the callers against these declarations.
assets/words.txt Holds the five editable words, one per line. Supplies both the compiled count and the disk data
tools/build-data.pl Reads that list on the Mac and produces two files. Generated C source and a 256-byte WORDS.DAT

Here is the whole conductor's score, from the installed template.

/* SPDX-License-Identifier: GPL-3.0-or-later */
#include <cmoc.h>
#include <coco.h>
#include "hello.h"

int main(void)
{
    unsigned char status;
    initCoCoSupport();
    setHighSpeed(FALSE);
    showHeading();
    status = showDiskWords();
    printf("DISK RESULT: %u\n", status);
    printf("GENERATED WORD COUNT: %u\n", generatedWordCount);
    return status;
}

Read the last two print calls aloud. One number comes back from a function at run time. The other was counted when you built the program. They can tell different stories.

Follow the arrows back to their inputs

Open Project Settings → Preview or read the project's Makefile. Find the rule starting with HELLO.dsk:. The name on the left is a target, something Make knows how to produce. The items on the right must be ready first. The indented lines beneath it are the recipe. Here is the route to take through this particular file:

  1. To make HELLO.dsk, the recipe creates a fresh image, installs a small DOS loader, and puts HELLO.bin and generated/WORDS.DAT in its directory.
  2. To make HELLO.bin, the linker joins four compiled pieces and resolves the disk calls using decbfile. Three pieces correspond to the handwritten C files. The fourth comes from generated/word-count.c.
  3. The grouped rule for generated/word-count.c and generated/WORDS.DAT runs once to create both from the same word list. Open Resources to see the inputs, outputs and Perl command. One output will become part of the program. The other travels beside it.
  4. To change the cargo, edit assets/words.txt. An edit inside a generated file can disappear on the very next build.

A header is useful here for a different reason than a library. The declaration in hello.h tells the compiler how to call showDiskWords. The object built from disk.c supplies that function to the linker. Likewise, decbfile.h declares the disk calls and the library archive supplies their implementations.

Pick the button that performs your experiment

Start a Disk BASIC session with the FD-502 available. Save work in the guest before launching a different program.

Action What happens with these projects
Build Runs the configured build target on the Mac. Hello Disk specifies disk, so this builds its image as well as its binary. Hello World normally builds a binary.
Build Disk Requests the configured disk target explicitly. In the supplied Hello Disk project it is also disk.
Run With binary launch selected, the workbench loads the executable into the CoCo and enters it directly. Earth or Mars needs only this.
Launch Disk With disk launch selected, the workbench uses the built image, asks about replacing FD0 as needed, and sends the project's BASIC launch command. Hello Disk uses DOS.

Choose Build Disk. Read the last successful target in the build output. Choose it a second time without editing anything. Make can report that the target is already up to date. Rebuild is useful when you specifically want fresh compilation. Show Build Products takes you to the result on the Mac. The app builds in its own work area, so looking for a newly written HELLO.dsk among your handwritten sources can send you on a wild-goose chase.

In the C workspace, Disk & Run lists generated/WORDS.DAT as an extra file. The executable is included automatically. The disk will occupy FD0 and DOS will launch it.

Next choose Launch Disk. Attend to any floppy-replacement prompt. On the guest you should see five words and two numbers. Keep the disk and project open for a trip through the sector reader.

Original VCC Plus manuals © 2026 Brian K. Holman. Third-party references retain their authors’ copyrights and licenses. Artwork notices. Edition 3.7.1; source and export identity. Printable edition: PDF source and export identity.

A closer look

Open original