Режим модерирования
Документы
НОВОСТИ
OPTICAL BROTHERS
ФАЙЛЫ
АРХИВ САЙТОВ
ССЫЛКИ
О САЙТЕ
ФОРУМЫ
ГОСТЕВАЯ КНИГА
Беларуская моваРусский языкEnglish language

Copyright © 2001-2006 Optical Brothers
qc_4_01.zip · docs/QC_4_01_technical_eng.txtЗакрыть ×
                 ░            ░▓▄▄▄▄▄
▄             ▓  ▓▀ ▀▀▀▓▄▄▄▄▄  ▀▓█▄ ▀▀▀████▓▄▄▄▄              ▓
██▓██▄▄▄     ▓░        ░    ▀▀▀▀▒▀█▓▄       ▀▀▀▀██▓██▄▄▄     ▓░
  ░▀▀▀▓███▓▄█▒                  ░  ▒   ▀░         ░▀▀▀▓███▓▄█▒
      ░  ▀▀█ ░                     ░                  ░  ▀▀█ ░


                     Quick Commander v4.01
                         For developers


    For  those  who  write  programs  working with QC, patch its
files  or  test  QC  on  their machines or in emulators: what QC
needs  and  how it uses the ports, the layout of QC's memory and
files, its settings, the resident and the return to QC, the file
formats. How to use QC (keys, menus, installing it, Quick Setup)
is  in  guide_en.txt,  the  version  history in hist_en.txt. All
numbers are for the QC 4.00 release build.


    :: What QC needs

    A  Z80  and  IM 1 interrupts (QC sets I = #3F) at 50 Hz: the
player  and  key  waits run on them. While QC runs, the BASIC 48
ROM  is  in  (bit  4  of  #7FFD  always  1): QC calls its PO_MSG
(#0C0A),  MAIN_4  (#1303),  STMT_RET (#1B76), BREAK_KEY (#1F54),
CLEAR_1  (#1EB7),  OUT_NUM_1 (#1A1B), #22B0 and #30A9. Keys come
from  LAST_K  (#5C08), filled by the ROM's interrupt routine; QC
puts mouse clicks there too.

    TR-DOS  ROM  5.03  or  later: QC's addresses are the same in
5.03, 5.04, 5.04T, 5.04S, 5.5H, 6.07+, 6.10E, 6.11E and the SMUC
ROMs; 5.01 differs. Drives: 80 cylinders, two sides; QC counts a
track  as  cylinder*2+side  and  writes  disk  type  #16  to the
catalogue.


    :: The memory

        #5B00-#5B7F  page table (2 bytes per page)
        #5B80, #5B90 name being typed, mask
        #5B98        code that starts a program
        #5C00-#5D3A  system variables
        #5D3B-#5E51  BASIC loader with the settings
        #5E5A-#5F37  the SD card's rows of CS and SS held
        #5FE8        stack (grows down)
        #6000-#9F63  QC's code
        #9F64-#A2FF  the panels' window: the disks' headers, the
                     files shown (20 bytes each) and their marks
        #A300-#BFFF  QC's overlay and its buffers (at start:
                     QC's set-up and memory test, run once)
        #C000-#FFFF  window: the buffer, the file viewed

    Code page #D7 (the #7FFD value): from #C000 the launcher and
QC's  ZX0-packed  code  (QC.C), from #FD42 what QC keeps for the
return  from  a  program,  #FD45-#FF97  a  copy  of  the  system
variables  and  the  BASIC  loader taken at load, from #FFF0 the
mark  "Residentpresent!".  The  .qco  file  lies  in the overlay
pages:  its  first  16K in #D6, the next 16K in #D4, the rest in
#D3. The pages' numbers:

        machine                          #D3  #D4  #D6  #D7
        128K, Scorpion, Profi, ATM,
        ZX-Evolution                       3    4    6    7
        Pentagon 512, 1024, 4096          27   28   30   31
        KAY 1024                          19   20   22   23

    QC  never  pages in 2 and 5; the other pages but the overlay
pages and the code page are the Copy and Move buffer, 64 sectors
each.  On  128K  (and  started with W held) the code page is the
buffer's  last page (the buffer is 0, 1 and 7, 192 sectors), and
there is no resident.
    Past the .qco in #D3: from #DE00 the catalogue of a disk put
in  during  a one-drive Copy (and M's new catalogue), from #E700
the  sector  where QC reads a catalogue's first and info sectors
to  check the disk before a write; from #E800 (the active panel)
and  from #F400 (the other one) the panels' places, 3K each: the
catalogue  (9 sectors), from +#900 the marks, from +#A00 the 9th
and  10th characters of a tape's names, from +#B00 the SD card's
folder.
    A  reset  that leaves the memory alone (Pentagon 512 and up,
KAY,  Scorpion)  keeps the overlay pages; the Spectrum 128's and
Pentagon  128's  ROMs  clear  pages  0-7  at a reset. 48K has no
pages:  the .qco's start goes to #C000-#E6FF of the main memory,
from #E700 the check sector and one panel's place.


    :: The overlays' file .qco

    Most  of QC is ZX0 streams in its .qco file: on a disk under
QC's  file name, type q, "co" in the start field, on the SD card
/SYS/TRDBOOT.OVR. Its header:

        +0      "QCO"
        +3      QC's version, 4 characters: "4.00", the
                betas' "400a" (b1), "400b" (b2)...
        +7      the build's stamp (a word)
        +9      the stream count N
        +10     4 bytes a stream: its offset in the file,
                its Fletcher-16
        +10+4N  the offset of the last stream's end
        +12+4N  a byte a stream: its library's number
                (#FF none)
        +12+5N  the build's data: the SD card's panel's
                line 23 rows, 212 bytes

    Then the streams back to back and zeros to the sector's end.
The  stamp  is  the  Fletcher-16 of the file from +9 to its last
sector's  end  (both sums mod 255); QC only compares it with its
own.  The  file  can be cut anywhere with nothing recounted: the
streams  before  the  cut stay whole, the others QC turns off by
their  sums (so the ROM set and the shadow RAM's copy are made).
Hence the streams go from the more important to the less:

        stream            what                  library
         0 MediaLibrary   the media's common       -
         1 TrdosLibrary   2's and 3's common       0
         2 TrdosReader    TR-DOS: reading, P, U    1
         3 TrdosWriter    TR-DOS: commands         1
         4 StreamLibrary  P's and U's streams      -
         5 PagesLibrary   a file through pages     4
         6 Prepare        unpacking, U, music      5
         7 Help           the help                 -
         8 ViewerLibrary  the viewers' common      5
         9 TextLibrary    the text viewer          8
        10 Text           UTF-8                    9
        11 Dump           the hex dump             9
        12 Picture        pictures                 -
        13 Player         the player               -
        14 Convert        ALASM's sources          5
        15 Packer         the packer (P)           4
        16 DiskUtils      disk_Utils               0
        17 CardLibrary    18's and 20's common     0
        18 CardReader     the SD card's panel     17
        19 Image          images and the tape      0
        20 CardWriter     the card's commands     17
        21 Sprite         sprites                  8

    An  overlay unpacks to #A300-#BFFF, its libraries before it,
from  the  root;  a  stream  across  two pages QC copies to that
area's  end first. Without streams 0-2 QC doesn't run: a message
and an exit to TR-DOS. At start QC takes the .qco from its pages
if  all  of  its build's streams are whole there, else reads the
file  from  the  disk  it started from, under esxDOS from the SD
card,  else takes the ROM set, else works with what is whole. On
48K  QC  reads the header and streams 0-2 to #C000, under esxDOS
17-19 too; no other overlays there.


    :: The disk: the VG93 directly

    The Beta Disk ports respond only while the TR-DOS ROM is in:
it  comes  in  on an instruction fetch from #3D00-#3DFF and goes
out on a fetch from RAM. So QC drives the controller with pieces
of  the ROM's own code: it pushes their addresses and enters the
ROM  via  #3D2F  (NOP;  RET), often chaining several. Ports: #1F
command/status,  #3F  track,  #5F  sector,  #7F data, #FF system
register (read: bit 7 INTRQ, bit 6 DRQ).

    System register: #2C plus the drive (bits 0-1): bit 2 = 1 no
reset,  bit  3  =  1  HLT,  bit  5 = 1 as TR-DOS, bit 6 = 0 MFM;
bit 4 = 1  (#3C)  selects  the first side, TR-DOS's even tracks.
Commands:  #08  to cylinder 0, #18 seek (6 ms steps, no verify),
#80/#A0  read/write a sector, #C0 read address, #F0 write track,
#D0 interrupt.

    TR-DOS ROM addresses QC uses:

        #3D2F - the way into the ROM (NOP; RET);
        #3D13 - function 5, read sectors: loading QC, and a
                code file before running it; #13 at the start
                (esxDOS's TR-DOS emulation answers it; without
                esxDOS, the DOS's name and version from #0358),
                under esxDOS 1 too (a drive's disk) and #0D
                (nothing: on the way out, X and the SD
                card's SS+R);
        #2A53 - OUT (C),A; RET: VG93 registers, ATM2 port;
        #3EF5 - wait for the end of a command;
        #3FE5, #3FCA - read (INI) and write (OUTI) data;
        #2740 - status and seek;
        #2090, #2093, #2099 - read and write a sector;
        #294A, #2920, #2970 - load a BASIC program;
        #0048 - exit to TR-DOS (key X);
        #3FF0, #3FF3 - OUT and IN for the SMUC clock.

    Speed  (CONFDRV, see "The settings in QC's file"): fast read
and  write  bits per drive; slow waits an extra frame (EI; HALT)
after  each  seek.  The  first  write after a reset or a seek to
track 0 waits ~0.3 s unless QC has seen the disk spinning. After
4  failed tries QC asks Retry / Abort / Ignore; between tries it
reads  an  address  (#C0)  to  fix  the track register, or seeks
cylinder 0.

    QC loads its own code via #3D13, so it loads wherever TR-DOS
works,  from  its  RAM  disk  too; QC's panel doesn't see TR-DOS
6.1xE's RAM disk: it is reachable only via #3D13.


    :: esxDOS

    esxDOS  0.8.5+ (tested: 0.8.9) on a DivMMC or a DivIDE (both
called  DivMMC below: their port #E3 is the same, a DivIDE's 32K
of  RAM  banks 0-3) emulates TR-DOS on the SD card's TRD images:
it  traps  #3D13  and the ROM pieces QC calls via #3D2F and runs
them  itself  (by its table of 85 addresses; another gives a red
border and BASIC 48). QC works with it as with a Beta Disk.

    QC (and Quick Setup) detects esxDOS so: #3D13's function #13
copies 16 bytes from #0370 to #5CDD; the emulation serves copies
of  four  ROM  places  (#0370,  #1803,  #0013,  #2A09; a read of
another  gives  a green border and DI: HALT), and after its copy
"5.04T*"  comes  its  own  code: the seventh byte is #CD (CALL),
while every TR-DOS ROM QC knows has #0D or text there. No DivMMC
port  is written for that; esxDOS's #3D13 selects bank 3 itself,
so #3D2F works after it. The DOS's name and version for the mode
window  QC  takes  from the ROM at #0358 (by the same function),
under esxDOS from M_DOSVERSION (RST 8, #88; there from 0.8.7 on:
HL = #0890 for 0.8.9).

    Under  esxDOS  QC exits to TR-DOS by M_AUTOLOAD (RST 8, #90)
with  A  =  #FC  after  clearing  the  memory, as when running a
program  (#0048 isn't in the table); before a command to a drive
with no image (it never ends there) calls #3D13's function 1 and
looks  at  bit  7 of the status; turns the SMUC clock off (#3FF0
and  #3FF3  aren't in the table); doesn't probe for Scorpion and
KAY  memory  (on a +2A/+3 #1FFD selects the ROM). esxDOS 0.8.9's
quirks:  it  doesn't  write  a  sector past the end of a TRD cut
after  its last file, and the status shows no error bit; with no
card  its  calls  give  an error, and the TR-DOS emulation on an
image  of  the  card  resets  the  machine; RST 8 from a program
leaves  DivMMC  bank 0 selected, and the emulation's #3D2F jumps
into  the  selected  bank  (after a call: OUT (#E3),3); TR-DOS's
error  question  (#3F7E)  isn't  in the table; trapping TR-DOS's
"no disk"  error  at a drive's select leaves the emulation where
its #0000 and #3D00 reset the machine (QC and Quick Setup select
a drive skipping BASIC routines: POP AF, RET at #5CC2).

    TRDBOOT.BIN: when an image started from esxDOS's browser has
no   boot   and   /SYS/CONFIG/TRDOS.CFG  has  AlwaysBoot=1,  the
emulation  loads /SYS/TRDBOOT.BIN at #6000 (#4000 bytes at most)
and  runs it. QC's TRDBOOT.BIN (16 304 bytes) is a 24-byte boot,
then  QC.C,  the  system  variables  (from +#3D5D) and the BASIC
loader  (from  +#3E98),  as in the code page: the boot pages #D7
in,  copies  them  to  #C000  and  jumps  to  QC's launcher. The
overlays are /SYS/TRDBOOT.OVR. Quick Setup writes both files and
/BIN/QC  (F_OPEN,  F_SEEK,  F_READ,  F_WRITE;  another  boot  it
renames  TRDBOOT.NAV  by  F_RENAME) from QC's files on its disk,
with the settings of the QC that was there.

    The  dot  command  .qc  (/BIN/QC)  loads /SYS/TRDBOOT.BIN at
#6000  and runs it if its first 11 bytes are as QC's TRDBOOT.BIN
has them. .qc NAME first puts a file of the current folder in: a
TRD  or  an  SCL  in  drive  A (EJECT, MOUNT), a TAP in the tape
(M_TAPEIN,  the  full  path),  and  sets KeptSettings (the first
file,  medium  0  or  5) and LaunchedFrom = 2 in the TRDBOOT.BIN
copy of the same build (by QC's file descriptor): QC comes up on
that medium.

    The  tape  is  esxDOS's:  QC  puts its own TAP in both slots
(M_TAPEIN and M_TAPEOUT, in_open and out_open), and the SAVEs of
a  program  it runs append blocks to its end; esxDOS writes them
to the card at out_close, so each start of QC takes its tape out
and puts it in again. A TZX QC copies (blocks #10, #11) to a TAP
beside  it,  of  the same name, and puts that in. The card's and
the  tape's  files  QC runs by esxDOS's calls after clearing the
memory: a tape by M_AUTOLOAD with A = 0 (LOAD ""), a TRD in A by
M_AUTOLOAD  #FD (its boot), a +3DOS program by M_AUTOLOAD "*", a
snapshot  by M_EXECCMD "snapload NAME"; they get esxDOS's BASIC,
with no TR-DOS variables.


    :: The extended memory

    QC  detects  memory at every start, interrupts off. First it
checks  for  128K:  it pages in page 1 (#7FFD = #11) and sees if
page  0 (#10) changed. If not, it is 48K (or #7FFD is locked: QC
run  in 48K mode), and QC tries only ZX-Evolution's #F7F7: there
the  clock  must  leave  its  #EFF7  as is (see the Gluk clock).
Otherwise  it  tries the ports in order; the first that responds
tells the machine:

        port   machine                page bits
        #F7F7  ZX-Evolution           3-7, inverted
        #FFF7  ATM Turbo 2+           3-5, inverted
        #AFF7  Pentagon 4096          0, 1
        #1FFD  Scorpion, KAY          4, 6, 7
        #DFFD  Profi                  0-2
        #FDFD  ATM1                   0-2
        #7FFD  Pentagon 1024          5 (with Caps shift)
        #7FFD  128K, Pentagon 512     0-2, 6, 7

    The  ATM ports come first, with bits 0-2 of #7FFD (bits 6, 7
select  no  page there). ZX-Evolution answers both, but only its
#F7F7  (an 8-bit page number) pages all 4M; if #F7F7 finds 1024K
or  less, it is an ATM. Pentagon 4096 (#AFF7; ALASM 4.46 has its
driver)  comes  after  them: ZX-Evolution's BaseConf takes #AFF7
for  its  #EFF7  (any  port  with A12 = 0, A8 = 1, low byte #F7,
outside  TR-DOS),  where a 0 turns on its Pentagon 1024 mode and
turbo,  in which its ATM ports page nothing. Scorpion GMX (#DFFD
with   bit   4  of  #1FFD)  and  GitHub's  Pentagon-4096  aren't
supported.

    Counting  pages:  for  each  combination  of  port values QC
zeroes  the  byte  at  #C000 and takes the pages where it stayed
zero;  then  all  bytes  are  restored, so a RAM disk survives a
start  (not Copy and Move). QC uses 64 pages at most (1024K) for
the buffer but counts all (on Pentagon 4096 the probe finds 128:
"Pentagon 2M");  a  +2A or +3 it tells by the 48K ROM: only they
have bit 0 of byte #0B53 = 0.

    The  page table (#5B00): 2 bytes a page, the extended port's
value  and  #7FFD's;  the buffer's pages first, then the overlay
pages  and the code page. On Pentagon the page bits are added to
#7FFD's  value;  elsewhere  QC  writes  the  extended port, then
#7FFD;  on  ATM2  and  ZX-Evolution  the  value  is inverted and
written  to  #FFF7  or #F7F7 via the TR-DOS ROM (#2A53): the ATM
ports respond only while it is in.

    With  W held at start QC uses #7FFD alone (128K); a Pentagon
1024  by  bit 5 of #7FFD it looks for only with Caps shift held:
elsewhere that probe locks the port till a reset. Page 8 is used
only  if CONFIG2 bit 5 is 1 and the BASIC 48 ROM has no JP (#C3)
at  #0008:  Scorpion's has, its page 8 holds the shadow monitor.
QC  doesn't page the +2A/+3's memory by #1FFD: it works there as
on  a 128K (under esxDOS). Its delays are counted loops, shorter
with a turbo.


    :: The Shadow RAM and the Magic button

    Quick  Setup  puts QC into the shadow RAM (the cache): turns
it on by reading port #FB, writes both 16K halves of a 32K cache
(selected  by bit 4 of #7FFD), turns it off by reading port #7B;
it  tests  for  one by writing a byte. A 16K cache (one half for
both ROMs) gets QC's half alone.

    QC's  half (bit 4 = 1): #0000-#0007 the hop to the overlays'
half  (DI,  #7FFD  = #C6), zeros up to #003E (NOPs: Gluk's Reset
Service  enters  the  shadow RAM at 0), #003F-#0067 the resident
(41  bytes; its JR at #0066, the NMI entry, goes to #0000), from
#0068 a copy of the code page's #C000-#FF97.
    The  overlays' half (bit 4 = 0): from #0000 the same hop and
code  that copies #0068-#3FFF to page #D6 and pages QC's half in
(#7FFD  =  #D7);  then  zeros, JR #0000 at #0066, from #0068 the
.qco's first 16 280 bytes as they are (streams 0-11 whole).

    Magic  must give an NMI with the shadow RAM in. The resident
sets  the  stack to #5FE8, pages #D7 in, copies #0068-#3FFF back
to  #C000,  clears the screen and border and jumps to #C000. The
launcher  restores  the  system  variables  and the BASIC loader
(#5C00-#5E52),  unpacks  QC to #6000 and starts it; QC turns the
shadow  RAM off, takes the settings from the CMOS, as on a start
from ROM, and the overlays as on any start (the .qco's first 16K
already  in  #D6,  the rest in #D4 and #D3 if they hold the same
.qco).


    :: QC in ROM, the snapshot and the tape

    QC_4_01.rom  (16K)  replaces the Basic 128 ROM (ROM 0, bit 4
of  #7FFD  =  0);  ROM  1  must  be BASIC 48, and a Beta Disk is
needed.  From #0000 DI and NOPs up to #0037, so both an entry at
0  and  an  IM  1  interrupt  start QC. From #0038: stack #5FE8,
border 0, attributes cleared, #7FFD = #C7 (page #D7 keeping QC's
ROM  in),  the  image  copied from #005B to #C000, a jump to the
launcher.  From  #005B:  the  launcher and the packed code; from
#3DA0:  the  system variables #5C00-#5D3A with the descriptor of
the file "QC 4.01" and the BASIC loader (to #FD45). No NMI entry
with  QC's  ROM  in:  #0066 is inside the launcher. The settings
come from the CMOS, without one they are the build's.

    The ROM set QC_4_01_ovr.rom (16K) is the .qco's first 16K as
they are (streams 0-11 whole), #FF after it. On Pentagon 1024 it
goes  in  place  of  Basic  128  and QC_4_01.rom in place of the
service  ROM  (Mr Gluk's Reset Service), which the reset starts;
in an emulator's 64K ROM image (Unreal Speccy's order) 0 the ROM
set, 1 BASIC 48, 2 QC, 3 TR-DOS. With not all the overlays whole
in  the pages and no .qco on the input disk (under esxDOS on the
card) QC pages in ROM 0 (bit 4 of #7FFD = 0, out of TR-DOS) and,
if  the  ROM  set  of its build is there, copies the 16K to page
#D6.

    The  snapshot  QC_4_01.sna  is  a  128K  SNA: TRDBOOT.BIN at
#6000,  the  whole  .qco  in pages 6, 4, 3, PC #A000, interrupts
off,  #7FFD  =  #10. Its start blacks the border, selects DivMMC
bank  0  (OUT  (#E3),0:  after  esxDOS's  snapload  its snapshot
loader's  bank  is  selected),  copies the .qco's pages to those
#D6,  #D4, #D3 page in on this machine and goes to TRDBOOT.BIN's
boot. After a reset the machine's own ROM runs.

    The tape QC_4_01.tap: the program with an autostart: line 10
(a  REM)  a  probe  for  TR-DOS (entry 15619, as in z88dk), with
neither  TR-DOS nor esxDOS a message and STOP, next CLEAR 24575:
LOAD  ""CODE:  RANDOMIZE  USR 24576; code at #6000 (TRDBOOT.BIN,
loader.LaunchedFrom  FromTape  in its launcher), then headerless
blocks:  a copy of the .qco for 48K (overlay.Room48 bytes), then
the  .qco,  16K  each.  QC  reads the blocks itself as it starts
(overlay.Tape;  LD_BYTES,  #0556), before a disk is read: on 48K
the copy alone, to #C000; else the copy is passed and the .qco's
parts go to #C000 of pages #D6, #D4, #D3; with this build's .qco
whole  in  the  pages  already nothing is read. Under esxDOS the
DivMMC's  bank  0 is selected for a block. Both start QC as from
ROM.


    :: The CMOS clock

    CONFIG2  sets  up  the clock: bit 2 use the CMOS, bit 3 Gluk
(1) or SMUC (0), bit 4 read and write (0: clock only).

    Gluk:  OUT  (#EFF7),#80  (bit  7 opens access), the register
number  to  #DFF7, data IN or OUT via #BFF7, then OUT (#EFF7),0.
The  port  can't  be  read, and QC writes all of it, every frame
while  waiting  for a key: its other bits become 0. Where an ATM
port   pages   (ZX-Evolution's   #F7F7   or   ATM2's  #FFF7;  on
ZX-Evolution  also  with #7FFD locked and with W), it writes #94
and  #14: bit 2 = 1 keeps the Pentagon 1024 mode off (in it page
bits 3-5 come from #7FFD), bit 4 = 1 keeps 3.5 MHz.

    SMUC:  the ports respond only while the TR-DOS ROM is in; QC
reaches  them through pieces of the SMUC ROMs: OUT (C),A; RET at
#3FF0  and  IN  A,(C);  RET  at  #3FF3. Read: register number to
#DFBA,  then IN from #DFBA. Write: register number to #DFBA, #F7
to  #FFBA,  data to #DFBA, #77 to #FFBA. These pieces are in the
SMUC TR-DOS ROMs and 6.10E/6.11E but not 5.04T.

    The  clock: register #0B = #FF means no clock. If writing is
allowed  and  #0B isn't 24 hours, BCD already (bits 1-2 = 1, 0),
QC  sets  it so (%00000010) while reading and restores it after:
it  writes  a  cell  only  if it holds another value, as all its
writes  to  the  CMOS do (on ZXMC-2 the cells but the time's are
its  controller's  EEPROM:  a  write takes about 8.5 ms, and the
next  access  waits  for  it  with  the Z80 in WAIT and the PS/2
keyboard  not read); while bit 7 (UIP) of register #0A is 1, the
frame  is skipped; the time is registers 4, 2, 0 (BCD). At start
QC  reads  #0B  for  a frame: if it changes even once or is #FF,
CONFIG2 bit 2 is reset in memory (on a 128 or +2 without a clock
its ports read screen bytes).

    QC's  cells:  #10  the input medium (0-3 drive A-D, 4 the SD
card,  5 the tape); #15 CONFIG (bits 0-2 the output medium); #16
the  cursor's file number + 1 (the low byte; 0 none; for a drive
past  #80 none of the cells taken). QC writes those that changed
(the  cursor's  last)  a second after the cursor's last move and
before  running  a  program,  if CONFIG2 bits 2 and 4 are 1, and
reads  them,  with  the  same  bits,  only  on a start from ROM,
TRDBOOT.BIN,  a  tape or by Magic; CONFIG is taken from #15 only
if  its  bit 5 is 1. Cell #10 is shared with Real Commander 1.96
and  TR-DOS  6.05E+  (the autostart drive); Gluk 6.2-6.61 and QC
3.x take its bits 0-1. With its bit 7 set (Mr Gluk Reset Service
6.3+: don't keep the drive) QC leaves #10 alone, as Gluk does.


    :: The Kempston mouse and the AY

    The  mouse:  #FBDF  X, #FFDF Y (inverted; QC inverts it so Y
grows  down),  #FADF  buttons  in  bits  0-2 (0: pressed): bit 0
right,  bit  1  left,  bit  2  third.  ZX-Evolution  (and MAME's
pentevo)  has  the  left one in bit 0: with CONFIG2 bit 7 = 0 QC
swaps  bits  0  and  1. The wheel isn't read; a button counts as
pressed  after 3 unchanged frames. If at start a button reads as
pressed  even  once  within  a  frame (1202 reads of #FADF), the
mouse  is  turned  off (so on a grey 128 or +2 too: the floating
bus).  Unreal  Speccy  needs SwapMouse=1 for the Kempston button
order.

    The  AY:  the player (Sergey Bulba's PTSPlay) works with one
AY  or  two (TurboSound, NedoPC's standard: #FF to #FFFD selects
the  first  AY,  #FE  the  second): #FFFD register number, #BFFD
data.  Registers  0-12  are  written  every  frame, 13 only when
changed;  the  meters  read  registers 0-5 and 8-10. At start QC
silences  both AYs: mixer #FF, volumes 0. The channels go in the
order ABC, ACB or BAC (TXTMODE bits 4-5).


    :: The settings in QC's file

    The file "QC 4.01" (type B, start and length 279) is a BASIC
loader:  line  1  CLEAR  24575: RANDOMIZE USR 23925 (the numbers
hidden  behind  dots),  then  the  settings,  the loader and the
depacker; from the 3rd sector the packed code (QC.C), its sector
count  at offset 74 (#4A). The settings are 35 bytes from offset
23 (#17), #5D52-#5D74 in memory; the same offsets in QC 3.11 and
later.  QC's  file is known by its BASIC line (bytes 4-21: FD 2E
0E 00 00 FF 5F 00 3A F9 C0 2E 0E 00 00 75 5D 00) and LD SP,#5FFF
(#31 #FF #5F) at the start of the 3rd sector.

    The  same  loader,  the settings at the same offset from its
line,  is  in  QC's  ROM image and TRDBOOT.BIN (#3E80 bytes past
their  boot code; in the ROM image the settings start at #3EF2),
in  the  code  page (#FE80) and in the Shadow RAM (#3EE8 of QC's
half).  Quick  Setup finds it by the loader's line (on a disk in
boot.B's  first  sector)  and  takes the settings of QC 3.20 and
later  for the QC it writes there. The bytes, their defaults and
file offsets:

        ;0-2: output: 0-3 drive, 4 SD, 5 tape, 7 same.
        ;3: not used.
        ;4: 1 - fullcat off, 0 - fullcat on.
        ;5: 1 - QC config ID, 0 - RC config ID.
        ;6: 1 - play without loop, 0 - loop on.
        ;7: 1 - boot mode, 0 - commander mode.
CONFIG  DB %10111111                        ;#17

        ;0: not used.
        ;1: not used.
        ;2: 1 - use CMOS, 0 - don't use.
        ;3: 1 - Gluk CMOS, 0 - SMUC CMOS.
        ;4: 1 - read & write CMOS, 0 - clock only.
        ;5: 1 - use page 8 (not on Scorpion), 0 - never.
        ;6: 1 - key click on, 0 - off (S).
        ;7: 1 - Kempston mouse buttons, 0 - swapped.
CONFIG2 DB %11111111                        ;#18

        ;0: 1 - fast load, 0 - slow load: Drive A.
        ;1: 1 - fast save, 0 - slow save: Drive A.
        ;2: 1 - fast load, 0 - slow load: Drive B.
        ;3: 1 - fast save, 0 - slow save: Drive B.
        ;4: 1 - fast load, 0 - slow load: Drive C.
        ;5: 1 - fast save, 0 - slow save: Drive C.
        ;6: 1 - fast load, 0 - slow load: Drive D.
        ;7: 1 - fast save, 0 - slow save: Drive D.
            ;D C B A
CONFDRV DB %11111111                        ;#19

        ;0-1: text viewer W: 0 - cut, 1 - wrap, 2 - words.
        ;2-3: text viewer M: 1 - colours, 2 - codes as
        ;     signs, 0 - codes hidden.
        ;4-5: music view C: 0 - ABC, 1 - ACB,
        ;     2 - BAC.
        ;6-7: not used.
TXTMODE DB %00000100                        ;#1A
SET_VER DB 2                                ;#1B

COLORSF DB #47,#07,#43             ;B C s   ;#1C
        DB #45,#45,#FF,#45,#45,#45 ;m M st - S w
        DB #44,#44,#44,#44         ;W t T d
        DB #02,#42,#42,#42,#42     ;p z Z r h
        DB #05,#05,#05,#05,#05     ;H R a A X
COLORSO DB #04,#01,#06             ;scr del oth ;#33
COLORS  DB #5F,#78,#05,#30                  ;#36

    CONFIG:  bits  0-2  the  output medium (the codes as in CMOS
cell #10, 7 the input medium's drive), 4 the full catalogue off,
5  = 1 these are QC's settings (a CONFIG with bit 5 = 0 from the
resident or the CMOS isn't taken, the media and the cursor are),
6  tunes  without looping, 7 the boot mode. On a start from disk
the  input  medium is the byte st, the output one CONFIG's; on a
return from a program and from the CMOS the kept ones.
    CONFIG2:  bits 2-4 the clock (see "The CMOS clock"; with bit
4 = 0 the settings are neither written to the CMOS nor read from
it), bit 5 page 8, bit 6 the key click, bit 7 the mouse buttons'
order;  bits  0  and  1 unused (1 in the settings). CONFDRV: the
drives'  speed.  TXTMODE:  the  viewers' modes at start. CONFIG,
CONFIG2 (bit 6) and TXTMODE change while QC runs.
    SET_VER:  the  settings'  version, 2 (1 in QC 3.30..3.32; QC
3.20..3.23  have  the  track  number 159..162 here). Quick Setup
takes  another version's settings with the output "same" (CONFIG
bits 0-2 = 7), 3.20..3.23's with the default TXTMODE too.
    COLORSF:  colours  of 21 file types, in reverse order of the
panel's type table ("XAaRHhrZzpdTtWwSXXMmsCB"); byte 5 (st, from
0)  the  medium of a start from disk (0-5, else the boot drive),
byte  6  unused.  COLORSO: colours of screen files and fonts, of
deleted  files,  of  other types; COLORS: the cursor on a marked
file, marked files, the viewer's text and its info line.


    :: The resident and the return to QC

    There  is  a resident only with over 128K: the code page #D7
(see  "The  memory").  The  mark "Residentpresent!" QC writes at
start: by it TR-DOS 6.10E+ start QC after a reset. QC checks the
resident by the word #FF31 at #C000 (the launcher's LD SP,#5FFF)
and  the  mark's  last  bytes  ("t!" at #FFFE: a program's stack
spoils  them first). Before running a program or going to TR-DOS
QC also checks the Fletcher-16 of QC.C (the build writes it into
the BASIC loader) and the sum of #FD45-#FFFF taken at the start;
if  any  is  off  (on  128K and 48K always), QC wipes the mark's
first  and  last bytes and the launcher's first one: no #FF31 at
#C000 then.

    Page  #D7 is Pentagon's standard #C7 (bit 4 selects only the
ROM):  TR-DOS 6.05E+ and 6.10E find it. Where #7FFD ignores bits
6  and 7 (Scorpion, Profi, ATM), #D7 = #17 = page 7; on Pentagon
512/1024  it  is  page  31,  on  KAY 1024 page 23, and a program
paging  in  #17  (Real  Commander's and QC's up to 3.10 resident
page) won't find QC there. Returning to QC from a program:

        LD BC,#7FFD
        LD A,#D7 ;(not #17!!!)
        OUT (C),A
        LD HL,(#C000)
        LD DE,#FF31
        XOR A
        SBC HL,DE
        JP Z,#C000
        LD H,A
        LD L,A
        PUSH HL
        LD A,#10
        OUT (C),A
        JP #3D2F

    If  the resident is intact, JP #C000 starts the launcher: it
sets  the  stack,  restores  the  system variables and the BASIC
loader  (#5C00-#5E52),  unpacks  QC  to  #6000  and  starts  it.
Otherwise  page 0 and the BASIC 48 ROM come in, 0 is pushed, and
JP  #3D2F  (NOP; RET in the TR-DOS ROM) goes to the TR-DOS ROM's
address 0: TR-DOS 6.10E+ find the mark and start QC, others just
start.  The  program's  stack must be below #C000 (the PUSH runs
with  page  #D7  in),  interrupts  are  best off beforehand (the
launcher  disables  them  only with its second instruction), and
the  extended  port  (#1FFD,  #DFFD, #FDFD) should be zeroed: QC
writes #7FFD alone.

    To return, a program must leave page #D7 from #C000 to #FF97
and  the  mark  from  #FFF0  intact. On Scorpion, Profi, ATM and
ZX-Evolution  that  page  is  the second screen (#C000-#DAFF). A
program run in 48K mode can't return: #7FFD is locked.

    Before a run QC writes the cursor's file number + 1 (#FD42),
CONFIG (#FD43) and the input medium (#FD44, the codes as in CMOS
cell  #10) into page #D7 and sets LaunchedFrom (#C01E) = 2. On a
return  QC  takes  them back: the cursor if 1..#80 (for the card
and  the  tape  1..#FF),  CONFIG  if  its bit 5 is 1 (the output
medium  from  its  bits  0-2  anyway), the input medium from the
third  byte.  LaunchedFrom:  0  started  from  disk, 1 from ROM,
TRDBOOT.BIN or by Magic, 2 back from a program (and .qc NAME), 3
from a tape.


    :: Running programs

    Before  any  run  QC  pages  in  page 0 and the BASIC 48 ROM
(#7FFD  =  #10),  sets  CURCHL = #5D26 and HL' = #2758, puts the
file's  catalogue entry into the TR-DOS descriptor (#5CDD-#5CEC)
and  its track into #5CF5 (the head goes there), DosHook (#5CC2)
=  RET,  the  current  drive into #5CF6, #5D19, #5CF8, #5CF9 and
bits 0-1 of #5D16, and enables interrupts (IY = #5C3A, IM 1, I =
#3F); LAST_K = 0, REPDEL = 16, REPPER = 1, FLAGS = #CD, FLAGS2 =
0, P_POSN = 0.

    A  code  file: the screen cleared (border and attributes 0),
#5D3B-#FFFF  of  page 0 zeroed, the file's sectors read by #3D13
at  its start (not past #FFFF), the program started via PUSH IX;
JP  #3D13,  stack #5FE8, a 0 on it. A start below #4000 lands in
the  TR-DOS  ROM.  A  BASIC program: white border, CLEAR (#1EB7)
with  RAMTOP  #FF00,  #5D3B-#FE4B zeroed, the file loaded by the
TR-DOS ROM by its descriptor, no catalogue search, the autostart
line  from  the  bytes  #80,  #AA  and the line number after the
program,  the  run  started via STMT_RET (#1B76). 48K mode (R in
the  main  menu):  #7FFD  = #30 (page 0, BASIC 48 ROM, bit 5 the
lock;  on  Pentagon 1024 bit 5 is a page bit), the extended port
at  page  0's value. Exit to TR-DOS: border 7, P_RAMT = #FFFF, a
jump to #0048 of the TR-DOS ROM.


    :: TR-DOS disks

    QC  doesn't  use  TR-DOS's  catalogue  and file routines: it
reads  and  writes  the catalogue's 9 sectors itself. Track D is
cylinder  D/2,  even tracks on the first side (#3C in the system
register),  odd  ones on the second (#2C). Sector E is 0..15, as
in  TR-DOS,  numbered  E+1 on the disk, 256 bytes; the side in a
sector  ID  isn't  checked. A track number may be anything up to
255; reads and writes run on from one track to the next.

    The  disk  size comes from the info sector (track 0's sector
8,  counting  from 0): the first free sector's number (#E1, #E2)
plus the free sectors (#E5-#E6), so disks of any size keep their
size,  a  1 MB TRD (256 tracks) as esxDOS mounts it too. A first
free  sector  on  track  0 is past track 255 (a full disk of 256
tracks).  QC  doesn't read the disk type (#E3) and always writes
#16: it has no double stepping or single side.

    QC  recounts the info sector in memory after every catalogue
read  and  before  a write: #00 = 0; #E1, #E2 past the last file
with sectors, deleted ones counted (entries of no sectors at 0/0
after  the  files are pictures drawn by names and take no room),
but  not  before  the  value  on  the  disk  (only Delete at the
catalogue's  end  and M move it back); #E3 = #16; #E4 entries up
to  the  catalogue's  end;  #E5-#E6 the size less the first free
sector;  #E7  = #10 (not checked on reading); #F4 deleted files.
Other  bytes  are  written  back  as read. QC's disk name has 11
characters,  #F5-#FF;  TR-DOS's  8  (#F5-#FC).  TR-DOS's  Format
writes  zeros to #FD-#FF, QC shows them as spaces; N writes only
the  bytes typed. TR-DOS's CAT and LIST print the name up to a 0
byte or one with bit 7 set: with no zero in #F5-#FF past it too.

    The  catalogue: 128 entries of 16 bytes; a name's first byte
0 is the catalogue's end, 1 a deleted file. Delete sets 1, and a
run of deleted entries right before the end becomes the end (0),
their  room free, as after TR-DOS's ERASE of the last file. Copy
adds  files after the last entry, deleted ones counted, from the
first  free  sector;  deleted  entries aren't reused, same names
aren't  checked.  The  marking  order  (129  bytes)  QC keeps at
#40-#C0  of the info sector in memory; after a Copy to the other
drive  or  an  aborted  one  there are zeros there, and the next
catalogue  write  puts  them  on the disk. Move (M) rewrites the
live  files  back  to  back, deleted entries past that place are
gone;  aborted  after a part was written, M writes the catalogue
as  it  left the disk (before the first file not moved a deleted
entry over the room left).

    A file over 255 sectors is a group of parts (as Hrip and RAR
from a PC write them): the first part, then in the catalogue and
on  the disk parts of the same name and start with types 0, 1...
in  order,  all but the last of 255 sectors, length 65280. Merge
(G)  grows  only the first entry's sectors (its length no longer
fits them) and over 255 sectors makes such a group.

    A file's length: the sectors are the entry's byte 13 (a file
of  0 sectors isn't read). The length field is taken if its high
byte is sectors-1 (low byte not 0) or sectors (low byte 0); else
the  length is sectors*256. Copy and a code file's run take byte
13 as is.

    Names: 8 characters and the type (byte 8); TR-DOS knows only
the  type.  QC  shows  a 3-character extension: the type and the
start  field's  two bytes (low, high) if both are #20..#7F, else
the type and two spaces (B's start is the program's length: CODE
30000, #7530, shows as .C0u). Russian letters in names are cp866
(#80-#AF,  #E0-#EF);  TR-DOS  prints  them through BASIC's PRINT
(#80-#8F  block  graphics,  #90-#A4  UDGs, #A5-#FF keywords) and
compares  names  byte for byte. QC's conventions: p_X and z_X, a
file  of type X packed by Hrust (p) or ZX0 (z), "_" and X in the
start field: U gives the file type X (else C), two spaces in the
start  (a  code  file  kept  so gets start #8000) and the data's
length;  .zx0  is  type z and "x0"; a TAP, a TZX and an SCL on a
disk are types t and s with "ap", "zx" and "cl" in the start (as
Copy from the SD card names them), which QC opens as images.

    A  file's  colour in the panel, in checking order: a deleted
file  the  deleted colour; a length field of exactly 6912, 6144,
13824,  2048  or 768 (not a B file) the picture colour; types i,
p_i  and  z_i  too; type p or z with "_" in the start's low byte
the colour of the type in the high byte; else the type is looked
for (case-sensitive) in the table "XAaRHhrZzpdTtWwSXXMmsCB", and
one not found gets the other files' colour (as do TR-DOS's D and
#). The table's types:

        B  BASIC               p  Hrust
        C  code                z  .zip, .zx0
        s  .scr, .scl          Z  ZXZip
        m  ProTracker 3        r  .rar, .rzx, .rom
        M  ProTracker 2        h  Hrip
        S  Sound Tracker       H  ALASM
        w  .wav                R  Storm
        W  ZXWord              a  Masm, ZASM
        t  .txt                A  TASM, GENS
        T  .TXT                X  Xas
        d  .diz, .doc

    TR-DOS variables: QC reads #5CF6 (the boot drive) and #5CF4,
#5CF5,  the  code's  place  on  disk,  which TR-DOS leaves after
loading  the BASIC part (a program loading QC's file itself must
leave them so). DosHook (#5CC2) = POP AF; RET: TR-DOS's calls of
BASIC  routines (via #2F72) are skipped, so the BREAK test never
fires  in  the ROM pieces. The drives' step time (#5CFA-#5CFD) =
8:  bit 7 = 0 (TR-DOS doesn't test the drive on selecting it), 6
ms steps; seeks by the pieces at #2740 step at 30 ms (#1B).

    The  catalogue  copy on track 161 (sectors 7-15) is kept and
restored  by  disk_Utils;  the  track  is  formatted  with those
sectors  only.  The mark "Quick Commander " at offset #C8 of the
info  sector  QC  neither  writes  nor reads; there is no "DIRS"
table of the 8th sector standard.

    Quick  Setup  (item  B) puts boot.B and the .qco in place of
the  first  file  of  the  same name and type: if it is the last
file,  over  it  and the free room after it; if it is as long or
longer,  over  it,  the  rest  a deleted file after it (with the
catalogue  full  the  old  length  kept  in the entry); if it is
shorter,  it  is marked deleted and the new one added at the end
(so  too  with  no such file). Other live files of that name are
deleted.


    :: File formats

    Texts: cp866 or UTF-8. A text with no byte of #80 or more is
cp866. Otherwise QC checks it from the first such byte: up to 16
multibyte  sequences  within  1024 characters. A sequence starts
with  #C2..#DF  (1  continuation  byte  follows),  #E0..#EF (2),
#F0..#F4  (3);  a  continuation is #80..#BF. It isn't UTF-8 if a
byte  #80..#C1  or  #F5..#FF  starting  a  character,  or  a cut
sequence,  comes  first  (overlong  forms,  surrogates and codes
above U+10FFFF aren't checked).

    UTF-8's  signs  QC  prints  in its cp866 font: А..я, Ё, ё as
their  codes;  the pseudographics U+25xx (░▒▓, frames, █▄▌▐▀) as
#B0..#DF;  the  quotes U+00AB, U+00BB, U+201C, U+201D, U+201E as
",  U+2018,  U+2019  as  ';  the dashes U+2013, U+2014 as -; the
ellipsis  as three dots; Є, є as Е, е; Ї, ї and the Ukrainian I,
i (U+0406, U+0456) as Latin I, i; Ў, ў as У, у; the Ukrainian G,
g  (U+0490,  U+0491) as Г, г; a BOM, soft hyphen and stress mark
aren't  printed;  the  font's  signs  (U+2265,  U+2264,  U+2320,
U+2321,  U+00F7, U+2248, °, U+2022 and ∙, ·, √, №, U+00B2, ■ and
the no-break space) as its codes #F2..#FF, ¤ as #FD; others, all
4-byte ones too, as ?. A byte starting no sequence prints as is,
but  cp866  inside UTF-8 shows only by chance (cp866's "ра", #E0
#A0, looks like a 3-byte sequence's start and becomes ?).

    The  viewer's  font:  256  signs 4 dots wide, 64 columns, 23
lines.  #00  blank, #01-#1F and #7F cp437's signs (faces, suits,
arrows,  house),  #80-#AF  А..п, #B0-#DF pseudographics, #E0-#EF
р..я,  #F0  Ё,  #F1 ё, #F2-#FF the signs U+2265, U+2264, U+2320,
U+2321,  U+00F7,  U+2248, °, ∙, ·, √, №, U+00B2, ■ and blank. At
#F2-#F7  and  #FD the font differs from cp866 (Є є Ї ї Ў ў and ¤
there).

    A  line  ends with CR (#0D), LF (#0A), CR LF or a 0 byte; LF
CR  gives  an  extra empty line. Tab (9) goes to the next column
that  is  a  multiple of 8; codes 11, 12, 21-31 and #7F print as
the  font's  signs.  Colours follow ACEdit: codes 1-7 ink 1-7 on
black, 8 the text colour from the settings, 14-20 bright ink 1-7
(code  less 13). A code prints as a space and acts from where it
stands;  there is one attribute per two characters, so a code in
a  cell's  second  half  acts  from  the next cell. A code right
before  the  line end (CR, LF or 0) sets the colour of the whole
line (not with CR LF: CR is before the LF); of a line wrapped by
width only its last part gets it. Code 0 ends the line.

    An ALASM 4.x source is a file up to 16K: a 64-byte header (H
at  +8,  at  +#28  8 bytes adding up to #80), then lines, each a
length  byte (counted too) and its bytes, and 0 at the end. In a
line:  1..#F  that  many spaces, #10 the rest of the line as is,
bytes   from  #80  up  tokens  (the  first  the  mnemonic,  then
operands),  ";" a comment to the line's end, a quote a string to
the next quote, #FF nothing. QC turns it into a text with ACEdit
colour  codes:  label  6,  instruction  8,  jump 3, directive 2,
operands  7,  comment 4 (a code in place of the space before its
part);  the  text ends at the buffer's top (64K, 48K on 128K) or
where it would overtake the source's unread part.

    Pictures QC knows by length (which: guide_en.txt, V): exact,
the low byte 0 (but .bsc's 11136, #2B80), fitting the sectors. A
@-file  (49152,  192 sectors) shows its first 6912 bytes, a 6144
one  (dots alone) gets attributes #07; a packed picture is known
by  its data's length. .mlt isn't supported. .bsc: 6912 bytes of
screen  and  4224 of border, a 384x304 picture (64 dots left and
right, 64 lines above and 48 below), a colour for each 8 dots of
a line, two a byte (bits 0-2 and 3-5). The border is drawn along
the  beam  only  with  a  known  timing (the frame: Pentagon and
ZX-Evolution  71680  T-states,  48K and Scorpion 69888, 128K and
+2A/+3  70908;  a  +2A/+3  told  by  byte #0B53 of the 48K ROM);
strokes  under  3  cells (24 dots) and too many colours in a row
are  skipped,  then  a  sign  of two wavy lines marks the bottom
right  corner.  Otherwise  (and in turbo) the border is its most
frequent colour. .img: two 6912-byte screens; the second goes to
page  7, and bit 3 of #7FFD flips them every frame (the bytes of
page 7 under it QC moves to a buffer page meanwhile).

    Fonts:  768  bytes  are  96  characters of 8 bytes, top down
(usually codes #20-#7F); 2048 bytes 256 characters. Sprites: any
file  as  a black and white picture, a line of dots the sprite's
width  (1..32  bytes) in a row, the high bit the left dot, lines
one after another, no character cells or attributes.

    Music: Pro Tracker 3 and Vortex Tracker II modules (PT3) and
Pro  Tracker  2  (PT2),  Sergey  Bulba's PTSPlay (release 0). QC
looks  for  a  PT3  text  header anywhere in a file (so it finds
modules  with  a  player  too):  a T, an r after it, a P 4 bytes
before   the   r   ("ProTracker")   or   a   V  8  bytes  before
("Vortex Tracker"),  and a b #3F bytes past the P or V (" by "),
in 16K parts, going on from part to part; not in files under 256
bytes. The header:

        +#00  "ProTracker 3.x compilation of " (the version
              at +#0D) or "Vortex Tracker II 1.0 module: "
        +#1E  title, 32 bytes (line 22, "PT3.5 : ")
        +#3E  " by "
        +#42  author, 32 bytes (line 23, "Author: ")
        +#63  note table (bits 0-1)
        +#64  tempo
        +#65  positions (for the position bar)
        +#66  loop position
        +#67  patterns' pointer
        +#69  32 samples' pointers
        +#A9  16 ornaments' pointers
        +#C9  positions' list, ended by #FF

    The  version  is  the  digit  at  +#0D;  a non-digit (Vortex
Tracker's  r)  counts as 6. Below 4 the old note tables, below 5
the  old  volume  table,  below 6 the old portamento, from 7 Pro
Tracker 3.7's rule for commands 1xx and 2xx with delay 0.

    Without a text header a module is looked for by its header's
structure in the file's first 3K (the author's UniSearch): tempo
1..#3F,  1  or more positions with the loop position among them,
the  positions' list ended by #FF right before the patterns, the
empty  ornament  0  (PT3: 0, 1, 0; PT2: 1, 0, 0). So PT2 modules
are  found  (bare  or  after  Pro  Tracker  2's player), and PT3
modules without the text.

    A module plays if the farthest of its 48 sample and ornament
pointers  is under #4000; a module going on into the file's next
16K  part QC gathers at its part's start. TurboSound on two AYs:
Vortex  Tracker II pairs (two PT3 modules one after the other at
the  file's  end,  then "PT3!" size1 "PT3!" size2 "02TS"; a pair
that  doesn't  fit  16K  plays  its first) and Alone Coder's Pro
Tracker 3.7 TS modules (version 7 and on, byte 98 not a space).

    Hrust  2  (hr2):  the  block  must start at the file's first
byte:

        +0  "hr2"
        +3  flags: bit 7 = 1 the data not packed
        +4  unpacked data's length (a word)
        +6  packed block's length, counted from +8
        +8  packed block

    One block; what follows isn't read. The unpacked data L must
fit  with  room to spare: L + L/8 + 272 at most the buffer's top
(64K,  48K  on  128K),  i.e.  up  to 58012 bytes (43448). A file
starting with "hr2" that fails the check isn't tried as ZX0.

    Hrust  1  (Hrumer's DEHRUST format): a block from the file's
first byte too:

        +0  "HR"
        +2  unpacked data's length (a word)
        +4  whole block's length (a word)
        +6  unpacked data's last 6 bytes
        +12 packed stream

    The  block is taken if its length is the file's or up to 255
bytes  less; the data's limits are Hrust 2's. Otherwise the file
is  tried as ZX0. Hrip archives ("HRi" at the start, their first
block's "Hrst2" at +8) aren't unpacked, only coloured.

    ZX0:  format  ZX0 v2, forward (the stream for dzx0_standard;
dzx0_turbo and dzx0_mega share it); backward (-b) and the old v1
(-c)  won't  do.  ZX0  has  no  header,  so QC knows a stream by
itself: it unpacks it on trial, writing nothing, and checks that
each  copy  is  of  data  already unpacked and the end marker is
exactly  at  the  file's  last byte (a file past the buffer: the
marker  alone).  So  the  file's  catalogue  length  must be the
stream's  exact length, not rounded to a sector. Data up to 16M:
those  that  don't fit in the buffer U and the viewers unpack in
portions from the medium.


    :: Real Commander's conventions

    QC  keeps Real Commander's conventions (Pawel Kislyak): CMOS
cell  #10 is the current drive (QC's input medium, a drive 0-3);
bit 5 of the settings byte (in CMOS cell #15 and the resident) =
1  means QC's settings, 0 RC's; the way back to the commander is
by  the  signature  LD SP,#??FF (the word #FF31) at #C000 of the
resident's  page.  Real Commander keeps its resident in page #17
and  leaves  to TR-DOS via JP 15649 (#3D21), QC in page #D7 (see
"The resident and the return to QC").


    :: The ZX0 licence

    The  ZX0  depacker  in QC (the loader unpacks QC's code with
it)  is  the  "standard"  one  of  ZX0  v2  by  Einar Saukas and
Urusergi;  U  and the viewers unpack ZX0 files with a copy of it
of  24-bit  lengths,  and  the check of a ZX0 stream reads Elias
gamma  as  the  "turbo"  one  by Einar Saukas and introspec. Its
licence:

    BSD 3-Clause License

    Copyright (c) 2021, Einar Saukas
    All rights reserved.

    Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:

    1. Redistributions of source code must retain the above
       copyright notice, this list of conditions and the
       following disclaimer.

    2. Redistributions in binary form must reproduce the above
       copyright notice, this list of conditions and the
       following disclaimer in the documentation and/or other
       materials provided with the distribution.

    3. Neither the name of the copyright holder nor the names of
       its contributors may be used to endorse or promote
       products derived from this software without specific
       prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.


                 ░            ░▓▄▄▄▄▄
▄             ▓  ▓▀ ▀▀▀▓▄▄▄▄▄  ▀▓█▄ ▀▀▀████▓▄▄▄▄              ▓
██▓██▄▄▄     ▓░        ░    ▀▀▀▀▒▀█▓▄       ▀▀▀▀██▓██▄▄▄     ▓░
  ░▀▀▀▓███▓▄█▒                  ░  ▒   ▀░         ░▀▀▀▓███▓▄█▒
      ░  ▀▀█ ░                     ░                  ░  ▀▀█ ░