From 2990c4cb539eebdf00b4e24142b61bc9916dfd99 Mon Sep 17 00:00:00 2001 From: Jeremy Rand Date: Thu, 14 Jun 2018 23:51:01 -0400 Subject: [PATCH] Add the ability to link in drivers by just enabling them in the root Makefile --- Makefile | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++ make/head.mk | 9 ++--- make/tail.mk | 102 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 216 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 3c9af2f..6e12e8b 100644 --- a/Makefile +++ b/Makefile @@ -81,6 +81,118 @@ SRCDIRS+= # this variable: # LDFLAGS += -v +# If you want to link the lores graphics driver with your executable, +# uncomment the next line. +# DRIVERS += loresgr +# +# To use the lores driver, add code which looks like this to your +# project: +# +# #include "drivers/a2_lores_drv.h" +# int main(void) +# { +# tgi_install(&a2_lores_drv); +# tgi_init(); +# // Use the graphics driver +# tgi_uninstall(); +# } +# +# Read the /usr/local/lib/cc65/include/tgi.h file to see what the +# driver interface provides. Also check out +# /usr/local/lib/cc65/include/apple2.h to see the colour definitions. + +# If you want to link the hires graphics driver with your executable, +# uncomment the next line. +# DRIVERS += hiresgr +# +# To use the hires driver, add code which looks like this to your +# project: +# +# #include "drivers/a2_hires_drv.h" +# int main(void) +# { +# tgi_install(&a2_hires_drv); +# tgi_init(); +# // Use the graphics driver +# tgi_uninstall(); +# } +# +# Read the /usr/local/lib/cc65/include/tgi.h file to see what the +# driver interface provides. Also check out +# /usr/local/lib/cc65/include/apple2.h to see the colour definitions. + +# If you want to link the extended memory driver with your executable, +# uncomment the next line. +# DRIVERS += auxmem +# +# To use the auxmem driver, add code which looks like this to your +# project: +# +# #include "drivers/a2_auxmem_drv.h" +# int main(void) +# { +# em_install(&a2_auxmem_drv); +# // Use the auxmem driver +# em_uninstall(); +# } +# +# Read the /usr/local/lib/cc65/include/em.h file to see what the +# driver interface provides. + +# If you want to link the joystick driver with your executable, +# uncomment the next line. +# DRIVERS += joystick +# +# To use the joystick driver, add code which looks like this to your +# project: +# +# #include "drivers/a2_joystick_drv.h" +# int main(void) +# { +# joy_install(&a2_joystick_drv); +# // Use the joystick driver +# joy_uninstall(); +# } +# +# Read the /usr/local/lib/cc65/include/joystick.h file to see what the +# driver interface provides. + +# If you want to link the mouse driver with your executable, +# uncomment the next line. +# DRIVERS += mouse +# +# To use the mouse driver, add code which looks like this to your +# project: +# +# #include "drivers/a2_mouse_drv.h" +# int main(void) +# { +# mouse_install(&mouse_def_callbacks, &a2_mouse_drv); +# // Use the mouse driver +# mouse_uninstall(); +# } +# +# Read the /usr/local/lib/cc65/include/mouse.h file to see what the +# driver interface provides. + +# If you want to link the serial driver with your executable, +# uncomment the next line. +# DRIVERS += serial +# +# To use the serial driver, add code which looks like this to your +# project: +# +# #include "drivers/a2_serial_drv.h" +# int main(void) +# { +# ser_install(&a2_serial_drv); +# // Use the serial driver +# ser_uninstall(); +# } +# +# Read the /usr/local/lib/cc65/include/serial.h file to see what the +# driver interface provides. + # If you have java installed in a non-standard location, you can set # the path to it by uncommenting the following line: # export JAVA=/usr/bin/java diff --git a/make/head.mk b/make/head.mk index 9190343..0f3205f 100644 --- a/make/head.mk +++ b/make/head.mk @@ -17,6 +17,7 @@ CC65_BIN = /usr/local/bin CL65=$(CC65_BIN)/cl65 CA65=$(CC65_BIN)/ca65 CC65=$(CC65_BIN)/cc65 +CO65=$(CC65_BIN)/co65 AC=make/AppleCommander.jar @@ -27,6 +28,8 @@ CPU=6502 CFLAGS= ASMFLAGS= LDFLAGS= +DRIVERS= +DRVDIR=drivers XCODE_PATH=/Applications/Xcode.app XCODE_INFO=$(XCODE_PATH)/Contents/Info.plist @@ -37,13 +40,9 @@ CC65_PLUGIN_INFO=$(CC65_PLUGIN_PATH)/Contents/Info.plist XCODE_PLUGIN_COMPATIBILITY=DVTPlugInCompatibilityUUID -.PHONY: all gen genclean xcodefix +.PHONY: all gen genclean all: - @make xcodefix @make gen @make build -xcodefix: - defaults write "$(CC65_PLUGIN_INFO)" $(XCODE_PLUGIN_COMPATIBILITY)s -array `defaults read "$(XCODE_INFO)" $(XCODE_PLUGIN_COMPATIBILITY)` - diff --git a/make/tail.mk b/make/tail.mk index 32ef931..6463582 100644 --- a/make/tail.mk +++ b/make/tail.mk @@ -14,6 +14,10 @@ export PATH := $(PATH):$(CC65_BIN) CWD=$(shell pwd) +ifneq ($(DRIVERS),) + SRCDIRS+=$(DRVDIR) +endif + C_SRCS=$(patsubst ./%, %, $(wildcard $(addsuffix /*.c, $(SRCDIRS)))) C_OBJS=$(C_SRCS:.c=.o) C_DEPS=$(C_SRCS:.c=.u) @@ -57,6 +61,13 @@ ifneq ($(filter $(MACHINE), apple2 apple2enh apple2-dos33 apple2enh-dos33),) EXECCMD=$(shell echo brun $(PGM) | tr '[a-z]' '[A-Z]') endif +# By default, use the a2 drivers. If the machine is one of the enhanced +# targets though, use the a2e drivers. +DRV_BASE_MACHINE=a2 +ifneq ($(filter $(MACHINE), apple2enh apple2enh-dos33 apple2enh-system apple2enh-loader apple2enh-reboot),) + DRV_BASE_MACHINE=a2e +endif + MACHCONFIG= -t apple2 ifneq ($(filter $(MACHINE), apple2enh apple2apple2enh-dos33 apple2enh-system apple2enh-loader apple2enh-reboot),) @@ -67,17 +78,18 @@ ifeq ($(filter $(MACHINE), apple2 apple2enh),) MACHCONFIG += -C $(MACHINE).cfg endif -.PHONY: build execute clean +.PHONY: build execute clean xcodefix loresgr hiresgr auxmem joystick mouse serial build: $(ALLTARGET) -clean: +clean: genclean rm -f "$(PGM)" rm -f $(OBJS) rm -f $(C_DEPS) rm -f $(MAPFILE) rm -f $(ASM_LSTS) rm -f "$(DISKIMAGE)" + rm -Rf "$(DRVDIR)" cleanMacCruft: rm -rf pkg @@ -101,4 +113,90 @@ execute: $(DISKIMAGE) $(OBJS): Makefile + +# Some gen phase stuff... +gen: xcodefix $(DRIVERS) + +xcodefix: + defaults write "$(CC65_PLUGIN_INFO)" $(XCODE_PLUGIN_COMPATIBILITY)s -array `defaults read "$(XCODE_INFO)" $(XCODE_PLUGIN_COMPATIBILITY)` + + +# Lores driver codegen +loresgr: $(DRVDIR)/a2_lores_drv.s $(DRVDIR)/a2_lores_drv.h + +$(DRVDIR)/a2_lores_drv.s: $(CC65_HOME)/tgi/$(DRV_BASE_MACHINE).lo.tgi + mkdir -p $(DRVDIR) + $(CO65) --code-label _a2_lores_drv -o $@ $(CC65_HOME)/tgi/$(DRV_BASE_MACHINE).lo.tgi + +$(DRVDIR)/a2_lores_drv.h: + mkdir -p $(DRVDIR) + echo '#include ' > $@ + echo 'extern char a2_lores_drv;' >> $@ + + +# Hires driver codegen +hiresgr: $(DRVDIR)/a2_hires_drv.s $(DRVDIR)/a2_hires_drv.h + +$(DRVDIR)/a2_hires_drv.s: $(CC65_HOME)/tgi/$(DRV_BASE_MACHINE).hi.tgi + mkdir -p $(DRVDIR) + $(CO65) --code-label _a2_hires_drv -o $@ $(CC65_HOME)/tgi/$(DRV_BASE_MACHINE).hi.tgi + +$(DRVDIR)/a2_hires_drv.h: + mkdir -p $(DRVDIR) + echo '#include ' > $@ + echo 'extern char a2_hires_drv;' >> $@ + + +# Auxmem driver codegen +auxmem: $(DRVDIR)/a2_auxmem_drv.s $(DRVDIR)/a2_auxmem_drv.h + +$(DRVDIR)/a2_auxmem_drv.s: $(CC65_HOME)/emd/$(DRV_BASE_MACHINE).auxmem.emd + mkdir -p $(DRVDIR) + $(CO65) --code-label _a2_auxmem_drv -o $@ $(CC65_HOME)/emd/$(DRV_BASE_MACHINE).auxmem.emd + +$(DRVDIR)/a2_auxmem_drv.h: + mkdir -p $(DRVDIR) + echo '#include ' > $@ + echo 'extern char a2_auxmem_drv;' >> $@ + + +# Joystick driver codegen +joystick: $(DRVDIR)/a2_joystick_drv.s $(DRVDIR)/a2_joystick_drv.h + +$(DRVDIR)/a2_joystick_drv.s: $(CC65_HOME)/joy/$(DRV_BASE_MACHINE).stdjoy.joy + mkdir -p $(DRVDIR) + $(CO65) --code-label _a2_joystick_drv -o $@ $(CC65_HOME)/joy/$(DRV_BASE_MACHINE).stdjoy.joy + +$(DRVDIR)/a2_joystick_drv.h: + mkdir -p $(DRVDIR) + echo '#include ' > $@ + echo 'extern char a2_joystick_drv;' >> $@ + + +# Mouse driver codegen +mouse: $(DRVDIR)/a2_mouse_drv.s $(DRVDIR)/a2_mouse_drv.h + +$(DRVDIR)/a2_mouse_drv.s: $(CC65_HOME)/mou/$(DRV_BASE_MACHINE).stdmou.mou + mkdir -p $(DRVDIR) + $(CO65) --code-label _a2_mouse_drv -o $@ $(CC65_HOME)/mou/$(DRV_BASE_MACHINE).stdmou.mou + +$(DRVDIR)/a2_mouse_drv.h: + mkdir -p $(DRVDIR) + echo '#include ' > $@ + echo 'extern char a2_mouse_drv;' >> $@ + + +# Serial driver codegen +serial: $(DRVDIR)/a2_serial_drv.s $(DRVDIR)/a2_serial_drv.h + +$(DRVDIR)/a2_serial_drv.s: $(CC65_HOME)/ser/$(DRV_BASE_MACHINE).ssc.ser + mkdir -p $(DRVDIR) + $(CO65) --code-label _a2_serial_drv -o $@ $(CC65_HOME)/ser/$(DRV_BASE_MACHINE).ssc.ser + +$(DRVDIR)/a2_serial_drv.h: + mkdir -p $(DRVDIR) + echo '#include ' > $@ + echo 'extern char a2_serial_drv;' >> $@ + + -include $(C_DEPS)