joeylib2/make/examples.mk
2026-10-13 14:01:46 -05:00

175 lines
8.9 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.
PROGRAMS := HELLO PATTERN DRAW KEYS SERIAL SERTEST SERMOUSE SAVE TILEBANK SCB JOY SPRITE AUDIO UBER ADV ADV2
TEST_PROGRAMS := SCCPROBE SERLOSS SERLOSSS DIRTYMRK UBERPROB AUDIOPRB PALPROBE
# DVX's help and resource texts call these JoeyLib examples.
DVX_KIND := JoeyLib example
# 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.
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 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
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 builds it as part of
# `all` (scripts/verify-dvx-display.sh), packaged in build/dvx/probe.
UBERPROB_SRCS := $(UBER_SRCS)
UBERPROB_PORTS := iigs dvx
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
# 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
# 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 $@)