# Apple IIgs build rules. # # Uses GoldenGate's iix to drive ORCA/C 2.1.0 + ORCA Linker. The # toolchains/iigs/iix-build.sh wrapper handles ORCA's case-sensitivity # quirks (lowercase .a/.root/.sym vs linker demands for uppercase), # multi-source compile/link, and pragma injection for include paths # and the stdint/stdbool shim headers. include $(dir $(lastword $(MAKEFILE_LIST)))/common.mk PLATFORM := iigs BUILD := $(REPO_DIR)/build/$(PLATFORM) BINDIR := $(BUILD)/bin PORT_C_SRCS_ALL := $(wildcard $(SRC_PORT)/iigs/*.c) # audio.c is the no-op stub linked into every demo. audio_full.c is the # real implementation (NewHandle / fopen / JSL trampoline) and links # only into AUDIO -- the IIgs build is monolithic, so pulling Memory # Manager + ORCA stdio into every binary blows the linker's # "Expression too complex" budget. The two files define the same # halAudio* symbols; iigs/audio.c is filtered out of the AUDIO source # set, audio_full.c is filtered out of the everyone-else set. PORT_C_SRCS := $(filter-out %/audio_full.c, $(PORT_C_SRCS_ALL)) PORT_C_SRCS_AUDIO := $(filter-out %/audio.c, $(PORT_C_SRCS_ALL)) # IIgs uses NTPstreamsound for SFX, not the libxmp+overlay combo that # DOS and ST share, so src/core/audioSfxMix.c is unused here. Filter # it out so the ORCA Linker doesn't pull its dead code into every # IIgs binary (the monolithic-link budget is tight). CORE_C_SRCS_IIGS := $(filter-out %/audioSfxMix.c, $(CORE_C_SRCS)) # Sprite codegen: 65816 emitter + cross-platform compile dispatch. CODEGEN_SRCS := $(REPO_DIR)/src/codegen/spriteEmitIigs.c \ $(REPO_DIR)/src/codegen/spriteCompile.c LIB_SRCS := $(CORE_C_SRCS_IIGS) $(PORT_C_SRCS) $(CODEGEN_SRCS) LIB_SRCS_AUDIO := $(CORE_C_SRCS_IIGS) $(PORT_C_SRCS_AUDIO) $(CODEGEN_SRCS) # NinjaTrackerPlus replayer. Assembled with Merlin32 from the staged # source at toolchains/iigs/ntp/ninjatrackerplus.s. Output is a 34 KB # raw 65816 binary that the IIgs audio HAL loads at runtime via # Memory Manager into a fixed-bank handle. NTP source is bank-internal # (no JSL/JML cross-bank jumps) so the player works at any bank-start # load address even though it was assembled with `org $0F0000`. NTP_SRC := $(REPO_DIR)/toolchains/iigs/ntp/ninjatrackerplus.s NTP_BIN := $(BUILD)/audio/ntpplayer.bin NTP_HEADER := $(BUILD)/audio/ntpplayer_data.h IIGS_MERLIN := $(REPO_DIR)/toolchains/iigs/merlin32/bin/merlin32 HELLO_SRC := $(EXAMPLES)/hello/hello.c HELLO_BIN := $(BINDIR)/HELLO PATTERN_SRC := $(EXAMPLES)/pattern/pattern.c PATTERN_BIN := $(BINDIR)/PATTERN KEYS_SRC := $(EXAMPLES)/keys/keys.c KEYS_BIN := $(BINDIR)/KEYS JOY_SRC := $(EXAMPLES)/joy/joy.c JOY_BIN := $(BINDIR)/JOY SPRITE_SRC := $(EXAMPLES)/sprite/sprite.c SPRITE_BIN := $(BINDIR)/SPRITE AUDIO_SRC := $(EXAMPLES)/audio/audio.c AUDIO_BIN := $(BINDIR)/AUDIO AUDIO_MOD := $(REPO_DIR)/assets/test.mod AUDIO_SFX := $(REPO_DIR)/assets/test.sfx AUDIO_NTP := $(BUILD)/audio/test.ntp AUDIO_HEADER := $(BUILD)/audio/test_assets.h JOEYMOD := $(REPO_DIR)/tools/joeymod/joeymod DISK_IMG := $(BINDIR)/joey.2mg IIGS_PACKAGE := $(REPO_DIR)/toolchains/iigs/package-disk.sh IIX_INCLUDES := \ -I $(IIGS_INCLUDE_SHIM) \ -I $(INCLUDE_DIR) \ -I $(INCLUDE_DIR)/joey \ -I $(SRC_CORE) \ -I $(REPO_DIR)/src/codegen .PHONY: all iigs iigs-disk clean-iigs all iigs: $(HELLO_BIN) $(PATTERN_BIN) $(KEYS_BIN) $(JOY_BIN) $(SPRITE_BIN) $(AUDIO_BIN) $(NTP_BIN): $(NTP_SRC) $(IIGS_MERLIN) @mkdir -p $(dir $@) @cp $(NTP_SRC) $(BUILD)/audio/ninjatrackerplus.s cd $(BUILD)/audio && $(IIGS_MERLIN) . ninjatrackerplus.s mv $(BUILD)/audio/ntpplayer $@ # Bake the NTP replayer bytes into a C header so audio_full.c can link # the player into the AUDIO binary instead of fopen'ing a separate # NTPPLAYER.BIN at runtime. NTP is bank-internal / PIC, so the linked # bytes still BlockMove cleanly into the Memory Manager handle the HAL # allocates. Same xxd-i pattern as test_assets.h. $(NTP_HEADER): $(NTP_BIN) @mkdir -p $(dir $@) @echo "// Generated by make/iigs.mk -- NinjaTrackerPlus replayer bytes." > $@ @echo "#ifndef JOEYLIB_NTPPLAYER_DATA_H" >> $@ @echo "#define JOEYLIB_NTPPLAYER_DATA_H" >> $@ @printf "static const unsigned char gNtpPlayerBytes[] = {\n" >> $@ @xxd -i < $(NTP_BIN) >> $@ @printf "};\nstatic const unsigned int gNtpPlayerBytes_len = %d;\n" $$(wc -c < $(NTP_BIN)) >> $@ @echo "#endif" >> $@ # iix-build.sh takes MAIN.c first, then EXTRA sources (compiled with # #pragma noroot). The example source supplies main(); libjoey sources # are the extras. The chtyp post-step tags the output as GS/OS S16 # ($B3) so GS/OS recognizes it as launchable; the file-type lives in # a user.com.apple.FinderInfo xattr that iix and profuse preserve. $(HELLO_BIN): $(HELLO_SRC) $(LIB_SRCS) $(IIGS_BUILD) @mkdir -p $(dir $@) $(IIGS_BUILD) $(IIX_INCLUDES) -o $@ $(HELLO_SRC) $(LIB_SRCS) $(IIGS_IIX) chtyp -t S16 $@ $(PATTERN_BIN): $(PATTERN_SRC) $(LIB_SRCS) $(IIGS_BUILD) @mkdir -p $(dir $@) $(IIGS_BUILD) $(IIX_INCLUDES) -o $@ $(PATTERN_SRC) $(LIB_SRCS) $(IIGS_IIX) chtyp -t S16 $@ $(KEYS_BIN): $(KEYS_SRC) $(LIB_SRCS) $(IIGS_BUILD) @mkdir -p $(dir $@) $(IIGS_BUILD) $(IIX_INCLUDES) -o $@ $(KEYS_SRC) $(LIB_SRCS) $(IIGS_IIX) chtyp -t S16 $@ $(JOY_BIN): $(JOY_SRC) $(LIB_SRCS) $(IIGS_BUILD) @mkdir -p $(dir $@) $(IIGS_BUILD) $(IIX_INCLUDES) -o $@ $(JOY_SRC) $(LIB_SRCS) $(IIGS_IIX) chtyp -t S16 $@ # Sprite demo uses ORCA-C large memory model (-b) so pointers are # 32-bit and the codegen-arena JSL stub can call cross-bank into the # arena. Without -b, ORCA-C's 16-bit pointers would lose the bank # byte and the stub would JSL into bank 0 (system memory) -> crash. $(SPRITE_BIN): $(SPRITE_SRC) $(LIB_SRCS) $(IIGS_BUILD) @mkdir -p $(dir $@) $(IIGS_BUILD) -b $(IIX_INCLUDES) -o $@ $(SPRITE_SRC) $(LIB_SRCS) $(IIGS_IIX) chtyp -t S16 $@ # Convert the cross-platform .MOD asset to NinjaTrackerPlus runtime # format via joeymod (which shells out to ntpconverter.php). Without # php-cli the conversion is skipped; in that case the IIgs disk just # won't carry a TEST.NTP and the audio demo will report "missing data # file" at runtime instead of crashing on bad MOD magic. HAVE_PHP := $(shell command -v php >/dev/null 2>&1 && echo 1) ifeq ($(HAVE_PHP),1) $(AUDIO_NTP): $(AUDIO_MOD) $(JOEYMOD) @mkdir -p $(dir $@) $(JOEYMOD) $< $@ AUDIO_DATA_FILES := $(AUDIO_NTP) $(AUDIO_SFX) else $(info iigs: php-cli not installed -- AUDIO demo will ship without TEST.NTP; install php-cli for real IIgs audio playback) AUDIO_DATA_FILES := $(AUDIO_SFX) endif $(AUDIO_BIN): $(AUDIO_SRC) $(LIB_SRCS_AUDIO) $(NTP_HEADER) $(IIGS_BUILD) @mkdir -p $(dir $@) $(IIGS_BUILD) -b $(IIX_INCLUDES) -I $(dir $(NTP_HEADER)) -I $(EXAMPLES)/audio -o $@ $(AUDIO_SRC) $(LIB_SRCS_AUDIO) $(IIGS_IIX) chtyp -t S16 $@ # Assemble an 800KB ProDOS 2img containing the examples, ready to # mount in GSplus alongside a GS/OS boot volume. iigs-disk: $(DISK_IMG) $(DISK_IMG): $(HELLO_BIN) $(PATTERN_BIN) $(KEYS_BIN) $(JOY_BIN) $(SPRITE_BIN) $(AUDIO_BIN) $(AUDIO_DATA_FILES) $(IIGS_PACKAGE) @mkdir -p $(dir $@) $(IIGS_PACKAGE) $@ $(HELLO_BIN) $(PATTERN_BIN) $(KEYS_BIN) $(JOY_BIN) $(SPRITE_BIN) $(AUDIO_BIN) -- $(AUDIO_DATA_FILES) clean-iigs: rm -rf $(BUILD)