° °ІЬЬЬЬЬ Ь І ІЯ ЯЯЯІЬЬЬЬЬ ЯІЫЬ ЯЯЯЫЫЫЫІЬЬЬЬ І ЫЫІЫЫЬЬЬ І° ° ЯЯЯЯ±ЯЫІЬ ЯЯЯЯЫЫІЫЫЬЬЬ І° °ЯЯЯІЫЫЫІЬЫ± ° ± Я° °ЯЯЯІЫЫЫІЬЫ± ° ЯЯЫ ° ° ° ЯЯЫ ° Quick Commander v4.10 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.10 release build. :: What QC needs A Z80 and IM 1 interrupts (QC sets I = #3F) at 50 Hz: key waits and the mouse's pointer 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), LD_BYTES (#0556), #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-#5BBD a plugin's switcher while it runs, code that starts a program #5BBE-#5BFF the page switch #5C00-#5D3A system variables #5D3B-#5E51 BASIC loader with the settings, at its end (#5E4E-#5E51) the start's cells #5E5A-#5F3D the SD card's rows of CS and SS held #5F40-#5FE7 a plugin's start while it runs #5FE8 stack (grows down) #6000-#76AB QC's code #76AC-#76FF the shown files' marks, the panels' headers #7700-#A2FF modules: TR-DOS's catalogue and the drive, the drivers of the Gotek's stick, the SD card and esxDOS's card, QC's FAT #7F00-#7FFF while a plugin runs: QC's functions for it #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, #FD41-#FD44 the start's cells kept for a return from a program, #FD45-#FF97 a copy of the system variables and the BASIC loader taken at load, from #FFF0 the mark "Residentpresent!". Page #D1: QC's ZX0-packed code (QC.C) from #C000. 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 #D1 #D3 #D4 #D6 #D7 128K, Scorpion, Profi, ATM, ZX-Evolution 1 3 4 6 7 Pentagon 512, 1024, 4096 25 27 28 30 31 KAY 1024 17 19 20 22 23 QC never pages in 2 and 5; the other pages but 0, the overlay pages, #D1 and the code page are the Copy and Move buffer, 64 sectors each. On 128K (and started with W held) #D1 and the code page are the buffer's (the buffer is 1 and 7, 128 sectors), and there is no resident. Page 0: from #C000 QC's code (its third part), from #E700 the sector where QC reads a catalogue's first and info sectors to check the disk before a write; the panels' places, 3K each: the catalogue (9 sectors), the other panel's from #E800, the active one's from #F400, and a sector each of the marks, the 9th and 10th characters of a tape's names and the SD card's folder, the active panel's from #F100, the other's from #FD00. The catalogue of a disk put in during a one-drive Copy (and M's new catalogue) is at #B700. 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 modules are unpacked in place once, the .qco's header and the streams 48K has lie at places of their own from #7D00 and (the SD card's panel) from #E700; from #F100 the check sector and one panel's place. Quick Doctor's check of a FAT volume keeps its map of the clusters (a bit each) in the main memory and, on 128K, for a volume past it, in pages 1 and 7, then 3, 4 and 6 (#7FFD alone), as many as the volume needs; with the code page at #17 (Scorpion, Profi, ATM) in none. Their bytes are not kept: on 128K QC then reads its .qco again at the start. :: 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/QC/QC.OVR. Its header: +0 "QCO" +3 QC's version, 4 characters: "4.10", the betas' "410a" (b1), "410b" (b2)... +7 the build's stamp (a word) +9 the stream count N +10 4 bytes a stream: its offset in the file, its sum (each byte added to the low byte, then the two bytes exchanged) +10+4N the offset of the last stream's end +12+4N a byte a stream: its library's number (#FF none, #FE a module) +12+5N the build's data: the SD card's panel's line 23 rows 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. The streams go as 48K reads them first, then the rest: stream what library 0 Directory TR-DOS's catalogue - 1 Disk the drive - 2 MediaLibrary the media's common - 3 TrdosLibrary TR-DOS's common 2 4 TrdosReader TR-DOS: reading, P, U 3 5 StartTail the start's tail - 6 TapeLibrary a tape's blocks 2 7 FoldersLibrary 10's and 12's common 2 8 ImageLibrary 9's and 34's common 6 9 Image images and the tape 8 10 FoldersReader the SD card's panel 7 11 EsxLong the adapter's module - 12 FoldersWriteLibrary the card's Copy 7 13 RareKeys the rare keys - 14 FoldersWriter the card's P and U 12 15 TrdosWriter TR-DOS: commands 3 16 FoldersCommands the card's commands 12 17 Fat QC's own FAT - 18 StreamLibrary P's and U's streams - 19 PagesLibrary a file through pages 18 20 Help the help - 21 Picture pictures - 22 Prepare unpacking, U 19 23 ViewerLibrary the viewers' common 19 24 TextLibrary the text viewer 23 25 Text UTF-8 24 26 Dump the hex dump 24 27 QcoReader the .qco's reader - 28 Packer the packer (P) 18 29 Sprite sprites 23 30 Esx esxDOS's card - 31 Sd the SD card (SPI) - 32 Probe the FAT's probe - 33 Gotek the Gotek's stick - 34 ImageWriter a tape written 8 35 TrdosCommands TR-DOS: r and R 3 36 GotekKeys the Gotek's keys - 37 Plugins the plugins - 38 Convert ALASM sources 19 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. Streams 0, 1, 11, 17 and 30-33 are modules (library #FE), unpacked at their own addresses. Without streams 0-5 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 works with what is whole. On 48K QC reads the header and streams 0-5, under esxDOS 0-10, in the file's order to places of their own (the tape's first blocks are those pieces of the file); 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.9 or later 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. Older esxDOS versions are unsupported and may fail to work. 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). On esxDOS 0.8.9 and 0.9.0 (128K and more) QC reads and writes the card's FAT itself by esxDOS's sector calls, RST 8 #81 and #82 (A the device, BCDE the sector, IX 512 bytes), keeping esxDOS's caches and free count in step; an NMI served amid it gives "Error.". Files opened, programs, images and the tape go through esxDOS. Other versions and 48K: esxDOS's file calls alone. 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 is a starter: it moves itself to #A400, clears its own "QC" at #6002, reads /SYS/QC/QC.BIN to #6000 (F_OPEN "$", F_READ of #4400 bytes at most, F_CLOSE), pages DivMMC bank 3 in (OUT (#E3),3), checks "QC", the contract's version and the file whole (its length even, its sum 0: see the ROM's loader below) and jumps to #6000; with no file (or folder) or not QC's or not whole it prints "No QC in /SYS/QC" and goes to the emulation's command line (#3D00). QC.BIN (#4400 bytes at most) is the contract (22 bytes) and the boot, then from +#46 the system variables and the BASIC loader (from +#181), then from +#299 QC.C to its last sector's end, then a 0 if its length is odd and two bytes that make its sum 0 (its bytes at even places, and those at odd ones, each summed mod 256; Quick Setup writes them anew with the settings, the ROM's loader, the starter and .qc refuse a QC.BIN changed by hand): the boot pages #D1 in, copies QC.C to #C000 and the variables to #5C00 and starts QC as the loader on a disk does. Quick Setup enables T, A, I and N in M if M_DOSVERSION gives #0890 or higher. Below #0900 (0.8.9 loses a new file in a FAT folder whose clusters hold no free entry) it first reads the target folders by the sector call (#81) and refuses one with neither an end mark nor enough erased entries in its clusters (Directory full.). On 128K M loads that check into page 1 before an image in Quick Setup's drive can change; on 48K N reads it from Quick Setup's disk. The overlays are /SYS/QC/QC.OVR. Quick Setup makes /SYS/QC (F_MKDIR) and writes the starter and /BIN/QC (F_OPEN, F_SEEK, F_READ, F_WRITE) from QC's files on its disk, with the settings of the QC that was there. It renames another boot to TRDBOOT.NAV (F_RENAME) and removes the old /SYS/TRDBOOT.OVR (F_UNLINK). It writes QC.BIN and QC.OVR as NEW.BIN and NEW.OVR before replacing the old pair (F_UNLINK, F_RENAME). If there is no room for both, it writes in place. The starter has "QC starter" at +2, past its first JR: by it Quick Setup tells QC as the images' boot (item I removes the starter by F_UNLINK and renames TRDBOOT.NAV back, or writes it, another boot renamed TRDBOOT.NAV first). The dot command .qc (/BIN/QC) loads /SYS/QC/QC.BIN at #6000 and runs it if it is whole (as the starter checks it) and the 11 bytes of its boot are as this build's QC.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 QC.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 Z-Controller's card and the Gotek's stick The Z-Controller's SD card (128K and more, no esxDOS needed): ports #77 (bit 0 the card's power, bit 1 its select, 0 selected) and #57 (data), SPI, a block of 512 bytes a command; SD, SDHC and SDXC. QC reads and writes FAT12, FAT16 and FAT32 itself, with long names: the volume in the card's block 0, else in the first MBR partition that holds one; QC's files in /SYS/QC. The Gotek's USB stick (FlashFloppy's Direct Access; 128K and more, not under esxDOS): with an image chosen QC steps the drive's head to cylinder 255; sector 0 there read is the state ("HxCFEDA"), written a command: CMD_SET_LBA (a window of the stick's blocks from that one, 1 to 8, in sectors 1-8; the track as long as the window), CMD_SELECT_NAME (an image put in), CMD_SET_CYL 0 as QC leaves (the firmware mounts its image again). The drive found: CMOS cell #0F. The stick's images. A TRD of the stick's root goes in as it is; a folder's, an SCL's disk and a card's image go in a copy in the stick's root, and /QC_TMP.CFG there names the copy and its way back. QC runs a program from the Gotek with "Q" and the drive (0-3) in TR-DOS's unused #5D0A-#5D0B; QC's next start with them, or its next mount, offers to put the copy back. :: 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's loader 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) takes it once. The loader is the ROM's (see the next section) built for the cache, kept in Quick Setup's file past its code and checked by its Fletcher-16: #0000 DI, JP #0068 (Gluk's Reset Service enters the shadow RAM at 0), #0066 JR #0068 (the NMI entry), from #0068 the loader, then zeros. Magic must give an NMI with the shadow RAM in. The loader works as the ROM's and ends from the RAM, at #A637: IN A,(#7B) turns the shadow RAM off, then JP #6000, or JP #0000 (a reset) on a failure or with Caps shift held. Quick Setup puts the Gotek's drive of item C's step into the loader's byte the ROM images differ in (see the next section). :: The ROM's loader, the snapshot and the tape QC_basic128.rom (16K) is the Pentagon's Basic 128 bank with QC's loader in its RS232's, COPY's, PLAY's and MIDI output's code, #06D8-#11EA (their entries RET, #06D8 XOR A: RET), the reset's JP at #0009 to it (#0A06). Caps shift held (at the reset, before the Gotek, at a block's read): the 128's own start, #00C7, as any failure. The loader clears the screen, white on black, prints its lines in ROM 1's font, starts the Z-Controller's card (#77, #57), finds FAT16 or FAT32 (block 0, else the first fitting one of the four MBR partitions), reads /SYS/QC/QC.BIN to #6000 (34 blocks at most; its length, its entry's, even and its sum 0, else refused) and checks its contract: #6000 a JR past it, #6002 "QC", #6004 the version, 2, #6005 QC's mark for TR-DOS's variables #5D0A, the medium's ("Z" the Z-Controller's card, "Q" the Gotek's stick; 0 in the file), #6006 the medium (the loader writes 1 for the Z-Controller's card, 2-5 for the Gotek's stick in drive A-D), #6007 the second file's name in the same folder as a FAT entry has it (QC.OVR's), #6012 the #7FFD values of its pages, 16K each, 0 their end; it reads that file into them with bit 4 of #7FFD 0 and jumps to #6000. #A400-#BFFF its RAM. QC starts as from the starter (LaunchedFrom 1), its overlays whole in the pages. QC_basic128_gotekA.rom and QC_basic128_gotekB.rom differ from it in one byte, the Gotek's drive (#FF none, 0 A, 1 B). With the card refused they read the same files from the Gotek's USB stick by FlashFloppy's Direct Access: the drive selected, #D0, the controller's seek from cylinder 0 to 255 (255 steps of 6 ms), sector 0 its state; then CMD_SET_LBA windows of a block (a FAT's sector, a folder's) or of a cluster's blocks, 8 at most, read in sectors 1-8. The controller through the TR-DOS ROM's pieces (#2A53, #3FD5 and #3FBA with a time-out for the first byte, #3FE5) with ROM 1 in, from the driver's copy at #A63C; no piece turns the interrupts on. No answer, another drive: the head restored, #00C7. The loader leaves the stick in Direct Access (no CMD_SET_CYL 0) and QC.BIN's boot puts #6005's mark and the drive (#FF: the card's) into TR-DOS's unused #5D0A-#5D0B: started so (LaunchedFrom 1), QC opens the medium's panel first, the card's or the stick's, the other panel the same medium's (the output drive not asked), its drive taken in Direct Access with no steps, the image put back first if the stick has QC_TMP.CFG. Quick Setup's Z and G write QC.BIN and QC.OVR in /SYS/QC of the Z-Controller's card and of the Gotek's stick (FAT16 or FAT32, as the loader reads) by QC's own FAT driver, a block of Quick Setup's file read to #C000 in page 0; G selects the Gotek's drive through TR-DOS first and leaves Direct Access (CMD_SET_CYL 0) after the stick's reads and writes. The snapshot QC_4_10.sna is a 128K SNA: QC.BIN at #6000, the whole .qco in pages 6, 4, 3, PC #A400, 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 QC.BIN's boot. After a reset the machine's own ROM runs. The tape QC_4_10.tap: the program with an autostart: line 10 (a REM) a probe for TR-DOS (entry 15619, as in z88dk) and, on a 128K, for a Z-Controller's card, line 20 CLEAR 41983: LET a=USR the probe, line 30 with none of them a message and STOP, line 40 CLEAR 24575: LOAD ""CODE: POKE 25236,2+PEEK 41984: RANDOMIZE USR 24576 (the POKE: FromTape in LaunchedFrom, with no TR-DOS FromBare); code at #6000 (QC.BIN), then headerless blocks, the .qco's own bytes: its first page in 48K's pieces (the header, the modules' streams, MediaLibrary..StartTail, TapeLibrary with FoldersLibrary, ImageLibrary with Image, FoldersReader) and the page's rest, then 16K each (the last one shorter). QC reads the blocks itself as it starts (overlay.Tape; LD_BYTES, #0556), before a disk is read: on 48K the header and the pieces it needs, two (five under esxDOS), each stream to its place; else each block to its place in 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, a Gotek's stick its drive's, 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, by the starter and .qc, a tape or by Magic; CONFIG is taken from #15 only if its bit 5 is 1. Cell #0F: the drive a Gotek was found on, #A4 with the drive (0-3) in bits 0-1 (written as the Gotek answers, cleared when it answers no more), read at every start. 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: QC plays no music itself (the plugins do: the kit's _PT, 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 written every frame, 13 only when changed; its meters read registers 0-5 and 8-10). At start QC silences both AYs: mixer #FF, volumes 0. The music plugins' order of the channels (ABC, ACB or BAC: TXTMODE bits 4-5) and looping (CONFIG bit 6) are QC's settings. :: The settings in QC's file The file "QC 4.10" (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). The same loader, the settings at the same offset from its line, is in QC.BIN (from +#181) and in the code page (#FE80). 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 plugins' C: 0 - ABC, 1 - ACB, ; 2 - BAC. ;6-7: not used. TXTMODE DB %00000100 ;#1A SET_VER DB 3 ;#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, 3 (2 in QC 4.00-4.01, 1 in 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 sum of QC.C in page #D1 (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), checks QC.C in page #D1 by its sum, unpacks it to #6000 and starts QC; with QC.C spoilt it wipes the mark and goes to TR-DOS as below. 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 in page #D7 the launcher (#C000-#C0FF) and the start's cells, the kept variables and the mark (#FD00-#FFFF) intact, and page #D1 (QC.C) whole. On Scorpion, Profi, ATM and ZX-Evolution #D7 is page 7, the second screen (#C000-#DAFF), and #D1 is page 1. QC 4.00 and 4.01 kept QC.C in page #D7: a program that keeps #D7 alone and spoils #D1 goes back to them, but not to QC 4.10: it ends in TR-DOS. A program run in 48K mode can't return: #7FFD is locked. Before a run QC writes LaunchedFrom = 2 (#FD41), the cursor's file number + 1 (#FD42), CONFIG (#FD43) and the input medium (#FD44, the codes as in CMOS cell #10) into page #D7; the launcher puts them back at #5E4E-#5E51. 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, by the starter, .qc or by Magic, 2 back from a program (and .qc NAME), 3 from a tape, 4 from a tape with no TR-DOS. :: 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. :: Plugins A plugin is a program QC runs on Enter on a file (128K and more). QC looks for /SYS/QC/PLUGINS on esxDOS's card, the Z-Controller's card and the Gotek's stick, in that order, and takes the first folder found. A plugin's name says which files it takes: an extension (on FAT the short name's three characters: PHOTO.JPEG goes to JPE; on a TR-DOS disk three characters when the type and the start spell them, else the type, its letter in either case; X_Y, a packed file of type Y, is X_) or a length in decimal up to 65535, letters in either case. Each ! past the key raises its priority: PT3! goes before 6976, 6976 before PT3. An empty file KEY.PLG is a link: the files its name takes go to the plugin its extension names (PT3._PT sends .pt3 to _PT; the name of a plugin reached by links alone is "_" and two letters, no extension of a file and no key). The sources of the kit's plugins, plugin.asm with the names below and README.md are in esxdos/SYS/QC/src. With no folder on any of them QC looks for QPLUGINS.SCL (letters in either case) in the directory of the active panel's drive, then the other one's, and takes the plugins from it: a plugin is a file of type " " (start #8000), a link a file of no sectors whose type and start name the plugin (PT3 with "_PT"). QC's disk has one; copy it to another disk as it is. A plugin's file is an image loaded at #8000: +0 "QCP", +3 interface version (QC 4.10 requires 0), +4 flags, +5 a word with the memory it needs from #8000 (code, data and stack; at most 16128 bytes). The entry is #8007. QC swaps the declared memory and its 256-byte fast resident. With 8960 bytes or less, QC keeps its screen in memory and returns faster. Flag bit 4 says the plugin's screen covers QC's panels (a picture). Without the screen's copy QC then draws the panels again whole; with bit 4 clear only what a player's screen takes: columns 24..31 of lines 19..21, lines 22 and 23. With flag bit 0 set, the disk header has a zero size word. Its bits 1..7 come from the original header. The rest is the whole image including its header, packed with forward ZX0 v2. In-place unpacking must fit in the first 8960 bytes. On entry the file's first 16K (or all of it) is at #C000, SP at the end of the plugin's memory with #5B80 on it, interrupts on in IM 1, the BASIC 48 ROM in, IY = #5C3A. IX points to the file's name (8 bytes), extension (3) and length (3 bytes, #FFFFFF from 16M); +14 is 1 when the file is on esxDOS's card in esxDOS's current folder (the plugin may open it by RST 8 with the name in IX, port #E3 left alone), 2 when the file is in the plugin's pages already (reason 6's data: its 16K k in page k), +15 the #7FFD value paging the file's 16K in (0 where #7FFD alone can't: Scorpion, Profi, ATM, ZX Evolution). The plugin may use its memory, the screen and #C000-#DAFF of page 7. What it borrows of QC's #5B00-#7FFF and #BF00-#BFFF (#5B00-#5CFF with interrupts off) it puts back before it calls QC or ends; with #5B00-#5BFF and #7F00-#7FFF back first, functions 0 and 1 work. QC's fixed points: #5B80 the end (a RET comes there), #5B81 the end with the reason in A, #5B84 function A (parameters in HL, DE, BC), #5B87 value A to HL, #5B8A value A from HL. On error they give CF = 1 and the code in A: 1 unknown function, value or access direction, 2 wrong parameter, 3 QC's memory is taken, 20 read failed or the medium cannot be read here, 21 past the end or the file is already in the plugin's pages. FnPrint may change BC' and DE'. Other fast calls preserve the shadow registers. Slow calls may change all four pairs. Reserved codes on the slow path return ErrUnknown. Functions: 0 the plugin's page L at #C000 (0 the file's 16K, 1 and on free pages), 1 page 7 at #C000, 2 the main screen shown, 3 the second one, 4 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 B characters from HL at line D, x E in pixels, in QC's font (HL past them), 20 BC bytes (1..65535) from block HL of 256 bytes. D below #80 reads consecutive pages from D at #C000 and leaves the last selected. From #80 it reads at D*256 and keeps the page. The whole request must fit the pages or the declared memory. BC returns bytes read, HL the next block. The last block is padded with zeros at EOF. Function 4 spoils BC, DE and HL, 5 BC. Function 20 and Get 10 and 20 swap the plugin out and back, set IM 1 and spoil BC, DE and HL except for the results. Values: 0 Get the interface version (0), 1 Put the address of the plugin's error text, 2 Get the page count (1 at least), 10 Get controls in L (1 Kempston mouse, 2 its buttons swapped, 4 key click on; H = 0), 20 Get the long name (QC's own FAT) in 256 bytes at HL, ending in 0 (HL its length, 0 none), 30 Get/Put music settings (#40 no looping, #30 channel order: 0 ABC, #10 ACB, #20 BAC; #02 fast). See plugin.asm for reserved codes. RET ends the plugin. JP #5B81 with A = 1 says "not mine": QC tries the next plugin, then opens the file itself; A = 2 asks for the next file, as Enter in the viewers; A = 4 an error: value 1's text (up to 50 characters, ended by 0 or by a character with bit 7), else QC's own for the last error's code, shown on line 23 till a key; A = 5: the file is a text, QC shows it in its text viewer as V does; A = 6: the data in the plugin's pages are a file of another kind (its 16K k in page k, the first at #C000), the extension (3 characters) and the length (16K a page, 65535 at most) the plugin wrote in its block: QC runs the plugins again for them, the pages kept (3 times a chain at most), +14 then 2, FnRead ErrEnd. 3 is reserved, an unknown reason ends the plugin. Back, QC sets IM 1 and I = #3F, puts its screen back, then sets the border black. :: 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. 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 Quick Doctor; 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. 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; QC shows the screen, not the border. .img: two 6912-byte screens; QC shows the first. 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. ALASM 4.x: H at #08, eight bytes at #28 sum to #80. Convert shows a source up to 16K as coloured text. Music: the kit's plugin _PT plays Pro Tracker 3 and Vortex Tracker II modules (PT3; .vt2 too, Vortex Tracker's text module is the text viewer's) and Pro Tracker 2 (PT2) by Sergey Bulba's PTSPlay (release 0), the file's first 16K the module (a PT2 one by its extension .pt2). A PT3 module's 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. 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 past 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, 32K on 128K), i.e. up to 58012 bytes (28885). 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. ° °ІЬЬЬЬЬ Ь І ІЯ ЯЯЯІЬЬЬЬЬ ЯІЫЬ ЯЯЯЫЫЫЫІЬЬЬЬ І ЫЫІЫЫЬЬЬ І° ° ЯЯЯЯ±ЯЫІЬ ЯЯЯЯЫЫІЫЫЬЬЬ І° °ЯЯЯІЫЫЫІЬЫ± ° ± Я° °ЯЯЯІЫЫЫІЬЫ± ° ЯЯЫ ° ° ° ЯЯЫ °