# Generated by VCC Plus — edit Project Settings to regenerate. # Ordinary GNU Make; no VCC Plus project parser is required to build it. CMOC ?= cmoc PERL ?= perl WRITECOCOFILE ?= writecocofile INSTALL_LOADER ?= install-coco-boot-loader VCC_CONFIGURATION ?= Debug ifeq ($(VCC_CONFIGURATION),Release) OPTIM ?= -O2 else OPTIM ?= -O0 DEBUG_FRAME ?= -fno-omit-frame-pointer endif define VCC_DEFINES endef define VCC_COMPILER_OPTIONS endef define VCC_LINKER_OPTIONS endef CPPFLAGS += -Iinclude $(VCC_DEFINES) CFLAGS += --coco --intermediate --deps --stack-space=2048 $(OPTIM) $(DEBUG_FRAME) $(VCC_COMPILER_OPTIONS) LDFLAGS += --coco --intermediate --org=2800 $(VCC_LINKER_OPTIONS) LDLIBS += -ldecbfile OBJECTS := obj/main.o obj/src/display.o obj/src/disk.o obj/generated/word-count.o .PHONY: all build clean disk libraries all: build build: HELLO.bin HELLO.bin: $(OBJECTS) Makefile @mkdir -p $(dir $@) "$(CMOC)" $(LDFLAGS) -o $@ $(OBJECTS) $(LDLIBS) obj/main.o: main.c Makefile generated/word-count.c generated/WORDS.DAT @mkdir -p $(dir $@) "$(CMOC)" $(CPPFLAGS) $(CFLAGS) --intdir=$(dir $@) -c -o $@ $< obj/src/display.o: src/display.c Makefile generated/word-count.c generated/WORDS.DAT @mkdir -p $(dir $@) "$(CMOC)" $(CPPFLAGS) $(CFLAGS) --intdir=$(dir $@) -c -o $@ $< obj/src/disk.o: src/disk.c Makefile generated/word-count.c generated/WORDS.DAT @mkdir -p $(dir $@) "$(CMOC)" $(CPPFLAGS) $(CFLAGS) --intdir=$(dir $@) -c -o $@ $< obj/generated/word-count.o: generated/word-count.c Makefile generated/word-count.c generated/WORDS.DAT @mkdir -p $(dir $@) "$(CMOC)" $(CPPFLAGS) $(CFLAGS) --intdir=$(dir $@) -c -o $@ $< generated/word-count.c generated/WORDS.DAT &: tools/build-data.pl assets/words.txt Makefile @mkdir -p generated $(PERL) tools/build-data.pl assets/words.txt generated/word-count.c generated/WORDS.DAT test -f generated/word-count.c test -f generated/WORDS.DAT # DOS helper: Pierre Sarrazin, autostart.c 0.1.2, public domain. obj/vcc-dos-boot/loader.bin: Makefile @mkdir -p $(dir $@) @printf '%s\n' '// autostart.c - Program to be run by the Disk Basic DOS command.' '// By Pierre Sarrazin ' '// This file is in the public domain.' '//' '// Reference: Roger Schrag, "A Special Use For The DOS Command",' '// The Rainbow, November 1984, p.140.' '//' '// To compile: cmoc --dos autostart.c' '// To install on CoCo disk image: install-coco-boot-loader some-image.dsk autostart.bin' '// To run on CoCo: type DOS and to automatically run *.BAS.' '//' '// Version history:' '// 0.1.0 2016-01-16 Use of legacy.h discontinued.' '// 0.1.1 2018-04-03 Adapted to CMOC 0.1.51 (const).' '// 0.1.2 2018-08-04 Basic line now forced to be uppercase.' '' '#include ' '' '#define ENDFLG 0x00 // STOP/END FLAG: POSITIVE=STOP, NEG=END' '#define CINBFL 0x70 // CONSOLE IN BUFFER FLAG: 00=NOT EMPTY, $$FF=EMPTY' '#define RVEC4 0x016a // RAM hook: CONSOLE IN' '' '' 'byte oldHookInstr;' 'word oldHookAddr;' 'const char *basicLineReader;' '' '' 'void feedKeyboard()' '{' ' word preservedX;' ' asm("stx", preservedX);' '' ' * (byte *) CINBFL = 0; // console in buffer now not empty' '' ' char nextBasicByte = (char) toupper(*basicLineReader);' ' ++basicLineReader;' ' if (nextBasicByte == 0) // if finished returning Basic line' ' {' ' * (byte *) RVEC4 = oldHookInstr;' ' * (word *) (RVEC4 + 1) = oldHookAddr;' ' nextBasicByte = '"'"'\r'"'"'; // return "Enter" to cause execution of Basic line' ' }' '' ' asm {' ' lda nextBasicByte' ' ldx preservedX' ' tfr u,s // discard stack frame' ' leas 4,s // discard previous stack frame ptr and return addr' ' rts // return to caller of CONSOLE IN' ' }' '}' '' '' 'int main()' '{' ' * (byte *) ENDFLG = - * (byte *) ENDFLG; // why?' '' ' basicLineReader =' ' #ifndef COMMAND' ' "RUN\"*.BAS\""' ' #else' ' COMMAND' ' #endif' ' ;' '' ' // Install function feedKeyboard() as CONSOLE IN routine.' ' //' ' oldHookInstr = * (byte *) RVEC4;' ' oldHookAddr = * (word *) (RVEC4 + 1);' '' ' * (byte *) RVEC4 = 0x7e; // JMP instruction' ' * (void **) (RVEC4 + 1) = (void *) feedKeyboard;' '' ' * (word *) 0x2600 = 0; // overwrite "OS" marker with two null bytes' '' ' asm("jmp", "$$ac7c"); // go interpret a Basic line (which is read from console)' '' ' return 0; // avoids compiler error' '}' > obj/vcc-dos-boot/loader.c "$(CMOC)" --dos -O0 --limit=2800 -o $@ '-DCOMMAND="LOADM\"HELLO.BIN\":EXEC"' obj/vcc-dos-boot/loader.c disk: HELLO.dsk HELLO.dsk: HELLO.bin generated/WORDS.DAT obj/vcc-dos-boot/loader.bin Makefile @mkdir -p $(dir $@) $(PERL) -e 'print chr(255) x (35*18*256)' > $@ $(INSTALL_LOADER) $@ obj/vcc-dos-boot/loader.bin $(WRITECOCOFILE) $@ HELLO.bin $(WRITECOCOFILE) $@ generated/WORDS.DAT clean: rm -rf obj rm -f HELLO.bin HELLO.map HELLO.link HELLO.dsk generated/word-count.c generated/WORDS.DAT -include $(OBJECTS:.o=.d)