joeylib2/make/examples.mk

238 lines
12 KiB
Makefile

# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
# See LICENSE.md for license information.
# SPDX-License-Identifier: MIT
#
# JoeyLib's own example programs, described for make/programs.mk (which
# lists what each variable means). Every port's makefile includes this file,
# then make/programs.mk, which makes each port's rules for them.
#
# Worth knowing which ones the gates use:
# UBER the golden-hash vehicle: every public op, a hash per op, which
# tools/diff-uber-hashes compares against tests/goldens/uber (the
# X68000 against the IIgs's, DVX against the DOS port's: the same
# stage). UBERPROB is UBER with its UBER_PROBE rows.
# PATTERN the SCB acceptance vehicle: 8 bands of 25 lines with 8 gradient
# palettes, so a misplaced band boundary is immediately visible.
# AUDIO every audio path: chip music with noise drums, MOD and SFX
# (ADPCM on the X68000), a raw-format stream and a noise sweep.
# AUDIOPRB is AUDIO pressing its own keys, for the IIgs,
# X68000 and PSP gates.
# KEYS the input and mouse vehicle: key predicates, the typed line
# (jlInputGetChar) and its verification row.
# SERIAL the serial gates' echo program.
# TILEBANK the tile-bank gates' program: this port's .tbk bake loaded both
# ways and pixel-checked, every other target's bake refused.
# SERMOUSE X68000: the serial + mouse gate's program: streams both ways on
# the RS-232C port (SCC channel A) while the mouse (channel B)
# moves.
# SCB X68000: the SCB gate's program: all 16 palettes, 147 palette
# changes a frame (every line for 128 of them), for the raster
# interrupt that reloads the text plane's one palette as the beam
# scans.
# PALPROBE Amiga: the palette gate's program: how fast palette and SCB
# changes reach the screen through the copper, and a held screen
# of bands to check that they reach it right.
# SERSLOT ST: SERTEST opening JL_SERIAL_SLOT unit 2 -- a Mega STe's SCC
# channel B through Bconmap -- for verify-atarist-serial-slot.sh.
# SERFAST Win16: SERTEST at 115200 for the throughput and loss gate,
# verify-win16-serial-fast.sh.
# FASTRAM Amiga: the Fast RAM gate's program: a surface made once chip
# RAM has run out draws and copies as a chip one does.
# WBLAUNCH Amiga: the icon gate's program: a program's icon read and
# drawn by icon.library, and the program started from it the way
# Workbench starts a tool.
# AUDPAR the audio conformance gate's program: one logged timeline of
# tones, voice and noise steps, sound effects, a module's end
# and tick rates, which every port must play alike.
PROGRAMS := HELLO PATTERN DRAW KEYS SERIAL SERTEST SERMOUSE SAVE TILEBANK SCB JOY SPRITE SCROLL AUDIO UBER ADV ADV2
TEST_PROGRAMS := SCCPROBE SERLOSS SERLOSSS SERSLOT SERFAST DIRTYMRK UBERPROB AUDIOPRB AUDPAR PALPROBE FASTRAM WBLAUNCH
# Whose these are, as a project names its own: on DVX the vendor folder
# they install in and their author (make/dvx.mk), on macOS the start of
# their apps' identifiers (make/macos.mk). DVX's help and resource texts
# call them JoeyLib examples.
DVX_VENDOR := kpunch
DVX_AUTHOR := Scott Duensing
DVX_KIND := JoeyLib example
MACOS_ID_PREFIX := com.kangaroopunch.joeylib
# The IIgs build has never included HELLO.
HELLO_SRCS := $(EXAMPLES)/hello/hello.c
HELLO_PORTS := amiga atarist ste dos x68000 dvx
HELLO_TITLE := Hello
HELLO_HELP := The smallest JoeyLib program: it clears the screen and waits for a key.
PATTERN_SRCS := $(EXAMPLES)/pattern/pattern.c
PATTERN_TITLE := Pattern
PATTERN_HELP := Eight bands of gradient palettes, one per band of scan lines.
DRAW_SRCS := $(EXAMPLES)/draw/draw.c
DRAW_TITLE := Draw
DRAW_HELP := The drawing primitives: pixels, lines, circles, rectangles and flood fills.
KEYS_SRCS := $(EXAMPLES)/keys/keys.c
KEYS_TITLE := Keys
KEYS_HELP := Keyboard, typed characters and mouse: held keys light up and typed text appears. Escape ends it.
SERIAL_SRCS := $(EXAMPLES)/serial/serial.c
SERIAL_TITLE := Serial
SERIAL_HELP := A serial terminal on COM1.
SERTEST_SRCS := $(EXAMPLES)/sertest/sertest.c
SERTEST_TITLE := SerTest
SERTEST_HELP := The serial port test program.
SERTEST_AMIGA_NAME := SerTest
SERMOUSE_SRCS := $(EXAMPLES)/sermouse/sermouse.c
SERMOUSE_PORTS := x68000
SAVE_SRCS := $(EXAMPLES)/save/save.c
SAVE_TITLE := Save
SAVE_HELP := Saved files: counts its runs in a file in its settings folder.
TILEBANK_SRCS := $(EXAMPLES)/tilebank/tilebank.c
TILEBANK_TITLE := TileBank
TILEBANK_HELP := The tile bank check: loads a baked tile bank two ways and checks every pixel.
TILEBANK_AMIGA_NAME := TileBank
SCB_SRCS := $(EXAMPLES)/scb/scb.c
SCB_PORTS := x68000
JOY_SRCS := $(EXAMPLES)/joy/joy.c
JOY_TITLE := Joy
JOY_HELP := Joysticks: shows the position and buttons of each joystick.
SPRITE_SRCS := $(EXAMPLES)/sprite/sprite.c
SPRITE_TITLE := Sprite
SPRITE_HELP := Compiled sprites moving over a background.
SCROLL_SRCS := $(EXAMPLES)/scroll/scroll.c
SCROLL_TITLE := Scroll
SCROLL_HELP := A tile layer scrolling a landscape under a sprite, with a bar showing the frames drawn a second.
AUDIO_SRCS := $(EXAMPLES)/audio/audio.c
AUDIO_TITLE := Audio
AUDIO_HELP := Sound: tracker music, a MOD, sound effects, a streamed tone and a noise sweep.
UBER_SRCS := $(EXAMPLES)/uber/uber.c
UBER_TITLE := Uber
UBER_HELP := The JoeyLib conformance and speed test: every drawing call, timed and checked. Its results go to joeylog.txt in its settings folder.
ADV_SRCS := $(EXAMPLES)/adventure/adventure.c
ADV_TITLE := Adventure
ADV_HELP := A small adventure game.
ADV2_SRCS := $(EXAMPLES)/adventure2/adventure2.c
ADV2_TITLE := Adventure 2
ADV2_HELP := A second small adventure game.
# Every example that ships as its own bootable IIgs volume (make
# iigs-game-disks).
$(foreach p,DRAW PATTERN KEYS JOY SPRITE SCROLL SAVE AUDIO ADV ADV2 UBER SERIAL SERTEST,$(eval $(p)_IIGS_GAME_DISK := yes))
# IIgs serial probes for the gates: SCCPROBE (verify-iigs-serial.sh: does
# opening the modem port leave the printer port, AppleTalk's channel, alive?)
# and the receive-loss probes for the modem port and a Super Serial Card in
# slot 2 (verify-iigs-serial-loss.sh). The card runs at SERLOSS_SSC_BAUD:
# its 6551 holds ONE received byte, so it is lossless through full-screen
# presents only up to 2400 (docs/ApiSerial.adoc); at 9600 that half of the
# gate could never pass.
SERLOSS_SSC_BAUD := 2400
SCCPROBE_SRCS := $(EXAMPLES)/sccprobe/sccprobe.c
SCCPROBE_PORTS := iigs
SERLOSS_SRCS := $(EXAMPLES)/serloss/serloss.c
SERLOSS_PORTS := iigs
SERLOSSS_SRCS := $(SERLOSS_SRCS)
SERLOSSS_PORTS := iigs
SERLOSSS_CFLAGS := -DSERLOSS_SLOT=2 -DSERLOSS_BAUD=$(SERLOSS_SSC_BAUD)u
# The dirty-band marker's on-target check: tests/host/dirtyMarkHost.c against
# src/m68k/stageBands.s, the asm the Amiga and X68000 share. Not a shipped
# program, so it builds beside bin/; scripts/verify-atarist-dirtymark.sh runs
# it under Hatari. The host check runs 200,000 scenarios; this many takes
# under a minute of emulated time.
DIRTYMARK_SCENARIOS := 4000ul
DIRTYMARK_LOG := DIRTYMRK.TXT
DIRTYMRK_SRCS := $(REPO_DIR)/tests/host/dirtyMarkHost.c
DIRTYMRK_PORTS := atarist
DIRTYMRK_BINDIR := $(PROGRAM_BUILD)/test
PALPROBE_SRCS := $(EXAMPLES)/palprobe/palprobe.c
PALPROBE_PORTS := amiga
PALPROBE_BINDIR := $(PROGRAM_BUILD)/test
SERSLOT_SRCS := $(EXAMPLES)/sertest/sertest.c
SERSLOT_PORTS := atarist
SERSLOT_BINDIR := $(PROGRAM_BUILD)/test
SERSLOT_CFLAGS := -DSERTEST_DEVICE=JL_SERIAL_SLOT -DSERTEST_UNIT=2u
SERFAST_SRCS := $(EXAMPLES)/sertest/sertest.c
SERFAST_PORTS := win16
SERFAST_BINDIR := $(PROGRAM_BUILD)/test
SERFAST_CFLAGS := -DSERTEST_BAUD=115200u
FASTRAM_SRCS := $(REPO_DIR)/tests/amiga/fastRam.c
FASTRAM_PORTS := amiga
FASTRAM_BINDIR := $(PROGRAM_BUILD)/test
WBLAUNCH_SRCS := $(EXAMPLES)/wblaunch/wblaunch.c
WBLAUNCH_PORTS := amiga
WBLAUNCH_BINDIR := $(PROGRAM_BUILD)/test
DIRTYMRK_CFLAGS := -DDIRTY_MARK_SCENARIOS=$(DIRTYMARK_SCENARIOS) -DDIRTY_MARK_LOG='"$(DIRTYMARK_LOG)"'
# UBER with its UBER_PROBE rows (the present checked against the stage),
# built apart so neither bin/ (joey-run's tree) nor the goldened UBER
# changes. -DUBER_FRAMES=1: the run is wanted for its probe rows, not its
# timings, and a probe run at the golden 16 frames does not fit
# bench-iigs.sh's MAME cap. The IIgs packs it as UBER, the name its disks
# and bench-iigs.sh look for (iigs-verify-shrtail). DVX and the windowed
# hosted ports build it as part of `all`, into build/<port>/probe, for
# their display gates (scripts/verify-dvx-display.sh,
# verify-win16-display.sh, verify-win32-display.sh, verify-be-display.sh,
# and verify-atarist-display.sh).
UBERPROB_SRCS := $(UBER_SRCS)
UBERPROB_PORTS := iigs dvx win16 win32 haiku haiku32 beos atarist ste amiga
UBERPROB_CFLAGS := -DUBER_PROBE -DUBER_FRAMES=1
UBERPROB_TITLE := Uber Probe
UBERPROB_HELP := UBER with its probe rows: the present checked against the stage on screen. Its results go to joeylog.txt in its settings folder.
UBERPROB_IIGS_NAME := UBER
UBERPROB_IIGS_BINDIR := $(PROGRAM_BUILD)/probe/bin
UBERPROB_DVX_BINDIR := $(PROGRAM_BUILD)/probe
UBERPROB_WIN16_BINDIR := $(PROGRAM_BUILD)/probe
UBERPROB_WIN32_BINDIR := $(PROGRAM_BUILD)/probe
UBERPROB_HAIKU_BINDIR := $(PROGRAM_BUILD)/probe
UBERPROB_HAIKU32_BINDIR := $(PROGRAM_BUILD)/probe
UBERPROB_BEOS_BINDIR := $(PROGRAM_BUILD)/probe
UBERPROB_ATARIST_BINDIR := $(PROGRAM_BUILD)/probe
UBERPROB_STE_BINDIR := $(PROGRAM_BUILD)/probe
UBERPROB_AMIGA_BINDIR := $(PROGRAM_BUILD)/probe
# AUDIO with its keys pressed on a timetable (-DAUDIO_PROBE): N once, S every
# 1.5 seconds, under the tracker song. The IIgs and X68000 audio gates read
# their sound chips under MAME and cannot type, and the PSP has no keys to
# type with, so this is their subject (iigs-verify-audio, x68000-verify-audio,
# psp-verify-audio). Built apart, so neither bin/ nor the shipped AUDIO
# changes; it needs no DATA.
AUDIOPRB_SRCS := $(AUDIO_SRCS)
AUDIOPRB_PORTS := iigs x68000 psp
AUDIOPRB_CFLAGS := -DAUDIO_PROBE
AUDIOPRB_BINDIR := $(PROGRAM_BUILD)/probe
AUDIOPRB_IIGS_BINDIR := $(PROGRAM_BUILD)/probe/bin
# AUDPAR (scripts/verify-audio-conformance.sh): built apart like AUDIOPRB,
# with the module AUDIO plays in its DATA: the IIgs's as NinjaTrackerPlus's
# .NTP, made by tools/joeymod.
AUDPAR_SRCS := $(EXAMPLES)/audpar/audpar.c
AUDPAR_BINDIR := $(PROGRAM_BUILD)/probe
AUDPAR_IIGS_BINDIR := $(PROGRAM_BUILD)/probe/bin
AUDPAR_DATA := $(call programDataDir,AUDPAR)/test.mod
AUDPAR_IIGS_DATA := $(call programDataDir,AUDPAR)/TEST.NTP
$(call programDataDir,AUDPAR)/TEST.NTP: $(REPO_DIR)/assets/test.mod $(REPO_DIR)/tools/joeymod/joeymod
@mkdir -p $(dir $@)
$(REPO_DIR)/tools/joeymod/joeymod $< $@
$(call programDataDir,AUDPAR)/%: $(REPO_DIR)/assets/%
@mkdir -p $(dir $@)
cp $< $@
# AUDIO loads DATA/test.mod and DATA/test.sfx from beside the program. The
# IIgs plays its chip music through NTP and stages no MOD.
AUDIO_DATA := $(addprefix $(call programDataDir,AUDIO)/,test.mod test.sfx)
AUDIO_IIGS_DATA :=
$(call programDataDir,AUDIO)/%: $(REPO_DIR)/assets/%
@mkdir -p $(dir $@)
cp $< $@
# TILEBANK loads the host gate's fixture, so the host
# (scripts/check-tilebank.sh) and every port share one expected hash. Its
# DATA/tilebank holds this port's bake of it, every other target's bake (each
# must be refused) and the expected pixels.
TILEBANK_PNG := $(REPO_DIR)/tests/host/tileBank.png
TILEBANK_STAGE := $(REPO_DIR)/tests/host/tileBankStage.py
TILEBANK_BAKE_DEPS := $(TILEBANK_PNG) $(TILEBANK_STAGE) $(REPO_DIR)/tools/assetbake/assetbake.py
TILEBANK_DATA := $(call programDataDir,TILEBANK)/tilebank/own.tbk
$(TILEBANK_DATA): $(TILEBANK_BAKE_DEPS)
python3 $(TILEBANK_STAGE) $(ASSET_PLATFORM) $(TILEBANK_PNG) $(dir $@)