Add a CDA target for the Merlin assembler

This commit is contained in:
Jeremy Rand 2019-07-17 19:42:12 -05:00
parent 6dbfdabb6e
commit 5fec9448c5
8 changed files with 605 additions and 24 deletions

107
Makefile.merlin Normal file
View File

@ -0,0 +1,107 @@
#
# Makefile
# Apple //GS Build Engine for ORCA
#
include make/head.mk
# Customize this file to control what kind of project you are working on,
# where to find files, etc.
# The name of your system or binary file to build goes here:
PGM=___PACKAGENAME___
# This tells the build engine that your assembler is Merlin. You should
# not change this (afterall, are you going to change all of your assembly
# to ORCA/M also?)
ASSEMBLER=merlin
# Set the target type you would like to build. The options are:
# shell - A shell command for ORCA, GNO or other GS shell
# desktop - A full desktop application
# cda - A classic desk accessory
# cdev - A control panel device
# nba - A HyperStudio new button action
# nda - A new desk accessory
# xcmd - A HyperCard XCMD or XCFN
#
# TARGETTYPE=shell
# TARGETTYPE=desktop
# TARGETTYPE=cda
# TARGETTYPE=cdev
# TARGETTYPE=nba
# TARGETTYPE=nda
# TARGETTYPE=xcmd
# Add any other directories where you are putting C or assembly source
# files to this list. Note that you must manually add all source files
# to the linkscript.s file. All this does is help the build system
# see what files it should consider important to deciding whether to do
# a re-build.
# SRCDIRS+=
# Add any arguments you want passed to the resource compiler to this variable:
REZFLAGS+=
# Uncomment the following line if you have installed rlint as found here:
# https://github.com/ksherlock/rlint/releases
# Assuming that it is in the path that ORCA searches (the Utilities directory is
# probably a good choice), you can just leave the value unchanged. If you have
# put the rlint somewhere weird, you can set this to the correct path
# RLINT_PATH=rlint
# If you want to copy one or more files or directories to the target disk
# image, add the root directory to this variable. Any directories under
# the source directory which don't exist in the target disk image will be
# created. All files will be copied from the source to the target using
# the same path from the source.
#
# For example, if you set COPYDIRS to dir and in your project you have
# the following files:
# dir/System/mySystemFile
# dir/newDir/anotherFile
# Then, during the copy phase, mySystemFile will be copied into the System
# folder and a folder newDir will be created and anotherFile will be copied
# into there.
COPYDIRS=
# By default, the build expects that you have GSplus in the path:
# /Applications/GSplus.app/Contents/MacOS/gsplus
# If you have it in a different location, specify that here.
# GSPLUS=/Applications/GSplus.app/Contents/MacOS/gsplus
# By default, the build expects that you have GSport in the path:
# /Applications/GSport/GSport.app/Contents/MacOS/GSport
# If you have it in a different location, specify that here.
# GSPORT=/Applications/GSport/GSport.app/Contents/MacOS/GSport
# For a desktop application, it can operate in 640x200 or 320x200
# resolution. This setting is used to define which horizontal
# resolution you want to use for a desktop application. Other
# target types ignore this value.
# DESKTOP_RES_MODE=640
# For a desktop application, it can support opening and printing
# files based on paths sent to it by the message center. This
# option controls if that is or is not supported in the
# application (note: only the C desktop template supports message
# center today)
# MESSAGE_CENTER=0
# Add any rules you want to execute before any compiles or assembly
# 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
# add rules in genclean to remove those generated files when you
# clean your build.
genclean:
# Do not change anything else below here...
include make/tail.mk

View File

@ -10,6 +10,12 @@ export ORCA=$(ORCA_BINDIR)/orca
TARGETTYPE=shell
ASSEMBLER=orcam
MERLIN_DIR=/usr/local
MERLIN_BIN=$(MERLIN_DIR)/bin/Merlin32
MERLIN_LIB=$(MERLIN_DIR)/lib/Merlin
SRCDIRS=.
# Check for Xcode build variables for the locations of build outputs and fall back
@ -58,6 +64,7 @@ CHTYP=$(ORCA) chtyp
RM=rm -f
CP=cp
MV=mv
MKDIR=mkdir -p
DESKTOP_RES_MODE=640

View File

@ -19,9 +19,9 @@ ifeq ($(TARGETTYPE),shell)
else ifeq ($(TARGETTYPE),desktop)
FILETYPE=s16
ifeq ($(MESSAGE_CENTER),1)
AUXTYPE=-a 0x0000db07
AUXTYPE=-a 0x0000db07
else
AUXTYPE=-a 0x0000db03
AUXTYPE=-a 0x0000db03
endif
CFLAGS+=-dMESSAGE_CENTER=$(MESSAGE_CENTER)
REZFLAGS+=rez='-d DESKTOP_RES_MODE=$(DESKTOP_RES_MODE)'
@ -45,20 +45,24 @@ else ifeq ($(TARGETTYPE),xcmd)
BUILDTARGET=$(TARGETDIR)/$(PGM)
endif
ifeq ($(wildcard $(ROOTCFILE)),)
ROOTCFILE=
endif
C_ROOTS=$(patsubst %.c, $(OBJDIR)/%.root, $(ROOTCFILE))
C_SRCS+=$(filter-out $(ROOTCFILE), $(patsubst ./%, %, $(wildcard $(addsuffix /*.c, $(SRCDIRS)))))
C_OBJS=$(patsubst %.c, $(OBJDIR)/%.a, $(C_SRCS))
C_DEPS=$(patsubst %.c, $(OBJDIR)/%.d, $(ROOTCFILE)) $(patsubst %.c, $(OBJDIR)/%.d, $(C_SRCS))
ASM_SRCS=$(patsubst ./%, %, $(wildcard $(addsuffix /*.s, $(SRCDIRS))))
ASM_MACROS=$(patsubst %.s, $(OBJDIR)/%.macros, $(ASM_SRCS))
ASM_DEPS=$(patsubst %.s, $(OBJDIR)/%.macros.d, $(ASM_SRCS))
ASM_ROOTS=$(patsubst %.s, $(OBJDIR)/%.ROOT, $(ASM_SRCS))
ASM_OBJS=$(patsubst %.s, $(OBJDIR)/%.a, $(ASM_SRCS))
ifeq ($(ASSEMBLER),orcam)
ASM_MACROS=$(patsubst %.s, $(OBJDIR)/%.macros, $(ASM_SRCS))
ASM_DEPS=$(patsubst %.s, $(OBJDIR)/%.macros.d, $(ASM_SRCS))
ASM_ROOTS=$(patsubst %.s, $(OBJDIR)/%.ROOT, $(ASM_SRCS))
ASM_OBJS=$(patsubst %.s, $(OBJDIR)/%.a, $(ASM_SRCS))
ifeq ($(wildcard $(ROOTCFILE)),)
ROOTCFILE=
endif
C_ROOTS=$(patsubst %.c, $(OBJDIR)/%.root, $(ROOTCFILE))
C_SRCS+=$(filter-out $(ROOTCFILE), $(patsubst ./%, %, $(wildcard $(addsuffix /*.c, $(SRCDIRS)))))
C_OBJS=$(patsubst %.c, $(OBJDIR)/%.a, $(C_SRCS))
C_DEPS=$(patsubst %.c, $(OBJDIR)/%.d, $(ROOTCFILE)) $(patsubst %.c, $(OBJDIR)/%.d, $(C_SRCS))
endif
REZ_SRCS=$(patsubst ./%, %, $(wildcard $(addsuffix /*.rez, $(SRCDIRS))))
REZ_DEPS=$(patsubst %.rez, $(OBJDIR)/%.rez.d, $(REZ_SRCS))
@ -107,10 +111,11 @@ cleanMacCruft:
ifeq ($(BINTARGET),)
ifeq ($(ASSEMBLER),orcam)
# This is a standard build where we generate the resources if any and then link
# the binary over that same file creating the resource fork first and the data
# fork second.
# This is a standard ORCA build where we generate the resources if any and
# then link the binary over that same file creating the resource fork first
# and the data fork second.
$(TARGETDIR)/$(PGM): $(BUILD_OBJS)
ifneq ($(REZ_OBJS),)
$(RM) $(TARGETDIR)/$(PGM)
@ -119,15 +124,46 @@ endif
$(LINK) $(LDFLAGS) $(BUILD_OBJS_NOSUFFIX) --keep=$(TARGETDIR)/$(PGM)
$(CHTYP) -t $(FILETYPE) $(AUXTYPE) $(TARGETDIR)/$(PGM)
endif
ifeq ($(ASSEMBLER),merlin)
# This is a standard Merlin build where we generate the resources if any and
# then link the binary over that same file creating the resource fork first
# and the data fork second.
$(TARGETDIR)/$(PGM): $(BUILD_OBJS) $(ASM_SRCS)
$(RM) $(TARGETDIR)/$(PGM)
$(MERLIN_BIN) -V $(MERLIN_LIB) linkscript.s
$(MV) $(PGM) $(TARGETDIR)/$(PGM)
ifneq ($(REZ_OBJS),)
$(CP) $(REZ_OBJS)/rsrc $(TARGETDIR)/$(PGM)/rsrc
endif
$(CHTYP) -t $(FILETYPE) $(AUXTYPE) $(TARGETDIR)/$(PGM)
endif
else
# This is a special build for CDevs (maybe others also?) where we build the binary
# into a $(PGM).bin file and then build the resources into the $(PGM) target. The
# resource compile will read the $(PGM).bin binary and load it into the resources
# also.
ifeq ($(ASSEMBLER),orcam)
# This is a special build for CDevs under ORCA where we build the binary into
# a $(PGM).bin file and then build the resources into the $(PGM) target. The
# resource compile will read the $(PGM).bin binary and load it into the
# resources also.
$(BINTARGET): $(BUILD_OBJS)
$(LINK) $(LDFLAGS) $(BUILD_OBJS_NOSUFFIX) --keep=$(BINTARGET)
endif
ifeq ($(ASSEMBLER),merlin)
# This is a special build for CDevs under Merlin where we build the binary into
# a $(PGM).bin file and then build the resources into the $(PGM) target. The
# resource compile will read the $(PGM).bin binary and load it into the
# resources # also.
$(BINTARGET): $(BUILD_OBJS) $(ASM_SRCS)
$(MERLIN_BIN) -V $(MERLIN_LIB) linkscript.s
endif
$(REZ_OBJS): $(BINTARGET)
$(TARGETDIR)/$(PGM): $(REZ_OBJS)

View File

@ -0,0 +1,203 @@
<?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>Nodes</key>
<array>
<string>main.s</string>
<string>linkscript.s</string>
<string>Makefile</string>
<string>make/config.txt</string>
<string>make/createDiskImage</string>
<string>make/head.mk</string>
<string>make/launchEmulator</string>
<string>make/orca-asm</string>
<string>make/orca-cc</string>
<string>make/orca-rez</string>
<string>make/system601.2mg</string>
<string>make/tail.mk</string>
<string>../___PACKAGENAME___.xcodeproj/xcshareddata/xcschemes/___PACKAGENAME___.xcscheme</string>
</array>
<key>Definitions</key>
<dict>
<key>main.s</key>
<dict>
<key>Path</key>
<string>main.s</string>
</dict>
<key>linkscript.s</key>
<dict>
<key>Path</key>
<string>linkscript.s</string>
</dict>
<key>make/config.txt</key>
<dict>
<key>Group</key>
<string>make</string>
<key>Path</key>
<string>make/config.txt</string>
</dict>
<key>make/createDiskImage</key>
<dict>
<key>Group</key>
<string>make</string>
<key>Path</key>
<string>make/createDiskImage</string>
</dict>
<key>make/head.mk</key>
<dict>
<key>Group</key>
<string>make</string>
<key>Path</key>
<string>make/head.mk</string>
</dict>
<key>make/launchEmulator</key>
<dict>
<key>Group</key>
<string>make</string>
<key>Path</key>
<string>make/launchEmulator</string>
</dict>
<key>make/orca-asm</key>
<dict>
<key>Group</key>
<string>make</string>
<key>Path</key>
<string>make/orca-asm</string>
</dict>
<key>make/orca-cc</key>
<dict>
<key>Group</key>
<string>make</string>
<key>Path</key>
<string>make/orca-cc</string>
</dict>
<key>make/orca-rez</key>
<dict>
<key>Group</key>
<string>make</string>
<key>Path</key>
<string>make/orca-rez</string>
</dict>
<key>make/system601.2mg</key>
<dict>
<key>Group</key>
<string>make</string>
<key>Path</key>
<string>make/system601.2mg</string>
</dict>
<key>make/tail.mk</key>
<dict>
<key>Group</key>
<string>make</string>
<key>Path</key>
<string>make/tail.mk</string>
</dict>
<key>Makefile</key>
<dict>
<key>Path</key>
<string>Makefile</string>
</dict>
<key>../___PACKAGENAME___.xcodeproj/xcshareddata/xcschemes/___PACKAGENAME___.xcscheme</key>
<dict>
<key>Group</key>
<array>
<string>Supporting Files</string>
</array>
<key>Path</key>
<string>___PACKAGENAME___.xcscheme</string>
</dict>
</dict>
<key>Kind</key>
<string>Xcode.Xcode3.ProjectTemplateUnitKind</string>
<key>Identifier</key>
<string>com.halcyontouch.apple2gsMerlinCDA</string>
<key>Ancestors</key>
<array>
<string>com.apple.dt.unit.externalBuildSystem</string>
</array>
<key>Concrete</key>
<true/>
<key>Description</key>
<string>This template creates an Apple IIgs Merlin code project to build a classic desk accessory. The project starts with a single assembly file which you can modify. You can also add more assembly files as you may like.</string>
<key>Options</key>
<array/>
<key>Targets</key>
<array>
<dict>
<key>TargetType</key>
<string>Legacy</string>
<key>TargetIdentifier</key>
<string>com.apple.dt.cocoaLegacyTarget</string>
<key>BuildToolPath</key>
<string>___VARIABLE_buildToolPath___</string>
<key>BuildToolArgsString</key>
<string>-C ___PACKAGENAME___ $(ACTION)</string>
<key>SharedSettings</key>
<dict>
<key>OTHER_CFLAGS</key>
<string></string>
<key>OTHER_LDFLAGS</key>
<string></string>
</dict>
<key>Configurations</key>
<dict>
<key>Debug</key>
<dict>
<key>DEBUGGING_SYMBOLS</key>
<string>YES</string>
<key>GCC_GENERATE_DEBUGGING_SYMBOLS</key>
<string>YES</string>
<key>GCC_OPTIMIZATION_LEVEL</key>
<string>0</string>
</dict>
<key>Release</key>
<dict/>
</dict>
</dict>
<dict>
<key>ProductType</key>
<string>com.apple.product-type.tool</string>
<key>TargetIdentifier</key>
<string>com.apple.dt.commandLineToolTarget</string>
<key>Name</key>
<string>doNotBuild</string>
<key>SharedSettings</key>
<dict>
<key>PRODUCT_NAME</key>
<string>doNotBuild</string>
<key>GCC_PREPROCESSOR_DEFINITIONS</key>
<string>inline(X,Y)=""
extended=double
pascal=""</string>
<key>HEADER_SEARCH_PATHS</key>
<string>$GOLDEN_GATE/Libraries/ORCACDefs
~/Library/GoldenGate/Libraries/ORCACDefs
/Library/GoldenGate/Libraries/ORCACDefs
~/GoldenGate/Libraries/ORCACDefs</string>
</dict>
<key>BuildPhases</key>
<array>
<dict>
<key>Class</key>
<string>Sources</string>
</dict>
<dict>
<key>Class</key>
<string>Frameworks</string>
</dict>
<dict>
<key>Class</key>
<string>CopyFiles</string>
<key>DstPath</key>
<string>/usr/share/man/man1/</string>
<key>DstSubfolderSpec</key>
<string>0</string>
<key>RunOnlyForDeploymentPostprocessing</key>
<string>YES</string>
</dict>
</array>
</dict>
</array>
</dict>
</plist>

View File

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9D0B917C1F526C2D004D7E0B"
BuildableName = "___PACKAGENAME___"
BlueprintName = "___PACKAGENAME___"
ReferencedContainer = "container:___PACKAGENAME___.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<PathRunnable
runnableDebuggingMode = "0"
FilePath = "/usr/bin/make">
</PathRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9D0B917C1F526C2D004D7E0B"
BuildableName = "___PACKAGENAME___"
BlueprintName = "___PACKAGENAME___"
ReferencedContainer = "container:___PACKAGENAME___.xcodeproj">
</BuildableReference>
</MacroExpansion>
<CommandLineArguments>
<CommandLineArgument
argument = "-C"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "$PROJECT_DIR/___PACKAGENAME___"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "TARGET_BUILD_DIR=$TARGET_BUILD_DIR"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "DERIVED_SOURCES_DIR=$DERIVED_SOURCES_DIR"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "OBJECT_FILE_DIR=$OBJECT_FILE_DIR"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "execute"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9D0B917C1F526C2D004D7E0B"
BuildableName = "___PACKAGENAME___"
BlueprintName = "___PACKAGENAME___"
ReferencedContainer = "container:___PACKAGENAME___.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,18 @@
*
* ___FILENAME___
* ___PROJECTNAME___
*
* Created by ___FULLUSERNAME___ on ___DATE___.
* ___COPYRIGHT___
*
dsk ___PROJECTNAME___
typ $B9
xpl
asm main.s
ds 0
knd #$1100
ali None
LNA ___PROJECTNAME___.S16
sna main

View File

@ -0,0 +1,93 @@
*
* ___FILENAME___
* ___PROJECTNAME___
*
* Created by ___FULLUSERNAME___ on ___DATE___.
* ___COPYRIGHT___
*
]XCODESTART ; Keep this at the start and put your code after this
mx %00
use 4/Util.Macs
use 4/Text.Macs
str '___PROJECTNAME___'
adrl startCda
adrl shutdownCda
startCda
phb
phk
plb
pha
pha
pha
_GetInputDevice
pha
pha
_GetInGlobals
pha
pha
pha
_GetOutputDevice
pha
pha
_GetOutGlobals
PushLong #0
PushWord #3
_SetInputDevice
PushWord #$7f
PushWord #0
_SetInGlobals
PushLong #0
PushWord #3
_SetOutputDevice
PushWord #$ff
PushWord #$80
_SetOutGlobals
PushWord #0
_InitTextDev
PushWord #1
_InitTextDev
PushWord #$0c
_WriteChar
PushLong #message
_WriteCString
pha
PushWord #0
_ReadChar
pla
_SetOutGlobals
_SetOutputDevice
_SetInGlobals
_SetInputDevice
~InitTextDev #0
~InitTextDev #1
plb
rtl
shutdownCda
rtl
message
asc 'Hello, world!',0d,0d,' Press ENTER to quit...',00
]XCODEEND ; Keep this at the end and put your code above this

View File

@ -11,6 +11,7 @@ PROJECTS=/tmp/projects.$$
cat > $PROJECTS << EOF
cda:orca:ORCAC Classic Desk Accessory:0:0
cda:orca:ORCAM Classic Desk Accessory:0:0
cda:merlin:Merlin Classic Desk Accessory:0:0
cdev:orca:ORCAC Control Panel:0:0
cdev:orca:ORCAM Control Panel:0:0
desktop:orca:ORCAC Desktop Application:1:1
@ -30,9 +31,15 @@ do
SUPPORTS_RES_MODE=`echo $PROJECT | awk -F: '{print $4}'`
SUPPORTS_MESSAGE_CENTER=`echo $PROJECT | awk -F: '{print $5}'`
sed "
/^# TARGETTYPE=${PROJECT_TYPE}/s/^# //
/^# export ORCA=.*\/${SHELL_TYPE}$/s/^# //" Makefile > "${TMPDIR}/Templates/Apple IIgs/${PROJECT_NAME}.xctemplate/Makefile"
if [ $SHELL_TYPE = merlin ]
then
sed "
/^# TARGETTYPE=${PROJECT_TYPE}/s/^# //" Makefile.merlin > "${TMPDIR}/Templates/Apple IIgs/${PROJECT_NAME}.xctemplate/Makefile"
else
sed "
/^# TARGETTYPE=${PROJECT_TYPE}/s/^# //
/^# export ORCA=.*\/${SHELL_TYPE}$/s/^# //" Makefile > "${TMPDIR}/Templates/Apple IIgs/${PROJECT_NAME}.xctemplate/Makefile"
fi
if [ "$SUPPORTS_RES_MODE" -eq 1 ]
then