# Quick Commander plugins
This folder holds the sources of the plugins that come with Quick Commander 4.10, and the description of the plugin
interface for those who want to write their own.
A plugin is a small program that QC runs when you press Enter on a file. When it finishes, you are back in QC with
the same panels, the cursor on the same file.
## The plugins
| File | Opens | Source |
|---------|-----------------------------------------------------------------------|--------------------------|
| `13824` | gigascreen pictures (`.img`) | `giga/giga.asm`, `common/` |
| `11136` | `.bsc` pictures with the border | `bsc/bsc.asm`, `common/` |
| `12288` | multicolour 8x1 pictures (`.mlt`), near enough on a plain screen | `mlt/mlt.asm`, `common/` |
| `SCA` | screen animations (`.sca`) | `sca/sca.asm` |
| `_PT` | music: ProTracker 2 and 3, Vortex Tracker II (`.pt2`, `.pt3`, `.vt2`) | `pts/pts.asm`, `common/` |
| `STC` | music: Sound Tracker (`.stc`) | `stc/stc.asm`, `common/` |
| `ASC` | music: ASC Sound Master (`.asc`) | `asc/asc.asm`, `common/` |
| `STP` | music: Sound Tracker Pro (`.stp`) | `stp/stp.asm`, `common/` |
| `GTR` | music: Global Tracker 1.0 and 1.1 (`.gtr`) | `gtr/gtr.asm`, `common/` |
| `PSC` | music: Pro Sound Creator 1.00-1.07 (`.psc`) | `psc/psc.asm`, `common/` |
| `SQT` | music: SQ-Tracker (`.sqt`) | `sqt/sqt.asm`, `common/` |
| `PT1` | music: Pro Tracker 1 (`.pt1`) | `pt1/pt1.asm`, `common/` |
| `FTC` | music: Fast Tracker (`.ftc`) | `ftc/ftc.asm`, `common/` |
| `FLS` | music: Flash Tracker (`.fls`) | `fls/fls.asm`, `common/` |
| `FXM` | music: Fuxoft AY Language (`.fxm`) | `fxm/fxm.asm`, `common/` |
| `MYM` | music: MYM tunes, packed AY register dumps (`.mym`) | `mym/mym.asm`, `common/` |
| `PSG` | music: 50 Hz logs of AY register writes (`.psg`) | `psg/psg.asm`, `common/` |
| `AY` | music: AY files, Z80 code with its music (`.ay`) | `ay/ay.asm` |
| `_GS` | music: MOD and WAV on a General Sound or a NeoGS (`.mod`, `.wav`) | `gs/gs.asm` |
| `_MZ` | music in TR-DOS `C` files and tracker modules in `m` files | `muz/muz.asm` |
| `_HR` | packed files: Hrust 1 and 2 (`p_`), unpacked to their type's plugin | `hru/hru.asm`, `common/` |
| `_Z0` | packed files: QC's ZX0 (`z_`), unpacked to their type's plugin | `zx0/zx0.asm`, `common/` |
| `_TX` | texts QC's own check misses: long lines, UTF-8 in code, to its viewer | `txt/txt.asm` |
The gigascreen viewer shows the two screens of a picture in turn, one each frame. The `.bsc` viewer draws the border
picture cell by cell; it knows the timing of the 48K, the 128K, the +2A/+3, the Pentagon and the Scorpion, and on other
machines paints the border in one colour. The multicolour viewer shows an `.mlt` (Multiartist's: the pixels, then an
attribute for each 8 pixels of each line) on a plain screen: in each cell the two colours most of its pixels have are
its ink and paper, a pixel of another colour the nearer of them (about 2 s at 3.5 MHz). Its exact picture would need its
attributes changed with the beam each line, each machine's own timing: a later version.
The SCA viewer loops full-screen frames or attribute frames over a fixed bitmap. `p` or the right mouse button
pauses or resumes, `f` shows it three times faster, `l` turns the looping off or on (off: the next file after the
last frame), `b` starts it again, Enter or 0 goes to the next file, other keys return to the panels; `f` and `l` are
QC's settings, the music players' too. Frames are read as needed from a floppy or FAT folder. Slow media can extend
the frame delays.
The music player `_PT` plays ProTracker 3 and Vortex Tracker II modules, ProTracker 2 modules and TurboSound pairs
(Vortex Tracker's and Alone Coder's PT 3.7 TS) on two AYs; the files `PT3._PT`, `PT2._PT` and `VT2._PT` are links to it
(a `.vt2` is a PT3 module; Vortex Tracker's text module, `[Module]` its first line, the plugin leaves to QC's text
viewer). The player is Sergey Bulba's PTSPlay; the view (`common/`, shared by the plugins) clears the two bottom lines
and shows there the format, the name, the author and the modes, with the AY analyzer and the position bar above them.
Keys: `p` or the mouse's right button pause, `l` looping on or off, `f` fast, `c` the order of the channels (ABC, ACB,
BAC), `b` from the beginning, Enter or `0` the next file, any other key back to QC. QC keeps `l`, `f` and `c` in its
settings. `5`, `8` and Space (the `AY` player's songs) do nothing here: the players share one set of keys
(`common/keys.asm`), and a key of it that a player has no use for does nothing, so no key leaves one player and
changes a mode in another. Letters work with Caps Shift as well. A TurboSound pair longer than 16K (its first module 16K
at most, its second 16K less the first one's length's low byte) plays on two AYs where the plugin has a second page
(`common/pages.asm`: its second module read there; not on
a 128K, which plays the first module alone); a pair already in the pages (an unpacker's data, reason 6) gives its tail
and its second module from there (`common/move.asm`).
The music player `STC` plays Sound Tracker's modules with the same view and keys, line 22 the file's long name. Its
player is Ivan Tatarinov's playstc.inc (public domain) with Sound Tracker's own note table: the AY's registers are those
of the compiled modules' player ("SONG BY ST COMPILE") frame by frame.
The music player `ASC` plays ASC Sound Master's modules (1.x and 0.x) with the same view and keys, line 22 the
module's title (or the file's long name), line 23 its author. Its player is written for the kit from Sergey Bulba's
description of the format (Ay_Emul): the AY's registers are those of the compiled modules' own player frame by frame.
The music player `STP` plays Sound Tracker Pro's modules with the same view and keys, line 22 the module's name (or
the file's long name). Its player is written for the kit from the format's descriptions (VfNG's, with KSA Software's
player decompiled; Sergey Bulba's): the AY's registers are those of the compiled modules' player frame by frame.
The music player `GTR` plays Global Tracker's modules (1.0 and 1.1) with the same view and keys, line 22 the module's
name (or the file's long name). Its player is written for the kit from the format's descriptions (Doctor Max's,
Sergey Bulba's): the AY's registers are those of the tracker's own players for compiled modules frame by frame.
The music player `PSC` plays Pro Sound Creator's modules (1.00-1.07) with the same view and keys, line 22 the module's
name (or the file's long name), line 23 its author. Its player is written for the kit from Sergey Bulba's description
of the format (Ay_Emul): the AY's registers are those of KVA's players of compiled modules frame by frame.
The music player `SQT` plays SQ-Tracker's modules and TurboSound pairs (two modules in a file, as Ay_Emul keeps them)
on two AYs (a pair past 16K as `_PT`'s), with the same view and keys, line 22 the file's long name (the module has no
name); on one AY a pair plays its first module. Its player is written for the kit from Sergey Bulba's description
of the format (Ay_Emul): the AY's
registers are those of the compiled modules' player frame by frame.
The music player `PT1` plays Pro Tracker 1's modules with the same view and keys, line 22 the module's name (or the
file's long name). Its player is written for the kit from Sergey Bulba's description of the format (Ay_Emul): the AY's
registers are those of the compiled modules' player frame by frame.
The music player `FTC` plays Fast Tracker's modules with the same view and keys, line 22 the module's name (or the
file's long name). Its player is written for the kit from Sergey Bulba's description of the format (Ay_Emul): the AY's
registers are those of the compiled modules' player (1.00) frame by frame.
The music player `FLS` plays Flash Tracker's modules with the same view and keys, line 22 the file's long name (the
module has no name). A module's pointers are those of the place it was compiled for: the plugin finds that place by
the module's own layout and moves them; a file it can't place is QC's. Its player is written for the kit from Sergey
Bulba's description of the format (Ay_Emul): the AY's registers are those of Wild Commander's player frame by frame.
The music player `FXM` plays Fuxoft AY Language's modules with the same view and keys, line 22 the file's long name (the
module has no name); a module has no positions and no loop point, so line 21 has no position bar and with the looping
off it plays on till a key. Its player is written
for the kit from Sergey Bulba's description of the format (Ay_Emul): the AY's registers are those of Fuxoft's player
frame by frame.
The music player `MYM` plays MYM tunes (packed AY register dumps by Marq/Lieves!Tuore) with the same view and keys,
line 22 the file's long name. A tune over 16K is read whole at the start into the plugin's pages when the machine
has enough of them, else 16K at a time as it plays (a short pause at each read). Its player is written for the kit
from the format's converters: the AY's registers are those of MYMPlay (Zack's ZX Spectrum port) frame by frame.
The music player `PSG` plays 50 Hz AY register logs on the first AY, including files over 64K, with the same view
and keys. Line 22 shows the file's name, the long one when QC has it. It reads a file of up to 64K into pages
before playing if the pages suffice. Otherwise it reads 16K at a time, muting the AY for each read.
The music player `AY` plays AY files (ZXAYEMUL: Z80 code with its music, mostly ripped from games) as the format's own
player plays them. A song gets all the memory from `#5B00` to `#FFFF`, so QC steps aside while it plays: the panels give
way to the player's screen, "PLAYING AY SONG" in blue above, the channels' volumes below it, the song's name (none: the
file's), its author, its number and the time in QC's font (none for a song playing in its own code, as the beeper's: it
heeds its own keys alone). Keys: `5` (cursor left) the previous song, `8` (cursor right) or Space the next, `b` from the
beginning, `l` the looping (on: the song plays on; off: at its end, its length from the file or 3 minutes, the next
song, past the last the next file), `f` fast and `p` the pause (songs with an interrupt routine), Enter or `0` the next
file, any other key (Edit and Break too) or the mouse's left button back to QC, its right button the pause. The songs
write the AY themselves, so the order of the channels (`c`) is not theirs. Blocks below `#4000` with the BASIC 48 ROM's
own bytes are skipped (the format's machine has RAM there); a song that needs other memory below `#5B00`, or more than
the file's first 25K, is refused. A beeper song plays inside its init and stops only if its own code reads the keys; the
player's keys work when the song's code gives it back control, a hung song stops at Reset alone. A song that writes over
the screen where QC lies meanwhile (about 1.5% of ZX-Art's) can't give QC back: the player says so and resets the
computer at a key.
The music player `_GS` plays 4-channel MOD modules (`M.K.`, `M!K!`, `FLT4`, `4CHN`) and WAV sounds (PCM, 8 or 16 bits,
mono or stereo) on a General Sound or a NeoGS: the card's own player plays them, the plugin loads the file into the card
(16K at a time; a WAV as the card's sample, its 8 high bits, a stereo sound's channels mixed, its note by the rate) and
starts it. The links `MOD!!._GS` and `WAV!!._GS` put it first for those files; with no card answering, the file goes
on to QC. A file over the card's memory (a WAV's 8 bits mono) and a WAV whose sound starts past the file's first 16K are
refused at once. Line 22 shows the module's name (none, and a WAV: the file's), line 23 the card and at its right in a
load "Loading NN%" (the share sent to the card, after each 16K), then "Preparing" as the card readies the file.
Line 21 shows a MOD's position and progress within its current pattern. Cards with note and volume replies also
show 31 note bands on lines 19 and 20. If row queries are unavailable, the bar shows the order alone.
For WAV, line 21 estimates the time from the samples sent to the card and lines 19 and 20 show peaks from the last
3.1 seconds, newest on the right. A WAV with more than about 17 minutes of playback has the time mark alone. At the
mark's end the next file follows with the looping off (QC's `l`), else the WAV plays again from its start. Keys:
`p` or the mouse's right button pause (a WAV plays again from its start), `b` from the beginning, Enter or `0` the
next file, `f`, `l`, `c`, `5`, `8` and Space nothing, any other key back to QC; leaving stops the music. Enter, `0`
and the keys outside the players' set stop a long load.
The music detector `_MZ` finds a module in a TR-DOS code file (a game's or a demo's code with its player and music; the
link `C!!._MZ`) or a type `m` file (`M._MZ`) and hands it on to the player, as QC 4.01's music search did: a ProTracker
3 or Vortex Tracker II module by its text in the file's first 16K, else a ProTracker 2 one (or a PT3 one without its
text) by its structure in its first 3K (the place of a module alone or after ProTracker 2's own player), else the text
in the rest of the file's first 64K, read 16K at a time. It moves the module to `#C000` (read from its start when it
isn't all in the first 16K, as far as 16K) and gives it to QC as a `.pt3` or `.pt2` file of the module's length (reason
6): `_PT` plays it. A file already in the pages (an unpacked type `m` file) is looked at in its first 16K alone; the
module and all past it move to `#C000` on through the pages, and a TurboSound pair of PT3 modules right to the file's
end goes on whole. A drive's file with another PT3 header past the module in its first 16K is read into the pages first
(a 128K: 16K, four pages: 64K) and goes the same way: its pair whole. No module: the file goes on to QC (its viewers,
"Run?") as it was, in about 0.2 s for 16K, 0.35 s and a few reads for 40K (on a 128K the file's first 16K read again at
the end).
For a type `m` file, `_MZ` also recognizes ASC, STC, STP, PSC, PT1 and SQT modules by their header at the start and
hands them to their own player. SQT TurboSound pairs go on whole if their bytes fit in the available plugin pages.
The transparent unpackers `_HR` and `_Z0` give a packed file's data on to the plugins of its own type. QC's `P` packs a
file of type `Y` into one of type `z`, start `_Y` (on FAT the extension `Z_Y`); QC 3.11's `h` (Hrust) gave type `p`.
Such a file's key is its packer's two characters: the links `P_._HR` and `Z_._Z0` take every `p_` and `z_` file. The
plugin unpacks the file into its pages as a file (its first 16K at `#C000`, its 16K k in page k) and gives the data to
QC as a file of type `Y` of their length (reason 6): a packed module `SONG.P_M` goes on to `_MZ`, then to `_PT`. `_HR`
reads Hrust 2 (`hr2`, packed or stored) and Hrust 1 (`HR`) blocks up to 65 535 bytes, in 13K portions from a drive or
FAT folder. `_Z0` reads ZX0 streams in 14K portions from the same sources. Elsewhere the first window can supply up
to 13 914 bytes for `_HR` or 14 585 for `_Z0`. The data fit as many pages as QC gives the plugin: 16K on a 128K with
resident overlays, 48K on a 128K with overlays on a card, up to 65 535 bytes with four pages or more. Data past the
pages, a broken stream or no
type (`P_`) go on to QC, whose viewers unpack big files themselves. A module of 16K unpacks from memory in about
0.3-0.4 s with ZX0, 0.4-0.5 s with Hrust 2, 0.6-0.7 s with Hrust 1. Other packers (`.tar`, `.gz`, `.xz`) come the same
way: a plugin keyed by the packer's extension giving the data on as a file of their own type.
The text detector `_TX` sends to QC's text viewer what QC's own check takes for no text (it wants a line end every 256
bytes: a text of a paragraph a line is none to it). The links `TXT._TX`, `MD._TX`, `NFO._TX`, `DIZ._TX`, `ME._TX`
and `ASM._TX` select the text viewer by extension. A link such as `LOG._TX` adds an extension without changing the
plugin. `CFG._TX` checks the first 4K for binary control codes. A code file (`C._TX`, after `C!!._MZ`) is a text if its
first 4K are UTF-8 of 16 sequences at least, with few control codes. The plugin answers with reason 5 for text
(QC shows it as its key `V` does). Binary CFG files and code go back through QC's usual checks.
## Installing
Copy the folder `PLUGINS` (it lies next to this `src` folder in the kit) to `/SYS/QC/PLUGINS` on the SD card
(esxDOS or Z-Controller) or on the Gotek's USB stick.
QC looks for the folder on the esxDOS card first, then on the Z-Controller's card, then on the Gotek's stick, and
takes the first one it finds. Plugins work on 128K machines and bigger.
With no such folder QC takes the plugins from the file `QPLUGINS.SCL` (letters in either case) on a floppy shown in a
panel, the active one's drive first: QC's disk has one with all the kit's plugins. With one drive, copy it to the disk
with your music. Inside it a plugin is a file of type ` ` (a space), a link a file of no sectors whose type and start
spell its plugin (`PT3` with type `_`, start `PT`).
## How QC picks a plugin
The name of a plugin file says which files it takes:
- an extension: `PT3` for `SONG.PT3`. On FAT the short name's three characters (`PHOTO.JPEG` goes to the plugin
`JPE`). On a TR-DOS disk three characters when the type and the start address spell them (`SONG.PT3`), else the
type's letter (`GAME.C`: the key `C`);
- a packed file's extension `X_Y` (its packer's `X`, the data's type `Y`): its two first characters, `X_` (`SONG.P_M`
goes to the plugin `P_`, every `p_` file);
- a file length in decimal, up to 65535: `6976` takes every file of 6976 bytes.
Letters are not case sensitive. One or more `!` past the key raise the plugin's priority: `PT3!` goes before `6976`,
which goes before `PT3` (sorted by name, `C!!._MZ` lies next to `C._TX`). If a plugin answers "not mine", QC tries the
next one, and when none is left it opens the file as usual.
An empty file `KEY.PLG` in `PLUGINS` is a link: its name is a key as a plugin's name is (with its `!`), its extension
names the plugin. For example, an empty file `PT3._PT` sends every `.pt3` file to the player `_PT`; make one with `touch
PT3._PT`, or on the Spectrum copy a link and rename it. A link's plugin is a name of three characters at most. A plugin
reached through links alone is named `_` and two letters (`_PT`, `_GS`, `_MZ`, `_HR`, `_Z0`, `_TX`): it is no file's
extension, and in `PLUGINS` it reads as a plugin's name, not an extension; only its links supply registry keys; a
plugin of its own extension or length keeps that for its name (`STC`, `13824`).
QC's registry holds **64 distinct keys**. `PT3` and `PT3!` share one key. The links `PT3._PT` and `PT2._PT` use two.
With a 65th key, QC marks the registry incomplete and searches the plugin folder or `QPLUGINS.SCL` each time you press
Enter on a file.
## Writing a plugin
`plugin.asm` has the interface's names and the `pluginHeader` macro. In short:
- The plugin is loaded at `#8000` and starts at `#8007`, right after its 7-byte header: `"QCP"`, the interface version
(QC 4.10 accepts exactly 0), flags (bit 0 clear in the original image, bit 4 for a screen over QC's panels, see
the way back below) and a word `Size` with its memory from `#8000`, including code, data and stack (up to 16128
bytes). QC swaps `Size` bytes plus its 256-byte fast resident. A plugin of 8960 bytes or less also leaves room for
a copy of QC's screen. Within `#8000`Б─⌠`#BEFF`, write only to the declared memory.
- A packed plugin on disk starts with `QCP`, version 0, flags with bit 0 set and a zero size word. The kit builder
copies bits 1Б─⌠7 from the original header. The rest is the forward ZX0 stream of the whole original image. The
builder packs an image when it gets smaller and can unpack in place in the first 8960 bytes. It can pack an image
that uses two chunks at runtime (up to 16128 bytes). The kit uses this option for `_HR`.
- On entry the first 16K of the file (or all of it if it's shorter) is at `#C000`. IX points to the file's block: the
name (8 bytes), the extension (3) and the length (3 bytes); then a byte that is 1 when the file is on the esxDOS card
and esxDOS's current folder is the file's, 2 when the file is in the plugin's pages already (reason 6's data: its 16K
k in page k, no `FnRead`), and the `#7FFD` value that pages the file's 16K in (0 on machines where `#7FFD` alone can't
do it). SP is at the end of the plugin's memory, interrupts are on in IM 1, the BASIC 48 ROM is paged in, IY is
`#5C3A`.
- When that byte is 1, the plugin may read the file itself through esxDOS: `RST 8` with the name in IX, as any program
does, the DivMMC port left alone.
- The plugin may use its own memory, the screen and the second screen (page 7, `#C000`-`#DAFF`).
- Memory from `#5B00` to `#7FFF` is QC's, and so is `#BF00`-`#BFFF` past the plugin's memory. You may borrow it,
with interrupts off from `#5B00` to `#5CFF` (the ROM's interrupt writes the system variables), if you put it back
before you call QC or leave. With `#5B00`-`#5BFF` and `#7F00`-`#7FFF` back first, `FnPage` and `FnPage7` work
before the rest is back: take back what you put away in other pages.
- QC's resident has five fixed points, the only addresses QC promises:
| Address | Name | What it does |
|---------|--------|------------------------------------------------------------|
| `#5B80` | `End` | the end: a plain `RET` of the plugin comes here |
| `#5B81` | `Exit` | the end with the reason in A |
| `#5B84` | `Call` | function A, its parameters in HL, DE, BC |
| `#5B87` | `Get` | value A to HL |
| `#5B8A` | `Put` | value A from HL |
`Call`, `Get` and `Put` return CF = 1 on an error, its code in A: 1 unavailable function, value
or access direction, 2 a wrong parameter, 3 QC's memory is not in place (the plugin took it), 20 the
medium failed (or QC can't read its files for plugins), 21 past the file's end or the file is already in the pages.
`FnPrint` may change BCБ─╡ and DEБ─╡. Other fast calls preserve the shadow set. Slow calls may change all four pairs.
Reserved `Call` and `Get` selectors can take the slow path and return `ErrUnknown`.
- Functions (`Call`):
| A | Name | What it does |
|----|------------------|------------------------------------------------------------------------------------|
| 0 | `FnPage` | the plugin's page L at `#C000`: 0 the file's 16K, 1 and on free pages |
| 1 | `FnPage7` | page 7 (the second screen) at `#C000` |
| 2 | `FnScreenMain` | the main screen shown |
| 3 | `FnScreenSecond` | the second screen shown |
| 4 | `FnKey` | the key pressed, no wait: its code in A and NZ, or 0 and Z; Break is Edit (7); a |
| | | mouse click `#80` plus the buttons (1 right, 2 left, 4 the third); IY = `#5C3A` |
| 5 | `FnPrint` | B characters from HL at line D, x E (in pixels) in QC's font; HL past them |
| 20 | `FnRead` | BC bytes (1..65535) from block HL of 256 bytes. D < `#80` reads into pages |
| | | D onward at `#C000`. D Б┴╔ `#80` reads at Dц≈256. BC returns bytes, HL the next block. |
`FnKey` spoils BC, DE and HL, `FnPrint` spoils BC; the others keep them.
`FnRead` swaps the plugin out to read and back, sets IM 1 and spoils DE. The last page read stays selected.
A read into plugin memory keeps the current page. The whole request, rounded to blocks, must fit in the pages
below `ValPages` or within the declared memory, away from the stack and active code. The last block is padded with
zeros past EOF and counts in the returned HL. Both destinations work on floppy and in SD and Gotek folders.
A file on tape or in an image on the card gives error 20.
- Values (`Get`, `Put`):
| A | Name | What it is |
|----|------------------|------------------------------------------------------------------------------------|
| 0 | `ValVersion` | the interface version QC gives (0 in QC 4.10), `Get` only |
| 1 | `ValError` | the address of the plugin's error text, `Put` only |
| 2 | `ValPages` | the plugin's pages for `FnPage`, at least 1, `Get` only |
| 10 | `ValControls` | `Get` alone, slow: the controls QC found and its settings for them, L's bits: 1 a |
| | | Kempston mouse (ports `#FADF` the buttons, 0 pressed, `#FBDF` X, `#FFDF` Y), 2 its |
| | | buttons swapped (the left one in bit 0, as on the ZX-Evolution; else the right |
| | | one), 4 the keys' click on; H 0 |
| 20 | `ValLongName` | `Get` alone, slow: the file's long name copied to the plugin's 256 bytes at HL (in |
| | | QC's font's codes, a 0 after it); HL its characters, 0 none (a drive's file) |
| 30 | `ValMusic` | QC's music settings, `Get` and `Put`: `#40` no loop, `#30` channel order |
| | | (0 ABC, `#10` ACB, `#20` BAC), `#02` fast. Start with them and store what the user |
| | | changes. In picture viewers, `#40` advances after 500 frames. |
See `plugin.asm` for all codes, including reserved ones.
- `RET` finishes the plugin. To say anything else, jump to `#5B81` with A = 1 ("not mine": QC tries the next plugin,
then opens the file itself; leave the window at `#C000` as you got it, the next plugin gets it), A = 2 (the next file,
as Enter in QC's viewers), A = 4 (an error: put the address of your message in your memory, from `#8000` on, up to 50
characters ended by 0 or by a character with bit 7 set, to `ValError` first), A = 5 (the file is a text: QC's text
viewer shows it as its key `V` does, the file itself, any length, a packed one unpacked) or A = 6 (the data in your
pages are a file of another kind, a detector's or an unpacker's answer, laid as a file: its first 16K at `#C000` of
page 0, its 16K k in page k; first write their extension, 3 characters, to the block at IX+8 and their length, 1 to
`ValPages` times 16384 and 65535 at most, to IX+11 (3 bytes); QC then runs its plugins for them as for a file of that
extension and length, the pages as you left them, the block's byte at IX+14 2, `FnRead` answering `ErrEnd` (21).
If no plugin takes those data, QC resumes the original file's handler). Other values are reserved. An unknown
value ends the plugin.
- On the way back QC sets IM 1 again, so a plugin may use IM 2. The border turns black.
- QC's panels come back from its copy of the screen when the plugin left the copy alone. Without the copy QC goes by
bit 4 of the header's flags, `plugin.FlagCovers` (the `pluginHeaderCovers` macro): set, for a screen over the
panels (a picture, an animation), QC draws the panels again whole; clear, it draws again only what a player's
screen takes, its pixels and colours: lines 19Б─⌠21's columns 24Б─⌠31, line 22 and line 23.
The smallest useful plugin shows a file as a screen until a key is pressed:
```
device ZXSPECTRUM128
include "plugin.asm"
org plugin.At
pluginHeaderCovers Size ;the memory it needs from #8000: its code, then its stack; a screen over the panels
ld hl,#C000
ld de,#4000
ld bc,6912
ldir
wait
halt
ld a,plugin.FnKey
call plugin.Call
jr z,wait
ret
codeEnd
Size equ codeEnd-plugin.At+96 ;96 bytes of stack: QC's functions, the ROM's interrupt
savebin "SCR",plugin.At,codeEnd-plugin.At
```
Its picture covers the panels, so its header is `pluginHeaderCovers` (flag bit 4, `plugin.FlagCovers`). This plugin is
small and leaves page 7 alone, so QC's copy of its screen stays whole and the panels come back from it; were the copy
gone, the flag would make QC draw the panels again whole. A player that leaves the rest of the panels, as the
kit's do, uses `pluginHeader`.
## Building
The sources are for sjasmplus (version 1.24 or newer: in `PATH`, or named by `SJASMPLUS`). With `just` installed, in
this folder:
```
just build
```
writes the plugin files and their links into `out/`, made anew, with each plugin's symbols, listing and SLD. A
plugin is a folder with its `<folder>.asm`, the
main file (`fls/fls.asm`; a music player's `player.asm` beside it), its tests beside them; a new folder is a new
plugin, no list to add it to. The plugin's file name is the one its `savebin` writes (`pts/pts.asm`: `_PT`). A
folder's `LINKS` names its links, a key a line: each becomes an empty file `KEY.PLG`, `PLG` that file name
(`pts/LINKS`: `PT3._PT`, `PT2._PT`, `VT2._PT`). `common/` is the code several plugins include (the music view,
the AY's output, the note tables, the pages' loader), `testkit/` the tests' common part; neither is a plugin. Without
`just`, `sjasmplus giga/giga.asm` and so on, from any folder: each writes its plugin file into the current one.
`just test` builds the plugins and runs their tests (Go 1.26 or newer) with no QC: `testkit/` is the tests' Spectrum and
QC's double by this contract (its answers checked against QC itself by QC's own tests), so a plugin's test plays a file
with it and checks the AY's registers frame by frame, the lines it prints, its end and its reason; what the contract
forbids (QC's memory not put back, a write to #5B00-#5CFF, an OUT to #7FFD) fails the test. Each music plugin plays
modules its test makes by the format, kept in its `testdata/` with the AY's registers they gave (`PLUGINS_GOLDEN=write
just test` writes them anew after a change meant); that those registers are the format's own player's is checked by QC's
tests, which play the same modules with the original players. `_PT` and the music view play One Man's modules (of
Optical Brothers, `pts/testdata`), GIGA his gigascreen picture (`giga/testdata`). The tests need nothing outside this
folder.
`just coverage` tells how much of each folder's code the tests run, and of each plugin's (its own and what it
includes); `just coverage fls` lists the folder's procedures with their share and the lines not run. In QC's source
repository, where this folder is `plugins/`, QC's `just test-plugins-coverage` counts QC's own tests of the plugins
too.
## License
MIT, see `LICENSE`: use these sources freely, in your own plugins too.