Add support for cc65 2.17.

This commit is contained in:
Jeremy Rand 2018-10-17 23:59:31 -04:00
parent 628963f505
commit 0afbfb7356
10 changed files with 381 additions and 122 deletions

View File

@ -21,6 +21,7 @@
9D24619320D8B30C00227E1D /* joystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 9D24618E20D8B30C00227E1D /* joystick.c */; };
9D24619420D8B30C00227E1D /* curta.c in Sources */ = {isa = PBXBuildFile; fileRef = 9D24618F20D8B30C00227E1D /* curta.c */; };
9D24619520D8B30C00227E1D /* curtaUI.c in Sources */ = {isa = PBXBuildFile; fileRef = 9D24619120D8B30C00227E1D /* curtaUI.c */; };
9D3A3EC421783BEA00BE74C7 /* bastokenizer-tools-bt-0.2.0.jar in Frameworks */ = {isa = PBXBuildFile; fileRef = 9D3A3EC321783BEA00BE74C7 /* bastokenizer-tools-bt-0.2.0.jar */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@ -64,6 +65,8 @@
9D24618F20D8B30C00227E1D /* curta.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = curta.c; sourceTree = "<group>"; };
9D24619020D8B30C00227E1D /* joystick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = joystick.h; sourceTree = "<group>"; };
9D24619120D8B30C00227E1D /* curtaUI.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = curtaUI.c; sourceTree = "<group>"; };
9D3A3EC221783BEA00BE74C7 /* bt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = bt; path = make/bt; sourceTree = "<group>"; };
9D3A3EC321783BEA00BE74C7 /* bastokenizer-tools-bt-0.2.0.jar */ = {isa = PBXFileReference; lastKnownFileType = archive.jar; name = "bastokenizer-tools-bt-0.2.0.jar"; path = "make/bastokenizer-tools-bt-0.2.0.jar"; sourceTree = "<group>"; };
9D45ABB620E1E564008C3F16 /* errorFilter.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; name = errorFilter.sh; path = make/errorFilter.sh; sourceTree = "<group>"; };
9D65A1BF20DCA472004268B7 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -74,6 +77,7 @@
buildActionMask = 2147483647;
files = (
9D24616F20D8B2AE00227E1D /* AppleCommander.jar in Frameworks */,
9D3A3EC421783BEA00BE74C7 /* bastokenizer-tools-bt-0.2.0.jar in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -120,6 +124,8 @@
isa = PBXGroup;
children = (
9D24616E20D8B2AE00227E1D /* AppleCommander.jar */,
9D3A3EC321783BEA00BE74C7 /* bastokenizer-tools-bt-0.2.0.jar */,
9D3A3EC221783BEA00BE74C7 /* bt */,
9D24617020D8B2AE00227E1D /* createDiskImage */,
9D24617220D8B2AE00227E1D /* DevApple.vii */,
9D24617420D8B2AE00227E1D /* dos33_template.dsk */,

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Original</string>
</dict>
</plist>

View File

@ -18,10 +18,6 @@ include make/head.mk
# The name of your system or binary file to build goes here:
PGM=curta
# Set the config you are building for. See these pages for details:
# http://cc65.github.io/cc65/doc/apple2.html#s4
# http://cc65.github.io/cc65/doc/apple2enh.html#s4
#
# Uncomment the one you want below (the first one is the default):
# MACHINE = apple2
# MACHINE = apple2-dos33
@ -34,6 +30,13 @@ MACHINE = apple2-loader
# MACHINE = apple2enh-loader
# MACHINE = apple2enh-reboot
# Uncomment the appropriate project type. If your entry point is
# main() in a .c file, then your project type is cc65. If your
# entry point is in an assembly file, then you project type is
# ca65:
PROJECT_TYPE = cc65
# PROJECT_TYPE = ca65
# Uncomment and set this to your starting address in Apple II memory
# if necessary:
START_ADDR = 4000
@ -54,8 +57,12 @@ SRCDIRS+=
# If you have a non-standard cc65 install, you may need to change
# some of these. Uncomment the following line and change it to the
# correct path to CC65_HOME if the default is not correct:
# export CC65_HOME := /usr/local/lib/cc65
# correct path to CC65_HOME if the default is not correct. If you
# are using cc65 v2.13.3, the default is:
# /usr/local/lib/cc65
# If you are using cc65 v2.17, the default is:
# /usr/local/share/cc65
# export CC65_HOME := /path/to/your/cc65/directory
#
# If the path to the cc65 binaries is not correct, uncomment this
# line and change it:
@ -73,6 +80,10 @@ SRCDIRS+=
# this variable:
# LDFLAGS += -v
# If you want to add arguments to the BASIC tokenizer commandline,
# add them to this valiable:
# BASICFLAGS += --optimize
# If you want to link the lores graphics driver with your executable,
# uncomment the next line.
# DRIVERS += loresgr
@ -89,9 +100,9 @@ SRCDIRS+=
# tgi_uninstall();
# }
#
# Read the /usr/local/lib/cc65/include/tgi.h file to see what the
# Read the $CC65_HOME/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.
# $CC65_HOME/include/apple2.h to see the colour definitions.
# If you want to link the hires graphics driver with your executable,
# uncomment the next line.
@ -109,9 +120,9 @@ DRIVERS += hiresgr
# tgi_uninstall();
# }
#
# Read the /usr/local/lib/cc65/include/tgi.h file to see what the
# Read the $CC65_HOME/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.
# $CC65_HOME/include/apple2.h to see the colour definitions.
# If you want to link the extended memory driver with your executable,
# uncomment the next line.
@ -128,7 +139,7 @@ DRIVERS += hiresgr
# em_uninstall();
# }
#
# Read the /usr/local/lib/cc65/include/em.h file to see what the
# Read the $CC65_HOME/include/em.h file to see what the
# driver interface provides.
# If you want to link the joystick driver with your executable,
@ -146,7 +157,7 @@ DRIVERS += hiresgr
# joy_uninstall();
# }
#
# Read the /usr/local/lib/cc65/include/joystick.h file to see what the
# Read the $CC65_HOME/include/joystick.h file to see what the
# driver interface provides.
# If you want to link the mouse driver with your executable,
@ -164,7 +175,7 @@ DRIVERS += hiresgr
# mouse_uninstall();
# }
#
# Read the /usr/local/lib/cc65/include/mouse.h file to see what the
# Read the $CC65_HOME/include/mouse.h file to see what the
# driver interface provides.
# If you want to link the serial driver with your executable,
@ -182,7 +193,7 @@ DRIVERS += hiresgr
# ser_uninstall();
# }
#
# Read the /usr/local/lib/cc65/include/serial.h file to see what the
# Read the $CC65_HOME/include/serial.h file to see what the
# driver interface provides.
# If you have java installed in a non-standard location, you can set
@ -224,6 +235,10 @@ COPYDIRS=
# commands are called here, if any. You can generate .c, .s or .h
# files for example. You can generate data files. Whatever you
# might need.
#
# All of your commands associated with a rule _must_ start with a tab
# character. Xcode makes it a bit tough to type a tab character by
# default. Press option-tab within Xcode to insert a tab character.
gen:
# For any files you generated in the gen target above, you should

Binary file not shown.

Binary file not shown.

34
CurtaSim/make/bt Executable file
View File

@ -0,0 +1,34 @@
#!/bin/sh
if [ -z "$JAVA" ]
then
for item in "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home" /Library/Java/JavaVirtualMachines/*/Contents/Home /usr
do
if [ -x "$item/bin/java" ]
then
JAVA="$item/bin/java"
break
fi
done
fi
if [ -z "$JAVA" ]
then
echo Cannot find a path to a Java runtime.
echo Go to https://java.com/download if you do not have Java.
echo If you do have Java, you may need to uncomment the JAVA
echo line in the Makefile and set it to the path for your
echo Java runtime binary.
exit 1
fi
INPUTFILE=$1
shift
tr -d '©' < "$INPUTFILE" > /tmp/bt_filtered.$$
"$JAVA" -jar make/bastokenizer-tools-bt-0.2.0.jar $* /tmp/bt_filtered.$$
RESULT=$?
rm /tmp/bt_filtered.$$
exit $RESULT

View File

@ -1,5 +1,10 @@
#!/bin/sh
merlinStartAddr() {
awk '$1 ~ /^[oO][rR][gG]$/{print $2}' linkscript.s | sed 's/^[0$]*//'
}
if [ $# -lt 5 ]
then
echo USAGE: $0 '<AppleCommander> <machine> <diskimage> <binary>'
@ -43,11 +48,7 @@ shift
STARTADDR=`echo $1 | sed 's/^0*//'`
shift
if [ ! -f "$PROGRAM" ]
then
echo "Cannot file executable $PROGRAM"
exit 1
fi
SOURCEFILE=$PROGRAM
case "$MACHINE" in
apple2)
@ -55,8 +56,10 @@ case "$MACHINE" in
DELETELOADER=1
RENAMELOADER=0
DELETEBASIC=0
COPYBINARY=1
HASHEADER=1
FILETYPE="bin"
BASICFILETYPE="bas"
TARGETFILE=`basename $PROGRAM`
MAXFILENAMELEN=15
;;
@ -66,8 +69,10 @@ case "$MACHINE" in
DELETELOADER=1
RENAMELOADER=0
DELETEBASIC=0
COPYBINARY=1
HASHEADER=1
FILETYPE="bin"
BASICFILETYPE="bas"
TARGETFILE=`basename $PROGRAM`
MAXFILENAMELEN=15
;;
@ -77,8 +82,10 @@ case "$MACHINE" in
DELETELOADER=0
RENAMELOADER=0
DELETEBASIC=0
COPYBINARY=1
HASHEADER=1
FILETYPE="bin"
FILETYPE="B"
BASICFILETYPE="A"
TARGETFILE=`basename $PROGRAM`
MAXFILENAMELEN=30
;;
@ -88,8 +95,10 @@ case "$MACHINE" in
DELETELOADER=0
RENAMELOADER=0
DELETEBASIC=0
COPYBINARY=1
HASHEADER=1
FILETYPE="bin"
FILETYPE="B"
BASICFILETYPE="A"
TARGETFILE=`basename $PROGRAM`
MAXFILENAMELEN=30
;;
@ -99,8 +108,10 @@ case "$MACHINE" in
DELETELOADER=1
RENAMELOADER=0
DELETEBASIC=1
COPYBINARY=1
HASHEADER=0
FILETYPE="sys"
BASICFILETYPE="bas"
TARGETFILE=`basename $PROGRAM`.system
MAXFILENAMELEN=15
;;
@ -110,8 +121,10 @@ case "$MACHINE" in
DELETELOADER=1
RENAMELOADER=0
DELETEBASIC=1
COPYBINARY=1
HASHEADER=0
FILETYPE="sys"
BASICFILETYPE="bas"
TARGETFILE=`basename $PROGRAM`.system
MAXFILENAMELEN=15
;;
@ -121,8 +134,10 @@ case "$MACHINE" in
DELETELOADER=0
RENAMELOADER=1
DELETEBASIC=1
COPYBINARY=1
HASHEADER=1
FILETYPE="bin"
BASICFILETYPE="bas"
TARGETFILE=`basename $PROGRAM`
MAXFILENAMELEN=15
;;
@ -132,8 +147,10 @@ case "$MACHINE" in
DELETELOADER=0
RENAMELOADER=1
DELETEBASIC=1
COPYBINARY=1
HASHEADER=1
FILETYPE="bin"
BASICFILETYPE="bas"
TARGETFILE=`basename $PROGRAM`
MAXFILENAMELEN=15
;;
@ -143,8 +160,10 @@ case "$MACHINE" in
DELETELOADER=0
RENAMELOADER=1
DELETEBASIC=1
COPYBINARY=1
HASHEADER=1
FILETYPE="bin"
BASICFILETYPE="bas"
TARGETFILE=`basename $PROGRAM`
MAXFILENAMELEN=15
;;
@ -154,18 +173,89 @@ case "$MACHINE" in
DELETELOADER=0
RENAMELOADER=1
DELETEBASIC=1
COPYBINARY=1
HASHEADER=1
FILETYPE="bin"
BASICFILETYPE="bas"
TARGETFILE=`basename $PROGRAM`
MAXFILENAMELEN=15
;;
apple2-basic)
TEMPLATE="make/prodos_template.dsk"
DELETELOADER=1
RENAMELOADER=0
DELETEBASIC=0
COPYBINARY=0
FILETYPE="bas"
BASICFILETYPE="bas"
TARGETFILE=`basename $PROGRAM`
SOURCEFILE=${PROGRAM}.tok
MAXFILENAMELEN=15
;;
apple2-dos33-basic)
TEMPLATE="make/dos33_template.dsk"
DELETELOADER=0
RENAMELOADER=0
DELETEBASIC=0
COPYBINARY=0
FILETYPE="A"
BASICFILETYPE="A"
TARGETFILE=`basename $PROGRAM`
SOURCEFILE=${PROGRAM}.tok
MAXFILENAMELEN=30
;;
apple2-merlin)
TEMPLATE="make/prodos_template.dsk"
DELETELOADER=1
RENAMELOADER=0
DELETEBASIC=0
COPYBINARY=1
HASHEADER=0
FILETYPE="bin"
BASICFILETYPE="bas"
TARGETFILE=`basename $PROGRAM`
MAXFILENAMELEN=15
STARTADDR=`merlinStartAddr`
;;
apple2-dos33-merlin)
TEMPLATE="make/dos33_template.dsk"
DELETELOADER=0
RENAMELOADER=0
DELETEBASIC=0
COPYBINARY=1
HASHEADER=0
FILETYPE="B"
BASICFILETYPE="A"
TARGETFILE=`basename $PROGRAM`
MAXFILENAMELEN=30
STARTADDR=`merlinStartAddr`
;;
*)
echo "Invalid machine type $MACHINE"
exit 1
;;
esac
STARTARG=""
if [ ! -z "$STARTADDR" ]
then
STARTARG="0x$STARTADDR"
fi
if [ ! -f "$SOURCEFILE" ]
then
echo "Cannot file executable $SOURCEFILE"
exit 1
fi
if [ ${#TARGETFILE} -gt $MAXFILENAMELEN ]
then
echo "The filename $TARGETFILE exceeds the max name length of the filesystem ($MAXFILENAMELEN)"
@ -203,29 +293,44 @@ then
"$JAVA" -jar "$APPLECOMMANDER" -d "$DISKIMAGE" BASIC.SYSTEM
fi
if [ $HASHEADER -eq 1 ]
if [ $COPYBINARY -eq 1 ]
then
HDR_STARTADDR=`od -t x2 -N 2 < "$PROGRAM" | head -1 | awk '{print $2}' | sed 's/^0*//'`
if [ "$HDR_STARTADDR" = "$STARTADDR" ]
if [ "$CC65_SUPPORTS_APPLE_SINGLE" -eq 1 ]
then
dd if="$PROGRAM" bs=4 skip=1 | "$JAVA" -jar "$APPLECOMMANDER" -p "$DISKIMAGE" "$TARGETFILE" $FILETYPE 0x$STARTADDR
else
"$JAVA" -jar "$APPLECOMMANDER" -p "$DISKIMAGE" "$TARGETFILE" $FILETYPE 0x$STARTADDR < "$PROGRAM"
"$JAVA" -jar "$APPLECOMMANDER" -as "$DISKIMAGE" "$TARGETFILE" < "$SOURCEFILE"
elif [ $HASHEADER -eq 1 ]
then
HDR_STARTADDR=`od -t x2 -N 2 < "$SOURCEFILE" | head -1 | awk '{print $2}' | sed 's/^0*//'`
if [ "$HDR_STARTADDR" = "$STARTADDR" ]
then
dd if="$SOURCEFILE" bs=4 skip=1 | "$JAVA" -jar "$APPLECOMMANDER" -p "$DISKIMAGE" "$TARGETFILE" $FILETYPE $STARTARG
else
"$JAVA" -jar "$APPLECOMMANDER" -p "$DISKIMAGE" "$TARGETFILE" $FILETYPE $STARTARG < "$SOURCEFILE"
fi
else
"$JAVA" -jar "$APPLECOMMANDER" -p "$DISKIMAGE" "$TARGETFILE" $FILETYPE $STARTARG < "$SOURCEFILE"
fi
else
"$JAVA" -jar "$APPLECOMMANDER" -p "$DISKIMAGE" "$TARGETFILE" $FILETYPE < "$PROGRAM"
fi
for DIR in $*
for ITEM in $*
do
if [ ! -d "$DIR" ]
# If this is a file matching *.tok, then this is an Applesoft BASIC file
# to copy to the disk image.
if [ -f "$ITEM" ] && echo "$ITEM" | grep '\.tok$' > /dev/null
then
echo Unable to find directory $DIR
DESTFILE=`echo "$ITEM" | sed 's/\.tok$//'`
"$JAVA" -jar "$APPLECOMMANDER" -p "$DISKIMAGE" "$DESTFILE" "$BASICFILETYPE" 0x801 < "$ITEM"
continue
fi
if [ ! -d "$ITEM" ]
then
echo Unable to find directory $ITEM
exit 1
fi
OLDPWD=`pwd`
cd $DIR
cd $ITEM
find . -type f -print | while read FILE
do

View File

@ -10,15 +10,23 @@
# http://www.quinndunki.com/blondihacks
#
export CC65_HOME := /usr/local/lib/cc65
CC65_BIN=/usr/local/bin
CC65_BIN = /usr/local/bin
ifneq ($(wildcard /usr/local/lib/cc65),)
export CC65_HOME := /usr/local/lib/cc65
else
export CC65_HOME := /usr/local/share/cc65
endif
CL65=$(CC65_BIN)/cl65
CA65=$(CC65_BIN)/ca65
CC65=$(CC65_BIN)/cc65
CO65=$(CC65_BIN)/co65
MERLIN_DIR=/usr/local
MERLIN_BIN=$(MERLIN_DIR)/bin/Merlin32
MERLIN_LIB=$(MERLIN_DIR)/lib/Merlin
AC=make/AppleCommander.jar
SRCDIRS=.

View File

@ -10,123 +10,204 @@
# http://www.quinndunki.com/blondihacks
#
export PATH := $(PATH):$(CC65_BIN)
BUILD_TYPE := $(shell if echo $(MACHINE) | grep -q -- -basic; then echo basic; elif echo $(MACHINE) | grep -q -- -merlin; then echo merlin; else echo cc65; fi)
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)
ASM_SRCS=$(patsubst ./%, %, $(wildcard $(addsuffix /*.s, $(SRCDIRS))))
ASM_OBJS=$(ASM_SRCS:.s=.o)
ASM_LSTS=$(ASM_SRCS:.s=.lst)
OBJS=$(C_OBJS) $(ASM_OBJS)
MAPFILE=$(PGM).map
DISKIMAGE=$(PGM).dsk
LINK_ARGS=
EXECCMD=
ALLTARGET=$(DISKIMAGE)
BASIC_SRCS=$(patsubst ./%, %, $(wildcard $(addsuffix /*.bas, $(SRCDIRS))))
BASIC_OBJS=$(BASIC_SRCS:.bas=.tok)
ifneq ($(START_ADDR),)
# If the MACHINE is set to an option which does not support a variable start
# address, then error.
ifneq ($(filter $(MACHINE), apple2-system apple2enh-system),)
$(error You cannot change start address with this machine type)
ifeq ($(BUILD_TYPE),cc65)
export PATH := $(PATH):$(CC65_BIN)
# By default, use the a2 drivers. If the machine is one of the enhanced
# targets though, use the a2e drivers.
DRV_BASE_MACHINE=a2
BASE_MACHINE = apple2
ifneq ($(filter $(MACHINE), apple2enh apple2enh-dos33 apple2enh-system apple2enh-loader apple2enh-reboot),)
DRV_BASE_MACHINE=a2e
BASE_MACHINE = apple2enh
endif
CC65_VERSION := $(shell $(CC65) --version 2>&1 | grep '^cc65 V')
ifeq ($(CC65_VERSION),cc65 V2.13.3)
export CC65_SUPPORTS_APPLE_SINGLE=0
CC65_CREATE_DEP_ARG=--create-dep
CC65_LIST_ARG=-l
CC65_DRV_DIR=$(CC65_HOME)
MACHCONFIG= -t $(BASE_MACHINE)
ifeq ($(filter $(MACHINE), apple2 apple2enh),)
MACHCONFIG += -C $(MACHINE).cfg
endif
else
export CC65_SUPPORTS_APPLE_SINGLE=1
CC65_CREATE_DEP_ARG=--create-dep $(@:.o=.u)
CC65_LIST_ARG=-l $(@:.o=.lst)
CC65_DRV_DIR=$(CC65_HOME)/target/$(BASE_MACHINE)/drv
MACHCONFIG= -t $(BASE_MACHINE)
ifneq ($(filter $(MACHINE), apple2-system apple2enh-system),)
MACHCONFIG += -C $(BASE_MACHINE)-system.cfg
else
ifeq ($(PROJECT_TYPE),ca65)
MACHCONFIG += -C $(BASE_MACHINE)-asm.cfg
LDFLAGS += -u __EXEHDR__
else
MACHCONFIG += -C $(BASE_MACHINE).cfg
endif
endif
endif
ifneq ($(DRIVERS),)
SRCDIRS+=$(DRVDIR)
endif
C_SRCS=$(patsubst ./%, %, $(wildcard $(addsuffix /*.c, $(SRCDIRS))))
C_OBJS=$(C_SRCS:.c=.o)
C_DEPS=$(C_SRCS:.c=.u)
ASM_SRCS=$(patsubst ./%, %, $(wildcard $(addsuffix /*.s, $(SRCDIRS))))
ASM_OBJS=$(ASM_SRCS:.s=.o)
ASM_LSTS=$(ASM_SRCS:.s=.lst)
MAPFILE=$(PGM).map
ifneq ($(START_ADDR),)
# If the MACHINE is set to an option which does not support a variable
# start address, then error.
ifneq ($(filter $(MACHINE), apple2-system apple2enh-system),)
$(error You cannot change start address with this machine type)
endif
else
# If not set, then use the default for the config as per cc65
# documentation
ifneq ($(filter $(MACHINE), apple2 apple2-dos33 apple2enh apple2enh-dos33),)
START_ADDR=803
endif
ifneq ($(filter $(MACHINE), apple2-system apple2enh-system),)
START_ADDR=2000
endif
ifneq ($(filter $(MACHINE), apple2-loader apple2-reboot apple2enh-loader apple2enh-reboot),)
START_ADDR=800
endif
endif
LDFLAGS += --start-addr 0x$(START_ADDR)
ifneq ($(filter $(MACHINE), apple2 apple2enh apple2-dos33 apple2enh-dos33),)
EXECCMD=$(shell echo brun $(PGM) | tr '[a-z]' '[A-Z]')
endif
else
# If not set, then use the default for the config as per cc65 documentation
ifneq ($(filter $(MACHINE), apple2 apple2-dos33 apple2enh apple2enh-dos33),)
START_ADDR=803
endif
ifneq ($(filter $(MACHINE), apple2-system apple2enh-system),)
START_ADDR=2000
endif
ifneq ($(filter $(MACHINE), apple2-loader apple2-reboot apple2enh-loader apple2enh-reboot),)
START_ADDR=800
endif
endif
LDFLAGS += --start-addr 0x$(START_ADDR)
C_OBJS=
C_DEPS=
ifneq ($(filter $(MACHINE), apple2 apple2enh apple2-dos33 apple2enh-dos33),)
ASM_OBJS=
ASM_LSTS=
endif
ifeq ($(BUILD_TYPE),merlin)
ASM_SRCS=$(patsubst ./%, %, $(wildcard $(addsuffix /*.s, $(SRCDIRS))))
MAPFILE=_Output.txt
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
ifeq ($(BUILD_TYPE),basic)
MAPFILE=
EXECCMD=$(shell echo run $(PGM) | tr '[a-z]' '[A-Z]')
endif
MACHCONFIG= -t apple2
OBJS=$(C_OBJS) $(ASM_OBJS) $(BASIC_OBJS)
ifneq ($(filter $(MACHINE), apple2enh apple2apple2enh-dos33 apple2enh-system apple2enh-loader apple2enh-reboot),)
MACHCONFIG= -t apple2enh
endif
ALLTARGET=$(DISKIMAGE)
ifeq ($(filter $(MACHINE), apple2 apple2enh),)
MACHCONFIG += -C $(MACHINE).cfg
endif
.PHONY: build execute clean xcodefix loresgr hiresgr auxmem joystick mouse serial
.PHONY: build execute clean cleandrivers xcodefix
build: $(ALLTARGET)
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
$(PGM): $(OBJS)
make/errorFilter.sh $(CL65) $(MACHCONFIG) --mapfile $(MAPFILE) $(LDFLAGS) -o "$(PGM)" $(OBJS)
$(DISKIMAGE): $(PGM)
make/createDiskImage $(AC) $(MACHINE) "$(DISKIMAGE)" "$(PGM)" "$(START_ADDR)" $(COPYDIRS)
make/createDiskImage $(AC) $(MACHINE) "$(DISKIMAGE)" "$(PGM)" "$(START_ADDR)" $(BASIC_OBJS) $(COPYDIRS)
execute: $(DISKIMAGE)
osascript make/V2Make.scpt "$(CWD)" "$(PGM)" "$(CWD)/make/DevApple.vii" "$(EXECCMD)"
%.o: %.c
make/errorFilter.sh $(CL65) $(MACHCONFIG) $(CFLAGS) --create-dep -c -o $@ $<
sed -i .bak 's/\.s:/.o:/' $(@:.o=.u)
rm -f $(@:.o=.u).bak
%.tok: %.bas
make/bt $< $(BASICFLAGS) -o $@
%.o: %.s
make/errorFilter.sh $(CL65) $(MACHCONFIG) --cpu $(CPU) $(ASMFLAGS) -l -c -o $@ $<
ifneq ($(DRIVERS),)
cleandrivers:
rm -Rf "$(DRVDIR)"
$(OBJS): Makefile
else
cleandrivers:
endif
clean: genclean cleandrivers
rm -f "$(PGM)" $(OBJS) $(C_DEPS) $(MAPFILE) $(ASM_LSTS) "$(DISKIMAGE)"
cleanMacCruft:
rm -rf pkg
# 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)`
defaults write "$(CC65_PLUGIN_INFO)" $(XCODE_PLUGIN_COMPATIBILITY)s -array `defaults read "$(XCODE_INFO)" $(XCODE_PLUGIN_COMPATIBILITY)` || true
ifeq ($(BUILD_TYPE),basic)
# Build rules for BASIC projects
$(PGM): $(OBJS)
cp $(PGM).tok $(PGM)
$(OBJS): Makefile
endif
ifeq ($(BUILD_TYPE),merlin)
# Build rules for Merlin projects
$(PGM): $(ASM_SRCS) Makefile
$(MERLIN_BIN) -V $(MERLIN_LIB) linkscript.s
rm -f _FileInformation.txt
endif
ifeq ($(BUILD_TYPE),cc65)
# Build rules for cc65 projects
$(PGM): $(OBJS)
make/errorFilter.sh $(CL65) $(MACHCONFIG) --mapfile $(MAPFILE) $(LDFLAGS) -o "$(PGM)" $(OBJS)
$(OBJS): Makefile
%.o: %.c
make/errorFilter.sh $(CL65) $(MACHCONFIG) $(CFLAGS) $(CC65_CREATE_DEP_ARG) -c -o $@ $<
sed -i .bak 's/\.s:/.o:/' $(@:.o=.u)
rm -f $(@:.o=.u).bak
%.o: %.s
make/errorFilter.sh $(CL65) $(MACHCONFIG) --cpu $(CPU) $(ASMFLAGS) $(CC65_LIST_ARG) -c -o $@ $<
.PHONY: loresgr hiresgr auxmem joystick mouse serial
# 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
$(DRVDIR)/a2_lores_drv.s: $(CC65_DRV_DIR)/tgi/$(DRV_BASE_MACHINE).lo.tgi
mkdir -p $(DRVDIR)
$(CO65) --code-label _a2_lores_drv -o $@ $(CC65_HOME)/tgi/$(DRV_BASE_MACHINE).lo.tgi
$(CO65) --code-label _a2_lores_drv -o $@ $(CC65_DRV_DIR)/tgi/$(DRV_BASE_MACHINE).lo.tgi
$(DRVDIR)/a2_lores_drv.h:
mkdir -p $(DRVDIR)
@ -137,9 +218,9 @@ $(DRVDIR)/a2_lores_drv.h:
# 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
$(DRVDIR)/a2_hires_drv.s: $(CC65_DRV_DIR)/tgi/$(DRV_BASE_MACHINE).hi.tgi
mkdir -p $(DRVDIR)
$(CO65) --code-label _a2_hires_drv -o $@ $(CC65_HOME)/tgi/$(DRV_BASE_MACHINE).hi.tgi
$(CO65) --code-label _a2_hires_drv -o $@ $(CC65_DRV_DIR)/tgi/$(DRV_BASE_MACHINE).hi.tgi
$(DRVDIR)/a2_hires_drv.h:
mkdir -p $(DRVDIR)
@ -150,9 +231,9 @@ $(DRVDIR)/a2_hires_drv.h:
# 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
$(DRVDIR)/a2_auxmem_drv.s: $(CC65_DRV_DIR)/emd/$(DRV_BASE_MACHINE).auxmem.emd
mkdir -p $(DRVDIR)
$(CO65) --code-label _a2_auxmem_drv -o $@ $(CC65_HOME)/emd/$(DRV_BASE_MACHINE).auxmem.emd
$(CO65) --code-label _a2_auxmem_drv -o $@ $(CC65_DRV_DIR)/emd/$(DRV_BASE_MACHINE).auxmem.emd
$(DRVDIR)/a2_auxmem_drv.h:
mkdir -p $(DRVDIR)
@ -163,9 +244,9 @@ $(DRVDIR)/a2_auxmem_drv.h:
# 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
$(DRVDIR)/a2_joystick_drv.s: $(CC65_DRV_DIR)/joy/$(DRV_BASE_MACHINE).stdjoy.joy
mkdir -p $(DRVDIR)
$(CO65) --code-label _a2_joystick_drv -o $@ $(CC65_HOME)/joy/$(DRV_BASE_MACHINE).stdjoy.joy
$(CO65) --code-label _a2_joystick_drv -o $@ $(CC65_DRV_DIR)/joy/$(DRV_BASE_MACHINE).stdjoy.joy
$(DRVDIR)/a2_joystick_drv.h:
mkdir -p $(DRVDIR)
@ -176,9 +257,9 @@ $(DRVDIR)/a2_joystick_drv.h:
# 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
$(DRVDIR)/a2_mouse_drv.s: $(CC65_DRV_DIR)/mou/$(DRV_BASE_MACHINE).stdmou.mou
mkdir -p $(DRVDIR)
$(CO65) --code-label _a2_mouse_drv -o $@ $(CC65_HOME)/mou/$(DRV_BASE_MACHINE).stdmou.mou
$(CO65) --code-label _a2_mouse_drv -o $@ $(CC65_DRV_DIR)/mou/$(DRV_BASE_MACHINE).stdmou.mou
$(DRVDIR)/a2_mouse_drv.h:
mkdir -p $(DRVDIR)
@ -189,14 +270,16 @@ $(DRVDIR)/a2_mouse_drv.h:
# 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
$(DRVDIR)/a2_serial_drv.s: $(CC65_DRV_DIR)/ser/$(DRV_BASE_MACHINE).ssc.ser
mkdir -p $(DRVDIR)
$(CO65) --code-label _a2_serial_drv -o $@ $(CC65_HOME)/ser/$(DRV_BASE_MACHINE).ssc.ser
$(CO65) --code-label _a2_serial_drv -o $@ $(CC65_DRV_DIR)/ser/$(DRV_BASE_MACHINE).ssc.ser
$(DRVDIR)/a2_serial_drv.h:
mkdir -p $(DRVDIR)
echo '#include <serial.h>' > $@
echo 'extern char a2_serial_drv;' >> $@
endif
-include $(C_DEPS)